@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | function geodir_deactivation() |
| 16 | 16 | {
|
| 17 | 17 | |
| 18 | - // Update installed variable |
|
| 19 | - update_option("geodir_installed", 0);
|
|
| 18 | + // Update installed variable |
|
| 19 | + update_option("geodir_installed", 0);
|
|
| 20 | 20 | |
| 21 | - // Remove rewrite rules and then recreate rewrite rules. |
|
| 22 | - flush_rewrite_rules(); |
|
| 21 | + // Remove rewrite rules and then recreate rewrite rules. |
|
| 22 | + flush_rewrite_rules(); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -32,124 +32,124 @@ discard block |
||
| 32 | 32 | function geodir_uninstall() |
| 33 | 33 | {
|
| 34 | 34 | |
| 35 | - delete_option('geodir_default_data_installed');
|
|
| 35 | + delete_option('geodir_default_data_installed');
|
|
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | if (!function_exists('geodir_admin_styles')) {
|
| 40 | - /** |
|
| 41 | - * Enqueue Admin Styles. |
|
| 42 | - * |
|
| 43 | - * @since 1.0.0 |
|
| 44 | - * @package GeoDirectory |
|
| 45 | - */ |
|
| 46 | - function geodir_admin_styles() |
|
| 47 | - {
|
|
| 40 | + /** |
|
| 41 | + * Enqueue Admin Styles. |
|
| 42 | + * |
|
| 43 | + * @since 1.0.0 |
|
| 44 | + * @package GeoDirectory |
|
| 45 | + */ |
|
| 46 | + function geodir_admin_styles() |
|
| 47 | + {
|
|
| 48 | 48 | |
| 49 | - wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
|
|
| 50 | - wp_enqueue_style('geodirectory-admin-css');
|
|
| 49 | + wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
|
|
| 50 | + wp_enqueue_style('geodirectory-admin-css');
|
|
| 51 | 51 | |
| 52 | - wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
|
|
| 53 | - wp_enqueue_style('geodirectory-frontend-style');
|
|
| 52 | + wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
|
|
| 53 | + wp_enqueue_style('geodirectory-frontend-style');
|
|
| 54 | 54 | |
| 55 | - wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
|
|
| 56 | - wp_enqueue_style('geodir-chosen-style');
|
|
| 55 | + wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
|
|
| 56 | + wp_enqueue_style('geodir-chosen-style');
|
|
| 57 | 57 | |
| 58 | - wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
|
|
| 59 | - wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
|
|
| 58 | + wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
|
|
| 59 | + wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
|
|
| 60 | 60 | |
| 61 | - wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
|
|
| 62 | - wp_enqueue_style('geodirectory-jquery-ui-css');
|
|
| 61 | + wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
|
|
| 62 | + wp_enqueue_style('geodirectory-jquery-ui-css');
|
|
| 63 | 63 | |
| 64 | - wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
|
|
| 65 | - wp_enqueue_style('geodirectory-custom-fields-css');
|
|
| 64 | + wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
|
|
| 65 | + wp_enqueue_style('geodirectory-custom-fields-css');
|
|
| 66 | 66 | |
| 67 | - wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
|
|
| 68 | - wp_enqueue_style('geodirectory-pluplodar-css');
|
|
| 67 | + wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
|
|
| 68 | + wp_enqueue_style('geodirectory-pluplodar-css');
|
|
| 69 | 69 | |
| 70 | - wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
|
|
| 71 | - wp_enqueue_style('geodir-rating-style');
|
|
| 70 | + wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
|
|
| 71 | + wp_enqueue_style('geodir-rating-style');
|
|
| 72 | 72 | |
| 73 | - wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
|
|
| 74 | - wp_enqueue_style('geodir-rtl-style');
|
|
| 73 | + wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
|
|
| 74 | + wp_enqueue_style('geodir-rtl-style');
|
|
| 75 | 75 | |
| 76 | - } |
|
| 76 | + } |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | if (!function_exists('geodir_admin_styles_req')) {
|
| 80 | - /** |
|
| 81 | - * Loads stylesheets from CDN. |
|
| 82 | - * |
|
| 83 | - * @since 1.0.0 |
|
| 84 | - * @package GeoDirectory |
|
| 85 | - */ |
|
| 86 | - function geodir_admin_styles_req() |
|
| 87 | - {
|
|
| 80 | + /** |
|
| 81 | + * Loads stylesheets from CDN. |
|
| 82 | + * |
|
| 83 | + * @since 1.0.0 |
|
| 84 | + * @package GeoDirectory |
|
| 85 | + */ |
|
| 86 | + function geodir_admin_styles_req() |
|
| 87 | + {
|
|
| 88 | 88 | |
| 89 | - wp_register_style('geodirectory-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
|
|
| 90 | - wp_enqueue_style('geodirectory-font-awesome');
|
|
| 89 | + wp_register_style('geodirectory-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
|
|
| 90 | + wp_enqueue_style('geodirectory-font-awesome');
|
|
| 91 | 91 | |
| 92 | - wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 93 | - wp_enqueue_script('geodirectory-admin');
|
|
| 92 | + wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 93 | + wp_enqueue_script('geodirectory-admin');
|
|
| 94 | 94 | |
| 95 | - } |
|
| 95 | + } |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | if (!function_exists('geodir_admin_scripts')) {
|
| 99 | - /** |
|
| 100 | - * Enqueue Admin Scripts. |
|
| 101 | - * |
|
| 102 | - * @since 1.0.0 |
|
| 103 | - * @package GeoDirectory |
|
| 104 | - */ |
|
| 105 | - function geodir_admin_scripts() |
|
| 106 | - {
|
|
| 107 | - $geodir_map_name = geodir_map_name(); |
|
| 99 | + /** |
|
| 100 | + * Enqueue Admin Scripts. |
|
| 101 | + * |
|
| 102 | + * @since 1.0.0 |
|
| 103 | + * @package GeoDirectory |
|
| 104 | + */ |
|
| 105 | + function geodir_admin_scripts() |
|
| 106 | + {
|
|
| 107 | + $geodir_map_name = geodir_map_name(); |
|
| 108 | 108 | |
| 109 | - wp_enqueue_script('jquery');
|
|
| 109 | + wp_enqueue_script('jquery');
|
|
| 110 | 110 | |
| 111 | - 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);
|
|
| 111 | + 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);
|
|
| 112 | 112 | |
| 113 | - wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 114 | - wp_enqueue_script('chosen');
|
|
| 113 | + wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 114 | + wp_enqueue_script('chosen');
|
|
| 115 | 115 | |
| 116 | - wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
|
|
| 117 | - wp_enqueue_script('geodirectory-choose-ajax');
|
|
| 116 | + wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
|
|
| 117 | + wp_enqueue_script('geodirectory-choose-ajax');
|
|
| 118 | 118 | |
| 119 | - if (isset($_REQUEST['listing_type'])) {
|
|
| 120 | - wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
|
|
| 121 | - } |
|
| 119 | + if (isset($_REQUEST['listing_type'])) {
|
|
| 120 | + wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
|
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - wp_enqueue_script('geodirectory-custom-fields-script');
|
|
| 124 | - $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
| 123 | + wp_enqueue_script('geodirectory-custom-fields-script');
|
|
| 124 | + $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
| 125 | 125 | |
| 126 | - wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
|
|
| 126 | + wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
|
|
| 127 | 127 | |
| 128 | - if (in_array($geodir_map_name, array('auto', 'google'))) {
|
|
| 129 | - $map_lang = "&language=" . geodir_get_map_default_language(); |
|
| 130 | - /** This filter is documented in geodirectory_template_tags.php */ |
|
| 131 | - $map_extra = apply_filters('geodir_googlemap_script_extra', '');
|
|
| 132 | - wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
|
|
| 133 | - } |
|
| 128 | + if (in_array($geodir_map_name, array('auto', 'google'))) {
|
|
| 129 | + $map_lang = "&language=" . geodir_get_map_default_language(); |
|
| 130 | + /** This filter is documented in geodirectory_template_tags.php */ |
|
| 131 | + $map_extra = apply_filters('geodir_googlemap_script_extra', '');
|
|
| 132 | + wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
|
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - if ($geodir_map_name == 'osm') {
|
|
| 136 | - // Leaflet OpenStreetMap |
|
| 137 | - wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 138 | - wp_enqueue_style('geodirectory-leaflet-style');
|
|
| 135 | + if ($geodir_map_name == 'osm') {
|
|
| 136 | + // Leaflet OpenStreetMap |
|
| 137 | + wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 138 | + wp_enqueue_style('geodirectory-leaflet-style');
|
|
| 139 | 139 | |
| 140 | - wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 141 | - wp_enqueue_script('geodirectory-leaflet-script');
|
|
| 140 | + wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 141 | + wp_enqueue_script('geodirectory-leaflet-script');
|
|
| 142 | 142 | |
| 143 | - wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
|
|
| 144 | - wp_enqueue_script('geodirectory-leaflet-geo-script');
|
|
| 145 | - } |
|
| 146 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 143 | + wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
|
|
| 144 | + wp_enqueue_script('geodirectory-leaflet-geo-script');
|
|
| 145 | + } |
|
| 146 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 147 | 147 | |
| 148 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 149 | - wp_enqueue_script('geodirectory-goMap-script');
|
|
| 148 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 149 | + wp_enqueue_script('geodirectory-goMap-script');
|
|
| 150 | 150 | |
| 151 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 152 | - wp_enqueue_script('geodirectory-goMap-script');
|
|
| 151 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 152 | + wp_enqueue_script('geodirectory-goMap-script');
|
|
| 153 | 153 | |
| 154 | 154 | // font awesome rating script |
| 155 | 155 | if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
@@ -160,167 +160,167 @@ discard block |
||
| 160 | 160 | wp_enqueue_script('geodir-jRating-js');
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
|
|
| 164 | - wp_enqueue_script('geodir-on-document-load');
|
|
| 165 | - |
|
| 166 | - |
|
| 167 | - // SCRIPT FOR UPLOAD |
|
| 168 | - wp_enqueue_script('plupload-all');
|
|
| 169 | - wp_enqueue_script('jquery-ui-sortable');
|
|
| 170 | - |
|
| 171 | - wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 172 | - wp_enqueue_script('geodirectory-plupload-script');
|
|
| 173 | - |
|
| 174 | - // SCRIPT FOR UPLOAD END |
|
| 175 | - |
|
| 176 | - |
|
| 177 | - // place js config array for plupload |
|
| 178 | - $plupload_init = array( |
|
| 179 | - 'runtimes' => 'html5,silverlight,flash,html4', |
|
| 180 | - 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
| 181 | - 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
| 182 | - 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
| 183 | - 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
| 184 | - 'multiple_queues' => true, |
|
| 185 | - 'max_file_size' => geodir_max_upload_size(), |
|
| 186 | - 'url' => admin_url('admin-ajax.php'),
|
|
| 187 | - 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
|
| 188 | - 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
|
| 189 | - 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
|
|
| 190 | - 'multipart' => true, |
|
| 191 | - 'urlstream_upload' => true, |
|
| 192 | - 'multi_selection' => false, // will be added per uploader |
|
| 193 | - // additional post data to send to our ajax hook |
|
| 194 | - 'multipart_params' => array( |
|
| 195 | - '_ajax_nonce' => "", // will be added per uploader |
|
| 196 | - 'action' => 'plupload_action', // the ajax action name |
|
| 197 | - 'imgid' => 0 // will be added per uploader |
|
| 198 | - ) |
|
| 199 | - ); |
|
| 200 | - $base_plupload_config = json_encode($plupload_init); |
|
| 201 | - |
|
| 202 | - |
|
| 203 | - $thumb_img_arr = array(); |
|
| 204 | - |
|
| 205 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 206 | - $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 207 | - |
|
| 208 | - $totImg = ''; |
|
| 209 | - $image_limit = ''; |
|
| 210 | - if (!empty($thumb_img_arr)) {
|
|
| 211 | - $totImg = count($thumb_img_arr); |
|
| 212 | - } |
|
| 163 | + wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
|
|
| 164 | + wp_enqueue_script('geodir-on-document-load');
|
|
| 165 | + |
|
| 166 | + |
|
| 167 | + // SCRIPT FOR UPLOAD |
|
| 168 | + wp_enqueue_script('plupload-all');
|
|
| 169 | + wp_enqueue_script('jquery-ui-sortable');
|
|
| 170 | + |
|
| 171 | + wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 172 | + wp_enqueue_script('geodirectory-plupload-script');
|
|
| 173 | + |
|
| 174 | + // SCRIPT FOR UPLOAD END |
|
| 175 | + |
|
| 176 | + |
|
| 177 | + // place js config array for plupload |
|
| 178 | + $plupload_init = array( |
|
| 179 | + 'runtimes' => 'html5,silverlight,flash,html4', |
|
| 180 | + 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
| 181 | + 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
| 182 | + 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
| 183 | + 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
| 184 | + 'multiple_queues' => true, |
|
| 185 | + 'max_file_size' => geodir_max_upload_size(), |
|
| 186 | + 'url' => admin_url('admin-ajax.php'),
|
|
| 187 | + 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
|
| 188 | + 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
|
| 189 | + 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
|
|
| 190 | + 'multipart' => true, |
|
| 191 | + 'urlstream_upload' => true, |
|
| 192 | + 'multi_selection' => false, // will be added per uploader |
|
| 193 | + // additional post data to send to our ajax hook |
|
| 194 | + 'multipart_params' => array( |
|
| 195 | + '_ajax_nonce' => "", // will be added per uploader |
|
| 196 | + 'action' => 'plupload_action', // the ajax action name |
|
| 197 | + 'imgid' => 0 // will be added per uploader |
|
| 198 | + ) |
|
| 199 | + ); |
|
| 200 | + $base_plupload_config = json_encode($plupload_init); |
|
| 201 | + |
|
| 202 | + |
|
| 203 | + $thumb_img_arr = array(); |
|
| 204 | + |
|
| 205 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 206 | + $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 207 | + |
|
| 208 | + $totImg = ''; |
|
| 209 | + $image_limit = ''; |
|
| 210 | + if (!empty($thumb_img_arr)) {
|
|
| 211 | + $totImg = count($thumb_img_arr); |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
|
|
| 215 | - 'totalImg' => $totImg, |
|
| 216 | - 'image_limit' => $image_limit, |
|
| 217 | - 'upload_img_size' => geodir_max_upload_size()); |
|
| 214 | + $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
|
|
| 215 | + 'totalImg' => $totImg, |
|
| 216 | + 'image_limit' => $image_limit, |
|
| 217 | + 'upload_img_size' => geodir_max_upload_size()); |
|
| 218 | 218 | |
| 219 | - wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
|
|
| 219 | + wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
|
|
| 220 | 220 | |
| 221 | - $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
|
|
| 222 | - wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
|
|
| 221 | + $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
|
|
| 222 | + wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
|
|
| 223 | 223 | |
| 224 | 224 | |
| 225 | - wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 226 | - wp_enqueue_script('geodirectory-admin-script');
|
|
| 225 | + wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 226 | + wp_enqueue_script('geodirectory-admin-script');
|
|
| 227 | 227 | |
| 228 | - wp_enqueue_style('farbtastic');
|
|
| 229 | - wp_enqueue_script('farbtastic');
|
|
| 228 | + wp_enqueue_style('farbtastic');
|
|
| 229 | + wp_enqueue_script('farbtastic');
|
|
| 230 | 230 | |
| 231 | - $screen = get_current_screen(); |
|
| 232 | - if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
|
|
| 233 | - wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 234 | - } |
|
| 231 | + $screen = get_current_screen(); |
|
| 232 | + if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
|
|
| 233 | + wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - $ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
|
|
| 237 | - wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
|
|
| 236 | + $ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
|
|
| 237 | + wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
|
|
| 238 | 238 | |
| 239 | - } |
|
| 239 | + } |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | if (!function_exists('geodir_admin_menu')) {
|
| 243 | - /** |
|
| 244 | - * Admin Menus |
|
| 245 | - * |
|
| 246 | - * Sets up the admin menus in wordpress. |
|
| 247 | - * |
|
| 248 | - * @since 1.0.0 |
|
| 249 | - * @package GeoDirectory |
|
| 250 | - * @global array $menu Menu array. |
|
| 251 | - * @global object $geodirectory GeoDirectory plugin object. |
|
| 252 | - */ |
|
| 253 | - function geodir_admin_menu() |
|
| 254 | - {
|
|
| 255 | - global $menu, $geodirectory; |
|
| 243 | + /** |
|
| 244 | + * Admin Menus |
|
| 245 | + * |
|
| 246 | + * Sets up the admin menus in wordpress. |
|
| 247 | + * |
|
| 248 | + * @since 1.0.0 |
|
| 249 | + * @package GeoDirectory |
|
| 250 | + * @global array $menu Menu array. |
|
| 251 | + * @global object $geodirectory GeoDirectory plugin object. |
|
| 252 | + */ |
|
| 253 | + function geodir_admin_menu() |
|
| 254 | + {
|
|
| 255 | + global $menu, $geodirectory; |
|
| 256 | 256 | |
| 257 | - if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
|
| 257 | + if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
|
| 258 | 258 | |
| 259 | - add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 259 | + add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 260 | 260 | |
| 261 | 261 | |
| 262 | - } |
|
| 262 | + } |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | if (!function_exists('geodir_admin_menu_order')) {
|
| 266 | - /** |
|
| 267 | - * Order admin menus. |
|
| 268 | - * |
|
| 269 | - * @since 1.0.0 |
|
| 270 | - * @package GeoDirectory |
|
| 271 | - * @param array $menu_order Menu order array. |
|
| 272 | - * @return array Modified menu order array. |
|
| 273 | - */ |
|
| 274 | - function geodir_admin_menu_order($menu_order) |
|
| 275 | - {
|
|
| 276 | - |
|
| 277 | - // Initialize our custom order array |
|
| 278 | - $geodir_menu_order = array(); |
|
| 279 | - |
|
| 280 | - // Get the index of our custom separator |
|
| 281 | - $geodir_separator = array_search('separator-geodirectory', $menu_order);
|
|
| 282 | - |
|
| 283 | - // Get index of posttype menu |
|
| 284 | - $post_types = geodir_get_posttypes(); |
|
| 285 | - |
|
| 286 | - // Loop through menu order and do some rearranging |
|
| 287 | - foreach ($menu_order as $index => $item) : |
|
| 288 | - |
|
| 289 | - if ((('geodirectory') == $item)) :
|
|
| 290 | - $geodir_menu_order[] = 'separator-geodirectory'; |
|
| 291 | - if (!empty($post_types)) {
|
|
| 292 | - foreach ($post_types as $post_type) {
|
|
| 293 | - $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
| 294 | - } |
|
| 295 | - } |
|
| 296 | - $geodir_menu_order[] = $item; |
|
| 266 | + /** |
|
| 267 | + * Order admin menus. |
|
| 268 | + * |
|
| 269 | + * @since 1.0.0 |
|
| 270 | + * @package GeoDirectory |
|
| 271 | + * @param array $menu_order Menu order array. |
|
| 272 | + * @return array Modified menu order array. |
|
| 273 | + */ |
|
| 274 | + function geodir_admin_menu_order($menu_order) |
|
| 275 | + {
|
|
| 297 | 276 | |
| 298 | - unset($menu_order[$geodir_separator]); |
|
| 299 | - //unset( $menu_order[$geodir_places] ); |
|
| 300 | - elseif (!in_array($item, array('separator-geodirectory'))) :
|
|
| 301 | - $geodir_menu_order[] = $item; |
|
| 302 | - endif; |
|
| 277 | + // Initialize our custom order array |
|
| 278 | + $geodir_menu_order = array(); |
|
| 303 | 279 | |
| 304 | - endforeach; |
|
| 280 | + // Get the index of our custom separator |
|
| 281 | + $geodir_separator = array_search('separator-geodirectory', $menu_order);
|
|
| 305 | 282 | |
| 306 | - // Return order |
|
| 307 | - return $geodir_menu_order; |
|
| 308 | - } |
|
| 283 | + // Get index of posttype menu |
|
| 284 | + $post_types = geodir_get_posttypes(); |
|
| 285 | + |
|
| 286 | + // Loop through menu order and do some rearranging |
|
| 287 | + foreach ($menu_order as $index => $item) : |
|
| 288 | + |
|
| 289 | + if ((('geodirectory') == $item)) :
|
|
| 290 | + $geodir_menu_order[] = 'separator-geodirectory'; |
|
| 291 | + if (!empty($post_types)) {
|
|
| 292 | + foreach ($post_types as $post_type) {
|
|
| 293 | + $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | + $geodir_menu_order[] = $item; |
|
| 297 | + |
|
| 298 | + unset($menu_order[$geodir_separator]); |
|
| 299 | + //unset( $menu_order[$geodir_places] ); |
|
| 300 | + elseif (!in_array($item, array('separator-geodirectory'))) :
|
|
| 301 | + $geodir_menu_order[] = $item; |
|
| 302 | + endif; |
|
| 303 | + |
|
| 304 | + endforeach; |
|
| 305 | + |
|
| 306 | + // Return order |
|
| 307 | + return $geodir_menu_order; |
|
| 308 | + } |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | if (!function_exists('geodir_admin_custom_menu_order')) {
|
| 312 | - /** |
|
| 313 | - * Enables custom menu order. |
|
| 314 | - * |
|
| 315 | - * @since 1.0.0 |
|
| 316 | - * @package GeoDirectory |
|
| 317 | - * @return bool |
|
| 318 | - */ |
|
| 319 | - function geodir_admin_custom_menu_order() |
|
| 320 | - {
|
|
| 321 | - if (!current_user_can('manage_options')) return false;
|
|
| 322 | - return true; |
|
| 323 | - } |
|
| 312 | + /** |
|
| 313 | + * Enables custom menu order. |
|
| 314 | + * |
|
| 315 | + * @since 1.0.0 |
|
| 316 | + * @package GeoDirectory |
|
| 317 | + * @return bool |
|
| 318 | + */ |
|
| 319 | + function geodir_admin_custom_menu_order() |
|
| 320 | + {
|
|
| 321 | + if (!current_user_can('manage_options')) return false;
|
|
| 322 | + return true; |
|
| 323 | + } |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
@@ -331,41 +331,41 @@ discard block |
||
| 331 | 331 | */ |
| 332 | 332 | function geodir_before_admin_panel() |
| 333 | 333 | {
|
| 334 | - if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
|
|
| 335 | - echo '<div id="message" class="updated fade"> |
|
| 334 | + if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
|
|
| 335 | + echo '<div id="message" class="updated fade"> |
|
| 336 | 336 | <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>
|
| 337 | 337 | <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
|
| 338 | 338 | </div>'; |
| 339 | 339 | |
| 340 | - } |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
|
|
| 343 | - switch ($_REQUEST['msg']) {
|
|
| 344 | - case 'success': |
|
| 345 | - echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
|
|
| 346 | - flush_rewrite_rules(false); |
|
| 342 | + if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
|
|
| 343 | + switch ($_REQUEST['msg']) {
|
|
| 344 | + case 'success': |
|
| 345 | + echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
|
|
| 346 | + flush_rewrite_rules(false); |
|
| 347 | 347 | |
| 348 | - break; |
|
| 348 | + break; |
|
| 349 | 349 | case 'fail': |
| 350 | 350 | $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
| 351 | 351 | |
| 352 | 352 | if ($gderr == 21) |
| 353 | - 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>';
|
|
| 353 | + 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>';
|
|
| 354 | 354 | else |
| 355 | 355 | echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
|
| 356 | - break; |
|
| 357 | - } |
|
| 358 | - } |
|
| 356 | + break; |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | - if (!geodir_is_default_location_set()) {
|
|
| 361 | - 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>';
|
|
| 360 | + if (!geodir_is_default_location_set()) {
|
|
| 361 | + 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>';
|
|
| 362 | 362 | |
| 363 | - } |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | - if (!function_exists('curl_init')) {
|
|
| 366 | - 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>';
|
|
| 365 | + if (!function_exists('curl_init')) {
|
|
| 366 | + 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>';
|
|
| 367 | 367 | |
| 368 | - } |
|
| 368 | + } |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -378,19 +378,19 @@ discard block |
||
| 378 | 378 | */ |
| 379 | 379 | function geodir_handle_option_form_submit($current_tab) |
| 380 | 380 | {
|
| 381 | - global $geodir_settings; |
|
| 382 | - if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
|
|
| 383 | - /** |
|
| 384 | - * Contains settings array for current tab. |
|
| 385 | - * |
|
| 386 | - * @since 1.0.0 |
|
| 387 | - * @package GeoDirectory |
|
| 388 | - */ |
|
| 389 | - include_once('option-pages/' . $current_tab . '_array.php');
|
|
| 390 | - } |
|
| 391 | - if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
| 392 | - if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 393 | - if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 381 | + global $geodir_settings; |
|
| 382 | + if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
|
|
| 383 | + /** |
|
| 384 | + * Contains settings array for current tab. |
|
| 385 | + * |
|
| 386 | + * @since 1.0.0 |
|
| 387 | + * @package GeoDirectory |
|
| 388 | + */ |
|
| 389 | + include_once('option-pages/' . $current_tab . '_array.php');
|
|
| 390 | + } |
|
| 391 | + if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
| 392 | + if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 393 | + if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 394 | 394 | |
| 395 | 395 | /** |
| 396 | 396 | * Fires before updating geodirectory admin settings. |
@@ -402,98 +402,98 @@ discard block |
||
| 402 | 402 | */ |
| 403 | 403 | do_action('geodir_before_update_options', $current_tab, $geodir_settings);
|
| 404 | 404 | |
| 405 | - if (!empty($geodir_settings[$current_tab])) |
|
| 406 | - geodir_update_options($geodir_settings[$current_tab]); |
|
| 405 | + if (!empty($geodir_settings[$current_tab])) |
|
| 406 | + geodir_update_options($geodir_settings[$current_tab]); |
|
| 407 | 407 | |
| 408 | - /** |
|
| 409 | - * Called after GeoDirectory options settings are updated. |
|
| 410 | - * |
|
| 411 | - * @since 1.0.0 |
|
| 412 | - * @param array $geodir_settings The array of GeoDirectory settings. |
|
| 413 | - * @see 'geodir_before_update_options' |
|
| 414 | - */ |
|
| 415 | - do_action('geodir_update_options', $geodir_settings);
|
|
| 408 | + /** |
|
| 409 | + * Called after GeoDirectory options settings are updated. |
|
| 410 | + * |
|
| 411 | + * @since 1.0.0 |
|
| 412 | + * @param array $geodir_settings The array of GeoDirectory settings. |
|
| 413 | + * @see 'geodir_before_update_options' |
|
| 414 | + */ |
|
| 415 | + do_action('geodir_update_options', $geodir_settings);
|
|
| 416 | 416 | |
| 417 | - /** |
|
| 418 | - * Called after GeoDirectory options settings are updated. |
|
| 419 | - * |
|
| 420 | - * Provides tab specific settings. |
|
| 421 | - * |
|
| 422 | - * @since 1.0.0 |
|
| 423 | - * @param string $current_tab The current settings tab name. |
|
| 424 | - * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
| 425 | - */ |
|
| 426 | - do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
|
|
| 417 | + /** |
|
| 418 | + * Called after GeoDirectory options settings are updated. |
|
| 419 | + * |
|
| 420 | + * Provides tab specific settings. |
|
| 421 | + * |
|
| 422 | + * @since 1.0.0 |
|
| 423 | + * @param string $current_tab The current settings tab name. |
|
| 424 | + * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
| 425 | + */ |
|
| 426 | + do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
|
|
| 427 | 427 | |
| 428 | - flush_rewrite_rules(false); |
|
| 428 | + flush_rewrite_rules(false); |
|
| 429 | 429 | |
| 430 | - $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
| 430 | + $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
| 431 | 431 | |
| 432 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
|
|
| 432 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
|
|
| 433 | 433 | |
| 434 | - wp_redirect($redirect_url); |
|
| 435 | - exit(); |
|
| 436 | - endif; |
|
| 434 | + wp_redirect($redirect_url); |
|
| 435 | + exit(); |
|
| 436 | + endif; |
|
| 437 | 437 | |
| 438 | 438 | |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | |
| 442 | 442 | if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined( 'GD_TESTING_MODE' ))) {
|
| 443 | - /** |
|
| 444 | - * GeoDirectory dummy data installation. |
|
| 445 | - * |
|
| 446 | - * @since 1.0.0 |
|
| 447 | - * @package GeoDirectory |
|
| 448 | - * @global object $wpdb WordPress Database object. |
|
| 449 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 450 | - * @param string $post_type The post type. |
|
| 451 | - */ |
|
| 452 | - function geodir_autoinstall_admin_header($post_type = 'gd_place') |
|
| 453 | - {
|
|
| 443 | + /** |
|
| 444 | + * GeoDirectory dummy data installation. |
|
| 445 | + * |
|
| 446 | + * @since 1.0.0 |
|
| 447 | + * @package GeoDirectory |
|
| 448 | + * @global object $wpdb WordPress Database object. |
|
| 449 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 450 | + * @param string $post_type The post type. |
|
| 451 | + */ |
|
| 452 | + function geodir_autoinstall_admin_header($post_type = 'gd_place') |
|
| 453 | + {
|
|
| 454 | 454 | |
| 455 | - global $wpdb, $plugin_prefix; |
|
| 455 | + global $wpdb, $plugin_prefix; |
|
| 456 | 456 | |
| 457 | - if (!geodir_is_default_location_set()) {
|
|
| 458 | - echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 459 | - } else {
|
|
| 457 | + if (!geodir_is_default_location_set()) {
|
|
| 458 | + echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 459 | + } else {
|
|
| 460 | 460 | |
| 461 | - $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab='; |
|
| 461 | + $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab='; |
|
| 462 | 462 | |
| 463 | - $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
|
|
| 463 | + $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
|
|
| 464 | 464 | |
| 465 | - if ($post_counts > 0) {
|
|
| 466 | - $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
|
|
| 465 | + if ($post_counts > 0) {
|
|
| 466 | + $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
|
|
| 467 | 467 | |
| 468 | - $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . SAMPLE_DATA_SHOW_MSG . '</b><br /><a id="geodir_dummy_delete" class="button_delete" onclick="geodir_autoinstall(this,\'geodir_dummy_delete\',\'' . $nonce . '\',\'' . $post_type . '\')" href="javascript:void(0);" redirect_to="' . $geodir_url . '" >' . DELETE_BTN_SAMPLE_MSG . '</a></p></div>'; |
|
| 469 | - $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_DELETE_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /></p></div>'; |
|
| 470 | - } else {
|
|
| 471 | - $options_list = ''; |
|
| 472 | - for ($option = 1; $option <= 30; $option++) {
|
|
| 473 | - $selected = ''; |
|
| 474 | - if ($option == 10) |
|
| 475 | - $selected = 'selected="selected"'; |
|
| 468 | + $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . SAMPLE_DATA_SHOW_MSG . '</b><br /><a id="geodir_dummy_delete" class="button_delete" onclick="geodir_autoinstall(this,\'geodir_dummy_delete\',\'' . $nonce . '\',\'' . $post_type . '\')" href="javascript:void(0);" redirect_to="' . $geodir_url . '" >' . DELETE_BTN_SAMPLE_MSG . '</a></p></div>'; |
|
| 469 | + $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_DELETE_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /></p></div>'; |
|
| 470 | + } else {
|
|
| 471 | + $options_list = ''; |
|
| 472 | + for ($option = 1; $option <= 30; $option++) {
|
|
| 473 | + $selected = ''; |
|
| 474 | + if ($option == 10) |
|
| 475 | + $selected = 'selected="selected"'; |
|
| 476 | 476 | |
| 477 | - $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>'; |
|
| 478 | - } |
|
| 477 | + $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>'; |
|
| 478 | + } |
|
| 479 | 479 | |
| 480 | - $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
|
|
| 480 | + $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
|
|
| 481 | 481 | |
| 482 | - $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . AUTO_INSATALL_MSG . '</b><br /><select class="selected_sample_data">' . $options_list . '</select><a id="geodir_dummy_insert" class="button_insert" href="javascript:void(0);" onclick="geodir_autoinstall(this,\'geodir_dummy_insert\',\'' . $nonce . '\',\'' . $post_type . '\')" redirect_to="' . $geodir_url . '" >' . INSERT_BTN_SAMPLE_MSG . '</a></p></div>'; |
|
| 483 | - $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_IMPORT_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /><br><span class="dummy_post_inserted"></span></div>'; |
|
| 482 | + $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . AUTO_INSATALL_MSG . '</b><br /><select class="selected_sample_data">' . $options_list . '</select><a id="geodir_dummy_insert" class="button_insert" href="javascript:void(0);" onclick="geodir_autoinstall(this,\'geodir_dummy_insert\',\'' . $nonce . '\',\'' . $post_type . '\')" redirect_to="' . $geodir_url . '" >' . INSERT_BTN_SAMPLE_MSG . '</a></p></div>'; |
|
| 483 | + $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_IMPORT_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /><br><span class="dummy_post_inserted"></span></div>'; |
|
| 484 | 484 | |
| 485 | - } |
|
| 486 | - echo $dummy_msg; |
|
| 487 | - ?> |
|
| 485 | + } |
|
| 486 | + echo $dummy_msg; |
|
| 487 | + ?> |
|
| 488 | 488 | <script> |
| 489 | 489 | <?php |
| 490 | - $default_location = geodir_get_default_location(); |
|
| 491 | - $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 492 | - $region =isset($default_location->region) ? $default_location->region : ''; |
|
| 493 | - $country =isset($default_location->country) ? $default_location->country : ''; |
|
| 494 | - $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 495 | - $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 496 | - ?> |
|
| 490 | + $default_location = geodir_get_default_location(); |
|
| 491 | + $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 492 | + $region =isset($default_location->region) ? $default_location->region : ''; |
|
| 493 | + $country =isset($default_location->country) ? $default_location->country : ''; |
|
| 494 | + $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 495 | + $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 496 | + ?> |
|
| 497 | 497 | var geocoder = window.gdMaps == 'google' ? new google.maps.Geocoder() : null; |
| 498 | 498 | var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country;?>'; |
| 499 | 499 | var bound_lat_lng; |
@@ -584,8 +584,8 @@ discard block |
||
| 584 | 584 | } |
| 585 | 585 | </script> |
| 586 | 586 | <?php |
| 587 | - } |
|
| 588 | - } |
|
| 587 | + } |
|
| 588 | + } |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | /** |
@@ -598,19 +598,19 @@ discard block |
||
| 598 | 598 | */ |
| 599 | 599 | function geodir_insert_dummy_posts() |
| 600 | 600 | {
|
| 601 | - geodir_default_taxonomies(); |
|
| 601 | + geodir_default_taxonomies(); |
|
| 602 | 602 | |
| 603 | - ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
|
|
| 603 | + ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
|
|
| 604 | 604 | |
| 605 | - global $wpdb, $current_user; |
|
| 605 | + global $wpdb, $current_user; |
|
| 606 | 606 | |
| 607 | - /** |
|
| 608 | - * Contains dummy post content. |
|
| 609 | - * |
|
| 610 | - * @since 1.0.0 |
|
| 611 | - * @package GeoDirectory |
|
| 612 | - */ |
|
| 613 | - include_once('place_dummy_post.php');
|
|
| 607 | + /** |
|
| 608 | + * Contains dummy post content. |
|
| 609 | + * |
|
| 610 | + * @since 1.0.0 |
|
| 611 | + * @package GeoDirectory |
|
| 612 | + */ |
|
| 613 | + include_once('place_dummy_post.php');
|
|
| 614 | 614 | |
| 615 | 615 | } |
| 616 | 616 | |
@@ -624,18 +624,18 @@ discard block |
||
| 624 | 624 | */ |
| 625 | 625 | function geodir_delete_dummy_posts() |
| 626 | 626 | {
|
| 627 | - global $wpdb, $plugin_prefix; |
|
| 627 | + global $wpdb, $plugin_prefix; |
|
| 628 | 628 | |
| 629 | 629 | |
| 630 | - $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 630 | + $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 631 | 631 | |
| 632 | 632 | |
| 633 | - foreach ($post_ids as $post_ids_obj) {
|
|
| 634 | - wp_delete_post($post_ids_obj->post_id); |
|
| 635 | - } |
|
| 633 | + foreach ($post_ids as $post_ids_obj) {
|
|
| 634 | + wp_delete_post($post_ids_obj->post_id); |
|
| 635 | + } |
|
| 636 | 636 | |
| 637 | - //double check posts are deleted |
|
| 638 | - $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 637 | + //double check posts are deleted |
|
| 638 | + $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | /** |
@@ -649,114 +649,114 @@ discard block |
||
| 649 | 649 | * @global string $dummy_image_path The dummy image path. |
| 650 | 650 | */ |
| 651 | 651 | function geodir_default_taxonomies() {
|
| 652 | - global $wpdb, $dummy_image_path; |
|
| 652 | + global $wpdb, $dummy_image_path; |
|
| 653 | 653 | |
| 654 | - $category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
|
|
| 654 | + $category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
|
|
| 655 | 655 | |
| 656 | - $last_catid = ''; |
|
| 656 | + $last_catid = ''; |
|
| 657 | 657 | |
| 658 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 658 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 659 | 659 | |
| 660 | - for ($i = 0; $i < count($category_array); $i++) {
|
|
| 661 | - $parent_catid = 0; |
|
| 662 | - if (is_array($category_array[$i])) {
|
|
| 663 | - $cat_name_arr = $category_array[$i]; |
|
| 664 | - for ($j = 0; $j < count($cat_name_arr); $j++) {
|
|
| 665 | - $catname = $cat_name_arr[$j]; |
|
| 660 | + for ($i = 0; $i < count($category_array); $i++) {
|
|
| 661 | + $parent_catid = 0; |
|
| 662 | + if (is_array($category_array[$i])) {
|
|
| 663 | + $cat_name_arr = $category_array[$i]; |
|
| 664 | + for ($j = 0; $j < count($cat_name_arr); $j++) {
|
|
| 665 | + $catname = $cat_name_arr[$j]; |
|
| 666 | 666 | |
| 667 | - if (!term_exists($catname, 'gd_placecategory')) {
|
|
| 668 | - $last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
|
|
| 667 | + if (!term_exists($catname, 'gd_placecategory')) {
|
|
| 668 | + $last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
|
|
| 669 | 669 | |
| 670 | - if ($j == 0) {
|
|
| 671 | - $parent_catid = $last_catid; |
|
| 672 | - } |
|
| 670 | + if ($j == 0) {
|
|
| 671 | + $parent_catid = $last_catid; |
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | 674 | |
| 675 | - if (geodir_dummy_folder_exists()) |
|
| 676 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 677 | - else |
|
| 678 | - $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 675 | + if (geodir_dummy_folder_exists()) |
|
| 676 | + $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 677 | + else |
|
| 678 | + $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 679 | 679 | |
| 680 | - $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
|
|
| 680 | + $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
|
|
| 681 | 681 | |
| 682 | - $catname = str_replace(' ', '_', $catname);
|
|
| 683 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 682 | + $catname = str_replace(' ', '_', $catname);
|
|
| 683 | + $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 684 | 684 | |
| 685 | - if (empty($uploaded['error'])) {
|
|
| 686 | - $new_path = $uploaded['file']; |
|
| 687 | - $new_url = $uploaded['url']; |
|
| 688 | - } |
|
| 685 | + if (empty($uploaded['error'])) {
|
|
| 686 | + $new_path = $uploaded['file']; |
|
| 687 | + $new_url = $uploaded['url']; |
|
| 688 | + } |
|
| 689 | 689 | |
| 690 | - $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
| 691 | - |
|
| 692 | - $attachment = array( |
|
| 693 | - 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 694 | - 'post_mime_type' => $wp_filetype['type'], |
|
| 695 | - 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
|
| 696 | - 'post_content' => '', |
|
| 697 | - 'post_status' => 'inherit' |
|
| 698 | - ); |
|
| 699 | - $attach_id = wp_insert_attachment($attachment, $new_path); |
|
| 700 | - |
|
| 701 | - // you must first include the image.php file |
|
| 702 | - // for the function wp_generate_attachment_metadata() to work |
|
| 703 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 704 | - $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
| 705 | - wp_update_attachment_metadata($attach_id, $attach_data); |
|
| 706 | - |
|
| 707 | - if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
|
|
| 708 | - update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
|
|
| 709 | - } |
|
| 710 | - } |
|
| 711 | - } |
|
| 690 | + $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
| 691 | + |
|
| 692 | + $attachment = array( |
|
| 693 | + 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 694 | + 'post_mime_type' => $wp_filetype['type'], |
|
| 695 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
|
| 696 | + 'post_content' => '', |
|
| 697 | + 'post_status' => 'inherit' |
|
| 698 | + ); |
|
| 699 | + $attach_id = wp_insert_attachment($attachment, $new_path); |
|
| 700 | + |
|
| 701 | + // you must first include the image.php file |
|
| 702 | + // for the function wp_generate_attachment_metadata() to work |
|
| 703 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 704 | + $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
| 705 | + wp_update_attachment_metadata($attach_id, $attach_data); |
|
| 706 | + |
|
| 707 | + if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
|
|
| 708 | + update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
|
|
| 709 | + } |
|
| 710 | + } |
|
| 711 | + } |
|
| 712 | 712 | |
| 713 | - } else {
|
|
| 714 | - $catname = $category_array[$i]; |
|
| 713 | + } else {
|
|
| 714 | + $catname = $category_array[$i]; |
|
| 715 | 715 | |
| 716 | - if (!term_exists($catname, 'gd_placecategory')) {
|
|
| 717 | - $last_catid = wp_insert_term($catname, 'gd_placecategory'); |
|
| 716 | + if (!term_exists($catname, 'gd_placecategory')) {
|
|
| 717 | + $last_catid = wp_insert_term($catname, 'gd_placecategory'); |
|
| 718 | 718 | |
| 719 | - if (geodir_dummy_folder_exists()) |
|
| 720 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 721 | - else |
|
| 722 | - $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 719 | + if (geodir_dummy_folder_exists()) |
|
| 720 | + $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 721 | + else |
|
| 722 | + $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 723 | 723 | |
| 724 | - $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
|
|
| 724 | + $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
|
|
| 725 | 725 | |
| 726 | - $catname = str_replace(' ', '_', $catname);
|
|
| 727 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 726 | + $catname = str_replace(' ', '_', $catname);
|
|
| 727 | + $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 728 | 728 | |
| 729 | - if (empty($uploaded['error'])) {
|
|
| 730 | - $new_path = $uploaded['file']; |
|
| 731 | - $new_url = $uploaded['url']; |
|
| 732 | - } |
|
| 729 | + if (empty($uploaded['error'])) {
|
|
| 730 | + $new_path = $uploaded['file']; |
|
| 731 | + $new_url = $uploaded['url']; |
|
| 732 | + } |
|
| 733 | 733 | |
| 734 | - $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
| 734 | + $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
| 735 | 735 | |
| 736 | - $attachment = array( |
|
| 737 | - 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 738 | - 'post_mime_type' => $wp_filetype['type'], |
|
| 739 | - 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
|
| 740 | - 'post_content' => '', |
|
| 741 | - 'post_status' => 'inherit' |
|
| 742 | - ); |
|
| 736 | + $attachment = array( |
|
| 737 | + 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 738 | + 'post_mime_type' => $wp_filetype['type'], |
|
| 739 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
|
| 740 | + 'post_content' => '', |
|
| 741 | + 'post_status' => 'inherit' |
|
| 742 | + ); |
|
| 743 | 743 | |
| 744 | - $attach_id = wp_insert_attachment($attachment, $new_path); |
|
| 744 | + $attach_id = wp_insert_attachment($attachment, $new_path); |
|
| 745 | 745 | |
| 746 | 746 | |
| 747 | - // you must first include the image.php file |
|
| 748 | - // for the function wp_generate_attachment_metadata() to work |
|
| 749 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 750 | - $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
| 751 | - wp_update_attachment_metadata($attach_id, $attach_data); |
|
| 747 | + // you must first include the image.php file |
|
| 748 | + // for the function wp_generate_attachment_metadata() to work |
|
| 749 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 750 | + $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
| 751 | + wp_update_attachment_metadata($attach_id, $attach_data); |
|
| 752 | 752 | |
| 753 | - if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
|
|
| 754 | - update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
|
|
| 755 | - } |
|
| 756 | - } |
|
| 757 | - } |
|
| 753 | + if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
|
|
| 754 | + update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
|
|
| 755 | + } |
|
| 756 | + } |
|
| 757 | + } |
|
| 758 | 758 | |
| 759 | - } |
|
| 759 | + } |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | /** |
@@ -771,144 +771,144 @@ discard block |
||
| 771 | 771 | * @return bool Returns true if saved. |
| 772 | 772 | */ |
| 773 | 773 | function geodir_update_options($options, $dummy = false) {
|
| 774 | - if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
| 774 | + if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
| 775 | 775 | |
| 776 | - foreach ($options as $value) {
|
|
| 777 | - if ($dummy && isset($value['std'])) |
|
| 778 | - $_POST[$value['id']] = $value['std']; |
|
| 776 | + foreach ($options as $value) {
|
|
| 777 | + if ($dummy && isset($value['std'])) |
|
| 778 | + $_POST[$value['id']] = $value['std']; |
|
| 779 | 779 | |
| 780 | 780 | |
| 781 | - if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
| 781 | + if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
| 782 | 782 | |
| 783 | - if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 784 | - update_option($value['id'], $_POST[$value['id']]); |
|
| 785 | - } else {
|
|
| 786 | - update_option($value['id'], 0); |
|
| 787 | - } |
|
| 783 | + if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 784 | + update_option($value['id'], $_POST[$value['id']]); |
|
| 785 | + } else {
|
|
| 786 | + update_option($value['id'], 0); |
|
| 787 | + } |
|
| 788 | 788 | |
| 789 | - elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 789 | + elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 790 | 790 | |
| 791 | - if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
|
| 792 | - update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
| 793 | - update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
| 794 | - if (isset($_POST[$value['id'] . '_crop'])) : |
|
| 795 | - update_option($value['id'] . '_crop', 1); |
|
| 796 | - else : |
|
| 797 | - update_option($value['id'] . '_crop', 0); |
|
| 798 | - endif; |
|
| 799 | - } else {
|
|
| 800 | - update_option($value['id'] . '_width', $value['std']); |
|
| 801 | - update_option($value['id'] . '_height', $value['std']); |
|
| 802 | - update_option($value['id'] . '_crop', 1); |
|
| 803 | - } |
|
| 791 | + if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
|
| 792 | + update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
| 793 | + update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
| 794 | + if (isset($_POST[$value['id'] . '_crop'])) : |
|
| 795 | + update_option($value['id'] . '_crop', 1); |
|
| 796 | + else : |
|
| 797 | + update_option($value['id'] . '_crop', 0); |
|
| 798 | + endif; |
|
| 799 | + } else {
|
|
| 800 | + update_option($value['id'] . '_width', $value['std']); |
|
| 801 | + update_option($value['id'] . '_height', $value['std']); |
|
| 802 | + update_option($value['id'] . '_crop', 1); |
|
| 803 | + } |
|
| 804 | 804 | |
| 805 | - elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 806 | - $post_types = array(); |
|
| 807 | - $categories = array(); |
|
| 805 | + elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 806 | + $post_types = array(); |
|
| 807 | + $categories = array(); |
|
| 808 | 808 | |
| 809 | - if (!empty($_POST['home_map_post_types'])) : |
|
| 810 | - foreach ($_POST['home_map_post_types'] as $post_type) : |
|
| 811 | - $post_types[] = $post_type; |
|
| 812 | - endforeach; |
|
| 813 | - endif; |
|
| 809 | + if (!empty($_POST['home_map_post_types'])) : |
|
| 810 | + foreach ($_POST['home_map_post_types'] as $post_type) : |
|
| 811 | + $post_types[] = $post_type; |
|
| 812 | + endforeach; |
|
| 813 | + endif; |
|
| 814 | 814 | |
| 815 | - update_option('geodir_exclude_post_type_on_map', $post_types);
|
|
| 815 | + update_option('geodir_exclude_post_type_on_map', $post_types);
|
|
| 816 | 816 | |
| 817 | - if (!empty($_POST['post_category'])) : |
|
| 818 | - foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
| 819 | - $categories[$texonomy] = array(); |
|
| 820 | - foreach ($cat_arr as $category) : |
|
| 821 | - $categories[$texonomy][] = $category; |
|
| 822 | - endforeach; |
|
| 823 | - $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
| 824 | - endforeach; |
|
| 825 | - endif; |
|
| 826 | - update_option('geodir_exclude_cat_on_map', $categories);
|
|
| 827 | - update_option('geodir_exclude_cat_on_map_upgrade', 1);
|
|
| 828 | - elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
| 817 | + if (!empty($_POST['post_category'])) : |
|
| 818 | + foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
| 819 | + $categories[$texonomy] = array(); |
|
| 820 | + foreach ($cat_arr as $category) : |
|
| 821 | + $categories[$texonomy][] = $category; |
|
| 822 | + endforeach; |
|
| 823 | + $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
| 824 | + endforeach; |
|
| 825 | + endif; |
|
| 826 | + update_option('geodir_exclude_cat_on_map', $categories);
|
|
| 827 | + update_option('geodir_exclude_cat_on_map_upgrade', 1);
|
|
| 828 | + elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
| 829 | 829 | |
| 830 | 830 | |
| 831 | - if (!empty($_POST['geodir_default_map_language'])): |
|
| 832 | - update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
|
|
| 833 | - endif; |
|
| 831 | + if (!empty($_POST['geodir_default_map_language'])): |
|
| 832 | + update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
|
|
| 833 | + endif; |
|
| 834 | 834 | |
| 835 | 835 | |
| 836 | - if (!empty($_POST['geodir_default_map_search_pt'])): |
|
| 837 | - update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
|
|
| 838 | - endif; |
|
| 836 | + if (!empty($_POST['geodir_default_map_search_pt'])): |
|
| 837 | + update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
|
|
| 838 | + endif; |
|
| 839 | 839 | |
| 840 | 840 | |
| 841 | - elseif (isset($value['type']) && $value['type'] == 'file') : |
|
| 841 | + elseif (isset($value['type']) && $value['type'] == 'file') : |
|
| 842 | 842 | |
| 843 | 843 | |
| 844 | - if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
|
|
| 844 | + if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
|
|
| 845 | 845 | |
| 846 | - if (get_option($value['id'])) {
|
|
| 847 | - $image_name_arr = explode('/', get_option($value['id']));
|
|
| 848 | - $noimg_name = end($image_name_arr); |
|
| 849 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 850 | - if (file_exists($img_path)) |
|
| 851 | - unlink($img_path); |
|
| 852 | - } |
|
| 846 | + if (get_option($value['id'])) {
|
|
| 847 | + $image_name_arr = explode('/', get_option($value['id']));
|
|
| 848 | + $noimg_name = end($image_name_arr); |
|
| 849 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 850 | + if (file_exists($img_path)) |
|
| 851 | + unlink($img_path); |
|
| 852 | + } |
|
| 853 | 853 | |
| 854 | - update_option($value['id'], ''); |
|
| 855 | - } |
|
| 854 | + update_option($value['id'], ''); |
|
| 855 | + } |
|
| 856 | 856 | |
| 857 | - $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
| 858 | - $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
| 859 | - |
|
| 860 | - if (!empty($filename)): |
|
| 861 | - $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
| 862 | - $uplaods = array(); |
|
| 863 | - |
|
| 864 | - foreach ($uploadedfile as $key => $uplaod): |
|
| 865 | - if ($key == 'name'): |
|
| 866 | - $uplaods[$key] = $filename; |
|
| 867 | - else : |
|
| 868 | - $uplaods[$key] = $uplaod; |
|
| 869 | - endif; |
|
| 870 | - endforeach; |
|
| 871 | - |
|
| 872 | - $uploads = wp_upload_dir(); |
|
| 873 | - |
|
| 874 | - if (get_option($value['id'])) {
|
|
| 875 | - $image_name_arr = explode('/', get_option($value['id']));
|
|
| 876 | - $noimg_name = end($image_name_arr); |
|
| 877 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 878 | - if (file_exists($img_path)) |
|
| 879 | - unlink($img_path); |
|
| 880 | - } |
|
| 857 | + $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
| 858 | + $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
| 859 | + |
|
| 860 | + if (!empty($filename)): |
|
| 861 | + $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
| 862 | + $uplaods = array(); |
|
| 863 | + |
|
| 864 | + foreach ($uploadedfile as $key => $uplaod): |
|
| 865 | + if ($key == 'name'): |
|
| 866 | + $uplaods[$key] = $filename; |
|
| 867 | + else : |
|
| 868 | + $uplaods[$key] = $uplaod; |
|
| 869 | + endif; |
|
| 870 | + endforeach; |
|
| 871 | + |
|
| 872 | + $uploads = wp_upload_dir(); |
|
| 873 | + |
|
| 874 | + if (get_option($value['id'])) {
|
|
| 875 | + $image_name_arr = explode('/', get_option($value['id']));
|
|
| 876 | + $noimg_name = end($image_name_arr); |
|
| 877 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 878 | + if (file_exists($img_path)) |
|
| 879 | + unlink($img_path); |
|
| 880 | + } |
|
| 881 | 881 | |
| 882 | - $upload_overrides = array('test_form' => false);
|
|
| 883 | - $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
| 882 | + $upload_overrides = array('test_form' => false);
|
|
| 883 | + $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
| 884 | 884 | |
| 885 | - update_option($value['id'], $movefile['url']); |
|
| 885 | + update_option($value['id'], $movefile['url']); |
|
| 886 | 886 | |
| 887 | - endif; |
|
| 887 | + endif; |
|
| 888 | 888 | |
| 889 | - if (!get_option($value['id']) && isset($value['value'])): |
|
| 890 | - update_option($value['id'], $value['value']); |
|
| 891 | - endif; |
|
| 889 | + if (!get_option($value['id']) && isset($value['value'])): |
|
| 890 | + update_option($value['id'], $value['value']); |
|
| 891 | + endif; |
|
| 892 | 892 | |
| 893 | 893 | |
| 894 | - else : |
|
| 895 | - // same menu setting per theme. |
|
| 896 | - if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
|
| 897 | - $theme = wp_get_theme(); |
|
| 898 | - update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
|
| 899 | - } |
|
| 894 | + else : |
|
| 895 | + // same menu setting per theme. |
|
| 896 | + if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
|
| 897 | + $theme = wp_get_theme(); |
|
| 898 | + update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
|
| 899 | + } |
|
| 900 | 900 | |
| 901 | - if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 902 | - update_option($value['id'], $_POST[$value['id']]); |
|
| 903 | - } else {
|
|
| 904 | - delete_option($value['id']); |
|
| 905 | - } |
|
| 901 | + if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 902 | + update_option($value['id'], $_POST[$value['id']]); |
|
| 903 | + } else {
|
|
| 904 | + delete_option($value['id']); |
|
| 905 | + } |
|
| 906 | 906 | |
| 907 | - endif; |
|
| 908 | - } |
|
| 909 | - if ($dummy) |
|
| 910 | - $_POST = array(); |
|
| 911 | - return true; |
|
| 907 | + endif; |
|
| 908 | + } |
|
| 909 | + if ($dummy) |
|
| 910 | + $_POST = array(); |
|
| 911 | + return true; |
|
| 912 | 912 | |
| 913 | 913 | } |
| 914 | 914 | |
@@ -957,33 +957,33 @@ discard block |
||
| 957 | 957 | function places_custom_fields_tab($tabs) |
| 958 | 958 | {
|
| 959 | 959 | |
| 960 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 960 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 961 | 961 | |
| 962 | - if (!empty($geodir_post_types)) {
|
|
| 962 | + if (!empty($geodir_post_types)) {
|
|
| 963 | 963 | |
| 964 | - foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
| 964 | + foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
| 965 | 965 | |
| 966 | - $listing_slug = $geodir_posttype_info['labels']['singular_name']; |
|
| 966 | + $listing_slug = $geodir_posttype_info['labels']['singular_name']; |
|
| 967 | 967 | |
| 968 | - $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
| 969 | - 'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'), |
|
| 970 | - 'subtabs' => array( |
|
| 971 | - array('subtab' => 'custom_fields',
|
|
| 972 | - 'label' => __('Custom Fields', 'geodirectory'),
|
|
| 973 | - 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 974 | - array('subtab' => 'sorting_options',
|
|
| 975 | - 'label' => __('Sorting Options', 'geodirectory'),
|
|
| 976 | - 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 977 | - ), |
|
| 978 | - 'tab_index' => 9, |
|
| 979 | - 'request' => array('listing_type' => $geodir_post_type)
|
|
| 980 | - ); |
|
| 968 | + $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
| 969 | + 'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'), |
|
| 970 | + 'subtabs' => array( |
|
| 971 | + array('subtab' => 'custom_fields',
|
|
| 972 | + 'label' => __('Custom Fields', 'geodirectory'),
|
|
| 973 | + 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 974 | + array('subtab' => 'sorting_options',
|
|
| 975 | + 'label' => __('Sorting Options', 'geodirectory'),
|
|
| 976 | + 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 977 | + ), |
|
| 978 | + 'tab_index' => 9, |
|
| 979 | + 'request' => array('listing_type' => $geodir_post_type)
|
|
| 980 | + ); |
|
| 981 | 981 | |
| 982 | - endforeach; |
|
| 982 | + endforeach; |
|
| 983 | 983 | |
| 984 | - } |
|
| 984 | + } |
|
| 985 | 985 | |
| 986 | - return $tabs; |
|
| 986 | + return $tabs; |
|
| 987 | 987 | } |
| 988 | 988 | |
| 989 | 989 | |
@@ -999,8 +999,8 @@ discard block |
||
| 999 | 999 | */ |
| 1000 | 1000 | function geodir_tools_setting_tab($tabs) |
| 1001 | 1001 | {
|
| 1002 | - $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
|
|
| 1003 | - return $tabs; |
|
| 1002 | + $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
|
|
| 1003 | + return $tabs; |
|
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | /** |
@@ -1015,8 +1015,8 @@ discard block |
||
| 1015 | 1015 | */ |
| 1016 | 1016 | function geodir_compatibility_setting_tab($tabs) |
| 1017 | 1017 | {
|
| 1018 | - $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
|
|
| 1019 | - return $tabs; |
|
| 1018 | + $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
|
|
| 1019 | + return $tabs; |
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | 1022 | |
@@ -1032,144 +1032,144 @@ discard block |
||
| 1032 | 1032 | */ |
| 1033 | 1033 | function geodir_extend_geodirectory_setting_tab($tabs) |
| 1034 | 1034 | {
|
| 1035 | - $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
|
|
| 1036 | - return $tabs; |
|
| 1035 | + $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
|
|
| 1036 | + return $tabs; |
|
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | 1039 | |
| 1040 | 1040 | if (!function_exists('geodir_edit_post_columns')) {
|
| 1041 | - /** |
|
| 1042 | - * Modify admin post listing page columns. |
|
| 1043 | - * |
|
| 1044 | - * @since 1.0.0 |
|
| 1045 | - * @package GeoDirectory |
|
| 1046 | - * @param array $columns The column array. |
|
| 1047 | - * @return array Altered column array. |
|
| 1048 | - */ |
|
| 1049 | - function geodir_edit_post_columns($columns) |
|
| 1050 | - {
|
|
| 1051 | - |
|
| 1052 | - $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
|
|
| 1053 | - 'categorys' => __('Categories', 'geodirectory'));
|
|
| 1054 | - |
|
| 1055 | - if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
|
|
| 1056 | - {
|
|
| 1057 | - $offset = 0; // should we prepend $array with $data? |
|
| 1058 | - $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
| 1059 | - } |
|
| 1041 | + /** |
|
| 1042 | + * Modify admin post listing page columns. |
|
| 1043 | + * |
|
| 1044 | + * @since 1.0.0 |
|
| 1045 | + * @package GeoDirectory |
|
| 1046 | + * @param array $columns The column array. |
|
| 1047 | + * @return array Altered column array. |
|
| 1048 | + */ |
|
| 1049 | + function geodir_edit_post_columns($columns) |
|
| 1050 | + {
|
|
| 1051 | + |
|
| 1052 | + $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
|
|
| 1053 | + 'categorys' => __('Categories', 'geodirectory'));
|
|
| 1060 | 1054 | |
| 1061 | - $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
| 1055 | + if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
|
|
| 1056 | + {
|
|
| 1057 | + $offset = 0; // should we prepend $array with $data? |
|
| 1058 | + $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
| 1059 | + } |
|
| 1062 | 1060 | |
| 1063 | - $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
|
|
| 1061 | + $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
| 1064 | 1062 | |
| 1065 | - return $columns; |
|
| 1066 | - } |
|
| 1063 | + $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
|
|
| 1064 | + |
|
| 1065 | + return $columns; |
|
| 1066 | + } |
|
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | 1069 | |
| 1070 | 1070 | if (!function_exists('geodir_manage_post_columns')) {
|
| 1071 | - /** |
|
| 1072 | - * Adds content to our custom post listing page columns. |
|
| 1073 | - * |
|
| 1074 | - * @since 1.0.0 |
|
| 1075 | - * @package GeoDirectory |
|
| 1076 | - * @global object $wpdb WordPress Database object. |
|
| 1077 | - * @global object $post WordPress Post object. |
|
| 1078 | - * @param string $column The column name. |
|
| 1079 | - * @param int $post_id The post ID. |
|
| 1080 | - */ |
|
| 1081 | - function geodir_manage_post_columns($column, $post_id) |
|
| 1082 | - {
|
|
| 1083 | - global $post, $wpdb; |
|
| 1084 | - |
|
| 1085 | - switch ($column): |
|
| 1086 | - /* If displaying the 'city' column. */ |
|
| 1087 | - case 'location' : |
|
| 1088 | - $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
| 1089 | - $location = geodir_get_location($location_id); |
|
| 1090 | - /* If no city is found, output a default message. */ |
|
| 1091 | - if (empty($location)) {
|
|
| 1092 | - _e('Unknown', 'geodirectory');
|
|
| 1093 | - } else {
|
|
| 1094 | - /* If there is a city id, append 'city name' to the text string. */ |
|
| 1095 | - $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
|
|
| 1096 | - echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
| 1097 | - } |
|
| 1098 | - break; |
|
| 1099 | - |
|
| 1100 | - /* If displaying the 'expire' column. */ |
|
| 1101 | - case 'expire' : |
|
| 1102 | - $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
| 1103 | - $d1 = $expire_date; // get expire_date |
|
| 1104 | - $d2 = date('Y-m-d'); // get current date
|
|
| 1105 | - $state = __('days left', 'geodirectory');
|
|
| 1106 | - $date_diff_text = ''; |
|
| 1107 | - $expire_class = 'expire_left'; |
|
| 1108 | - if ($expire_date != 'Never') {
|
|
| 1109 | - if (strtotime($d1) < strtotime($d2)) {
|
|
| 1110 | - $state = __('days overdue', 'geodirectory');
|
|
| 1111 | - $expire_class = 'expire_over'; |
|
| 1112 | - } |
|
| 1113 | - $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
|
| 1114 | - $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
|
| 1115 | - } |
|
| 1116 | - /* If no expire_date is found, output a default message. */ |
|
| 1117 | - if (empty($expire_date)) |
|
| 1118 | - echo __('Unknown', 'geodirectory');
|
|
| 1119 | - /* If there is a expire_date, append 'days left' to the text string. */ |
|
| 1120 | - else |
|
| 1121 | - echo $expire_date . $date_diff_text; |
|
| 1122 | - break; |
|
| 1123 | - |
|
| 1124 | - /* If displaying the 'categorys' column. */ |
|
| 1125 | - case 'categorys' : |
|
| 1126 | - |
|
| 1127 | - /* Get the categorys for the post. */ |
|
| 1128 | - |
|
| 1129 | - |
|
| 1130 | - $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
| 1131 | - |
|
| 1132 | - /* If terms were found. */ |
|
| 1133 | - if (!empty($terms)) {
|
|
| 1134 | - $out = array(); |
|
| 1135 | - /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
| 1136 | - foreach ($terms as $term) {
|
|
| 1137 | - if (!strstr($term->taxonomy, 'tag')) {
|
|
| 1138 | - $out[] = sprintf('<a href="%s">%s</a>',
|
|
| 1139 | - esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
|
|
| 1140 | - esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
|
|
| 1141 | - ); |
|
| 1142 | - } |
|
| 1143 | - } |
|
| 1144 | - /* Join the terms, separating them with a comma. */ |
|
| 1145 | - echo(join(', ', $out));
|
|
| 1146 | - } /* If no terms were found, output a default message. */ |
|
| 1147 | - else {
|
|
| 1148 | - _e('No Categories', 'geodirectory');
|
|
| 1149 | - } |
|
| 1150 | - break; |
|
| 1071 | + /** |
|
| 1072 | + * Adds content to our custom post listing page columns. |
|
| 1073 | + * |
|
| 1074 | + * @since 1.0.0 |
|
| 1075 | + * @package GeoDirectory |
|
| 1076 | + * @global object $wpdb WordPress Database object. |
|
| 1077 | + * @global object $post WordPress Post object. |
|
| 1078 | + * @param string $column The column name. |
|
| 1079 | + * @param int $post_id The post ID. |
|
| 1080 | + */ |
|
| 1081 | + function geodir_manage_post_columns($column, $post_id) |
|
| 1082 | + {
|
|
| 1083 | + global $post, $wpdb; |
|
| 1084 | + |
|
| 1085 | + switch ($column): |
|
| 1086 | + /* If displaying the 'city' column. */ |
|
| 1087 | + case 'location' : |
|
| 1088 | + $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
| 1089 | + $location = geodir_get_location($location_id); |
|
| 1090 | + /* If no city is found, output a default message. */ |
|
| 1091 | + if (empty($location)) {
|
|
| 1092 | + _e('Unknown', 'geodirectory');
|
|
| 1093 | + } else {
|
|
| 1094 | + /* If there is a city id, append 'city name' to the text string. */ |
|
| 1095 | + $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
|
|
| 1096 | + echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
| 1097 | + } |
|
| 1098 | + break; |
|
| 1099 | + |
|
| 1100 | + /* If displaying the 'expire' column. */ |
|
| 1101 | + case 'expire' : |
|
| 1102 | + $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
| 1103 | + $d1 = $expire_date; // get expire_date |
|
| 1104 | + $d2 = date('Y-m-d'); // get current date
|
|
| 1105 | + $state = __('days left', 'geodirectory');
|
|
| 1106 | + $date_diff_text = ''; |
|
| 1107 | + $expire_class = 'expire_left'; |
|
| 1108 | + if ($expire_date != 'Never') {
|
|
| 1109 | + if (strtotime($d1) < strtotime($d2)) {
|
|
| 1110 | + $state = __('days overdue', 'geodirectory');
|
|
| 1111 | + $expire_class = 'expire_over'; |
|
| 1112 | + } |
|
| 1113 | + $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
|
| 1114 | + $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
|
| 1115 | + } |
|
| 1116 | + /* If no expire_date is found, output a default message. */ |
|
| 1117 | + if (empty($expire_date)) |
|
| 1118 | + echo __('Unknown', 'geodirectory');
|
|
| 1119 | + /* If there is a expire_date, append 'days left' to the text string. */ |
|
| 1120 | + else |
|
| 1121 | + echo $expire_date . $date_diff_text; |
|
| 1122 | + break; |
|
| 1151 | 1123 | |
| 1152 | - endswitch; |
|
| 1153 | - } |
|
| 1124 | + /* If displaying the 'categorys' column. */ |
|
| 1125 | + case 'categorys' : |
|
| 1126 | + |
|
| 1127 | + /* Get the categorys for the post. */ |
|
| 1128 | + |
|
| 1129 | + |
|
| 1130 | + $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
| 1131 | + |
|
| 1132 | + /* If terms were found. */ |
|
| 1133 | + if (!empty($terms)) {
|
|
| 1134 | + $out = array(); |
|
| 1135 | + /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
| 1136 | + foreach ($terms as $term) {
|
|
| 1137 | + if (!strstr($term->taxonomy, 'tag')) {
|
|
| 1138 | + $out[] = sprintf('<a href="%s">%s</a>',
|
|
| 1139 | + esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
|
|
| 1140 | + esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
|
|
| 1141 | + ); |
|
| 1142 | + } |
|
| 1143 | + } |
|
| 1144 | + /* Join the terms, separating them with a comma. */ |
|
| 1145 | + echo(join(', ', $out));
|
|
| 1146 | + } /* If no terms were found, output a default message. */ |
|
| 1147 | + else {
|
|
| 1148 | + _e('No Categories', 'geodirectory');
|
|
| 1149 | + } |
|
| 1150 | + break; |
|
| 1151 | + |
|
| 1152 | + endswitch; |
|
| 1153 | + } |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | |
| 1157 | 1157 | if (!function_exists('geodir_post_sortable_columns')) {
|
| 1158 | - /** |
|
| 1159 | - * Makes admin post listing page columns sortable. |
|
| 1160 | - * |
|
| 1161 | - * @since 1.0.0 |
|
| 1162 | - * @package GeoDirectory |
|
| 1163 | - * @param array $columns The column array. |
|
| 1164 | - * @return array Altered column array. |
|
| 1165 | - */ |
|
| 1166 | - function geodir_post_sortable_columns($columns) |
|
| 1167 | - {
|
|
| 1168 | - |
|
| 1169 | - $columns['expire'] = 'expire'; |
|
| 1170 | - |
|
| 1171 | - return $columns; |
|
| 1172 | - } |
|
| 1158 | + /** |
|
| 1159 | + * Makes admin post listing page columns sortable. |
|
| 1160 | + * |
|
| 1161 | + * @since 1.0.0 |
|
| 1162 | + * @package GeoDirectory |
|
| 1163 | + * @param array $columns The column array. |
|
| 1164 | + * @return array Altered column array. |
|
| 1165 | + */ |
|
| 1166 | + function geodir_post_sortable_columns($columns) |
|
| 1167 | + {
|
|
| 1168 | + |
|
| 1169 | + $columns['expire'] = 'expire'; |
|
| 1170 | + |
|
| 1171 | + return $columns; |
|
| 1172 | + } |
|
| 1173 | 1173 | } |
| 1174 | 1174 | |
| 1175 | 1175 | /** |
@@ -1183,32 +1183,32 @@ discard block |
||
| 1183 | 1183 | * @param int $post_id The post ID. |
| 1184 | 1184 | */ |
| 1185 | 1185 | function geodir_post_information_save($post_id, $post) {
|
| 1186 | - global $wpdb, $current_user; |
|
| 1186 | + global $wpdb, $current_user; |
|
| 1187 | 1187 | |
| 1188 | - if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 1189 | - return; |
|
| 1190 | - } |
|
| 1188 | + if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 1189 | + return; |
|
| 1190 | + } |
|
| 1191 | 1191 | |
| 1192 | - $geodir_posttypes = geodir_get_posttypes(); |
|
| 1192 | + $geodir_posttypes = geodir_get_posttypes(); |
|
| 1193 | 1193 | |
| 1194 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
|
| 1195 | - return; |
|
| 1194 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
|
| 1195 | + return; |
|
| 1196 | 1196 | |
| 1197 | - if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 1198 | - if (isset($_REQUEST['_status'])) |
|
| 1199 | - geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 1197 | + if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 1198 | + if (isset($_REQUEST['_status'])) |
|
| 1199 | + geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 1200 | 1200 | |
| 1201 | - if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
| 1202 | - return; |
|
| 1201 | + if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
| 1202 | + return; |
|
| 1203 | 1203 | |
| 1204 | - if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
| 1205 | - return; |
|
| 1204 | + if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
| 1205 | + return; |
|
| 1206 | 1206 | |
| 1207 | - if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
| 1208 | - return; |
|
| 1207 | + if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
| 1208 | + return; |
|
| 1209 | 1209 | |
| 1210 | - geodir_save_listing($_REQUEST); |
|
| 1211 | - } |
|
| 1210 | + geodir_save_listing($_REQUEST); |
|
| 1211 | + } |
|
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | 1214 | /** |
@@ -1224,102 +1224,102 @@ discard block |
||
| 1224 | 1224 | */ |
| 1225 | 1225 | function geodir_admin_fields($options) |
| 1226 | 1226 | {
|
| 1227 | - global $geodirectory; |
|
| 1228 | - |
|
| 1229 | - $first_title = true; |
|
| 1230 | - $tab_id = ''; |
|
| 1231 | - $i = 0; |
|
| 1232 | - foreach ($options as $value) : |
|
| 1233 | - if (!isset($value['name'])) $value['name'] = ''; |
|
| 1234 | - if (!isset($value['class'])) $value['class'] = ''; |
|
| 1235 | - if (!isset($value['css'])) $value['css'] = ''; |
|
| 1236 | - if (!isset($value['std'])) $value['std'] = ''; |
|
| 1237 | - $desc = ''; |
|
| 1238 | - switch ($value['type']) : |
|
| 1239 | - case 'dummy_installer': |
|
| 1240 | - $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
| 1241 | - geodir_autoinstall_admin_header($post_type); |
|
| 1242 | - break; |
|
| 1243 | - case 'title': |
|
| 1244 | - |
|
| 1245 | - if ($i == 0) {
|
|
| 1246 | - echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
| 1247 | - echo '<div class="inner_content_tab_main">'; |
|
| 1248 | - } |
|
| 1227 | + global $geodirectory; |
|
| 1228 | + |
|
| 1229 | + $first_title = true; |
|
| 1230 | + $tab_id = ''; |
|
| 1231 | + $i = 0; |
|
| 1232 | + foreach ($options as $value) : |
|
| 1233 | + if (!isset($value['name'])) $value['name'] = ''; |
|
| 1234 | + if (!isset($value['class'])) $value['class'] = ''; |
|
| 1235 | + if (!isset($value['css'])) $value['css'] = ''; |
|
| 1236 | + if (!isset($value['std'])) $value['std'] = ''; |
|
| 1237 | + $desc = ''; |
|
| 1238 | + switch ($value['type']) : |
|
| 1239 | + case 'dummy_installer': |
|
| 1240 | + $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
| 1241 | + geodir_autoinstall_admin_header($post_type); |
|
| 1242 | + break; |
|
| 1243 | + case 'title': |
|
| 1244 | + |
|
| 1245 | + if ($i == 0) {
|
|
| 1246 | + echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
| 1247 | + echo '<div class="inner_content_tab_main">'; |
|
| 1248 | + } |
|
| 1249 | 1249 | |
| 1250 | - $i++; |
|
| 1250 | + $i++; |
|
| 1251 | 1251 | |
| 1252 | - if (isset($value['id']) && $value['id']) |
|
| 1253 | - $tab_id = $value['id']; |
|
| 1252 | + if (isset($value['id']) && $value['id']) |
|
| 1253 | + $tab_id = $value['id']; |
|
| 1254 | 1254 | |
| 1255 | - if (isset($value['desc']) && $value['desc']) |
|
| 1256 | - $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 1255 | + if (isset($value['desc']) && $value['desc']) |
|
| 1256 | + $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 1257 | 1257 | |
| 1258 | - if (isset($value['name']) && $value['name']) {
|
|
| 1259 | - if ($first_title === true) {
|
|
| 1260 | - $first_title = false; |
|
| 1261 | - } else {
|
|
| 1262 | - echo '</div>'; |
|
| 1263 | - } |
|
| 1264 | - echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
| 1258 | + if (isset($value['name']) && $value['name']) {
|
|
| 1259 | + if ($first_title === true) {
|
|
| 1260 | + $first_title = false; |
|
| 1261 | + } else {
|
|
| 1262 | + echo '</div>'; |
|
| 1263 | + } |
|
| 1264 | + echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
| 1265 | 1265 | |
| 1266 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1267 | - } |
|
| 1266 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1267 | + } |
|
| 1268 | 1268 | |
| 1269 | - /** |
|
| 1270 | - * Called after a GeoDirectory settings title is output in the GD settings page. |
|
| 1271 | - * |
|
| 1272 | - * The action is called dynamically geodir_settings_$value['id']. |
|
| 1273 | - * |
|
| 1274 | - * @since 1.0.0 |
|
| 1275 | - */ |
|
| 1276 | - do_action('geodir_settings_' . sanitize_title($value['id']));
|
|
| 1277 | - break; |
|
| 1278 | - |
|
| 1279 | - case 'no_tabs': |
|
| 1280 | - |
|
| 1281 | - echo '<div class="inner_content_tab_main">'; |
|
| 1282 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1283 | - |
|
| 1284 | - break; |
|
| 1285 | - |
|
| 1286 | - case 'sectionstart': |
|
| 1287 | - if (isset($value['desc']) && $value['desc']) |
|
| 1288 | - $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 1289 | - if (isset($value['name']) && $value['name']) |
|
| 1290 | - echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 1291 | - /** |
|
| 1292 | - * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
| 1293 | - * |
|
| 1294 | - * The action is called dynamically geodir_settings_$value['id']_start. |
|
| 1295 | - * |
|
| 1296 | - * @since 1.0.0 |
|
| 1297 | - */ |
|
| 1298 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 1299 | - echo '<table class="form-table">' . "\n\n"; |
|
| 1300 | - |
|
| 1301 | - break; |
|
| 1302 | - case 'sectionend': |
|
| 1303 | - /** |
|
| 1304 | - * Called before a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 1305 | - * |
|
| 1306 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 1307 | - * |
|
| 1308 | - * @since 1.0.0 |
|
| 1309 | - */ |
|
| 1310 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 1311 | - echo '</table>'; |
|
| 1312 | - /** |
|
| 1313 | - * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 1314 | - * |
|
| 1315 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 1316 | - * |
|
| 1317 | - * @since 1.0.0 |
|
| 1318 | - */ |
|
| 1319 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 1320 | - break; |
|
| 1321 | - case 'text': |
|
| 1322 | - ?> |
|
| 1269 | + /** |
|
| 1270 | + * Called after a GeoDirectory settings title is output in the GD settings page. |
|
| 1271 | + * |
|
| 1272 | + * The action is called dynamically geodir_settings_$value['id']. |
|
| 1273 | + * |
|
| 1274 | + * @since 1.0.0 |
|
| 1275 | + */ |
|
| 1276 | + do_action('geodir_settings_' . sanitize_title($value['id']));
|
|
| 1277 | + break; |
|
| 1278 | + |
|
| 1279 | + case 'no_tabs': |
|
| 1280 | + |
|
| 1281 | + echo '<div class="inner_content_tab_main">'; |
|
| 1282 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1283 | + |
|
| 1284 | + break; |
|
| 1285 | + |
|
| 1286 | + case 'sectionstart': |
|
| 1287 | + if (isset($value['desc']) && $value['desc']) |
|
| 1288 | + $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 1289 | + if (isset($value['name']) && $value['name']) |
|
| 1290 | + echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 1291 | + /** |
|
| 1292 | + * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
| 1293 | + * |
|
| 1294 | + * The action is called dynamically geodir_settings_$value['id']_start. |
|
| 1295 | + * |
|
| 1296 | + * @since 1.0.0 |
|
| 1297 | + */ |
|
| 1298 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 1299 | + echo '<table class="form-table">' . "\n\n"; |
|
| 1300 | + |
|
| 1301 | + break; |
|
| 1302 | + case 'sectionend': |
|
| 1303 | + /** |
|
| 1304 | + * Called before a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 1305 | + * |
|
| 1306 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 1307 | + * |
|
| 1308 | + * @since 1.0.0 |
|
| 1309 | + */ |
|
| 1310 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 1311 | + echo '</table>'; |
|
| 1312 | + /** |
|
| 1313 | + * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 1314 | + * |
|
| 1315 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 1316 | + * |
|
| 1317 | + * @since 1.0.0 |
|
| 1318 | + */ |
|
| 1319 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 1320 | + break; |
|
| 1321 | + case 'text': |
|
| 1322 | + ?> |
|
| 1323 | 1323 | <tr valign="top"> |
| 1324 | 1324 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1325 | 1325 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1328,15 +1328,15 @@ discard block |
||
| 1328 | 1328 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 1329 | 1329 | style=" <?php echo esc_attr($value['css']); ?>" |
| 1330 | 1330 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1331 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1332 | - } else {
|
|
| 1333 | - echo esc_attr($value['std']); |
|
| 1334 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1331 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1332 | + } else {
|
|
| 1333 | + echo esc_attr($value['std']); |
|
| 1334 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1335 | 1335 | </tr><?php |
| 1336 | - break; |
|
| 1336 | + break; |
|
| 1337 | 1337 | |
| 1338 | - case 'password': |
|
| 1339 | - ?> |
|
| 1338 | + case 'password': |
|
| 1339 | + ?> |
|
| 1340 | 1340 | <tr valign="top"> |
| 1341 | 1341 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1342 | 1342 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1345,42 +1345,42 @@ discard block |
||
| 1345 | 1345 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 1346 | 1346 | style="<?php echo esc_attr($value['css']); ?>" |
| 1347 | 1347 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1348 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1349 | - } else {
|
|
| 1350 | - echo esc_attr($value['std']); |
|
| 1351 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1348 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1349 | + } else {
|
|
| 1350 | + echo esc_attr($value['std']); |
|
| 1351 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1352 | 1352 | </tr><?php |
| 1353 | - break; |
|
| 1353 | + break; |
|
| 1354 | 1354 | |
| 1355 | - case 'html_content': |
|
| 1356 | - ?> |
|
| 1355 | + case 'html_content': |
|
| 1356 | + ?> |
|
| 1357 | 1357 | <tr valign="top"> |
| 1358 | 1358 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1359 | 1359 | <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td> |
| 1360 | 1360 | </tr><?php |
| 1361 | - break; |
|
| 1361 | + break; |
|
| 1362 | 1362 | |
| 1363 | - case 'color' : |
|
| 1364 | - ?> |
|
| 1363 | + case 'color' : |
|
| 1364 | + ?> |
|
| 1365 | 1365 | <tr valign="top"> |
| 1366 | 1366 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1367 | 1367 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
| 1368 | 1368 | id="<?php echo esc_attr($value['id']); ?>" type="text" |
| 1369 | 1369 | style="<?php echo esc_attr($value['css']); ?>" |
| 1370 | 1370 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1371 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1372 | - } else {
|
|
| 1373 | - echo esc_attr($value['std']); |
|
| 1374 | - } ?>" class="colorpick"/> <span |
|
| 1371 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1372 | + } else {
|
|
| 1373 | + echo esc_attr($value['std']); |
|
| 1374 | + } ?>" class="colorpick"/> <span |
|
| 1375 | 1375 | class="description"><?php echo $value['desc']; ?></span> |
| 1376 | 1376 | |
| 1377 | 1377 | <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv" |
| 1378 | 1378 | style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div> |
| 1379 | 1379 | </td> |
| 1380 | 1380 | </tr><?php |
| 1381 | - break; |
|
| 1382 | - case 'image_width' : |
|
| 1383 | - ?> |
|
| 1381 | + break; |
|
| 1382 | + case 'image_width' : |
|
| 1383 | + ?> |
|
| 1384 | 1384 | <tr valign="top"> |
| 1385 | 1385 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1386 | 1386 | <td class="forminp"> |
@@ -1402,11 +1402,11 @@ discard block |
||
| 1402 | 1402 | |
| 1403 | 1403 | <span class="description"><?php echo $value['desc'] ?></span></td> |
| 1404 | 1404 | </tr><?php |
| 1405 | - break; |
|
| 1406 | - case 'select': |
|
| 1407 | - $option_value = get_option($value['id']); |
|
| 1408 | - $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value; |
|
| 1409 | - ?> |
|
| 1405 | + break; |
|
| 1406 | + case 'select': |
|
| 1407 | + $option_value = get_option($value['id']); |
|
| 1408 | + $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value; |
|
| 1409 | + ?> |
|
| 1410 | 1410 | <tr valign="top"> |
| 1411 | 1411 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1412 | 1412 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -1415,33 +1415,33 @@ discard block |
||
| 1415 | 1415 | class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
| 1416 | 1416 | option-ajaxchosen="false"> |
| 1417 | 1417 | <?php |
| 1418 | - foreach ($value['options'] as $key => $val) {
|
|
| 1419 | - $geodir_select_value = ''; |
|
| 1420 | - if ($option_value != '') {
|
|
| 1421 | - if ($option_value != '' && $option_value == $key) |
|
| 1422 | - $geodir_select_value = ' selected="selected" '; |
|
| 1423 | - } else {
|
|
| 1424 | - if ($value['std'] == $key) |
|
| 1425 | - $geodir_select_value = ' selected="selected" '; |
|
| 1426 | - } |
|
| 1427 | - ?> |
|
| 1418 | + foreach ($value['options'] as $key => $val) {
|
|
| 1419 | + $geodir_select_value = ''; |
|
| 1420 | + if ($option_value != '') {
|
|
| 1421 | + if ($option_value != '' && $option_value == $key) |
|
| 1422 | + $geodir_select_value = ' selected="selected" '; |
|
| 1423 | + } else {
|
|
| 1424 | + if ($value['std'] == $key) |
|
| 1425 | + $geodir_select_value = ' selected="selected" '; |
|
| 1426 | + } |
|
| 1427 | + ?> |
|
| 1428 | 1428 | <option |
| 1429 | 1429 | value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo ucfirst($val) ?></option> |
| 1430 | 1430 | <?php |
| 1431 | - } |
|
| 1432 | - ?> |
|
| 1431 | + } |
|
| 1432 | + ?> |
|
| 1433 | 1433 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1434 | 1434 | </td> |
| 1435 | 1435 | </tr><?php |
| 1436 | - break; |
|
| 1436 | + break; |
|
| 1437 | 1437 | |
| 1438 | - case 'multiselect': |
|
| 1439 | - $option_values = get_option($value['id']); |
|
| 1440 | - if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
|
|
| 1441 | - $option_values = $value['std']; |
|
| 1442 | - } |
|
| 1443 | - $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values; |
|
| 1444 | - ?> |
|
| 1438 | + case 'multiselect': |
|
| 1439 | + $option_values = get_option($value['id']); |
|
| 1440 | + if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
|
|
| 1441 | + $option_values = $value['std']; |
|
| 1442 | + } |
|
| 1443 | + $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values; |
|
| 1444 | + ?> |
|
| 1445 | 1445 | <tr valign="top"> |
| 1446 | 1446 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1447 | 1447 | <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]" |
@@ -1451,25 +1451,25 @@ discard block |
||
| 1451 | 1451 | data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>" |
| 1452 | 1452 | option-ajaxchosen="false"> |
| 1453 | 1453 | <?php |
| 1454 | - foreach ($value['options'] as $key => $val) {
|
|
| 1455 | - if (strpos($key, 'optgroup_start-') === 0) {
|
|
| 1456 | - ?><optgroup label="<?php echo ucfirst($val); ?>"><?php |
|
| 1457 | - } else if (strpos($key, 'optgroup_end-') === 0) {
|
|
| 1458 | - ?></optgroup><?php |
|
| 1459 | - } else {
|
|
| 1460 | - ?> |
|
| 1454 | + foreach ($value['options'] as $key => $val) {
|
|
| 1455 | + if (strpos($key, 'optgroup_start-') === 0) {
|
|
| 1456 | + ?><optgroup label="<?php echo ucfirst($val); ?>"><?php |
|
| 1457 | + } else if (strpos($key, 'optgroup_end-') === 0) {
|
|
| 1458 | + ?></optgroup><?php |
|
| 1459 | + } else {
|
|
| 1460 | + ?> |
|
| 1461 | 1461 | <option |
| 1462 | 1462 | value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option> |
| 1463 | 1463 | <?php |
| 1464 | - } |
|
| 1465 | - } |
|
| 1466 | - ?> |
|
| 1464 | + } |
|
| 1465 | + } |
|
| 1466 | + ?> |
|
| 1467 | 1467 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1468 | 1468 | </td> |
| 1469 | 1469 | </tr><?php |
| 1470 | - break; |
|
| 1471 | - case 'file': |
|
| 1472 | - ?> |
|
| 1470 | + break; |
|
| 1471 | + case 'file': |
|
| 1472 | + ?> |
|
| 1473 | 1473 | <tr valign="top"> |
| 1474 | 1474 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1475 | 1475 | <td class="forminp"> |
@@ -1489,87 +1489,87 @@ discard block |
||
| 1489 | 1489 | <?php } ?> |
| 1490 | 1490 | </td> |
| 1491 | 1491 | </tr><?php |
| 1492 | - break; |
|
| 1493 | - case 'map_default_settings' : |
|
| 1494 | - ?> |
|
| 1492 | + break; |
|
| 1493 | + case 'map_default_settings' : |
|
| 1494 | + ?> |
|
| 1495 | 1495 | |
| 1496 | 1496 | <tr valign="top"> |
| 1497 | 1497 | <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
|
| 1498 | 1498 | <td width="60%"> |
| 1499 | 1499 | <select name="geodir_default_map_language" style="width:60%"> |
| 1500 | 1500 | <?php |
| 1501 | - $arr_map_langages = array( |
|
| 1502 | - 'ar' => __('ARABIC', 'geodirectory'),
|
|
| 1503 | - 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1504 | - 'bg' => __('BULGARIAN', 'geodirectory'),
|
|
| 1505 | - 'bn' => __('BENGALI', 'geodirectory'),
|
|
| 1506 | - 'ca' => __('CATALAN', 'geodirectory'),
|
|
| 1507 | - 'cs' => __('CZECH', 'geodirectory'),
|
|
| 1508 | - 'da' => __('DANISH', 'geodirectory'),
|
|
| 1509 | - 'de' => __('GERMAN', 'geodirectory'),
|
|
| 1510 | - 'el' => __('GREEK', 'geodirectory'),
|
|
| 1511 | - 'en' => __('ENGLISH', 'geodirectory'),
|
|
| 1512 | - 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
|
|
| 1513 | - 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
|
|
| 1514 | - 'es' => __('SPANISH', 'geodirectory'),
|
|
| 1515 | - 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1516 | - 'fa' => __('FARSI', 'geodirectory'),
|
|
| 1517 | - 'fi' => __('FINNISH', 'geodirectory'),
|
|
| 1518 | - 'fil' => __('FILIPINO', 'geodirectory'),
|
|
| 1519 | - 'fr' => __('FRENCH', 'geodirectory'),
|
|
| 1520 | - 'gl' => __('GALICIAN', 'geodirectory'),
|
|
| 1521 | - 'gu' => __('GUJARATI', 'geodirectory'),
|
|
| 1522 | - 'hi' => __('HINDI', 'geodirectory'),
|
|
| 1523 | - 'hr' => __('CROATIAN', 'geodirectory'),
|
|
| 1524 | - 'hu' => __('HUNGARIAN', 'geodirectory'),
|
|
| 1525 | - 'id' => __('INDONESIAN', 'geodirectory'),
|
|
| 1526 | - 'it' => __('ITALIAN', 'geodirectory'),
|
|
| 1527 | - 'iw' => __('HEBREW', 'geodirectory'),
|
|
| 1528 | - 'ja' => __('JAPANESE', 'geodirectory'),
|
|
| 1529 | - 'kn' => __('KANNADA', 'geodirectory'),
|
|
| 1530 | - 'ko' => __('KOREAN', 'geodirectory'),
|
|
| 1531 | - 'lt' => __('LITHUANIAN', 'geodirectory'),
|
|
| 1532 | - 'lv' => __('LATVIAN', 'geodirectory'),
|
|
| 1533 | - 'ml' => __('MALAYALAM', 'geodirectory'),
|
|
| 1534 | - 'mr' => __('MARATHI', 'geodirectory'),
|
|
| 1535 | - 'nl' => __('DUTCH', 'geodirectory'),
|
|
| 1536 | - 'no' => __('NORWEGIAN', 'geodirectory'),
|
|
| 1537 | - 'pl' => __('POLISH', 'geodirectory'),
|
|
| 1538 | - 'pt' => __('PORTUGUESE', 'geodirectory'),
|
|
| 1539 | - 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
|
|
| 1540 | - 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
|
|
| 1541 | - 'ro' => __('ROMANIAN', 'geodirectory'),
|
|
| 1542 | - 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1543 | - 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1544 | - 'sk' => __('SLOVAK', 'geodirectory'),
|
|
| 1545 | - 'sl' => __('SLOVENIAN', 'geodirectory'),
|
|
| 1546 | - 'sr' => __('SERBIAN', 'geodirectory'),
|
|
| 1547 | - 'sv' => __(' SWEDISH', 'geodirectory'),
|
|
| 1548 | - 'tl' => __('TAGALOG', 'geodirectory'),
|
|
| 1549 | - 'ta' => __('TAMIL', 'geodirectory'),
|
|
| 1550 | - 'te' => __('TELUGU', 'geodirectory'),
|
|
| 1551 | - 'th' => __('THAI', 'geodirectory'),
|
|
| 1552 | - 'tr' => __('TURKISH', 'geodirectory'),
|
|
| 1553 | - 'uk' => __('UKRAINIAN', 'geodirectory'),
|
|
| 1554 | - 'vi' => __('VIETNAMESE', 'geodirectory'),
|
|
| 1555 | - 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
|
|
| 1556 | - 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
|
|
| 1557 | - ); |
|
| 1558 | - $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 1559 | - if (empty($geodir_default_map_language)) |
|
| 1560 | - $geodir_default_map_language = 'en'; |
|
| 1561 | - foreach ($arr_map_langages as $language_key => $language_txt) {
|
|
| 1562 | - if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
| 1563 | - $geodir_default_language_selected = "selected='selected'"; |
|
| 1564 | - else |
|
| 1565 | - $geodir_default_language_selected = ''; |
|
| 1566 | - |
|
| 1567 | - ?> |
|
| 1501 | + $arr_map_langages = array( |
|
| 1502 | + 'ar' => __('ARABIC', 'geodirectory'),
|
|
| 1503 | + 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1504 | + 'bg' => __('BULGARIAN', 'geodirectory'),
|
|
| 1505 | + 'bn' => __('BENGALI', 'geodirectory'),
|
|
| 1506 | + 'ca' => __('CATALAN', 'geodirectory'),
|
|
| 1507 | + 'cs' => __('CZECH', 'geodirectory'),
|
|
| 1508 | + 'da' => __('DANISH', 'geodirectory'),
|
|
| 1509 | + 'de' => __('GERMAN', 'geodirectory'),
|
|
| 1510 | + 'el' => __('GREEK', 'geodirectory'),
|
|
| 1511 | + 'en' => __('ENGLISH', 'geodirectory'),
|
|
| 1512 | + 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
|
|
| 1513 | + 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
|
|
| 1514 | + 'es' => __('SPANISH', 'geodirectory'),
|
|
| 1515 | + 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1516 | + 'fa' => __('FARSI', 'geodirectory'),
|
|
| 1517 | + 'fi' => __('FINNISH', 'geodirectory'),
|
|
| 1518 | + 'fil' => __('FILIPINO', 'geodirectory'),
|
|
| 1519 | + 'fr' => __('FRENCH', 'geodirectory'),
|
|
| 1520 | + 'gl' => __('GALICIAN', 'geodirectory'),
|
|
| 1521 | + 'gu' => __('GUJARATI', 'geodirectory'),
|
|
| 1522 | + 'hi' => __('HINDI', 'geodirectory'),
|
|
| 1523 | + 'hr' => __('CROATIAN', 'geodirectory'),
|
|
| 1524 | + 'hu' => __('HUNGARIAN', 'geodirectory'),
|
|
| 1525 | + 'id' => __('INDONESIAN', 'geodirectory'),
|
|
| 1526 | + 'it' => __('ITALIAN', 'geodirectory'),
|
|
| 1527 | + 'iw' => __('HEBREW', 'geodirectory'),
|
|
| 1528 | + 'ja' => __('JAPANESE', 'geodirectory'),
|
|
| 1529 | + 'kn' => __('KANNADA', 'geodirectory'),
|
|
| 1530 | + 'ko' => __('KOREAN', 'geodirectory'),
|
|
| 1531 | + 'lt' => __('LITHUANIAN', 'geodirectory'),
|
|
| 1532 | + 'lv' => __('LATVIAN', 'geodirectory'),
|
|
| 1533 | + 'ml' => __('MALAYALAM', 'geodirectory'),
|
|
| 1534 | + 'mr' => __('MARATHI', 'geodirectory'),
|
|
| 1535 | + 'nl' => __('DUTCH', 'geodirectory'),
|
|
| 1536 | + 'no' => __('NORWEGIAN', 'geodirectory'),
|
|
| 1537 | + 'pl' => __('POLISH', 'geodirectory'),
|
|
| 1538 | + 'pt' => __('PORTUGUESE', 'geodirectory'),
|
|
| 1539 | + 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
|
|
| 1540 | + 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
|
|
| 1541 | + 'ro' => __('ROMANIAN', 'geodirectory'),
|
|
| 1542 | + 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1543 | + 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1544 | + 'sk' => __('SLOVAK', 'geodirectory'),
|
|
| 1545 | + 'sl' => __('SLOVENIAN', 'geodirectory'),
|
|
| 1546 | + 'sr' => __('SERBIAN', 'geodirectory'),
|
|
| 1547 | + 'sv' => __(' SWEDISH', 'geodirectory'),
|
|
| 1548 | + 'tl' => __('TAGALOG', 'geodirectory'),
|
|
| 1549 | + 'ta' => __('TAMIL', 'geodirectory'),
|
|
| 1550 | + 'te' => __('TELUGU', 'geodirectory'),
|
|
| 1551 | + 'th' => __('THAI', 'geodirectory'),
|
|
| 1552 | + 'tr' => __('TURKISH', 'geodirectory'),
|
|
| 1553 | + 'uk' => __('UKRAINIAN', 'geodirectory'),
|
|
| 1554 | + 'vi' => __('VIETNAMESE', 'geodirectory'),
|
|
| 1555 | + 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
|
|
| 1556 | + 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
|
|
| 1557 | + ); |
|
| 1558 | + $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 1559 | + if (empty($geodir_default_map_language)) |
|
| 1560 | + $geodir_default_map_language = 'en'; |
|
| 1561 | + foreach ($arr_map_langages as $language_key => $language_txt) {
|
|
| 1562 | + if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
| 1563 | + $geodir_default_language_selected = "selected='selected'"; |
|
| 1564 | + else |
|
| 1565 | + $geodir_default_language_selected = ''; |
|
| 1566 | + |
|
| 1567 | + ?> |
|
| 1568 | 1568 | <option |
| 1569 | 1569 | value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option> |
| 1570 | 1570 | |
| 1571 | 1571 | <?php } |
| 1572 | - ?> |
|
| 1572 | + ?> |
|
| 1573 | 1573 | </select> |
| 1574 | 1574 | </td> |
| 1575 | 1575 | </tr> |
@@ -1580,46 +1580,46 @@ discard block |
||
| 1580 | 1580 | <td width="60%"> |
| 1581 | 1581 | <select name="geodir_default_map_search_pt" style="width:60%"> |
| 1582 | 1582 | <?php |
| 1583 | - $post_types = geodir_get_posttypes('array');
|
|
| 1584 | - $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
|
|
| 1585 | - if (empty($geodir_default_map_search_pt)) |
|
| 1586 | - $geodir_default_map_search_pt = 'gd_place'; |
|
| 1587 | - if (is_array($post_types)) {
|
|
| 1588 | - foreach ($post_types as $key => $post_types_obj) {
|
|
| 1589 | - if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
| 1590 | - $geodir_search_pt_selected = "selected='selected'"; |
|
| 1591 | - else |
|
| 1592 | - $geodir_search_pt_selected = ''; |
|
| 1593 | - |
|
| 1594 | - ?> |
|
| 1583 | + $post_types = geodir_get_posttypes('array');
|
|
| 1584 | + $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
|
|
| 1585 | + if (empty($geodir_default_map_search_pt)) |
|
| 1586 | + $geodir_default_map_search_pt = 'gd_place'; |
|
| 1587 | + if (is_array($post_types)) {
|
|
| 1588 | + foreach ($post_types as $key => $post_types_obj) {
|
|
| 1589 | + if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
| 1590 | + $geodir_search_pt_selected = "selected='selected'"; |
|
| 1591 | + else |
|
| 1592 | + $geodir_search_pt_selected = ''; |
|
| 1593 | + |
|
| 1594 | + ?> |
|
| 1595 | 1595 | <option |
| 1596 | 1596 | value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo $post_types_obj['labels']['singular_name']; ?></option> |
| 1597 | 1597 | |
| 1598 | 1598 | <?php } |
| 1599 | 1599 | |
| 1600 | - } |
|
| 1600 | + } |
|
| 1601 | 1601 | |
| 1602 | - ?> |
|
| 1602 | + ?> |
|
| 1603 | 1603 | </select> |
| 1604 | 1604 | </td> |
| 1605 | 1605 | </tr> |
| 1606 | 1606 | |
| 1607 | 1607 | <?php |
| 1608 | - break; |
|
| 1608 | + break; |
|
| 1609 | 1609 | |
| 1610 | - case 'map': |
|
| 1611 | - ?> |
|
| 1610 | + case 'map': |
|
| 1611 | + ?> |
|
| 1612 | 1612 | <tr valign="top"> |
| 1613 | 1613 | <td class="forminp"> |
| 1614 | 1614 | <?php |
| 1615 | - global $post_cat, $cat_display; |
|
| 1616 | - $post_types = geodir_get_posttypes('object');
|
|
| 1617 | - $cat_display = 'checkbox'; |
|
| 1618 | - $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
|
| 1619 | - $gd_cats = get_option('geodir_exclude_cat_on_map');
|
|
| 1620 | - $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 1621 | - $count = 1; |
|
| 1622 | - ?> |
|
| 1615 | + global $post_cat, $cat_display; |
|
| 1616 | + $post_types = geodir_get_posttypes('object');
|
|
| 1617 | + $cat_display = 'checkbox'; |
|
| 1618 | + $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
|
| 1619 | + $gd_cats = get_option('geodir_exclude_cat_on_map');
|
|
| 1620 | + $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 1621 | + $count = 1; |
|
| 1622 | + ?> |
|
| 1623 | 1623 | <table width="70%" class="widefat"> |
| 1624 | 1624 | <thead> |
| 1625 | 1625 | <tr> |
@@ -1628,18 +1628,18 @@ discard block |
||
| 1628 | 1628 | <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th> |
| 1629 | 1629 | </tr> |
| 1630 | 1630 | <?php |
| 1631 | - $gd_categs = $gd_cats; |
|
| 1632 | - foreach ($post_types as $key => $post_types_obj) : |
|
| 1633 | - $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
| 1634 | - $gd_taxonomy = geodir_get_taxonomies($key); |
|
| 1635 | - if ($gd_cats_upgrade) {
|
|
| 1636 | - $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
| 1637 | - $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
| 1638 | - $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
| 1639 | - } |
|
| 1640 | - $post_cat = implode(',', $gd_cats);
|
|
| 1641 | - $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
| 1642 | - ?> |
|
| 1631 | + $gd_categs = $gd_cats; |
|
| 1632 | + foreach ($post_types as $key => $post_types_obj) : |
|
| 1633 | + $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
| 1634 | + $gd_taxonomy = geodir_get_taxonomies($key); |
|
| 1635 | + if ($gd_cats_upgrade) {
|
|
| 1636 | + $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
| 1637 | + $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
| 1638 | + $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
| 1639 | + } |
|
| 1640 | + $post_cat = implode(',', $gd_cats);
|
|
| 1641 | + $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
| 1642 | + ?> |
|
| 1643 | 1643 | <tr> |
| 1644 | 1644 | <td valign="top" width="5%"><?php echo $count; ?></td> |
| 1645 | 1645 | <td valign="top" width="25%" id="td_post_types"><input type="checkbox" |
@@ -1660,19 +1660,19 @@ discard block |
||
| 1660 | 1660 | </td> |
| 1661 | 1661 | </tr> |
| 1662 | 1662 | <?php |
| 1663 | - break; |
|
| 1663 | + break; |
|
| 1664 | 1664 | |
| 1665 | - case 'checkbox' : |
|
| 1665 | + case 'checkbox' : |
|
| 1666 | 1666 | |
| 1667 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
| 1668 | - ?> |
|
| 1667 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
| 1668 | + ?> |
|
| 1669 | 1669 | <tr valign="top"> |
| 1670 | 1670 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1671 | 1671 | <td class="forminp"> |
| 1672 | 1672 | <?php |
| 1673 | - endif; |
|
| 1673 | + endif; |
|
| 1674 | 1674 | |
| 1675 | - ?> |
|
| 1675 | + ?> |
|
| 1676 | 1676 | <fieldset> |
| 1677 | 1677 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 1678 | 1678 | <label for="<?php echo $value['id'] ?>"> |
@@ -1682,49 +1682,49 @@ discard block |
||
| 1682 | 1682 | </fieldset> |
| 1683 | 1683 | <?php |
| 1684 | 1684 | |
| 1685 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
| 1686 | - ?> |
|
| 1685 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
| 1686 | + ?> |
|
| 1687 | 1687 | </td> |
| 1688 | 1688 | </tr> |
| 1689 | 1689 | <?php |
| 1690 | - endif; |
|
| 1690 | + endif; |
|
| 1691 | 1691 | |
| 1692 | - break; |
|
| 1692 | + break; |
|
| 1693 | 1693 | |
| 1694 | - case 'radio' : |
|
| 1694 | + case 'radio' : |
|
| 1695 | 1695 | |
| 1696 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
| 1697 | - ?> |
|
| 1696 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
| 1697 | + ?> |
|
| 1698 | 1698 | <tr valign="top"> |
| 1699 | 1699 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1700 | 1700 | <td class="forminp"> |
| 1701 | 1701 | <?php |
| 1702 | - endif; |
|
| 1702 | + endif; |
|
| 1703 | 1703 | |
| 1704 | - ?> |
|
| 1704 | + ?> |
|
| 1705 | 1705 | <fieldset> |
| 1706 | 1706 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 1707 | 1707 | <label for="<?php echo $value['id'];?>"> |
| 1708 | 1708 | <input name="<?php echo esc_attr($value['id']); ?>" |
| 1709 | 1709 | id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio" |
| 1710 | 1710 | value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
|
| 1711 | - echo 'checked="checked"'; |
|
| 1712 | - }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 1711 | + echo 'checked="checked"'; |
|
| 1712 | + }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 1713 | 1713 | <?php echo $value['desc']; ?></label><br> |
| 1714 | 1714 | </fieldset> |
| 1715 | 1715 | <?php |
| 1716 | 1716 | |
| 1717 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
| 1718 | - ?> |
|
| 1717 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
| 1718 | + ?> |
|
| 1719 | 1719 | </td> |
| 1720 | 1720 | </tr> |
| 1721 | 1721 | <?php |
| 1722 | - endif; |
|
| 1722 | + endif; |
|
| 1723 | 1723 | |
| 1724 | - break; |
|
| 1724 | + break; |
|
| 1725 | 1725 | |
| 1726 | - case 'textarea': |
|
| 1727 | - ?> |
|
| 1726 | + case 'textarea': |
|
| 1727 | + ?> |
|
| 1728 | 1728 | <tr valign="top"> |
| 1729 | 1729 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1730 | 1730 | <td class="forminp"> |
@@ -1737,30 +1737,30 @@ discard block |
||
| 1737 | 1737 | |
| 1738 | 1738 | </td> |
| 1739 | 1739 | </tr><?php |
| 1740 | - break; |
|
| 1740 | + break; |
|
| 1741 | 1741 | |
| 1742 | - case 'editor': |
|
| 1743 | - ?> |
|
| 1742 | + case 'editor': |
|
| 1743 | + ?> |
|
| 1744 | 1744 | <tr valign="top"> |
| 1745 | 1745 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1746 | 1746 | <td class="forminp"><?php |
| 1747 | - if (get_option($value['id'])) |
|
| 1748 | - $content = stripslashes(get_option($value['id'])); |
|
| 1749 | - else |
|
| 1750 | - $content = $value['std']; |
|
| 1747 | + if (get_option($value['id'])) |
|
| 1748 | + $content = stripslashes(get_option($value['id'])); |
|
| 1749 | + else |
|
| 1750 | + $content = $value['std']; |
|
| 1751 | 1751 | |
| 1752 | - $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
|
| 1752 | + $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
|
| 1753 | 1753 | |
| 1754 | - wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
| 1754 | + wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
| 1755 | 1755 | |
| 1756 | - ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
| 1756 | + ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
| 1757 | 1757 | |
| 1758 | 1758 | </td> |
| 1759 | 1759 | </tr><?php |
| 1760 | - break; |
|
| 1760 | + break; |
|
| 1761 | 1761 | |
| 1762 | - case 'single_select_page' : |
|
| 1763 | - // WPML |
|
| 1762 | + case 'single_select_page' : |
|
| 1763 | + // WPML |
|
| 1764 | 1764 | $switch_lang = false; |
| 1765 | 1765 | $disabled = ''; |
| 1766 | 1766 | if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
|
@@ -1778,18 +1778,18 @@ discard block |
||
| 1778 | 1778 | // |
| 1779 | 1779 | $page_setting = (int)get_option($value['id']); |
| 1780 | 1780 | |
| 1781 | - $args = array('name' => $value['id'],
|
|
| 1782 | - 'id' => $value['id'], |
|
| 1783 | - 'sort_column' => 'menu_order', |
|
| 1784 | - 'sort_order' => 'ASC', |
|
| 1785 | - 'show_option_none' => ' ', |
|
| 1786 | - 'class' => $value['class'], |
|
| 1787 | - 'echo' => false, |
|
| 1788 | - 'selected' => $page_setting); |
|
| 1781 | + $args = array('name' => $value['id'],
|
|
| 1782 | + 'id' => $value['id'], |
|
| 1783 | + 'sort_column' => 'menu_order', |
|
| 1784 | + 'sort_order' => 'ASC', |
|
| 1785 | + 'show_option_none' => ' ', |
|
| 1786 | + 'class' => $value['class'], |
|
| 1787 | + 'echo' => false, |
|
| 1788 | + 'selected' => $page_setting); |
|
| 1789 | 1789 | |
| 1790 | - if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
| 1790 | + if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
| 1791 | 1791 | |
| 1792 | - ?> |
|
| 1792 | + ?> |
|
| 1793 | 1793 | <tr valign="top" class="single_select_page"> |
| 1794 | 1794 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1795 | 1795 | <td class="forminp"> |
@@ -1800,17 +1800,17 @@ discard block |
||
| 1800 | 1800 | if ($switch_lang) {
|
| 1801 | 1801 | $sitepress->switch_lang($switch_lang, true); |
| 1802 | 1802 | } |
| 1803 | - break; |
|
| 1804 | - case 'single_select_country' : |
|
| 1805 | - $country_setting = (string)get_option($value['id']); |
|
| 1806 | - if (strstr($country_setting, ':')) : |
|
| 1807 | - $country = current(explode(':', $country_setting));
|
|
| 1808 | - $state = end(explode(':', $country_setting));
|
|
| 1809 | - else : |
|
| 1810 | - $country = $country_setting; |
|
| 1811 | - $state = '*'; |
|
| 1812 | - endif; |
|
| 1813 | - ?> |
|
| 1803 | + break; |
|
| 1804 | + case 'single_select_country' : |
|
| 1805 | + $country_setting = (string)get_option($value['id']); |
|
| 1806 | + if (strstr($country_setting, ':')) : |
|
| 1807 | + $country = current(explode(':', $country_setting));
|
|
| 1808 | + $state = end(explode(':', $country_setting));
|
|
| 1809 | + else : |
|
| 1810 | + $country = $country_setting; |
|
| 1811 | + $state = '*'; |
|
| 1812 | + endif; |
|
| 1813 | + ?> |
|
| 1814 | 1814 | <tr valign="top"> |
| 1815 | 1815 | <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th> |
| 1816 | 1816 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -1821,12 +1821,12 @@ discard block |
||
| 1821 | 1821 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1822 | 1822 | </td> |
| 1823 | 1823 | </tr><?php |
| 1824 | - break; |
|
| 1825 | - case 'multi_select_countries' : |
|
| 1826 | - $countries = $geodirectory->countries->countries; |
|
| 1827 | - asort($countries); |
|
| 1828 | - $selections = (array)get_option($value['id']); |
|
| 1829 | - ?> |
|
| 1824 | + break; |
|
| 1825 | + case 'multi_select_countries' : |
|
| 1826 | + $countries = $geodirectory->countries->countries; |
|
| 1827 | + asort($countries); |
|
| 1828 | + $selections = (array)get_option($value['id']); |
|
| 1829 | + ?> |
|
| 1830 | 1830 | <tr valign="top"> |
| 1831 | 1831 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1832 | 1832 | <td class="forminp"> |
@@ -1834,22 +1834,22 @@ discard block |
||
| 1834 | 1834 | data-placeholder="<?php _e('Choose countries…', 'geodirectory'); ?>"
|
| 1835 | 1835 | title="Country" class="chosen_select"> |
| 1836 | 1836 | <?php |
| 1837 | - if ($countries) foreach ($countries as $key => $val) : |
|
| 1838 | - echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 1839 | - endforeach; |
|
| 1840 | - ?> |
|
| 1837 | + if ($countries) foreach ($countries as $key => $val) : |
|
| 1838 | + echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 1839 | + endforeach; |
|
| 1840 | + ?> |
|
| 1841 | 1841 | </select> |
| 1842 | 1842 | </td> |
| 1843 | 1843 | </tr> |
| 1844 | 1844 | |
| 1845 | 1845 | <?php |
| 1846 | 1846 | |
| 1847 | - break; |
|
| 1847 | + break; |
|
| 1848 | 1848 | |
| 1849 | - case 'google_analytics' : |
|
| 1850 | - $selections = (array)get_option($value['id']); |
|
| 1851 | - if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
|
|
| 1852 | - ?> |
|
| 1849 | + case 'google_analytics' : |
|
| 1850 | + $selections = (array)get_option($value['id']); |
|
| 1851 | + if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
|
|
| 1852 | + ?> |
|
| 1853 | 1853 | <tr valign="top"> |
| 1854 | 1854 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1855 | 1855 | <td class="forminp"> |
@@ -1857,19 +1857,19 @@ discard block |
||
| 1857 | 1857 | |
| 1858 | 1858 | <?php |
| 1859 | 1859 | |
| 1860 | - $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
| 1861 | - $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
| 1862 | - $state = "&state=123";//any string |
|
| 1863 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 1864 | - $response_type = "&response_type=code"; |
|
| 1865 | - $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 1866 | - $access_type = "&access_type=offline"; |
|
| 1867 | - $approval_prompt = "&approval_prompt=force"; |
|
| 1860 | + $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
| 1861 | + $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
| 1862 | + $state = "&state=123";//any string |
|
| 1863 | + $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 1864 | + $response_type = "&response_type=code"; |
|
| 1865 | + $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 1866 | + $access_type = "&access_type=offline"; |
|
| 1867 | + $approval_prompt = "&approval_prompt=force"; |
|
| 1868 | 1868 | |
| 1869 | - $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
| 1869 | + $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
| 1870 | 1870 | |
| 1871 | 1871 | |
| 1872 | - ?> |
|
| 1872 | + ?> |
|
| 1873 | 1873 | <script> |
| 1874 | 1874 | function gd_ga_popup() {
|
| 1875 | 1875 | var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
|
@@ -1884,47 +1884,47 @@ discard block |
||
| 1884 | 1884 | </script> |
| 1885 | 1885 | |
| 1886 | 1886 | <?php |
| 1887 | - if (get_option('gd_ga_refresh_token')) {
|
|
| 1888 | - ?> |
|
| 1887 | + if (get_option('gd_ga_refresh_token')) {
|
|
| 1888 | + ?> |
|
| 1889 | 1889 | <span class="button-primary" |
| 1890 | 1890 | onclick="gd_ga_popup();"><?php _e('Re-authorize', 'geodirectory'); ?></span>
|
| 1891 | 1891 | <span |
| 1892 | 1892 | style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
|
| 1893 | 1893 | <?php |
| 1894 | - } else {
|
|
| 1895 | - ?> |
|
| 1894 | + } else {
|
|
| 1895 | + ?> |
|
| 1896 | 1896 | <span class="button-primary" |
| 1897 | 1897 | onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
|
| 1898 | 1898 | <?php |
| 1899 | - } |
|
| 1900 | - ?> |
|
| 1899 | + } |
|
| 1900 | + ?> |
|
| 1901 | 1901 | </td> |
| 1902 | 1902 | </tr> |
| 1903 | 1903 | |
| 1904 | 1904 | <?php |
| 1905 | - } |
|
| 1905 | + } |
|
| 1906 | 1906 | |
| 1907 | - break; |
|
| 1907 | + break; |
|
| 1908 | 1908 | |
| 1909 | - case 'field_seperator' : |
|
| 1909 | + case 'field_seperator' : |
|
| 1910 | 1910 | |
| 1911 | - ?> |
|
| 1911 | + ?> |
|
| 1912 | 1912 | <tr valign="top"> |
| 1913 | 1913 | <td colspan="2" class="forminp geodir_line_seperator"></td> |
| 1914 | 1914 | </tr> |
| 1915 | 1915 | <?php |
| 1916 | 1916 | |
| 1917 | - break; |
|
| 1917 | + break; |
|
| 1918 | 1918 | |
| 1919 | - endswitch; |
|
| 1919 | + endswitch; |
|
| 1920 | 1920 | |
| 1921 | - endforeach; |
|
| 1921 | + endforeach; |
|
| 1922 | 1922 | |
| 1923 | - if ($first_title === false) {
|
|
| 1924 | - echo "</div>"; |
|
| 1925 | - } |
|
| 1923 | + if ($first_title === false) {
|
|
| 1924 | + echo "</div>"; |
|
| 1925 | + } |
|
| 1926 | 1926 | |
| 1927 | - ?> |
|
| 1927 | + ?> |
|
| 1928 | 1928 | |
| 1929 | 1929 | <script type="text/javascript"> |
| 1930 | 1930 | |
@@ -1984,33 +1984,33 @@ discard block |
||
| 1984 | 1984 | */ |
| 1985 | 1985 | function geodir_post_info_setting() |
| 1986 | 1986 | {
|
| 1987 | - global $post, $post_id; |
|
| 1988 | - |
|
| 1989 | - $post_type = get_post_type(); |
|
| 1990 | - |
|
| 1991 | - $package_info = array(); |
|
| 1992 | - |
|
| 1993 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1994 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
| 1995 | - echo '<div id="geodir_wrapper">'; |
|
| 1996 | - /** |
|
| 1997 | - * Called before the GD custom fields are output in the wp-admin area. |
|
| 1998 | - * |
|
| 1999 | - * @since 1.0.0 |
|
| 2000 | - * @see 'geodir_after_default_field_in_meta_box' |
|
| 2001 | - */ |
|
| 2002 | - do_action('geodir_before_default_field_in_meta_box');
|
|
| 2003 | - //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
| 2004 | - // to display all fields in one information box |
|
| 2005 | - geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
| 2006 | - /** |
|
| 2007 | - * Called after the GD custom fields are output in the wp-admin area. |
|
| 2008 | - * |
|
| 2009 | - * @since 1.0.0 |
|
| 2010 | - * @see 'geodir_before_default_field_in_meta_box' |
|
| 2011 | - */ |
|
| 2012 | - do_action('geodir_after_default_field_in_meta_box');
|
|
| 2013 | - echo '</div>'; |
|
| 1987 | + global $post, $post_id; |
|
| 1988 | + |
|
| 1989 | + $post_type = get_post_type(); |
|
| 1990 | + |
|
| 1991 | + $package_info = array(); |
|
| 1992 | + |
|
| 1993 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1994 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
| 1995 | + echo '<div id="geodir_wrapper">'; |
|
| 1996 | + /** |
|
| 1997 | + * Called before the GD custom fields are output in the wp-admin area. |
|
| 1998 | + * |
|
| 1999 | + * @since 1.0.0 |
|
| 2000 | + * @see 'geodir_after_default_field_in_meta_box' |
|
| 2001 | + */ |
|
| 2002 | + do_action('geodir_before_default_field_in_meta_box');
|
|
| 2003 | + //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
| 2004 | + // to display all fields in one information box |
|
| 2005 | + geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
| 2006 | + /** |
|
| 2007 | + * Called after the GD custom fields are output in the wp-admin area. |
|
| 2008 | + * |
|
| 2009 | + * @since 1.0.0 |
|
| 2010 | + * @see 'geodir_before_default_field_in_meta_box' |
|
| 2011 | + */ |
|
| 2012 | + do_action('geodir_after_default_field_in_meta_box');
|
|
| 2013 | + echo '</div>'; |
|
| 2014 | 2014 | } |
| 2015 | 2015 | |
| 2016 | 2016 | /** |
@@ -2023,18 +2023,18 @@ discard block |
||
| 2023 | 2023 | */ |
| 2024 | 2024 | function geodir_post_addinfo_setting() |
| 2025 | 2025 | {
|
| 2026 | - global $post, $post_id; |
|
| 2026 | + global $post, $post_id; |
|
| 2027 | 2027 | |
| 2028 | - $post_type = get_post_type(); |
|
| 2028 | + $post_type = get_post_type(); |
|
| 2029 | 2029 | |
| 2030 | - $package_info = array(); |
|
| 2030 | + $package_info = array(); |
|
| 2031 | 2031 | |
| 2032 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 2032 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 2033 | 2033 | |
| 2034 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
| 2035 | - echo '<div id="geodir_wrapper">'; |
|
| 2036 | - geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
| 2037 | - echo '</div>'; |
|
| 2034 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
| 2035 | + echo '<div id="geodir_wrapper">'; |
|
| 2036 | + geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
| 2037 | + echo '</div>'; |
|
| 2038 | 2038 | |
| 2039 | 2039 | } |
| 2040 | 2040 | |
@@ -2048,60 +2048,60 @@ discard block |
||
| 2048 | 2048 | */ |
| 2049 | 2049 | function geodir_post_attachments() |
| 2050 | 2050 | {
|
| 2051 | - global $post, $post_id; |
|
| 2051 | + global $post, $post_id; |
|
| 2052 | 2052 | |
| 2053 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
| 2053 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
| 2054 | 2054 | |
| 2055 | - if (geodir_get_featured_image($post_id, 'thumbnail')) {
|
|
| 2056 | - echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
|
|
| 2057 | - geodir_show_featured_image($post_id, 'thumbnail'); |
|
| 2058 | - } |
|
| 2055 | + if (geodir_get_featured_image($post_id, 'thumbnail')) {
|
|
| 2056 | + echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
|
|
| 2057 | + geodir_show_featured_image($post_id, 'thumbnail'); |
|
| 2058 | + } |
|
| 2059 | 2059 | |
| 2060 | - $image_limit = 0; |
|
| 2060 | + $image_limit = 0; |
|
| 2061 | 2061 | |
| 2062 | - ?> |
|
| 2062 | + ?> |
|
| 2063 | 2063 | |
| 2064 | 2064 | |
| 2065 | 2065 | <h5 class="form_title"> |
| 2066 | 2066 | <?php if ($image_limit != 0 && $image_limit == 1) {
|
| 2067 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 2068 | - } ?> |
|
| 2067 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 2068 | + } ?> |
|
| 2069 | 2069 | <?php if ($image_limit != 0 && $image_limit > 1) {
|
| 2070 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 2071 | - } ?> |
|
| 2070 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 2071 | + } ?> |
|
| 2072 | 2072 | <?php if ($image_limit == 0) {
|
| 2073 | - echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 2074 | - } ?> |
|
| 2073 | + echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 2074 | + } ?> |
|
| 2075 | 2075 | </h5> |
| 2076 | 2076 | |
| 2077 | 2077 | |
| 2078 | 2078 | <?php |
| 2079 | 2079 | |
| 2080 | - $curImages = geodir_get_images($post_id); |
|
| 2081 | - $place_img_array = array(); |
|
| 2080 | + $curImages = geodir_get_images($post_id); |
|
| 2081 | + $place_img_array = array(); |
|
| 2082 | 2082 | |
| 2083 | - if (!empty($curImages)): |
|
| 2084 | - foreach ($curImages as $p_img): |
|
| 2085 | - $place_img_array[] = $p_img->src; |
|
| 2086 | - endforeach; |
|
| 2087 | - endif; |
|
| 2083 | + if (!empty($curImages)): |
|
| 2084 | + foreach ($curImages as $p_img): |
|
| 2085 | + $place_img_array[] = $p_img->src; |
|
| 2086 | + endforeach; |
|
| 2087 | + endif; |
|
| 2088 | 2088 | |
| 2089 | - if (!empty($place_img_array)) |
|
| 2090 | - $curImages = implode(',', $place_img_array);
|
|
| 2089 | + if (!empty($place_img_array)) |
|
| 2090 | + $curImages = implode(',', $place_img_array);
|
|
| 2091 | 2091 | |
| 2092 | 2092 | |
| 2093 | - // adjust values here |
|
| 2094 | - $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 |
|
| 2093 | + // adjust values here |
|
| 2094 | + $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 |
|
| 2095 | 2095 | |
| 2096 | - $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
| 2096 | + $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
| 2097 | 2097 | |
| 2098 | - $multiple = true; // allow multiple files upload |
|
| 2098 | + $multiple = true; // allow multiple files upload |
|
| 2099 | 2099 | |
| 2100 | - $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 2100 | + $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 2101 | 2101 | |
| 2102 | - $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 2102 | + $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 2103 | 2103 | |
| 2104 | - ?> |
|
| 2104 | + ?> |
|
| 2105 | 2105 | |
| 2106 | 2106 | <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;"> |
| 2107 | 2107 | <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/> |
@@ -2143,13 +2143,13 @@ discard block |
||
| 2143 | 2143 | */ |
| 2144 | 2144 | function geodir_action_post_updated($post_ID, $post_after, $post_before) |
| 2145 | 2145 | {
|
| 2146 | - $post_type = get_post_type($post_ID); |
|
| 2146 | + $post_type = get_post_type($post_ID); |
|
| 2147 | 2147 | |
| 2148 | - if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 2149 | - 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) {
|
|
| 2150 | - geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
| 2151 | - } |
|
| 2152 | - } |
|
| 2148 | + if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 2149 | + 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) {
|
|
| 2150 | + geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
| 2151 | + } |
|
| 2152 | + } |
|
| 2153 | 2153 | } |
| 2154 | 2154 | |
| 2155 | 2155 | /** |
@@ -2164,39 +2164,39 @@ discard block |
||
| 2164 | 2164 | */ |
| 2165 | 2165 | function geodir_notification_add_bcc_option($settings) |
| 2166 | 2166 | {
|
| 2167 | - if (!empty($settings)) {
|
|
| 2168 | - $new_settings = array(); |
|
| 2169 | - foreach ($settings as $setting) {
|
|
| 2170 | - if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
|
|
| 2171 | - $geodir_bcc_listing_published_yes = array( |
|
| 2172 | - 'name' => __('Listing published', 'geodirectory'),
|
|
| 2173 | - 'desc' => __('Yes', 'geodirectory'),
|
|
| 2174 | - 'id' => 'geodir_bcc_listing_published', |
|
| 2175 | - 'std' => 'yes', |
|
| 2176 | - 'type' => 'radio', |
|
| 2177 | - 'value' => '1', |
|
| 2178 | - 'radiogroup' => 'start' |
|
| 2179 | - ); |
|
| 2180 | - |
|
| 2181 | - $geodir_bcc_listing_published_no = array( |
|
| 2182 | - 'name' => __('Listing published', 'geodirectory'),
|
|
| 2183 | - 'desc' => __('No', 'geodirectory'),
|
|
| 2184 | - 'id' => 'geodir_bcc_listing_published', |
|
| 2185 | - 'std' => 'yes', |
|
| 2186 | - 'type' => 'radio', |
|
| 2187 | - 'value' => '0', |
|
| 2188 | - 'radiogroup' => 'end' |
|
| 2189 | - ); |
|
| 2190 | - |
|
| 2191 | - $new_settings[] = $geodir_bcc_listing_published_yes; |
|
| 2192 | - $new_settings[] = $geodir_bcc_listing_published_no; |
|
| 2193 | - } |
|
| 2194 | - $new_settings[] = $setting; |
|
| 2195 | - } |
|
| 2196 | - $settings = $new_settings; |
|
| 2197 | - } |
|
| 2167 | + if (!empty($settings)) {
|
|
| 2168 | + $new_settings = array(); |
|
| 2169 | + foreach ($settings as $setting) {
|
|
| 2170 | + if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
|
|
| 2171 | + $geodir_bcc_listing_published_yes = array( |
|
| 2172 | + 'name' => __('Listing published', 'geodirectory'),
|
|
| 2173 | + 'desc' => __('Yes', 'geodirectory'),
|
|
| 2174 | + 'id' => 'geodir_bcc_listing_published', |
|
| 2175 | + 'std' => 'yes', |
|
| 2176 | + 'type' => 'radio', |
|
| 2177 | + 'value' => '1', |
|
| 2178 | + 'radiogroup' => 'start' |
|
| 2179 | + ); |
|
| 2180 | + |
|
| 2181 | + $geodir_bcc_listing_published_no = array( |
|
| 2182 | + 'name' => __('Listing published', 'geodirectory'),
|
|
| 2183 | + 'desc' => __('No', 'geodirectory'),
|
|
| 2184 | + 'id' => 'geodir_bcc_listing_published', |
|
| 2185 | + 'std' => 'yes', |
|
| 2186 | + 'type' => 'radio', |
|
| 2187 | + 'value' => '0', |
|
| 2188 | + 'radiogroup' => 'end' |
|
| 2189 | + ); |
|
| 2190 | + |
|
| 2191 | + $new_settings[] = $geodir_bcc_listing_published_yes; |
|
| 2192 | + $new_settings[] = $geodir_bcc_listing_published_no; |
|
| 2193 | + } |
|
| 2194 | + $new_settings[] = $setting; |
|
| 2195 | + } |
|
| 2196 | + $settings = $new_settings; |
|
| 2197 | + } |
|
| 2198 | 2198 | |
| 2199 | - return $settings; |
|
| 2199 | + return $settings; |
|
| 2200 | 2200 | } |
| 2201 | 2201 | |
| 2202 | 2202 | |
@@ -2211,19 +2211,19 @@ discard block |
||
| 2211 | 2211 | */ |
| 2212 | 2212 | function get_gd_theme_compat_callback() |
| 2213 | 2213 | {
|
| 2214 | - global $wpdb; |
|
| 2215 | - $themes = get_option('gd_theme_compats');
|
|
| 2216 | - |
|
| 2217 | - if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
|
|
| 2218 | - if (isset($_POST['export'])) {
|
|
| 2219 | - echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
| 2220 | - } else {
|
|
| 2221 | - echo json_encode($themes[$_POST['theme']]); |
|
| 2222 | - } |
|
| 2214 | + global $wpdb; |
|
| 2215 | + $themes = get_option('gd_theme_compats');
|
|
| 2223 | 2216 | |
| 2224 | - } |
|
| 2217 | + if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
|
|
| 2218 | + if (isset($_POST['export'])) {
|
|
| 2219 | + echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
| 2220 | + } else {
|
|
| 2221 | + echo json_encode($themes[$_POST['theme']]); |
|
| 2222 | + } |
|
| 2223 | + |
|
| 2224 | + } |
|
| 2225 | 2225 | |
| 2226 | - die(); |
|
| 2226 | + die(); |
|
| 2227 | 2227 | } |
| 2228 | 2228 | |
| 2229 | 2229 | add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback');
|
@@ -2237,20 +2237,20 @@ discard block |
||
| 2237 | 2237 | */ |
| 2238 | 2238 | function get_gd_theme_compat_import_callback() |
| 2239 | 2239 | {
|
| 2240 | - global $wpdb; |
|
| 2241 | - $themes = get_option('gd_theme_compats');
|
|
| 2242 | - if (isset($_POST['theme']) && !empty($_POST['theme'])) {
|
|
| 2243 | - $json = json_decode(stripslashes($_POST['theme']), true); |
|
| 2244 | - if (!empty($json) && is_array($json)) {
|
|
| 2245 | - $key = sanitize_text_field(key($json)); |
|
| 2246 | - $themes[$key] = $json[$key]; |
|
| 2247 | - update_option('gd_theme_compats', $themes);
|
|
| 2248 | - echo $key; |
|
| 2249 | - die(); |
|
| 2250 | - } |
|
| 2251 | - } |
|
| 2252 | - echo '0'; |
|
| 2253 | - die(); |
|
| 2240 | + global $wpdb; |
|
| 2241 | + $themes = get_option('gd_theme_compats');
|
|
| 2242 | + if (isset($_POST['theme']) && !empty($_POST['theme'])) {
|
|
| 2243 | + $json = json_decode(stripslashes($_POST['theme']), true); |
|
| 2244 | + if (!empty($json) && is_array($json)) {
|
|
| 2245 | + $key = sanitize_text_field(key($json)); |
|
| 2246 | + $themes[$key] = $json[$key]; |
|
| 2247 | + update_option('gd_theme_compats', $themes);
|
|
| 2248 | + echo $key; |
|
| 2249 | + die(); |
|
| 2250 | + } |
|
| 2251 | + } |
|
| 2252 | + echo '0'; |
|
| 2253 | + die(); |
|
| 2254 | 2254 | } |
| 2255 | 2255 | |
| 2256 | 2256 | |
@@ -2263,39 +2263,39 @@ discard block |
||
| 2263 | 2263 | */ |
| 2264 | 2264 | function gd_set_theme_compat() |
| 2265 | 2265 | {
|
| 2266 | - global $wpdb; |
|
| 2267 | - $theme = wp_get_theme(); |
|
| 2266 | + global $wpdb; |
|
| 2267 | + $theme = wp_get_theme(); |
|
| 2268 | 2268 | |
| 2269 | - if ($theme->parent()) {
|
|
| 2270 | - $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
|
|
| 2271 | - } else {
|
|
| 2272 | - $theme_name = str_replace(" ", "_", $theme->get('Name'));
|
|
| 2273 | - } |
|
| 2269 | + if ($theme->parent()) {
|
|
| 2270 | + $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
|
|
| 2271 | + } else {
|
|
| 2272 | + $theme_name = str_replace(" ", "_", $theme->get('Name'));
|
|
| 2273 | + } |
|
| 2274 | 2274 | |
| 2275 | - $theme_compats = get_option('gd_theme_compats');
|
|
| 2276 | - $current_compat = get_option('gd_theme_compat');
|
|
| 2277 | - $current_compat = str_replace("_custom", "", $current_compat);
|
|
| 2275 | + $theme_compats = get_option('gd_theme_compats');
|
|
| 2276 | + $current_compat = get_option('gd_theme_compat');
|
|
| 2277 | + $current_compat = str_replace("_custom", "", $current_compat);
|
|
| 2278 | 2278 | |
| 2279 | - if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
|
|
| 2280 | - return; |
|
| 2281 | - }// if already running correct compat then bail |
|
| 2279 | + if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
|
|
| 2280 | + return; |
|
| 2281 | + }// if already running correct compat then bail |
|
| 2282 | 2282 | |
| 2283 | - if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
|
|
| 2284 | - update_option('gd_theme_compat', $theme_name);
|
|
| 2285 | - update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
|
|
| 2283 | + if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
|
|
| 2284 | + update_option('gd_theme_compat', $theme_name);
|
|
| 2285 | + update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
|
|
| 2286 | 2286 | |
| 2287 | - // if there are default options to set then set them |
|
| 2288 | - if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
|
|
| 2287 | + // if there are default options to set then set them |
|
| 2288 | + if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
|
|
| 2289 | 2289 | |
| 2290 | - foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
|
|
| 2291 | - update_option($key, $val); |
|
| 2292 | - } |
|
| 2293 | - } |
|
| 2290 | + foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
|
|
| 2291 | + update_option($key, $val); |
|
| 2292 | + } |
|
| 2293 | + } |
|
| 2294 | 2294 | |
| 2295 | - } else {
|
|
| 2296 | - update_option('gd_theme_compat', '');
|
|
| 2297 | - update_option('theme_compatibility_setting', '');
|
|
| 2298 | - } |
|
| 2295 | + } else {
|
|
| 2296 | + update_option('gd_theme_compat', '');
|
|
| 2297 | + update_option('theme_compatibility_setting', '');
|
|
| 2298 | + } |
|
| 2299 | 2299 | |
| 2300 | 2300 | |
| 2301 | 2301 | } |
@@ -2310,9 +2310,9 @@ discard block |
||
| 2310 | 2310 | */ |
| 2311 | 2311 | function gd_check_avada_compat() |
| 2312 | 2312 | {
|
| 2313 | - if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
|
|
| 2314 | - add_action('admin_notices', 'gd_avada_compat_warning');
|
|
| 2315 | - } |
|
| 2313 | + if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
|
|
| 2314 | + add_action('admin_notices', 'gd_avada_compat_warning');
|
|
| 2315 | + } |
|
| 2316 | 2316 | } |
| 2317 | 2317 | |
| 2318 | 2318 | |
@@ -2325,22 +2325,22 @@ discard block |
||
| 2325 | 2325 | function gd_avada_compat_warning() |
| 2326 | 2326 | {
|
| 2327 | 2327 | |
| 2328 | - /* |
|
| 2328 | + /* |
|
| 2329 | 2329 | $msg_type = error |
| 2330 | 2330 | $msg_type = updated fade |
| 2331 | 2331 | $msg_type = update-nag |
| 2332 | 2332 | */ |
| 2333 | 2333 | |
| 2334 | - $plugin = 'avada-nag'; |
|
| 2335 | - $timestamp = 'avada-nag1234'; |
|
| 2336 | - $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');
|
|
| 2337 | - echo '<div id="' . $timestamp . '" class="error">'; |
|
| 2338 | - echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
| 2339 | - echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 2340 | - echo "<p>$message</p>"; |
|
| 2341 | - echo "</div>"; |
|
| 2334 | + $plugin = 'avada-nag'; |
|
| 2335 | + $timestamp = 'avada-nag1234'; |
|
| 2336 | + $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');
|
|
| 2337 | + echo '<div id="' . $timestamp . '" class="error">'; |
|
| 2338 | + echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
| 2339 | + echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 2340 | + echo "<p>$message</p>"; |
|
| 2341 | + echo "</div>"; |
|
| 2342 | 2342 | |
| 2343 | - ?> |
|
| 2343 | + ?> |
|
| 2344 | 2344 | <script> |
| 2345 | 2345 | function gdRemoveANotification($plugin, $timestamp) {
|
| 2346 | 2346 | |
@@ -2408,10 +2408,10 @@ discard block |
||
| 2408 | 2408 | */ |
| 2409 | 2409 | function geodir_avada_remove_notification() |
| 2410 | 2410 | {
|
| 2411 | - update_option('avada_nag', TRUE);
|
|
| 2411 | + update_option('avada_nag', TRUE);
|
|
| 2412 | 2412 | |
| 2413 | - // Always die in functions echoing ajax content |
|
| 2414 | - die(); |
|
| 2413 | + // Always die in functions echoing ajax content |
|
| 2414 | + die(); |
|
| 2415 | 2415 | } |
| 2416 | 2416 | |
| 2417 | 2417 | |
@@ -2433,9 +2433,9 @@ discard block |
||
| 2433 | 2433 | global $post, $typenow, $current_screen; |
| 2434 | 2434 | |
| 2435 | 2435 | $post_type = NULL; |
| 2436 | - if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 2436 | + if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 2437 | 2437 | $post_type = get_post_type($_REQUEST['post']); |
| 2438 | - elseif ($post && isset($post->post_type)) |
|
| 2438 | + elseif ($post && isset($post->post_type)) |
|
| 2439 | 2439 | $post_type = $post->post_type; |
| 2440 | 2440 | elseif ($typenow) |
| 2441 | 2441 | $post_type = $typenow; |
@@ -2470,7 +2470,7 @@ discard block |
||
| 2470 | 2470 | // Don't allow same slug url for listing and location |
| 2471 | 2471 | if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
|
| 2472 | 2472 | $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
|
| 2473 | - wp_redirect($redirect_url); |
|
| 2473 | + wp_redirect($redirect_url); |
|
| 2474 | 2474 | exit; |
| 2475 | 2475 | } |
| 2476 | 2476 | |
@@ -2500,10 +2500,10 @@ discard block |
||
| 2500 | 2500 | * @package GeoDirectory |
| 2501 | 2501 | */ |
| 2502 | 2502 | function geodir_hide_admin_preview_button() {
|
| 2503 | - global $post_type; |
|
| 2504 | - $post_types = geodir_get_posttypes(); |
|
| 2505 | - if(in_array($post_type, $post_types)) |
|
| 2506 | - echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
|
| 2503 | + global $post_type; |
|
| 2504 | + $post_types = geodir_get_posttypes(); |
|
| 2505 | + if(in_array($post_type, $post_types)) |
|
| 2506 | + echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
|
| 2507 | 2507 | } |
| 2508 | 2508 | add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' ); |
| 2509 | 2509 | add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' ); |
@@ -2518,7 +2518,7 @@ discard block |
||
| 2518 | 2518 | */ |
| 2519 | 2519 | function geodir_import_export_tab( $tabs ) {
|
| 2520 | 2520 | $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
| 2521 | - return $tabs; |
|
| 2521 | + return $tabs; |
|
| 2522 | 2522 | } |
| 2523 | 2523 | |
| 2524 | 2524 | /** |
@@ -2533,26 +2533,26 @@ discard block |
||
| 2533 | 2533 | function geodir_import_export_page() {
|
| 2534 | 2534 | $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
| 2535 | 2535 | $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
| 2536 | - /** |
|
| 2537 | - * Filter sample category data csv file url. |
|
| 2538 | - * |
|
| 2539 | - * @since 1.0.0 |
|
| 2540 | - * @package GeoDirectory |
|
| 2541 | - * |
|
| 2542 | - * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
| 2543 | - */ |
|
| 2536 | + /** |
|
| 2537 | + * Filter sample category data csv file url. |
|
| 2538 | + * |
|
| 2539 | + * @since 1.0.0 |
|
| 2540 | + * @package GeoDirectory |
|
| 2541 | + * |
|
| 2542 | + * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
| 2543 | + */ |
|
| 2544 | 2544 | $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
| 2545 | 2545 | |
| 2546 | 2546 | $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
| 2547 | - /** |
|
| 2548 | - * Filter sample post data csv file url. |
|
| 2549 | - * |
|
| 2550 | - * @since 1.0.0 |
|
| 2551 | - * @package GeoDirectory |
|
| 2552 | - * |
|
| 2553 | - * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
| 2554 | - */ |
|
| 2555 | - $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 2547 | + /** |
|
| 2548 | + * Filter sample post data csv file url. |
|
| 2549 | + * |
|
| 2550 | + * @since 1.0.0 |
|
| 2551 | + * @package GeoDirectory |
|
| 2552 | + * |
|
| 2553 | + * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
| 2554 | + */ |
|
| 2555 | + $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 2556 | 2556 | |
| 2557 | 2557 | $gd_posttypes = geodir_get_posttypes( 'array' ); |
| 2558 | 2558 | |
@@ -2575,14 +2575,14 @@ discard block |
||
| 2575 | 2575 | $gd_chunksize_options[100000] = 100000; |
| 2576 | 2576 | |
| 2577 | 2577 | /** |
| 2578 | - * Filter max entries per export csv file. |
|
| 2579 | - * |
|
| 2580 | - * @since 1.5.6 |
|
| 2581 | - * @package GeoDirectory |
|
| 2582 | - * |
|
| 2583 | - * @param string $gd_chunksize_options Entries options. |
|
| 2584 | - */ |
|
| 2585 | - $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 2578 | + * Filter max entries per export csv file. |
|
| 2579 | + * |
|
| 2580 | + * @since 1.5.6 |
|
| 2581 | + * @package GeoDirectory |
|
| 2582 | + * |
|
| 2583 | + * @param string $gd_chunksize_options Entries options. |
|
| 2584 | + */ |
|
| 2585 | + $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 2586 | 2586 | |
| 2587 | 2587 | $gd_chunksize_option = ''; |
| 2588 | 2588 | foreach ($gd_chunksize_options as $value => $title) {
|
@@ -2598,12 +2598,12 @@ discard block |
||
| 2598 | 2598 | <div class="gd-content-heading"> |
| 2599 | 2599 | |
| 2600 | 2600 | <?php |
| 2601 | - ini_set('max_execution_time', 999999);
|
|
| 2602 | - $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 2603 | - ini_restore('max_execution_time');
|
|
| 2601 | + ini_set('max_execution_time', 999999);
|
|
| 2602 | + $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 2603 | + ini_restore('max_execution_time');
|
|
| 2604 | 2604 | |
| 2605 | - if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 2606 | - ?> |
|
| 2605 | + if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 2606 | + ?> |
|
| 2607 | 2607 | <div id="gd_ie_reqs" class="metabox-holder"> |
| 2608 | 2608 | <div class="meta-box-sortables ui-sortable"> |
| 2609 | 2609 | <div class="postbox"> |
@@ -2772,7 +2772,7 @@ discard block |
||
| 2772 | 2772 | * Called just after the sample CSV download link. |
| 2773 | 2773 | * |
| 2774 | 2774 | * @since 1.0.0 |
| 2775 | - * @package GeoDirectory |
|
| 2775 | + * @package GeoDirectory |
|
| 2776 | 2776 | */ |
| 2777 | 2777 | do_action('geodir_sample_cats_csv_download_link');
|
| 2778 | 2778 | ?> |
@@ -2857,11 +2857,11 @@ discard block |
||
| 2857 | 2857 | * |
| 2858 | 2858 | * Called after the last setting on the GD > Import & Export page. |
| 2859 | 2859 | * @since 1.4.6 |
| 2860 | - * @package GeoDirectory |
|
| 2860 | + * @package GeoDirectory |
|
| 2861 | 2861 | * |
| 2862 | 2862 | * @param array $gd_posttypes GD post types. |
| 2863 | - * @param array $gd_chunksize_options File chunk size options. |
|
| 2864 | - * @param string $nonce Wordpress security token for GD import & export. |
|
| 2863 | + * @param array $gd_chunksize_options File chunk size options. |
|
| 2864 | + * @param string $nonce Wordpress security token for GD import & export. |
|
| 2865 | 2865 | */ |
| 2866 | 2866 | do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
| 2867 | 2867 | ?> |
@@ -3526,44 +3526,44 @@ discard block |
||
| 3526 | 3526 | function geodir_init_filesystem() |
| 3527 | 3527 | {
|
| 3528 | 3528 | |
| 3529 | - if(!function_exists('get_filesystem_method')){
|
|
| 3530 | - require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
| 3531 | - } |
|
| 3532 | - $access_type = get_filesystem_method(); |
|
| 3533 | - if ($access_type === 'direct') {
|
|
| 3534 | - /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
| 3535 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3536 | - |
|
| 3537 | - /* initialize the API */ |
|
| 3538 | - if (!WP_Filesystem($creds)) {
|
|
| 3539 | - /* any problems and we exit */ |
|
| 3540 | - //return '@@@3'; |
|
| 3541 | - return false; |
|
| 3542 | - } |
|
| 3543 | - |
|
| 3544 | - global $wp_filesystem; |
|
| 3545 | - return $wp_filesystem; |
|
| 3546 | - /* do our file manipulations below */ |
|
| 3547 | - } elseif (defined('FTP_USER')) {
|
|
| 3548 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3529 | + if(!function_exists('get_filesystem_method')){
|
|
| 3530 | + require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
| 3531 | + } |
|
| 3532 | + $access_type = get_filesystem_method(); |
|
| 3533 | + if ($access_type === 'direct') {
|
|
| 3534 | + /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
| 3535 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3536 | + |
|
| 3537 | + /* initialize the API */ |
|
| 3538 | + if (!WP_Filesystem($creds)) {
|
|
| 3539 | + /* any problems and we exit */ |
|
| 3540 | + //return '@@@3'; |
|
| 3541 | + return false; |
|
| 3542 | + } |
|
| 3549 | 3543 | |
| 3550 | - /* initialize the API */ |
|
| 3551 | - if (!WP_Filesystem($creds)) {
|
|
| 3552 | - /* any problems and we exit */ |
|
| 3553 | - //return '@@@33'; |
|
| 3554 | - return false; |
|
| 3555 | - } |
|
| 3544 | + global $wp_filesystem; |
|
| 3545 | + return $wp_filesystem; |
|
| 3546 | + /* do our file manipulations below */ |
|
| 3547 | + } elseif (defined('FTP_USER')) {
|
|
| 3548 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3549 | + |
|
| 3550 | + /* initialize the API */ |
|
| 3551 | + if (!WP_Filesystem($creds)) {
|
|
| 3552 | + /* any problems and we exit */ |
|
| 3553 | + //return '@@@33'; |
|
| 3554 | + return false; |
|
| 3555 | + } |
|
| 3556 | 3556 | |
| 3557 | - global $wp_filesystem; |
|
| 3558 | - //return '@@@1'; |
|
| 3559 | - return $wp_filesystem; |
|
| 3557 | + global $wp_filesystem; |
|
| 3558 | + //return '@@@1'; |
|
| 3559 | + return $wp_filesystem; |
|
| 3560 | 3560 | |
| 3561 | - } else {
|
|
| 3562 | - //return '@@@2'; |
|
| 3563 | - /* don't have direct write access. Prompt user with our notice */ |
|
| 3564 | - add_action('admin_notice', 'geodir_filesystem_notice');
|
|
| 3565 | - return false; |
|
| 3566 | - } |
|
| 3561 | + } else {
|
|
| 3562 | + //return '@@@2'; |
|
| 3563 | + /* don't have direct write access. Prompt user with our notice */ |
|
| 3564 | + add_action('admin_notice', 'geodir_filesystem_notice');
|
|
| 3565 | + return false; |
|
| 3566 | + } |
|
| 3567 | 3567 | |
| 3568 | 3568 | } |
| 3569 | 3569 | |
@@ -3581,10 +3581,10 @@ discard block |
||
| 3581 | 3581 | */ |
| 3582 | 3582 | function geodir_filesystem_notice() |
| 3583 | 3583 | { if ( defined( 'DOING_AJAX' ) ){return;}
|
| 3584 | - $access_type = get_filesystem_method(); |
|
| 3585 | - if ($access_type === 'direct') {
|
|
| 3586 | - } elseif (!defined('FTP_USER')) {
|
|
| 3587 | - ?> |
|
| 3584 | + $access_type = get_filesystem_method(); |
|
| 3585 | + if ($access_type === 'direct') {
|
|
| 3586 | + } elseif (!defined('FTP_USER')) {
|
|
| 3587 | + ?> |
|
| 3588 | 3588 | <div class="error"> |
| 3589 | 3589 | <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'); ?>
|
| 3590 | 3590 | <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> |
@@ -3610,1514 +3610,1514 @@ discard block |
||
| 3610 | 3610 | * @return string Json data. |
| 3611 | 3611 | */ |
| 3612 | 3612 | function geodir_ajax_import_export() {
|
| 3613 | - global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 3613 | + global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 3614 | 3614 | |
| 3615 | - error_reporting(0); |
|
| 3615 | + error_reporting(0); |
|
| 3616 | 3616 | |
| 3617 | - // try to set higher limits for import |
|
| 3618 | - $max_input_time = ini_get('max_input_time');
|
|
| 3619 | - $max_execution_time = ini_get('max_execution_time');
|
|
| 3620 | - $memory_limit= ini_get('memory_limit');
|
|
| 3617 | + // try to set higher limits for import |
|
| 3618 | + $max_input_time = ini_get('max_input_time');
|
|
| 3619 | + $max_execution_time = ini_get('max_execution_time');
|
|
| 3620 | + $memory_limit= ini_get('memory_limit');
|
|
| 3621 | 3621 | |
| 3622 | - if(!$max_input_time || $max_input_time<3000){
|
|
| 3623 | - ini_set('max_input_time', 3000);
|
|
| 3624 | - } |
|
| 3622 | + if(!$max_input_time || $max_input_time<3000){
|
|
| 3623 | + ini_set('max_input_time', 3000);
|
|
| 3624 | + } |
|
| 3625 | 3625 | |
| 3626 | - if(!$max_execution_time || $max_execution_time<3000){
|
|
| 3627 | - ini_set('max_execution_time', 3000);
|
|
| 3628 | - } |
|
| 3626 | + if(!$max_execution_time || $max_execution_time<3000){
|
|
| 3627 | + ini_set('max_execution_time', 3000);
|
|
| 3628 | + } |
|
| 3629 | 3629 | |
| 3630 | - if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 3631 | - if(str_replace('M','',$memory_limit)<256){
|
|
| 3632 | - ini_set('memory_limit', '256M');
|
|
| 3633 | - } |
|
| 3634 | - } |
|
| 3630 | + if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 3631 | + if(str_replace('M','',$memory_limit)<256){
|
|
| 3632 | + ini_set('memory_limit', '256M');
|
|
| 3633 | + } |
|
| 3634 | + } |
|
| 3635 | 3635 | |
| 3636 | - $json = array(); |
|
| 3636 | + $json = array(); |
|
| 3637 | 3637 | |
| 3638 | - if ( !current_user_can( 'manage_options' ) ) {
|
|
| 3639 | - wp_send_json( $json ); |
|
| 3640 | - } |
|
| 3638 | + if ( !current_user_can( 'manage_options' ) ) {
|
|
| 3639 | + wp_send_json( $json ); |
|
| 3640 | + } |
|
| 3641 | 3641 | |
| 3642 | - $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 3643 | - $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 3644 | - $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 3642 | + $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 3643 | + $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 3644 | + $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 3645 | 3645 | |
| 3646 | - if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 3647 | - wp_send_json( $json ); |
|
| 3648 | - } |
|
| 3646 | + if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 3647 | + wp_send_json( $json ); |
|
| 3648 | + } |
|
| 3649 | 3649 | |
| 3650 | - $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 3651 | - $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 3652 | - $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 3653 | - $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 3650 | + $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 3651 | + $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 3652 | + $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 3653 | + $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 3654 | 3654 | |
| 3655 | - $wp_filesystem = geodir_init_filesystem(); |
|
| 3656 | - if (!$wp_filesystem) {
|
|
| 3657 | - $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 3658 | - wp_send_json( $json ); |
|
| 3659 | - } |
|
| 3655 | + $wp_filesystem = geodir_init_filesystem(); |
|
| 3656 | + if (!$wp_filesystem) {
|
|
| 3657 | + $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 3658 | + wp_send_json( $json ); |
|
| 3659 | + } |
|
| 3660 | 3660 | |
| 3661 | - if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 3662 | - $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 3663 | - wp_send_json( $json ); |
|
| 3664 | - } |
|
| 3661 | + if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 3662 | + $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 3663 | + wp_send_json( $json ); |
|
| 3664 | + } |
|
| 3665 | 3665 | |
| 3666 | - $csv_file_dir = geodir_path_import_export( false ); |
|
| 3667 | - if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 3668 | - if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 3669 | - $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3670 | - wp_send_json( $json ); |
|
| 3671 | - } |
|
| 3672 | - } |
|
| 3666 | + $csv_file_dir = geodir_path_import_export( false ); |
|
| 3667 | + if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 3668 | + if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 3669 | + $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3670 | + wp_send_json( $json ); |
|
| 3671 | + } |
|
| 3672 | + } |
|
| 3673 | 3673 | |
| 3674 | - $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 3675 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 3676 | - |
|
| 3677 | - switch ( $task ) {
|
|
| 3678 | - case 'export_posts': {
|
|
| 3679 | - // WPML |
|
| 3680 | - $is_wpml = geodir_is_wpml(); |
|
| 3681 | - if ($is_wpml) {
|
|
| 3682 | - global $sitepress; |
|
| 3683 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3674 | + $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 3675 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 3676 | + |
|
| 3677 | + switch ( $task ) {
|
|
| 3678 | + case 'export_posts': {
|
|
| 3679 | + // WPML |
|
| 3680 | + $is_wpml = geodir_is_wpml(); |
|
| 3681 | + if ($is_wpml) {
|
|
| 3682 | + global $sitepress; |
|
| 3683 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3684 | 3684 | |
| 3685 | - $sitepress->switch_lang('all', true);
|
|
| 3686 | - } |
|
| 3687 | - // WPML |
|
| 3688 | - if ( $post_type == 'gd_event' ) {
|
|
| 3689 | - add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 3690 | - } |
|
| 3691 | - $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 3692 | - $posts_count = geodir_get_posts_count( $post_type ); |
|
| 3693 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3694 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3695 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3696 | - $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 3685 | + $sitepress->switch_lang('all', true);
|
|
| 3686 | + } |
|
| 3687 | + // WPML |
|
| 3688 | + if ( $post_type == 'gd_event' ) {
|
|
| 3689 | + add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 3690 | + } |
|
| 3691 | + $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 3692 | + $posts_count = geodir_get_posts_count( $post_type ); |
|
| 3693 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3694 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3695 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3696 | + $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 3697 | 3697 | |
| 3698 | - $chunk_file_paths = array(); |
|
| 3698 | + $chunk_file_paths = array(); |
|
| 3699 | 3699 | |
| 3700 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3701 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3702 | - $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 3703 | - $percentage = min( $percentage, 100 ); |
|
| 3700 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3701 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3702 | + $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 3703 | + $percentage = min( $percentage, 100 ); |
|
| 3704 | 3704 | |
| 3705 | - $json['percentage'] = $percentage; |
|
| 3706 | - // WPML |
|
| 3707 | - if ($is_wpml) {
|
|
| 3708 | - $sitepress->switch_lang($active_lang, true); |
|
| 3709 | - } |
|
| 3710 | - // WPML |
|
| 3711 | - wp_send_json( $json ); |
|
| 3712 | - gd_die(); |
|
| 3713 | - } else {
|
|
| 3714 | - if ( !$posts_count > 0 ) {
|
|
| 3715 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3716 | - } else {
|
|
| 3717 | - $total_posts = $posts_count; |
|
| 3718 | - if ($chunk_per_page > $total_posts) {
|
|
| 3719 | - $chunk_per_page = $total_posts; |
|
| 3720 | - } |
|
| 3721 | - $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 3705 | + $json['percentage'] = $percentage; |
|
| 3706 | + // WPML |
|
| 3707 | + if ($is_wpml) {
|
|
| 3708 | + $sitepress->switch_lang($active_lang, true); |
|
| 3709 | + } |
|
| 3710 | + // WPML |
|
| 3711 | + wp_send_json( $json ); |
|
| 3712 | + gd_die(); |
|
| 3713 | + } else {
|
|
| 3714 | + if ( !$posts_count > 0 ) {
|
|
| 3715 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3716 | + } else {
|
|
| 3717 | + $total_posts = $posts_count; |
|
| 3718 | + if ($chunk_per_page > $total_posts) {
|
|
| 3719 | + $chunk_per_page = $total_posts; |
|
| 3720 | + } |
|
| 3721 | + $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 3722 | 3722 | |
| 3723 | - $j = $chunk_page_no; |
|
| 3724 | - $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 3723 | + $j = $chunk_page_no; |
|
| 3724 | + $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 3725 | 3725 | |
| 3726 | - $per_page = 500; |
|
| 3727 | - if ($per_page > $chunk_per_page) {
|
|
| 3728 | - $per_page = $chunk_per_page; |
|
| 3729 | - } |
|
| 3730 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3726 | + $per_page = 500; |
|
| 3727 | + if ($per_page > $chunk_per_page) {
|
|
| 3728 | + $per_page = $chunk_per_page; |
|
| 3729 | + } |
|
| 3730 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3731 | 3731 | |
| 3732 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3733 | - $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 3732 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3733 | + $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 3734 | 3734 | |
| 3735 | - $clear = $i == 0 ? true : false; |
|
| 3736 | - geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 3737 | - } |
|
| 3735 | + $clear = $i == 0 ? true : false; |
|
| 3736 | + geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 3737 | + } |
|
| 3738 | 3738 | |
| 3739 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3740 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3741 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3742 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3743 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3739 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3740 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3741 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3742 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3743 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3744 | 3744 | |
| 3745 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3746 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3747 | - } |
|
| 3745 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3746 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3747 | + } |
|
| 3748 | 3748 | |
| 3749 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3750 | - $json['total'] = $posts_count; |
|
| 3751 | - $json['files'] = $chunk_file_paths; |
|
| 3752 | - } else {
|
|
| 3753 | - if ($j > 1) {
|
|
| 3754 | - $json['total'] = $posts_count; |
|
| 3755 | - $json['files'] = array(); |
|
| 3756 | - } else {
|
|
| 3757 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3758 | - } |
|
| 3759 | - } |
|
| 3760 | - } |
|
| 3761 | - // WPML |
|
| 3762 | - if ($is_wpml) {
|
|
| 3763 | - $sitepress->switch_lang($active_lang, true); |
|
| 3764 | - } |
|
| 3765 | - // WPML |
|
| 3766 | - wp_send_json( $json ); |
|
| 3767 | - } |
|
| 3768 | - } |
|
| 3769 | - break; |
|
| 3770 | - case 'export_cats': {
|
|
| 3771 | - // WPML |
|
| 3772 | - $is_wpml = geodir_is_wpml(); |
|
| 3773 | - if ($is_wpml) {
|
|
| 3774 | - global $sitepress; |
|
| 3775 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3749 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3750 | + $json['total'] = $posts_count; |
|
| 3751 | + $json['files'] = $chunk_file_paths; |
|
| 3752 | + } else {
|
|
| 3753 | + if ($j > 1) {
|
|
| 3754 | + $json['total'] = $posts_count; |
|
| 3755 | + $json['files'] = array(); |
|
| 3756 | + } else {
|
|
| 3757 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3758 | + } |
|
| 3759 | + } |
|
| 3760 | + } |
|
| 3761 | + // WPML |
|
| 3762 | + if ($is_wpml) {
|
|
| 3763 | + $sitepress->switch_lang($active_lang, true); |
|
| 3764 | + } |
|
| 3765 | + // WPML |
|
| 3766 | + wp_send_json( $json ); |
|
| 3767 | + } |
|
| 3768 | + } |
|
| 3769 | + break; |
|
| 3770 | + case 'export_cats': {
|
|
| 3771 | + // WPML |
|
| 3772 | + $is_wpml = geodir_is_wpml(); |
|
| 3773 | + if ($is_wpml) {
|
|
| 3774 | + global $sitepress; |
|
| 3775 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3776 | 3776 | |
| 3777 | - $sitepress->switch_lang('all', true);
|
|
| 3778 | - } |
|
| 3779 | - // WPML |
|
| 3780 | - $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 3777 | + $sitepress->switch_lang('all', true);
|
|
| 3778 | + } |
|
| 3779 | + // WPML |
|
| 3780 | + $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 3781 | 3781 | |
| 3782 | - $terms_count = geodir_get_terms_count( $post_type ); |
|
| 3783 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3784 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3785 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3786 | - $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 3782 | + $terms_count = geodir_get_terms_count( $post_type ); |
|
| 3783 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3784 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3785 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3786 | + $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 3787 | 3787 | |
| 3788 | - $chunk_file_paths = array(); |
|
| 3788 | + $chunk_file_paths = array(); |
|
| 3789 | 3789 | |
| 3790 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3791 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3792 | - $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 3793 | - $percentage = min( $percentage, 100 ); |
|
| 3790 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3791 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3792 | + $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 3793 | + $percentage = min( $percentage, 100 ); |
|
| 3794 | 3794 | |
| 3795 | - $json['percentage'] = $percentage; |
|
| 3796 | - // WPML |
|
| 3797 | - if ($is_wpml) {
|
|
| 3798 | - $sitepress->switch_lang($active_lang, true); |
|
| 3799 | - } |
|
| 3800 | - // WPML |
|
| 3801 | - wp_send_json( $json ); |
|
| 3802 | - } else {
|
|
| 3803 | - if ( !$terms_count > 0 ) {
|
|
| 3804 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3805 | - } else {
|
|
| 3806 | - $total_terms = $terms_count; |
|
| 3807 | - if ($chunk_per_page > $terms_count) {
|
|
| 3808 | - $chunk_per_page = $terms_count; |
|
| 3809 | - } |
|
| 3810 | - $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 3795 | + $json['percentage'] = $percentage; |
|
| 3796 | + // WPML |
|
| 3797 | + if ($is_wpml) {
|
|
| 3798 | + $sitepress->switch_lang($active_lang, true); |
|
| 3799 | + } |
|
| 3800 | + // WPML |
|
| 3801 | + wp_send_json( $json ); |
|
| 3802 | + } else {
|
|
| 3803 | + if ( !$terms_count > 0 ) {
|
|
| 3804 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3805 | + } else {
|
|
| 3806 | + $total_terms = $terms_count; |
|
| 3807 | + if ($chunk_per_page > $terms_count) {
|
|
| 3808 | + $chunk_per_page = $terms_count; |
|
| 3809 | + } |
|
| 3810 | + $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 3811 | 3811 | |
| 3812 | - $j = $chunk_page_no; |
|
| 3813 | - $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 3812 | + $j = $chunk_page_no; |
|
| 3813 | + $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 3814 | 3814 | |
| 3815 | - $per_page = 500; |
|
| 3816 | - if ($per_page > $chunk_per_page) {
|
|
| 3817 | - $per_page = $chunk_per_page; |
|
| 3818 | - } |
|
| 3819 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3815 | + $per_page = 500; |
|
| 3816 | + if ($per_page > $chunk_per_page) {
|
|
| 3817 | + $per_page = $chunk_per_page; |
|
| 3818 | + } |
|
| 3819 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3820 | 3820 | |
| 3821 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3822 | - $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 3821 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3822 | + $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 3823 | 3823 | |
| 3824 | - $clear = $i == 0 ? true : false; |
|
| 3825 | - geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 3826 | - } |
|
| 3824 | + $clear = $i == 0 ? true : false; |
|
| 3825 | + geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 3826 | + } |
|
| 3827 | 3827 | |
| 3828 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3829 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3830 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3831 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3832 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3828 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3829 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3830 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3831 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3832 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3833 | 3833 | |
| 3834 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3835 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3836 | - } |
|
| 3834 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3835 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3836 | + } |
|
| 3837 | 3837 | |
| 3838 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3839 | - $json['total'] = $terms_count; |
|
| 3840 | - $json['files'] = $chunk_file_paths; |
|
| 3841 | - } else {
|
|
| 3842 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3843 | - } |
|
| 3844 | - } |
|
| 3845 | - // WPML |
|
| 3846 | - if ($is_wpml) {
|
|
| 3847 | - $sitepress->switch_lang($active_lang, true); |
|
| 3848 | - } |
|
| 3849 | - // WPML |
|
| 3850 | - wp_send_json( $json ); |
|
| 3851 | - } |
|
| 3852 | - } |
|
| 3853 | - break; |
|
| 3854 | - case 'export_locations': {
|
|
| 3855 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3856 | - $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 3857 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3858 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3859 | - $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 3838 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3839 | + $json['total'] = $terms_count; |
|
| 3840 | + $json['files'] = $chunk_file_paths; |
|
| 3841 | + } else {
|
|
| 3842 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3843 | + } |
|
| 3844 | + } |
|
| 3845 | + // WPML |
|
| 3846 | + if ($is_wpml) {
|
|
| 3847 | + $sitepress->switch_lang($active_lang, true); |
|
| 3848 | + } |
|
| 3849 | + // WPML |
|
| 3850 | + wp_send_json( $json ); |
|
| 3851 | + } |
|
| 3852 | + } |
|
| 3853 | + break; |
|
| 3854 | + case 'export_locations': {
|
|
| 3855 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3856 | + $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 3857 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3858 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3859 | + $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 3860 | 3860 | |
| 3861 | - $items_count = (int)geodir_location_imex_count_locations(); |
|
| 3861 | + $items_count = (int)geodir_location_imex_count_locations(); |
|
| 3862 | 3862 | |
| 3863 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3864 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3865 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3866 | - $percentage = min( $percentage, 100 ); |
|
| 3863 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3864 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3865 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3866 | + $percentage = min( $percentage, 100 ); |
|
| 3867 | 3867 | |
| 3868 | - $json['percentage'] = $percentage; |
|
| 3869 | - wp_send_json( $json ); |
|
| 3870 | - } else {
|
|
| 3871 | - $chunk_file_paths = array(); |
|
| 3868 | + $json['percentage'] = $percentage; |
|
| 3869 | + wp_send_json( $json ); |
|
| 3870 | + } else {
|
|
| 3871 | + $chunk_file_paths = array(); |
|
| 3872 | 3872 | |
| 3873 | - if ( !$items_count > 0 ) {
|
|
| 3874 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3875 | - } else {
|
|
| 3876 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3877 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3873 | + if ( !$items_count > 0 ) {
|
|
| 3874 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3875 | + } else {
|
|
| 3876 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3877 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3878 | 3878 | |
| 3879 | - $j = $chunk_page_no; |
|
| 3880 | - $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 3879 | + $j = $chunk_page_no; |
|
| 3880 | + $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 3881 | 3881 | |
| 3882 | - $per_page = 500; |
|
| 3883 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 3884 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3882 | + $per_page = 500; |
|
| 3883 | + $per_page = min( $per_page, $chunk_per_page ); |
|
| 3884 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3885 | 3885 | |
| 3886 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3887 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3886 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3887 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3888 | 3888 | |
| 3889 | - $clear = $i == 0 ? true : false; |
|
| 3890 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3891 | - } |
|
| 3889 | + $clear = $i == 0 ? true : false; |
|
| 3890 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3891 | + } |
|
| 3892 | 3892 | |
| 3893 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3894 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3895 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3896 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3897 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3893 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3894 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3895 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3896 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3897 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3898 | 3898 | |
| 3899 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3900 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3901 | - } |
|
| 3899 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3900 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3901 | + } |
|
| 3902 | 3902 | |
| 3903 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3904 | - $json['total'] = $items_count; |
|
| 3905 | - $json['files'] = $chunk_file_paths; |
|
| 3906 | - } else {
|
|
| 3907 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3908 | - } |
|
| 3909 | - } |
|
| 3910 | - wp_send_json( $json ); |
|
| 3911 | - } |
|
| 3912 | - } |
|
| 3913 | - break; |
|
| 3914 | - case 'export_hoods': {
|
|
| 3915 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3916 | - $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
| 3917 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3918 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3919 | - $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
| 3903 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3904 | + $json['total'] = $items_count; |
|
| 3905 | + $json['files'] = $chunk_file_paths; |
|
| 3906 | + } else {
|
|
| 3907 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3908 | + } |
|
| 3909 | + } |
|
| 3910 | + wp_send_json( $json ); |
|
| 3911 | + } |
|
| 3912 | + } |
|
| 3913 | + break; |
|
| 3914 | + case 'export_hoods': {
|
|
| 3915 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3916 | + $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
| 3917 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3918 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3919 | + $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
| 3920 | 3920 | |
| 3921 | - $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
| 3921 | + $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
| 3922 | 3922 | |
| 3923 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3924 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3925 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3926 | - $percentage = min( $percentage, 100 ); |
|
| 3923 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3924 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3925 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3926 | + $percentage = min( $percentage, 100 ); |
|
| 3927 | 3927 | |
| 3928 | - $json['percentage'] = $percentage; |
|
| 3929 | - wp_send_json( $json ); |
|
| 3930 | - } else {
|
|
| 3931 | - $chunk_file_paths = array(); |
|
| 3928 | + $json['percentage'] = $percentage; |
|
| 3929 | + wp_send_json( $json ); |
|
| 3930 | + } else {
|
|
| 3931 | + $chunk_file_paths = array(); |
|
| 3932 | 3932 | |
| 3933 | - if ( !$items_count > 0 ) {
|
|
| 3934 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3935 | - } else {
|
|
| 3936 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3937 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3933 | + if ( !$items_count > 0 ) {
|
|
| 3934 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3935 | + } else {
|
|
| 3936 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3937 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3938 | 3938 | |
| 3939 | - $j = $chunk_page_no; |
|
| 3940 | - $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
| 3939 | + $j = $chunk_page_no; |
|
| 3940 | + $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
| 3941 | 3941 | |
| 3942 | - $per_page = 500; |
|
| 3943 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 3944 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3942 | + $per_page = 500; |
|
| 3943 | + $per_page = min( $per_page, $chunk_per_page ); |
|
| 3944 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3945 | 3945 | |
| 3946 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3947 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3946 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3947 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3948 | 3948 | |
| 3949 | - $clear = $i == 0 ? true : false; |
|
| 3950 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3951 | - } |
|
| 3949 | + $clear = $i == 0 ? true : false; |
|
| 3950 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3951 | + } |
|
| 3952 | 3952 | |
| 3953 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3954 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3955 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3956 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3957 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3953 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3954 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3955 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3956 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3957 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3958 | 3958 | |
| 3959 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3960 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3961 | - } |
|
| 3959 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3960 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3961 | + } |
|
| 3962 | 3962 | |
| 3963 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3964 | - $json['total'] = $items_count; |
|
| 3965 | - $json['files'] = $chunk_file_paths; |
|
| 3966 | - } else {
|
|
| 3967 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3968 | - } |
|
| 3969 | - } |
|
| 3970 | - wp_send_json( $json ); |
|
| 3971 | - } |
|
| 3972 | - } |
|
| 3973 | - break; |
|
| 3974 | - case 'prepare_import': |
|
| 3975 | - case 'import_cat': |
|
| 3976 | - case 'import_post': |
|
| 3977 | - case 'import_loc': |
|
| 3978 | - case 'import_hood': {
|
|
| 3979 | - // WPML |
|
| 3980 | - $is_wpml = geodir_is_wpml(); |
|
| 3981 | - if ($is_wpml) {
|
|
| 3982 | - global $sitepress; |
|
| 3983 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3984 | - } |
|
| 3985 | - // WPML |
|
| 3963 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3964 | + $json['total'] = $items_count; |
|
| 3965 | + $json['files'] = $chunk_file_paths; |
|
| 3966 | + } else {
|
|
| 3967 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3968 | + } |
|
| 3969 | + } |
|
| 3970 | + wp_send_json( $json ); |
|
| 3971 | + } |
|
| 3972 | + } |
|
| 3973 | + break; |
|
| 3974 | + case 'prepare_import': |
|
| 3975 | + case 'import_cat': |
|
| 3976 | + case 'import_post': |
|
| 3977 | + case 'import_loc': |
|
| 3978 | + case 'import_hood': {
|
|
| 3979 | + // WPML |
|
| 3980 | + $is_wpml = geodir_is_wpml(); |
|
| 3981 | + if ($is_wpml) {
|
|
| 3982 | + global $sitepress; |
|
| 3983 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3984 | + } |
|
| 3985 | + // WPML |
|
| 3986 | 3986 | |
| 3987 | - ini_set( 'auto_detect_line_endings', true ); |
|
| 3987 | + ini_set( 'auto_detect_line_endings', true ); |
|
| 3988 | 3988 | |
| 3989 | - $uploads = wp_upload_dir(); |
|
| 3990 | - $uploads_dir = $uploads['path']; |
|
| 3991 | - $uploads_subdir = $uploads['subdir']; |
|
| 3989 | + $uploads = wp_upload_dir(); |
|
| 3990 | + $uploads_dir = $uploads['path']; |
|
| 3991 | + $uploads_subdir = $uploads['subdir']; |
|
| 3992 | 3992 | |
| 3993 | - $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 3994 | - $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 3993 | + $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 3994 | + $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 3995 | 3995 | |
| 3996 | - $csv_file_arr = explode( '/', $csv_file ); |
|
| 3997 | - $csv_filename = end( $csv_file_arr ); |
|
| 3998 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 3996 | + $csv_file_arr = explode( '/', $csv_file ); |
|
| 3997 | + $csv_filename = end( $csv_file_arr ); |
|
| 3998 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 3999 | 3999 | |
| 4000 | - $json['file'] = $csv_file; |
|
| 4001 | - $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 4002 | - $file = array(); |
|
| 4000 | + $json['file'] = $csv_file; |
|
| 4001 | + $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 4002 | + $file = array(); |
|
| 4003 | 4003 | |
| 4004 | - if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 4005 | - $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 4004 | + if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 4005 | + $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 4006 | 4006 | |
| 4007 | - if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 4008 | - $json['error'] = NULL; |
|
| 4009 | - $json['rows'] = 0; |
|
| 4007 | + if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 4008 | + $json['error'] = NULL; |
|
| 4009 | + $json['rows'] = 0; |
|
| 4010 | 4010 | |
| 4011 | - if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 4012 | - while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 4013 | - if ( !empty( $data ) ) {
|
|
| 4014 | - $file[] = $data; |
|
| 4015 | - } |
|
| 4016 | - } |
|
| 4017 | - fclose($handle); |
|
| 4018 | - } |
|
| 4011 | + if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 4012 | + while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 4013 | + if ( !empty( $data ) ) {
|
|
| 4014 | + $file[] = $data; |
|
| 4015 | + } |
|
| 4016 | + } |
|
| 4017 | + fclose($handle); |
|
| 4018 | + } |
|
| 4019 | 4019 | |
| 4020 | - $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 4020 | + $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 4021 | 4021 | |
| 4022 | - if (!$json['rows'] > 0) {
|
|
| 4023 | - $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 4024 | - } |
|
| 4025 | - } else {
|
|
| 4026 | - wp_send_json( $json ); |
|
| 4027 | - } |
|
| 4028 | - } else {
|
|
| 4029 | - wp_send_json( $json ); |
|
| 4030 | - } |
|
| 4022 | + if (!$json['rows'] > 0) {
|
|
| 4023 | + $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 4024 | + } |
|
| 4025 | + } else {
|
|
| 4026 | + wp_send_json( $json ); |
|
| 4027 | + } |
|
| 4028 | + } else {
|
|
| 4029 | + wp_send_json( $json ); |
|
| 4030 | + } |
|
| 4031 | 4031 | |
| 4032 | - if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 4033 | - wp_send_json( $json ); |
|
| 4034 | - } |
|
| 4032 | + if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 4033 | + wp_send_json( $json ); |
|
| 4034 | + } |
|
| 4035 | 4035 | |
| 4036 | - $total = $json['rows']; |
|
| 4037 | - $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 4038 | - $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 4036 | + $total = $json['rows']; |
|
| 4037 | + $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 4038 | + $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 4039 | 4039 | |
| 4040 | - $count = $limit; |
|
| 4040 | + $count = $limit; |
|
| 4041 | 4041 | |
| 4042 | - if ($count < $total) {
|
|
| 4043 | - $count = $processed + $count; |
|
| 4044 | - if ($count > $total) {
|
|
| 4045 | - $count = $total; |
|
| 4046 | - } |
|
| 4047 | - } else {
|
|
| 4048 | - $count = $total; |
|
| 4049 | - } |
|
| 4042 | + if ($count < $total) {
|
|
| 4043 | + $count = $processed + $count; |
|
| 4044 | + if ($count > $total) {
|
|
| 4045 | + $count = $total; |
|
| 4046 | + } |
|
| 4047 | + } else {
|
|
| 4048 | + $count = $total; |
|
| 4049 | + } |
|
| 4050 | 4050 | |
| 4051 | - $created = 0; |
|
| 4052 | - $updated = 0; |
|
| 4053 | - $skipped = 0; |
|
| 4054 | - $invalid = 0; |
|
| 4055 | - $invalid_addr = 0; |
|
| 4056 | - $images = 0; |
|
| 4051 | + $created = 0; |
|
| 4052 | + $updated = 0; |
|
| 4053 | + $skipped = 0; |
|
| 4054 | + $invalid = 0; |
|
| 4055 | + $invalid_addr = 0; |
|
| 4056 | + $images = 0; |
|
| 4057 | 4057 | |
| 4058 | - $gd_post_info = array(); |
|
| 4059 | - $countpost = 0; |
|
| 4058 | + $gd_post_info = array(); |
|
| 4059 | + $countpost = 0; |
|
| 4060 | 4060 | |
| 4061 | - $post_types = geodir_get_posttypes(); |
|
| 4061 | + $post_types = geodir_get_posttypes(); |
|
| 4062 | 4062 | |
| 4063 | - if ( $task == 'import_cat' ) {
|
|
| 4064 | - if (!empty($file)) {
|
|
| 4065 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4063 | + if ( $task == 'import_cat' ) {
|
|
| 4064 | + if (!empty($file)) {
|
|
| 4065 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4066 | 4066 | |
| 4067 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4068 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 4069 | - wp_send_json( $json ); |
|
| 4070 | - exit; |
|
| 4071 | - } |
|
| 4067 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4068 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 4069 | + wp_send_json( $json ); |
|
| 4070 | + exit; |
|
| 4071 | + } |
|
| 4072 | 4072 | |
| 4073 | - $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
|
|
| 4073 | + $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
|
|
| 4074 | 4074 | |
| 4075 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4076 | - $index = $processed + $i; |
|
| 4075 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4076 | + $index = $processed + $i; |
|
| 4077 | 4077 | |
| 4078 | - if (isset($file[$index])) {
|
|
| 4079 | - $row = $file[$index]; |
|
| 4080 | - $row = array_map( 'trim', $row ); |
|
| 4081 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 4078 | + if (isset($file[$index])) {
|
|
| 4079 | + $row = $file[$index]; |
|
| 4080 | + $row = array_map( 'trim', $row ); |
|
| 4081 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 4082 | 4082 | |
| 4083 | - $cat_id = ''; |
|
| 4084 | - $cat_name = ''; |
|
| 4085 | - $cat_slug = ''; |
|
| 4086 | - $cat_posttype = ''; |
|
| 4087 | - $cat_parent = ''; |
|
| 4088 | - $cat_description = ''; |
|
| 4089 | - $cat_schema = ''; |
|
| 4090 | - $cat_top_description = ''; |
|
| 4091 | - $cat_image = ''; |
|
| 4092 | - $cat_icon = ''; |
|
| 4093 | - $cat_language = ''; |
|
| 4094 | - $cat_id_original = ''; |
|
| 4083 | + $cat_id = ''; |
|
| 4084 | + $cat_name = ''; |
|
| 4085 | + $cat_slug = ''; |
|
| 4086 | + $cat_posttype = ''; |
|
| 4087 | + $cat_parent = ''; |
|
| 4088 | + $cat_description = ''; |
|
| 4089 | + $cat_schema = ''; |
|
| 4090 | + $cat_top_description = ''; |
|
| 4091 | + $cat_image = ''; |
|
| 4092 | + $cat_icon = ''; |
|
| 4093 | + $cat_language = ''; |
|
| 4094 | + $cat_id_original = ''; |
|
| 4095 | 4095 | |
| 4096 | - $c = 0; |
|
| 4097 | - foreach ($columns as $column ) {
|
|
| 4098 | - if ( $column == 'cat_id' ) {
|
|
| 4099 | - $cat_id = (int)$row[$c]; |
|
| 4100 | - } else if ( $column == 'cat_name' ) {
|
|
| 4101 | - $cat_name = $row[$c]; |
|
| 4102 | - } else if ( $column == 'cat_slug' ) {
|
|
| 4103 | - $cat_slug = $row[$c]; |
|
| 4104 | - } else if ( $column == 'cat_posttype' ) {
|
|
| 4105 | - $cat_posttype = $row[$c]; |
|
| 4106 | - } else if ( $column == 'cat_parent' ) {
|
|
| 4107 | - $cat_parent = trim($row[$c]); |
|
| 4108 | - } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 4109 | - $cat_schema = $row[$c]; |
|
| 4110 | - } else if ( $column == 'cat_description' ) {
|
|
| 4111 | - $cat_description = $row[$c]; |
|
| 4112 | - } else if ( $column == 'cat_top_description' ) {
|
|
| 4113 | - $cat_top_description = $row[$c]; |
|
| 4114 | - } else if ( $column == 'cat_image' ) {
|
|
| 4115 | - $cat_image = $row[$c]; |
|
| 4116 | - } else if ( $column == 'cat_icon' ) {
|
|
| 4117 | - $cat_icon = $row[$c]; |
|
| 4118 | - } |
|
| 4119 | - // WPML |
|
| 4120 | - if ( $is_wpml ) {
|
|
| 4121 | - if ( $column == 'cat_language' ) {
|
|
| 4122 | - $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
| 4123 | - } else if ( $column == 'cat_id_original' ) {
|
|
| 4124 | - $cat_id_original = (int)$row[$c]; |
|
| 4125 | - } |
|
| 4126 | - } |
|
| 4127 | - // WPML |
|
| 4128 | - $c++; |
|
| 4129 | - } |
|
| 4096 | + $c = 0; |
|
| 4097 | + foreach ($columns as $column ) {
|
|
| 4098 | + if ( $column == 'cat_id' ) {
|
|
| 4099 | + $cat_id = (int)$row[$c]; |
|
| 4100 | + } else if ( $column == 'cat_name' ) {
|
|
| 4101 | + $cat_name = $row[$c]; |
|
| 4102 | + } else if ( $column == 'cat_slug' ) {
|
|
| 4103 | + $cat_slug = $row[$c]; |
|
| 4104 | + } else if ( $column == 'cat_posttype' ) {
|
|
| 4105 | + $cat_posttype = $row[$c]; |
|
| 4106 | + } else if ( $column == 'cat_parent' ) {
|
|
| 4107 | + $cat_parent = trim($row[$c]); |
|
| 4108 | + } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 4109 | + $cat_schema = $row[$c]; |
|
| 4110 | + } else if ( $column == 'cat_description' ) {
|
|
| 4111 | + $cat_description = $row[$c]; |
|
| 4112 | + } else if ( $column == 'cat_top_description' ) {
|
|
| 4113 | + $cat_top_description = $row[$c]; |
|
| 4114 | + } else if ( $column == 'cat_image' ) {
|
|
| 4115 | + $cat_image = $row[$c]; |
|
| 4116 | + } else if ( $column == 'cat_icon' ) {
|
|
| 4117 | + $cat_icon = $row[$c]; |
|
| 4118 | + } |
|
| 4119 | + // WPML |
|
| 4120 | + if ( $is_wpml ) {
|
|
| 4121 | + if ( $column == 'cat_language' ) {
|
|
| 4122 | + $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
| 4123 | + } else if ( $column == 'cat_id_original' ) {
|
|
| 4124 | + $cat_id_original = (int)$row[$c]; |
|
| 4125 | + } |
|
| 4126 | + } |
|
| 4127 | + // WPML |
|
| 4128 | + $c++; |
|
| 4129 | + } |
|
| 4130 | 4130 | |
| 4131 | - if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 4132 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4131 | + if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 4132 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4133 | 4133 | |
| 4134 | - $invalid++; |
|
| 4135 | - continue; |
|
| 4136 | - } |
|
| 4134 | + $invalid++; |
|
| 4135 | + continue; |
|
| 4136 | + } |
|
| 4137 | 4137 | |
| 4138 | - // WPML |
|
| 4139 | - if ($is_wpml && $cat_language != '') {
|
|
| 4140 | - $sitepress->switch_lang($cat_language, true); |
|
| 4141 | - } |
|
| 4142 | - // WPML |
|
| 4138 | + // WPML |
|
| 4139 | + if ($is_wpml && $cat_language != '') {
|
|
| 4140 | + $sitepress->switch_lang($cat_language, true); |
|
| 4141 | + } |
|
| 4142 | + // WPML |
|
| 4143 | 4143 | |
| 4144 | - $term_data = array(); |
|
| 4145 | - $term_data['name'] = $cat_name; |
|
| 4146 | - $term_data['slug'] = $cat_slug; |
|
| 4147 | - $term_data['description'] = $cat_description; |
|
| 4148 | - $term_data['cat_schema'] = $cat_schema; |
|
| 4149 | - $term_data['top_description'] = $cat_top_description; |
|
| 4150 | - $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 4151 | - $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 4144 | + $term_data = array(); |
|
| 4145 | + $term_data['name'] = $cat_name; |
|
| 4146 | + $term_data['slug'] = $cat_slug; |
|
| 4147 | + $term_data['description'] = $cat_description; |
|
| 4148 | + $term_data['cat_schema'] = $cat_schema; |
|
| 4149 | + $term_data['top_description'] = $cat_top_description; |
|
| 4150 | + $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 4151 | + $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 4152 | 4152 | |
| 4153 | - //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 4153 | + //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 4154 | 4154 | |
| 4155 | - $taxonomy = $cat_posttype . 'category'; |
|
| 4155 | + $taxonomy = $cat_posttype . 'category'; |
|
| 4156 | 4156 | |
| 4157 | - $term_data['taxonomy'] = $taxonomy; |
|
| 4157 | + $term_data['taxonomy'] = $taxonomy; |
|
| 4158 | 4158 | |
| 4159 | - $term_parent_id = 0; |
|
| 4160 | - if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 4161 | - $term_parent = ''; |
|
| 4159 | + $term_parent_id = 0; |
|
| 4160 | + if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 4161 | + $term_parent = ''; |
|
| 4162 | 4162 | |
| 4163 | - if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 4164 | - // |
|
| 4165 | - } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 4166 | - // |
|
| 4167 | - } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 4168 | - // |
|
| 4169 | - } else {
|
|
| 4170 | - $term_parent_data = array(); |
|
| 4171 | - $term_parent_data['name'] = $cat_parent; |
|
| 4172 | - //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 4173 | - $term_parent_data['taxonomy'] = $taxonomy; |
|
| 4163 | + if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 4164 | + // |
|
| 4165 | + } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 4166 | + // |
|
| 4167 | + } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 4168 | + // |
|
| 4169 | + } else {
|
|
| 4170 | + $term_parent_data = array(); |
|
| 4171 | + $term_parent_data['name'] = $cat_parent; |
|
| 4172 | + //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 4173 | + $term_parent_data['taxonomy'] = $taxonomy; |
|
| 4174 | 4174 | |
| 4175 | - $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 4176 | - } |
|
| 4175 | + $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 4176 | + } |
|
| 4177 | 4177 | |
| 4178 | - if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 4179 | - $term_parent_id = (int)$term_parent->term_id; |
|
| 4180 | - } |
|
| 4181 | - } |
|
| 4182 | - $term_data['parent'] = (int)$term_parent_id; |
|
| 4178 | + if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 4179 | + $term_parent_id = (int)$term_parent->term_id; |
|
| 4180 | + } |
|
| 4181 | + } |
|
| 4182 | + $term_data['parent'] = (int)$term_parent_id; |
|
| 4183 | 4183 | |
| 4184 | - $term_id = NULL; |
|
| 4185 | - if ( $import_choice == 'update' ) {
|
|
| 4186 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 4187 | - $term_data['term_id'] = $term['term_id']; |
|
| 4184 | + $term_id = NULL; |
|
| 4185 | + if ( $import_choice == 'update' ) {
|
|
| 4186 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 4187 | + $term_data['term_id'] = $term['term_id']; |
|
| 4188 | 4188 | |
| 4189 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 4190 | - $updated++; |
|
| 4191 | - } else {
|
|
| 4192 | - $invalid++; |
|
| 4193 | - 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' ) ); |
|
| 4194 | - } |
|
| 4195 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 4196 | - $term_data['term_id'] = $term['term_id']; |
|
| 4189 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 4190 | + $updated++; |
|
| 4191 | + } else {
|
|
| 4192 | + $invalid++; |
|
| 4193 | + 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' ) ); |
|
| 4194 | + } |
|
| 4195 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 4196 | + $term_data['term_id'] = $term['term_id']; |
|
| 4197 | 4197 | |
| 4198 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 4199 | - $updated++; |
|
| 4200 | - } else {
|
|
| 4201 | - $invalid++; |
|
| 4202 | - 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' ) ); |
|
| 4203 | - } |
|
| 4204 | - } else {
|
|
| 4205 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 4206 | - $created++; |
|
| 4207 | - } else {
|
|
| 4208 | - $invalid++; |
|
| 4209 | - 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' ) ); |
|
| 4210 | - } |
|
| 4211 | - } |
|
| 4212 | - } else if ( $import_choice == 'skip' ) {
|
|
| 4213 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 4214 | - $skipped++; |
|
| 4215 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 4216 | - $skipped++; |
|
| 4217 | - } else {
|
|
| 4218 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 4219 | - $created++; |
|
| 4220 | - } else {
|
|
| 4221 | - $invalid++; |
|
| 4222 | - 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' ) ); |
|
| 4223 | - } |
|
| 4224 | - } |
|
| 4225 | - } else {
|
|
| 4226 | - $invalid++; |
|
| 4227 | - 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' ) ); |
|
| 4228 | - } |
|
| 4198 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 4199 | + $updated++; |
|
| 4200 | + } else {
|
|
| 4201 | + $invalid++; |
|
| 4202 | + 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' ) ); |
|
| 4203 | + } |
|
| 4204 | + } else {
|
|
| 4205 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 4206 | + $created++; |
|
| 4207 | + } else {
|
|
| 4208 | + $invalid++; |
|
| 4209 | + 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' ) ); |
|
| 4210 | + } |
|
| 4211 | + } |
|
| 4212 | + } else if ( $import_choice == 'skip' ) {
|
|
| 4213 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 4214 | + $skipped++; |
|
| 4215 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 4216 | + $skipped++; |
|
| 4217 | + } else {
|
|
| 4218 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 4219 | + $created++; |
|
| 4220 | + } else {
|
|
| 4221 | + $invalid++; |
|
| 4222 | + 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' ) ); |
|
| 4223 | + } |
|
| 4224 | + } |
|
| 4225 | + } else {
|
|
| 4226 | + $invalid++; |
|
| 4227 | + 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' ) ); |
|
| 4228 | + } |
|
| 4229 | 4229 | |
| 4230 | - if ( $term_id ) {
|
|
| 4231 | - // WPML |
|
| 4232 | - if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
|
|
| 4233 | - $wpml_element_type = 'tax_' . $taxonomy; |
|
| 4234 | - $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
| 4235 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 4236 | - |
|
| 4237 | - $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
| 4230 | + if ( $term_id ) {
|
|
| 4231 | + // WPML |
|
| 4232 | + if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
|
|
| 4233 | + $wpml_element_type = 'tax_' . $taxonomy; |
|
| 4234 | + $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
| 4235 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 4236 | + |
|
| 4237 | + $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
| 4238 | 4238 | |
| 4239 | - $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
| 4240 | - } |
|
| 4241 | - // WPML |
|
| 4239 | + $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
| 4240 | + } |
|
| 4241 | + // WPML |
|
| 4242 | 4242 | |
| 4243 | - if ( isset( $term_data['top_description'] ) ) {
|
|
| 4244 | - update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 4245 | - } |
|
| 4243 | + if ( isset( $term_data['top_description'] ) ) {
|
|
| 4244 | + update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 4245 | + } |
|
| 4246 | 4246 | |
| 4247 | - if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 4248 | - update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 4249 | - } |
|
| 4247 | + if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 4248 | + update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 4249 | + } |
|
| 4250 | 4250 | |
| 4251 | - $attachment = false; |
|
| 4252 | - if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 4253 | - $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 4254 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 4251 | + $attachment = false; |
|
| 4252 | + if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 4253 | + $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 4254 | + $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 4255 | 4255 | |
| 4256 | - if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 4257 | - $attachment = true; |
|
| 4258 | - update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 4259 | - } |
|
| 4260 | - } |
|
| 4256 | + if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 4257 | + $attachment = true; |
|
| 4258 | + update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 4259 | + } |
|
| 4260 | + } |
|
| 4261 | 4261 | |
| 4262 | - if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 4263 | - $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 4264 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 4262 | + if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 4263 | + $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 4264 | + $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 4265 | 4265 | |
| 4266 | - if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 4267 | - $attachment = true; |
|
| 4268 | - update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 4269 | - } |
|
| 4270 | - } |
|
| 4266 | + if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 4267 | + $attachment = true; |
|
| 4268 | + update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 4269 | + } |
|
| 4270 | + } |
|
| 4271 | 4271 | |
| 4272 | - if ( $attachment ) {
|
|
| 4273 | - $images++; |
|
| 4274 | - } |
|
| 4275 | - } |
|
| 4272 | + if ( $attachment ) {
|
|
| 4273 | + $images++; |
|
| 4274 | + } |
|
| 4275 | + } |
|
| 4276 | 4276 | |
| 4277 | - // WPML |
|
| 4278 | - if ($is_wpml && $cat_language != '') {
|
|
| 4279 | - $sitepress->switch_lang($active_lang, true); |
|
| 4280 | - } |
|
| 4281 | - // WPML |
|
| 4282 | - } |
|
| 4283 | - } |
|
| 4284 | - } |
|
| 4277 | + // WPML |
|
| 4278 | + if ($is_wpml && $cat_language != '') {
|
|
| 4279 | + $sitepress->switch_lang($active_lang, true); |
|
| 4280 | + } |
|
| 4281 | + // WPML |
|
| 4282 | + } |
|
| 4283 | + } |
|
| 4284 | + } |
|
| 4285 | 4285 | |
| 4286 | - $json = array(); |
|
| 4287 | - $json['processed'] = $limit; |
|
| 4288 | - $json['created'] = $created; |
|
| 4289 | - $json['updated'] = $updated; |
|
| 4290 | - $json['skipped'] = $skipped; |
|
| 4291 | - $json['invalid'] = $invalid; |
|
| 4292 | - $json['images'] = $images; |
|
| 4286 | + $json = array(); |
|
| 4287 | + $json['processed'] = $limit; |
|
| 4288 | + $json['created'] = $created; |
|
| 4289 | + $json['updated'] = $updated; |
|
| 4290 | + $json['skipped'] = $skipped; |
|
| 4291 | + $json['invalid'] = $invalid; |
|
| 4292 | + $json['images'] = $images; |
|
| 4293 | 4293 | |
| 4294 | - wp_send_json( $json ); |
|
| 4295 | - exit; |
|
| 4296 | - } else if ( $task == 'import_post' ) {
|
|
| 4297 | - //run some stuff to make the import quicker |
|
| 4298 | - wp_defer_term_counting( true ); |
|
| 4299 | - wp_defer_comment_counting( true ); |
|
| 4300 | - $wpdb->query( 'SET autocommit = 0;' ); |
|
| 4301 | - |
|
| 4302 | - //remove_all_actions('publish_post');
|
|
| 4303 | - //remove_all_actions('transition_post_status');
|
|
| 4304 | - //remove_all_actions('publish_future_post');
|
|
| 4305 | - |
|
| 4306 | - if (!empty($file)) {
|
|
| 4307 | - $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 4308 | - $default_status = 'publish'; |
|
| 4309 | - $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 4294 | + wp_send_json( $json ); |
|
| 4295 | + exit; |
|
| 4296 | + } else if ( $task == 'import_post' ) {
|
|
| 4297 | + //run some stuff to make the import quicker |
|
| 4298 | + wp_defer_term_counting( true ); |
|
| 4299 | + wp_defer_comment_counting( true ); |
|
| 4300 | + $wpdb->query( 'SET autocommit = 0;' ); |
|
| 4301 | + |
|
| 4302 | + //remove_all_actions('publish_post');
|
|
| 4303 | + //remove_all_actions('transition_post_status');
|
|
| 4304 | + //remove_all_actions('publish_future_post');
|
|
| 4305 | + |
|
| 4306 | + if (!empty($file)) {
|
|
| 4307 | + $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 4308 | + $default_status = 'publish'; |
|
| 4309 | + $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 4310 | 4310 | |
| 4311 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4311 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4312 | 4312 | |
| 4313 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4314 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 4315 | - wp_send_json( $json ); |
|
| 4316 | - exit; |
|
| 4317 | - } |
|
| 4313 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4314 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 4315 | + wp_send_json( $json ); |
|
| 4316 | + exit; |
|
| 4317 | + } |
|
| 4318 | 4318 | |
| 4319 | - $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
|
|
| 4320 | - $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
| 4321 | - $processed_actual = 0; |
|
| 4322 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4323 | - $index = $processed + $i; |
|
| 4324 | - $gd_post = array(); |
|
| 4319 | + $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
|
|
| 4320 | + $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
| 4321 | + $processed_actual = 0; |
|
| 4322 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4323 | + $index = $processed + $i; |
|
| 4324 | + $gd_post = array(); |
|
| 4325 | 4325 | |
| 4326 | - if (isset($file[$index])) {
|
|
| 4327 | - $processed_actual++; |
|
| 4328 | - $row = $file[$index]; |
|
| 4329 | - $row = array_map( 'trim', $row ); |
|
| 4330 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 4331 | - $row = array_map( 'addslashes_gpc', $row ); |
|
| 4326 | + if (isset($file[$index])) {
|
|
| 4327 | + $processed_actual++; |
|
| 4328 | + $row = $file[$index]; |
|
| 4329 | + $row = array_map( 'trim', $row ); |
|
| 4330 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 4331 | + $row = array_map( 'addslashes_gpc', $row ); |
|
| 4332 | 4332 | |
| 4333 | - $post_id = ''; |
|
| 4334 | - $post_title = ''; |
|
| 4335 | - $post_author = ''; |
|
| 4336 | - $post_content = ''; |
|
| 4337 | - $post_category_arr = array(); |
|
| 4338 | - $default_category = ''; |
|
| 4339 | - $post_tags = array(); |
|
| 4340 | - $post_type = ''; |
|
| 4341 | - $post_status = ''; |
|
| 4342 | - $geodir_video = ''; |
|
| 4343 | - $post_address = ''; |
|
| 4344 | - $post_city = ''; |
|
| 4345 | - $post_region = ''; |
|
| 4346 | - $post_country = ''; |
|
| 4347 | - $post_zip = ''; |
|
| 4348 | - $post_latitude = ''; |
|
| 4349 | - $post_longitude = ''; |
|
| 4350 | - $post_neighbourhood = ''; |
|
| 4351 | - $neighbourhood_latitude = ''; |
|
| 4352 | - $neighbourhood_longitude = ''; |
|
| 4353 | - $geodir_timing = ''; |
|
| 4354 | - $geodir_contact = ''; |
|
| 4355 | - $geodir_email = ''; |
|
| 4356 | - $geodir_website = ''; |
|
| 4357 | - $geodir_twitter = ''; |
|
| 4358 | - $geodir_facebook = ''; |
|
| 4359 | - $geodir_twitter = ''; |
|
| 4360 | - $post_images = array(); |
|
| 4333 | + $post_id = ''; |
|
| 4334 | + $post_title = ''; |
|
| 4335 | + $post_author = ''; |
|
| 4336 | + $post_content = ''; |
|
| 4337 | + $post_category_arr = array(); |
|
| 4338 | + $default_category = ''; |
|
| 4339 | + $post_tags = array(); |
|
| 4340 | + $post_type = ''; |
|
| 4341 | + $post_status = ''; |
|
| 4342 | + $geodir_video = ''; |
|
| 4343 | + $post_address = ''; |
|
| 4344 | + $post_city = ''; |
|
| 4345 | + $post_region = ''; |
|
| 4346 | + $post_country = ''; |
|
| 4347 | + $post_zip = ''; |
|
| 4348 | + $post_latitude = ''; |
|
| 4349 | + $post_longitude = ''; |
|
| 4350 | + $post_neighbourhood = ''; |
|
| 4351 | + $neighbourhood_latitude = ''; |
|
| 4352 | + $neighbourhood_longitude = ''; |
|
| 4353 | + $geodir_timing = ''; |
|
| 4354 | + $geodir_contact = ''; |
|
| 4355 | + $geodir_email = ''; |
|
| 4356 | + $geodir_website = ''; |
|
| 4357 | + $geodir_twitter = ''; |
|
| 4358 | + $geodir_facebook = ''; |
|
| 4359 | + $geodir_twitter = ''; |
|
| 4360 | + $post_images = array(); |
|
| 4361 | 4361 | |
| 4362 | - $expire_date = 'Never'; |
|
| 4362 | + $expire_date = 'Never'; |
|
| 4363 | 4363 | |
| 4364 | - $language = ''; |
|
| 4365 | - $original_post_id = ''; |
|
| 4364 | + $language = ''; |
|
| 4365 | + $original_post_id = ''; |
|
| 4366 | 4366 | |
| 4367 | - $c = 0; |
|
| 4368 | - foreach ($columns as $column ) {
|
|
| 4369 | - $gd_post[$column] = $row[$c]; |
|
| 4367 | + $c = 0; |
|
| 4368 | + foreach ($columns as $column ) {
|
|
| 4369 | + $gd_post[$column] = $row[$c]; |
|
| 4370 | 4370 | |
| 4371 | - if ( $column == 'post_id' ) {
|
|
| 4372 | - $post_id = $row[$c]; |
|
| 4373 | - } else if ( $column == 'post_title' ) {
|
|
| 4374 | - $post_title = sanitize_text_field($row[$c]); |
|
| 4375 | - } else if ( $column == 'post_author' ) {
|
|
| 4376 | - $post_author = $row[$c]; |
|
| 4377 | - } else if ( $column == 'post_content' ) {
|
|
| 4378 | - $post_content = $row[$c]; |
|
| 4379 | - } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 4380 | - $post_category_arr = explode( ',', $row[$c] ); |
|
| 4381 | - } else if ( $column == 'default_category' ) {
|
|
| 4382 | - $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 4383 | - } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 4384 | - $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
| 4385 | - } else if ( $column == 'post_type' ) {
|
|
| 4386 | - $post_type = $row[$c]; |
|
| 4387 | - } else if ( $column == 'post_status' ) {
|
|
| 4388 | - $post_status = sanitize_key( $row[$c] ); |
|
| 4389 | - } else if ( $column == 'is_featured' ) {
|
|
| 4390 | - $is_featured = (int)$row[$c]; |
|
| 4391 | - } else if ( $column == 'geodir_video' ) {
|
|
| 4392 | - $geodir_video = $row[$c]; |
|
| 4393 | - } else if ( $column == 'post_address' ) {
|
|
| 4394 | - $post_address = sanitize_text_field($row[$c]); |
|
| 4395 | - } else if ( $column == 'post_city' ) {
|
|
| 4396 | - $post_city = sanitize_text_field($row[$c]); |
|
| 4397 | - } else if ( $column == 'post_region' ) {
|
|
| 4398 | - $post_region = sanitize_text_field($row[$c]); |
|
| 4399 | - } else if ( $column == 'post_country' ) {
|
|
| 4400 | - $post_country = sanitize_text_field($row[$c]); |
|
| 4401 | - } else if ( $column == 'post_zip' ) {
|
|
| 4402 | - $post_zip = sanitize_text_field($row[$c]); |
|
| 4403 | - } else if ( $column == 'post_latitude' ) {
|
|
| 4404 | - $post_latitude = sanitize_text_field($row[$c]); |
|
| 4405 | - } else if ( $column == 'post_longitude' ) {
|
|
| 4406 | - $post_longitude = sanitize_text_field($row[$c]); |
|
| 4407 | - } else if ( $column == 'post_neighbourhood' ) {
|
|
| 4408 | - $post_neighbourhood = sanitize_text_field($row[$c]); |
|
| 4409 | - unset($gd_post[$column]); |
|
| 4410 | - } else if ( $column == 'neighbourhood_latitude' ) {
|
|
| 4411 | - $neighbourhood_latitude = sanitize_text_field($row[$c]); |
|
| 4412 | - } else if ( $column == 'neighbourhood_longitude' ) {
|
|
| 4413 | - $neighbourhood_longitude = sanitize_text_field($row[$c]); |
|
| 4414 | - } else if ( $column == 'geodir_timing' ) {
|
|
| 4415 | - $geodir_timing = sanitize_text_field($row[$c]); |
|
| 4416 | - } else if ( $column == 'geodir_contact' ) {
|
|
| 4417 | - $geodir_contact = sanitize_text_field($row[$c]); |
|
| 4418 | - } else if ( $column == 'geodir_email' ) {
|
|
| 4419 | - $geodir_email = sanitize_email($row[$c]); |
|
| 4420 | - } else if ( $column == 'geodir_website' ) {
|
|
| 4421 | - $geodir_website = sanitize_text_field($row[$c]); |
|
| 4422 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 4423 | - $geodir_twitter = sanitize_text_field($row[$c]); |
|
| 4424 | - } else if ( $column == 'geodir_facebook' ) {
|
|
| 4425 | - $geodir_facebook = sanitize_text_field($row[$c]); |
|
| 4426 | - } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 4427 | - $post_images[] = $row[$c]; |
|
| 4428 | - } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 4429 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 4430 | - } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 4431 | - $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 4432 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 4433 | - } |
|
| 4434 | - // WPML |
|
| 4435 | - if ($is_wpml) {
|
|
| 4436 | - if ($column == 'language') {
|
|
| 4437 | - $language = geodir_strtolower(trim($row[$c])); |
|
| 4438 | - } else if ($column == 'original_post_id') {
|
|
| 4439 | - $original_post_id = (int)$row[$c]; |
|
| 4440 | - } |
|
| 4441 | - } |
|
| 4442 | - // WPML |
|
| 4443 | - $c++; |
|
| 4444 | - } |
|
| 4371 | + if ( $column == 'post_id' ) {
|
|
| 4372 | + $post_id = $row[$c]; |
|
| 4373 | + } else if ( $column == 'post_title' ) {
|
|
| 4374 | + $post_title = sanitize_text_field($row[$c]); |
|
| 4375 | + } else if ( $column == 'post_author' ) {
|
|
| 4376 | + $post_author = $row[$c]; |
|
| 4377 | + } else if ( $column == 'post_content' ) {
|
|
| 4378 | + $post_content = $row[$c]; |
|
| 4379 | + } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 4380 | + $post_category_arr = explode( ',', $row[$c] ); |
|
| 4381 | + } else if ( $column == 'default_category' ) {
|
|
| 4382 | + $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 4383 | + } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 4384 | + $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
| 4385 | + } else if ( $column == 'post_type' ) {
|
|
| 4386 | + $post_type = $row[$c]; |
|
| 4387 | + } else if ( $column == 'post_status' ) {
|
|
| 4388 | + $post_status = sanitize_key( $row[$c] ); |
|
| 4389 | + } else if ( $column == 'is_featured' ) {
|
|
| 4390 | + $is_featured = (int)$row[$c]; |
|
| 4391 | + } else if ( $column == 'geodir_video' ) {
|
|
| 4392 | + $geodir_video = $row[$c]; |
|
| 4393 | + } else if ( $column == 'post_address' ) {
|
|
| 4394 | + $post_address = sanitize_text_field($row[$c]); |
|
| 4395 | + } else if ( $column == 'post_city' ) {
|
|
| 4396 | + $post_city = sanitize_text_field($row[$c]); |
|
| 4397 | + } else if ( $column == 'post_region' ) {
|
|
| 4398 | + $post_region = sanitize_text_field($row[$c]); |
|
| 4399 | + } else if ( $column == 'post_country' ) {
|
|
| 4400 | + $post_country = sanitize_text_field($row[$c]); |
|
| 4401 | + } else if ( $column == 'post_zip' ) {
|
|
| 4402 | + $post_zip = sanitize_text_field($row[$c]); |
|
| 4403 | + } else if ( $column == 'post_latitude' ) {
|
|
| 4404 | + $post_latitude = sanitize_text_field($row[$c]); |
|
| 4405 | + } else if ( $column == 'post_longitude' ) {
|
|
| 4406 | + $post_longitude = sanitize_text_field($row[$c]); |
|
| 4407 | + } else if ( $column == 'post_neighbourhood' ) {
|
|
| 4408 | + $post_neighbourhood = sanitize_text_field($row[$c]); |
|
| 4409 | + unset($gd_post[$column]); |
|
| 4410 | + } else if ( $column == 'neighbourhood_latitude' ) {
|
|
| 4411 | + $neighbourhood_latitude = sanitize_text_field($row[$c]); |
|
| 4412 | + } else if ( $column == 'neighbourhood_longitude' ) {
|
|
| 4413 | + $neighbourhood_longitude = sanitize_text_field($row[$c]); |
|
| 4414 | + } else if ( $column == 'geodir_timing' ) {
|
|
| 4415 | + $geodir_timing = sanitize_text_field($row[$c]); |
|
| 4416 | + } else if ( $column == 'geodir_contact' ) {
|
|
| 4417 | + $geodir_contact = sanitize_text_field($row[$c]); |
|
| 4418 | + } else if ( $column == 'geodir_email' ) {
|
|
| 4419 | + $geodir_email = sanitize_email($row[$c]); |
|
| 4420 | + } else if ( $column == 'geodir_website' ) {
|
|
| 4421 | + $geodir_website = sanitize_text_field($row[$c]); |
|
| 4422 | + } else if ( $column == 'geodir_twitter' ) {
|
|
| 4423 | + $geodir_twitter = sanitize_text_field($row[$c]); |
|
| 4424 | + } else if ( $column == 'geodir_facebook' ) {
|
|
| 4425 | + $geodir_facebook = sanitize_text_field($row[$c]); |
|
| 4426 | + } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 4427 | + $post_images[] = $row[$c]; |
|
| 4428 | + } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 4429 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 4430 | + } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 4431 | + $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 4432 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 4433 | + } |
|
| 4434 | + // WPML |
|
| 4435 | + if ($is_wpml) {
|
|
| 4436 | + if ($column == 'language') {
|
|
| 4437 | + $language = geodir_strtolower(trim($row[$c])); |
|
| 4438 | + } else if ($column == 'original_post_id') {
|
|
| 4439 | + $original_post_id = (int)$row[$c]; |
|
| 4440 | + } |
|
| 4441 | + } |
|
| 4442 | + // WPML |
|
| 4443 | + $c++; |
|
| 4444 | + } |
|
| 4445 | 4445 | |
| 4446 | - // WPML |
|
| 4447 | - if ($is_wpml && $language != '') {
|
|
| 4448 | - $sitepress->switch_lang($language, true); |
|
| 4449 | - } |
|
| 4450 | - // WPML |
|
| 4446 | + // WPML |
|
| 4447 | + if ($is_wpml && $language != '') {
|
|
| 4448 | + $sitepress->switch_lang($language, true); |
|
| 4449 | + } |
|
| 4450 | + // WPML |
|
| 4451 | 4451 | |
| 4452 | - $gd_post['IMAGE'] = $post_images; |
|
| 4452 | + $gd_post['IMAGE'] = $post_images; |
|
| 4453 | 4453 | |
| 4454 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 4455 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 4454 | + $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 4455 | + $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 4456 | 4456 | |
| 4457 | - $valid = true; |
|
| 4457 | + $valid = true; |
|
| 4458 | 4458 | |
| 4459 | - if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 4460 | - $invalid++; |
|
| 4461 | - $valid = false; |
|
| 4462 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4463 | - } |
|
| 4459 | + if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 4460 | + $invalid++; |
|
| 4461 | + $valid = false; |
|
| 4462 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4463 | + } |
|
| 4464 | 4464 | |
| 4465 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 4466 | - if ( $location_allowed ) {
|
|
| 4467 | - $location_result = geodir_get_default_location(); |
|
| 4468 | - if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 4469 | - $invalid_addr++; |
|
| 4470 | - $valid = false; |
|
| 4471 | - 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' ) ); |
|
| 4472 | - } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 4473 | - 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 ) ) ) {
|
|
| 4474 | - $invalid_addr++; |
|
| 4475 | - $valid = false; |
|
| 4476 | - 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' ) ); |
|
| 4477 | - } else {
|
|
| 4478 | - if (!$location_manager) {
|
|
| 4479 | - $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. |
|
| 4480 | - } |
|
| 4481 | - } |
|
| 4482 | - } |
|
| 4483 | - } |
|
| 4465 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 4466 | + if ( $location_allowed ) {
|
|
| 4467 | + $location_result = geodir_get_default_location(); |
|
| 4468 | + if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 4469 | + $invalid_addr++; |
|
| 4470 | + $valid = false; |
|
| 4471 | + 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' ) ); |
|
| 4472 | + } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 4473 | + 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 ) ) ) {
|
|
| 4474 | + $invalid_addr++; |
|
| 4475 | + $valid = false; |
|
| 4476 | + 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' ) ); |
|
| 4477 | + } else {
|
|
| 4478 | + if (!$location_manager) {
|
|
| 4479 | + $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. |
|
| 4480 | + } |
|
| 4481 | + } |
|
| 4482 | + } |
|
| 4483 | + } |
|
| 4484 | 4484 | |
| 4485 | - if ( !$valid ) {
|
|
| 4486 | - continue; |
|
| 4487 | - } |
|
| 4485 | + if ( !$valid ) {
|
|
| 4486 | + continue; |
|
| 4487 | + } |
|
| 4488 | 4488 | |
| 4489 | - $cat_taxonomy = $post_type . 'category'; |
|
| 4490 | - $tags_taxonomy = $post_type . '_tags'; |
|
| 4489 | + $cat_taxonomy = $post_type . 'category'; |
|
| 4490 | + $tags_taxonomy = $post_type . '_tags'; |
|
| 4491 | 4491 | |
| 4492 | - if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 4493 | - $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 4494 | - } |
|
| 4492 | + if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 4493 | + $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 4494 | + } |
|
| 4495 | 4495 | |
| 4496 | - $post_category = array(); |
|
| 4497 | - $default_category_id = NULL; |
|
| 4498 | - if ( !empty( $post_category_arr ) ) {
|
|
| 4499 | - foreach ( $post_category_arr as $value ) {
|
|
| 4500 | - $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 4496 | + $post_category = array(); |
|
| 4497 | + $default_category_id = NULL; |
|
| 4498 | + if ( !empty( $post_category_arr ) ) {
|
|
| 4499 | + foreach ( $post_category_arr as $value ) {
|
|
| 4500 | + $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 4501 | 4501 | |
| 4502 | - if ( $category_name != '' ) {
|
|
| 4503 | - $term_category = array(); |
|
| 4502 | + if ( $category_name != '' ) {
|
|
| 4503 | + $term_category = array(); |
|
| 4504 | 4504 | |
| 4505 | - if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 4506 | - $term_category = $term; |
|
| 4507 | - } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 4508 | - $term_category = $term; |
|
| 4509 | - } else {
|
|
| 4510 | - $term_data = array(); |
|
| 4511 | - $term_data['name'] = $category_name; |
|
| 4512 | - $term_data['taxonomy'] = $cat_taxonomy; |
|
| 4505 | + if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 4506 | + $term_category = $term; |
|
| 4507 | + } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 4508 | + $term_category = $term; |
|
| 4509 | + } else {
|
|
| 4510 | + $term_data = array(); |
|
| 4511 | + $term_data['name'] = $category_name; |
|
| 4512 | + $term_data['taxonomy'] = $cat_taxonomy; |
|
| 4513 | 4513 | |
| 4514 | - $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 4515 | - if ( $term_id ) {
|
|
| 4516 | - $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 4517 | - } |
|
| 4518 | - } |
|
| 4514 | + $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 4515 | + if ( $term_id ) {
|
|
| 4516 | + $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 4517 | + } |
|
| 4518 | + } |
|
| 4519 | 4519 | |
| 4520 | - if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 4521 | - $post_category[] = intval($term_category->term_id); |
|
| 4520 | + if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 4521 | + $post_category[] = intval($term_category->term_id); |
|
| 4522 | 4522 | |
| 4523 | - if ($category_name == $default_category) {
|
|
| 4524 | - $default_category_id = intval($term_category->term_id); |
|
| 4525 | - } |
|
| 4526 | - } |
|
| 4527 | - } |
|
| 4528 | - } |
|
| 4529 | - } |
|
| 4523 | + if ($category_name == $default_category) {
|
|
| 4524 | + $default_category_id = intval($term_category->term_id); |
|
| 4525 | + } |
|
| 4526 | + } |
|
| 4527 | + } |
|
| 4528 | + } |
|
| 4529 | + } |
|
| 4530 | 4530 | |
| 4531 | - $save_post = array(); |
|
| 4532 | - $save_post['post_title'] = $post_title; |
|
| 4533 | - $save_post['post_content'] = $post_content; |
|
| 4534 | - $save_post['post_type'] = $post_type; |
|
| 4535 | - $save_post['post_author'] = $post_author; |
|
| 4536 | - $save_post['post_status'] = $post_status; |
|
| 4537 | - $save_post['post_category'] = $post_category; |
|
| 4538 | - $save_post['post_tags'] = $post_tags; |
|
| 4539 | - |
|
| 4540 | - $saved_post_id = NULL; |
|
| 4541 | - if ( $import_choice == 'update' ) {
|
|
| 4542 | - $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
| 4531 | + $save_post = array(); |
|
| 4532 | + $save_post['post_title'] = $post_title; |
|
| 4533 | + $save_post['post_content'] = $post_content; |
|
| 4534 | + $save_post['post_type'] = $post_type; |
|
| 4535 | + $save_post['post_author'] = $post_author; |
|
| 4536 | + $save_post['post_status'] = $post_status; |
|
| 4537 | + $save_post['post_category'] = $post_category; |
|
| 4538 | + $save_post['post_tags'] = $post_tags; |
|
| 4539 | + |
|
| 4540 | + $saved_post_id = NULL; |
|
| 4541 | + if ( $import_choice == 'update' ) {
|
|
| 4542 | + $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
| 4543 | 4543 | |
| 4544 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4545 | - $save_post['ID'] = $post_id; |
|
| 4544 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4545 | + $save_post['ID'] = $post_id; |
|
| 4546 | 4546 | |
| 4547 | - if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
|
|
| 4548 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4549 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4550 | - $saved_post_id = 0; |
|
| 4551 | - } else {
|
|
| 4552 | - $saved_post_id = $post_id; |
|
| 4553 | - $updated++; |
|
| 4554 | - } |
|
| 4555 | - } |
|
| 4556 | - } else {
|
|
| 4557 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4558 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4559 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4560 | - $saved_post_id = 0; |
|
| 4561 | - } else {
|
|
| 4562 | - $created++; |
|
| 4563 | - } |
|
| 4564 | - } |
|
| 4565 | - } |
|
| 4547 | + if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
|
|
| 4548 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4549 | + $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4550 | + $saved_post_id = 0; |
|
| 4551 | + } else {
|
|
| 4552 | + $saved_post_id = $post_id; |
|
| 4553 | + $updated++; |
|
| 4554 | + } |
|
| 4555 | + } |
|
| 4556 | + } else {
|
|
| 4557 | + if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4558 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4559 | + $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4560 | + $saved_post_id = 0; |
|
| 4561 | + } else {
|
|
| 4562 | + $created++; |
|
| 4563 | + } |
|
| 4564 | + } |
|
| 4565 | + } |
|
| 4566 | 4566 | |
| 4567 | - if ( !$saved_post_id > 0 ) {
|
|
| 4568 | - $invalid++; |
|
| 4569 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
| 4570 | - } |
|
| 4571 | - } else if ( $import_choice == 'skip' ) {
|
|
| 4572 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4573 | - $skipped++; |
|
| 4574 | - } else {
|
|
| 4575 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4576 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4577 | - $invalid++; |
|
| 4567 | + if ( !$saved_post_id > 0 ) {
|
|
| 4568 | + $invalid++; |
|
| 4569 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
| 4570 | + } |
|
| 4571 | + } else if ( $import_choice == 'skip' ) {
|
|
| 4572 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4573 | + $skipped++; |
|
| 4574 | + } else {
|
|
| 4575 | + if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4576 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4577 | + $invalid++; |
|
| 4578 | 4578 | |
| 4579 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
| 4580 | - $saved_post_id = 0; |
|
| 4581 | - } else {
|
|
| 4582 | - $created++; |
|
| 4583 | - } |
|
| 4584 | - } else {
|
|
| 4585 | - $invalid++; |
|
| 4579 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
| 4580 | + $saved_post_id = 0; |
|
| 4581 | + } else {
|
|
| 4582 | + $created++; |
|
| 4583 | + } |
|
| 4584 | + } else {
|
|
| 4585 | + $invalid++; |
|
| 4586 | 4586 | |
| 4587 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4588 | - } |
|
| 4589 | - } |
|
| 4590 | - } else {
|
|
| 4591 | - $invalid++; |
|
| 4587 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4588 | + } |
|
| 4589 | + } |
|
| 4590 | + } else {
|
|
| 4591 | + $invalid++; |
|
| 4592 | 4592 | |
| 4593 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4594 | - } |
|
| 4593 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4594 | + } |
|
| 4595 | 4595 | |
| 4596 | - if ( (int)$saved_post_id > 0 ) {
|
|
| 4597 | - // WPML |
|
| 4598 | - if ($is_wpml && $original_post_id > 0 && $language != '') {
|
|
| 4599 | - $wpml_post_type = 'post_' . $post_type; |
|
| 4600 | - $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 4601 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 4596 | + if ( (int)$saved_post_id > 0 ) {
|
|
| 4597 | + // WPML |
|
| 4598 | + if ($is_wpml && $original_post_id > 0 && $language != '') {
|
|
| 4599 | + $wpml_post_type = 'post_' . $post_type; |
|
| 4600 | + $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 4601 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 4602 | 4602 | |
| 4603 | - $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 4603 | + $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 4604 | 4604 | |
| 4605 | - $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 4606 | - } |
|
| 4607 | - // WPML |
|
| 4608 | - $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 4605 | + $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 4606 | + } |
|
| 4607 | + // WPML |
|
| 4608 | + $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 4609 | 4609 | |
| 4610 | - $gd_post['post_id'] = $saved_post_id; |
|
| 4611 | - $gd_post['ID'] = $saved_post_id; |
|
| 4612 | - $gd_post['post_tags'] = $post_tags; |
|
| 4613 | - $gd_post['post_title'] = $post_title; |
|
| 4614 | - $gd_post['post_status'] = $post_status; |
|
| 4615 | - $gd_post['submit_time'] = time(); |
|
| 4616 | - $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 4610 | + $gd_post['post_id'] = $saved_post_id; |
|
| 4611 | + $gd_post['ID'] = $saved_post_id; |
|
| 4612 | + $gd_post['post_tags'] = $post_tags; |
|
| 4613 | + $gd_post['post_title'] = $post_title; |
|
| 4614 | + $gd_post['post_status'] = $post_status; |
|
| 4615 | + $gd_post['submit_time'] = time(); |
|
| 4616 | + $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 4617 | 4617 | |
| 4618 | - // post location |
|
| 4619 | - $post_location_id = 0; |
|
| 4620 | - if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 4621 | - $gd_post['post_neighbourhood'] = ''; |
|
| 4618 | + // post location |
|
| 4619 | + $post_location_id = 0; |
|
| 4620 | + if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 4621 | + $gd_post['post_neighbourhood'] = ''; |
|
| 4622 | 4622 | |
| 4623 | - $post_location_info = array( |
|
| 4624 | - 'city' => $post_city, |
|
| 4625 | - 'region' => $post_region, |
|
| 4626 | - 'country' => $post_country, |
|
| 4627 | - 'geo_lat' => $post_latitude, |
|
| 4628 | - 'geo_lng' => $post_longitude |
|
| 4629 | - ); |
|
| 4630 | - if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 4631 | - $post_location_id = $location_id; |
|
| 4632 | - } |
|
| 4623 | + $post_location_info = array( |
|
| 4624 | + 'city' => $post_city, |
|
| 4625 | + 'region' => $post_region, |
|
| 4626 | + 'country' => $post_country, |
|
| 4627 | + 'geo_lat' => $post_latitude, |
|
| 4628 | + 'geo_lng' => $post_longitude |
|
| 4629 | + ); |
|
| 4630 | + if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 4631 | + $post_location_id = $location_id; |
|
| 4632 | + } |
|
| 4633 | 4633 | |
| 4634 | - if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
|
|
| 4635 | - $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id); |
|
| 4634 | + if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
|
|
| 4635 | + $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id); |
|
| 4636 | 4636 | |
| 4637 | - $hood_data = array(); |
|
| 4638 | - $hood_data['hood_location_id'] = $post_location_id; |
|
| 4639 | - $hood_data['hood_name'] = $post_neighbourhood; |
|
| 4637 | + $hood_data = array(); |
|
| 4638 | + $hood_data['hood_location_id'] = $post_location_id; |
|
| 4639 | + $hood_data['hood_name'] = $post_neighbourhood; |
|
| 4640 | 4640 | |
| 4641 | - if (!empty($neighbourhood_info)) {
|
|
| 4642 | - $hood_data['hood_id'] = $neighbourhood_info->hood_id; |
|
| 4643 | - $hood_data['hood_slug'] = $neighbourhood_info->hood_slug; |
|
| 4641 | + if (!empty($neighbourhood_info)) {
|
|
| 4642 | + $hood_data['hood_id'] = $neighbourhood_info->hood_id; |
|
| 4643 | + $hood_data['hood_slug'] = $neighbourhood_info->hood_slug; |
|
| 4644 | 4644 | |
| 4645 | - if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4646 | - $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4647 | - $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4648 | - } |
|
| 4649 | - } |
|
| 4645 | + if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4646 | + $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4647 | + $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4648 | + } |
|
| 4649 | + } |
|
| 4650 | 4650 | |
| 4651 | - if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4652 | - $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4653 | - $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4654 | - } |
|
| 4651 | + if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4652 | + $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4653 | + $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4654 | + } |
|
| 4655 | 4655 | |
| 4656 | - $hood_data['hood_latitude'] = $post_latitude; |
|
| 4657 | - $hood_data['hood_longitude'] = $post_longitude; |
|
| 4656 | + $hood_data['hood_latitude'] = $post_latitude; |
|
| 4657 | + $hood_data['hood_longitude'] = $post_longitude; |
|
| 4658 | 4658 | |
| 4659 | - $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data); |
|
| 4660 | - if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
|
|
| 4661 | - $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug; |
|
| 4662 | - } |
|
| 4663 | - } |
|
| 4664 | - } |
|
| 4665 | - $gd_post['post_location_id'] = $post_location_id; |
|
| 4659 | + $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data); |
|
| 4660 | + if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
|
|
| 4661 | + $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug; |
|
| 4662 | + } |
|
| 4663 | + } |
|
| 4664 | + } |
|
| 4665 | + $gd_post['post_location_id'] = $post_location_id; |
|
| 4666 | 4666 | |
| 4667 | - // post package info |
|
| 4668 | - $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 4669 | - if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 4670 | - $package_id = $gd_post_info->package_id; |
|
| 4671 | - } |
|
| 4667 | + // post package info |
|
| 4668 | + $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 4669 | + if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 4670 | + $package_id = $gd_post_info->package_id; |
|
| 4671 | + } |
|
| 4672 | 4672 | |
| 4673 | - $package_info = array(); |
|
| 4674 | - if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 4675 | - $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 4673 | + $package_info = array(); |
|
| 4674 | + if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 4675 | + $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 4676 | 4676 | |
| 4677 | - if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 4678 | - $package_info = array(); |
|
| 4679 | - } |
|
| 4680 | - } |
|
| 4677 | + if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 4678 | + $package_info = array(); |
|
| 4679 | + } |
|
| 4680 | + } |
|
| 4681 | 4681 | |
| 4682 | - if (empty($package_info)) {
|
|
| 4683 | - $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 4684 | - } |
|
| 4682 | + if (empty($package_info)) {
|
|
| 4683 | + $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 4684 | + } |
|
| 4685 | 4685 | |
| 4686 | - if (!empty($package_info)) {
|
|
| 4687 | - $package_id = $package_info['pid']; |
|
| 4686 | + if (!empty($package_info)) {
|
|
| 4687 | + $package_id = $package_info['pid']; |
|
| 4688 | 4688 | |
| 4689 | - if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 4690 | - $gd_post['expire_date'] = $expire_date; |
|
| 4691 | - } else {
|
|
| 4692 | - if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 4693 | - $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 4694 | - $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 4695 | - } else {
|
|
| 4696 | - $gd_post['expire_date'] = 'Never'; |
|
| 4697 | - } |
|
| 4698 | - } |
|
| 4689 | + if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 4690 | + $gd_post['expire_date'] = $expire_date; |
|
| 4691 | + } else {
|
|
| 4692 | + if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 4693 | + $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 4694 | + $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 4695 | + } else {
|
|
| 4696 | + $gd_post['expire_date'] = 'Never'; |
|
| 4697 | + } |
|
| 4698 | + } |
|
| 4699 | 4699 | |
| 4700 | - $gd_post['package_id'] = $package_id; |
|
| 4701 | - } |
|
| 4700 | + $gd_post['package_id'] = $package_id; |
|
| 4701 | + } |
|
| 4702 | 4702 | |
| 4703 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 4703 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 4704 | 4704 | |
| 4705 | - if ($post_type == 'gd_event') {
|
|
| 4706 | - $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 4707 | - } |
|
| 4705 | + if ($post_type == 'gd_event') {
|
|
| 4706 | + $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 4707 | + } |
|
| 4708 | 4708 | |
| 4709 | - if (isset($gd_post['post_id'])) {
|
|
| 4710 | - unset($gd_post['post_id']); |
|
| 4711 | - } |
|
| 4709 | + if (isset($gd_post['post_id'])) {
|
|
| 4710 | + unset($gd_post['post_id']); |
|
| 4711 | + } |
|
| 4712 | 4712 | |
| 4713 | - // Export franchise fields |
|
| 4714 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 4715 | - if ($is_franchise_active) {
|
|
| 4716 | - if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 4717 | - $gd_franchise_lock = array(); |
|
| 4713 | + // Export franchise fields |
|
| 4714 | + $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 4715 | + if ($is_franchise_active) {
|
|
| 4716 | + if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 4717 | + $gd_franchise_lock = array(); |
|
| 4718 | 4718 | |
| 4719 | - if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 4720 | - $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 4721 | - $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 4722 | - $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 4723 | - } |
|
| 4719 | + if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 4720 | + $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 4721 | + $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 4722 | + $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 4723 | + } |
|
| 4724 | 4724 | |
| 4725 | - update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 4726 | - update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 4727 | - } else {
|
|
| 4728 | - if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 4729 | - geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 4730 | - } |
|
| 4731 | - } |
|
| 4732 | - } |
|
| 4725 | + update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 4726 | + update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 4727 | + } else {
|
|
| 4728 | + if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 4729 | + geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 4730 | + } |
|
| 4731 | + } |
|
| 4732 | + } |
|
| 4733 | 4733 | |
| 4734 | - if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 4735 | - $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 4736 | - if ($default_category_id) {
|
|
| 4737 | - $save_post['post_default_category'] = $default_category_id; |
|
| 4738 | - $gd_post['default_category'] = $default_category_id; |
|
| 4739 | - } |
|
| 4740 | - $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 4741 | - } |
|
| 4734 | + if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 4735 | + $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 4736 | + if ($default_category_id) {
|
|
| 4737 | + $save_post['post_default_category'] = $default_category_id; |
|
| 4738 | + $gd_post['default_category'] = $default_category_id; |
|
| 4739 | + } |
|
| 4740 | + $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 4741 | + } |
|
| 4742 | 4742 | |
| 4743 | - // Save post info |
|
| 4744 | - geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 4745 | - // post taxonomies |
|
| 4746 | - if ( !empty( $save_post['post_category'] ) ) {
|
|
| 4747 | - wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 4743 | + // Save post info |
|
| 4744 | + geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 4745 | + // post taxonomies |
|
| 4746 | + if ( !empty( $save_post['post_category'] ) ) {
|
|
| 4747 | + wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 4748 | 4748 | |
| 4749 | - $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 4750 | - if ($default_category_id) {
|
|
| 4751 | - $post_default_category = $default_category_id; |
|
| 4752 | - } |
|
| 4753 | - $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 4754 | - $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 4755 | - $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 4749 | + $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 4750 | + if ($default_category_id) {
|
|
| 4751 | + $post_default_category = $default_category_id; |
|
| 4752 | + } |
|
| 4753 | + $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 4754 | + $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 4755 | + $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 4756 | 4756 | |
| 4757 | - if ($post_category_str != '' && $post_default_category) {
|
|
| 4758 | - $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 4759 | - } |
|
| 4757 | + if ($post_category_str != '' && $post_default_category) {
|
|
| 4758 | + $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 4759 | + } |
|
| 4760 | 4760 | |
| 4761 | - $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 4761 | + $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 4762 | 4762 | |
| 4763 | - geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 4764 | - } |
|
| 4763 | + geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 4764 | + } |
|
| 4765 | 4765 | |
| 4766 | - if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 4767 | - wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 4768 | - } |
|
| 4766 | + if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 4767 | + wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 4768 | + } |
|
| 4769 | 4769 | |
| 4770 | - // Post images |
|
| 4771 | - if ( !empty( $post_images ) ) {
|
|
| 4772 | - $post_images = array_unique($post_images); |
|
| 4770 | + // Post images |
|
| 4771 | + if ( !empty( $post_images ) ) {
|
|
| 4772 | + $post_images = array_unique($post_images); |
|
| 4773 | 4773 | |
| 4774 | - $old_post_images_arr = array(); |
|
| 4775 | - $saved_post_images_arr = array(); |
|
| 4774 | + $old_post_images_arr = array(); |
|
| 4775 | + $saved_post_images_arr = array(); |
|
| 4776 | 4776 | |
| 4777 | - $order = 1; |
|
| 4777 | + $order = 1; |
|
| 4778 | 4778 | |
| 4779 | - $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 4780 | - if (!empty($old_post_images)) {
|
|
| 4781 | - foreach( $old_post_images as $old_post_image ) {
|
|
| 4782 | - if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 4783 | - $old_post_images_arr[] = $old_post_image->file; |
|
| 4784 | - } |
|
| 4785 | - } |
|
| 4786 | - } |
|
| 4779 | + $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 4780 | + if (!empty($old_post_images)) {
|
|
| 4781 | + foreach( $old_post_images as $old_post_image ) {
|
|
| 4782 | + if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 4783 | + $old_post_images_arr[] = $old_post_image->file; |
|
| 4784 | + } |
|
| 4785 | + } |
|
| 4786 | + } |
|
| 4787 | 4787 | |
| 4788 | - foreach ( $post_images as $post_image ) {
|
|
| 4789 | - $image_name = basename( $post_image ); |
|
| 4790 | - $saved_post_images_arr[] = $image_name; |
|
| 4788 | + foreach ( $post_images as $post_image ) {
|
|
| 4789 | + $image_name = basename( $post_image ); |
|
| 4790 | + $saved_post_images_arr[] = $image_name; |
|
| 4791 | 4791 | |
| 4792 | - if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 4793 | - continue; // Skip if image already exists. |
|
| 4794 | - } |
|
| 4792 | + if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 4793 | + continue; // Skip if image already exists. |
|
| 4794 | + } |
|
| 4795 | 4795 | |
| 4796 | - $image_name_parts = explode( '.', $image_name ); |
|
| 4797 | - array_pop( $image_name_parts ); |
|
| 4798 | - $proper_image_name = implode( '.', $image_name_parts ); |
|
| 4796 | + $image_name_parts = explode( '.', $image_name ); |
|
| 4797 | + array_pop( $image_name_parts ); |
|
| 4798 | + $proper_image_name = implode( '.', $image_name_parts ); |
|
| 4799 | 4799 | |
| 4800 | - $arr_file_type = wp_check_filetype( $image_name ); |
|
| 4800 | + $arr_file_type = wp_check_filetype( $image_name ); |
|
| 4801 | 4801 | |
| 4802 | - if ( !empty( $arr_file_type ) ) {
|
|
| 4803 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 4802 | + if ( !empty( $arr_file_type ) ) {
|
|
| 4803 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 4804 | 4804 | |
| 4805 | - $attachment = array(); |
|
| 4806 | - $attachment['post_id'] = $saved_post_id; |
|
| 4807 | - $attachment['title'] = $proper_image_name; |
|
| 4808 | - $attachment['content'] = ''; |
|
| 4809 | - $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 4810 | - $attachment['mime_type'] = $uploaded_file_type; |
|
| 4811 | - $attachment['menu_order'] = $order; |
|
| 4812 | - $attachment['is_featured'] = 0; |
|
| 4813 | - |
|
| 4814 | - $attachment_set = ''; |
|
| 4815 | - foreach ( $attachment as $key => $val ) {
|
|
| 4816 | - if ( $val != '' ) {
|
|
| 4817 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 4818 | - } |
|
| 4819 | - } |
|
| 4820 | - $attachment_set = trim( $attachment_set, ", " ); |
|
| 4805 | + $attachment = array(); |
|
| 4806 | + $attachment['post_id'] = $saved_post_id; |
|
| 4807 | + $attachment['title'] = $proper_image_name; |
|
| 4808 | + $attachment['content'] = ''; |
|
| 4809 | + $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 4810 | + $attachment['mime_type'] = $uploaded_file_type; |
|
| 4811 | + $attachment['menu_order'] = $order; |
|
| 4812 | + $attachment['is_featured'] = 0; |
|
| 4813 | + |
|
| 4814 | + $attachment_set = ''; |
|
| 4815 | + foreach ( $attachment as $key => $val ) {
|
|
| 4816 | + if ( $val != '' ) {
|
|
| 4817 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 4818 | + } |
|
| 4819 | + } |
|
| 4820 | + $attachment_set = trim( $attachment_set, ", " ); |
|
| 4821 | 4821 | |
| 4822 | - // Add new attachment |
|
| 4823 | - $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 4822 | + // Add new attachment |
|
| 4823 | + $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 4824 | 4824 | |
| 4825 | - $order++; |
|
| 4826 | - } |
|
| 4827 | - } |
|
| 4825 | + $order++; |
|
| 4826 | + } |
|
| 4827 | + } |
|
| 4828 | 4828 | |
| 4829 | - $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 4830 | - // Remove previous attachment |
|
| 4831 | - $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 4829 | + $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 4830 | + // Remove previous attachment |
|
| 4831 | + $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 4832 | 4832 | |
| 4833 | - if ( !empty( $saved_post_images_arr ) ) {
|
|
| 4834 | - $menu_order = 1; |
|
| 4833 | + if ( !empty( $saved_post_images_arr ) ) {
|
|
| 4834 | + $menu_order = 1; |
|
| 4835 | 4835 | |
| 4836 | - foreach ( $saved_post_images_arr as $img_name ) {
|
|
| 4837 | - $wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) ); |
|
| 4836 | + foreach ( $saved_post_images_arr as $img_name ) {
|
|
| 4837 | + $wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) ); |
|
| 4838 | 4838 | |
| 4839 | - if( $menu_order == 1 ) {
|
|
| 4840 | - if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
|
|
| 4841 | - $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) ); |
|
| 4842 | - } |
|
| 4843 | - } |
|
| 4844 | - $menu_order++; |
|
| 4845 | - } |
|
| 4846 | - } |
|
| 4839 | + if( $menu_order == 1 ) {
|
|
| 4840 | + if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
|
|
| 4841 | + $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) ); |
|
| 4842 | + } |
|
| 4843 | + } |
|
| 4844 | + $menu_order++; |
|
| 4845 | + } |
|
| 4846 | + } |
|
| 4847 | 4847 | |
| 4848 | - if ( $order > 1 ) {
|
|
| 4849 | - $images++; |
|
| 4850 | - } |
|
| 4851 | - } |
|
| 4848 | + if ( $order > 1 ) {
|
|
| 4849 | + $images++; |
|
| 4850 | + } |
|
| 4851 | + } |
|
| 4852 | 4852 | |
| 4853 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 4854 | - do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 4853 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 4854 | + do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 4855 | 4855 | |
| 4856 | - if (isset($is_featured)) {
|
|
| 4857 | - geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 4858 | - } |
|
| 4859 | - if (isset($gd_post['expire_date'])) {
|
|
| 4860 | - geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 4861 | - } |
|
| 4862 | - } |
|
| 4856 | + if (isset($is_featured)) {
|
|
| 4857 | + geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 4858 | + } |
|
| 4859 | + if (isset($gd_post['expire_date'])) {
|
|
| 4860 | + geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 4861 | + } |
|
| 4862 | + } |
|
| 4863 | 4863 | |
| 4864 | - // WPML |
|
| 4865 | - if ($is_wpml && $language != '') {
|
|
| 4866 | - $sitepress->switch_lang($active_lang, true); |
|
| 4867 | - } |
|
| 4868 | - // WPML |
|
| 4869 | - } |
|
| 4870 | - } |
|
| 4871 | - } |
|
| 4864 | + // WPML |
|
| 4865 | + if ($is_wpml && $language != '') {
|
|
| 4866 | + $sitepress->switch_lang($active_lang, true); |
|
| 4867 | + } |
|
| 4868 | + // WPML |
|
| 4869 | + } |
|
| 4870 | + } |
|
| 4871 | + } |
|
| 4872 | 4872 | |
| 4873 | - //undo some stuff to make the import quicker |
|
| 4874 | - wp_defer_term_counting( false ); |
|
| 4875 | - wp_defer_comment_counting( false ); |
|
| 4876 | - $wpdb->query( 'COMMIT;' ); |
|
| 4877 | - $wpdb->query( 'SET autocommit = 1;' ); |
|
| 4878 | - |
|
| 4879 | - $json = array(); |
|
| 4880 | - $json['processed'] = $processed_actual; |
|
| 4881 | - $json['created'] = $created; |
|
| 4882 | - $json['updated'] = $updated; |
|
| 4883 | - $json['skipped'] = $skipped; |
|
| 4884 | - $json['invalid'] = $invalid; |
|
| 4885 | - $json['invalid_addr'] = $invalid_addr; |
|
| 4886 | - $json['images'] = $images; |
|
| 4873 | + //undo some stuff to make the import quicker |
|
| 4874 | + wp_defer_term_counting( false ); |
|
| 4875 | + wp_defer_comment_counting( false ); |
|
| 4876 | + $wpdb->query( 'COMMIT;' ); |
|
| 4877 | + $wpdb->query( 'SET autocommit = 1;' ); |
|
| 4878 | + |
|
| 4879 | + $json = array(); |
|
| 4880 | + $json['processed'] = $processed_actual; |
|
| 4881 | + $json['created'] = $created; |
|
| 4882 | + $json['updated'] = $updated; |
|
| 4883 | + $json['skipped'] = $skipped; |
|
| 4884 | + $json['invalid'] = $invalid; |
|
| 4885 | + $json['invalid_addr'] = $invalid_addr; |
|
| 4886 | + $json['images'] = $images; |
|
| 4887 | 4887 | |
| 4888 | - wp_send_json( $json ); |
|
| 4889 | - exit; |
|
| 4890 | - } else if ( $task == 'import_loc' ) {
|
|
| 4891 | - global $gd_post_types; |
|
| 4892 | - $gd_post_types = $post_types; |
|
| 4888 | + wp_send_json( $json ); |
|
| 4889 | + exit; |
|
| 4890 | + } else if ( $task == 'import_loc' ) {
|
|
| 4891 | + global $gd_post_types; |
|
| 4892 | + $gd_post_types = $post_types; |
|
| 4893 | 4893 | |
| 4894 | - if (!empty($file)) {
|
|
| 4895 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4894 | + if (!empty($file)) {
|
|
| 4895 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4896 | 4896 | |
| 4897 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4898 | - $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4899 | - wp_send_json( $json ); |
|
| 4900 | - } |
|
| 4897 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4898 | + $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4899 | + wp_send_json( $json ); |
|
| 4900 | + } |
|
| 4901 | 4901 | |
| 4902 | - $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
|
|
| 4903 | - $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
| 4904 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4905 | - $index = $processed + $i; |
|
| 4902 | + $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
|
|
| 4903 | + $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
| 4904 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4905 | + $index = $processed + $i; |
|
| 4906 | 4906 | |
| 4907 | - if (isset($file[$index])) {
|
|
| 4908 | - $row = $file[$index]; |
|
| 4909 | - $row = array_map( 'trim', $row ); |
|
| 4910 | - $data = array(); |
|
| 4907 | + if (isset($file[$index])) {
|
|
| 4908 | + $row = $file[$index]; |
|
| 4909 | + $row = array_map( 'trim', $row ); |
|
| 4910 | + $data = array(); |
|
| 4911 | 4911 | |
| 4912 | - foreach ($columns as $c => $column ) {
|
|
| 4913 | - if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta', 'city_desc', 'region_meta', 'region_desc', 'country_meta', 'country_desc'))) {
|
|
| 4914 | - $data[$column] = $row[$c]; |
|
| 4915 | - } |
|
| 4916 | - } |
|
| 4912 | + foreach ($columns as $c => $column ) {
|
|
| 4913 | + if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta', 'city_desc', 'region_meta', 'region_desc', 'country_meta', 'country_desc'))) {
|
|
| 4914 | + $data[$column] = $row[$c]; |
|
| 4915 | + } |
|
| 4916 | + } |
|
| 4917 | 4917 | |
| 4918 | - if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 4919 | - $invalid++; |
|
| 4920 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4921 | - continue; |
|
| 4922 | - } |
|
| 4918 | + if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 4919 | + $invalid++; |
|
| 4920 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4921 | + continue; |
|
| 4922 | + } |
|
| 4923 | 4923 | |
| 4924 | - $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 4924 | + $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 4925 | 4925 | |
| 4926 | - if ( $import_choice == 'update' ) {
|
|
| 4927 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4928 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4929 | - $updated++; |
|
| 4930 | - } else {
|
|
| 4931 | - $invalid++; |
|
| 4932 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4933 | - } |
|
| 4934 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4935 | - $data['location_id'] = (int)$location->location_id; |
|
| 4926 | + if ( $import_choice == 'update' ) {
|
|
| 4927 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4928 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4929 | + $updated++; |
|
| 4930 | + } else {
|
|
| 4931 | + $invalid++; |
|
| 4932 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4933 | + } |
|
| 4934 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4935 | + $data['location_id'] = (int)$location->location_id; |
|
| 4936 | 4936 | |
| 4937 | - if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 4938 | - $data['location_id'] = (int)$location->location_id; |
|
| 4939 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 4940 | - $data['location_id'] = (int)$location->location_id; |
|
| 4941 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 4942 | - $data['location_id'] = (int)$location->location_id; |
|
| 4943 | - } |
|
| 4937 | + if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 4938 | + $data['location_id'] = (int)$location->location_id; |
|
| 4939 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 4940 | + $data['location_id'] = (int)$location->location_id; |
|
| 4941 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 4942 | + $data['location_id'] = (int)$location->location_id; |
|
| 4943 | + } |
|
| 4944 | 4944 | |
| 4945 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4946 | - $updated++; |
|
| 4947 | - } else {
|
|
| 4948 | - $invalid++; |
|
| 4949 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4950 | - } |
|
| 4951 | - } else {
|
|
| 4952 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4953 | - $created++; |
|
| 4954 | - } else {
|
|
| 4955 | - $invalid++; |
|
| 4956 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4957 | - } |
|
| 4958 | - } |
|
| 4959 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 4960 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4961 | - $skipped++; |
|
| 4962 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4963 | - $skipped++; |
|
| 4964 | - } else {
|
|
| 4965 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4966 | - $created++; |
|
| 4967 | - } else {
|
|
| 4968 | - $invalid++; |
|
| 4969 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4970 | - } |
|
| 4971 | - } |
|
| 4972 | - } else {
|
|
| 4973 | - $invalid++; |
|
| 4974 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4975 | - } |
|
| 4976 | - } |
|
| 4977 | - } |
|
| 4978 | - } |
|
| 4945 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4946 | + $updated++; |
|
| 4947 | + } else {
|
|
| 4948 | + $invalid++; |
|
| 4949 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4950 | + } |
|
| 4951 | + } else {
|
|
| 4952 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4953 | + $created++; |
|
| 4954 | + } else {
|
|
| 4955 | + $invalid++; |
|
| 4956 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4957 | + } |
|
| 4958 | + } |
|
| 4959 | + } elseif ( $import_choice == 'skip' ) {
|
|
| 4960 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4961 | + $skipped++; |
|
| 4962 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4963 | + $skipped++; |
|
| 4964 | + } else {
|
|
| 4965 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4966 | + $created++; |
|
| 4967 | + } else {
|
|
| 4968 | + $invalid++; |
|
| 4969 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4970 | + } |
|
| 4971 | + } |
|
| 4972 | + } else {
|
|
| 4973 | + $invalid++; |
|
| 4974 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4975 | + } |
|
| 4976 | + } |
|
| 4977 | + } |
|
| 4978 | + } |
|
| 4979 | 4979 | |
| 4980 | - $json = array(); |
|
| 4981 | - $json['processed'] = $limit; |
|
| 4982 | - $json['created'] = $created; |
|
| 4983 | - $json['updated'] = $updated; |
|
| 4984 | - $json['skipped'] = $skipped; |
|
| 4985 | - $json['invalid'] = $invalid; |
|
| 4986 | - $json['images'] = $images; |
|
| 4980 | + $json = array(); |
|
| 4981 | + $json['processed'] = $limit; |
|
| 4982 | + $json['created'] = $created; |
|
| 4983 | + $json['updated'] = $updated; |
|
| 4984 | + $json['skipped'] = $skipped; |
|
| 4985 | + $json['invalid'] = $invalid; |
|
| 4986 | + $json['images'] = $images; |
|
| 4987 | 4987 | |
| 4988 | - wp_send_json( $json ); |
|
| 4989 | - } else if ( $task == 'import_hood' ) {
|
|
| 4990 | - if (!empty($file)) {
|
|
| 4991 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4988 | + wp_send_json( $json ); |
|
| 4989 | + } else if ( $task == 'import_hood' ) {
|
|
| 4990 | + if (!empty($file)) {
|
|
| 4991 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4992 | 4992 | |
| 4993 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4994 | - $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4995 | - wp_send_json( $json ); |
|
| 4996 | - } |
|
| 4993 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4994 | + $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4995 | + wp_send_json( $json ); |
|
| 4996 | + } |
|
| 4997 | 4997 | |
| 4998 | - $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
|
|
| 4999 | - $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' ); |
|
| 5000 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 5001 | - $index = $processed + $i; |
|
| 4998 | + $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
|
|
| 4999 | + $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' ); |
|
| 5000 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 5001 | + $index = $processed + $i; |
|
| 5002 | 5002 | |
| 5003 | - if (isset($file[$index])) {
|
|
| 5004 | - $row = $file[$index]; |
|
| 5005 | - $row = array_map( 'trim', $row ); |
|
| 5006 | - $data = array(); |
|
| 5003 | + if (isset($file[$index])) {
|
|
| 5004 | + $row = $file[$index]; |
|
| 5005 | + $row = array_map( 'trim', $row ); |
|
| 5006 | + $data = array(); |
|
| 5007 | 5007 | |
| 5008 | - foreach ($columns as $c => $column) {
|
|
| 5009 | - if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
|
|
| 5010 | - $data[$column] = sanitize_text_field($row[$c]); |
|
| 5011 | - } |
|
| 5012 | - } |
|
| 5008 | + foreach ($columns as $c => $column) {
|
|
| 5009 | + if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
|
|
| 5010 | + $data[$column] = sanitize_text_field($row[$c]); |
|
| 5011 | + } |
|
| 5012 | + } |
|
| 5013 | 5013 | |
| 5014 | - if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
|
|
| 5015 | - $invalid++; |
|
| 5016 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5017 | - continue; |
|
| 5018 | - } |
|
| 5014 | + if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
|
|
| 5015 | + $invalid++; |
|
| 5016 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5017 | + continue; |
|
| 5018 | + } |
|
| 5019 | 5019 | |
| 5020 | - $location_info = array(); |
|
| 5021 | - if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
|
|
| 5022 | - $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
|
|
| 5023 | - } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
|
|
| 5024 | - $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
|
|
| 5025 | - } |
|
| 5020 | + $location_info = array(); |
|
| 5021 | + if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
|
|
| 5022 | + $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
|
|
| 5023 | + } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
|
|
| 5024 | + $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
|
|
| 5025 | + } |
|
| 5026 | 5026 | |
| 5027 | - if (empty($location_info)) {
|
|
| 5028 | - $invalid++; |
|
| 5029 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5030 | - continue; |
|
| 5031 | - } |
|
| 5027 | + if (empty($location_info)) {
|
|
| 5028 | + $invalid++; |
|
| 5029 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5030 | + continue; |
|
| 5031 | + } |
|
| 5032 | 5032 | |
| 5033 | - $location_id = $location_info->location_id; |
|
| 5033 | + $location_id = $location_info->location_id; |
|
| 5034 | 5034 | |
| 5035 | - $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0; |
|
| 5035 | + $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0; |
|
| 5036 | 5036 | |
| 5037 | - $hood_data = array(); |
|
| 5038 | - $hood_data['hood_name'] = $data['neighbourhood_name']; |
|
| 5039 | - $hood_data['hood_slug'] = $data['neighbourhood_slug']; |
|
| 5040 | - $hood_data['hood_latitude'] = $data['latitude']; |
|
| 5041 | - $hood_data['hood_longitude'] = $data['longitude']; |
|
| 5042 | - $hood_data['hood_location_id'] = $location_id; |
|
| 5037 | + $hood_data = array(); |
|
| 5038 | + $hood_data['hood_name'] = $data['neighbourhood_name']; |
|
| 5039 | + $hood_data['hood_slug'] = $data['neighbourhood_slug']; |
|
| 5040 | + $hood_data['hood_latitude'] = $data['latitude']; |
|
| 5041 | + $hood_data['hood_longitude'] = $data['longitude']; |
|
| 5042 | + $hood_data['hood_location_id'] = $location_id; |
|
| 5043 | 5043 | |
| 5044 | - if ( $import_choice == 'update' ) {
|
|
| 5045 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 5046 | - $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
| 5044 | + if ( $import_choice == 'update' ) {
|
|
| 5045 | + if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 5046 | + $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
| 5047 | 5047 | |
| 5048 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5049 | - $updated++; |
|
| 5050 | - } else {
|
|
| 5051 | - $invalid++; |
|
| 5052 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5053 | - } |
|
| 5054 | - } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 5055 | - $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
| 5048 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5049 | + $updated++; |
|
| 5050 | + } else {
|
|
| 5051 | + $invalid++; |
|
| 5052 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5053 | + } |
|
| 5054 | + } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 5055 | + $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
| 5056 | 5056 | |
| 5057 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5058 | - $updated++; |
|
| 5059 | - } else {
|
|
| 5060 | - $invalid++; |
|
| 5061 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5062 | - } |
|
| 5063 | - } else {
|
|
| 5064 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5065 | - $created++; |
|
| 5066 | - } else {
|
|
| 5067 | - $invalid++; |
|
| 5068 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5069 | - } |
|
| 5070 | - } |
|
| 5071 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 5072 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 5073 | - $skipped++; |
|
| 5074 | - } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 5075 | - $skipped++; |
|
| 5076 | - } else {
|
|
| 5057 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5058 | + $updated++; |
|
| 5059 | + } else {
|
|
| 5060 | + $invalid++; |
|
| 5061 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5062 | + } |
|
| 5063 | + } else {
|
|
| 5064 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5065 | + $created++; |
|
| 5066 | + } else {
|
|
| 5067 | + $invalid++; |
|
| 5068 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5069 | + } |
|
| 5070 | + } |
|
| 5071 | + } elseif ( $import_choice == 'skip' ) {
|
|
| 5072 | + if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 5073 | + $skipped++; |
|
| 5074 | + } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 5075 | + $skipped++; |
|
| 5076 | + } else {
|
|
| 5077 | 5077 | |
| 5078 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5079 | - $created++; |
|
| 5080 | - } else {
|
|
| 5081 | - $invalid++; |
|
| 5082 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5083 | - } |
|
| 5084 | - } |
|
| 5085 | - } else {
|
|
| 5086 | - $invalid++; |
|
| 5087 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5088 | - } |
|
| 5089 | - } |
|
| 5090 | - } |
|
| 5091 | - } |
|
| 5078 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5079 | + $created++; |
|
| 5080 | + } else {
|
|
| 5081 | + $invalid++; |
|
| 5082 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5083 | + } |
|
| 5084 | + } |
|
| 5085 | + } else {
|
|
| 5086 | + $invalid++; |
|
| 5087 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5088 | + } |
|
| 5089 | + } |
|
| 5090 | + } |
|
| 5091 | + } |
|
| 5092 | 5092 | |
| 5093 | - $json = array(); |
|
| 5094 | - $json['processed'] = $limit; |
|
| 5095 | - $json['created'] = $created; |
|
| 5096 | - $json['updated'] = $updated; |
|
| 5097 | - $json['skipped'] = $skipped; |
|
| 5098 | - $json['invalid'] = $invalid; |
|
| 5099 | - $json['images'] = $images; |
|
| 5093 | + $json = array(); |
|
| 5094 | + $json['processed'] = $limit; |
|
| 5095 | + $json['created'] = $created; |
|
| 5096 | + $json['updated'] = $updated; |
|
| 5097 | + $json['skipped'] = $skipped; |
|
| 5098 | + $json['invalid'] = $invalid; |
|
| 5099 | + $json['images'] = $images; |
|
| 5100 | 5100 | |
| 5101 | - wp_send_json( $json ); |
|
| 5102 | - } |
|
| 5103 | - } |
|
| 5104 | - break; |
|
| 5105 | - case 'import_finish':{
|
|
| 5106 | - /** |
|
| 5107 | - * Run an action when an import finishes. |
|
| 5108 | - * |
|
| 5109 | - * This action can be used to fire functions after an import ends. |
|
| 5110 | - * |
|
| 5111 | - * @since 1.5.3 |
|
| 5112 | - * @package GeoDirectory |
|
| 5113 | - */ |
|
| 5114 | - do_action('geodir_import_finished');
|
|
| 5115 | - } |
|
| 5116 | - break; |
|
| 5101 | + wp_send_json( $json ); |
|
| 5102 | + } |
|
| 5103 | + } |
|
| 5104 | + break; |
|
| 5105 | + case 'import_finish':{
|
|
| 5106 | + /** |
|
| 5107 | + * Run an action when an import finishes. |
|
| 5108 | + * |
|
| 5109 | + * This action can be used to fire functions after an import ends. |
|
| 5110 | + * |
|
| 5111 | + * @since 1.5.3 |
|
| 5112 | + * @package GeoDirectory |
|
| 5113 | + */ |
|
| 5114 | + do_action('geodir_import_finished');
|
|
| 5115 | + } |
|
| 5116 | + break; |
|
| 5117 | 5117 | |
| 5118 | - } |
|
| 5119 | - echo '0'; |
|
| 5120 | - gd_die(); |
|
| 5118 | + } |
|
| 5119 | + echo '0'; |
|
| 5120 | + gd_die(); |
|
| 5121 | 5121 | } |
| 5122 | 5122 | |
| 5123 | 5123 | /** |
@@ -5161,12 +5161,12 @@ discard block |
||
| 5161 | 5161 | $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
| 5162 | 5162 | } |
| 5163 | 5163 | |
| 5164 | - if( !empty( $term ) ) {
|
|
| 5164 | + if( !empty( $term ) ) {
|
|
| 5165 | 5165 | $result = wp_insert_term( $term, $taxonomy, $args ); |
| 5166 | - if( !is_wp_error( $result ) ) {
|
|
| 5167 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5168 | - } |
|
| 5169 | - } |
|
| 5166 | + if( !is_wp_error( $result ) ) {
|
|
| 5167 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5168 | + } |
|
| 5169 | + } |
|
| 5170 | 5170 | |
| 5171 | 5171 | return false; |
| 5172 | 5172 | } |
@@ -5212,16 +5212,16 @@ discard block |
||
| 5212 | 5212 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
| 5213 | 5213 | |
| 5214 | 5214 | if( !is_wp_error( $result ) ) {
|
| 5215 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5216 | - } |
|
| 5215 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5216 | + } |
|
| 5217 | 5217 | } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
| 5218 | 5218 | $term_data['term_id'] = $term_info['term_id']; |
| 5219 | 5219 | |
| 5220 | 5220 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
| 5221 | 5221 | |
| 5222 | 5222 | if( !is_wp_error( $result ) ) {
|
| 5223 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5224 | - } |
|
| 5223 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5224 | + } |
|
| 5225 | 5225 | } else {
|
| 5226 | 5226 | return geodir_imex_insert_term( $taxonomy, $term_data ); |
| 5227 | 5227 | } |
@@ -5242,37 +5242,37 @@ discard block |
||
| 5242 | 5242 | * @return int Posts count. |
| 5243 | 5243 | */ |
| 5244 | 5244 | function geodir_get_posts_count( $post_type ) {
|
| 5245 | - global $wpdb, $plugin_prefix; |
|
| 5245 | + global $wpdb, $plugin_prefix; |
|
| 5246 | 5246 | |
| 5247 | - if ( !post_type_exists( $post_type ) ) {
|
|
| 5248 | - return 0; |
|
| 5249 | - } |
|
| 5247 | + if ( !post_type_exists( $post_type ) ) {
|
|
| 5248 | + return 0; |
|
| 5249 | + } |
|
| 5250 | 5250 | |
| 5251 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5251 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5252 | 5252 | |
| 5253 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5254 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5255 | - $where_statuses = ''; |
|
| 5256 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5257 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5258 | - } |
|
| 5253 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5254 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5255 | + $where_statuses = ''; |
|
| 5256 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5257 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5258 | + } |
|
| 5259 | 5259 | |
| 5260 | - $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 );
|
|
| 5260 | + $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 );
|
|
| 5261 | 5261 | |
| 5262 | - $posts_count = (int)$wpdb->get_var( $query ); |
|
| 5262 | + $posts_count = (int)$wpdb->get_var( $query ); |
|
| 5263 | 5263 | |
| 5264 | - /** |
|
| 5265 | - * Modify returned post counts for the current post type. |
|
| 5266 | - * |
|
| 5267 | - * @since 1.4.6 |
|
| 5268 | - * @package GeoDirectory |
|
| 5269 | - * |
|
| 5270 | - * @param int $posts_count Post counts. |
|
| 5271 | - * @param string $post_type Post type. |
|
| 5272 | - */ |
|
| 5273 | - $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5274 | - |
|
| 5275 | - return $posts_count; |
|
| 5264 | + /** |
|
| 5265 | + * Modify returned post counts for the current post type. |
|
| 5266 | + * |
|
| 5267 | + * @since 1.4.6 |
|
| 5268 | + * @package GeoDirectory |
|
| 5269 | + * |
|
| 5270 | + * @param int $posts_count Post counts. |
|
| 5271 | + * @param string $post_type Post type. |
|
| 5272 | + */ |
|
| 5273 | + $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5274 | + |
|
| 5275 | + return $posts_count; |
|
| 5276 | 5276 | } |
| 5277 | 5277 | |
| 5278 | 5278 | /** |
@@ -5300,9 +5300,9 @@ discard block |
||
| 5300 | 5300 | |
| 5301 | 5301 | if ( !empty( $posts ) ) {
|
| 5302 | 5302 | $is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' ); |
| 5303 | - $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 5304 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5305 | - $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
|
|
| 5303 | + $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 5304 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5305 | + $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
|
|
| 5306 | 5306 | |
| 5307 | 5307 | $csv_row = array(); |
| 5308 | 5308 | $csv_row[] = 'post_id'; |
@@ -5346,11 +5346,11 @@ discard block |
||
| 5346 | 5346 | $csv_row[] = 'post_zip'; |
| 5347 | 5347 | $csv_row[] = 'post_latitude'; |
| 5348 | 5348 | $csv_row[] = 'post_longitude'; |
| 5349 | - if ($neighbourhood_active) {
|
|
| 5350 | - $csv_row[] = 'post_neighbourhood'; |
|
| 5351 | - $csv_row[] = 'neighbourhood_latitude'; |
|
| 5352 | - $csv_row[] = 'neighbourhood_longitude'; |
|
| 5353 | - } |
|
| 5349 | + if ($neighbourhood_active) {
|
|
| 5350 | + $csv_row[] = 'post_neighbourhood'; |
|
| 5351 | + $csv_row[] = 'neighbourhood_latitude'; |
|
| 5352 | + $csv_row[] = 'neighbourhood_longitude'; |
|
| 5353 | + } |
|
| 5354 | 5354 | $csv_row[] = 'geodir_timing'; |
| 5355 | 5355 | $csv_row[] = 'geodir_contact'; |
| 5356 | 5356 | $csv_row[] = 'geodir_email'; |
@@ -5385,7 +5385,7 @@ discard block |
||
| 5385 | 5385 | $csv_rows[] = $csv_row; |
| 5386 | 5386 | |
| 5387 | 5387 | $images_count = 5; |
| 5388 | - $xx=0; |
|
| 5388 | + $xx=0; |
|
| 5389 | 5389 | foreach ( $posts as $post ) {$xx++;
|
| 5390 | 5390 | $post_id = $post['ID']; |
| 5391 | 5391 | |
@@ -5528,21 +5528,21 @@ discard block |
||
| 5528 | 5528 | $csv_row[] = $post_info['post_zip']; // post_zip |
| 5529 | 5529 | $csv_row[] = $post_info['post_latitude']; // post_latitude |
| 5530 | 5530 | $csv_row[] = $post_info['post_longitude']; // post_longitude |
| 5531 | - if ($neighbourhood_active) {
|
|
| 5532 | - $post_neighbourhood = ''; |
|
| 5533 | - $neighbourhood_latitude = ''; |
|
| 5534 | - $neighbourhood_longitude = ''; |
|
| 5535 | - if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
|
|
| 5536 | - if (!empty($hood_info)) {
|
|
| 5537 | - $post_neighbourhood = $hood_info->hood_name; |
|
| 5538 | - $neighbourhood_latitude = $hood_info->hood_latitude; |
|
| 5539 | - $neighbourhood_longitude = $hood_info->hood_longitude; |
|
| 5540 | - } |
|
| 5541 | - } |
|
| 5542 | - $csv_row[] = $post_neighbourhood; // post_neighbourhood |
|
| 5543 | - $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude |
|
| 5544 | - $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude |
|
| 5545 | - } |
|
| 5531 | + if ($neighbourhood_active) {
|
|
| 5532 | + $post_neighbourhood = ''; |
|
| 5533 | + $neighbourhood_latitude = ''; |
|
| 5534 | + $neighbourhood_longitude = ''; |
|
| 5535 | + if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
|
|
| 5536 | + if (!empty($hood_info)) {
|
|
| 5537 | + $post_neighbourhood = $hood_info->hood_name; |
|
| 5538 | + $neighbourhood_latitude = $hood_info->hood_latitude; |
|
| 5539 | + $neighbourhood_longitude = $hood_info->hood_longitude; |
|
| 5540 | + } |
|
| 5541 | + } |
|
| 5542 | + $csv_row[] = $post_neighbourhood; // post_neighbourhood |
|
| 5543 | + $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude |
|
| 5544 | + $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude |
|
| 5545 | + } |
|
| 5546 | 5546 | $csv_row[] = $post_info['geodir_timing']; // geodir_timing |
| 5547 | 5547 | $csv_row[] = $post_info['geodir_contact']; // geodir_contact |
| 5548 | 5548 | $csv_row[] = $post_info['geodir_email']; // geodir_email |
@@ -5613,55 +5613,55 @@ discard block |
||
| 5613 | 5613 | * @return array Array of posts data. |
| 5614 | 5614 | */ |
| 5615 | 5615 | function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
| 5616 | - global $wpdb, $plugin_prefix; |
|
| 5616 | + global $wpdb, $plugin_prefix; |
|
| 5617 | 5617 | |
| 5618 | - if ( ! post_type_exists( $post_type ) ) |
|
| 5619 | - return new stdClass; |
|
| 5618 | + if ( ! post_type_exists( $post_type ) ) |
|
| 5619 | + return new stdClass; |
|
| 5620 | 5620 | |
| 5621 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5621 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5622 | 5622 | |
| 5623 | - $limit = ''; |
|
| 5624 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 5625 | - $offset = ( $page_no - 1 ) * $per_page; |
|
| 5623 | + $limit = ''; |
|
| 5624 | + if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 5625 | + $offset = ( $page_no - 1 ) * $per_page; |
|
| 5626 | 5626 | |
| 5627 | - if ( $offset > 0 ) {
|
|
| 5628 | - $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 5629 | - } else {
|
|
| 5630 | - $limit = " LIMIT " . $per_page; |
|
| 5631 | - } |
|
| 5632 | - } |
|
| 5627 | + if ( $offset > 0 ) {
|
|
| 5628 | + $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 5629 | + } else {
|
|
| 5630 | + $limit = " LIMIT " . $per_page; |
|
| 5631 | + } |
|
| 5632 | + } |
|
| 5633 | 5633 | |
| 5634 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5635 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5636 | - $where_statuses = ''; |
|
| 5637 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5638 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5639 | - } |
|
| 5634 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5635 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5636 | + $where_statuses = ''; |
|
| 5637 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5638 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5639 | + } |
|
| 5640 | + |
|
| 5641 | + $query = "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;
|
|
| 5642 | + /** |
|
| 5643 | + * Modify returned posts SQL query for the current post type. |
|
| 5644 | + * |
|
| 5645 | + * @since 1.4.6 |
|
| 5646 | + * @package GeoDirectory |
|
| 5647 | + * |
|
| 5648 | + * @param int $query The SQL query. |
|
| 5649 | + * @param string $post_type Post type. |
|
| 5650 | + */ |
|
| 5651 | + $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 5652 | + |
|
| 5653 | + $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 5640 | 5654 | |
| 5641 | - $query = "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;
|
|
| 5642 | - /** |
|
| 5643 | - * Modify returned posts SQL query for the current post type. |
|
| 5644 | - * |
|
| 5645 | - * @since 1.4.6 |
|
| 5646 | - * @package GeoDirectory |
|
| 5647 | - * |
|
| 5648 | - * @param int $query The SQL query. |
|
| 5649 | - * @param string $post_type Post type. |
|
| 5650 | - */ |
|
| 5651 | - $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 5652 | - |
|
| 5653 | - $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 5654 | - |
|
| 5655 | - /** |
|
| 5656 | - * Modify returned post results for the current post type. |
|
| 5657 | - * |
|
| 5658 | - * @since 1.4.6 |
|
| 5659 | - * @package GeoDirectory |
|
| 5660 | - * |
|
| 5661 | - * @param object $results An object containing all post ids. |
|
| 5662 | - * @param string $post_type Post type. |
|
| 5663 | - */ |
|
| 5664 | - return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 5655 | + /** |
|
| 5656 | + * Modify returned post results for the current post type. |
|
| 5657 | + * |
|
| 5658 | + * @since 1.4.6 |
|
| 5659 | + * @package GeoDirectory |
|
| 5660 | + * |
|
| 5661 | + * @param object $results An object containing all post ids. |
|
| 5662 | + * @param string $post_type Post type. |
|
| 5663 | + */ |
|
| 5664 | + return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 5665 | 5665 | } |
| 5666 | 5666 | |
| 5667 | 5667 | /** |
@@ -5679,23 +5679,23 @@ discard block |
||
| 5679 | 5679 | * @return string The SQL query. |
| 5680 | 5680 | */ |
| 5681 | 5681 | function geodir_imex_get_events_query( $query, $post_type ) {
|
| 5682 | - if ( $post_type == 'gd_event' ) {
|
|
| 5683 | - global $wpdb, $plugin_prefix; |
|
| 5682 | + if ( $post_type == 'gd_event' ) {
|
|
| 5683 | + global $wpdb, $plugin_prefix; |
|
| 5684 | 5684 | |
| 5685 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5686 | - $schedule_table = EVENT_SCHEDULE; |
|
| 5685 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5686 | + $schedule_table = EVENT_SCHEDULE; |
|
| 5687 | 5687 | |
| 5688 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5689 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5690 | - $where_statuses = ''; |
|
| 5691 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5692 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5693 | - } |
|
| 5688 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5689 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5690 | + $where_statuses = ''; |
|
| 5691 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5692 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5693 | + } |
|
| 5694 | 5694 | |
| 5695 | - $query = "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC";
|
|
| 5696 | - } |
|
| 5695 | + $query = "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC";
|
|
| 5696 | + } |
|
| 5697 | 5697 | |
| 5698 | - return $query; |
|
| 5698 | + return $query; |
|
| 5699 | 5699 | } |
| 5700 | 5700 | |
| 5701 | 5701 | /** |
@@ -5717,36 +5717,36 @@ discard block |
||
| 5717 | 5717 | * @return int Total terms count. |
| 5718 | 5718 | */ |
| 5719 | 5719 | function geodir_get_terms_count( $post_type ) {
|
| 5720 | - $args = array( 'hide_empty' => 0 ); |
|
| 5720 | + $args = array( 'hide_empty' => 0 ); |
|
| 5721 | 5721 | |
| 5722 | - remove_all_filters( 'get_terms' ); |
|
| 5722 | + remove_all_filters( 'get_terms' ); |
|
| 5723 | 5723 | |
| 5724 | - $taxonomy = $post_type . 'category'; |
|
| 5724 | + $taxonomy = $post_type . 'category'; |
|
| 5725 | 5725 | |
| 5726 | - // WPML |
|
| 5727 | - $is_wpml = geodir_is_wpml(); |
|
| 5728 | - $active_lang = 'all'; |
|
| 5729 | - if ( $is_wpml ) {
|
|
| 5730 | - global $sitepress; |
|
| 5731 | - $active_lang = $sitepress->get_current_language(); |
|
| 5726 | + // WPML |
|
| 5727 | + $is_wpml = geodir_is_wpml(); |
|
| 5728 | + $active_lang = 'all'; |
|
| 5729 | + if ( $is_wpml ) {
|
|
| 5730 | + global $sitepress; |
|
| 5731 | + $active_lang = $sitepress->get_current_language(); |
|
| 5732 | 5732 | |
| 5733 | - if ( $active_lang != 'all' ) {
|
|
| 5734 | - $sitepress->switch_lang( 'all', true ); |
|
| 5735 | - } |
|
| 5736 | - } |
|
| 5737 | - // WPML |
|
| 5733 | + if ( $active_lang != 'all' ) {
|
|
| 5734 | + $sitepress->switch_lang( 'all', true ); |
|
| 5735 | + } |
|
| 5736 | + } |
|
| 5737 | + // WPML |
|
| 5738 | 5738 | |
| 5739 | - $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 5739 | + $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 5740 | 5740 | |
| 5741 | - // WPML |
|
| 5742 | - if ( $is_wpml && $active_lang !== 'all' ) {
|
|
| 5743 | - global $sitepress; |
|
| 5744 | - $sitepress->switch_lang( $active_lang, true ); |
|
| 5745 | - } |
|
| 5746 | - // WPML |
|
| 5747 | - $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 5741 | + // WPML |
|
| 5742 | + if ( $is_wpml && $active_lang !== 'all' ) {
|
|
| 5743 | + global $sitepress; |
|
| 5744 | + $sitepress->switch_lang( $active_lang, true ); |
|
| 5745 | + } |
|
| 5746 | + // WPML |
|
| 5747 | + $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 5748 | 5748 | |
| 5749 | - return $count_terms; |
|
| 5749 | + return $count_terms; |
|
| 5750 | 5750 | } |
| 5751 | 5751 | |
| 5752 | 5752 | /** |
@@ -5785,11 +5785,11 @@ discard block |
||
| 5785 | 5785 | $csv_row[] = 'cat_posttype'; |
| 5786 | 5786 | $csv_row[] = 'cat_parent'; |
| 5787 | 5787 | $csv_row[] = 'cat_schema'; |
| 5788 | - // WPML |
|
| 5788 | + // WPML |
|
| 5789 | 5789 | $is_wpml = geodir_is_wpml(); |
| 5790 | 5790 | if ($is_wpml) {
|
| 5791 | 5791 | $csv_row[] = 'cat_language'; |
| 5792 | - $csv_row[] = 'cat_id_original'; |
|
| 5792 | + $csv_row[] = 'cat_id_original'; |
|
| 5793 | 5793 | } |
| 5794 | 5794 | // WPML |
| 5795 | 5795 | $csv_row[] = 'cat_description'; |
@@ -5819,10 +5819,10 @@ discard block |
||
| 5819 | 5819 | $csv_row[] = $post_type; |
| 5820 | 5820 | $csv_row[] = $cat_parent; |
| 5821 | 5821 | $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); |
| 5822 | - // WPML |
|
| 5822 | + // WPML |
|
| 5823 | 5823 | if ($is_wpml) {
|
| 5824 | 5824 | $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); |
| 5825 | - $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
| 5825 | + $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
| 5826 | 5826 | } |
| 5827 | 5827 | // WPML |
| 5828 | 5828 | $csv_row[] = $term->description; |
@@ -6418,43 +6418,43 @@ discard block |
||
| 6418 | 6418 | * @param string $status Post status. |
| 6419 | 6419 | */ |
| 6420 | 6420 | function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') {
|
| 6421 | - global $wpdb, $current_user; |
|
| 6422 | - |
|
| 6423 | - $option_value = get_option($option); |
|
| 6424 | - |
|
| 6425 | - if ($option_value > 0) : |
|
| 6426 | - if (get_post($option_value)) : |
|
| 6427 | - // Page exists |
|
| 6428 | - return; |
|
| 6429 | - endif; |
|
| 6430 | - endif; |
|
| 6431 | - |
|
| 6432 | - $page_found = $wpdb->get_var( |
|
| 6433 | - $wpdb->prepare( |
|
| 6434 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 6435 | - array($slug) |
|
| 6436 | - ) |
|
| 6437 | - ); |
|
| 6438 | - |
|
| 6439 | - if ($page_found) : |
|
| 6440 | - // Page exists |
|
| 6441 | - if (!$option_value) update_option($option, $page_found); |
|
| 6442 | - return; |
|
| 6443 | - endif; |
|
| 6444 | - |
|
| 6445 | - $page_data = array( |
|
| 6446 | - 'post_status' => $status, |
|
| 6447 | - 'post_type' => 'page', |
|
| 6448 | - 'post_author' => $current_user->ID, |
|
| 6449 | - 'post_name' => $slug, |
|
| 6450 | - 'post_title' => $page_title, |
|
| 6451 | - 'post_content' => $page_content, |
|
| 6452 | - 'post_parent' => $post_parent, |
|
| 6453 | - 'comment_status' => 'closed' |
|
| 6454 | - ); |
|
| 6455 | - $page_id = wp_insert_post($page_data); |
|
| 6456 | - |
|
| 6457 | - add_option($option, $page_id); |
|
| 6421 | + global $wpdb, $current_user; |
|
| 6422 | + |
|
| 6423 | + $option_value = get_option($option); |
|
| 6424 | + |
|
| 6425 | + if ($option_value > 0) : |
|
| 6426 | + if (get_post($option_value)) : |
|
| 6427 | + // Page exists |
|
| 6428 | + return; |
|
| 6429 | + endif; |
|
| 6430 | + endif; |
|
| 6431 | + |
|
| 6432 | + $page_found = $wpdb->get_var( |
|
| 6433 | + $wpdb->prepare( |
|
| 6434 | + "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 6435 | + array($slug) |
|
| 6436 | + ) |
|
| 6437 | + ); |
|
| 6438 | + |
|
| 6439 | + if ($page_found) : |
|
| 6440 | + // Page exists |
|
| 6441 | + if (!$option_value) update_option($option, $page_found); |
|
| 6442 | + return; |
|
| 6443 | + endif; |
|
| 6444 | + |
|
| 6445 | + $page_data = array( |
|
| 6446 | + 'post_status' => $status, |
|
| 6447 | + 'post_type' => 'page', |
|
| 6448 | + 'post_author' => $current_user->ID, |
|
| 6449 | + 'post_name' => $slug, |
|
| 6450 | + 'post_title' => $page_title, |
|
| 6451 | + 'post_content' => $page_content, |
|
| 6452 | + 'post_parent' => $post_parent, |
|
| 6453 | + 'comment_status' => 'closed' |
|
| 6454 | + ); |
|
| 6455 | + $page_id = wp_insert_post($page_data); |
|
| 6456 | + |
|
| 6457 | + add_option($option, $page_id); |
|
| 6458 | 6458 | |
| 6459 | 6459 | } |
| 6460 | 6460 | |
@@ -6485,9 +6485,9 @@ discard block |
||
| 6485 | 6485 | * @package GeoDirectory |
| 6486 | 6486 | */ |
| 6487 | 6487 | function geodir_admin_upgrade_notice() {
|
| 6488 | - $class = "error"; |
|
| 6489 | - $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 6490 | - echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
| 6488 | + $class = "error"; |
|
| 6489 | + $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 6490 | + echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
| 6491 | 6491 | } |
| 6492 | 6492 | |
| 6493 | 6493 | /** |
@@ -6500,18 +6500,18 @@ discard block |
||
| 6500 | 6500 | */ |
| 6501 | 6501 | function geodire_admin_upgrade_notice( $plugin_data, $r ) |
| 6502 | 6502 | {
|
| 6503 | - // readme contents |
|
| 6504 | - $args = array( |
|
| 6505 | - 'timeout' => 15, |
|
| 6506 | - 'redirection' => 5 |
|
| 6507 | - ); |
|
| 6508 | - $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
| 6509 | - $data = wp_remote_get( $url, $args ); |
|
| 6503 | + // readme contents |
|
| 6504 | + $args = array( |
|
| 6505 | + 'timeout' => 15, |
|
| 6506 | + 'redirection' => 5 |
|
| 6507 | + ); |
|
| 6508 | + $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
| 6509 | + $data = wp_remote_get( $url, $args ); |
|
| 6510 | 6510 | |
| 6511 | - if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
|
| 6511 | + if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
|
| 6512 | 6512 | |
| 6513 | - geodir_in_plugin_update_message($data['body']); |
|
| 6514 | - } |
|
| 6513 | + geodir_in_plugin_update_message($data['body']); |
|
| 6514 | + } |
|
| 6515 | 6515 | } |
| 6516 | 6516 | |
| 6517 | 6517 | |
@@ -6519,28 +6519,28 @@ discard block |
||
| 6519 | 6519 | * @param string $content http response body |
| 6520 | 6520 | */ |
| 6521 | 6521 | function geodir_in_plugin_update_message($content) {
|
| 6522 | - // Output Upgrade Notice |
|
| 6523 | - $matches = null; |
|
| 6524 | - $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 6525 | - $upgrade_notice = ''; |
|
| 6526 | - if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 6527 | - if(empty($matches)){return;}
|
|
| 6528 | - |
|
| 6529 | - $version = trim( $matches[1] ); |
|
| 6530 | - if($version && $version>GEODIRECTORY_VERSION){
|
|
| 6531 | - |
|
| 6532 | - |
|
| 6533 | - $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 6534 | - if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
|
|
| 6535 | - $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
| 6536 | - foreach ( $notices as $index => $line ) {
|
|
| 6537 | - $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 6538 | - } |
|
| 6539 | - $upgrade_notice .= '</div> '; |
|
| 6540 | - } |
|
| 6541 | - } |
|
| 6542 | - } |
|
| 6543 | - echo $upgrade_notice; |
|
| 6522 | + // Output Upgrade Notice |
|
| 6523 | + $matches = null; |
|
| 6524 | + $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 6525 | + $upgrade_notice = ''; |
|
| 6526 | + if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 6527 | + if(empty($matches)){return;}
|
|
| 6528 | + |
|
| 6529 | + $version = trim( $matches[1] ); |
|
| 6530 | + if($version && $version>GEODIRECTORY_VERSION){
|
|
| 6531 | + |
|
| 6532 | + |
|
| 6533 | + $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 6534 | + if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
|
|
| 6535 | + $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
| 6536 | + foreach ( $notices as $index => $line ) {
|
|
| 6537 | + $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 6538 | + } |
|
| 6539 | + $upgrade_notice .= '</div> '; |
|
| 6540 | + } |
|
| 6541 | + } |
|
| 6542 | + } |
|
| 6543 | + echo $upgrade_notice; |
|
| 6544 | 6544 | } |
| 6545 | 6545 | |
| 6546 | 6546 | /** |
@@ -6573,19 +6573,19 @@ discard block |
||
| 6573 | 6573 | * @param array Listing statuses to be skipped. |
| 6574 | 6574 | */ |
| 6575 | 6575 | function geodir_imex_export_skip_statuses() {
|
| 6576 | - $statuses = array( 'trash', 'auto-draft' ); |
|
| 6576 | + $statuses = array( 'trash', 'auto-draft' ); |
|
| 6577 | 6577 | |
| 6578 | - /** |
|
| 6579 | - * Filter the statuses to skip during GD export listings. |
|
| 6580 | - * |
|
| 6581 | - * @since 1.6.0 |
|
| 6582 | - * @package GeoDirectory |
|
| 6583 | - * |
|
| 6584 | - * @param array $statuses Listing statuses to be skipped. |
|
| 6585 | - */ |
|
| 6586 | - $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
| 6578 | + /** |
|
| 6579 | + * Filter the statuses to skip during GD export listings. |
|
| 6580 | + * |
|
| 6581 | + * @since 1.6.0 |
|
| 6582 | + * @package GeoDirectory |
|
| 6583 | + * |
|
| 6584 | + * @param array $statuses Listing statuses to be skipped. |
|
| 6585 | + */ |
|
| 6586 | + $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
| 6587 | 6587 | |
| 6588 | - return $statuses; |
|
| 6588 | + return $statuses; |
|
| 6589 | 6589 | } |
| 6590 | 6590 | |
| 6591 | 6591 | /** |
@@ -6597,15 +6597,15 @@ discard block |
||
| 6597 | 6597 | * @since 1.6.3 |
| 6598 | 6598 | */ |
| 6599 | 6599 | function geodir_admin_dequeue_scripts() {
|
| 6600 | - // EDD |
|
| 6601 | - if (wp_script_is('jquery-chosen', 'enqueued')) {
|
|
| 6602 | - wp_dequeue_script('jquery-chosen');
|
|
| 6603 | - } |
|
| 6600 | + // EDD |
|
| 6601 | + if (wp_script_is('jquery-chosen', 'enqueued')) {
|
|
| 6602 | + wp_dequeue_script('jquery-chosen');
|
|
| 6603 | + } |
|
| 6604 | 6604 | |
| 6605 | - // Ultimate Addons for Visual Composer |
|
| 6606 | - if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
|
|
| 6607 | - wp_dequeue_script('ultimate-vc-backend-script');
|
|
| 6608 | - } |
|
| 6605 | + // Ultimate Addons for Visual Composer |
|
| 6606 | + if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
|
|
| 6607 | + wp_dequeue_script('ultimate-vc-backend-script');
|
|
| 6608 | + } |
|
| 6609 | 6609 | } |
| 6610 | 6610 | |
| 6611 | 6611 | /* |
@@ -46,31 +46,31 @@ discard block |
||
| 46 | 46 | function geodir_admin_styles() |
| 47 | 47 | {
|
| 48 | 48 | |
| 49 | - wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
|
|
| 49 | + wp_register_style('geodirectory-admin-css', geodir_plugin_url().'/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
|
|
| 50 | 50 | wp_enqueue_style('geodirectory-admin-css');
|
| 51 | 51 | |
| 52 | - wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
|
|
| 52 | + wp_register_style('geodirectory-frontend-style', geodir_plugin_url().'/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
|
|
| 53 | 53 | wp_enqueue_style('geodirectory-frontend-style');
|
| 54 | 54 | |
| 55 | - wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
|
|
| 55 | + wp_register_style('geodir-chosen-style', geodir_plugin_url().'/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
|
|
| 56 | 56 | wp_enqueue_style('geodir-chosen-style');
|
| 57 | 57 | |
| 58 | - wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
|
|
| 58 | + wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url().'/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
|
|
| 59 | 59 | wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
|
| 60 | 60 | |
| 61 | - wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
|
|
| 61 | + wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url().'/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
|
|
| 62 | 62 | wp_enqueue_style('geodirectory-jquery-ui-css');
|
| 63 | 63 | |
| 64 | - wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
|
|
| 64 | + wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url().'/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
|
|
| 65 | 65 | wp_enqueue_style('geodirectory-custom-fields-css');
|
| 66 | 66 | |
| 67 | - wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
|
|
| 67 | + wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url().'/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
|
|
| 68 | 68 | wp_enqueue_style('geodirectory-pluplodar-css');
|
| 69 | 69 | |
| 70 | - wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
|
|
| 70 | + wp_register_style('geodir-rating-style', geodir_plugin_url().'/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
|
|
| 71 | 71 | wp_enqueue_style('geodir-rating-style');
|
| 72 | 72 | |
| 73 | - wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
|
|
| 73 | + wp_register_style('geodir-rtl-style', geodir_plugin_url().'/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
|
|
| 74 | 74 | wp_enqueue_style('geodir-rtl-style');
|
| 75 | 75 | |
| 76 | 76 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | wp_register_style('geodirectory-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
|
| 90 | 90 | wp_enqueue_style('geodirectory-font-awesome');
|
| 91 | 91 | |
| 92 | - wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 92 | + wp_register_script('geodirectory-admin', geodir_plugin_url().'/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 93 | 93 | wp_enqueue_script('geodirectory-admin');
|
| 94 | 94 | |
| 95 | 95 | } |
@@ -108,59 +108,59 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | wp_enqueue_script('jquery');
|
| 110 | 110 | |
| 111 | - 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);
|
|
| 111 | + 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);
|
|
| 112 | 112 | |
| 113 | - wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 113 | + wp_register_script('chosen', geodir_plugin_url().'/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 114 | 114 | wp_enqueue_script('chosen');
|
| 115 | 115 | |
| 116 | - wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
|
|
| 116 | + wp_register_script('geodirectory-choose-ajax', geodir_plugin_url().'/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
|
|
| 117 | 117 | wp_enqueue_script('geodirectory-choose-ajax');
|
| 118 | 118 | |
| 119 | 119 | if (isset($_REQUEST['listing_type'])) {
|
| 120 | - wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
|
|
| 120 | + wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url().'/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
|
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | wp_enqueue_script('geodirectory-custom-fields-script');
|
| 124 | - $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
| 124 | + $plugin_path = geodir_plugin_url().'/geodirectory-functions/cat-meta-functions'; |
|
| 125 | 125 | |
| 126 | - wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
|
|
| 126 | + wp_enqueue_script('tax-meta-clss', $plugin_path.'/js/tax-meta-clss.js', array('jquery'), null, true);
|
|
| 127 | 127 | |
| 128 | 128 | if (in_array($geodir_map_name, array('auto', 'google'))) {
|
| 129 | - $map_lang = "&language=" . geodir_get_map_default_language(); |
|
| 129 | + $map_lang = "&language=".geodir_get_map_default_language(); |
|
| 130 | 130 | /** This filter is documented in geodirectory_template_tags.php */ |
| 131 | 131 | $map_extra = apply_filters('geodir_googlemap_script_extra', '');
|
| 132 | - wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
|
|
| 132 | + wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?'.$map_lang.$map_extra, '', NULL);
|
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | if ($geodir_map_name == 'osm') {
|
| 136 | 136 | // Leaflet OpenStreetMap |
| 137 | - wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 137 | + wp_register_style('geodirectory-leaflet-style', geodir_plugin_url().'/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 138 | 138 | wp_enqueue_style('geodirectory-leaflet-style');
|
| 139 | 139 | |
| 140 | - wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 140 | + wp_register_script('geodirectory-leaflet-script', geodir_plugin_url().'/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 141 | 141 | wp_enqueue_script('geodirectory-leaflet-script');
|
| 142 | 142 | |
| 143 | - wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
|
|
| 143 | + wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url().'/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
|
|
| 144 | 144 | wp_enqueue_script('geodirectory-leaflet-geo-script');
|
| 145 | 145 | } |
| 146 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 146 | + wp_enqueue_script('jquery-ui-autocomplete');
|
|
| 147 | 147 | |
| 148 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 148 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url().'/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
|
|
| 149 | 149 | wp_enqueue_script('geodirectory-goMap-script');
|
| 150 | 150 | |
| 151 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 151 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url().'/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 152 | 152 | wp_enqueue_script('geodirectory-goMap-script');
|
| 153 | 153 | |
| 154 | 154 | // font awesome rating script |
| 155 | 155 | if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
| 156 | - wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 156 | + wp_register_script('geodir-barrating-js', geodir_plugin_url().'/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 157 | 157 | wp_enqueue_script('geodir-barrating-js');
|
| 158 | 158 | } else { // default rating script
|
| 159 | - wp_register_script('geodir-jRating-js', geodir_plugin_url() . '/geodirectory-assets/js/jRating.jquery.js', array(), GEODIRECTORY_VERSION);
|
|
| 159 | + wp_register_script('geodir-jRating-js', geodir_plugin_url().'/geodirectory-assets/js/jRating.jquery.js', array(), GEODIRECTORY_VERSION);
|
|
| 160 | 160 | wp_enqueue_script('geodir-jRating-js');
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
|
|
| 163 | + wp_register_script('geodir-on-document-load', geodir_plugin_url().'/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
|
|
| 164 | 164 | wp_enqueue_script('geodir-on-document-load');
|
| 165 | 165 | |
| 166 | 166 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | wp_enqueue_script('plupload-all');
|
| 169 | 169 | wp_enqueue_script('jquery-ui-sortable');
|
| 170 | 170 | |
| 171 | - wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 171 | + wp_register_script('geodirectory-plupload-script', geodir_plugin_url().'/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 172 | 172 | wp_enqueue_script('geodirectory-plupload-script');
|
| 173 | 173 | |
| 174 | 174 | // SCRIPT FOR UPLOAD END |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
|
| 223 | 223 | |
| 224 | 224 | |
| 225 | - wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 225 | + wp_register_script('geodirectory-admin-script', geodir_plugin_url().'/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 226 | 226 | wp_enqueue_script('geodirectory-admin-script');
|
| 227 | 227 | |
| 228 | 228 | wp_enqueue_style('farbtastic');
|
@@ -230,10 +230,10 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | $screen = get_current_screen(); |
| 232 | 232 | if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
|
| 233 | - wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 233 | + wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url().'/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - $ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
|
|
| 236 | + $ajax_cons_data = array('url' => __(get_option('siteurl').'?geodir_ajax=true'));
|
|
| 237 | 237 | wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
|
| 238 | 238 | |
| 239 | 239 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
| 258 | 258 | |
| 259 | - add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 259 | + add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url().'/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 260 | 260 | |
| 261 | 261 | |
| 262 | 262 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | $geodir_menu_order[] = 'separator-geodirectory'; |
| 291 | 291 | if (!empty($post_types)) {
|
| 292 | 292 | foreach ($post_types as $post_type) {
|
| 293 | - $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
| 293 | + $geodir_menu_order[] = 'edit.php?post_type='.$post_type; |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | $geodir_menu_order[] = $item; |
@@ -333,8 +333,8 @@ discard block |
||
| 333 | 333 | {
|
| 334 | 334 | if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
|
| 335 | 335 | echo '<div id="message" class="updated fade"> |
| 336 | - <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>
|
|
| 337 | - <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
|
|
| 336 | + <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>
|
|
| 337 | + <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory').'</strong></p>
|
|
| 338 | 338 | </div>'; |
| 339 | 339 | |
| 340 | 340 | } |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
|
| 343 | 343 | switch ($_REQUEST['msg']) {
|
| 344 | 344 | case 'success': |
| 345 | - echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
|
|
| 345 | + echo '<div id="message" class="updated fade"><p><strong>'.__('Your settings have been saved.', 'geodirectory').'</strong></p></div>';
|
|
| 346 | 346 | flush_rewrite_rules(false); |
| 347 | 347 | |
| 348 | 348 | break; |
@@ -350,20 +350,20 @@ discard block |
||
| 350 | 350 | $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
| 351 | 351 | |
| 352 | 352 | if ($gderr == 21) |
| 353 | - 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>';
|
|
| 353 | + 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>';
|
|
| 354 | 354 | else |
| 355 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 355 | + echo '<div id="message" class="error fade"><p><strong>'.__('Error: Your settings have not been saved, please try again.', 'geodirectory').'</strong></p></div>';
|
|
| 356 | 356 | break; |
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | if (!geodir_is_default_location_set()) {
|
| 361 | - echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 361 | + 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>';
|
|
| 362 | 362 | |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | if (!function_exists('curl_init')) {
|
| 366 | - echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
|
|
| 366 | + 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>';
|
|
| 367 | 367 | |
| 368 | 368 | } |
| 369 | 369 | } |
@@ -379,18 +379,18 @@ discard block |
||
| 379 | 379 | function geodir_handle_option_form_submit($current_tab) |
| 380 | 380 | {
|
| 381 | 381 | global $geodir_settings; |
| 382 | - if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
|
|
| 382 | + if (file_exists(dirname(__FILE__).'/option-pages/'.$current_tab.'_array.php')) {
|
|
| 383 | 383 | /** |
| 384 | 384 | * Contains settings array for current tab. |
| 385 | 385 | * |
| 386 | 386 | * @since 1.0.0 |
| 387 | 387 | * @package GeoDirectory |
| 388 | 388 | */ |
| 389 | - include_once('option-pages/' . $current_tab . '_array.php');
|
|
| 389 | + include_once('option-pages/'.$current_tab.'_array.php');
|
|
| 390 | 390 | } |
| 391 | 391 | if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
| 392 | 392 | if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
| 393 | - if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 393 | + if (!wp_verify_nonce($_REQUEST['_wpnonce-'.$current_tab], 'geodir-settings-'.$current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 394 | 394 | |
| 395 | 395 | /** |
| 396 | 396 | * Fires before updating geodirectory admin settings. |
@@ -423,13 +423,13 @@ discard block |
||
| 423 | 423 | * @param string $current_tab The current settings tab name. |
| 424 | 424 | * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
| 425 | 425 | */ |
| 426 | - do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
|
|
| 426 | + do_action('geodir_update_options_'.$current_tab, $geodir_settings[$current_tab]);
|
|
| 427 | 427 | |
| 428 | 428 | flush_rewrite_rules(false); |
| 429 | 429 | |
| 430 | 430 | $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
| 431 | 431 | |
| 432 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
|
|
| 432 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$_REQUEST['active_tab'].'&msg=success');
|
|
| 433 | 433 | |
| 434 | 434 | wp_redirect($redirect_url); |
| 435 | 435 | exit(); |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | |
| 442 | -if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined( 'GD_TESTING_MODE' ))) {
|
|
| 442 | +if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined('GD_TESTING_MODE'))) {
|
|
| 443 | 443 | /** |
| 444 | 444 | * GeoDirectory dummy data installation. |
| 445 | 445 | * |
@@ -455,18 +455,18 @@ discard block |
||
| 455 | 455 | global $wpdb, $plugin_prefix; |
| 456 | 456 | |
| 457 | 457 | if (!geodir_is_default_location_set()) {
|
| 458 | - echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 458 | + echo '<div class="updated fade"><p><strong>'.sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\''.admin_url('admin.php?page=geodirectory&tab=default_location_settings').'\'>', '</a>').'</strong></p></div>';
|
|
| 459 | 459 | } else {
|
| 460 | 460 | |
| 461 | - $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab='; |
|
| 461 | + $geodir_url = admin_url().'admin.php?page=geodirectory&tab=general_settings&active_tab='; |
|
| 462 | 462 | |
| 463 | - $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
|
|
| 463 | + $post_counts = $wpdb->get_var("SELECT count(post_id) FROM ".$plugin_prefix.$post_type."_detail WHERE post_dummy='1'");
|
|
| 464 | 464 | |
| 465 | 465 | if ($post_counts > 0) {
|
| 466 | 466 | $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
|
| 467 | 467 | |
| 468 | - $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . SAMPLE_DATA_SHOW_MSG . '</b><br /><a id="geodir_dummy_delete" class="button_delete" onclick="geodir_autoinstall(this,\'geodir_dummy_delete\',\'' . $nonce . '\',\'' . $post_type . '\')" href="javascript:void(0);" redirect_to="' . $geodir_url . '" >' . DELETE_BTN_SAMPLE_MSG . '</a></p></div>'; |
|
| 469 | - $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_DELETE_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /></p></div>'; |
|
| 468 | + $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>'.SAMPLE_DATA_SHOW_MSG.'</b><br /><a id="geodir_dummy_delete" class="button_delete" onclick="geodir_autoinstall(this,\'geodir_dummy_delete\',\''.$nonce.'\',\''.$post_type.'\')" href="javascript:void(0);" redirect_to="'.$geodir_url.'" >'.DELETE_BTN_SAMPLE_MSG.'</a></p></div>'; |
|
| 469 | + $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>'.GEODIR_SAMPLE_DATA_DELETE_MSG.'</b><br><img src="'.geodir_plugin_url().'/geodirectory-assets/images/loadingAnimation.gif" /></p></div>'; |
|
| 470 | 470 | } else {
|
| 471 | 471 | $options_list = ''; |
| 472 | 472 | for ($option = 1; $option <= 30; $option++) {
|
@@ -474,13 +474,13 @@ discard block |
||
| 474 | 474 | if ($option == 10) |
| 475 | 475 | $selected = 'selected="selected"'; |
| 476 | 476 | |
| 477 | - $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>'; |
|
| 477 | + $options_list .= '<option '.$selected.' value="'.$option.'">'.$option.'</option>'; |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
|
| 481 | 481 | |
| 482 | - $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . AUTO_INSATALL_MSG . '</b><br /><select class="selected_sample_data">' . $options_list . '</select><a id="geodir_dummy_insert" class="button_insert" href="javascript:void(0);" onclick="geodir_autoinstall(this,\'geodir_dummy_insert\',\'' . $nonce . '\',\'' . $post_type . '\')" redirect_to="' . $geodir_url . '" >' . INSERT_BTN_SAMPLE_MSG . '</a></p></div>'; |
|
| 483 | - $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_IMPORT_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /><br><span class="dummy_post_inserted"></span></div>'; |
|
| 482 | + $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>'.AUTO_INSATALL_MSG.'</b><br /><select class="selected_sample_data">'.$options_list.'</select><a id="geodir_dummy_insert" class="button_insert" href="javascript:void(0);" onclick="geodir_autoinstall(this,\'geodir_dummy_insert\',\''.$nonce.'\',\''.$post_type.'\')" redirect_to="'.$geodir_url.'" >'.INSERT_BTN_SAMPLE_MSG.'</a></p></div>'; |
|
| 483 | + $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>'.GEODIR_SAMPLE_DATA_IMPORT_MSG.'</b><br><img src="'.geodir_plugin_url().'/geodirectory-assets/images/loadingAnimation.gif" /><br><span class="dummy_post_inserted"></span></div>'; |
|
| 484 | 484 | |
| 485 | 485 | } |
| 486 | 486 | echo $dummy_msg; |
@@ -488,14 +488,14 @@ discard block |
||
| 488 | 488 | <script> |
| 489 | 489 | <?php |
| 490 | 490 | $default_location = geodir_get_default_location(); |
| 491 | - $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 492 | - $region =isset($default_location->region) ? $default_location->region : ''; |
|
| 493 | - $country =isset($default_location->country) ? $default_location->country : ''; |
|
| 494 | - $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 495 | - $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 491 | + $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 492 | + $region = isset($default_location->region) ? $default_location->region : ''; |
|
| 493 | + $country = isset($default_location->country) ? $default_location->country : ''; |
|
| 494 | + $city_latitude = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 495 | + $city_longitude = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 496 | 496 | ?> |
| 497 | 497 | var geocoder = window.gdMaps == 'google' ? new google.maps.Geocoder() : null; |
| 498 | - var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country;?>'; |
|
| 498 | + var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country; ?>'; |
|
| 499 | 499 | var bound_lat_lng; |
| 500 | 500 | var latlng = ['<?php echo $city_latitude; ?>', <?php echo $city_longitude; ?>]; |
| 501 | 501 | var lat = <?php echo $city_latitude; ?>; |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | ); |
| 539 | 539 | |
| 540 | 540 | } else {
|
| 541 | - alert("<?php _e('Geocode was not successful for the following reason:','geodirectory');?> " + status);
|
|
| 541 | + alert("<?php _e('Geocode was not successful for the following reason:', 'geodirectory'); ?> " + status);
|
|
| 542 | 542 | } |
| 543 | 543 | }); |
| 544 | 544 | } |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | var total_dummy_post_count = jQuery('#sub_' + active_tab).find('.selected_sample_data').val();
|
| 552 | 552 | |
| 553 | 553 | if (id == 'geodir_dummy_delete') {
|
| 554 | - if (confirm('<?php _e('Are you sure you want to delete dummy data?' , 'geodirectory'); ?>')) {
|
|
| 554 | + if (confirm('<?php _e('Are you sure you want to delete dummy data?', 'geodirectory'); ?>')) {
|
|
| 555 | 555 | jQuery('#sub_' + active_tab).find('.geodir_auto_install').hide();
|
| 556 | 556 | jQuery('#sub_' + active_tab).find('.geodir_show_progress').show();
|
| 557 | 557 | jQuery.post('<?php echo geodir_get_ajax_url(); ?>&geodir_autofill=' + id + '&posttype=' + posttype + '&_wpnonce=' + nonce,
|
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | jQuery.post('<?php echo geodir_get_ajax_url(); ?>&geodir_autofill=' + id + '&posttype=' + posttype + '&insert_dummy_post_index=' + dummy_post_index + '&city_bound_lat1=' + bound_lat_lng[0] + '&city_bound_lng1=' + bound_lat_lng[1] + '&city_bound_lat2=' + bound_lat_lng[2] + '&city_bound_lng2=' + bound_lat_lng[3] + '&_wpnonce=' + nonce,
|
| 571 | 571 | function (data) {
|
| 572 | 572 | |
| 573 | - jQuery(obj).closest('form').find('.dummy_post_inserted').html('<?php _e('Dummy post(s) inserted:','geodirectory');?> ' + dummy_post_index + ' <?php _e('of' ,'geodirectory'); ?> ' + total_dummy_post_count + '');
|
|
| 573 | + jQuery(obj).closest('form').find('.dummy_post_inserted').html('<?php _e('Dummy post(s) inserted:', 'geodirectory'); ?> ' + dummy_post_index + ' <?php _e('of', 'geodirectory'); ?> ' + total_dummy_post_count + '');
|
|
| 574 | 574 | dummy_post_index++; |
| 575 | 575 | if (dummy_post_index <= total_dummy_post_count) |
| 576 | 576 | geodir_autoinstall(obj, id, nonce, posttype); |
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | global $wpdb, $plugin_prefix; |
| 628 | 628 | |
| 629 | 629 | |
| 630 | - $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 630 | + $post_ids = $wpdb->get_results("SELECT post_id FROM ".$plugin_prefix."gd_place_detail WHERE post_dummy='1'");
|
|
| 631 | 631 | |
| 632 | 632 | |
| 633 | 633 | foreach ($post_ids as $post_ids_obj) {
|
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | //double check posts are deleted |
| 638 | - $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 638 | + $wpdb->get_results("DELETE FROM ".$plugin_prefix."gd_place_detail WHERE post_dummy='1'");
|
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | /** |
@@ -673,14 +673,14 @@ discard block |
||
| 673 | 673 | |
| 674 | 674 | |
| 675 | 675 | if (geodir_dummy_folder_exists()) |
| 676 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 676 | + $dummy_image_url = geodir_plugin_url()."/geodirectory-admin/dummy/cat_icon"; |
|
| 677 | 677 | else |
| 678 | 678 | $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
| 679 | 679 | |
| 680 | 680 | $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
|
| 681 | 681 | |
| 682 | 682 | $catname = str_replace(' ', '_', $catname);
|
| 683 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 683 | + $uploaded = (array) fetch_remote_file("$dummy_image_url/".$catname.".png");
|
|
| 684 | 684 | |
| 685 | 685 | if (empty($uploaded['error'])) {
|
| 686 | 686 | $new_path = $uploaded['file']; |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | $wp_filetype = wp_check_filetype(basename($new_path), null); |
| 691 | 691 | |
| 692 | 692 | $attachment = array( |
| 693 | - 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 693 | + 'guid' => $uploads['baseurl'].'/'.basename($new_path), |
|
| 694 | 694 | 'post_mime_type' => $wp_filetype['type'], |
| 695 | 695 | 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
| 696 | 696 | 'post_content' => '', |
@@ -700,7 +700,7 @@ discard block |
||
| 700 | 700 | |
| 701 | 701 | // you must first include the image.php file |
| 702 | 702 | // for the function wp_generate_attachment_metadata() to work |
| 703 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 703 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
| 704 | 704 | $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
| 705 | 705 | wp_update_attachment_metadata($attach_id, $attach_data); |
| 706 | 706 | |
@@ -717,14 +717,14 @@ discard block |
||
| 717 | 717 | $last_catid = wp_insert_term($catname, 'gd_placecategory'); |
| 718 | 718 | |
| 719 | 719 | if (geodir_dummy_folder_exists()) |
| 720 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 720 | + $dummy_image_url = geodir_plugin_url()."/geodirectory-admin/dummy/cat_icon"; |
|
| 721 | 721 | else |
| 722 | 722 | $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
| 723 | 723 | |
| 724 | 724 | $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
|
| 725 | 725 | |
| 726 | 726 | $catname = str_replace(' ', '_', $catname);
|
| 727 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 727 | + $uploaded = (array) fetch_remote_file("$dummy_image_url/".$catname.".png");
|
|
| 728 | 728 | |
| 729 | 729 | if (empty($uploaded['error'])) {
|
| 730 | 730 | $new_path = $uploaded['file']; |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | $wp_filetype = wp_check_filetype(basename($new_path), null); |
| 735 | 735 | |
| 736 | 736 | $attachment = array( |
| 737 | - 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 737 | + 'guid' => $uploads['baseurl'].'/'.basename($new_path), |
|
| 738 | 738 | 'post_mime_type' => $wp_filetype['type'], |
| 739 | 739 | 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
| 740 | 740 | 'post_content' => '', |
@@ -746,7 +746,7 @@ discard block |
||
| 746 | 746 | |
| 747 | 747 | // you must first include the image.php file |
| 748 | 748 | // for the function wp_generate_attachment_metadata() to work |
| 749 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 749 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
| 750 | 750 | $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
| 751 | 751 | wp_update_attachment_metadata($attach_id, $attach_data); |
| 752 | 752 | |
@@ -788,18 +788,18 @@ discard block |
||
| 788 | 788 | |
| 789 | 789 | elseif (isset($value['type']) && $value['type'] == 'image_width') : |
| 790 | 790 | |
| 791 | - if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
|
| 792 | - update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
| 793 | - update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
| 794 | - if (isset($_POST[$value['id'] . '_crop'])) : |
|
| 795 | - update_option($value['id'] . '_crop', 1); |
|
| 791 | + if (isset($value['id']) && isset($_POST[$value['id'].'_width'])) {
|
|
| 792 | + update_option($value['id'].'_width', $_POST[$value['id'].'_width']); |
|
| 793 | + update_option($value['id'].'_height', $_POST[$value['id'].'_height']); |
|
| 794 | + if (isset($_POST[$value['id'].'_crop'])) : |
|
| 795 | + update_option($value['id'].'_crop', 1); |
|
| 796 | 796 | else : |
| 797 | - update_option($value['id'] . '_crop', 0); |
|
| 797 | + update_option($value['id'].'_crop', 0); |
|
| 798 | 798 | endif; |
| 799 | 799 | } else {
|
| 800 | - update_option($value['id'] . '_width', $value['std']); |
|
| 801 | - update_option($value['id'] . '_height', $value['std']); |
|
| 802 | - update_option($value['id'] . '_crop', 1); |
|
| 800 | + update_option($value['id'].'_width', $value['std']); |
|
| 801 | + update_option($value['id'].'_height', $value['std']); |
|
| 802 | + update_option($value['id'].'_crop', 1); |
|
| 803 | 803 | } |
| 804 | 804 | |
| 805 | 805 | elseif (isset($value['type']) && $value['type'] == 'map') : |
@@ -841,12 +841,12 @@ discard block |
||
| 841 | 841 | elseif (isset($value['type']) && $value['type'] == 'file') : |
| 842 | 842 | |
| 843 | 843 | |
| 844 | - if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
|
|
| 844 | + if (isset($_POST[$value['id'].'_remove']) && $_POST[$value['id'].'_remove']) {// if remove is set then remove the file
|
|
| 845 | 845 | |
| 846 | 846 | if (get_option($value['id'])) {
|
| 847 | 847 | $image_name_arr = explode('/', get_option($value['id']));
|
| 848 | 848 | $noimg_name = end($image_name_arr); |
| 849 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 849 | + $img_path = $uploads['path'].'/'.$noimg_name; |
|
| 850 | 850 | if (file_exists($img_path)) |
| 851 | 851 | unlink($img_path); |
| 852 | 852 | } |
@@ -874,7 +874,7 @@ discard block |
||
| 874 | 874 | if (get_option($value['id'])) {
|
| 875 | 875 | $image_name_arr = explode('/', get_option($value['id']));
|
| 876 | 876 | $noimg_name = end($image_name_arr); |
| 877 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 877 | + $img_path = $uploads['path'].'/'.$noimg_name; |
|
| 878 | 878 | if (file_exists($img_path)) |
| 879 | 879 | unlink($img_path); |
| 880 | 880 | } |
@@ -895,7 +895,7 @@ discard block |
||
| 895 | 895 | // same menu setting per theme. |
| 896 | 896 | if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
| 897 | 897 | $theme = wp_get_theme(); |
| 898 | - update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
|
| 898 | + update_option('geodir_theme_location_nav_'.$theme->name, $_POST[$value['id']]);
|
|
| 899 | 899 | } |
| 900 | 900 | |
| 901 | 901 | if (isset($value['id']) && isset($_POST[$value['id']])) {
|
@@ -965,8 +965,8 @@ discard block |
||
| 965 | 965 | |
| 966 | 966 | $listing_slug = $geodir_posttype_info['labels']['singular_name']; |
| 967 | 967 | |
| 968 | - $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
| 969 | - 'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'), |
|
| 968 | + $tabs[$geodir_post_type.'_fields_settings'] = array( |
|
| 969 | + 'label' => __(ucfirst($listing_slug).' Settings', 'geodirectory'), |
|
| 970 | 970 | 'subtabs' => array( |
| 971 | 971 | array('subtab' => 'custom_fields',
|
| 972 | 972 | 'label' => __('Custom Fields', 'geodirectory'),
|
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | */ |
| 1033 | 1033 | function geodir_extend_geodirectory_setting_tab($tabs) |
| 1034 | 1034 | {
|
| 1035 | - $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
|
|
| 1035 | + $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory').' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
|
|
| 1036 | 1036 | return $tabs; |
| 1037 | 1037 | } |
| 1038 | 1038 | |
@@ -1092,8 +1092,8 @@ discard block |
||
| 1092 | 1092 | _e('Unknown', 'geodirectory');
|
| 1093 | 1093 | } else {
|
| 1094 | 1094 | /* If there is a city id, append 'city name' to the text string. */ |
| 1095 | - $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
|
|
| 1096 | - echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
| 1095 | + $add_location_id = $location_id > 0 ? ' ('.$location_id.')' : '';
|
|
| 1096 | + echo(__($location->country, 'geodirectory').'-'.$location->region.'-'.$location->city.$add_location_id); |
|
| 1097 | 1097 | } |
| 1098 | 1098 | break; |
| 1099 | 1099 | |
@@ -1111,14 +1111,14 @@ discard block |
||
| 1111 | 1111 | $expire_class = 'expire_over'; |
| 1112 | 1112 | } |
| 1113 | 1113 | $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
| 1114 | - $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
|
| 1114 | + $date_diff_text = '<br /><span class="'.$expire_class.'">('.$date_diff.' '.$state.')</span>';
|
|
| 1115 | 1115 | } |
| 1116 | 1116 | /* If no expire_date is found, output a default message. */ |
| 1117 | 1117 | if (empty($expire_date)) |
| 1118 | 1118 | echo __('Unknown', 'geodirectory');
|
| 1119 | 1119 | /* If there is a expire_date, append 'days left' to the text string. */ |
| 1120 | 1120 | else |
| 1121 | - echo $expire_date . $date_diff_text; |
|
| 1121 | + echo $expire_date.$date_diff_text; |
|
| 1122 | 1122 | break; |
| 1123 | 1123 | |
| 1124 | 1124 | /* If displaying the 'categorys' column. */ |
@@ -1185,7 +1185,7 @@ discard block |
||
| 1185 | 1185 | function geodir_post_information_save($post_id, $post) {
|
| 1186 | 1186 | global $wpdb, $current_user; |
| 1187 | 1187 | |
| 1188 | - if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 1188 | + if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) {
|
|
| 1189 | 1189 | return; |
| 1190 | 1190 | } |
| 1191 | 1191 | |
@@ -1253,7 +1253,7 @@ discard block |
||
| 1253 | 1253 | $tab_id = $value['id']; |
| 1254 | 1254 | |
| 1255 | 1255 | if (isset($value['desc']) && $value['desc']) |
| 1256 | - $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 1256 | + $desc = '<span style=" text-transform:none;">:- '.$value['desc'].'</span>'; |
|
| 1257 | 1257 | |
| 1258 | 1258 | if (isset($value['name']) && $value['name']) {
|
| 1259 | 1259 | if ($first_title === true) {
|
@@ -1261,9 +1261,9 @@ discard block |
||
| 1261 | 1261 | } else {
|
| 1262 | 1262 | echo '</div>'; |
| 1263 | 1263 | } |
| 1264 | - echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
| 1264 | + echo '<dd id="'.trim($tab_id).'" class="geodir_option_tabs" ><a href="javascript:void(0);">'.$value['name'].'</a></dd>'; |
|
| 1265 | 1265 | |
| 1266 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1266 | + echo '<div id="sub_'.trim($tab_id).'" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | 1269 | /** |
@@ -1273,21 +1273,21 @@ discard block |
||
| 1273 | 1273 | * |
| 1274 | 1274 | * @since 1.0.0 |
| 1275 | 1275 | */ |
| 1276 | - do_action('geodir_settings_' . sanitize_title($value['id']));
|
|
| 1276 | + do_action('geodir_settings_'.sanitize_title($value['id']));
|
|
| 1277 | 1277 | break; |
| 1278 | 1278 | |
| 1279 | 1279 | case 'no_tabs': |
| 1280 | 1280 | |
| 1281 | 1281 | echo '<div class="inner_content_tab_main">'; |
| 1282 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1282 | + echo '<div id="sub_'.trim($tab_id).'" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1283 | 1283 | |
| 1284 | 1284 | break; |
| 1285 | 1285 | |
| 1286 | 1286 | case 'sectionstart': |
| 1287 | 1287 | if (isset($value['desc']) && $value['desc']) |
| 1288 | - $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 1288 | + $desc = '<span style=" text-transform:none;"> - '.$value['desc'].'</span>'; |
|
| 1289 | 1289 | if (isset($value['name']) && $value['name']) |
| 1290 | - echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 1290 | + echo '<h3>'.$value['name'].$desc.'</h3>'; |
|
| 1291 | 1291 | /** |
| 1292 | 1292 | * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
| 1293 | 1293 | * |
@@ -1295,8 +1295,8 @@ discard block |
||
| 1295 | 1295 | * |
| 1296 | 1296 | * @since 1.0.0 |
| 1297 | 1297 | */ |
| 1298 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 1299 | - echo '<table class="form-table">' . "\n\n"; |
|
| 1298 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_start');
|
|
| 1299 | + echo '<table class="form-table">'."\n\n"; |
|
| 1300 | 1300 | |
| 1301 | 1301 | break; |
| 1302 | 1302 | case 'sectionend': |
@@ -1307,7 +1307,7 @@ discard block |
||
| 1307 | 1307 | * |
| 1308 | 1308 | * @since 1.0.0 |
| 1309 | 1309 | */ |
| 1310 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 1310 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_end');
|
|
| 1311 | 1311 | echo '</table>'; |
| 1312 | 1312 | /** |
| 1313 | 1313 | * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
@@ -1316,7 +1316,7 @@ discard block |
||
| 1316 | 1316 | * |
| 1317 | 1317 | * @since 1.0.0 |
| 1318 | 1318 | */ |
| 1319 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 1319 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_after');
|
|
| 1320 | 1320 | break; |
| 1321 | 1321 | case 'text': |
| 1322 | 1322 | ?> |
@@ -1325,7 +1325,7 @@ discard block |
||
| 1325 | 1325 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
| 1326 | 1326 | id="<?php echo esc_attr($value['id']); ?>" |
| 1327 | 1327 | type="<?php echo esc_attr($value['type']); ?>" |
| 1328 | - <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 1328 | + <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 1329 | 1329 | style=" <?php echo esc_attr($value['css']); ?>" |
| 1330 | 1330 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1331 | 1331 | echo esc_attr(stripslashes(get_option($value['id']))); |
@@ -1342,7 +1342,7 @@ discard block |
||
| 1342 | 1342 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
| 1343 | 1343 | id="<?php echo esc_attr($value['id']); ?>" |
| 1344 | 1344 | type="<?php echo esc_attr($value['type']); ?>" |
| 1345 | - <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 1345 | + <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 1346 | 1346 | style="<?php echo esc_attr($value['css']); ?>" |
| 1347 | 1347 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1348 | 1348 | echo esc_attr(stripslashes(get_option($value['id']))); |
@@ -1388,17 +1388,17 @@ discard block |
||
| 1388 | 1388 | <?php _e('Width', 'geodirectory'); ?> <input
|
| 1389 | 1389 | name="<?php echo esc_attr($value['id']); ?>_width" |
| 1390 | 1390 | id="<?php echo esc_attr($value['id']); ?>_width" type="text" size="3" |
| 1391 | - value="<?php if ($size = get_option($value['id'] . '_width')) echo stripslashes($size); else echo $value['std']; ?>"/> |
|
| 1391 | + value="<?php if ($size = get_option($value['id'].'_width')) echo stripslashes($size); else echo $value['std']; ?>"/> |
|
| 1392 | 1392 | |
| 1393 | 1393 | <?php _e('Height', 'geodirectory'); ?> <input
|
| 1394 | 1394 | name="<?php echo esc_attr($value['id']); ?>_height" |
| 1395 | 1395 | id="<?php echo esc_attr($value['id']); ?>_height" type="text" size="3" |
| 1396 | - value="<?php if ($size = get_option($value['id'] . '_height')) echo stripslashes($size); else echo $value['std']; ?>"/> |
|
| 1396 | + value="<?php if ($size = get_option($value['id'].'_height')) echo stripslashes($size); else echo $value['std']; ?>"/> |
|
| 1397 | 1397 | |
| 1398 | 1398 | <label><?php _e('Hard Crop', 'geodirectory'); ?> <input
|
| 1399 | 1399 | name="<?php echo esc_attr($value['id']); ?>_crop" |
| 1400 | 1400 | id="<?php echo esc_attr($value['id']); ?>_crop" |
| 1401 | - type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') checked(get_option($value['id'] . '_crop'), 1); else checked(1); ?> /></label> |
|
| 1401 | + type="checkbox" <?php if (get_option($value['id'].'_crop') != '') checked(get_option($value['id'].'_crop'), 1); else checked(1); ?> /></label> |
|
| 1402 | 1402 | |
| 1403 | 1403 | <span class="description"><?php echo $value['desc'] ?></span></td> |
| 1404 | 1404 | </tr><?php |
@@ -1448,7 +1448,7 @@ discard block |
||
| 1448 | 1448 | id="<?php echo esc_attr($value['id']); ?>" |
| 1449 | 1449 | style="<?php echo esc_attr($value['css']); ?>" |
| 1450 | 1450 | class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
| 1451 | - data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>" |
|
| 1451 | + data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text']; ?>" |
|
| 1452 | 1452 | option-ajaxchosen="false"> |
| 1453 | 1453 | <?php |
| 1454 | 1454 | foreach ($value['options'] as $key => $val) {
|
@@ -1459,7 +1459,7 @@ discard block |
||
| 1459 | 1459 | } else {
|
| 1460 | 1460 | ?> |
| 1461 | 1461 | <option |
| 1462 | - value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option> |
|
| 1462 | + value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values))); ?>><?php echo ucfirst($val) ?></option> |
|
| 1463 | 1463 | <?php |
| 1464 | 1464 | } |
| 1465 | 1465 | } |
@@ -1494,7 +1494,7 @@ discard block |
||
| 1494 | 1494 | ?> |
| 1495 | 1495 | |
| 1496 | 1496 | <tr valign="top"> |
| 1497 | - <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
|
|
| 1497 | + <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory'); ?></th>
|
|
| 1498 | 1498 | <td width="60%"> |
| 1499 | 1499 | <select name="geodir_default_map_language" style="width:60%"> |
| 1500 | 1500 | <?php |
@@ -1576,7 +1576,7 @@ discard block |
||
| 1576 | 1576 | |
| 1577 | 1577 | <tr valign="top"> |
| 1578 | 1578 | <th class="titledesc" |
| 1579 | - width="40%"><?php _e('Default post type search on map', 'geodirectory');?></th>
|
|
| 1579 | + width="40%"><?php _e('Default post type search on map', 'geodirectory'); ?></th>
|
|
| 1580 | 1580 | <td width="60%"> |
| 1581 | 1581 | <select name="geodir_default_map_search_pt" style="width:60%"> |
| 1582 | 1582 | <?php |
@@ -1617,7 +1617,7 @@ discard block |
||
| 1617 | 1617 | $cat_display = 'checkbox'; |
| 1618 | 1618 | $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
| 1619 | 1619 | $gd_cats = get_option('geodir_exclude_cat_on_map');
|
| 1620 | - $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 1620 | + $gd_cats_upgrade = (int) get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 1621 | 1621 | $count = 1; |
| 1622 | 1622 | ?> |
| 1623 | 1623 | <table width="70%" class="widefat"> |
@@ -1646,7 +1646,7 @@ discard block |
||
| 1646 | 1646 | name="home_map_post_types[]" |
| 1647 | 1647 | id="<?php echo esc_attr($value['id']); ?>" |
| 1648 | 1648 | value="<?php echo $key; ?>" |
| 1649 | - class="map_post_type" <?php echo $checked;?> /> |
|
| 1649 | + class="map_post_type" <?php echo $checked; ?> /> |
|
| 1650 | 1650 | <?php echo $post_types_obj->labels->singular_name; ?></td> |
| 1651 | 1651 | <td width="40%"> |
| 1652 | 1652 | <div class="home_map_category" style="overflow:auto;width:200px;height:100px;" |
@@ -1704,12 +1704,12 @@ discard block |
||
| 1704 | 1704 | ?> |
| 1705 | 1705 | <fieldset> |
| 1706 | 1706 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 1707 | - <label for="<?php echo $value['id'];?>"> |
|
| 1707 | + <label for="<?php echo $value['id']; ?>"> |
|
| 1708 | 1708 | <input name="<?php echo esc_attr($value['id']); ?>" |
| 1709 | - id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio" |
|
| 1709 | + id="<?php echo esc_attr($value['id'].$value['value']); ?>" type="radio" |
|
| 1710 | 1710 | value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
|
| 1711 | 1711 | echo 'checked="checked"'; |
| 1712 | - }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 1712 | + }elseif (get_option($value['id']) == '' && $value['std'] == $value['value']) {echo 'checked="checked"'; } ?> />
|
|
| 1713 | 1713 | <?php echo $value['desc']; ?></label><br> |
| 1714 | 1714 | </fieldset> |
| 1715 | 1715 | <?php |
@@ -1729,9 +1729,9 @@ discard block |
||
| 1729 | 1729 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1730 | 1730 | <td class="forminp"> |
| 1731 | 1731 | <textarea |
| 1732 | - <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>" |
|
| 1732 | + <?php if (isset($value['args'])) echo $value['args'].' '; ?>name="<?php echo esc_attr($value['id']); ?>" |
|
| 1733 | 1733 | id="<?php echo esc_attr($value['id']); ?>" |
| 1734 | - <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 1734 | + <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 1735 | 1735 | style="<?php echo esc_attr($value['css']); ?>"><?php if (get_option($value['id'])) echo esc_textarea(stripslashes(get_option($value['id']))); else echo esc_textarea($value['std']); ?></textarea><span |
| 1736 | 1736 | class="description"><?php echo $value['desc'] ?></span> |
| 1737 | 1737 | |
@@ -1776,7 +1776,7 @@ discard block |
||
| 1776 | 1776 | } |
| 1777 | 1777 | } |
| 1778 | 1778 | // |
| 1779 | - $page_setting = (int)get_option($value['id']); |
|
| 1779 | + $page_setting = (int) get_option($value['id']); |
|
| 1780 | 1780 | |
| 1781 | 1781 | $args = array('name' => $value['id'],
|
| 1782 | 1782 | 'id' => $value['id'], |
@@ -1793,7 +1793,7 @@ discard block |
||
| 1793 | 1793 | <tr valign="top" class="single_select_page"> |
| 1794 | 1794 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1795 | 1795 | <td class="forminp"> |
| 1796 | - <?php echo str_replace(' id=', " data-placeholder='" . __('Select a page...', 'geodirectory') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' " . $disabled . " id=", wp_dropdown_pages($args)); ?>
|
|
| 1796 | + <?php echo str_replace(' id=', " data-placeholder='".__('Select a page...', 'geodirectory')."' style='".$value['css']."' class='".$value['class']."' ".$disabled." id=", wp_dropdown_pages($args)); ?>
|
|
| 1797 | 1797 | <span class="description"><?php echo $value['desc'] ?></span> |
| 1798 | 1798 | </td> |
| 1799 | 1799 | </tr><?php |
@@ -1802,7 +1802,7 @@ discard block |
||
| 1802 | 1802 | } |
| 1803 | 1803 | break; |
| 1804 | 1804 | case 'single_select_country' : |
| 1805 | - $country_setting = (string)get_option($value['id']); |
|
| 1805 | + $country_setting = (string) get_option($value['id']); |
|
| 1806 | 1806 | if (strstr($country_setting, ':')) : |
| 1807 | 1807 | $country = current(explode(':', $country_setting));
|
| 1808 | 1808 | $state = end(explode(':', $country_setting));
|
@@ -1825,7 +1825,7 @@ discard block |
||
| 1825 | 1825 | case 'multi_select_countries' : |
| 1826 | 1826 | $countries = $geodirectory->countries->countries; |
| 1827 | 1827 | asort($countries); |
| 1828 | - $selections = (array)get_option($value['id']); |
|
| 1828 | + $selections = (array) get_option($value['id']); |
|
| 1829 | 1829 | ?> |
| 1830 | 1830 | <tr valign="top"> |
| 1831 | 1831 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
@@ -1835,7 +1835,7 @@ discard block |
||
| 1835 | 1835 | title="Country" class="chosen_select"> |
| 1836 | 1836 | <?php |
| 1837 | 1837 | if ($countries) foreach ($countries as $key => $val) : |
| 1838 | - echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 1838 | + echo '<option value="'.$key.'" '.selected(in_array($key, $selections), true, false).'>'.$val.'</option>'; |
|
| 1839 | 1839 | endforeach; |
| 1840 | 1840 | ?> |
| 1841 | 1841 | </select> |
@@ -1847,8 +1847,8 @@ discard block |
||
| 1847 | 1847 | break; |
| 1848 | 1848 | |
| 1849 | 1849 | case 'google_analytics' : |
| 1850 | - $selections = (array)get_option($value['id']); |
|
| 1851 | - if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
|
|
| 1850 | + $selections = (array) get_option($value['id']); |
|
| 1851 | + if (get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret')) {
|
|
| 1852 | 1852 | ?> |
| 1853 | 1853 | <tr valign="top"> |
| 1854 | 1854 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
@@ -1859,20 +1859,20 @@ discard block |
||
| 1859 | 1859 | |
| 1860 | 1860 | $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
| 1861 | 1861 | $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
| 1862 | - $state = "&state=123";//any string |
|
| 1863 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 1862 | + $state = "&state=123"; //any string |
|
| 1863 | + $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback";
|
|
| 1864 | 1864 | $response_type = "&response_type=code"; |
| 1865 | 1865 | $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
| 1866 | 1866 | $access_type = "&access_type=offline"; |
| 1867 | 1867 | $approval_prompt = "&approval_prompt=force"; |
| 1868 | 1868 | |
| 1869 | - $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
| 1869 | + $auth_url = $oAuthURL.$scope.$state.$redirect_uri.$response_type.$client_id.$access_type.$approval_prompt; |
|
| 1870 | 1870 | |
| 1871 | 1871 | |
| 1872 | 1872 | ?> |
| 1873 | 1873 | <script> |
| 1874 | 1874 | function gd_ga_popup() {
|
| 1875 | - var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
|
|
| 1875 | + var win = window.open("<?php echo $auth_url; ?>", "Google Analytics", "");
|
|
| 1876 | 1876 | var pollTimer = window.setInterval(function () {
|
| 1877 | 1877 | if (win.closed !== false) { // !== is required for compatibility with Opera
|
| 1878 | 1878 | window.clearInterval(pollTimer); |
@@ -1894,7 +1894,7 @@ discard block |
||
| 1894 | 1894 | } else {
|
| 1895 | 1895 | ?> |
| 1896 | 1896 | <span class="button-primary" |
| 1897 | - onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
|
|
| 1897 | + onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory'); ?></span>
|
|
| 1898 | 1898 | <?php |
| 1899 | 1899 | } |
| 1900 | 1900 | ?> |
@@ -1965,9 +1965,9 @@ discard block |
||
| 1965 | 1965 | |
| 1966 | 1966 | <?php if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] != '') { ?>
|
| 1967 | 1967 | jQuery('.geodir_option_tabs').removeClass('gd-tab-active');
|
| 1968 | - jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').addClass('gd-tab-active');
|
|
| 1968 | + jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').addClass('gd-tab-active');
|
|
| 1969 | 1969 | jQuery('.gd-content-heading').hide();
|
| 1970 | - jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').show();
|
|
| 1970 | + jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').show();
|
|
| 1971 | 1971 | <?php } ?> |
| 1972 | 1972 | }); |
| 1973 | 1973 | </script> |
@@ -2053,7 +2053,7 @@ discard block |
||
| 2053 | 2053 | wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
| 2054 | 2054 | |
| 2055 | 2055 | if (geodir_get_featured_image($post_id, 'thumbnail')) {
|
| 2056 | - echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
|
|
| 2056 | + echo '<h4>'.__('Featured Image', 'geodirectory').'</h4>';
|
|
| 2057 | 2057 | geodir_show_featured_image($post_id, 'thumbnail'); |
| 2058 | 2058 | } |
| 2059 | 2059 | |
@@ -2064,13 +2064,13 @@ discard block |
||
| 2064 | 2064 | |
| 2065 | 2065 | <h5 class="form_title"> |
| 2066 | 2066 | <?php if ($image_limit != 0 && $image_limit == 1) {
|
| 2067 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 2067 | + echo '<br /><small>('.__('You can upload', 'geodirectory').' '.$image_limit.' '.__('image with this package', 'geodirectory').')</small>';
|
|
| 2068 | 2068 | } ?> |
| 2069 | 2069 | <?php if ($image_limit != 0 && $image_limit > 1) {
|
| 2070 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 2070 | + echo '<br /><small>('.__('You can upload', 'geodirectory').' '.$image_limit.' '.__('images with this package', 'geodirectory').')</small>';
|
|
| 2071 | 2071 | } ?> |
| 2072 | 2072 | <?php if ($image_limit == 0) {
|
| 2073 | - echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 2073 | + echo '<br /><small>('.__('You can upload unlimited images with this package', 'geodirectory').')</small>';
|
|
| 2074 | 2074 | } ?> |
| 2075 | 2075 | </h5> |
| 2076 | 2076 | |
@@ -2109,10 +2109,10 @@ discard block |
||
| 2109 | 2109 | <div |
| 2110 | 2110 | class="plupload-upload-uic hide-if-no-js <?php if ($multiple): ?>plupload-upload-uic-multiple<?php endif; ?>" |
| 2111 | 2111 | id="<?php echo $id; ?>plupload-upload-ui"> |
| 2112 | - <h4><?php _e('Drop files to upload', 'geodirectory');?></h4>
|
|
| 2112 | + <h4><?php _e('Drop files to upload', 'geodirectory'); ?></h4>
|
|
| 2113 | 2113 | <input id="<?php echo $id; ?>plupload-browse-button" type="button" |
| 2114 | 2114 | value="<?php _e('Select Files', 'geodirectory'); ?>" class="button"/>
|
| 2115 | - <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?>"></span> |
|
| 2115 | + <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id.'pluploadan'); ?>"></span> |
|
| 2116 | 2116 | <?php if ($width && $height): ?> |
| 2117 | 2117 | <span class="plupload-resize"></span> |
| 2118 | 2118 | <span class="plupload-width" id="plupload-width<?php echo $width; ?>"></span> |
@@ -2124,7 +2124,7 @@ discard block |
||
| 2124 | 2124 | id="<?php echo $id; ?>plupload-thumbs" style="border-top:1px solid #ccc; padding-top:10px;"> |
| 2125 | 2125 | </div> |
| 2126 | 2126 | <span |
| 2127 | - id="upload-msg"><?php _e('Please drag & drop the images to rearrange the order', 'geodirectory');?></span>
|
|
| 2127 | + id="upload-msg"><?php _e('Please drag & drop the images to rearrange the order', 'geodirectory'); ?></span>
|
|
| 2128 | 2128 | <span id="<?php echo $id; ?>upload-error" style="display:none"></span> |
| 2129 | 2129 | </div> |
| 2130 | 2130 | |
@@ -2334,9 +2334,9 @@ discard block |
||
| 2334 | 2334 | $plugin = 'avada-nag'; |
| 2335 | 2335 | $timestamp = 'avada-nag1234'; |
| 2336 | 2336 | $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');
|
| 2337 | - echo '<div id="' . $timestamp . '" class="error">'; |
|
| 2338 | - echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
| 2339 | - echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 2337 | + echo '<div id="'.$timestamp.'" class="error">'; |
|
| 2338 | + echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\''.$plugin.'\',\''.$timestamp.'\');" ><i class="fa fa-times"></i></span>'; |
|
| 2339 | + echo "<img class='gd-icon-noti' src='".plugin_dir_url('')."geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 2340 | 2340 | echo "<p>$message</p>"; |
| 2341 | 2341 | echo "</div>"; |
| 2342 | 2342 | |
@@ -2469,7 +2469,7 @@ discard block |
||
| 2469 | 2469 | |
| 2470 | 2470 | // Don't allow same slug url for listing and location |
| 2471 | 2471 | if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
|
| 2472 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
|
|
| 2472 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$active_tab.'&msg=fail&gderr=21');
|
|
| 2473 | 2473 | wp_redirect($redirect_url); |
| 2474 | 2474 | exit; |
| 2475 | 2475 | } |
@@ -2481,7 +2481,7 @@ discard block |
||
| 2481 | 2481 | $default_language = $sitepress->get_default_language(); |
| 2482 | 2482 | |
| 2483 | 2483 | if ($current_language != 'all' && $current_language != $default_language) {
|
| 2484 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab);
|
|
| 2484 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$active_tab);
|
|
| 2485 | 2485 | wp_redirect($redirect_url); |
| 2486 | 2486 | exit; |
| 2487 | 2487 | } |
@@ -2502,11 +2502,11 @@ discard block |
||
| 2502 | 2502 | function geodir_hide_admin_preview_button() {
|
| 2503 | 2503 | global $post_type; |
| 2504 | 2504 | $post_types = geodir_get_posttypes(); |
| 2505 | - if(in_array($post_type, $post_types)) |
|
| 2505 | + if (in_array($post_type, $post_types)) |
|
| 2506 | 2506 | echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
| 2507 | 2507 | } |
| 2508 | -add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' ); |
|
| 2509 | -add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' ); |
|
| 2508 | +add_action('admin_head-post-new.php', 'geodir_hide_admin_preview_button');
|
|
| 2509 | +add_action('admin_head-post.php', 'geodir_hide_admin_preview_button');
|
|
| 2510 | 2510 | |
| 2511 | 2511 | /** |
| 2512 | 2512 | * Add the tab in left sidebar menu fro import & export page. |
@@ -2516,8 +2516,8 @@ discard block |
||
| 2516 | 2516 | * |
| 2517 | 2517 | * @return array Array of tab data. |
| 2518 | 2518 | */ |
| 2519 | -function geodir_import_export_tab( $tabs ) {
|
|
| 2520 | - $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
|
| 2519 | +function geodir_import_export_tab($tabs) {
|
|
| 2520 | + $tabs['import_export'] = array('label' => __('Import & Export', 'geodirectory'));
|
|
| 2521 | 2521 | return $tabs; |
| 2522 | 2522 | } |
| 2523 | 2523 | |
@@ -2531,8 +2531,8 @@ discard block |
||
| 2531 | 2531 | * @return string Html content. |
| 2532 | 2532 | */ |
| 2533 | 2533 | function geodir_import_export_page() {
|
| 2534 | - $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
|
| 2535 | - $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
|
| 2534 | + $nonce = wp_create_nonce('geodir_import_export_nonce');
|
|
| 2535 | + $gd_cats_sample_csv = geodir_plugin_url().'/geodirectory-assets/gd_sample_categories.csv'; |
|
| 2536 | 2536 | /** |
| 2537 | 2537 | * Filter sample category data csv file url. |
| 2538 | 2538 | * |
@@ -2541,9 +2541,9 @@ discard block |
||
| 2541 | 2541 | * |
| 2542 | 2542 | * @param string $gd_cats_sample_csv Sample category data csv file url. |
| 2543 | 2543 | */ |
| 2544 | - $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
|
| 2544 | + $gd_cats_sample_csv = apply_filters('geodir_export_cats_sample_csv', $gd_cats_sample_csv);
|
|
| 2545 | 2545 | |
| 2546 | - $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
|
| 2546 | + $gd_posts_sample_csv = geodir_plugin_url().'/geodirectory-assets/place_listing.csv'; |
|
| 2547 | 2547 | /** |
| 2548 | 2548 | * Filter sample post data csv file url. |
| 2549 | 2549 | * |
@@ -2552,15 +2552,15 @@ discard block |
||
| 2552 | 2552 | * |
| 2553 | 2553 | * @param string $gd_posts_sample_csv Sample post data csv file url. |
| 2554 | 2554 | */ |
| 2555 | - $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 2555 | + $gd_posts_sample_csv = apply_filters('geodir_export_posts_sample_csv', $gd_posts_sample_csv);
|
|
| 2556 | 2556 | |
| 2557 | - $gd_posttypes = geodir_get_posttypes( 'array' ); |
|
| 2557 | + $gd_posttypes = geodir_get_posttypes('array');
|
|
| 2558 | 2558 | |
| 2559 | 2559 | $gd_posttypes_option = ''; |
| 2560 | - foreach ( $gd_posttypes as $gd_posttype => $row ) {
|
|
| 2561 | - $gd_posttypes_option .= '<option value="' . $gd_posttype . '" data-cats="' . (int)geodir_get_terms_count( $gd_posttype ) . '" data-posts="' . (int)geodir_get_posts_count( $gd_posttype ) . '">' . __( $row['labels']['name'], 'geodirectory' ) . '</option>'; |
|
| 2560 | + foreach ($gd_posttypes as $gd_posttype => $row) {
|
|
| 2561 | + $gd_posttypes_option .= '<option value="'.$gd_posttype.'" data-cats="'.(int) geodir_get_terms_count($gd_posttype).'" data-posts="'.(int) geodir_get_posts_count($gd_posttype).'">'.__($row['labels']['name'], 'geodirectory').'</option>'; |
|
| 2562 | 2562 | } |
| 2563 | - wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 2563 | + wp_enqueue_script('jquery-ui-progressbar');
|
|
| 2564 | 2564 | |
| 2565 | 2565 | $gd_chunksize_options = array(); |
| 2566 | 2566 | $gd_chunksize_options[100] = 100; |
@@ -2582,49 +2582,49 @@ discard block |
||
| 2582 | 2582 | * |
| 2583 | 2583 | * @param string $gd_chunksize_options Entries options. |
| 2584 | 2584 | */ |
| 2585 | - $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 2585 | + $gd_chunksize_options = apply_filters('geodir_export_csv_chunksize_options', $gd_chunksize_options);
|
|
| 2586 | 2586 | |
| 2587 | 2587 | $gd_chunksize_option = ''; |
| 2588 | 2588 | foreach ($gd_chunksize_options as $value => $title) {
|
| 2589 | - $gd_chunksize_option .= '<option value="' . $value . '" ' . selected($value, 5000, false) . '>' . $title . '</option>'; |
|
| 2589 | + $gd_chunksize_option .= '<option value="'.$value.'" '.selected($value, 5000, false).'>'.$title.'</option>'; |
|
| 2590 | 2590 | } |
| 2591 | 2591 | |
| 2592 | 2592 | $uploads = wp_upload_dir(); |
| 2593 | 2593 | ?> |
| 2594 | 2594 | </form> |
| 2595 | 2595 | <div class="inner_content_tab_main gd-import-export"> |
| 2596 | - <h3><?php _e( 'GD Import & Export CSV', 'geodirectory' ) ;?></h3> |
|
| 2597 | - <span class="description"><?php _e( 'Import & export csv for GD listings & categories.', 'geodirectory' ) ;?></span> |
|
| 2596 | + <h3><?php _e('GD Import & Export CSV', 'geodirectory'); ?></h3>
|
|
| 2597 | + <span class="description"><?php _e('Import & export csv for GD listings & categories.', 'geodirectory'); ?></span>
|
|
| 2598 | 2598 | <div class="gd-content-heading"> |
| 2599 | 2599 | |
| 2600 | 2600 | <?php |
| 2601 | 2601 | ini_set('max_execution_time', 999999);
|
| 2602 | - $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 2602 | + $ini_max_execution_time_check = @ini_get('max_execution_time');
|
|
| 2603 | 2603 | ini_restore('max_execution_time');
|
| 2604 | 2604 | |
| 2605 | - if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 2605 | + if ($ini_max_execution_time_check != 999999) { // only show these setting to the user if we can't change the ini setting
|
|
| 2606 | 2606 | ?> |
| 2607 | 2607 | <div id="gd_ie_reqs" class="metabox-holder"> |
| 2608 | 2608 | <div class="meta-box-sortables ui-sortable"> |
| 2609 | 2609 | <div class="postbox"> |
| 2610 | - <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'PHP Requirements for GD Import & Export CSV', 'geodirectory' );?></span></h3> |
|
| 2610 | + <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('PHP Requirements for GD Import & Export CSV', 'geodirectory'); ?></span></h3>
|
|
| 2611 | 2611 | <div class="inside"> |
| 2612 | - <span class="description"><?php echo __( 'Note: In case GD import & export csv not working for larger data then please check and configure following php settings.', 'geodirectory' );?></span> |
|
| 2612 | + <span class="description"><?php echo __('Note: In case GD import & export csv not working for larger data then please check and configure following php settings.', 'geodirectory'); ?></span>
|
|
| 2613 | 2613 | <table class="form-table"> |
| 2614 | 2614 | <thead> |
| 2615 | 2615 | <tr> |
| 2616 | - <th><?php _e( 'PHP Settings', 'geodirectory' );?></th><th><?php _e( 'Current Value', 'geodirectory' );?></th><th><?php _e( 'Recommended Value', 'geodirectory' );?></th> |
|
| 2616 | + <th><?php _e('PHP Settings', 'geodirectory'); ?></th><th><?php _e('Current Value', 'geodirectory'); ?></th><th><?php _e('Recommended Value', 'geodirectory'); ?></th>
|
|
| 2617 | 2617 | </tr> |
| 2618 | 2618 | </thead> |
| 2619 | 2619 | <tbody> |
| 2620 | 2620 | <tr> |
| 2621 | - <td>max_input_time</td><td><?php echo @ini_get( 'max_input_time' );?></td><td>3000</td> |
|
| 2621 | + <td>max_input_time</td><td><?php echo @ini_get('max_input_time'); ?></td><td>3000</td>
|
|
| 2622 | 2622 | </tr> |
| 2623 | 2623 | <tr> |
| 2624 | - <td>max_execution_time</td><td><?php echo @ini_get( 'max_execution_time' );?></td><td>3000</td> |
|
| 2624 | + <td>max_execution_time</td><td><?php echo @ini_get('max_execution_time'); ?></td><td>3000</td>
|
|
| 2625 | 2625 | </tr> |
| 2626 | 2626 | <tr> |
| 2627 | - <td>memory_limit</td><td><?php echo @ini_get( 'memory_limit' );?></td><td>256M</td> |
|
| 2627 | + <td>memory_limit</td><td><?php echo @ini_get('memory_limit'); ?></td><td>256M</td>
|
|
| 2628 | 2628 | </tr> |
| 2629 | 2629 | </tbody> |
| 2630 | 2630 | </table> |
@@ -2636,21 +2636,21 @@ discard block |
||
| 2636 | 2636 | <div id="gd_ie_imposts" class="metabox-holder"> |
| 2637 | 2637 | <div class="meta-box-sortables ui-sortable"> |
| 2638 | 2638 | <div id="gd_ie_im_posts" class="postbox gd-hndle-pbox"> |
| 2639 | - <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Listings: Import CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button> |
|
| 2640 | - <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Import CSV', 'geodirectory' );?></span></h3> |
|
| 2639 | + <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Listings: Import CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
|
|
| 2640 | + <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Listings: Import CSV', 'geodirectory'); ?></span></h3>
|
|
| 2641 | 2641 | <div class="inside"> |
| 2642 | 2642 | <table class="form-table"> |
| 2643 | 2643 | <tbody> |
| 2644 | 2644 | <tr> |
| 2645 | 2645 | <td class="gd-imex-box"> |
| 2646 | 2646 | <div class="gd-im-choices"> |
| 2647 | - <p><input type="radio" value="update" name="gd_im_choicepost" id="gd_im_pchoice_u" /><label for="gd_im_pchoice_u"><?php _e( 'Update listing if post with post_id already exists.', 'geodirectory' );?></label></p> |
|
| 2648 | - <p><input type="radio" checked="checked" value="skip" name="gd_im_choicepost" id="gd_im_pchoice_s" /><label for="gd_im_pchoice_s"><?php _e( 'Ignore listing if post with post_id already exists.', 'geodirectory' );?></label></p> |
|
| 2647 | + <p><input type="radio" value="update" name="gd_im_choicepost" id="gd_im_pchoice_u" /><label for="gd_im_pchoice_u"><?php _e('Update listing if post with post_id already exists.', 'geodirectory'); ?></label></p>
|
|
| 2648 | + <p><input type="radio" checked="checked" value="skip" name="gd_im_choicepost" id="gd_im_pchoice_s" /><label for="gd_im_pchoice_s"><?php _e('Ignore listing if post with post_id already exists.', 'geodirectory'); ?></label></p>
|
|
| 2649 | 2649 | </div> |
| 2650 | 2650 | <div class="plupload-upload-uic hide-if-no-js" id="gd_im_postplupload-upload-ui"> |
| 2651 | 2651 | <input type="text" readonly="readonly" name="gd_im_post_file" class="gd-imex-file gd_im_post_file" id="gd_im_post" onclick="jQuery('#gd_im_postplupload-browse-button').trigger('click');" />
|
| 2652 | - <input id="gd_im_postplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-pupload button-primary" /><input type="button" value="<?php echo esc_attr( __( 'Download Sample CSV', 'geodirectory' ) );?>" class="button-secondary" name="gd_ie_imposts_sample" id="gd_ie_imposts_sample"> |
|
| 2653 | - <input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv;?>" /> |
|
| 2652 | + <input id="gd_im_postplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-pupload button-primary" /><input type="button" value="<?php echo esc_attr(__('Download Sample CSV', 'geodirectory')); ?>" class="button-secondary" name="gd_ie_imposts_sample" id="gd_ie_imposts_sample">
|
|
| 2653 | + <input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv; ?>" /> |
|
| 2654 | 2654 | <?php |
| 2655 | 2655 | /** |
| 2656 | 2656 | * Called just after the sample CSV download link. |
@@ -2659,7 +2659,7 @@ discard block |
||
| 2659 | 2659 | */ |
| 2660 | 2660 | do_action('geodir_sample_csv_download_link');
|
| 2661 | 2661 | ?> |
| 2662 | - <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_postpluploadan' ); ?>"></span> |
|
| 2662 | + <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_postpluploadan'); ?>"></span>
|
|
| 2663 | 2663 | <div class="filelist"></div> |
| 2664 | 2664 | </div> |
| 2665 | 2665 | <span id="gd_im_catupload-error" style="display:none"></span> |
@@ -2677,7 +2677,7 @@ discard block |
||
| 2677 | 2677 | <input type="hidden" id="gd_terminateaction" value="continue"/> |
| 2678 | 2678 | </div> |
| 2679 | 2679 | <div class="gd-import-progress" id="gd-import-progress" style="display:none"> |
| 2680 | - <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
|
|
| 2680 | + <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
|
|
| 2681 | 2681 | id="gd-import-done">0</font> / <font id="gd-import-total">0</font> ( <font |
| 2682 | 2682 | id="gd-import-perc">0%</font> ) |
| 2683 | 2683 | <div class="gd-fileprogress"></div> |
@@ -2689,10 +2689,10 @@ discard block |
||
| 2689 | 2689 | <div class="gd-imex-btns" style="display:none;"> |
| 2690 | 2690 | <input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/> |
| 2691 | 2691 | <input onclick="gd_imex_PrepareImport(this, 'post')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" /> |
| 2692 | - <input onclick="gd_imex_ContinueImport(this, 'post')" type="button" value="<?php _e( "Continue Import Data", 'geodirectory' );?>" id="gd_continue_data" class="button-primary" style="display:none"/> |
|
| 2693 | - <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory');?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'post')"/>
|
|
| 2692 | + <input onclick="gd_imex_ContinueImport(this, 'post')" type="button" value="<?php _e("Continue Import Data", 'geodirectory'); ?>" id="gd_continue_data" class="button-primary" style="display:none"/>
|
|
| 2693 | + <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory'); ?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'post')"/>
|
|
| 2694 | 2694 | <div id="gd_process_data" style="display:none"> |
| 2695 | - <span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
|
|
| 2695 | + <span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
|
|
| 2696 | 2696 | </div> |
| 2697 | 2697 | </div> |
| 2698 | 2698 | </td> |
@@ -2706,26 +2706,26 @@ discard block |
||
| 2706 | 2706 | <div id="gd_ie_excategs" class="metabox-holder"> |
| 2707 | 2707 | <div class="meta-box-sortables ui-sortable"> |
| 2708 | 2708 | <div id="gd_ie_ex_posts" class="postbox gd-hndle-pbox"> |
| 2709 | - <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - Listings: Export CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button> |
|
| 2710 | - <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Export CSV', 'geodirectory' );?></span></h3> |
|
| 2709 | + <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - Listings: Export CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
|
|
| 2710 | + <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Listings: Export CSV', 'geodirectory'); ?></span></h3>
|
|
| 2711 | 2711 | <div class="inside"> |
| 2712 | 2712 | <table class="form-table"> |
| 2713 | 2713 | <tbody> |
| 2714 | 2714 | <tr> |
| 2715 | 2715 | <td class="fld"><label for="gd_post_type"> |
| 2716 | - <?php _e( 'Post Type:', 'geodirectory' );?> |
|
| 2716 | + <?php _e('Post Type:', 'geodirectory'); ?>
|
|
| 2717 | 2717 | </label></td> |
| 2718 | 2718 | <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"> |
| 2719 | - <?php echo $gd_posttypes_option;?> |
|
| 2719 | + <?php echo $gd_posttypes_option; ?> |
|
| 2720 | 2720 | </select></td> |
| 2721 | 2721 | </tr> |
| 2722 | 2722 | <tr> |
| 2723 | - <td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td> |
|
| 2724 | - <td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option;?></select><span class="description"><?php _e( 'Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory' );?></span></td> |
|
| 2723 | + <td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
|
|
| 2724 | + <td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option; ?></select><span class="description"><?php _e('Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory'); ?></span></td>
|
|
| 2725 | 2725 | </tr> |
| 2726 | 2726 | <tr> |
| 2727 | 2727 | <td class="fld" style="vertical-align:top"><label> |
| 2728 | - <?php _e( 'Progress:', 'geodirectory' );?> |
|
| 2728 | + <?php _e('Progress:', 'geodirectory'); ?>
|
|
| 2729 | 2729 | </label></td> |
| 2730 | 2730 | <td><div id='gd_progressbar_box'> |
| 2731 | 2731 | <div id="gd_progressbar" class="gd_progressbar"> |
@@ -2733,13 +2733,13 @@ discard block |
||
| 2733 | 2733 | </div> |
| 2734 | 2734 | </div> |
| 2735 | 2735 | <p style="display:inline-block"> |
| 2736 | - <?php _e( 'Elapsed Time:', 'geodirectory' );?> |
|
| 2736 | + <?php _e('Elapsed Time:', 'geodirectory'); ?>
|
|
| 2737 | 2737 | </p> |
| 2738 | 2738 | |
| 2739 | 2739 | <p id="gd_timer" class="gd_timer">00:00:00</p></td> |
| 2740 | 2740 | </tr> |
| 2741 | 2741 | <tr class="gd-ie-actions"> |
| 2742 | - <td style="vertical-align:top"><input type="submit" value="<?php echo esc_attr( __( 'Export CSV', 'geodirectory' ) );?>" class="button-primary" name="gd_ie_exposts_submit" id="gd_ie_exposts_submit"> |
|
| 2742 | + <td style="vertical-align:top"><input type="submit" value="<?php echo esc_attr(__('Export CSV', 'geodirectory')); ?>" class="button-primary" name="gd_ie_exposts_submit" id="gd_ie_exposts_submit">
|
|
| 2743 | 2743 | </td> |
| 2744 | 2744 | <td id="gd_ie_ex_files" class="gd-ie-files"></td> |
| 2745 | 2745 | </tr> |
@@ -2752,21 +2752,21 @@ discard block |
||
| 2752 | 2752 | <div id="gd_ie_imcategs" class="metabox-holder"> |
| 2753 | 2753 | <div class="meta-box-sortables ui-sortable"> |
| 2754 | 2754 | <div id="gd_ie_imcats" class="postbox gd-hndle-pbox"> |
| 2755 | - <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Categories: Import CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button> |
|
| 2756 | - <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Import CSV', 'geodirectory' );?></span></h3> |
|
| 2755 | + <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Categories: Import CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
|
|
| 2756 | + <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Categories: Import CSV', 'geodirectory'); ?></span></h3>
|
|
| 2757 | 2757 | <div class="inside"> |
| 2758 | 2758 | <table class="form-table"> |
| 2759 | 2759 | <tbody> |
| 2760 | 2760 | <tr> |
| 2761 | 2761 | <td class="gd-imex-box"> |
| 2762 | 2762 | <div class="gd-im-choices"> |
| 2763 | - <p><input type="radio" value="update" name="gd_im_choicecat" id="gd_im_cchoice_u" /><label for="gd_im_cchoice_u"><?php _e( 'Update item if item with cat_id/cat_slug already exists.', 'geodirectory' );?></label></p> |
|
| 2764 | - <p><input type="radio" checked="checked" value="skip" name="gd_im_choicecat" id="gd_im_cchoice_s" /><label for="gd_im_cchoice_s"><?php _e( 'Ignore item if item with cat_id/cat_slug already exists.', 'geodirectory' );?></label></p> |
|
| 2763 | + <p><input type="radio" value="update" name="gd_im_choicecat" id="gd_im_cchoice_u" /><label for="gd_im_cchoice_u"><?php _e('Update item if item with cat_id/cat_slug already exists.', 'geodirectory'); ?></label></p>
|
|
| 2764 | + <p><input type="radio" checked="checked" value="skip" name="gd_im_choicecat" id="gd_im_cchoice_s" /><label for="gd_im_cchoice_s"><?php _e('Ignore item if item with cat_id/cat_slug already exists.', 'geodirectory'); ?></label></p>
|
|
| 2765 | 2765 | </div> |
| 2766 | 2766 | <div class="plupload-upload-uic hide-if-no-js" id="gd_im_catplupload-upload-ui"> |
| 2767 | 2767 | <input type="text" readonly="readonly" name="gd_im_cat_file" class="gd-imex-file gd_im_cat_file" id="gd_im_cat" onclick="jQuery('#gd_im_catplupload-browse-button').trigger('click');" />
|
| 2768 | - <input id="gd_im_catplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-cupload button-primary" /><input type="button" value="<?php echo esc_attr( __( 'Download Sample CSV', 'geodirectory' ) );?>" class="button-secondary" name="gd_ie_imcats_sample" id="gd_ie_imcats_sample"> |
|
| 2769 | - <input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv;?>" /> |
|
| 2768 | + <input id="gd_im_catplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-cupload button-primary" /><input type="button" value="<?php echo esc_attr(__('Download Sample CSV', 'geodirectory')); ?>" class="button-secondary" name="gd_ie_imcats_sample" id="gd_ie_imcats_sample">
|
|
| 2769 | + <input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv; ?>" /> |
|
| 2770 | 2770 | <?php |
| 2771 | 2771 | /** |
| 2772 | 2772 | * Called just after the sample CSV download link. |
@@ -2776,7 +2776,7 @@ discard block |
||
| 2776 | 2776 | */ |
| 2777 | 2777 | do_action('geodir_sample_cats_csv_download_link');
|
| 2778 | 2778 | ?> |
| 2779 | - <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_catpluploadan' ); ?>"></span> |
|
| 2779 | + <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_catpluploadan'); ?>"></span>
|
|
| 2780 | 2780 | <div class="filelist"></div> |
| 2781 | 2781 | </div> |
| 2782 | 2782 | <span id="gd_im_catupload-error" style="display:none"></span> |
@@ -2793,7 +2793,7 @@ discard block |
||
| 2793 | 2793 | <input type="hidden" id="gd_terminateaction" value="continue"/> |
| 2794 | 2794 | </div> |
| 2795 | 2795 | <div class="gd-import-progress" id="gd-import-progress" style="display:none"> |
| 2796 | - <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
|
|
| 2796 | + <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
|
|
| 2797 | 2797 | id="gd-import-done">0</font> / <font id="gd-import-total">0</font> ( <font |
| 2798 | 2798 | id="gd-import-perc">0%</font> ) |
| 2799 | 2799 | <div class="gd-fileprogress"></div> |
@@ -2805,10 +2805,10 @@ discard block |
||
| 2805 | 2805 | <div class="gd-imex-btns" style="display:none;"> |
| 2806 | 2806 | <input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/> |
| 2807 | 2807 | <input onclick="gd_imex_PrepareImport(this, 'cat')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" /> |
| 2808 | - <input onclick="gd_imex_ContinueImport(this, 'cat')" type="button" value="<?php _e( "Continue Import Data", 'geodirectory' );?>" id="gd_continue_data" class="button-primary" style="display:none"/> |
|
| 2809 | - <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory');?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'cat')"/>
|
|
| 2808 | + <input onclick="gd_imex_ContinueImport(this, 'cat')" type="button" value="<?php _e("Continue Import Data", 'geodirectory'); ?>" id="gd_continue_data" class="button-primary" style="display:none"/>
|
|
| 2809 | + <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory'); ?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'cat')"/>
|
|
| 2810 | 2810 | <div id="gd_process_data" style="display:none"> |
| 2811 | - <span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
|
|
| 2811 | + <span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
|
|
| 2812 | 2812 | </div> |
| 2813 | 2813 | </div> |
| 2814 | 2814 | </td> |
@@ -2822,26 +2822,26 @@ discard block |
||
| 2822 | 2822 | <div id="gd_ie_excategs" class="metabox-holder"> |
| 2823 | 2823 | <div class="meta-box-sortables ui-sortable"> |
| 2824 | 2824 | <div id="gd_ie_ex_cats" class="postbox gd-hndle-pbox"> |
| 2825 | - <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Categories: Export CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button> |
|
| 2826 | - <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Export CSV', 'geodirectory' );?></span></h3> |
|
| 2825 | + <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Categories: Export CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
|
|
| 2826 | + <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Categories: Export CSV', 'geodirectory'); ?></span></h3>
|
|
| 2827 | 2827 | <div class="inside"> |
| 2828 | 2828 | <table class="form-table"> |
| 2829 | 2829 | <tbody> |
| 2830 | 2830 | <tr> |
| 2831 | - <td class="fld"><label for="gd_post_type"><?php _e( 'Post Type:', 'geodirectory' );?></label></td> |
|
| 2832 | - <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option;?></select></td> |
|
| 2831 | + <td class="fld"><label for="gd_post_type"><?php _e('Post Type:', 'geodirectory'); ?></label></td>
|
|
| 2832 | + <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option; ?></select></td> |
|
| 2833 | 2833 | </tr> |
| 2834 | 2834 | <tr> |
| 2835 | - <td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td> |
|
| 2836 | - <td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option;?></select><span class="description"><?php _e( 'Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory' );?></span></td> |
|
| 2835 | + <td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
|
|
| 2836 | + <td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option; ?></select><span class="description"><?php _e('Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory'); ?></span></td>
|
|
| 2837 | 2837 | </tr> |
| 2838 | 2838 | <tr> |
| 2839 | - <td class="fld" style="vertical-align:top"><label><?php _e( 'Progress:', 'geodirectory' );?></label></td> |
|
| 2840 | - <td><div id='gd_progressbar_box'><div id="gd_progressbar" class="gd_progressbar"><div class="gd-progress-label"></div></div></div><p style="display:inline-block"><?php _e( 'Elapsed Time:', 'geodirectory' );?></p> <p id="gd_timer" class="gd_timer">00:00:00</p></td> |
|
| 2839 | + <td class="fld" style="vertical-align:top"><label><?php _e('Progress:', 'geodirectory'); ?></label></td>
|
|
| 2840 | + <td><div id='gd_progressbar_box'><div id="gd_progressbar" class="gd_progressbar"><div class="gd-progress-label"></div></div></div><p style="display:inline-block"><?php _e('Elapsed Time:', 'geodirectory'); ?></p> <p id="gd_timer" class="gd_timer">00:00:00</p></td>
|
|
| 2841 | 2841 | </tr> |
| 2842 | 2842 | <tr class="gd-ie-actions"> |
| 2843 | 2843 | <td style="vertical-align:top"> |
| 2844 | - <input type="submit" value="<?php echo esc_attr( __( 'Export CSV', 'geodirectory' ) );?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit"> |
|
| 2844 | + <input type="submit" value="<?php echo esc_attr(__('Export CSV', 'geodirectory')); ?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
|
|
| 2845 | 2845 | </td> |
| 2846 | 2846 | <td id="gd_ie_ex_files" class="gd-ie-files"></td> |
| 2847 | 2847 | </tr> |
@@ -2863,7 +2863,7 @@ discard block |
||
| 2863 | 2863 | * @param array $gd_chunksize_options File chunk size options. |
| 2864 | 2864 | * @param string $nonce Wordpress security token for GD import & export. |
| 2865 | 2865 | */ |
| 2866 | - do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
|
| 2866 | + do_action('geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce);
|
|
| 2867 | 2867 | ?> |
| 2868 | 2868 | </div> |
| 2869 | 2869 | </div> |
@@ -2882,7 +2882,7 @@ discard block |
||
| 2882 | 2882 | jQuery.ajax({
|
| 2883 | 2883 | url: ajaxurl, |
| 2884 | 2884 | type: "POST", |
| 2885 | - data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce;?>', |
|
| 2885 | + data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce; ?>', |
|
| 2886 | 2886 | dataType: 'json', |
| 2887 | 2887 | cache: false, |
| 2888 | 2888 | success: function(data) {
|
@@ -2934,7 +2934,7 @@ discard block |
||
| 2934 | 2934 | |
| 2935 | 2935 | jQuery(cont).find('.filelist .file').remove();
|
| 2936 | 2936 | |
| 2937 | - jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr( PLZ_SELECT_CSV_FILE );?></p>");
|
|
| 2937 | + jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr(PLZ_SELECT_CSV_FILE); ?></p>");
|
|
| 2938 | 2938 | jQuery('#gd-import-msg', cont).show();
|
| 2939 | 2939 | |
| 2940 | 2940 | return false; |
@@ -2993,7 +2993,7 @@ discard block |
||
| 2993 | 2993 | jQuery.ajax({
|
| 2994 | 2994 | url: ajaxurl, |
| 2995 | 2995 | type: "POST", |
| 2996 | - data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce;?>', |
|
| 2996 | + data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce; ?>', |
|
| 2997 | 2997 | dataType : 'json', |
| 2998 | 2998 | cache: false, |
| 2999 | 2999 | success: function (data) {
|
@@ -3182,27 +3182,27 @@ discard block |
||
| 3182 | 3182 | |
| 3183 | 3183 | var gdMsg = '<p></p>'; |
| 3184 | 3184 | if ( processed > 0 ) {
|
| 3185 | - var msgParse = '<p><?php echo addslashes( sprintf( __( 'Total %s item(s) found.', 'geodirectory' ), '%s' ) );?></p>'; |
|
| 3185 | + var msgParse = '<p><?php echo addslashes(sprintf(__('Total %s item(s) found.', 'geodirectory'), '%s')); ?></p>';
|
|
| 3186 | 3186 | msgParse = msgParse.replace("%s", processed);
|
| 3187 | 3187 | gdMsg += msgParse; |
| 3188 | 3188 | } |
| 3189 | 3189 | |
| 3190 | 3190 | if ( updated > 0 ) {
|
| 3191 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) updated.', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 3191 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) updated.', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 3192 | 3192 | msgParse = msgParse.replace("%s", updated);
|
| 3193 | 3193 | msgParse = msgParse.replace("%d", processed);
|
| 3194 | 3194 | gdMsg += msgParse; |
| 3195 | 3195 | } |
| 3196 | 3196 | |
| 3197 | 3197 | if ( created > 0 ) {
|
| 3198 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) added.', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 3198 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) added.', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 3199 | 3199 | msgParse = msgParse.replace("%s", created);
|
| 3200 | 3200 | msgParse = msgParse.replace("%d", processed);
|
| 3201 | 3201 | gdMsg += msgParse; |
| 3202 | 3202 | } |
| 3203 | 3203 | |
| 3204 | 3204 | if ( skipped > 0 ) {
|
| 3205 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) ignored due to already exists.', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 3205 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) ignored due to already exists.', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 3206 | 3206 | msgParse = msgParse.replace("%s", skipped);
|
| 3207 | 3207 | msgParse = msgParse.replace("%d", processed);
|
| 3208 | 3208 | gdMsg += msgParse; |
@@ -3212,17 +3212,17 @@ discard block |
||
| 3212 | 3212 | if (type=='loc') {
|
| 3213 | 3213 | invalid_addr = invalid; |
| 3214 | 3214 | } |
| 3215 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 3215 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 3216 | 3216 | msgParse = msgParse.replace("%s", invalid_addr);
|
| 3217 | 3217 | msgParse = msgParse.replace("%d", total);
|
| 3218 | 3218 | gdMsg += msgParse; |
| 3219 | 3219 | } |
| 3220 | 3220 | |
| 3221 | 3221 | if (invalid > 0 && type!='loc') {
|
| 3222 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to blank title/invalid post type/invalid characters used in data.', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 3222 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to blank title/invalid post type/invalid characters used in data.', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 3223 | 3223 | |
| 3224 | 3224 | if (type=='hood') {
|
| 3225 | - msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 3225 | + msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 3226 | 3226 | } |
| 3227 | 3227 | msgParse = msgParse.replace("%s", invalid);
|
| 3228 | 3228 | msgParse = msgParse.replace("%d", total);
|
@@ -3230,7 +3230,7 @@ discard block |
||
| 3230 | 3230 | } |
| 3231 | 3231 | |
| 3232 | 3232 | if (images > 0) {
|
| 3233 | - gdMsg += '<p><?php echo addslashes( sprintf( CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'] ) );?></p>'; |
|
| 3233 | + gdMsg += '<p><?php echo addslashes(sprintf(CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'])); ?></p>'; |
|
| 3234 | 3234 | } |
| 3235 | 3235 | gdMsg += '<p></p>'; |
| 3236 | 3236 | jQuery('#gd-import-msg', cont).find('#message').removeClass('error').addClass('updated').html(gdMsg);
|
@@ -3387,7 +3387,7 @@ discard block |
||
| 3387 | 3387 | |
| 3388 | 3388 | function gd_process_export_posts(el, post_type, total_posts, chunk_size, pages, page) {
|
| 3389 | 3389 | if (page < 2) {
|
| 3390 | - gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>'); |
|
| 3390 | + gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
|
|
| 3391 | 3391 | jQuery(el).find('#gd_timer').text('00:00:01');
|
| 3392 | 3392 | jQuery('#gd_ie_ex_files', el).html('');
|
| 3393 | 3393 | } |
@@ -3395,7 +3395,7 @@ discard block |
||
| 3395 | 3395 | jQuery.ajax({
|
| 3396 | 3396 | url: ajaxurl, |
| 3397 | 3397 | type: "POST", |
| 3398 | - data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page, |
|
| 3398 | + data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page, |
|
| 3399 | 3399 | dataType : 'json', |
| 3400 | 3400 | cache: false, |
| 3401 | 3401 | beforeSend: function (jqXHR, settings) {},
|
@@ -3409,11 +3409,11 @@ discard block |
||
| 3409 | 3409 | } else {
|
| 3410 | 3410 | if (pages < page || pages == page) {
|
| 3411 | 3411 | window.clearInterval(timer_posts); |
| 3412 | - gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
|
|
| 3412 | + gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
|
|
| 3413 | 3413 | } else {
|
| 3414 | 3414 | var percentage = Math.round(((page * chunk_size) / total_posts) * 100); |
| 3415 | 3415 | percentage = percentage > 100 ? 100 : percentage; |
| 3416 | - gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
|
|
| 3416 | + gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
|
|
| 3417 | 3417 | } |
| 3418 | 3418 | if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
|
| 3419 | 3419 | var obj_files = data.files; |
@@ -3443,7 +3443,7 @@ discard block |
||
| 3443 | 3443 | |
| 3444 | 3444 | function gd_process_export_cats(el, post_type, total_cats, chunk_size, pages, page) {
|
| 3445 | 3445 | if (page < 2) {
|
| 3446 | - gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>'); |
|
| 3446 | + gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
|
|
| 3447 | 3447 | jQuery(el).find('#gd_timer').text('00:00:01');
|
| 3448 | 3448 | jQuery('#gd_ie_ex_files', el).html('');
|
| 3449 | 3449 | } |
@@ -3451,7 +3451,7 @@ discard block |
||
| 3451 | 3451 | jQuery.ajax({
|
| 3452 | 3452 | url: ajaxurl, |
| 3453 | 3453 | type: "POST", |
| 3454 | - data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page, |
|
| 3454 | + data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page, |
|
| 3455 | 3455 | dataType : 'json', |
| 3456 | 3456 | cache: false, |
| 3457 | 3457 | beforeSend: function (jqXHR, settings) {},
|
@@ -3465,11 +3465,11 @@ discard block |
||
| 3465 | 3465 | } else {
|
| 3466 | 3466 | if (pages < page || pages == page) {
|
| 3467 | 3467 | window.clearInterval(timer_cats); |
| 3468 | - gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
|
|
| 3468 | + gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
|
|
| 3469 | 3469 | } else {
|
| 3470 | 3470 | var percentage = Math.round(((page * chunk_size) / total_cats) * 100); |
| 3471 | 3471 | percentage = percentage > 100 ? 100 : percentage; |
| 3472 | - gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e( 'Exporting...', 'geodirectory' );?>');
|
|
| 3472 | + gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e('Exporting...', 'geodirectory'); ?>');
|
|
| 3473 | 3473 | } |
| 3474 | 3474 | if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
|
| 3475 | 3475 | var obj_files = data.files; |
@@ -3526,13 +3526,13 @@ discard block |
||
| 3526 | 3526 | function geodir_init_filesystem() |
| 3527 | 3527 | {
|
| 3528 | 3528 | |
| 3529 | - if(!function_exists('get_filesystem_method')){
|
|
| 3529 | + if (!function_exists('get_filesystem_method')) {
|
|
| 3530 | 3530 | require_once(ABSPATH."/wp-admin/includes/file.php"); |
| 3531 | 3531 | } |
| 3532 | 3532 | $access_type = get_filesystem_method(); |
| 3533 | 3533 | if ($access_type === 'direct') {
|
| 3534 | 3534 | /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
| 3535 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3535 | + $creds = request_filesystem_credentials(trailingslashit(site_url()).'wp-admin/', '', false, false, array()); |
|
| 3536 | 3536 | |
| 3537 | 3537 | /* initialize the API */ |
| 3538 | 3538 | if (!WP_Filesystem($creds)) {
|
@@ -3545,7 +3545,7 @@ discard block |
||
| 3545 | 3545 | return $wp_filesystem; |
| 3546 | 3546 | /* do our file manipulations below */ |
| 3547 | 3547 | } elseif (defined('FTP_USER')) {
|
| 3548 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3548 | + $creds = request_filesystem_credentials(trailingslashit(site_url()).'wp-admin/', '', false, false, array()); |
|
| 3549 | 3549 | |
| 3550 | 3550 | /* initialize the API */ |
| 3551 | 3551 | if (!WP_Filesystem($creds)) {
|
@@ -3580,7 +3580,7 @@ discard block |
||
| 3580 | 3580 | * @package GeoDirectory |
| 3581 | 3581 | */ |
| 3582 | 3582 | function geodir_filesystem_notice() |
| 3583 | -{ if ( defined( 'DOING_AJAX' ) ){return;}
|
|
| 3583 | +{ if (defined('DOING_AJAX')) {return; }
|
|
| 3584 | 3584 | $access_type = get_filesystem_method(); |
| 3585 | 3585 | if ($access_type === 'direct') {
|
| 3586 | 3586 | } elseif (!defined('FTP_USER')) {
|
@@ -3617,64 +3617,64 @@ discard block |
||
| 3617 | 3617 | // try to set higher limits for import |
| 3618 | 3618 | $max_input_time = ini_get('max_input_time');
|
| 3619 | 3619 | $max_execution_time = ini_get('max_execution_time');
|
| 3620 | - $memory_limit= ini_get('memory_limit');
|
|
| 3620 | + $memory_limit = ini_get('memory_limit');
|
|
| 3621 | 3621 | |
| 3622 | - if(!$max_input_time || $max_input_time<3000){
|
|
| 3622 | + if (!$max_input_time || $max_input_time < 3000) {
|
|
| 3623 | 3623 | ini_set('max_input_time', 3000);
|
| 3624 | 3624 | } |
| 3625 | 3625 | |
| 3626 | - if(!$max_execution_time || $max_execution_time<3000){
|
|
| 3626 | + if (!$max_execution_time || $max_execution_time < 3000) {
|
|
| 3627 | 3627 | ini_set('max_execution_time', 3000);
|
| 3628 | 3628 | } |
| 3629 | 3629 | |
| 3630 | - if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 3631 | - if(str_replace('M','',$memory_limit)<256){
|
|
| 3630 | + if ($memory_limit && str_replace('M', '', $memory_limit)) {
|
|
| 3631 | + if (str_replace('M', '', $memory_limit) < 256) {
|
|
| 3632 | 3632 | ini_set('memory_limit', '256M');
|
| 3633 | 3633 | } |
| 3634 | 3634 | } |
| 3635 | 3635 | |
| 3636 | 3636 | $json = array(); |
| 3637 | 3637 | |
| 3638 | - if ( !current_user_can( 'manage_options' ) ) {
|
|
| 3639 | - wp_send_json( $json ); |
|
| 3638 | + if (!current_user_can('manage_options')) {
|
|
| 3639 | + wp_send_json($json); |
|
| 3640 | 3640 | } |
| 3641 | 3641 | |
| 3642 | - $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 3643 | - $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 3644 | - $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 3642 | + $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : NULL; |
|
| 3643 | + $nonce = isset($_REQUEST['_nonce']) ? $_REQUEST['_nonce'] : NULL; |
|
| 3644 | + $stat = isset($_REQUEST['_st']) ? $_REQUEST['_st'] : false; |
|
| 3645 | 3645 | |
| 3646 | - if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 3647 | - wp_send_json( $json ); |
|
| 3646 | + if (!wp_verify_nonce($nonce, 'geodir_import_export_nonce')) {
|
|
| 3647 | + wp_send_json($json); |
|
| 3648 | 3648 | } |
| 3649 | 3649 | |
| 3650 | - $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 3651 | - $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 3650 | + $post_type = isset($_REQUEST['_pt']) ? $_REQUEST['_pt'] : NULL; |
|
| 3651 | + $chunk_per_page = isset($_REQUEST['_n']) ? absint($_REQUEST['_n']) : NULL; |
|
| 3652 | 3652 | $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
| 3653 | - $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 3653 | + $chunk_page_no = isset($_REQUEST['_p']) ? absint($_REQUEST['_p']) : 1; |
|
| 3654 | 3654 | |
| 3655 | 3655 | $wp_filesystem = geodir_init_filesystem(); |
| 3656 | 3656 | if (!$wp_filesystem) {
|
| 3657 | - $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 3658 | - wp_send_json( $json ); |
|
| 3657 | + $json['error'] = __('Filesystem ERROR: Could not access filesystem.', 'geodirectory');
|
|
| 3658 | + wp_send_json($json); |
|
| 3659 | 3659 | } |
| 3660 | 3660 | |
| 3661 | 3661 | if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
| 3662 | - $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 3663 | - wp_send_json( $json ); |
|
| 3662 | + $json['error'] = __('Filesystem ERROR: '.$wp_filesystem->errors->get_error_message(), 'geodirectory');
|
|
| 3663 | + wp_send_json($json); |
|
| 3664 | 3664 | } |
| 3665 | 3665 | |
| 3666 | - $csv_file_dir = geodir_path_import_export( false ); |
|
| 3667 | - if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 3668 | - if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 3669 | - $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3670 | - wp_send_json( $json ); |
|
| 3666 | + $csv_file_dir = geodir_path_import_export(false); |
|
| 3667 | + if (!$wp_filesystem->is_dir($csv_file_dir)) {
|
|
| 3668 | + if (!$wp_filesystem->mkdir($csv_file_dir, FS_CHMOD_DIR)) {
|
|
| 3669 | + $json['error'] = __('ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory');
|
|
| 3670 | + wp_send_json($json); |
|
| 3671 | 3671 | } |
| 3672 | 3672 | } |
| 3673 | 3673 | |
| 3674 | 3674 | $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
| 3675 | 3675 | $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
| 3676 | 3676 | |
| 3677 | - switch ( $task ) {
|
|
| 3677 | + switch ($task) {
|
|
| 3678 | 3678 | case 'export_posts': {
|
| 3679 | 3679 | // WPML |
| 3680 | 3680 | $is_wpml = geodir_is_wpml(); |
@@ -3685,22 +3685,22 @@ discard block |
||
| 3685 | 3685 | $sitepress->switch_lang('all', true);
|
| 3686 | 3686 | } |
| 3687 | 3687 | // WPML |
| 3688 | - if ( $post_type == 'gd_event' ) {
|
|
| 3689 | - add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 3688 | + if ($post_type == 'gd_event') {
|
|
| 3689 | + add_filter('geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2);
|
|
| 3690 | 3690 | } |
| 3691 | - $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 3692 | - $posts_count = geodir_get_posts_count( $post_type ); |
|
| 3693 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3694 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3695 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3696 | - $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 3691 | + $file_name = $post_type.'_'.date('dmyHi');
|
|
| 3692 | + $posts_count = geodir_get_posts_count($post_type); |
|
| 3693 | + $file_url_base = geodir_path_import_export().'/'; |
|
| 3694 | + $file_url = $file_url_base.$file_name.'.csv'; |
|
| 3695 | + $file_path = $csv_file_dir.'/'.$file_name.'.csv'; |
|
| 3696 | + $file_path_temp = $csv_file_dir.'/'.$post_type.'_'.$nonce.'.csv'; |
|
| 3697 | 3697 | |
| 3698 | 3698 | $chunk_file_paths = array(); |
| 3699 | 3699 | |
| 3700 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3701 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3702 | - $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 3703 | - $percentage = min( $percentage, 100 ); |
|
| 3700 | + if (isset($_REQUEST['_st'])) {
|
|
| 3701 | + $line_count = (int) geodir_import_export_line_count($file_path_temp); |
|
| 3702 | + $percentage = count($posts_count) > 0 && $line_count > 0 ? ceil($line_count / $posts_count) * 100 : 0; |
|
| 3703 | + $percentage = min($percentage, 100); |
|
| 3704 | 3704 | |
| 3705 | 3705 | $json['percentage'] = $percentage; |
| 3706 | 3706 | // WPML |
@@ -3708,45 +3708,45 @@ discard block |
||
| 3708 | 3708 | $sitepress->switch_lang($active_lang, true); |
| 3709 | 3709 | } |
| 3710 | 3710 | // WPML |
| 3711 | - wp_send_json( $json ); |
|
| 3711 | + wp_send_json($json); |
|
| 3712 | 3712 | gd_die(); |
| 3713 | 3713 | } else {
|
| 3714 | - if ( !$posts_count > 0 ) {
|
|
| 3715 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3714 | + if (!$posts_count > 0) {
|
|
| 3715 | + $json['error'] = __('No records to export.', 'geodirectory');
|
|
| 3716 | 3716 | } else {
|
| 3717 | 3717 | $total_posts = $posts_count; |
| 3718 | 3718 | if ($chunk_per_page > $total_posts) {
|
| 3719 | 3719 | $chunk_per_page = $total_posts; |
| 3720 | 3720 | } |
| 3721 | - $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 3721 | + $chunk_total_pages = ceil($total_posts / $chunk_per_page); |
|
| 3722 | 3722 | |
| 3723 | 3723 | $j = $chunk_page_no; |
| 3724 | - $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 3724 | + $chunk_save_posts = geodir_imex_get_posts($post_type, $chunk_per_page, $j); |
|
| 3725 | 3725 | |
| 3726 | 3726 | $per_page = 500; |
| 3727 | 3727 | if ($per_page > $chunk_per_page) {
|
| 3728 | 3728 | $per_page = $chunk_per_page; |
| 3729 | 3729 | } |
| 3730 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3730 | + $total_pages = ceil($chunk_per_page / $per_page); |
|
| 3731 | 3731 | |
| 3732 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3733 | - $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 3732 | + for ($i = 0; $i <= $total_pages; $i++) {
|
|
| 3733 | + $save_posts = array_slice($chunk_save_posts, ($i * $per_page), $per_page); |
|
| 3734 | 3734 | |
| 3735 | 3735 | $clear = $i == 0 ? true : false; |
| 3736 | - geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 3736 | + geodir_save_csv_data($file_path_temp, $save_posts, $clear); |
|
| 3737 | 3737 | } |
| 3738 | 3738 | |
| 3739 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3740 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3741 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3742 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3743 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3739 | + if ($wp_filesystem->exists($file_path_temp)) {
|
|
| 3740 | + $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : ''; |
|
| 3741 | + $chunk_file_name = $file_name.$chunk_page_no.'.csv'; |
|
| 3742 | + $file_path = $csv_file_dir.'/'.$chunk_file_name; |
|
| 3743 | + $wp_filesystem->move($file_path_temp, $file_path, true); |
|
| 3744 | 3744 | |
| 3745 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3746 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3745 | + $file_url = $file_url_base.$chunk_file_name; |
|
| 3746 | + $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3747 | 3747 | } |
| 3748 | 3748 | |
| 3749 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3749 | + if (!empty($chunk_file_paths)) {
|
|
| 3750 | 3750 | $json['total'] = $posts_count; |
| 3751 | 3751 | $json['files'] = $chunk_file_paths; |
| 3752 | 3752 | } else {
|
@@ -3754,7 +3754,7 @@ discard block |
||
| 3754 | 3754 | $json['total'] = $posts_count; |
| 3755 | 3755 | $json['files'] = array(); |
| 3756 | 3756 | } else {
|
| 3757 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3757 | + $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
|
|
| 3758 | 3758 | } |
| 3759 | 3759 | } |
| 3760 | 3760 | } |
@@ -3763,7 +3763,7 @@ discard block |
||
| 3763 | 3763 | $sitepress->switch_lang($active_lang, true); |
| 3764 | 3764 | } |
| 3765 | 3765 | // WPML |
| 3766 | - wp_send_json( $json ); |
|
| 3766 | + wp_send_json($json); |
|
| 3767 | 3767 | } |
| 3768 | 3768 | } |
| 3769 | 3769 | break; |
@@ -3777,20 +3777,20 @@ discard block |
||
| 3777 | 3777 | $sitepress->switch_lang('all', true);
|
| 3778 | 3778 | } |
| 3779 | 3779 | // WPML |
| 3780 | - $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 3780 | + $file_name = $post_type.'category_'.date('dmyHi');
|
|
| 3781 | 3781 | |
| 3782 | - $terms_count = geodir_get_terms_count( $post_type ); |
|
| 3783 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3784 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3785 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3786 | - $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 3782 | + $terms_count = geodir_get_terms_count($post_type); |
|
| 3783 | + $file_url_base = geodir_path_import_export().'/'; |
|
| 3784 | + $file_url = $file_url_base.$file_name.'.csv'; |
|
| 3785 | + $file_path = $csv_file_dir.'/'.$file_name.'.csv'; |
|
| 3786 | + $file_path_temp = $csv_file_dir.'/'.$post_type.'category_'.$nonce.'.csv'; |
|
| 3787 | 3787 | |
| 3788 | 3788 | $chunk_file_paths = array(); |
| 3789 | 3789 | |
| 3790 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3791 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3792 | - $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 3793 | - $percentage = min( $percentage, 100 ); |
|
| 3790 | + if (isset($_REQUEST['_st'])) {
|
|
| 3791 | + $line_count = (int) geodir_import_export_line_count($file_path_temp); |
|
| 3792 | + $percentage = count($terms_count) > 0 && $line_count > 0 ? ceil($line_count / $terms_count) * 100 : 0; |
|
| 3793 | + $percentage = min($percentage, 100); |
|
| 3794 | 3794 | |
| 3795 | 3795 | $json['percentage'] = $percentage; |
| 3796 | 3796 | // WPML |
@@ -3798,48 +3798,48 @@ discard block |
||
| 3798 | 3798 | $sitepress->switch_lang($active_lang, true); |
| 3799 | 3799 | } |
| 3800 | 3800 | // WPML |
| 3801 | - wp_send_json( $json ); |
|
| 3801 | + wp_send_json($json); |
|
| 3802 | 3802 | } else {
|
| 3803 | - if ( !$terms_count > 0 ) {
|
|
| 3804 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3803 | + if (!$terms_count > 0) {
|
|
| 3804 | + $json['error'] = __('No records to export.', 'geodirectory');
|
|
| 3805 | 3805 | } else {
|
| 3806 | 3806 | $total_terms = $terms_count; |
| 3807 | 3807 | if ($chunk_per_page > $terms_count) {
|
| 3808 | 3808 | $chunk_per_page = $terms_count; |
| 3809 | 3809 | } |
| 3810 | - $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 3810 | + $chunk_total_pages = ceil($total_terms / $chunk_per_page); |
|
| 3811 | 3811 | |
| 3812 | 3812 | $j = $chunk_page_no; |
| 3813 | - $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 3813 | + $chunk_save_terms = geodir_imex_get_terms($post_type, $chunk_per_page, $j); |
|
| 3814 | 3814 | |
| 3815 | 3815 | $per_page = 500; |
| 3816 | 3816 | if ($per_page > $chunk_per_page) {
|
| 3817 | 3817 | $per_page = $chunk_per_page; |
| 3818 | 3818 | } |
| 3819 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3819 | + $total_pages = ceil($chunk_per_page / $per_page); |
|
| 3820 | 3820 | |
| 3821 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3822 | - $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 3821 | + for ($i = 0; $i <= $total_pages; $i++) {
|
|
| 3822 | + $save_terms = array_slice($chunk_save_terms, ($i * $per_page), $per_page); |
|
| 3823 | 3823 | |
| 3824 | 3824 | $clear = $i == 0 ? true : false; |
| 3825 | - geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 3825 | + geodir_save_csv_data($file_path_temp, $save_terms, $clear); |
|
| 3826 | 3826 | } |
| 3827 | 3827 | |
| 3828 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3829 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3830 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3831 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3832 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3828 | + if ($wp_filesystem->exists($file_path_temp)) {
|
|
| 3829 | + $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : ''; |
|
| 3830 | + $chunk_file_name = $file_name.$chunk_page_no.'.csv'; |
|
| 3831 | + $file_path = $csv_file_dir.'/'.$chunk_file_name; |
|
| 3832 | + $wp_filesystem->move($file_path_temp, $file_path, true); |
|
| 3833 | 3833 | |
| 3834 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3835 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3834 | + $file_url = $file_url_base.$chunk_file_name; |
|
| 3835 | + $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3836 | 3836 | } |
| 3837 | 3837 | |
| 3838 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3838 | + if (!empty($chunk_file_paths)) {
|
|
| 3839 | 3839 | $json['total'] = $terms_count; |
| 3840 | 3840 | $json['files'] = $chunk_file_paths; |
| 3841 | 3841 | } else {
|
| 3842 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3842 | + $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
|
|
| 3843 | 3843 | } |
| 3844 | 3844 | } |
| 3845 | 3845 | // WPML |
@@ -3847,127 +3847,127 @@ discard block |
||
| 3847 | 3847 | $sitepress->switch_lang($active_lang, true); |
| 3848 | 3848 | } |
| 3849 | 3849 | // WPML |
| 3850 | - wp_send_json( $json ); |
|
| 3850 | + wp_send_json($json); |
|
| 3851 | 3851 | } |
| 3852 | 3852 | } |
| 3853 | 3853 | break; |
| 3854 | 3854 | case 'export_locations': {
|
| 3855 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3856 | - $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 3857 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3858 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3859 | - $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 3855 | + $file_url_base = geodir_path_import_export().'/'; |
|
| 3856 | + $file_name = 'gd_locations_'.date('dmyHi');
|
|
| 3857 | + $file_url = $file_url_base.$file_name.'.csv'; |
|
| 3858 | + $file_path = $csv_file_dir.'/'.$file_name.'.csv'; |
|
| 3859 | + $file_path_temp = $csv_file_dir.'/gd_locations_'.$nonce.'.csv'; |
|
| 3860 | 3860 | |
| 3861 | - $items_count = (int)geodir_location_imex_count_locations(); |
|
| 3861 | + $items_count = (int) geodir_location_imex_count_locations(); |
|
| 3862 | 3862 | |
| 3863 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3864 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3865 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3866 | - $percentage = min( $percentage, 100 ); |
|
| 3863 | + if (isset($_REQUEST['_st'])) {
|
|
| 3864 | + $line_count = (int) geodir_import_export_line_count($file_path_temp); |
|
| 3865 | + $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0; |
|
| 3866 | + $percentage = min($percentage, 100); |
|
| 3867 | 3867 | |
| 3868 | 3868 | $json['percentage'] = $percentage; |
| 3869 | - wp_send_json( $json ); |
|
| 3869 | + wp_send_json($json); |
|
| 3870 | 3870 | } else {
|
| 3871 | 3871 | $chunk_file_paths = array(); |
| 3872 | 3872 | |
| 3873 | - if ( !$items_count > 0 ) {
|
|
| 3874 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3873 | + if (!$items_count > 0) {
|
|
| 3874 | + $json['error'] = __('No records to export.', 'geodirectory');
|
|
| 3875 | 3875 | } else {
|
| 3876 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3877 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3876 | + $chunk_per_page = min($chunk_per_page, $items_count); |
|
| 3877 | + $chunk_total_pages = ceil($items_count / $chunk_per_page); |
|
| 3878 | 3878 | |
| 3879 | 3879 | $j = $chunk_page_no; |
| 3880 | - $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 3880 | + $chunk_save_items = geodir_location_imex_locations_data($chunk_per_page, $j); |
|
| 3881 | 3881 | |
| 3882 | 3882 | $per_page = 500; |
| 3883 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 3884 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3883 | + $per_page = min($per_page, $chunk_per_page); |
|
| 3884 | + $total_pages = ceil($chunk_per_page / $per_page); |
|
| 3885 | 3885 | |
| 3886 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3887 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3886 | + for ($i = 0; $i <= $total_pages; $i++) {
|
|
| 3887 | + $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page); |
|
| 3888 | 3888 | |
| 3889 | 3889 | $clear = $i == 0 ? true : false; |
| 3890 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3890 | + geodir_save_csv_data($file_path_temp, $save_items, $clear); |
|
| 3891 | 3891 | } |
| 3892 | 3892 | |
| 3893 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3894 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3895 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3896 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3897 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3893 | + if ($wp_filesystem->exists($file_path_temp)) {
|
|
| 3894 | + $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : ''; |
|
| 3895 | + $chunk_file_name = $file_name.$chunk_page_no.'.csv'; |
|
| 3896 | + $file_path = $csv_file_dir.'/'.$chunk_file_name; |
|
| 3897 | + $wp_filesystem->move($file_path_temp, $file_path, true); |
|
| 3898 | 3898 | |
| 3899 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3900 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3899 | + $file_url = $file_url_base.$chunk_file_name; |
|
| 3900 | + $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3901 | 3901 | } |
| 3902 | 3902 | |
| 3903 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3903 | + if (!empty($chunk_file_paths)) {
|
|
| 3904 | 3904 | $json['total'] = $items_count; |
| 3905 | 3905 | $json['files'] = $chunk_file_paths; |
| 3906 | 3906 | } else {
|
| 3907 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3907 | + $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
|
|
| 3908 | 3908 | } |
| 3909 | 3909 | } |
| 3910 | - wp_send_json( $json ); |
|
| 3910 | + wp_send_json($json); |
|
| 3911 | 3911 | } |
| 3912 | 3912 | } |
| 3913 | 3913 | break; |
| 3914 | 3914 | case 'export_hoods': {
|
| 3915 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3916 | - $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
| 3917 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3918 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3919 | - $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
| 3915 | + $file_url_base = geodir_path_import_export().'/'; |
|
| 3916 | + $file_name = 'gd_neighbourhoods_'.date('dmyHi');
|
|
| 3917 | + $file_url = $file_url_base.$file_name.'.csv'; |
|
| 3918 | + $file_path = $csv_file_dir.'/'.$file_name.'.csv'; |
|
| 3919 | + $file_path_temp = $csv_file_dir.'/gd_neighbourhoods_'.$nonce.'.csv'; |
|
| 3920 | 3920 | |
| 3921 | - $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
| 3921 | + $items_count = (int) geodir_location_imex_count_neighbourhoods(); |
|
| 3922 | 3922 | |
| 3923 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3924 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3925 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3926 | - $percentage = min( $percentage, 100 ); |
|
| 3923 | + if (isset($_REQUEST['_st'])) {
|
|
| 3924 | + $line_count = (int) geodir_import_export_line_count($file_path_temp); |
|
| 3925 | + $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0; |
|
| 3926 | + $percentage = min($percentage, 100); |
|
| 3927 | 3927 | |
| 3928 | 3928 | $json['percentage'] = $percentage; |
| 3929 | - wp_send_json( $json ); |
|
| 3929 | + wp_send_json($json); |
|
| 3930 | 3930 | } else {
|
| 3931 | 3931 | $chunk_file_paths = array(); |
| 3932 | 3932 | |
| 3933 | - if ( !$items_count > 0 ) {
|
|
| 3934 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3933 | + if (!$items_count > 0) {
|
|
| 3934 | + $json['error'] = __('No records to export.', 'geodirectory');
|
|
| 3935 | 3935 | } else {
|
| 3936 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3937 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3936 | + $chunk_per_page = min($chunk_per_page, $items_count); |
|
| 3937 | + $chunk_total_pages = ceil($items_count / $chunk_per_page); |
|
| 3938 | 3938 | |
| 3939 | 3939 | $j = $chunk_page_no; |
| 3940 | - $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
| 3940 | + $chunk_save_items = geodir_location_imex_neighbourhoods_data($chunk_per_page, $j); |
|
| 3941 | 3941 | |
| 3942 | 3942 | $per_page = 500; |
| 3943 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 3944 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3943 | + $per_page = min($per_page, $chunk_per_page); |
|
| 3944 | + $total_pages = ceil($chunk_per_page / $per_page); |
|
| 3945 | 3945 | |
| 3946 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3947 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3946 | + for ($i = 0; $i <= $total_pages; $i++) {
|
|
| 3947 | + $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page); |
|
| 3948 | 3948 | |
| 3949 | 3949 | $clear = $i == 0 ? true : false; |
| 3950 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3950 | + geodir_save_csv_data($file_path_temp, $save_items, $clear); |
|
| 3951 | 3951 | } |
| 3952 | 3952 | |
| 3953 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3954 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3955 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3956 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3957 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3953 | + if ($wp_filesystem->exists($file_path_temp)) {
|
|
| 3954 | + $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : ''; |
|
| 3955 | + $chunk_file_name = $file_name.$chunk_page_no.'.csv'; |
|
| 3956 | + $file_path = $csv_file_dir.'/'.$chunk_file_name; |
|
| 3957 | + $wp_filesystem->move($file_path_temp, $file_path, true); |
|
| 3958 | 3958 | |
| 3959 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3960 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3959 | + $file_url = $file_url_base.$chunk_file_name; |
|
| 3960 | + $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3961 | 3961 | } |
| 3962 | 3962 | |
| 3963 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3963 | + if (!empty($chunk_file_paths)) {
|
|
| 3964 | 3964 | $json['total'] = $items_count; |
| 3965 | 3965 | $json['files'] = $chunk_file_paths; |
| 3966 | 3966 | } else {
|
| 3967 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3967 | + $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
|
|
| 3968 | 3968 | } |
| 3969 | 3969 | } |
| 3970 | - wp_send_json( $json ); |
|
| 3970 | + wp_send_json($json); |
|
| 3971 | 3971 | } |
| 3972 | 3972 | } |
| 3973 | 3973 | break; |
@@ -3984,33 +3984,33 @@ discard block |
||
| 3984 | 3984 | } |
| 3985 | 3985 | // WPML |
| 3986 | 3986 | |
| 3987 | - ini_set( 'auto_detect_line_endings', true ); |
|
| 3987 | + ini_set('auto_detect_line_endings', true);
|
|
| 3988 | 3988 | |
| 3989 | 3989 | $uploads = wp_upload_dir(); |
| 3990 | 3990 | $uploads_dir = $uploads['path']; |
| 3991 | 3991 | $uploads_subdir = $uploads['subdir']; |
| 3992 | 3992 | |
| 3993 | - $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 3994 | - $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 3993 | + $csv_file = isset($_POST['_file']) ? $_POST['_file'] : NULL; |
|
| 3994 | + $import_choice = isset($_REQUEST['_ch']) ? $_REQUEST['_ch'] : 'skip'; |
|
| 3995 | 3995 | |
| 3996 | - $csv_file_arr = explode( '/', $csv_file ); |
|
| 3997 | - $csv_filename = end( $csv_file_arr ); |
|
| 3998 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 3996 | + $csv_file_arr = explode('/', $csv_file);
|
|
| 3997 | + $csv_filename = end($csv_file_arr); |
|
| 3998 | + $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$csv_filename; |
|
| 3999 | 3999 | |
| 4000 | 4000 | $json['file'] = $csv_file; |
| 4001 | - $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 4001 | + $json['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
|
|
| 4002 | 4002 | $file = array(); |
| 4003 | 4003 | |
| 4004 | - if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 4005 | - $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 4004 | + if ($csv_file && $wp_filesystem->is_file($target_path) && $wp_filesystem->exists($target_path)) {
|
|
| 4005 | + $wp_filetype = wp_check_filetype_and_ext($target_path, $csv_filename); |
|
| 4006 | 4006 | |
| 4007 | 4007 | if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
| 4008 | 4008 | $json['error'] = NULL; |
| 4009 | 4009 | $json['rows'] = 0; |
| 4010 | 4010 | |
| 4011 | - if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 4012 | - while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 4013 | - if ( !empty( $data ) ) {
|
|
| 4011 | + if (($handle = fopen($target_path, "r")) !== FALSE) {
|
|
| 4012 | + while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) {
|
|
| 4013 | + if (!empty($data)) {
|
|
| 4014 | 4014 | $file[] = $data; |
| 4015 | 4015 | } |
| 4016 | 4016 | } |
@@ -4023,19 +4023,19 @@ discard block |
||
| 4023 | 4023 | $json['error'] = __('No data found in csv file.', 'geodirectory');
|
| 4024 | 4024 | } |
| 4025 | 4025 | } else {
|
| 4026 | - wp_send_json( $json ); |
|
| 4026 | + wp_send_json($json); |
|
| 4027 | 4027 | } |
| 4028 | 4028 | } else {
|
| 4029 | - wp_send_json( $json ); |
|
| 4029 | + wp_send_json($json); |
|
| 4030 | 4030 | } |
| 4031 | 4031 | |
| 4032 | - if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 4033 | - wp_send_json( $json ); |
|
| 4032 | + if ($task == 'prepare_import' || !empty($json['error'])) {
|
|
| 4033 | + wp_send_json($json); |
|
| 4034 | 4034 | } |
| 4035 | 4035 | |
| 4036 | 4036 | $total = $json['rows']; |
| 4037 | - $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 4038 | - $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 4037 | + $limit = isset($_POST['limit']) ? (int) $_POST['limit'] : 1; |
|
| 4038 | + $processed = isset($_POST['processed']) ? (int) $_POST['processed'] : 0; |
|
| 4039 | 4039 | |
| 4040 | 4040 | $count = $limit; |
| 4041 | 4041 | |
@@ -4060,13 +4060,13 @@ discard block |
||
| 4060 | 4060 | |
| 4061 | 4061 | $post_types = geodir_get_posttypes(); |
| 4062 | 4062 | |
| 4063 | - if ( $task == 'import_cat' ) {
|
|
| 4063 | + if ($task == 'import_cat') {
|
|
| 4064 | 4064 | if (!empty($file)) {
|
| 4065 | 4065 | $columns = isset($file[0]) ? $file[0] : NULL; |
| 4066 | 4066 | |
| 4067 | 4067 | if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
| 4068 | 4068 | $json['error'] = CSV_INVAILD_FILE; |
| 4069 | - wp_send_json( $json ); |
|
| 4069 | + wp_send_json($json); |
|
| 4070 | 4070 | exit; |
| 4071 | 4071 | } |
| 4072 | 4072 | |
@@ -4077,7 +4077,7 @@ discard block |
||
| 4077 | 4077 | |
| 4078 | 4078 | if (isset($file[$index])) {
|
| 4079 | 4079 | $row = $file[$index]; |
| 4080 | - $row = array_map( 'trim', $row ); |
|
| 4080 | + $row = array_map('trim', $row);
|
|
| 4081 | 4081 | //$row = array_map( 'utf8_encode', $row ); |
| 4082 | 4082 | |
| 4083 | 4083 | $cat_id = ''; |
@@ -4094,42 +4094,42 @@ discard block |
||
| 4094 | 4094 | $cat_id_original = ''; |
| 4095 | 4095 | |
| 4096 | 4096 | $c = 0; |
| 4097 | - foreach ($columns as $column ) {
|
|
| 4098 | - if ( $column == 'cat_id' ) {
|
|
| 4099 | - $cat_id = (int)$row[$c]; |
|
| 4100 | - } else if ( $column == 'cat_name' ) {
|
|
| 4097 | + foreach ($columns as $column) {
|
|
| 4098 | + if ($column == 'cat_id') {
|
|
| 4099 | + $cat_id = (int) $row[$c]; |
|
| 4100 | + } else if ($column == 'cat_name') {
|
|
| 4101 | 4101 | $cat_name = $row[$c]; |
| 4102 | - } else if ( $column == 'cat_slug' ) {
|
|
| 4102 | + } else if ($column == 'cat_slug') {
|
|
| 4103 | 4103 | $cat_slug = $row[$c]; |
| 4104 | - } else if ( $column == 'cat_posttype' ) {
|
|
| 4104 | + } else if ($column == 'cat_posttype') {
|
|
| 4105 | 4105 | $cat_posttype = $row[$c]; |
| 4106 | - } else if ( $column == 'cat_parent' ) {
|
|
| 4106 | + } else if ($column == 'cat_parent') {
|
|
| 4107 | 4107 | $cat_parent = trim($row[$c]); |
| 4108 | - } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 4108 | + } else if ($column == 'cat_schema' && $row[$c] != '') {
|
|
| 4109 | 4109 | $cat_schema = $row[$c]; |
| 4110 | - } else if ( $column == 'cat_description' ) {
|
|
| 4110 | + } else if ($column == 'cat_description') {
|
|
| 4111 | 4111 | $cat_description = $row[$c]; |
| 4112 | - } else if ( $column == 'cat_top_description' ) {
|
|
| 4112 | + } else if ($column == 'cat_top_description') {
|
|
| 4113 | 4113 | $cat_top_description = $row[$c]; |
| 4114 | - } else if ( $column == 'cat_image' ) {
|
|
| 4114 | + } else if ($column == 'cat_image') {
|
|
| 4115 | 4115 | $cat_image = $row[$c]; |
| 4116 | - } else if ( $column == 'cat_icon' ) {
|
|
| 4116 | + } else if ($column == 'cat_icon') {
|
|
| 4117 | 4117 | $cat_icon = $row[$c]; |
| 4118 | 4118 | } |
| 4119 | 4119 | // WPML |
| 4120 | - if ( $is_wpml ) {
|
|
| 4121 | - if ( $column == 'cat_language' ) {
|
|
| 4122 | - $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
| 4123 | - } else if ( $column == 'cat_id_original' ) {
|
|
| 4124 | - $cat_id_original = (int)$row[$c]; |
|
| 4120 | + if ($is_wpml) {
|
|
| 4121 | + if ($column == 'cat_language') {
|
|
| 4122 | + $cat_language = geodir_strtolower(trim($row[$c])); |
|
| 4123 | + } else if ($column == 'cat_id_original') {
|
|
| 4124 | + $cat_id_original = (int) $row[$c]; |
|
| 4125 | 4125 | } |
| 4126 | 4126 | } |
| 4127 | 4127 | // WPML |
| 4128 | 4128 | $c++; |
| 4129 | 4129 | } |
| 4130 | 4130 | |
| 4131 | - if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 4132 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4131 | + if ($cat_name == '' || !in_array($cat_posttype, $post_types)) {
|
|
| 4132 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank title/invalid post type', 'geodirectory'));
|
|
| 4133 | 4133 | |
| 4134 | 4134 | $invalid++; |
| 4135 | 4135 | continue; |
@@ -4147,24 +4147,24 @@ discard block |
||
| 4147 | 4147 | $term_data['description'] = $cat_description; |
| 4148 | 4148 | $term_data['cat_schema'] = $cat_schema; |
| 4149 | 4149 | $term_data['top_description'] = $cat_top_description; |
| 4150 | - $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 4151 | - $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 4150 | + $term_data['image'] = $cat_image != '' ? basename($cat_image) : ''; |
|
| 4151 | + $term_data['icon'] = $cat_icon != '' ? basename($cat_icon) : ''; |
|
| 4152 | 4152 | |
| 4153 | 4153 | //$term_data = array_map( 'utf8_encode', $term_data ); |
| 4154 | 4154 | |
| 4155 | - $taxonomy = $cat_posttype . 'category'; |
|
| 4155 | + $taxonomy = $cat_posttype.'category'; |
|
| 4156 | 4156 | |
| 4157 | 4157 | $term_data['taxonomy'] = $taxonomy; |
| 4158 | 4158 | |
| 4159 | 4159 | $term_parent_id = 0; |
| 4160 | - if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 4160 | + if ($cat_parent != "" || (int) $cat_parent > 0) {
|
|
| 4161 | 4161 | $term_parent = ''; |
| 4162 | 4162 | |
| 4163 | - if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 4163 | + if ($term_parent = get_term_by('name', $cat_parent, $taxonomy)) {
|
|
| 4164 | 4164 | // |
| 4165 | - } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 4165 | + } else if ($term_parent = get_term_by('slug', $cat_parent, $taxonomy)) {
|
|
| 4166 | 4166 | // |
| 4167 | - } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 4167 | + } else if ($term_parent = get_term_by('id', $cat_parent, $taxonomy)) {
|
|
| 4168 | 4168 | // |
| 4169 | 4169 | } else {
|
| 4170 | 4170 | $term_parent_data = array(); |
@@ -4172,104 +4172,104 @@ discard block |
||
| 4172 | 4172 | //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
| 4173 | 4173 | $term_parent_data['taxonomy'] = $taxonomy; |
| 4174 | 4174 | |
| 4175 | - $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 4175 | + $term_parent_id = (int) geodir_imex_insert_term($taxonomy, $term_parent_data); |
|
| 4176 | 4176 | } |
| 4177 | 4177 | |
| 4178 | - if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 4179 | - $term_parent_id = (int)$term_parent->term_id; |
|
| 4178 | + if (!empty($term_parent) && !is_wp_error($term_parent)) {
|
|
| 4179 | + $term_parent_id = (int) $term_parent->term_id; |
|
| 4180 | 4180 | } |
| 4181 | 4181 | } |
| 4182 | - $term_data['parent'] = (int)$term_parent_id; |
|
| 4182 | + $term_data['parent'] = (int) $term_parent_id; |
|
| 4183 | 4183 | |
| 4184 | 4184 | $term_id = NULL; |
| 4185 | - if ( $import_choice == 'update' ) {
|
|
| 4186 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 4185 | + if ($import_choice == 'update') {
|
|
| 4186 | + if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
|
|
| 4187 | 4187 | $term_data['term_id'] = $term['term_id']; |
| 4188 | 4188 | |
| 4189 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 4189 | + if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
|
|
| 4190 | 4190 | $updated++; |
| 4191 | 4191 | } else {
|
| 4192 | 4192 | $invalid++; |
| 4193 | - 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' ) ); |
|
| 4193 | + 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'));
|
|
| 4194 | 4194 | } |
| 4195 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 4195 | + } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
|
|
| 4196 | 4196 | $term_data['term_id'] = $term['term_id']; |
| 4197 | 4197 | |
| 4198 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 4198 | + if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
|
|
| 4199 | 4199 | $updated++; |
| 4200 | 4200 | } else {
|
| 4201 | 4201 | $invalid++; |
| 4202 | - 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' ) ); |
|
| 4202 | + 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'));
|
|
| 4203 | 4203 | } |
| 4204 | 4204 | } else {
|
| 4205 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 4205 | + if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
|
|
| 4206 | 4206 | $created++; |
| 4207 | 4207 | } else {
|
| 4208 | 4208 | $invalid++; |
| 4209 | - 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' ) ); |
|
| 4209 | + 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'));
|
|
| 4210 | 4210 | } |
| 4211 | 4211 | } |
| 4212 | - } else if ( $import_choice == 'skip' ) {
|
|
| 4213 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 4212 | + } else if ($import_choice == 'skip') {
|
|
| 4213 | + if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
|
|
| 4214 | 4214 | $skipped++; |
| 4215 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 4215 | + } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
|
|
| 4216 | 4216 | $skipped++; |
| 4217 | 4217 | } else {
|
| 4218 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 4218 | + if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
|
|
| 4219 | 4219 | $created++; |
| 4220 | 4220 | } else {
|
| 4221 | 4221 | $invalid++; |
| 4222 | - 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' ) ); |
|
| 4222 | + 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'));
|
|
| 4223 | 4223 | } |
| 4224 | 4224 | } |
| 4225 | 4225 | } else {
|
| 4226 | 4226 | $invalid++; |
| 4227 | - 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' ) ); |
|
| 4227 | + 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'));
|
|
| 4228 | 4228 | } |
| 4229 | 4229 | |
| 4230 | - if ( $term_id ) {
|
|
| 4230 | + if ($term_id) {
|
|
| 4231 | 4231 | // WPML |
| 4232 | 4232 | if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
|
| 4233 | - $wpml_element_type = 'tax_' . $taxonomy; |
|
| 4234 | - $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
| 4233 | + $wpml_element_type = 'tax_'.$taxonomy; |
|
| 4234 | + $source_language = geodir_get_language_for_element($cat_id_original, $wpml_element_type); |
|
| 4235 | 4235 | $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
| 4236 | 4236 | |
| 4237 | - $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
| 4237 | + $trid = $sitepress->get_element_trid($cat_id_original, $wpml_element_type); |
|
| 4238 | 4238 | |
| 4239 | - $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
| 4239 | + $sitepress->set_element_language_details($term_id, $wpml_element_type, $trid, $cat_language, $source_language); |
|
| 4240 | 4240 | } |
| 4241 | 4241 | // WPML |
| 4242 | 4242 | |
| 4243 | - if ( isset( $term_data['top_description'] ) ) {
|
|
| 4244 | - update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 4243 | + if (isset($term_data['top_description'])) {
|
|
| 4244 | + update_tax_meta($term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype); |
|
| 4245 | 4245 | } |
| 4246 | 4246 | |
| 4247 | - if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 4248 | - update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 4247 | + if (isset($term_data['cat_schema'])) {
|
|
| 4248 | + update_tax_meta($term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype); |
|
| 4249 | 4249 | } |
| 4250 | 4250 | |
| 4251 | 4251 | $attachment = false; |
| 4252 | - if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 4253 | - $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 4254 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 4252 | + if (isset($term_data['image']) && $term_data['image'] != '') {
|
|
| 4253 | + $cat_image = geodir_get_default_catimage($term_id, $cat_posttype); |
|
| 4254 | + $cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : ''; |
|
| 4255 | 4255 | |
| 4256 | - if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 4256 | + if (basename($cat_image) != $term_data['image']) {
|
|
| 4257 | 4257 | $attachment = true; |
| 4258 | - update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 4258 | + update_tax_meta($term_id, 'ct_cat_default_img', array('id' => 'image', 'src' => $uploads['url'].'/'.$term_data['image']), $cat_posttype);
|
|
| 4259 | 4259 | } |
| 4260 | 4260 | } |
| 4261 | 4261 | |
| 4262 | - if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 4263 | - $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 4264 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 4262 | + if (isset($term_data['icon']) && $term_data['icon'] != '') {
|
|
| 4263 | + $cat_icon = get_tax_meta($term_id, 'ct_cat_icon', false, $cat_posttype); |
|
| 4264 | + $cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : ''; |
|
| 4265 | 4265 | |
| 4266 | - if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 4266 | + if (basename($cat_icon) != $term_data['icon']) {
|
|
| 4267 | 4267 | $attachment = true; |
| 4268 | - update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 4268 | + update_tax_meta($term_id, 'ct_cat_icon', array('id' => 'icon', 'src' => $uploads['url'].'/'.$term_data['icon']), $cat_posttype);
|
|
| 4269 | 4269 | } |
| 4270 | 4270 | } |
| 4271 | 4271 | |
| 4272 | - if ( $attachment ) {
|
|
| 4272 | + if ($attachment) {
|
|
| 4273 | 4273 | $images++; |
| 4274 | 4274 | } |
| 4275 | 4275 | } |
@@ -4291,13 +4291,13 @@ discard block |
||
| 4291 | 4291 | $json['invalid'] = $invalid; |
| 4292 | 4292 | $json['images'] = $images; |
| 4293 | 4293 | |
| 4294 | - wp_send_json( $json ); |
|
| 4294 | + wp_send_json($json); |
|
| 4295 | 4295 | exit; |
| 4296 | - } else if ( $task == 'import_post' ) {
|
|
| 4296 | + } else if ($task == 'import_post') {
|
|
| 4297 | 4297 | //run some stuff to make the import quicker |
| 4298 | - wp_defer_term_counting( true ); |
|
| 4299 | - wp_defer_comment_counting( true ); |
|
| 4300 | - $wpdb->query( 'SET autocommit = 0;' ); |
|
| 4298 | + wp_defer_term_counting(true); |
|
| 4299 | + wp_defer_comment_counting(true); |
|
| 4300 | + $wpdb->query('SET autocommit = 0;');
|
|
| 4301 | 4301 | |
| 4302 | 4302 | //remove_all_actions('publish_post');
|
| 4303 | 4303 | //remove_all_actions('transition_post_status');
|
@@ -4306,18 +4306,18 @@ discard block |
||
| 4306 | 4306 | if (!empty($file)) {
|
| 4307 | 4307 | $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
| 4308 | 4308 | $default_status = 'publish'; |
| 4309 | - $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 4309 | + $current_date = date_i18n('Y-m-d', time());
|
|
| 4310 | 4310 | |
| 4311 | 4311 | $columns = isset($file[0]) ? $file[0] : NULL; |
| 4312 | 4312 | |
| 4313 | 4313 | if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
| 4314 | 4314 | $json['error'] = CSV_INVAILD_FILE; |
| 4315 | - wp_send_json( $json ); |
|
| 4315 | + wp_send_json($json); |
|
| 4316 | 4316 | exit; |
| 4317 | 4317 | } |
| 4318 | 4318 | |
| 4319 | 4319 | $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
|
| 4320 | - $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
| 4320 | + $wp_chars_error = __('(check & remove if any invalid characters used in data)', 'geodirectory');
|
|
| 4321 | 4321 | $processed_actual = 0; |
| 4322 | 4322 | for ($i = 1; $i <= $limit; $i++) {
|
| 4323 | 4323 | $index = $processed + $i; |
@@ -4326,9 +4326,9 @@ discard block |
||
| 4326 | 4326 | if (isset($file[$index])) {
|
| 4327 | 4327 | $processed_actual++; |
| 4328 | 4328 | $row = $file[$index]; |
| 4329 | - $row = array_map( 'trim', $row ); |
|
| 4329 | + $row = array_map('trim', $row);
|
|
| 4330 | 4330 | //$row = array_map( 'utf8_encode', $row ); |
| 4331 | - $row = array_map( 'addslashes_gpc', $row ); |
|
| 4331 | + $row = array_map('addslashes_gpc', $row);
|
|
| 4332 | 4332 | |
| 4333 | 4333 | $post_id = ''; |
| 4334 | 4334 | $post_title = ''; |
@@ -4365,78 +4365,78 @@ discard block |
||
| 4365 | 4365 | $original_post_id = ''; |
| 4366 | 4366 | |
| 4367 | 4367 | $c = 0; |
| 4368 | - foreach ($columns as $column ) {
|
|
| 4368 | + foreach ($columns as $column) {
|
|
| 4369 | 4369 | $gd_post[$column] = $row[$c]; |
| 4370 | 4370 | |
| 4371 | - if ( $column == 'post_id' ) {
|
|
| 4371 | + if ($column == 'post_id') {
|
|
| 4372 | 4372 | $post_id = $row[$c]; |
| 4373 | - } else if ( $column == 'post_title' ) {
|
|
| 4373 | + } else if ($column == 'post_title') {
|
|
| 4374 | 4374 | $post_title = sanitize_text_field($row[$c]); |
| 4375 | - } else if ( $column == 'post_author' ) {
|
|
| 4375 | + } else if ($column == 'post_author') {
|
|
| 4376 | 4376 | $post_author = $row[$c]; |
| 4377 | - } else if ( $column == 'post_content' ) {
|
|
| 4377 | + } else if ($column == 'post_content') {
|
|
| 4378 | 4378 | $post_content = $row[$c]; |
| 4379 | - } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 4380 | - $post_category_arr = explode( ',', $row[$c] ); |
|
| 4381 | - } else if ( $column == 'default_category' ) {
|
|
| 4379 | + } else if ($column == 'post_category' && $row[$c] != '') {
|
|
| 4380 | + $post_category_arr = explode(',', $row[$c]);
|
|
| 4381 | + } else if ($column == 'default_category') {
|
|
| 4382 | 4382 | $default_category = wp_kses_normalize_entities($row[$c]); |
| 4383 | - } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 4384 | - $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
| 4385 | - } else if ( $column == 'post_type' ) {
|
|
| 4383 | + } else if ($column == 'post_tags' && $row[$c] != '') {
|
|
| 4384 | + $post_tags = explode(',', sanitize_text_field($row[$c]));
|
|
| 4385 | + } else if ($column == 'post_type') {
|
|
| 4386 | 4386 | $post_type = $row[$c]; |
| 4387 | - } else if ( $column == 'post_status' ) {
|
|
| 4388 | - $post_status = sanitize_key( $row[$c] ); |
|
| 4389 | - } else if ( $column == 'is_featured' ) {
|
|
| 4390 | - $is_featured = (int)$row[$c]; |
|
| 4391 | - } else if ( $column == 'geodir_video' ) {
|
|
| 4387 | + } else if ($column == 'post_status') {
|
|
| 4388 | + $post_status = sanitize_key($row[$c]); |
|
| 4389 | + } else if ($column == 'is_featured') {
|
|
| 4390 | + $is_featured = (int) $row[$c]; |
|
| 4391 | + } else if ($column == 'geodir_video') {
|
|
| 4392 | 4392 | $geodir_video = $row[$c]; |
| 4393 | - } else if ( $column == 'post_address' ) {
|
|
| 4393 | + } else if ($column == 'post_address') {
|
|
| 4394 | 4394 | $post_address = sanitize_text_field($row[$c]); |
| 4395 | - } else if ( $column == 'post_city' ) {
|
|
| 4395 | + } else if ($column == 'post_city') {
|
|
| 4396 | 4396 | $post_city = sanitize_text_field($row[$c]); |
| 4397 | - } else if ( $column == 'post_region' ) {
|
|
| 4397 | + } else if ($column == 'post_region') {
|
|
| 4398 | 4398 | $post_region = sanitize_text_field($row[$c]); |
| 4399 | - } else if ( $column == 'post_country' ) {
|
|
| 4399 | + } else if ($column == 'post_country') {
|
|
| 4400 | 4400 | $post_country = sanitize_text_field($row[$c]); |
| 4401 | - } else if ( $column == 'post_zip' ) {
|
|
| 4401 | + } else if ($column == 'post_zip') {
|
|
| 4402 | 4402 | $post_zip = sanitize_text_field($row[$c]); |
| 4403 | - } else if ( $column == 'post_latitude' ) {
|
|
| 4403 | + } else if ($column == 'post_latitude') {
|
|
| 4404 | 4404 | $post_latitude = sanitize_text_field($row[$c]); |
| 4405 | - } else if ( $column == 'post_longitude' ) {
|
|
| 4405 | + } else if ($column == 'post_longitude') {
|
|
| 4406 | 4406 | $post_longitude = sanitize_text_field($row[$c]); |
| 4407 | - } else if ( $column == 'post_neighbourhood' ) {
|
|
| 4407 | + } else if ($column == 'post_neighbourhood') {
|
|
| 4408 | 4408 | $post_neighbourhood = sanitize_text_field($row[$c]); |
| 4409 | 4409 | unset($gd_post[$column]); |
| 4410 | - } else if ( $column == 'neighbourhood_latitude' ) {
|
|
| 4410 | + } else if ($column == 'neighbourhood_latitude') {
|
|
| 4411 | 4411 | $neighbourhood_latitude = sanitize_text_field($row[$c]); |
| 4412 | - } else if ( $column == 'neighbourhood_longitude' ) {
|
|
| 4412 | + } else if ($column == 'neighbourhood_longitude') {
|
|
| 4413 | 4413 | $neighbourhood_longitude = sanitize_text_field($row[$c]); |
| 4414 | - } else if ( $column == 'geodir_timing' ) {
|
|
| 4414 | + } else if ($column == 'geodir_timing') {
|
|
| 4415 | 4415 | $geodir_timing = sanitize_text_field($row[$c]); |
| 4416 | - } else if ( $column == 'geodir_contact' ) {
|
|
| 4416 | + } else if ($column == 'geodir_contact') {
|
|
| 4417 | 4417 | $geodir_contact = sanitize_text_field($row[$c]); |
| 4418 | - } else if ( $column == 'geodir_email' ) {
|
|
| 4418 | + } else if ($column == 'geodir_email') {
|
|
| 4419 | 4419 | $geodir_email = sanitize_email($row[$c]); |
| 4420 | - } else if ( $column == 'geodir_website' ) {
|
|
| 4420 | + } else if ($column == 'geodir_website') {
|
|
| 4421 | 4421 | $geodir_website = sanitize_text_field($row[$c]); |
| 4422 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 4422 | + } else if ($column == 'geodir_twitter') {
|
|
| 4423 | 4423 | $geodir_twitter = sanitize_text_field($row[$c]); |
| 4424 | - } else if ( $column == 'geodir_facebook' ) {
|
|
| 4424 | + } else if ($column == 'geodir_facebook') {
|
|
| 4425 | 4425 | $geodir_facebook = sanitize_text_field($row[$c]); |
| 4426 | - } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 4426 | + } else if ($column == 'IMAGE' && !empty($row[$c]) && $row[$c] != '') {
|
|
| 4427 | 4427 | $post_images[] = $row[$c]; |
| 4428 | - } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 4429 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 4430 | - } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 4428 | + } else if ($column == 'alive_days' && (int) $row[$c] > 0) {
|
|
| 4429 | + $expire_date = date_i18n('Y-m-d', strtotime($current_date.'+'.(int) $row[$c].' days'));
|
|
| 4430 | + } else if ($column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never') {
|
|
| 4431 | 4431 | $row[$c] = str_replace('/', '-', $row[$c]);
|
| 4432 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 4432 | + $expire_date = date_i18n('Y-m-d', strtotime($row[$c]));
|
|
| 4433 | 4433 | } |
| 4434 | 4434 | // WPML |
| 4435 | 4435 | if ($is_wpml) {
|
| 4436 | 4436 | if ($column == 'language') {
|
| 4437 | 4437 | $language = geodir_strtolower(trim($row[$c])); |
| 4438 | 4438 | } else if ($column == 'original_post_id') {
|
| 4439 | - $original_post_id = (int)$row[$c]; |
|
| 4439 | + $original_post_id = (int) $row[$c]; |
|
| 4440 | 4440 | } |
| 4441 | 4441 | } |
| 4442 | 4442 | // WPML |
@@ -4451,43 +4451,43 @@ discard block |
||
| 4451 | 4451 | |
| 4452 | 4452 | $gd_post['IMAGE'] = $post_images; |
| 4453 | 4453 | |
| 4454 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 4455 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 4454 | + $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status; |
|
| 4455 | + $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status; |
|
| 4456 | 4456 | |
| 4457 | 4457 | $valid = true; |
| 4458 | 4458 | |
| 4459 | - if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 4459 | + if ($post_title == '' || !in_array($post_type, $post_types)) {
|
|
| 4460 | 4460 | $invalid++; |
| 4461 | 4461 | $valid = false; |
| 4462 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4462 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank title/invalid post type', 'geodirectory'));
|
|
| 4463 | 4463 | } |
| 4464 | 4464 | |
| 4465 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 4466 | - if ( $location_allowed ) {
|
|
| 4465 | + $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
|
|
| 4466 | + if ($location_allowed) {
|
|
| 4467 | 4467 | $location_result = geodir_get_default_location(); |
| 4468 | - if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 4468 | + if ($post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '') {
|
|
| 4469 | 4469 | $invalid_addr++; |
| 4470 | 4470 | $valid = false; |
| 4471 | - 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' ) ); |
|
| 4472 | - } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 4473 | - 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 ) ) ) {
|
|
| 4471 | + 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'));
|
|
| 4472 | + } else if (!empty($location_result) && $location_result->location_id == 0) {
|
|
| 4473 | + 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))) {
|
|
| 4474 | 4474 | $invalid_addr++; |
| 4475 | 4475 | $valid = false; |
| 4476 | - 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' ) ); |
|
| 4476 | + 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'));
|
|
| 4477 | 4477 | } else {
|
| 4478 | 4478 | if (!$location_manager) {
|
| 4479 | - $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. |
|
| 4479 | + $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. |
|
| 4480 | 4480 | } |
| 4481 | 4481 | } |
| 4482 | 4482 | } |
| 4483 | 4483 | } |
| 4484 | 4484 | |
| 4485 | - if ( !$valid ) {
|
|
| 4485 | + if (!$valid) {
|
|
| 4486 | 4486 | continue; |
| 4487 | 4487 | } |
| 4488 | 4488 | |
| 4489 | - $cat_taxonomy = $post_type . 'category'; |
|
| 4490 | - $tags_taxonomy = $post_type . '_tags'; |
|
| 4489 | + $cat_taxonomy = $post_type.'category'; |
|
| 4490 | + $tags_taxonomy = $post_type.'_tags'; |
|
| 4491 | 4491 | |
| 4492 | 4492 | if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
| 4493 | 4493 | $post_category_arr = array_merge(array($default_category), $post_category_arr); |
@@ -4495,29 +4495,29 @@ discard block |
||
| 4495 | 4495 | |
| 4496 | 4496 | $post_category = array(); |
| 4497 | 4497 | $default_category_id = NULL; |
| 4498 | - if ( !empty( $post_category_arr ) ) {
|
|
| 4499 | - foreach ( $post_category_arr as $value ) {
|
|
| 4500 | - $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 4498 | + if (!empty($post_category_arr)) {
|
|
| 4499 | + foreach ($post_category_arr as $value) {
|
|
| 4500 | + $category_name = wp_kses_normalize_entities(trim($value)); |
|
| 4501 | 4501 | |
| 4502 | - if ( $category_name != '' ) {
|
|
| 4502 | + if ($category_name != '') {
|
|
| 4503 | 4503 | $term_category = array(); |
| 4504 | 4504 | |
| 4505 | - if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 4505 | + if ($term = get_term_by('name', $category_name, $cat_taxonomy)) {
|
|
| 4506 | 4506 | $term_category = $term; |
| 4507 | - } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 4507 | + } else if ($term = get_term_by('slug', $category_name, $cat_taxonomy)) {
|
|
| 4508 | 4508 | $term_category = $term; |
| 4509 | 4509 | } else {
|
| 4510 | 4510 | $term_data = array(); |
| 4511 | 4511 | $term_data['name'] = $category_name; |
| 4512 | 4512 | $term_data['taxonomy'] = $cat_taxonomy; |
| 4513 | 4513 | |
| 4514 | - $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 4515 | - if ( $term_id ) {
|
|
| 4516 | - $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 4514 | + $term_id = geodir_imex_insert_term($cat_taxonomy, $term_data); |
|
| 4515 | + if ($term_id) {
|
|
| 4516 | + $term_category = get_term($term_id, $cat_taxonomy); |
|
| 4517 | 4517 | } |
| 4518 | 4518 | } |
| 4519 | 4519 | |
| 4520 | - if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 4520 | + if (!empty($term_category) && !is_wp_error($term_category)) {
|
|
| 4521 | 4521 | $post_category[] = intval($term_category->term_id); |
| 4522 | 4522 | |
| 4523 | 4523 | if ($category_name == $default_category) {
|
@@ -4538,15 +4538,15 @@ discard block |
||
| 4538 | 4538 | $save_post['post_tags'] = $post_tags; |
| 4539 | 4539 | |
| 4540 | 4540 | $saved_post_id = NULL; |
| 4541 | - if ( $import_choice == 'update' ) {
|
|
| 4542 | - $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
| 4541 | + if ($import_choice == 'update') {
|
|
| 4542 | + $gd_wp_error = __('Unable to add listing, please check the listing data.', 'geodirectory');
|
|
| 4543 | 4543 | |
| 4544 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4544 | + if ($post_id > 0 && get_post($post_id)) {
|
|
| 4545 | 4545 | $save_post['ID'] = $post_id; |
| 4546 | 4546 | |
| 4547 | - if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
|
|
| 4548 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4549 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4547 | + if ($saved_post_id = wp_update_post($save_post, true)) {
|
|
| 4548 | + if (is_wp_error($saved_post_id)) {
|
|
| 4549 | + $gd_wp_error = $saved_post_id->get_error_message().' '.$wp_chars_error; |
|
| 4550 | 4550 | $saved_post_id = 0; |
| 4551 | 4551 | } else {
|
| 4552 | 4552 | $saved_post_id = $post_id; |
@@ -4554,9 +4554,9 @@ discard block |
||
| 4554 | 4554 | } |
| 4555 | 4555 | } |
| 4556 | 4556 | } else {
|
| 4557 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4558 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4559 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4557 | + if ($saved_post_id = wp_insert_post($save_post, true)) {
|
|
| 4558 | + if (is_wp_error($saved_post_id)) {
|
|
| 4559 | + $gd_wp_error = $saved_post_id->get_error_message().' '.$wp_chars_error; |
|
| 4560 | 4560 | $saved_post_id = 0; |
| 4561 | 4561 | } else {
|
| 4562 | 4562 | $created++; |
@@ -4564,19 +4564,19 @@ discard block |
||
| 4564 | 4564 | } |
| 4565 | 4565 | } |
| 4566 | 4566 | |
| 4567 | - if ( !$saved_post_id > 0 ) {
|
|
| 4567 | + if (!$saved_post_id > 0) {
|
|
| 4568 | 4568 | $invalid++; |
| 4569 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
| 4569 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_wp_error); |
|
| 4570 | 4570 | } |
| 4571 | - } else if ( $import_choice == 'skip' ) {
|
|
| 4572 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4571 | + } else if ($import_choice == 'skip') {
|
|
| 4572 | + if ($post_id > 0 && get_post($post_id)) {
|
|
| 4573 | 4573 | $skipped++; |
| 4574 | 4574 | } else {
|
| 4575 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4576 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4575 | + if ($saved_post_id = wp_insert_post($save_post, true)) {
|
|
| 4576 | + if (is_wp_error($saved_post_id)) {
|
|
| 4577 | 4577 | $invalid++; |
| 4578 | 4578 | |
| 4579 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
| 4579 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$saved_post_id->get_error_message().' '.$wp_chars_error); |
|
| 4580 | 4580 | $saved_post_id = 0; |
| 4581 | 4581 | } else {
|
| 4582 | 4582 | $created++; |
@@ -4584,28 +4584,28 @@ discard block |
||
| 4584 | 4584 | } else {
|
| 4585 | 4585 | $invalid++; |
| 4586 | 4586 | |
| 4587 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4587 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$wp_chars_error); |
|
| 4588 | 4588 | } |
| 4589 | 4589 | } |
| 4590 | 4590 | } else {
|
| 4591 | 4591 | $invalid++; |
| 4592 | 4592 | |
| 4593 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4593 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$wp_chars_error); |
|
| 4594 | 4594 | } |
| 4595 | 4595 | |
| 4596 | - if ( (int)$saved_post_id > 0 ) {
|
|
| 4596 | + if ((int) $saved_post_id > 0) {
|
|
| 4597 | 4597 | // WPML |
| 4598 | 4598 | if ($is_wpml && $original_post_id > 0 && $language != '') {
|
| 4599 | - $wpml_post_type = 'post_' . $post_type; |
|
| 4600 | - $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 4599 | + $wpml_post_type = 'post_'.$post_type; |
|
| 4600 | + $source_language = geodir_get_language_for_element($original_post_id, $wpml_post_type); |
|
| 4601 | 4601 | $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
| 4602 | 4602 | |
| 4603 | - $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 4603 | + $trid = $sitepress->get_element_trid($original_post_id, $wpml_post_type); |
|
| 4604 | 4604 | |
| 4605 | - $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 4605 | + $sitepress->set_element_language_details($saved_post_id, $wpml_post_type, $trid, $language, $source_language); |
|
| 4606 | 4606 | } |
| 4607 | 4607 | // WPML |
| 4608 | - $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 4608 | + $gd_post_info = geodir_get_post_info($saved_post_id); |
|
| 4609 | 4609 | |
| 4610 | 4610 | $gd_post['post_id'] = $saved_post_id; |
| 4611 | 4611 | $gd_post['ID'] = $saved_post_id; |
@@ -4617,7 +4617,7 @@ discard block |
||
| 4617 | 4617 | |
| 4618 | 4618 | // post location |
| 4619 | 4619 | $post_location_id = 0; |
| 4620 | - if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 4620 | + if ($location_allowed && !empty($location_result) && $location_result->location_id > 0) {
|
|
| 4621 | 4621 | $gd_post['post_neighbourhood'] = ''; |
| 4622 | 4622 | |
| 4623 | 4623 | $post_location_info = array( |
@@ -4627,7 +4627,7 @@ discard block |
||
| 4627 | 4627 | 'geo_lat' => $post_latitude, |
| 4628 | 4628 | 'geo_lng' => $post_longitude |
| 4629 | 4629 | ); |
| 4630 | - if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 4630 | + if ($location_id = (int) geodir_add_new_location($post_location_info)) {
|
|
| 4631 | 4631 | $post_location_id = $location_id; |
| 4632 | 4632 | } |
| 4633 | 4633 | |
@@ -4665,14 +4665,14 @@ discard block |
||
| 4665 | 4665 | $gd_post['post_location_id'] = $post_location_id; |
| 4666 | 4666 | |
| 4667 | 4667 | // post package info |
| 4668 | - $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 4668 | + $package_id = isset($gd_post['package_id']) && !empty($gd_post['package_id']) ? (int) $gd_post['package_id'] : 0; |
|
| 4669 | 4669 | if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
| 4670 | 4670 | $package_id = $gd_post_info->package_id; |
| 4671 | 4671 | } |
| 4672 | 4672 | |
| 4673 | 4673 | $package_info = array(); |
| 4674 | 4674 | if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
| 4675 | - $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 4675 | + $package_info = (array) geodir_get_package_info_by_id($package_id); |
|
| 4676 | 4676 | |
| 4677 | 4677 | if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
| 4678 | 4678 | $package_info = array(); |
@@ -4680,18 +4680,18 @@ discard block |
||
| 4680 | 4680 | } |
| 4681 | 4681 | |
| 4682 | 4682 | if (empty($package_info)) {
|
| 4683 | - $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 4683 | + $package_info = (array) geodir_post_package_info(array(), '', $post_type); |
|
| 4684 | 4684 | } |
| 4685 | 4685 | |
| 4686 | - if (!empty($package_info)) {
|
|
| 4686 | + if (!empty($package_info)) {
|
|
| 4687 | 4687 | $package_id = $package_info['pid']; |
| 4688 | 4688 | |
| 4689 | 4689 | if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
| 4690 | 4690 | $gd_post['expire_date'] = $expire_date; |
| 4691 | 4691 | } else {
|
| 4692 | - if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 4693 | - $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 4694 | - $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 4692 | + if (isset($package_info['days']) && (int) $package_info['days'] > 0) {
|
|
| 4693 | + $gd_post['alive_days'] = (int) $package_info['days']; |
|
| 4694 | + $gd_post['expire_date'] = date_i18n('Y-m-d', strtotime($current_date.'+'.(int) $package_info['days'].' days'));
|
|
| 4695 | 4695 | } else {
|
| 4696 | 4696 | $gd_post['expire_date'] = 'Never'; |
| 4697 | 4697 | } |
@@ -4700,7 +4700,7 @@ discard block |
||
| 4700 | 4700 | $gd_post['package_id'] = $package_id; |
| 4701 | 4701 | } |
| 4702 | 4702 | |
| 4703 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 4703 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 4704 | 4704 | |
| 4705 | 4705 | if ($post_type == 'gd_event') {
|
| 4706 | 4706 | $gd_post = geodir_imex_process_event_data($gd_post); |
@@ -4711,28 +4711,28 @@ discard block |
||
| 4711 | 4711 | } |
| 4712 | 4712 | |
| 4713 | 4713 | // Export franchise fields |
| 4714 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 4714 | + $is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
|
|
| 4715 | 4715 | if ($is_franchise_active) {
|
| 4716 | - if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 4716 | + if (isset($gd_post['gd_is_franchise']) && (int) $gd_post['gd_is_franchise'] == 1) {
|
|
| 4717 | 4717 | $gd_franchise_lock = array(); |
| 4718 | 4718 | |
| 4719 | - if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 4720 | - $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 4721 | - $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 4722 | - $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 4719 | + if (isset($gd_post['gd_franchise_lock'])) {
|
|
| 4720 | + $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock']);
|
|
| 4721 | + $gd_franchise_lock = trim($gd_franchise_lock); |
|
| 4722 | + $gd_franchise_lock = explode(",", $gd_franchise_lock);
|
|
| 4723 | 4723 | } |
| 4724 | 4724 | |
| 4725 | - update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 4726 | - update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 4725 | + update_post_meta($saved_post_id, 'gd_is_franchise', 1); |
|
| 4726 | + update_post_meta($saved_post_id, 'gd_franchise_lock', $gd_franchise_lock); |
|
| 4727 | 4727 | } else {
|
| 4728 | - if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 4729 | - geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 4728 | + if (isset($gd_post['franchise']) && (int) $gd_post['franchise'] > 0 && geodir_franchise_check((int) $gd_post['franchise'])) {
|
|
| 4729 | + geodir_save_post_meta($saved_post_id, 'franchise', (int) $gd_post['franchise']); |
|
| 4730 | 4730 | } |
| 4731 | 4731 | } |
| 4732 | 4732 | } |
| 4733 | 4733 | |
| 4734 | 4734 | if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
| 4735 | - $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 4735 | + $save_post['post_category'] = array_unique(array_map('intval', $save_post['post_category']));
|
|
| 4736 | 4736 | if ($default_category_id) {
|
| 4737 | 4737 | $save_post['post_default_category'] = $default_category_id; |
| 4738 | 4738 | $gd_post['default_category'] = $default_category_id; |
@@ -4741,34 +4741,34 @@ discard block |
||
| 4741 | 4741 | } |
| 4742 | 4742 | |
| 4743 | 4743 | // Save post info |
| 4744 | - geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 4744 | + geodir_save_post_info($saved_post_id, $gd_post); |
|
| 4745 | 4745 | // post taxonomies |
| 4746 | - if ( !empty( $save_post['post_category'] ) ) {
|
|
| 4747 | - wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 4746 | + if (!empty($save_post['post_category'])) {
|
|
| 4747 | + wp_set_object_terms($saved_post_id, $save_post['post_category'], $cat_taxonomy); |
|
| 4748 | 4748 | |
| 4749 | - $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 4749 | + $post_default_category = isset($save_post['post_default_category']) ? $save_post['post_default_category'] : ''; |
|
| 4750 | 4750 | if ($default_category_id) {
|
| 4751 | 4751 | $post_default_category = $default_category_id; |
| 4752 | 4752 | } |
| 4753 | 4753 | $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
| 4754 | 4754 | $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
| 4755 | - $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 4755 | + $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']).',y:' : '';
|
|
| 4756 | 4756 | |
| 4757 | 4757 | if ($post_category_str != '' && $post_default_category) {
|
| 4758 | - $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 4758 | + $post_category_str = str_replace($post_default_category.',y:', $post_default_category.',y,d:', $post_category_str); |
|
| 4759 | 4759 | } |
| 4760 | 4760 | |
| 4761 | 4761 | $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
| 4762 | 4762 | |
| 4763 | - geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 4763 | + geodir_set_postcat_structure($saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str); |
|
| 4764 | 4764 | } |
| 4765 | 4765 | |
| 4766 | - if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 4767 | - wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 4766 | + if (!empty($save_post['post_tags'])) {
|
|
| 4767 | + wp_set_object_terms($saved_post_id, $save_post['post_tags'], $tags_taxonomy); |
|
| 4768 | 4768 | } |
| 4769 | 4769 | |
| 4770 | 4770 | // Post images |
| 4771 | - if ( !empty( $post_images ) ) {
|
|
| 4771 | + if (!empty($post_images)) {
|
|
| 4772 | 4772 | $post_images = array_unique($post_images); |
| 4773 | 4773 | |
| 4774 | 4774 | $old_post_images_arr = array(); |
@@ -4776,82 +4776,82 @@ discard block |
||
| 4776 | 4776 | |
| 4777 | 4777 | $order = 1; |
| 4778 | 4778 | |
| 4779 | - $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 4779 | + $old_post_images = geodir_get_images($saved_post_id); |
|
| 4780 | 4780 | if (!empty($old_post_images)) {
|
| 4781 | - foreach( $old_post_images as $old_post_image ) {
|
|
| 4781 | + foreach ($old_post_images as $old_post_image) {
|
|
| 4782 | 4782 | if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
| 4783 | 4783 | $old_post_images_arr[] = $old_post_image->file; |
| 4784 | 4784 | } |
| 4785 | 4785 | } |
| 4786 | 4786 | } |
| 4787 | 4787 | |
| 4788 | - foreach ( $post_images as $post_image ) {
|
|
| 4789 | - $image_name = basename( $post_image ); |
|
| 4788 | + foreach ($post_images as $post_image) {
|
|
| 4789 | + $image_name = basename($post_image); |
|
| 4790 | 4790 | $saved_post_images_arr[] = $image_name; |
| 4791 | 4791 | |
| 4792 | - if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 4792 | + if (!empty($old_post_images_arr) && in_array($image_name, $old_post_images_arr)) {
|
|
| 4793 | 4793 | continue; // Skip if image already exists. |
| 4794 | 4794 | } |
| 4795 | 4795 | |
| 4796 | - $image_name_parts = explode( '.', $image_name ); |
|
| 4797 | - array_pop( $image_name_parts ); |
|
| 4798 | - $proper_image_name = implode( '.', $image_name_parts ); |
|
| 4796 | + $image_name_parts = explode('.', $image_name);
|
|
| 4797 | + array_pop($image_name_parts); |
|
| 4798 | + $proper_image_name = implode('.', $image_name_parts);
|
|
| 4799 | 4799 | |
| 4800 | - $arr_file_type = wp_check_filetype( $image_name ); |
|
| 4800 | + $arr_file_type = wp_check_filetype($image_name); |
|
| 4801 | 4801 | |
| 4802 | - if ( !empty( $arr_file_type ) ) {
|
|
| 4802 | + if (!empty($arr_file_type)) {
|
|
| 4803 | 4803 | $uploaded_file_type = $arr_file_type['type']; |
| 4804 | 4804 | |
| 4805 | 4805 | $attachment = array(); |
| 4806 | 4806 | $attachment['post_id'] = $saved_post_id; |
| 4807 | 4807 | $attachment['title'] = $proper_image_name; |
| 4808 | 4808 | $attachment['content'] = ''; |
| 4809 | - $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 4809 | + $attachment['file'] = $uploads_subdir.'/'.$image_name; |
|
| 4810 | 4810 | $attachment['mime_type'] = $uploaded_file_type; |
| 4811 | 4811 | $attachment['menu_order'] = $order; |
| 4812 | 4812 | $attachment['is_featured'] = 0; |
| 4813 | 4813 | |
| 4814 | 4814 | $attachment_set = ''; |
| 4815 | - foreach ( $attachment as $key => $val ) {
|
|
| 4816 | - if ( $val != '' ) {
|
|
| 4817 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 4815 | + foreach ($attachment as $key => $val) {
|
|
| 4816 | + if ($val != '') {
|
|
| 4817 | + $attachment_set .= $key." = '".$val."', "; |
|
| 4818 | 4818 | } |
| 4819 | 4819 | } |
| 4820 | - $attachment_set = trim( $attachment_set, ", " ); |
|
| 4820 | + $attachment_set = trim($attachment_set, ", "); |
|
| 4821 | 4821 | |
| 4822 | 4822 | // Add new attachment |
| 4823 | - $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 4823 | + $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
|
|
| 4824 | 4824 | |
| 4825 | 4825 | $order++; |
| 4826 | 4826 | } |
| 4827 | 4827 | } |
| 4828 | 4828 | |
| 4829 | - $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 4829 | + $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/".implode("' AND file NOT LIKE '%/", $saved_post_images_arr)."' )" : '';
|
|
| 4830 | 4830 | // Remove previous attachment |
| 4831 | - $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 4831 | + $wpdb->query("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id = ".(int) $saved_post_id." ".$saved_post_images_sql);
|
|
| 4832 | 4832 | |
| 4833 | - if ( !empty( $saved_post_images_arr ) ) {
|
|
| 4833 | + if (!empty($saved_post_images_arr)) {
|
|
| 4834 | 4834 | $menu_order = 1; |
| 4835 | 4835 | |
| 4836 | - foreach ( $saved_post_images_arr as $img_name ) {
|
|
| 4837 | - $wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) ); |
|
| 4836 | + foreach ($saved_post_images_arr as $img_name) {
|
|
| 4837 | + $wpdb->query($wpdb->prepare("UPDATE ".GEODIR_ATTACHMENT_TABLE." SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array($menu_order, $saved_post_id, '%/'.$img_name)));
|
|
| 4838 | 4838 | |
| 4839 | - if( $menu_order == 1 ) {
|
|
| 4840 | - if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
|
|
| 4841 | - $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) ); |
|
| 4839 | + if ($menu_order == 1) {
|
|
| 4840 | + if ($featured_image = $wpdb->get_var($wpdb->prepare("SELECT file FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id =%d AND file LIKE %s", array($saved_post_id, '%/'.$img_name)))) {
|
|
| 4841 | + $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s WHERE post_id =%d", array($featured_image, $saved_post_id)));
|
|
| 4842 | 4842 | } |
| 4843 | 4843 | } |
| 4844 | 4844 | $menu_order++; |
| 4845 | 4845 | } |
| 4846 | 4846 | } |
| 4847 | 4847 | |
| 4848 | - if ( $order > 1 ) {
|
|
| 4848 | + if ($order > 1) {
|
|
| 4849 | 4849 | $images++; |
| 4850 | 4850 | } |
| 4851 | 4851 | } |
| 4852 | 4852 | |
| 4853 | 4853 | /** This action is documented in geodirectory-functions/post-functions.php */ |
| 4854 | - do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 4854 | + do_action('geodir_after_save_listing', $saved_post_id, $gd_post);
|
|
| 4855 | 4855 | |
| 4856 | 4856 | if (isset($is_featured)) {
|
| 4857 | 4857 | geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
@@ -4871,10 +4871,10 @@ discard block |
||
| 4871 | 4871 | } |
| 4872 | 4872 | |
| 4873 | 4873 | //undo some stuff to make the import quicker |
| 4874 | - wp_defer_term_counting( false ); |
|
| 4875 | - wp_defer_comment_counting( false ); |
|
| 4876 | - $wpdb->query( 'COMMIT;' ); |
|
| 4877 | - $wpdb->query( 'SET autocommit = 1;' ); |
|
| 4874 | + wp_defer_term_counting(false); |
|
| 4875 | + wp_defer_comment_counting(false); |
|
| 4876 | + $wpdb->query('COMMIT;');
|
|
| 4877 | + $wpdb->query('SET autocommit = 1;');
|
|
| 4878 | 4878 | |
| 4879 | 4879 | $json = array(); |
| 4880 | 4880 | $json['processed'] = $processed_actual; |
@@ -4885,9 +4885,9 @@ discard block |
||
| 4885 | 4885 | $json['invalid_addr'] = $invalid_addr; |
| 4886 | 4886 | $json['images'] = $images; |
| 4887 | 4887 | |
| 4888 | - wp_send_json( $json ); |
|
| 4888 | + wp_send_json($json); |
|
| 4889 | 4889 | exit; |
| 4890 | - } else if ( $task == 'import_loc' ) {
|
|
| 4890 | + } else if ($task == 'import_loc') {
|
|
| 4891 | 4891 | global $gd_post_types; |
| 4892 | 4892 | $gd_post_types = $post_types; |
| 4893 | 4893 | |
@@ -4896,82 +4896,82 @@ discard block |
||
| 4896 | 4896 | |
| 4897 | 4897 | if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
| 4898 | 4898 | $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
| 4899 | - wp_send_json( $json ); |
|
| 4899 | + wp_send_json($json); |
|
| 4900 | 4900 | } |
| 4901 | 4901 | |
| 4902 | 4902 | $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
|
| 4903 | - $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
| 4903 | + $gd_error_location = __('Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory');
|
|
| 4904 | 4904 | for ($i = 1; $i <= $limit; $i++) {
|
| 4905 | 4905 | $index = $processed + $i; |
| 4906 | 4906 | |
| 4907 | 4907 | if (isset($file[$index])) {
|
| 4908 | 4908 | $row = $file[$index]; |
| 4909 | - $row = array_map( 'trim', $row ); |
|
| 4909 | + $row = array_map('trim', $row);
|
|
| 4910 | 4910 | $data = array(); |
| 4911 | 4911 | |
| 4912 | - foreach ($columns as $c => $column ) {
|
|
| 4912 | + foreach ($columns as $c => $column) {
|
|
| 4913 | 4913 | if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta', 'city_desc', 'region_meta', 'region_desc', 'country_meta', 'country_desc'))) {
|
| 4914 | 4914 | $data[$column] = $row[$c]; |
| 4915 | 4915 | } |
| 4916 | 4916 | } |
| 4917 | 4917 | |
| 4918 | - if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 4918 | + if (empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude'])) {
|
|
| 4919 | 4919 | $invalid++; |
| 4920 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4920 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location); |
|
| 4921 | 4921 | continue; |
| 4922 | 4922 | } |
| 4923 | 4923 | |
| 4924 | 4924 | $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
| 4925 | 4925 | |
| 4926 | - if ( $import_choice == 'update' ) {
|
|
| 4927 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4928 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4926 | + if ($import_choice == 'update') {
|
|
| 4927 | + if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
|
|
| 4928 | + if ($location_id = geodir_location_update_city($data, true, $location)) {
|
|
| 4929 | 4929 | $updated++; |
| 4930 | 4930 | } else {
|
| 4931 | 4931 | $invalid++; |
| 4932 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4932 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location); |
|
| 4933 | 4933 | } |
| 4934 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4935 | - $data['location_id'] = (int)$location->location_id; |
|
| 4934 | + } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
|
|
| 4935 | + $data['location_id'] = (int) $location->location_id; |
|
| 4936 | 4936 | |
| 4937 | - if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 4938 | - $data['location_id'] = (int)$location->location_id; |
|
| 4939 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 4940 | - $data['location_id'] = (int)$location->location_id; |
|
| 4941 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 4942 | - $data['location_id'] = (int)$location->location_id; |
|
| 4937 | + if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region']))) {
|
|
| 4938 | + $data['location_id'] = (int) $location->location_id; |
|
| 4939 | + } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'region' => $data['region']))) {
|
|
| 4940 | + $data['location_id'] = (int) $location->location_id; |
|
| 4941 | + } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country']))) {
|
|
| 4942 | + $data['location_id'] = (int) $location->location_id; |
|
| 4943 | 4943 | } |
| 4944 | 4944 | |
| 4945 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4945 | + if ($location_id = geodir_location_update_city($data, true, $location)) {
|
|
| 4946 | 4946 | $updated++; |
| 4947 | 4947 | } else {
|
| 4948 | 4948 | $invalid++; |
| 4949 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4949 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location); |
|
| 4950 | 4950 | } |
| 4951 | 4951 | } else {
|
| 4952 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4952 | + if ($location_id = geodir_location_insert_city($data, true)) {
|
|
| 4953 | 4953 | $created++; |
| 4954 | 4954 | } else {
|
| 4955 | 4955 | $invalid++; |
| 4956 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4956 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location); |
|
| 4957 | 4957 | } |
| 4958 | 4958 | } |
| 4959 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 4960 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4959 | + } elseif ($import_choice == 'skip') {
|
|
| 4960 | + if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
|
|
| 4961 | 4961 | $skipped++; |
| 4962 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4962 | + } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
|
|
| 4963 | 4963 | $skipped++; |
| 4964 | 4964 | } else {
|
| 4965 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4965 | + if ($location_id = geodir_location_insert_city($data, true)) {
|
|
| 4966 | 4966 | $created++; |
| 4967 | 4967 | } else {
|
| 4968 | 4968 | $invalid++; |
| 4969 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4969 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location); |
|
| 4970 | 4970 | } |
| 4971 | 4971 | } |
| 4972 | 4972 | } else {
|
| 4973 | 4973 | $invalid++; |
| 4974 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4974 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location); |
|
| 4975 | 4975 | } |
| 4976 | 4976 | } |
| 4977 | 4977 | } |
@@ -4985,24 +4985,24 @@ discard block |
||
| 4985 | 4985 | $json['invalid'] = $invalid; |
| 4986 | 4986 | $json['images'] = $images; |
| 4987 | 4987 | |
| 4988 | - wp_send_json( $json ); |
|
| 4989 | - } else if ( $task == 'import_hood' ) {
|
|
| 4988 | + wp_send_json($json); |
|
| 4989 | + } else if ($task == 'import_hood') {
|
|
| 4990 | 4990 | if (!empty($file)) {
|
| 4991 | 4991 | $columns = isset($file[0]) ? $file[0] : NULL; |
| 4992 | 4992 | |
| 4993 | 4993 | if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
| 4994 | 4994 | $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
| 4995 | - wp_send_json( $json ); |
|
| 4995 | + wp_send_json($json); |
|
| 4996 | 4996 | } |
| 4997 | 4997 | |
| 4998 | 4998 | $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
|
| 4999 | - $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' ); |
|
| 4999 | + $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');
|
|
| 5000 | 5000 | for ($i = 1; $i <= $limit; $i++) {
|
| 5001 | 5001 | $index = $processed + $i; |
| 5002 | 5002 | |
| 5003 | 5003 | if (isset($file[$index])) {
|
| 5004 | 5004 | $row = $file[$index]; |
| 5005 | - $row = array_map( 'trim', $row ); |
|
| 5005 | + $row = array_map('trim', $row);
|
|
| 5006 | 5006 | $data = array(); |
| 5007 | 5007 | |
| 5008 | 5008 | foreach ($columns as $c => $column) {
|
@@ -5013,20 +5013,20 @@ discard block |
||
| 5013 | 5013 | |
| 5014 | 5014 | if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
|
| 5015 | 5015 | $invalid++; |
| 5016 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5016 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood); |
|
| 5017 | 5017 | continue; |
| 5018 | 5018 | } |
| 5019 | 5019 | |
| 5020 | 5020 | $location_info = array(); |
| 5021 | - if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
|
|
| 5022 | - $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
|
|
| 5021 | + if (!empty($data['location_id']) && (int) $data['location_id'] > 0) {
|
|
| 5022 | + $location_info = geodir_get_location_by_id('', (int) $data['location_id']);
|
|
| 5023 | 5023 | } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
|
| 5024 | 5024 | $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
|
| 5025 | 5025 | } |
| 5026 | 5026 | |
| 5027 | 5027 | if (empty($location_info)) {
|
| 5028 | 5028 | $invalid++; |
| 5029 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5029 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood); |
|
| 5030 | 5030 | continue; |
| 5031 | 5031 | } |
| 5032 | 5032 | |
@@ -5041,35 +5041,35 @@ discard block |
||
| 5041 | 5041 | $hood_data['hood_longitude'] = $data['longitude']; |
| 5042 | 5042 | $hood_data['hood_location_id'] = $location_id; |
| 5043 | 5043 | |
| 5044 | - if ( $import_choice == 'update' ) {
|
|
| 5045 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 5046 | - $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
| 5044 | + if ($import_choice == 'update') {
|
|
| 5045 | + if ((int) $data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int) $data['neighbourhood_id']))) {
|
|
| 5046 | + $hood_data['hood_id'] = (int) $data['neighbourhood_id']; |
|
| 5047 | 5047 | |
| 5048 | 5048 | if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
| 5049 | 5049 | $updated++; |
| 5050 | 5050 | } else {
|
| 5051 | 5051 | $invalid++; |
| 5052 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5052 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood); |
|
| 5053 | 5053 | } |
| 5054 | 5054 | } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
| 5055 | - $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
| 5055 | + $hood_data['hood_id'] = (int) $neighbourhood->hood_id; |
|
| 5056 | 5056 | |
| 5057 | 5057 | if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
| 5058 | 5058 | $updated++; |
| 5059 | 5059 | } else {
|
| 5060 | 5060 | $invalid++; |
| 5061 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5061 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood); |
|
| 5062 | 5062 | } |
| 5063 | 5063 | } else {
|
| 5064 | 5064 | if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
| 5065 | 5065 | $created++; |
| 5066 | 5066 | } else {
|
| 5067 | 5067 | $invalid++; |
| 5068 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5068 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood); |
|
| 5069 | 5069 | } |
| 5070 | 5070 | } |
| 5071 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 5072 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 5071 | + } elseif ($import_choice == 'skip') {
|
|
| 5072 | + if ((int) $data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int) $data['neighbourhood_id']))) {
|
|
| 5073 | 5073 | $skipped++; |
| 5074 | 5074 | } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
| 5075 | 5075 | $skipped++; |
@@ -5079,12 +5079,12 @@ discard block |
||
| 5079 | 5079 | $created++; |
| 5080 | 5080 | } else {
|
| 5081 | 5081 | $invalid++; |
| 5082 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5082 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood); |
|
| 5083 | 5083 | } |
| 5084 | 5084 | } |
| 5085 | 5085 | } else {
|
| 5086 | 5086 | $invalid++; |
| 5087 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5087 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood); |
|
| 5088 | 5088 | } |
| 5089 | 5089 | } |
| 5090 | 5090 | } |
@@ -5098,7 +5098,7 @@ discard block |
||
| 5098 | 5098 | $json['invalid'] = $invalid; |
| 5099 | 5099 | $json['images'] = $images; |
| 5100 | 5100 | |
| 5101 | - wp_send_json( $json ); |
|
| 5101 | + wp_send_json($json); |
|
| 5102 | 5102 | } |
| 5103 | 5103 | } |
| 5104 | 5104 | break; |
@@ -5142,29 +5142,29 @@ discard block |
||
| 5142 | 5142 | * } |
| 5143 | 5143 | * @return int|bool Term id when success, false when fail. |
| 5144 | 5144 | */ |
| 5145 | -function geodir_imex_insert_term( $taxonomy, $term_data ) {
|
|
| 5146 | - if ( empty( $taxonomy ) || empty( $term_data ) ) {
|
|
| 5145 | +function geodir_imex_insert_term($taxonomy, $term_data) {
|
|
| 5146 | + if (empty($taxonomy) || empty($term_data)) {
|
|
| 5147 | 5147 | return false; |
| 5148 | 5148 | } |
| 5149 | 5149 | |
| 5150 | - $term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : ''; |
|
| 5150 | + $term = isset($term_data['name']) && !empty($term_data['name']) ? $term_data['name'] : ''; |
|
| 5151 | 5151 | $args = array(); |
| 5152 | - $args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : ''; |
|
| 5153 | - $args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : ''; |
|
| 5154 | - $args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : ''; |
|
| 5152 | + $args['description'] = isset($term_data['description']) ? $term_data['description'] : ''; |
|
| 5153 | + $args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : ''; |
|
| 5154 | + $args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : ''; |
|
| 5155 | 5155 | |
| 5156 | - if ( ( !empty( $args['slug'] ) && term_exists( $args['slug'], $taxonomy ) ) || empty( $args['slug'] ) ) {
|
|
| 5157 | - $term_args = array_merge( $term_data, $args ); |
|
| 5158 | - $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => ''); |
|
| 5159 | - $term_args = wp_parse_args( $term_args, $defaults ); |
|
| 5160 | - $term_args = sanitize_term( $term_args, $taxonomy, 'db' ); |
|
| 5161 | - $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
|
| 5156 | + if ((!empty($args['slug']) && term_exists($args['slug'], $taxonomy)) || empty($args['slug'])) {
|
|
| 5157 | + $term_args = array_merge($term_data, $args); |
|
| 5158 | + $defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
|
|
| 5159 | + $term_args = wp_parse_args($term_args, $defaults); |
|
| 5160 | + $term_args = sanitize_term($term_args, $taxonomy, 'db'); |
|
| 5161 | + $args['slug'] = wp_unique_term_slug($args['slug'], (object) $term_args); |
|
| 5162 | 5162 | } |
| 5163 | 5163 | |
| 5164 | - if( !empty( $term ) ) {
|
|
| 5165 | - $result = wp_insert_term( $term, $taxonomy, $args ); |
|
| 5166 | - if( !is_wp_error( $result ) ) {
|
|
| 5167 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5164 | + if (!empty($term)) {
|
|
| 5165 | + $result = wp_insert_term($term, $taxonomy, $args); |
|
| 5166 | + if (!is_wp_error($result)) {
|
|
| 5167 | + return isset($result['term_id']) ? $result['term_id'] : 0; |
|
| 5168 | 5168 | } |
| 5169 | 5169 | } |
| 5170 | 5170 | |
@@ -5194,36 +5194,36 @@ discard block |
||
| 5194 | 5194 | * } |
| 5195 | 5195 | * @return int|bool Term id when success, false when fail. |
| 5196 | 5196 | */ |
| 5197 | -function geodir_imex_update_term( $taxonomy, $term_data ) {
|
|
| 5198 | - if ( empty( $taxonomy ) || empty( $term_data ) ) {
|
|
| 5197 | +function geodir_imex_update_term($taxonomy, $term_data) {
|
|
| 5198 | + if (empty($taxonomy) || empty($term_data)) {
|
|
| 5199 | 5199 | return false; |
| 5200 | 5200 | } |
| 5201 | 5201 | |
| 5202 | - $term_id = isset( $term_data['term_id'] ) && !empty( $term_data['term_id'] ) ? $term_data['term_id'] : 0; |
|
| 5202 | + $term_id = isset($term_data['term_id']) && !empty($term_data['term_id']) ? $term_data['term_id'] : 0; |
|
| 5203 | 5203 | |
| 5204 | 5204 | $args = array(); |
| 5205 | - $args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : ''; |
|
| 5206 | - $args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : ''; |
|
| 5207 | - $args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : ''; |
|
| 5205 | + $args['description'] = isset($term_data['description']) ? $term_data['description'] : ''; |
|
| 5206 | + $args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : ''; |
|
| 5207 | + $args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : ''; |
|
| 5208 | 5208 | |
| 5209 | - if ( $term_id > 0 && $term_info = (array)get_term( $term_id, $taxonomy ) ) {
|
|
| 5209 | + if ($term_id > 0 && $term_info = (array) get_term($term_id, $taxonomy)) {
|
|
| 5210 | 5210 | $term_data['term_id'] = $term_info['term_id']; |
| 5211 | 5211 | |
| 5212 | - $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
|
| 5212 | + $result = wp_update_term($term_data['term_id'], $taxonomy, $term_data); |
|
| 5213 | 5213 | |
| 5214 | - if( !is_wp_error( $result ) ) {
|
|
| 5215 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5214 | + if (!is_wp_error($result)) {
|
|
| 5215 | + return isset($result['term_id']) ? $result['term_id'] : 0; |
|
| 5216 | 5216 | } |
| 5217 | - } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5217 | + } else if ($term_data['slug'] != '' && $term_info = (array) term_exists($term_data['slug'], $taxonomy)) {
|
|
| 5218 | 5218 | $term_data['term_id'] = $term_info['term_id']; |
| 5219 | 5219 | |
| 5220 | - $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
|
| 5220 | + $result = wp_update_term($term_data['term_id'], $taxonomy, $term_data); |
|
| 5221 | 5221 | |
| 5222 | - if( !is_wp_error( $result ) ) {
|
|
| 5223 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5222 | + if (!is_wp_error($result)) {
|
|
| 5223 | + return isset($result['term_id']) ? $result['term_id'] : 0; |
|
| 5224 | 5224 | } |
| 5225 | 5225 | } else {
|
| 5226 | - return geodir_imex_insert_term( $taxonomy, $term_data ); |
|
| 5226 | + return geodir_imex_insert_term($taxonomy, $term_data); |
|
| 5227 | 5227 | } |
| 5228 | 5228 | |
| 5229 | 5229 | return false; |
@@ -5241,25 +5241,25 @@ discard block |
||
| 5241 | 5241 | * @param string $post_type Post type. |
| 5242 | 5242 | * @return int Posts count. |
| 5243 | 5243 | */ |
| 5244 | -function geodir_get_posts_count( $post_type ) {
|
|
| 5244 | +function geodir_get_posts_count($post_type) {
|
|
| 5245 | 5245 | global $wpdb, $plugin_prefix; |
| 5246 | 5246 | |
| 5247 | - if ( !post_type_exists( $post_type ) ) {
|
|
| 5247 | + if (!post_type_exists($post_type)) {
|
|
| 5248 | 5248 | return 0; |
| 5249 | 5249 | } |
| 5250 | 5250 | |
| 5251 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5251 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 5252 | 5252 | |
| 5253 | 5253 | // Skip listing with statuses trash, auto-draft etc... |
| 5254 | 5254 | $skip_statuses = geodir_imex_export_skip_statuses(); |
| 5255 | 5255 | $where_statuses = ''; |
| 5256 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5257 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5256 | + if (!empty($skip_statuses) && is_array($skip_statuses)) {
|
|
| 5257 | + $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
|
|
| 5258 | 5258 | } |
| 5259 | 5259 | |
| 5260 | - $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 );
|
|
| 5260 | + $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);
|
|
| 5261 | 5261 | |
| 5262 | - $posts_count = (int)$wpdb->get_var( $query ); |
|
| 5262 | + $posts_count = (int) $wpdb->get_var($query); |
|
| 5263 | 5263 | |
| 5264 | 5264 | /** |
| 5265 | 5265 | * Modify returned post counts for the current post type. |
@@ -5270,7 +5270,7 @@ discard block |
||
| 5270 | 5270 | * @param int $posts_count Post counts. |
| 5271 | 5271 | * @param string $post_type Post type. |
| 5272 | 5272 | */ |
| 5273 | - $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5273 | + $posts_count = apply_filters('geodir_imex_count_posts', $posts_count, $post_type);
|
|
| 5274 | 5274 | |
| 5275 | 5275 | return $posts_count; |
| 5276 | 5276 | } |
@@ -5291,17 +5291,17 @@ discard block |
||
| 5291 | 5291 | * @param int $page_no Page number. Default 0. |
| 5292 | 5292 | * @return array Array of posts data. |
| 5293 | 5293 | */ |
| 5294 | -function geodir_imex_get_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
|
| 5294 | +function geodir_imex_get_posts($post_type, $per_page = 0, $page_no = 0) {
|
|
| 5295 | 5295 | global $wp_filesystem; |
| 5296 | 5296 | |
| 5297 | - $posts = geodir_get_export_posts( $post_type, $per_page, $page_no ); |
|
| 5297 | + $posts = geodir_get_export_posts($post_type, $per_page, $page_no); |
|
| 5298 | 5298 | |
| 5299 | 5299 | $csv_rows = array(); |
| 5300 | 5300 | |
| 5301 | - if ( !empty( $posts ) ) {
|
|
| 5302 | - $is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' ); |
|
| 5301 | + if (!empty($posts)) {
|
|
| 5302 | + $is_payment_plugin = is_plugin_active('geodir_payment_manager/geodir_payment_manager.php');
|
|
| 5303 | 5303 | $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
| 5304 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5304 | + $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
|
|
| 5305 | 5305 | $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
|
| 5306 | 5306 | |
| 5307 | 5307 | $csv_row = array(); |
@@ -5313,7 +5313,7 @@ discard block |
||
| 5313 | 5313 | $csv_row[] = 'default_category'; |
| 5314 | 5314 | $csv_row[] = 'post_tags'; |
| 5315 | 5315 | $csv_row[] = 'post_type'; |
| 5316 | - if ( $post_type == 'gd_event' ) {
|
|
| 5316 | + if ($post_type == 'gd_event') {
|
|
| 5317 | 5317 | $csv_row[] = 'event_date'; |
| 5318 | 5318 | $csv_row[] = 'event_enddate'; |
| 5319 | 5319 | $csv_row[] = 'starttime'; |
@@ -5367,15 +5367,15 @@ discard block |
||
| 5367 | 5367 | } |
| 5368 | 5368 | // WPML |
| 5369 | 5369 | |
| 5370 | - $custom_fields = geodir_imex_get_custom_fields( $post_type ); |
|
| 5371 | - if ( !empty( $custom_fields ) ) {
|
|
| 5372 | - foreach ( $custom_fields as $custom_field ) {
|
|
| 5370 | + $custom_fields = geodir_imex_get_custom_fields($post_type); |
|
| 5371 | + if (!empty($custom_fields)) {
|
|
| 5372 | + foreach ($custom_fields as $custom_field) {
|
|
| 5373 | 5373 | $csv_row[] = $custom_field->htmlvar_name; |
| 5374 | 5374 | } |
| 5375 | 5375 | } |
| 5376 | 5376 | |
| 5377 | 5377 | // Export franchise fields |
| 5378 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 5378 | + $is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
|
|
| 5379 | 5379 | if ($is_franchise_active) {
|
| 5380 | 5380 | $csv_row[] = 'gd_is_franchise'; |
| 5381 | 5381 | $csv_row[] = 'gd_franchise_lock'; |
@@ -5385,28 +5385,28 @@ discard block |
||
| 5385 | 5385 | $csv_rows[] = $csv_row; |
| 5386 | 5386 | |
| 5387 | 5387 | $images_count = 5; |
| 5388 | - $xx=0; |
|
| 5389 | - foreach ( $posts as $post ) {$xx++;
|
|
| 5388 | + $xx = 0; |
|
| 5389 | + foreach ($posts as $post) {$xx++;
|
|
| 5390 | 5390 | $post_id = $post['ID']; |
| 5391 | 5391 | |
| 5392 | - $gd_post_info = geodir_get_post_info( $post_id ); |
|
| 5393 | - $post_info = (array)$gd_post_info; |
|
| 5392 | + $gd_post_info = geodir_get_post_info($post_id); |
|
| 5393 | + $post_info = (array) $gd_post_info; |
|
| 5394 | 5394 | |
| 5395 | - $taxonomy_category = $post_type . 'category'; |
|
| 5396 | - $taxonomy_tags = $post_type . '_tags'; |
|
| 5395 | + $taxonomy_category = $post_type.'category'; |
|
| 5396 | + $taxonomy_tags = $post_type.'_tags'; |
|
| 5397 | 5397 | |
| 5398 | 5398 | $post_category = ''; |
| 5399 | 5399 | $default_category_id = $gd_post_info->default_category; |
| 5400 | 5400 | $default_category = ''; |
| 5401 | 5401 | $post_tags = ''; |
| 5402 | - $terms = wp_get_post_terms( $post_id, array( $taxonomy_category, $taxonomy_tags ) ); |
|
| 5402 | + $terms = wp_get_post_terms($post_id, array($taxonomy_category, $taxonomy_tags)); |
|
| 5403 | 5403 | |
| 5404 | - if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
|
|
| 5404 | + if (!empty($terms) && !is_wp_error($terms)) {
|
|
| 5405 | 5405 | $post_category = array(); |
| 5406 | 5406 | $post_tags = array(); |
| 5407 | 5407 | |
| 5408 | - foreach ( $terms as $term ) {
|
|
| 5409 | - if ( $term->taxonomy == $taxonomy_category ) {
|
|
| 5408 | + foreach ($terms as $term) {
|
|
| 5409 | + if ($term->taxonomy == $taxonomy_category) {
|
|
| 5410 | 5410 | $post_category[] = $term->name; |
| 5411 | 5411 | |
| 5412 | 5412 | if ($default_category_id == $term->term_id) {
|
@@ -5414,7 +5414,7 @@ discard block |
||
| 5414 | 5414 | } |
| 5415 | 5415 | } |
| 5416 | 5416 | |
| 5417 | - if ( $term->taxonomy == $taxonomy_tags ) {
|
|
| 5417 | + if ($term->taxonomy == $taxonomy_tags) {
|
|
| 5418 | 5418 | $post_tags[] = $term->name; |
| 5419 | 5419 | } |
| 5420 | 5420 | } |
@@ -5422,47 +5422,47 @@ discard block |
||
| 5422 | 5422 | if (empty($default_category) && !empty($post_category)) {
|
| 5423 | 5423 | $default_category = $post_category[0]; // Set first one as default category. |
| 5424 | 5424 | } |
| 5425 | - $post_category = !empty( $post_category ) ? implode( ',', $post_category ) : ''; |
|
| 5426 | - $post_tags = !empty( $post_tags ) ? implode( ',', $post_tags ) : ''; |
|
| 5425 | + $post_category = !empty($post_category) ? implode(',', $post_category) : '';
|
|
| 5426 | + $post_tags = !empty($post_tags) ? implode(',', $post_tags) : '';
|
|
| 5427 | 5427 | } |
| 5428 | 5428 | |
| 5429 | 5429 | // Franchise data |
| 5430 | - if ($is_franchise_active && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 && geodir_franchise_check((int)$post_info['franchise'])) {
|
|
| 5430 | + if ($is_franchise_active && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 && geodir_franchise_check((int) $post_info['franchise'])) {
|
|
| 5431 | 5431 | $franchise_id = $post_info['franchise']; |
| 5432 | 5432 | $gd_franchise_info = geodir_get_post_info($franchise_id); |
| 5433 | 5433 | |
| 5434 | 5434 | if (geodir_franchise_pkg_is_active($gd_franchise_info)) {
|
| 5435 | - $franchise_info = (array)$gd_franchise_info; |
|
| 5435 | + $franchise_info = (array) $gd_franchise_info; |
|
| 5436 | 5436 | $locked_fields = geodir_franchise_get_locked_fields($franchise_id, true); |
| 5437 | 5437 | |
| 5438 | 5438 | if (!empty($locked_fields)) {
|
| 5439 | - foreach( $locked_fields as $locked_field) {
|
|
| 5439 | + foreach ($locked_fields as $locked_field) {
|
|
| 5440 | 5440 | if (isset($post_info[$locked_field]) && isset($franchise_info[$locked_field])) {
|
| 5441 | 5441 | $post_info[$locked_field] = $franchise_info[$locked_field]; |
| 5442 | 5442 | } |
| 5443 | 5443 | |
| 5444 | 5444 | if (in_array($taxonomy_category, $locked_fields) || in_array('post_tags', $locked_fields)) {
|
| 5445 | - $franchise_terms = wp_get_post_terms( $franchise_id, array( $taxonomy_category, $taxonomy_tags ) ); |
|
| 5445 | + $franchise_terms = wp_get_post_terms($franchise_id, array($taxonomy_category, $taxonomy_tags)); |
|
| 5446 | 5446 | |
| 5447 | - if ( !empty( $franchise_terms ) && !is_wp_error( $franchise_terms ) ) {
|
|
| 5447 | + if (!empty($franchise_terms) && !is_wp_error($franchise_terms)) {
|
|
| 5448 | 5448 | $franchise_post_category = array(); |
| 5449 | 5449 | $franchise_post_tags = array(); |
| 5450 | 5450 | |
| 5451 | - foreach ( $franchise_terms as $franchise_term ) {
|
|
| 5452 | - if ( $franchise_term->taxonomy == $taxonomy_category ) {
|
|
| 5451 | + foreach ($franchise_terms as $franchise_term) {
|
|
| 5452 | + if ($franchise_term->taxonomy == $taxonomy_category) {
|
|
| 5453 | 5453 | $franchise_post_category[] = $franchise_term->name; |
| 5454 | 5454 | } |
| 5455 | 5455 | |
| 5456 | - if ( $franchise_term->taxonomy == $taxonomy_tags ) {
|
|
| 5456 | + if ($franchise_term->taxonomy == $taxonomy_tags) {
|
|
| 5457 | 5457 | $franchise_post_tags[] = $franchise_term->name; |
| 5458 | 5458 | } |
| 5459 | 5459 | } |
| 5460 | 5460 | |
| 5461 | 5461 | if (in_array($taxonomy_category, $locked_fields)) {
|
| 5462 | - $post_category = !empty( $franchise_post_category ) ? implode( ',', $franchise_post_category ) : ''; |
|
| 5462 | + $post_category = !empty($franchise_post_category) ? implode(',', $franchise_post_category) : '';
|
|
| 5463 | 5463 | } |
| 5464 | 5464 | if (in_array('post_tags', $locked_fields)) {
|
| 5465 | - $post_tags = !empty( $franchise_post_tags ) ? implode( ',', $franchise_post_tags ) : ''; |
|
| 5465 | + $post_tags = !empty($franchise_post_tags) ? implode(',', $franchise_post_tags) : '';
|
|
| 5466 | 5466 | } |
| 5467 | 5467 | } |
| 5468 | 5468 | } |
@@ -5471,18 +5471,18 @@ discard block |
||
| 5471 | 5471 | } |
| 5472 | 5472 | } |
| 5473 | 5473 | |
| 5474 | - $post_images = geodir_get_images( $post_id ); |
|
| 5474 | + $post_images = geodir_get_images($post_id); |
|
| 5475 | 5475 | $current_images = array(); |
| 5476 | - if ( !empty( $post_images ) ) {
|
|
| 5477 | - foreach ( $post_images as $post_image ) {
|
|
| 5478 | - $post_image = (array)$post_image; |
|
| 5479 | - $image = !empty( $post_image ) && isset( $post_image['path'] ) && $wp_filesystem->is_file( $post_image['path'] ) && $wp_filesystem->exists( $post_image['path'] ) ? $post_image['src'] : ''; |
|
| 5480 | - if ( $image ) {
|
|
| 5476 | + if (!empty($post_images)) {
|
|
| 5477 | + foreach ($post_images as $post_image) {
|
|
| 5478 | + $post_image = (array) $post_image; |
|
| 5479 | + $image = !empty($post_image) && isset($post_image['path']) && $wp_filesystem->is_file($post_image['path']) && $wp_filesystem->exists($post_image['path']) ? $post_image['src'] : ''; |
|
| 5480 | + if ($image) {
|
|
| 5481 | 5481 | $current_images[] = $image; |
| 5482 | 5482 | } |
| 5483 | 5483 | } |
| 5484 | 5484 | |
| 5485 | - $images_count = max( $images_count, count( $current_images ) ); |
|
| 5485 | + $images_count = max($images_count, count($current_images)); |
|
| 5486 | 5486 | } |
| 5487 | 5487 | |
| 5488 | 5488 | $csv_row = array(); |
@@ -5494,7 +5494,7 @@ discard block |
||
| 5494 | 5494 | $csv_row[] = $default_category; // default_category |
| 5495 | 5495 | $csv_row[] = $post_tags; // post_tags |
| 5496 | 5496 | $csv_row[] = $post_type; // post_type |
| 5497 | - if ( $post_type == 'gd_event' ) {
|
|
| 5497 | + if ($post_type == 'gd_event') {
|
|
| 5498 | 5498 | $event_data = geodir_imex_get_event_data($post, $gd_post_info); |
| 5499 | 5499 | $csv_row[] = $event_data['event_date']; // event_date |
| 5500 | 5500 | $csv_row[] = $event_data['event_enddate']; // enddate |
@@ -5515,9 +5515,9 @@ discard block |
||
| 5515 | 5515 | $csv_row[] = $event_data['recurring_end_date']; // repeat_end |
| 5516 | 5516 | } |
| 5517 | 5517 | $csv_row[] = $post_info['post_status']; // post_status |
| 5518 | - $csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
|
| 5518 | + $csv_row[] = (int) $post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
|
| 5519 | 5519 | if ($is_payment_plugin) {
|
| 5520 | - $csv_row[] = (int)$post_info['package_id']; // package_id |
|
| 5520 | + $csv_row[] = (int) $post_info['package_id']; // package_id |
|
| 5521 | 5521 | $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
|
| 5522 | 5522 | } |
| 5523 | 5523 | $csv_row[] = $post_info['geodir_video']; // geodir_video |
@@ -5553,14 +5553,14 @@ discard block |
||
| 5553 | 5553 | $csv_row[] = $post_info['geodir_special_offers']; // geodir_special_offers |
| 5554 | 5554 | // WPML |
| 5555 | 5555 | if ($is_wpml) {
|
| 5556 | - $csv_row[] = geodir_get_language_for_element( $post_id, 'post_' . $post_type ); |
|
| 5557 | - $csv_row[] = geodir_imex_original_post_id( $post_id, 'post_' . $post_type ); |
|
| 5556 | + $csv_row[] = geodir_get_language_for_element($post_id, 'post_'.$post_type); |
|
| 5557 | + $csv_row[] = geodir_imex_original_post_id($post_id, 'post_'.$post_type); |
|
| 5558 | 5558 | } |
| 5559 | 5559 | // WPML |
| 5560 | 5560 | |
| 5561 | - if ( !empty( $custom_fields ) ) {
|
|
| 5562 | - foreach ( $custom_fields as $custom_field ) {
|
|
| 5563 | - $csv_row[] = isset( $post_info[$custom_field->htmlvar_name] ) ? $post_info[$custom_field->htmlvar_name] : ''; |
|
| 5561 | + if (!empty($custom_fields)) {
|
|
| 5562 | + foreach ($custom_fields as $custom_field) {
|
|
| 5563 | + $csv_row[] = isset($post_info[$custom_field->htmlvar_name]) ? $post_info[$custom_field->htmlvar_name] : ''; |
|
| 5564 | 5564 | } |
| 5565 | 5565 | } |
| 5566 | 5566 | |
@@ -5571,26 +5571,26 @@ discard block |
||
| 5571 | 5571 | $franchise = ''; |
| 5572 | 5572 | |
| 5573 | 5573 | if (geodir_franchise_pkg_is_active($gd_post_info)) {
|
| 5574 | - $gd_is_franchise = (int)get_post_meta( $post_id, 'gd_is_franchise', true ); |
|
| 5575 | - $locaked_fields = $gd_is_franchise ? get_post_meta( $post_id, 'gd_franchise_lock', true ) : ''; |
|
| 5574 | + $gd_is_franchise = (int) get_post_meta($post_id, 'gd_is_franchise', true); |
|
| 5575 | + $locaked_fields = $gd_is_franchise ? get_post_meta($post_id, 'gd_franchise_lock', true) : ''; |
|
| 5576 | 5576 | $locaked_fields = (is_array($locaked_fields) && !empty($locaked_fields) ? implode(",", $locaked_fields) : '');
|
| 5577 | - $franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 ? (int)$post_info['franchise'] : 0; // franchise id |
|
| 5577 | + $franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 ? (int) $post_info['franchise'] : 0; // franchise id |
|
| 5578 | 5578 | } |
| 5579 | 5579 | |
| 5580 | - $csv_row[] = (int)$gd_is_franchise; // gd_is_franchise |
|
| 5580 | + $csv_row[] = (int) $gd_is_franchise; // gd_is_franchise |
|
| 5581 | 5581 | $csv_row[] = $locaked_fields; // gd_franchise_lock fields |
| 5582 | - $csv_row[] = (int)$franchise; // franchise id |
|
| 5582 | + $csv_row[] = (int) $franchise; // franchise id |
|
| 5583 | 5583 | } |
| 5584 | 5584 | |
| 5585 | - for ( $c = 0; $c < $images_count; $c++ ) {
|
|
| 5586 | - $csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE |
|
| 5585 | + for ($c = 0; $c < $images_count; $c++) {
|
|
| 5586 | + $csv_row[] = isset($current_images[$c]) ? $current_images[$c] : ''; // IMAGE |
|
| 5587 | 5587 | } |
| 5588 | 5588 | |
| 5589 | 5589 | $csv_rows[] = $csv_row; |
| 5590 | 5590 | |
| 5591 | 5591 | } |
| 5592 | 5592 | |
| 5593 | - for ( $c = 0; $c < $images_count; $c++ ) {
|
|
| 5593 | + for ($c = 0; $c < $images_count; $c++) {
|
|
| 5594 | 5594 | $csv_rows[0][] = 'IMAGE'; |
| 5595 | 5595 | } |
| 5596 | 5596 | } |
@@ -5612,33 +5612,33 @@ discard block |
||
| 5612 | 5612 | * @param int $page_no Page number. Default 0. |
| 5613 | 5613 | * @return array Array of posts data. |
| 5614 | 5614 | */ |
| 5615 | -function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
|
| 5615 | +function geodir_get_export_posts($post_type, $per_page = 0, $page_no = 0) {
|
|
| 5616 | 5616 | global $wpdb, $plugin_prefix; |
| 5617 | 5617 | |
| 5618 | - if ( ! post_type_exists( $post_type ) ) |
|
| 5618 | + if (!post_type_exists($post_type)) |
|
| 5619 | 5619 | return new stdClass; |
| 5620 | 5620 | |
| 5621 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5621 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 5622 | 5622 | |
| 5623 | 5623 | $limit = ''; |
| 5624 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 5625 | - $offset = ( $page_no - 1 ) * $per_page; |
|
| 5624 | + if ($per_page > 0 && $page_no > 0) {
|
|
| 5625 | + $offset = ($page_no - 1) * $per_page; |
|
| 5626 | 5626 | |
| 5627 | - if ( $offset > 0 ) {
|
|
| 5628 | - $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 5627 | + if ($offset > 0) {
|
|
| 5628 | + $limit = " LIMIT ".$offset.",".$per_page; |
|
| 5629 | 5629 | } else {
|
| 5630 | - $limit = " LIMIT " . $per_page; |
|
| 5630 | + $limit = " LIMIT ".$per_page; |
|
| 5631 | 5631 | } |
| 5632 | 5632 | } |
| 5633 | 5633 | |
| 5634 | 5634 | // Skip listing with statuses trash, auto-draft etc... |
| 5635 | 5635 | $skip_statuses = geodir_imex_export_skip_statuses(); |
| 5636 | 5636 | $where_statuses = ''; |
| 5637 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5638 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5637 | + if (!empty($skip_statuses) && is_array($skip_statuses)) {
|
|
| 5638 | + $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
|
|
| 5639 | 5639 | } |
| 5640 | 5640 | |
| 5641 | - $query = "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;
|
|
| 5641 | + $query = "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;
|
|
| 5642 | 5642 | /** |
| 5643 | 5643 | * Modify returned posts SQL query for the current post type. |
| 5644 | 5644 | * |
@@ -5648,9 +5648,9 @@ discard block |
||
| 5648 | 5648 | * @param int $query The SQL query. |
| 5649 | 5649 | * @param string $post_type Post type. |
| 5650 | 5650 | */ |
| 5651 | - $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 5651 | + $query = apply_filters('geodir_imex_export_posts_query', $query, $post_type);
|
|
| 5652 | 5652 | |
| 5653 | - $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 5653 | + $results = (array) $wpdb->get_results($wpdb->prepare($query, $post_type), ARRAY_A); |
|
| 5654 | 5654 | |
| 5655 | 5655 | /** |
| 5656 | 5656 | * Modify returned post results for the current post type. |
@@ -5661,7 +5661,7 @@ discard block |
||
| 5661 | 5661 | * @param object $results An object containing all post ids. |
| 5662 | 5662 | * @param string $post_type Post type. |
| 5663 | 5663 | */ |
| 5664 | - return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 5664 | + return apply_filters('geodir_export_posts', $results, $post_type);
|
|
| 5665 | 5665 | } |
| 5666 | 5666 | |
| 5667 | 5667 | /** |
@@ -5678,21 +5678,21 @@ discard block |
||
| 5678 | 5678 | * @param string $post_type Post type. |
| 5679 | 5679 | * @return string The SQL query. |
| 5680 | 5680 | */ |
| 5681 | -function geodir_imex_get_events_query( $query, $post_type ) {
|
|
| 5682 | - if ( $post_type == 'gd_event' ) {
|
|
| 5681 | +function geodir_imex_get_events_query($query, $post_type) {
|
|
| 5682 | + if ($post_type == 'gd_event') {
|
|
| 5683 | 5683 | global $wpdb, $plugin_prefix; |
| 5684 | 5684 | |
| 5685 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5685 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 5686 | 5686 | $schedule_table = EVENT_SCHEDULE; |
| 5687 | 5687 | |
| 5688 | 5688 | // Skip listing with statuses trash, auto-draft etc... |
| 5689 | 5689 | $skip_statuses = geodir_imex_export_skip_statuses(); |
| 5690 | 5690 | $where_statuses = ''; |
| 5691 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5692 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5691 | + if (!empty($skip_statuses) && is_array($skip_statuses)) {
|
|
| 5692 | + $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
|
|
| 5693 | 5693 | } |
| 5694 | 5694 | |
| 5695 | - $query = "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC";
|
|
| 5695 | + $query = "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s ".$where_statuses." GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC";
|
|
| 5696 | 5696 | } |
| 5697 | 5697 | |
| 5698 | 5698 | return $query; |
@@ -5716,35 +5716,35 @@ discard block |
||
| 5716 | 5716 | * @param string $post_type Post type. |
| 5717 | 5717 | * @return int Total terms count. |
| 5718 | 5718 | */ |
| 5719 | -function geodir_get_terms_count( $post_type ) {
|
|
| 5720 | - $args = array( 'hide_empty' => 0 ); |
|
| 5719 | +function geodir_get_terms_count($post_type) {
|
|
| 5720 | + $args = array('hide_empty' => 0);
|
|
| 5721 | 5721 | |
| 5722 | - remove_all_filters( 'get_terms' ); |
|
| 5722 | + remove_all_filters('get_terms');
|
|
| 5723 | 5723 | |
| 5724 | - $taxonomy = $post_type . 'category'; |
|
| 5724 | + $taxonomy = $post_type.'category'; |
|
| 5725 | 5725 | |
| 5726 | 5726 | // WPML |
| 5727 | 5727 | $is_wpml = geodir_is_wpml(); |
| 5728 | 5728 | $active_lang = 'all'; |
| 5729 | - if ( $is_wpml ) {
|
|
| 5729 | + if ($is_wpml) {
|
|
| 5730 | 5730 | global $sitepress; |
| 5731 | 5731 | $active_lang = $sitepress->get_current_language(); |
| 5732 | 5732 | |
| 5733 | - if ( $active_lang != 'all' ) {
|
|
| 5734 | - $sitepress->switch_lang( 'all', true ); |
|
| 5733 | + if ($active_lang != 'all') {
|
|
| 5734 | + $sitepress->switch_lang('all', true);
|
|
| 5735 | 5735 | } |
| 5736 | 5736 | } |
| 5737 | 5737 | // WPML |
| 5738 | 5738 | |
| 5739 | - $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 5739 | + $count_terms = wp_count_terms($taxonomy, $args); |
|
| 5740 | 5740 | |
| 5741 | 5741 | // WPML |
| 5742 | - if ( $is_wpml && $active_lang !== 'all' ) {
|
|
| 5742 | + if ($is_wpml && $active_lang !== 'all') {
|
|
| 5743 | 5743 | global $sitepress; |
| 5744 | - $sitepress->switch_lang( $active_lang, true ); |
|
| 5744 | + $sitepress->switch_lang($active_lang, true); |
|
| 5745 | 5745 | } |
| 5746 | 5746 | // WPML |
| 5747 | - $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 5747 | + $count_terms = !is_wp_error($count_terms) ? $count_terms : 0; |
|
| 5748 | 5748 | |
| 5749 | 5749 | return $count_terms; |
| 5750 | 5750 | } |
@@ -5761,23 +5761,23 @@ discard block |
||
| 5761 | 5761 | * @param int $page_no Page number. Default 0. |
| 5762 | 5762 | * @return array Array of terms data. |
| 5763 | 5763 | */ |
| 5764 | -function geodir_imex_get_terms( $post_type, $per_page = 0, $page_no = 0 ) {
|
|
| 5765 | - $args = array( 'hide_empty' => 0, 'orderby' => 'id' ); |
|
| 5764 | +function geodir_imex_get_terms($post_type, $per_page = 0, $page_no = 0) {
|
|
| 5765 | + $args = array('hide_empty' => 0, 'orderby' => 'id');
|
|
| 5766 | 5766 | |
| 5767 | - remove_all_filters( 'get_terms' ); |
|
| 5767 | + remove_all_filters('get_terms');
|
|
| 5768 | 5768 | |
| 5769 | - $taxonomy = $post_type . 'category'; |
|
| 5769 | + $taxonomy = $post_type.'category'; |
|
| 5770 | 5770 | |
| 5771 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 5772 | - $args['offset'] = ( $page_no - 1 ) * $per_page; |
|
| 5771 | + if ($per_page > 0 && $page_no > 0) {
|
|
| 5772 | + $args['offset'] = ($page_no - 1) * $per_page; |
|
| 5773 | 5773 | $args['number'] = $per_page; |
| 5774 | 5774 | } |
| 5775 | 5775 | |
| 5776 | - $terms = get_terms( $taxonomy, $args ); |
|
| 5776 | + $terms = get_terms($taxonomy, $args); |
|
| 5777 | 5777 | |
| 5778 | 5778 | $csv_rows = array(); |
| 5779 | 5779 | |
| 5780 | - if ( !empty( $terms ) ) {
|
|
| 5780 | + if (!empty($terms)) {
|
|
| 5781 | 5781 | $csv_row = array(); |
| 5782 | 5782 | $csv_row[] = 'cat_id'; |
| 5783 | 5783 | $csv_row[] = 'cat_name'; |
@@ -5799,16 +5799,16 @@ discard block |
||
| 5799 | 5799 | |
| 5800 | 5800 | $csv_rows[] = $csv_row; |
| 5801 | 5801 | |
| 5802 | - foreach ( $terms as $term ) {
|
|
| 5803 | - $cat_icon = get_tax_meta( $term->term_id, 'ct_cat_icon', false, $post_type ); |
|
| 5804 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 5802 | + foreach ($terms as $term) {
|
|
| 5803 | + $cat_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $post_type); |
|
| 5804 | + $cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : ''; |
|
| 5805 | 5805 | |
| 5806 | - $cat_image = geodir_get_default_catimage( $term->term_id, $post_type ); |
|
| 5807 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 5806 | + $cat_image = geodir_get_default_catimage($term->term_id, $post_type); |
|
| 5807 | + $cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : ''; |
|
| 5808 | 5808 | |
| 5809 | 5809 | $cat_parent = ''; |
| 5810 | - if (isset($term->parent) && (int)$term->parent > 0 && term_exists((int)$term->parent, $taxonomy)) {
|
|
| 5811 | - $parent_term = (array)get_term_by( 'id', (int)$term->parent, $taxonomy ); |
|
| 5810 | + if (isset($term->parent) && (int) $term->parent > 0 && term_exists((int) $term->parent, $taxonomy)) {
|
|
| 5811 | + $parent_term = (array) get_term_by('id', (int) $term->parent, $taxonomy);
|
|
| 5812 | 5812 | $cat_parent = !empty($parent_term) && isset($parent_term['name']) ? $parent_term['name'] : ''; |
| 5813 | 5813 | } |
| 5814 | 5814 | |
@@ -5818,15 +5818,15 @@ discard block |
||
| 5818 | 5818 | $csv_row[] = $term->slug; |
| 5819 | 5819 | $csv_row[] = $post_type; |
| 5820 | 5820 | $csv_row[] = $cat_parent; |
| 5821 | - $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); |
|
| 5821 | + $csv_row[] = get_tax_meta($term->term_id, 'ct_cat_schema', false, $post_type); |
|
| 5822 | 5822 | // WPML |
| 5823 | 5823 | if ($is_wpml) {
|
| 5824 | - $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); |
|
| 5825 | - $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
| 5824 | + $csv_row[] = geodir_get_language_for_element($term->term_id, 'tax_'.$taxonomy); |
|
| 5825 | + $csv_row[] = geodir_imex_original_post_id($term->term_id, 'tax_'.$taxonomy); |
|
| 5826 | 5826 | } |
| 5827 | 5827 | // WPML |
| 5828 | 5828 | $csv_row[] = $term->description; |
| 5829 | - $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_top_desc', false, $post_type ); |
|
| 5829 | + $csv_row[] = get_tax_meta($term->term_id, 'ct_cat_top_desc', false, $post_type); |
|
| 5830 | 5830 | $csv_row[] = $cat_image; |
| 5831 | 5831 | $csv_row[] = $cat_icon; |
| 5832 | 5832 | |
@@ -5845,10 +5845,10 @@ discard block |
||
| 5845 | 5845 | * @param bool $relative True for relative path & False for absolute path. |
| 5846 | 5846 | * @return string Path to the cache directory. |
| 5847 | 5847 | */ |
| 5848 | -function geodir_path_import_export( $relative = true ) {
|
|
| 5848 | +function geodir_path_import_export($relative = true) {
|
|
| 5849 | 5849 | $upload_dir = wp_upload_dir(); |
| 5850 | 5850 | |
| 5851 | - return $relative ? $upload_dir['baseurl'] . '/cache' : $upload_dir['basedir'] . '/cache'; |
|
| 5851 | + return $relative ? $upload_dir['baseurl'].'/cache' : $upload_dir['basedir'].'/cache'; |
|
| 5852 | 5852 | } |
| 5853 | 5853 | |
| 5854 | 5854 | /** |
@@ -5864,8 +5864,8 @@ discard block |
||
| 5864 | 5864 | * @param bool $clear If true then it overwrite data otherwise add rows at the end of file. |
| 5865 | 5865 | * @return bool true if success otherwise false. |
| 5866 | 5866 | */ |
| 5867 | -function geodir_save_csv_data( $file_path, $csv_data = array(), $clear = true ) {
|
|
| 5868 | - if ( empty( $csv_data ) ) {
|
|
| 5867 | +function geodir_save_csv_data($file_path, $csv_data = array(), $clear = true) {
|
|
| 5868 | + if (empty($csv_data)) {
|
|
| 5869 | 5869 | return false; |
| 5870 | 5870 | } |
| 5871 | 5871 | |
@@ -5873,17 +5873,17 @@ discard block |
||
| 5873 | 5873 | |
| 5874 | 5874 | $mode = $clear ? 'w+' : 'a+'; |
| 5875 | 5875 | |
| 5876 | - if ( function_exists( 'fputcsv' ) ) {
|
|
| 5877 | - $file = fopen( $file_path, $mode ); |
|
| 5878 | - foreach( $csv_data as $csv_row ) {
|
|
| 5876 | + if (function_exists('fputcsv')) {
|
|
| 5877 | + $file = fopen($file_path, $mode); |
|
| 5878 | + foreach ($csv_data as $csv_row) {
|
|
| 5879 | 5879 | //$csv_row = array_map( 'utf8_decode', $csv_row ); |
| 5880 | - $write_successful = fputcsv( $file, $csv_row, ",", $enclosure = '"' ); |
|
| 5880 | + $write_successful = fputcsv($file, $csv_row, ",", $enclosure = '"'); |
|
| 5881 | 5881 | } |
| 5882 | - fclose( $file ); |
|
| 5882 | + fclose($file); |
|
| 5883 | 5883 | } else {
|
| 5884 | - foreach( $csv_data as $csv_row ) {
|
|
| 5884 | + foreach ($csv_data as $csv_row) {
|
|
| 5885 | 5885 | //$csv_row = array_map( 'utf8_decode', $csv_row ); |
| 5886 | - $wp_filesystem->put_contents( $file_path, $csv_row ); |
|
| 5886 | + $wp_filesystem->put_contents($file_path, $csv_row); |
|
| 5887 | 5887 | } |
| 5888 | 5888 | } |
| 5889 | 5889 | |
@@ -5901,14 +5901,14 @@ discard block |
||
| 5901 | 5901 | * @param string $file Full path to file. |
| 5902 | 5902 | * @return int No of file rows. |
| 5903 | 5903 | */ |
| 5904 | -function geodir_import_export_line_count( $file ) {
|
|
| 5904 | +function geodir_import_export_line_count($file) {
|
|
| 5905 | 5905 | global $wp_filesystem; |
| 5906 | 5906 | |
| 5907 | - if ( $wp_filesystem->is_file( $file ) && $wp_filesystem->exists( $file ) ) {
|
|
| 5908 | - $contents = $wp_filesystem->get_contents_array( $file ); |
|
| 5907 | + if ($wp_filesystem->is_file($file) && $wp_filesystem->exists($file)) {
|
|
| 5908 | + $contents = $wp_filesystem->get_contents_array($file); |
|
| 5909 | 5909 | |
| 5910 | - if ( !empty( $contents ) && is_array( $contents ) ) {
|
|
| 5911 | - return count( $contents ) - 1; |
|
| 5910 | + if (!empty($contents) && is_array($contents)) {
|
|
| 5911 | + return count($contents) - 1; |
|
| 5912 | 5912 | } |
| 5913 | 5913 | } |
| 5914 | 5914 | |
@@ -5925,11 +5925,11 @@ discard block |
||
| 5925 | 5925 | * @param string $post_type The post type. |
| 5926 | 5926 | * @return object Queried object. |
| 5927 | 5927 | */ |
| 5928 | -function geodir_imex_get_custom_fields( $post_type ) {
|
|
| 5928 | +function geodir_imex_get_custom_fields($post_type) {
|
|
| 5929 | 5929 | global $wpdb; |
| 5930 | 5930 | |
| 5931 | - $sql = $wpdb->prepare("SELECT htmlvar_name FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1' AND is_admin!='1' AND field_type != 'fieldset' AND htmlvar_name != '' ORDER BY id ASC", array( $post_type ) );
|
|
| 5932 | - $rows = $wpdb->get_results( $sql ); |
|
| 5931 | + $sql = $wpdb->prepare("SELECT htmlvar_name FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type=%s AND is_active='1' AND is_admin!='1' AND field_type != 'fieldset' AND htmlvar_name != '' ORDER BY id ASC", array($post_type));
|
|
| 5932 | + $rows = $wpdb->get_results($sql); |
|
| 5933 | 5933 | |
| 5934 | 5934 | return $rows; |
| 5935 | 5935 | } |
@@ -6008,14 +6008,14 @@ discard block |
||
| 6008 | 6008 | global $wpdb, $plugin_prefix; |
| 6009 | 6009 | |
| 6010 | 6010 | $post_type = get_post_type($master_post_id); |
| 6011 | - $post_table = $plugin_prefix . $post_type . '_detail'; |
|
| 6011 | + $post_table = $plugin_prefix.$post_type.'_detail'; |
|
| 6012 | 6012 | |
| 6013 | - $query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
|
|
| 6014 | - $data = (array)$wpdb->get_row($query); |
|
| 6013 | + $query = $wpdb->prepare("SELECT * FROM ".$post_table." WHERE post_id = %d", array($master_post_id));
|
|
| 6014 | + $data = (array) $wpdb->get_row($query); |
|
| 6015 | 6015 | |
| 6016 | - if ( !empty( $data ) ) {
|
|
| 6016 | + if (!empty($data)) {
|
|
| 6017 | 6017 | $data['post_id'] = $tr_post_id; |
| 6018 | - unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']); |
|
| 6018 | + unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type.'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']); |
|
| 6019 | 6019 | |
| 6020 | 6020 | $wpdb->update($post_table, $data, array('post_id' => $tr_post_id));
|
| 6021 | 6021 | return true; |
@@ -6041,7 +6041,7 @@ discard block |
||
| 6041 | 6041 | global $sitepress, $wpdb; |
| 6042 | 6042 | $post_type = get_post_type($master_post_id); |
| 6043 | 6043 | |
| 6044 | - remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
|
|
| 6044 | + remove_filter('get_term', array($sitepress, 'get_term_adjust_id')); // AVOID filtering to current language
|
|
| 6045 | 6045 | |
| 6046 | 6046 | $taxonomies = get_object_taxonomies($post_type); |
| 6047 | 6047 | foreach ($taxonomies as $taxonomy) {
|
@@ -6050,9 +6050,9 @@ discard block |
||
| 6050 | 6050 | |
| 6051 | 6051 | if ($terms) {
|
| 6052 | 6052 | foreach ($terms as $term) {
|
| 6053 | - $tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang); |
|
| 6053 | + $tr_id = apply_filters('translate_object_id', $term->term_id, $taxonomy, false, $lang);
|
|
| 6054 | 6054 | |
| 6055 | - if (!is_null($tr_id)){
|
|
| 6055 | + if (!is_null($tr_id)) {
|
|
| 6056 | 6056 | // not using get_term - unfiltered get_term |
| 6057 | 6057 | $translated_term = $wpdb->get_row($wpdb->prepare("
|
| 6058 | 6058 | SELECT * FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_id, $taxonomy));
|
@@ -6061,14 +6061,14 @@ discard block |
||
| 6061 | 6061 | } |
| 6062 | 6062 | } |
| 6063 | 6063 | |
| 6064 | - if (!is_taxonomy_hierarchical($taxonomy)){
|
|
| 6065 | - $terms_array = array_unique( array_map( 'intval', $terms_array ) ); |
|
| 6064 | + if (!is_taxonomy_hierarchical($taxonomy)) {
|
|
| 6065 | + $terms_array = array_unique(array_map('intval', $terms_array));
|
|
| 6066 | 6066 | } |
| 6067 | 6067 | |
| 6068 | 6068 | wp_set_post_terms($tr_post_id, $terms_array, $taxonomy); |
| 6069 | 6069 | |
| 6070 | - if ($taxonomy == $post_type . 'category') {
|
|
| 6071 | - geodir_set_postcat_structure($tr_post_id, $post_type . 'category'); |
|
| 6070 | + if ($taxonomy == $post_type.'category') {
|
|
| 6071 | + geodir_set_postcat_structure($tr_post_id, $post_type.'category'); |
|
| 6072 | 6072 | } |
| 6073 | 6073 | } |
| 6074 | 6074 | } |
@@ -6089,15 +6089,15 @@ discard block |
||
| 6089 | 6089 | function geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang) {
|
| 6090 | 6090 | global $wpdb; |
| 6091 | 6091 | |
| 6092 | - $query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
|
|
| 6092 | + $query = $wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
|
|
| 6093 | 6093 | $wpdb->query($query); |
| 6094 | 6094 | |
| 6095 | - $query = $wpdb->prepare("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
|
|
| 6095 | + $query = $wpdb->prepare("SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
|
|
| 6096 | 6096 | $post_images = $wpdb->get_results($query); |
| 6097 | 6097 | |
| 6098 | - if ( !empty( $post_images ) ) {
|
|
| 6099 | - foreach ( $post_images as $post_image) {
|
|
| 6100 | - $image_data = (array)$post_image; |
|
| 6098 | + if (!empty($post_images)) {
|
|
| 6099 | + foreach ($post_images as $post_image) {
|
|
| 6100 | + $image_data = (array) $post_image; |
|
| 6101 | 6101 | unset($image_data['ID']); |
| 6102 | 6102 | $image_data['post_id'] = $tr_post_id; |
| 6103 | 6103 | |
@@ -6123,10 +6123,10 @@ discard block |
||
| 6123 | 6123 | * @return array Event data array. |
| 6124 | 6124 | */ |
| 6125 | 6125 | function geodir_imex_get_event_data($post, $gd_post_info) {
|
| 6126 | - $event_date = isset( $post['event_date'] ) && $post['event_date'] != '' && $post['event_date'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $post['event_date'] ) ) : ''; |
|
| 6126 | + $event_date = isset($post['event_date']) && $post['event_date'] != '' && $post['event_date'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($post['event_date'])) : '';
|
|
| 6127 | 6127 | $event_enddate = $event_date; |
| 6128 | - $starttime = isset( $post['starttime'] ) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['starttime'] ) ) : ''; |
|
| 6129 | - $endtime = isset( $post['endtime'] ) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['endtime'] ) ) : ''; |
|
| 6128 | + $starttime = isset($post['starttime']) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['starttime'])) : '';
|
|
| 6129 | + $endtime = isset($post['endtime']) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['endtime'])) : '';
|
|
| 6130 | 6130 | |
| 6131 | 6131 | $is_recurring_event = ''; |
| 6132 | 6132 | $event_duration_days = ''; |
@@ -6143,15 +6143,15 @@ discard block |
||
| 6143 | 6143 | |
| 6144 | 6144 | $recurring_data = isset($gd_post_info->recurring_dates) ? maybe_unserialize($gd_post_info->recurring_dates) : array(); |
| 6145 | 6145 | if (!empty($recurring_data)) {
|
| 6146 | - $event_date = isset( $recurring_data['event_start'] ) && $recurring_data['event_start'] != '' && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_start'] ) ) : $event_date; |
|
| 6147 | - $event_enddate = isset( $recurring_data['event_end'] ) && $recurring_data['event_end'] != '' && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_end'] ) ) : $event_date; |
|
| 6148 | - $starttime = isset( $recurring_data['starttime'] ) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['starttime'] ) ) : $starttime; |
|
| 6149 | - $endtime = isset( $recurring_data['endtime'] ) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['endtime'] ) ) : $endtime; |
|
| 6146 | + $event_date = isset($recurring_data['event_start']) && $recurring_data['event_start'] != '' && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['event_start'])) : $event_date;
|
|
| 6147 | + $event_enddate = isset($recurring_data['event_end']) && $recurring_data['event_end'] != '' && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['event_end'])) : $event_date;
|
|
| 6148 | + $starttime = isset($recurring_data['starttime']) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['starttime'])) : $starttime;
|
|
| 6149 | + $endtime = isset($recurring_data['endtime']) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['endtime'])) : $endtime;
|
|
| 6150 | 6150 | $is_whole_day_event = !empty($recurring_data['all_day']) ? 1 : ''; |
| 6151 | 6151 | $different_times = !empty($recurring_data['different_times']) ? true : false; |
| 6152 | 6152 | |
| 6153 | - $recurring_pkg = geodir_event_recurring_pkg( $gd_post_info ); |
|
| 6154 | - $is_recurring = isset( $gd_post_info->is_recurring ) && (int)$gd_post_info->is_recurring == 0 ? false : true; |
|
| 6153 | + $recurring_pkg = geodir_event_recurring_pkg($gd_post_info); |
|
| 6154 | + $is_recurring = isset($gd_post_info->is_recurring) && (int) $gd_post_info->is_recurring == 0 ? false : true; |
|
| 6155 | 6155 | |
| 6156 | 6156 | if ($recurring_pkg && $is_recurring) {
|
| 6157 | 6157 | $recurring_dates = $event_date; |
@@ -6161,13 +6161,13 @@ discard block |
||
| 6161 | 6161 | $recurring_type = !empty($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'custom';
|
| 6162 | 6162 | |
| 6163 | 6163 | if (!empty($recurring_data['event_recurring_dates'])) {
|
| 6164 | - $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] ); |
|
| 6164 | + $event_recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
|
|
| 6165 | 6165 | |
| 6166 | 6166 | if (!empty($event_recurring_dates)) {
|
| 6167 | 6167 | $recurring_dates = array(); |
| 6168 | 6168 | |
| 6169 | 6169 | foreach ($event_recurring_dates as $date) {
|
| 6170 | - $recurring_dates[] = date_i18n( 'd/m/Y', strtotime( $date ) ); |
|
| 6170 | + $recurring_dates[] = date_i18n('d/m/Y', strtotime($date));
|
|
| 6171 | 6171 | } |
| 6172 | 6172 | |
| 6173 | 6173 | $recurring_dates = implode(",", $recurring_dates);
|
@@ -6183,7 +6183,7 @@ discard block |
||
| 6183 | 6183 | $times = array(); |
| 6184 | 6184 | |
| 6185 | 6185 | foreach ($recurring_data['starttimes'] as $time) {
|
| 6186 | - $times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00'; |
|
| 6186 | + $times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
|
|
| 6187 | 6187 | } |
| 6188 | 6188 | |
| 6189 | 6189 | $event_starttimes = implode(",", $times);
|
@@ -6193,7 +6193,7 @@ discard block |
||
| 6193 | 6193 | $times = array(); |
| 6194 | 6194 | |
| 6195 | 6195 | foreach ($recurring_data['endtimes'] as $time) {
|
| 6196 | - $times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00'; |
|
| 6196 | + $times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
|
|
| 6197 | 6197 | } |
| 6198 | 6198 | |
| 6199 | 6199 | $event_endtimes = implode(",", $times);
|
@@ -6205,8 +6205,8 @@ discard block |
||
| 6205 | 6205 | } |
| 6206 | 6206 | } |
| 6207 | 6207 | } else {
|
| 6208 | - $event_duration_days = isset($recurring_data['duration_x']) ? (int)$recurring_data['duration_x'] : 1; |
|
| 6209 | - $recurring_interval = !empty($recurring_data['repeat_x']) && (int)$recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1; |
|
| 6208 | + $event_duration_days = isset($recurring_data['duration_x']) ? (int) $recurring_data['duration_x'] : 1; |
|
| 6209 | + $recurring_interval = !empty($recurring_data['repeat_x']) && (int) $recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1; |
|
| 6210 | 6210 | |
| 6211 | 6211 | if (($recurring_type == 'week' || $recurring_type == 'month') && !empty($recurring_data['repeat_days'])) {
|
| 6212 | 6212 | $week_days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
|
@@ -6222,11 +6222,11 @@ discard block |
||
| 6222 | 6222 | } |
| 6223 | 6223 | |
| 6224 | 6224 | $recurring_week_nos = $recurring_type == 'month' && !empty($recurring_data['repeat_weeks']) ? implode(",", $recurring_data['repeat_weeks']) : $recurring_week_nos;
|
| 6225 | - if (!empty($recurring_data['repeat_end_type']) && (int)$recurring_data['repeat_end_type'] == 1) {
|
|
| 6226 | - $recurring_end_date = isset($recurring_data['repeat_end']) && $recurring_data['repeat_end'] != '' && $recurring_data['repeat_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['repeat_end'] ) ) : ''; |
|
| 6225 | + if (!empty($recurring_data['repeat_end_type']) && (int) $recurring_data['repeat_end_type'] == 1) {
|
|
| 6226 | + $recurring_end_date = isset($recurring_data['repeat_end']) && $recurring_data['repeat_end'] != '' && $recurring_data['repeat_end'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['repeat_end'])) : '';
|
|
| 6227 | 6227 | $max_recurring_count = empty($recurring_end_date) ? 1 : ''; |
| 6228 | 6228 | } else {
|
| 6229 | - $max_recurring_count = (!empty($recurring_data['max_repeat']) && (int)$recurring_data['max_repeat'] > 0 ? (int)$recurring_data['max_repeat'] : 1); |
|
| 6229 | + $max_recurring_count = (!empty($recurring_data['max_repeat']) && (int) $recurring_data['max_repeat'] > 0 ? (int) $recurring_data['max_repeat'] : 1); |
|
| 6230 | 6230 | } |
| 6231 | 6231 | } |
| 6232 | 6232 | } |
@@ -6290,9 +6290,9 @@ discard block |
||
| 6290 | 6290 | * @return array Event data array. |
| 6291 | 6291 | */ |
| 6292 | 6292 | function geodir_imex_process_event_data($gd_post) {
|
| 6293 | - $recurring_pkg = geodir_event_recurring_pkg( (object)$gd_post ); |
|
| 6293 | + $recurring_pkg = geodir_event_recurring_pkg((object) $gd_post); |
|
| 6294 | 6294 | |
| 6295 | - $is_recurring = isset( $gd_post['is_recurring_event'] ) && (int)$gd_post['is_recurring_event'] == 0 ? false : true; |
|
| 6295 | + $is_recurring = isset($gd_post['is_recurring_event']) && (int) $gd_post['is_recurring_event'] == 0 ? false : true; |
|
| 6296 | 6296 | $event_date = isset($gd_post['event_date']) && $gd_post['event_date'] != '' ? geodir_imex_get_date_ymd($gd_post['event_date']) : ''; |
| 6297 | 6297 | $event_enddate = isset($gd_post['event_enddate']) && $gd_post['event_enddate'] != '' ? geodir_imex_get_date_ymd($gd_post['event_enddate']) : $event_date; |
| 6298 | 6298 | $all_day = isset($gd_post['is_whole_day_event']) && !empty($gd_post['is_whole_day_event']) ? true : false; |
@@ -6339,17 +6339,17 @@ discard block |
||
| 6339 | 6339 | $event_recurring_dates = implode(",", $event_recurring_dates);
|
| 6340 | 6340 | } |
| 6341 | 6341 | } else {
|
| 6342 | - $duration_x = !empty( $gd_post['event_duration_days'] ) ? (int)$gd_post['event_duration_days'] : 1; |
|
| 6343 | - $repeat_x = !empty( $gd_post['recurring_interval'] ) ? (int)$gd_post['recurring_interval'] : 1; |
|
| 6344 | - $max_repeat = !empty( $gd_post['max_recurring_count'] ) ? (int)$gd_post['max_recurring_count'] : 1; |
|
| 6345 | - $repeat_end = !empty( $gd_post['recurring_end_date'] ) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : ''; |
|
| 6342 | + $duration_x = !empty($gd_post['event_duration_days']) ? (int) $gd_post['event_duration_days'] : 1; |
|
| 6343 | + $repeat_x = !empty($gd_post['recurring_interval']) ? (int) $gd_post['recurring_interval'] : 1; |
|
| 6344 | + $max_repeat = !empty($gd_post['max_recurring_count']) ? (int) $gd_post['max_recurring_count'] : 1; |
|
| 6345 | + $repeat_end = !empty($gd_post['recurring_end_date']) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : ''; |
|
| 6346 | 6346 | |
| 6347 | 6347 | $repeat_end_type = $repeat_end != '' ? 1 : 0; |
| 6348 | 6348 | $max_repeat = $repeat_end != '' ? '' : $max_repeat; |
| 6349 | 6349 | |
| 6350 | 6350 | $week_days = array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'));
|
| 6351 | 6351 | |
| 6352 | - $a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days'])!='' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
|
|
| 6352 | + $a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days']) != '' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
|
|
| 6353 | 6353 | $repeat_days = array(); |
| 6354 | 6354 | if (!empty($a_repeat_days)) {
|
| 6355 | 6355 | foreach ($a_repeat_days as $repeat_day) {
|
@@ -6367,7 +6367,7 @@ discard block |
||
| 6367 | 6367 | $repeat_weeks = array(); |
| 6368 | 6368 | if (!empty($a_repeat_weeks)) {
|
| 6369 | 6369 | foreach ($a_repeat_weeks as $repeat_week) {
|
| 6370 | - $repeat_weeks[] = (int)$repeat_week; |
|
| 6370 | + $repeat_weeks[] = (int) $repeat_week; |
|
| 6371 | 6371 | } |
| 6372 | 6372 | |
| 6373 | 6373 | $repeat_weeks = array_unique($repeat_weeks); |
@@ -6431,7 +6431,7 @@ discard block |
||
| 6431 | 6431 | |
| 6432 | 6432 | $page_found = $wpdb->get_var( |
| 6433 | 6433 | $wpdb->prepare( |
| 6434 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 6434 | + "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;", |
|
| 6435 | 6435 | array($slug) |
| 6436 | 6436 | ) |
| 6437 | 6437 | ); |
@@ -6486,7 +6486,7 @@ discard block |
||
| 6486 | 6486 | */ |
| 6487 | 6487 | function geodir_admin_upgrade_notice() {
|
| 6488 | 6488 | $class = "error"; |
| 6489 | - $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 6489 | + $message = __("Please update core GeoDirectory or some addons may not function correctly.", "geodirectory");
|
|
| 6490 | 6490 | echo"<div class=\"$class\"> <p>$message</p></div>"; |
| 6491 | 6491 | } |
| 6492 | 6492 | |
@@ -6498,7 +6498,7 @@ discard block |
||
| 6498 | 6498 | * @param (object) $r |
| 6499 | 6499 | * @return (string) $output |
| 6500 | 6500 | */ |
| 6501 | -function geodire_admin_upgrade_notice( $plugin_data, $r ) |
|
| 6501 | +function geodire_admin_upgrade_notice($plugin_data, $r) |
|
| 6502 | 6502 | {
|
| 6503 | 6503 | // readme contents |
| 6504 | 6504 | $args = array( |
@@ -6506,7 +6506,7 @@ discard block |
||
| 6506 | 6506 | 'redirection' => 5 |
| 6507 | 6507 | ); |
| 6508 | 6508 | $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
| 6509 | - $data = wp_remote_get( $url, $args ); |
|
| 6509 | + $data = wp_remote_get($url, $args); |
|
| 6510 | 6510 | |
| 6511 | 6511 | if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
| 6512 | 6512 | |
@@ -6521,20 +6521,20 @@ discard block |
||
| 6521 | 6521 | function geodir_in_plugin_update_message($content) {
|
| 6522 | 6522 | // Output Upgrade Notice |
| 6523 | 6523 | $matches = null; |
| 6524 | - $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 6524 | + $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*'.preg_quote(GEODIRECTORY_VERSION).'\s*=|$)~Uis'; |
|
| 6525 | 6525 | $upgrade_notice = ''; |
| 6526 | - if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 6527 | - if(empty($matches)){return;}
|
|
| 6526 | + if (preg_match($regexp, $content, $matches)) {
|
|
| 6527 | + if (empty($matches)) {return; }
|
|
| 6528 | 6528 | |
| 6529 | - $version = trim( $matches[1] ); |
|
| 6530 | - if($version && $version>GEODIRECTORY_VERSION){
|
|
| 6529 | + $version = trim($matches[1]); |
|
| 6530 | + if ($version && $version > GEODIRECTORY_VERSION) {
|
|
| 6531 | 6531 | |
| 6532 | 6532 | |
| 6533 | - $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 6534 | - if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
|
|
| 6533 | + $notices = (array) preg_split('~[\r\n]+~', trim($matches[2]));
|
|
| 6534 | + if (version_compare(GEODIRECTORY_VERSION, $version, '<')) {
|
|
| 6535 | 6535 | $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
| 6536 | - foreach ( $notices as $index => $line ) {
|
|
| 6537 | - $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 6536 | + foreach ($notices as $index => $line) {
|
|
| 6537 | + $upgrade_notice .= wp_kses_post(preg_replace('~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line));
|
|
| 6538 | 6538 | } |
| 6539 | 6539 | $upgrade_notice .= '</div> '; |
| 6540 | 6540 | } |
@@ -6558,7 +6558,7 @@ discard block |
||
| 6558 | 6558 | $default_language = $sitepress->get_default_language(); |
| 6559 | 6559 | if ($current_language != 'all' && $current_language != $default_language) {
|
| 6560 | 6560 | ?> |
| 6561 | - <div class="updated error notice-success" id="message"><p style="color:red"><strong><?php _e('Saving GeoDirectory pages settings on a different language breaks pages settings. Try to save after switching to default language.', 'geodirectory');?></strong></p></div>
|
|
| 6561 | + <div class="updated error notice-success" id="message"><p style="color:red"><strong><?php _e('Saving GeoDirectory pages settings on a different language breaks pages settings. Try to save after switching to default language.', 'geodirectory'); ?></strong></p></div>
|
|
| 6562 | 6562 | <?php |
| 6563 | 6563 | } |
| 6564 | 6564 | } |
@@ -6573,7 +6573,7 @@ discard block |
||
| 6573 | 6573 | * @param array Listing statuses to be skipped. |
| 6574 | 6574 | */ |
| 6575 | 6575 | function geodir_imex_export_skip_statuses() {
|
| 6576 | - $statuses = array( 'trash', 'auto-draft' ); |
|
| 6576 | + $statuses = array('trash', 'auto-draft');
|
|
| 6577 | 6577 | |
| 6578 | 6578 | /** |
| 6579 | 6579 | * Filter the statuses to skip during GD export listings. |
@@ -6583,7 +6583,7 @@ discard block |
||
| 6583 | 6583 | * |
| 6584 | 6584 | * @param array $statuses Listing statuses to be skipped. |
| 6585 | 6585 | */ |
| 6586 | - $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
| 6586 | + $statuses = apply_filters('geodir_imex_export_skip_statuses', $statuses);
|
|
| 6587 | 6587 | |
| 6588 | 6588 | return $statuses; |
| 6589 | 6589 | } |
@@ -10,33 +10,33 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | add_action('admin_init', 'geodir_admin_init');
|
| 12 | 12 | if (!function_exists('geodir_admin_init')) {
|
| 13 | - /** |
|
| 14 | - * Adds GD setting pages in admin. |
|
| 15 | - * |
|
| 16 | - * @since 1.0.0 |
|
| 17 | - * @package GeoDirectory |
|
| 18 | - * @global string $current_tab The current settings tab name. |
|
| 19 | - */ |
|
| 20 | - function geodir_admin_init() |
|
| 21 | - {
|
|
| 22 | - |
|
| 23 | - if (is_admin()): |
|
| 24 | - global $current_tab; |
|
| 25 | - geodir_redirect_to_admin_panel_on_installed(); |
|
| 26 | - $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings'; |
|
| 27 | - if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests |
|
| 28 | - geodir_handle_option_form_submit($current_tab); // located in admin function.php |
|
| 29 | - /** |
|
| 30 | - * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area. |
|
| 31 | - * |
|
| 32 | - * @since 1.0.0 |
|
| 33 | - */ |
|
| 34 | - do_action('admin_panel_init');
|
|
| 35 | - add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
|
|
| 36 | - |
|
| 37 | - |
|
| 38 | - endif; |
|
| 39 | - } |
|
| 13 | + /** |
|
| 14 | + * Adds GD setting pages in admin. |
|
| 15 | + * |
|
| 16 | + * @since 1.0.0 |
|
| 17 | + * @package GeoDirectory |
|
| 18 | + * @global string $current_tab The current settings tab name. |
|
| 19 | + */ |
|
| 20 | + function geodir_admin_init() |
|
| 21 | + {
|
|
| 22 | + |
|
| 23 | + if (is_admin()): |
|
| 24 | + global $current_tab; |
|
| 25 | + geodir_redirect_to_admin_panel_on_installed(); |
|
| 26 | + $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings'; |
|
| 27 | + if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests |
|
| 28 | + geodir_handle_option_form_submit($current_tab); // located in admin function.php |
|
| 29 | + /** |
|
| 30 | + * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area. |
|
| 31 | + * |
|
| 32 | + * @since 1.0.0 |
|
| 33 | + */ |
|
| 34 | + do_action('admin_panel_init');
|
|
| 35 | + add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
|
|
| 36 | + |
|
| 37 | + |
|
| 38 | + endif; |
|
| 39 | + } |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | function geodir_redirect_to_admin_panel_on_installed() |
| 49 | 49 | {
|
| 50 | - if (get_option('geodir_installation_redirect', false)) {
|
|
| 51 | - delete_option('geodir_installation_redirect');
|
|
| 52 | - wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
|
|
| 53 | - } |
|
| 50 | + if (get_option('geodir_installation_redirect', false)) {
|
|
| 51 | + delete_option('geodir_installation_redirect');
|
|
| 52 | + wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
|
|
| 53 | + } |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | function geodir_get_admin_option_form($current_tab) |
| 64 | 64 | {
|
| 65 | - geodir_admin_option_form($current_tab);// defined in admin template tags.php |
|
| 65 | + geodir_admin_option_form($current_tab);// defined in admin template tags.php |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
@@ -85,19 +85,19 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | function geodir_conditional_admin_script_load() |
| 87 | 87 | {
|
| 88 | - global $pagenow; |
|
| 88 | + global $pagenow; |
|
| 89 | 89 | |
| 90 | 90 | // Get the current post type |
| 91 | 91 | $post_type = geodir_admin_current_post_type(); |
| 92 | 92 | $geodir_post_types = geodir_get_posttypes(); |
| 93 | 93 | |
| 94 | 94 | if ((isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') || (($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') && $post_type && in_array($post_type, $geodir_post_types)) || ($pagenow == 'edit-tags.php' || $pagenow == 'term.php' || $pagenow == 'edit-comments.php' || $pagenow == 'comment.php')) {
|
| 95 | - add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
|
|
| 96 | - add_action('admin_enqueue_scripts', 'geodir_admin_styles');
|
|
| 97 | - add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
|
|
| 98 | - } |
|
| 95 | + add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
|
|
| 96 | + add_action('admin_enqueue_scripts', 'geodir_admin_styles');
|
|
| 97 | + add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
|
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
|
|
| 100 | + add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
|
|
| 101 | 101 | |
| 102 | 102 | } |
| 103 | 103 | |
@@ -131,12 +131,12 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | function create_default_admin_main_nav() |
| 133 | 133 | {
|
| 134 | - add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
|
|
| 135 | - add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
|
|
| 136 | - add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
|
|
| 137 | - add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
|
|
| 138 | - add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
|
|
| 139 | - //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
|
|
| 134 | + add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
|
|
| 135 | + add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
|
|
| 136 | + add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
|
|
| 137 | + add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
|
|
| 138 | + add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
|
|
| 139 | + //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
|
|
| 140 | 140 | |
| 141 | 141 | } |
| 142 | 142 | |
@@ -149,16 +149,16 @@ discard block |
||
| 149 | 149 | */ |
| 150 | 150 | function geodir_admin_list_columns() |
| 151 | 151 | {
|
| 152 | - if ($post_types = geodir_get_posttypes()) {
|
|
| 152 | + if ($post_types = geodir_get_posttypes()) {
|
|
| 153 | 153 | |
| 154 | - foreach ($post_types as $post_type): |
|
| 155 | - add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
|
|
| 156 | - //Filter-Payment-Manager to show Package |
|
| 157 | - add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
|
|
| 154 | + foreach ($post_types as $post_type): |
|
| 155 | + add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
|
|
| 156 | + //Filter-Payment-Manager to show Package |
|
| 157 | + add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
|
|
| 158 | 158 | |
| 159 | - add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
|
|
| 160 | - endforeach; |
|
| 161 | - } |
|
| 159 | + add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
|
|
| 160 | + endforeach; |
|
| 161 | + } |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -171,15 +171,15 @@ discard block |
||
| 171 | 171 | */ |
| 172 | 172 | function geodir_default_admin_main_tabs($tabs) |
| 173 | 173 | {
|
| 174 | - return $tabs = array( |
|
| 175 | - 'general_settings' => array('label' => __('General', 'geodirectory')),
|
|
| 176 | - 'design_settings' => array('label' => __('Design', 'geodirectory')),
|
|
| 177 | - 'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
|
|
| 178 | - 'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
|
|
| 179 | - 'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
|
|
| 180 | - 'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
|
|
| 181 | - |
|
| 182 | - ); |
|
| 174 | + return $tabs = array( |
|
| 175 | + 'general_settings' => array('label' => __('General', 'geodirectory')),
|
|
| 176 | + 'design_settings' => array('label' => __('Design', 'geodirectory')),
|
|
| 177 | + 'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
|
|
| 178 | + 'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
|
|
| 179 | + 'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
|
|
| 180 | + 'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
|
|
| 181 | + |
|
| 182 | + ); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | add_action('do_meta_boxes', 'geodir_remove_image_box');
|
@@ -192,16 +192,16 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | function geodir_remove_image_box() |
| 194 | 194 | {
|
| 195 | - global $post; |
|
| 195 | + global $post; |
|
| 196 | 196 | |
| 197 | - $geodir_posttypes = geodir_get_posttypes(); |
|
| 197 | + $geodir_posttypes = geodir_get_posttypes(); |
|
| 198 | 198 | |
| 199 | - if (isset($post) && in_array($post->post_type, $geodir_posttypes)): |
|
| 199 | + if (isset($post) && in_array($post->post_type, $geodir_posttypes)): |
|
| 200 | 200 | |
| 201 | - remove_meta_box('postimagediv', $post->post_type, 'side');
|
|
| 202 | - remove_meta_box('revisionsdiv', $post->post_type, 'normal');
|
|
| 201 | + remove_meta_box('postimagediv', $post->post_type, 'side');
|
|
| 202 | + remove_meta_box('revisionsdiv', $post->post_type, 'normal');
|
|
| 203 | 203 | |
| 204 | - endif; |
|
| 204 | + endif; |
|
| 205 | 205 | |
| 206 | 206 | } |
| 207 | 207 | |
@@ -216,26 +216,26 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | function geodir_meta_box_add() |
| 218 | 218 | {
|
| 219 | - global $post; |
|
| 219 | + global $post; |
|
| 220 | 220 | |
| 221 | - $geodir_post_types = geodir_get_posttypes('array');
|
|
| 222 | - $geodir_posttypes = array_keys($geodir_post_types); |
|
| 221 | + $geodir_post_types = geodir_get_posttypes('array');
|
|
| 222 | + $geodir_posttypes = array_keys($geodir_post_types); |
|
| 223 | 223 | |
| 224 | - if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)): |
|
| 224 | + if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)): |
|
| 225 | 225 | |
| 226 | - $geodir_posttype = $post->post_type; |
|
| 227 | - $post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']); |
|
| 226 | + $geodir_posttype = $post->post_type; |
|
| 227 | + $post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']); |
|
| 228 | 228 | |
| 229 | - // Filter-Payment-Manager |
|
| 229 | + // Filter-Payment-Manager |
|
| 230 | 230 | |
| 231 | - add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
|
|
| 231 | + add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
|
|
| 232 | 232 | |
| 233 | - add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
|
|
| 233 | + add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
|
|
| 234 | 234 | |
| 235 | - // no need of this box as all fields moved to main information box |
|
| 236 | - //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
|
|
| 235 | + // no need of this box as all fields moved to main information box |
|
| 236 | + //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
|
|
| 237 | 237 | |
| 238 | - endif; |
|
| 238 | + endif; |
|
| 239 | 239 | |
| 240 | 240 | } |
| 241 | 241 | |
@@ -259,23 +259,23 @@ discard block |
||
| 259 | 259 | function geodir_hide_post_taxonomy_meta_boxes() |
| 260 | 260 | {
|
| 261 | 261 | |
| 262 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 262 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 263 | 263 | |
| 264 | - if (!empty($geodir_post_types)) {
|
|
| 265 | - foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
|
|
| 264 | + if (!empty($geodir_post_types)) {
|
|
| 265 | + foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
|
|
| 266 | 266 | |
| 267 | - $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); |
|
| 267 | + $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); |
|
| 268 | 268 | |
| 269 | - if(!empty($gd_taxonomy)) {
|
|
| 270 | - foreach ($gd_taxonomy as $tax) {
|
|
| 269 | + if(!empty($gd_taxonomy)) {
|
|
| 270 | + foreach ($gd_taxonomy as $tax) {
|
|
| 271 | 271 | |
| 272 | - remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); |
|
| 272 | + remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); |
|
| 273 | 273 | |
| 274 | - } |
|
| 275 | - } |
|
| 274 | + } |
|
| 275 | + } |
|
| 276 | 276 | |
| 277 | - } |
|
| 278 | - } |
|
| 277 | + } |
|
| 278 | + } |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict');
|
@@ -289,12 +289,12 @@ discard block |
||
| 289 | 289 | */ |
| 290 | 290 | function geodir_add_listing_map_restrict($map_restirct) |
| 291 | 291 | {
|
| 292 | - if (is_admin()) {
|
|
| 293 | - if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
|
|
| 294 | - $map_restirct = false; |
|
| 295 | - } |
|
| 296 | - } |
|
| 297 | - return $map_restirct; |
|
| 292 | + if (is_admin()) {
|
|
| 293 | + if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
|
|
| 294 | + $map_restirct = false; |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + return $map_restirct; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | |
@@ -313,16 +313,16 @@ discard block |
||
| 313 | 313 | function geodir_enable_editor_on_notifications($notification) |
| 314 | 314 | {
|
| 315 | 315 | |
| 316 | - if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
|
|
| 316 | + if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
|
|
| 317 | 317 | |
| 318 | - foreach ($notification as $key => $value) {
|
|
| 319 | - if ($value['type'] == 'textarea') |
|
| 320 | - $notification[$key]['type'] = 'editor'; |
|
| 321 | - } |
|
| 318 | + foreach ($notification as $key => $value) {
|
|
| 319 | + if ($value['type'] == 'textarea') |
|
| 320 | + $notification[$key]['type'] = 'editor'; |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | - } |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | - return $notification; |
|
| 325 | + return $notification; |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | |
@@ -339,16 +339,16 @@ discard block |
||
| 339 | 339 | function geodir_enable_editor_on_design_settings($design_setting) |
| 340 | 340 | {
|
| 341 | 341 | |
| 342 | - if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
|
|
| 342 | + if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
|
|
| 343 | 343 | |
| 344 | - foreach ($design_setting as $key => $value) {
|
|
| 345 | - if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') |
|
| 346 | - $design_setting[$key]['type'] = 'editor'; |
|
| 347 | - } |
|
| 344 | + foreach ($design_setting as $key => $value) {
|
|
| 345 | + if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') |
|
| 346 | + $design_setting[$key]['type'] = 'editor'; |
|
| 347 | + } |
|
| 348 | 348 | |
| 349 | - } |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | - return $design_setting; |
|
| 351 | + return $design_setting; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /* ----------- START MANAGE CUSTOM FIELDS ---------------- */ |
@@ -369,16 +369,16 @@ discard block |
||
| 369 | 369 | function geodir_manage_available_fields($sub_tab) |
| 370 | 370 | {
|
| 371 | 371 | |
| 372 | - switch ($sub_tab) {
|
|
| 373 | - case 'custom_fields': |
|
| 374 | - geodir_custom_available_fields(); |
|
| 375 | - break; |
|
| 372 | + switch ($sub_tab) {
|
|
| 373 | + case 'custom_fields': |
|
| 374 | + geodir_custom_available_fields(); |
|
| 375 | + break; |
|
| 376 | 376 | |
| 377 | - case 'sorting_options': |
|
| 378 | - geodir_sorting_options_available_fields(); |
|
| 379 | - break; |
|
| 377 | + case 'sorting_options': |
|
| 378 | + geodir_sorting_options_available_fields(); |
|
| 379 | + break; |
|
| 380 | 380 | |
| 381 | - } |
|
| 381 | + } |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | |
@@ -394,16 +394,16 @@ discard block |
||
| 394 | 394 | function geodir_manage_selected_fields($sub_tab) |
| 395 | 395 | {
|
| 396 | 396 | |
| 397 | - switch ($sub_tab) {
|
|
| 398 | - case 'custom_fields': |
|
| 399 | - geodir_custom_selected_fields(); |
|
| 400 | - break; |
|
| 397 | + switch ($sub_tab) {
|
|
| 398 | + case 'custom_fields': |
|
| 399 | + geodir_custom_selected_fields(); |
|
| 400 | + break; |
|
| 401 | 401 | |
| 402 | - case 'sorting_options': |
|
| 403 | - geodir_sorting_options_selected_fields(); |
|
| 404 | - break; |
|
| 402 | + case 'sorting_options': |
|
| 403 | + geodir_sorting_options_selected_fields(); |
|
| 404 | + break; |
|
| 405 | 405 | |
| 406 | - } |
|
| 406 | + } |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -415,27 +415,27 @@ discard block |
||
| 415 | 415 | */ |
| 416 | 416 | function geodir_sorting_options_available_fields() |
| 417 | 417 | {
|
| 418 | - global $wpdb; |
|
| 419 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 420 | - ?> |
|
| 418 | + global $wpdb; |
|
| 419 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 420 | + ?> |
|
| 421 | 421 | <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
| 422 | 422 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
| 423 | 423 | <ul> |
| 424 | 424 | <?php |
| 425 | - $sort_options = geodir_get_custom_sort_options($listing_type); |
|
| 425 | + $sort_options = geodir_get_custom_sort_options($listing_type); |
|
| 426 | 426 | |
| 427 | - foreach ($sort_options as $key => $val) {
|
|
| 428 | - $val = stripslashes_deep($val); // strip slashes |
|
| 429 | - |
|
| 430 | - $check_html_variable = $wpdb->get_var( |
|
| 431 | - $wpdb->prepare( |
|
| 432 | - "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", |
|
| 433 | - array($val['htmlvar_name'], $listing_type, $val['field_type']) |
|
| 434 | - ) |
|
| 435 | - ); |
|
| 427 | + foreach ($sort_options as $key => $val) {
|
|
| 428 | + $val = stripslashes_deep($val); // strip slashes |
|
| 429 | + |
|
| 430 | + $check_html_variable = $wpdb->get_var( |
|
| 431 | + $wpdb->prepare( |
|
| 432 | + "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", |
|
| 433 | + array($val['htmlvar_name'], $listing_type, $val['field_type']) |
|
| 434 | + ) |
|
| 435 | + ); |
|
| 436 | 436 | |
| 437 | - $display = $check_html_variable ? ' style="display:none;"' : ''; |
|
| 438 | - ?> |
|
| 437 | + $display = $check_html_variable ? ' style="display:none;"' : ''; |
|
| 438 | + ?> |
|
| 439 | 439 | <li <?php echo $display;?>> |
| 440 | 440 | <a id="gt-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" |
| 441 | 441 | title="<?php echo $val['site_title'];?>" |
@@ -443,8 +443,8 @@ discard block |
||
| 443 | 443 | href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory');?></a> |
| 444 | 444 | </li> |
| 445 | 445 | <?php |
| 446 | - } |
|
| 447 | - ?> |
|
| 446 | + } |
|
| 447 | + ?> |
|
| 448 | 448 | </ul> |
| 449 | 449 | <?php |
| 450 | 450 | } |
@@ -458,28 +458,28 @@ discard block |
||
| 458 | 458 | */ |
| 459 | 459 | function geodir_sorting_options_selected_fields() |
| 460 | 460 | {
|
| 461 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 462 | - ?> |
|
| 461 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 462 | + ?> |
|
| 463 | 463 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
| 464 | 464 | <ul class="core"> |
| 465 | 465 | <?php |
| 466 | - global $wpdb; |
|
| 466 | + global $wpdb; |
|
| 467 | 467 | |
| 468 | - $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
|
|
| 468 | + $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
|
|
| 469 | 469 | |
| 470 | - if (!empty($fields)) {
|
|
| 471 | - foreach ($fields as $field) {
|
|
| 472 | - //$result_str = $field->id; |
|
| 473 | - $result_str = $field; |
|
| 474 | - $field_type = $field->field_type; |
|
| 475 | - $field_ins_upd = 'display'; |
|
| 470 | + if (!empty($fields)) {
|
|
| 471 | + foreach ($fields as $field) {
|
|
| 472 | + //$result_str = $field->id; |
|
| 473 | + $result_str = $field; |
|
| 474 | + $field_type = $field->field_type; |
|
| 475 | + $field_ins_upd = 'display'; |
|
| 476 | 476 | |
| 477 | - $default = false; |
|
| 477 | + $default = false; |
|
| 478 | 478 | |
| 479 | - geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default); |
|
| 480 | - } |
|
| 481 | - } |
|
| 482 | - ?> |
|
| 479 | + geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default); |
|
| 480 | + } |
|
| 481 | + } |
|
| 482 | + ?> |
|
| 483 | 483 | </ul> |
| 484 | 484 | <?php |
| 485 | 485 | } |
@@ -492,8 +492,8 @@ discard block |
||
| 492 | 492 | */ |
| 493 | 493 | function geodir_custom_available_fields() |
| 494 | 494 | {
|
| 495 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 496 | - ?> |
|
| 495 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 496 | + ?> |
|
| 497 | 497 | <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
| 498 | 498 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
| 499 | 499 | <ul class="full"> |
@@ -544,25 +544,25 @@ discard block |
||
| 544 | 544 | */ |
| 545 | 545 | function geodir_custom_selected_fields() |
| 546 | 546 | {
|
| 547 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 548 | - ?> |
|
| 547 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 548 | + ?> |
|
| 549 | 549 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
| 550 | 550 | <ul class="core"> |
| 551 | 551 | <?php |
| 552 | - global $wpdb; |
|
| 553 | - $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
|
|
| 554 | - |
|
| 555 | - if (!empty($fields)) {
|
|
| 556 | - foreach ($fields as $field) {
|
|
| 557 | - //$result_str = $field->id; |
|
| 558 | - $result_str = $field; |
|
| 559 | - $field_type = $field->field_type; |
|
| 560 | - $field_ins_upd = 'display'; |
|
| 561 | - |
|
| 562 | - geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd); |
|
| 563 | - } |
|
| 564 | - } |
|
| 565 | - ?></ul> |
|
| 552 | + global $wpdb; |
|
| 553 | + $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
|
|
| 554 | + |
|
| 555 | + if (!empty($fields)) {
|
|
| 556 | + foreach ($fields as $field) {
|
|
| 557 | + //$result_str = $field->id; |
|
| 558 | + $result_str = $field; |
|
| 559 | + $field_type = $field->field_type; |
|
| 560 | + $field_ins_upd = 'display'; |
|
| 561 | + |
|
| 562 | + geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd); |
|
| 563 | + } |
|
| 564 | + } |
|
| 565 | + ?></ul> |
|
| 566 | 566 | <?php |
| 567 | 567 | |
| 568 | 568 | } |
@@ -581,16 +581,16 @@ discard block |
||
| 581 | 581 | function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type) |
| 582 | 582 | {
|
| 583 | 583 | |
| 584 | - switch ($sub_tab) {
|
|
| 585 | - case 'custom_fields': |
|
| 586 | - $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 587 | - break; |
|
| 584 | + switch ($sub_tab) {
|
|
| 585 | + case 'custom_fields': |
|
| 586 | + $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 587 | + break; |
|
| 588 | 588 | |
| 589 | - case 'sorting_options': |
|
| 590 | - $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 591 | - break; |
|
| 592 | - } |
|
| 593 | - return $heading; |
|
| 589 | + case 'sorting_options': |
|
| 590 | + $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 591 | + break; |
|
| 592 | + } |
|
| 593 | + return $heading; |
|
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | |
@@ -608,16 +608,16 @@ discard block |
||
| 608 | 608 | function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type) |
| 609 | 609 | {
|
| 610 | 610 | |
| 611 | - switch ($sub_tab) {
|
|
| 612 | - case 'custom_fields': |
|
| 613 | - $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 614 | - break; |
|
| 611 | + switch ($sub_tab) {
|
|
| 612 | + case 'custom_fields': |
|
| 613 | + $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 614 | + break; |
|
| 615 | 615 | |
| 616 | - case 'sorting_options': |
|
| 617 | - $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 618 | - break; |
|
| 619 | - } |
|
| 620 | - return $heading; |
|
| 616 | + case 'sorting_options': |
|
| 617 | + $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 618 | + break; |
|
| 619 | + } |
|
| 620 | + return $heading; |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | |
@@ -635,16 +635,16 @@ discard block |
||
| 635 | 635 | function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type) |
| 636 | 636 | {
|
| 637 | 637 | |
| 638 | - switch ($sub_tab) {
|
|
| 639 | - case 'custom_fields': |
|
| 640 | - $note = sprintf(__('Click on any box below to add a field of that type on add %s listing form. You must be use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type));;
|
|
| 641 | - break; |
|
| 638 | + switch ($sub_tab) {
|
|
| 639 | + case 'custom_fields': |
|
| 640 | + $note = sprintf(__('Click on any box below to add a field of that type on add %s listing form. You must be use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type));;
|
|
| 641 | + break; |
|
| 642 | 642 | |
| 643 | - case 'sorting_options': |
|
| 644 | - $note = sprintf(__('Click on any box below to make it appear in sorting option dropdown on %s listing and search results.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 645 | - break; |
|
| 646 | - } |
|
| 647 | - return $note; |
|
| 643 | + case 'sorting_options': |
|
| 644 | + $note = sprintf(__('Click on any box below to make it appear in sorting option dropdown on %s listing and search results.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 645 | + break; |
|
| 646 | + } |
|
| 647 | + return $note; |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | |
@@ -662,16 +662,16 @@ discard block |
||
| 662 | 662 | function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type) |
| 663 | 663 | {
|
| 664 | 664 | |
| 665 | - switch ($sub_tab) {
|
|
| 666 | - case 'custom_fields': |
|
| 667 | - $heading = sprintf(__('List of fields those will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 668 | - break; |
|
| 665 | + switch ($sub_tab) {
|
|
| 666 | + case 'custom_fields': |
|
| 667 | + $heading = sprintf(__('List of fields those will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 668 | + break; |
|
| 669 | 669 | |
| 670 | - case 'sorting_options': |
|
| 671 | - $heading = sprintf(__('List of fields those will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 672 | - break; |
|
| 673 | - } |
|
| 674 | - return $heading; |
|
| 670 | + case 'sorting_options': |
|
| 671 | + $heading = sprintf(__('List of fields those will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 672 | + break; |
|
| 673 | + } |
|
| 674 | + return $heading; |
|
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | |
@@ -689,16 +689,16 @@ discard block |
||
| 689 | 689 | function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type) |
| 690 | 690 | {
|
| 691 | 691 | |
| 692 | - switch ($sub_tab) {
|
|
| 693 | - case 'custom_fields': |
|
| 694 | - $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type));;
|
|
| 695 | - break; |
|
| 692 | + switch ($sub_tab) {
|
|
| 693 | + case 'custom_fields': |
|
| 694 | + $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type));;
|
|
| 695 | + break; |
|
| 696 | 696 | |
| 697 | - case 'sorting_options': |
|
| 698 | - $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 699 | - break; |
|
| 700 | - } |
|
| 701 | - return $note; |
|
| 697 | + case 'sorting_options': |
|
| 698 | + $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type));
|
|
| 699 | + break; |
|
| 700 | + } |
|
| 701 | + return $note; |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | |
@@ -714,16 +714,16 @@ discard block |
||
| 714 | 714 | */ |
| 715 | 715 | function geodir_remove_unnecessary_fields() |
| 716 | 716 | {
|
| 717 | - global $wpdb, $plugin_prefix; |
|
| 717 | + global $wpdb, $plugin_prefix; |
|
| 718 | 718 | |
| 719 | - if (!get_option('geodir_remove_unnecessary_fields')) {
|
|
| 719 | + if (!get_option('geodir_remove_unnecessary_fields')) {
|
|
| 720 | 720 | |
| 721 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
|
|
| 722 | - $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
|
|
| 721 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
|
|
| 722 | + $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
|
|
| 723 | 723 | |
| 724 | - update_option('geodir_remove_unnecessary_fields', '1');
|
|
| 724 | + update_option('geodir_remove_unnecessary_fields', '1');
|
|
| 725 | 725 | |
| 726 | - } |
|
| 726 | + } |
|
| 727 | 727 | |
| 728 | 728 | } |
| 729 | 729 | |
@@ -741,25 +741,25 @@ discard block |
||
| 741 | 741 | */ |
| 742 | 742 | function geodir_admin_ajax_handler() |
| 743 | 743 | {
|
| 744 | - if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
|
|
| 745 | - $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action']; |
|
| 746 | - switch ($geodir_admin_ajax_action) {
|
|
| 747 | - case 'diagnosis' : |
|
| 748 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
| 749 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
| 750 | - call_user_func('geodir_diagnose_' . $diagnose_this);
|
|
| 751 | - exit(); |
|
| 752 | - break; |
|
| 753 | - |
|
| 754 | - case 'diagnosis-fix' : |
|
| 755 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
| 756 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
| 757 | - call_user_func('geodir_diagnose_' . $diagnose_this);
|
|
| 758 | - exit(); |
|
| 759 | - break; |
|
| 760 | - } |
|
| 761 | - } |
|
| 762 | - exit(); |
|
| 744 | + if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
|
|
| 745 | + $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action']; |
|
| 746 | + switch ($geodir_admin_ajax_action) {
|
|
| 747 | + case 'diagnosis' : |
|
| 748 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
| 749 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
| 750 | + call_user_func('geodir_diagnose_' . $diagnose_this);
|
|
| 751 | + exit(); |
|
| 752 | + break; |
|
| 753 | + |
|
| 754 | + case 'diagnosis-fix' : |
|
| 755 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
| 756 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
| 757 | + call_user_func('geodir_diagnose_' . $diagnose_this);
|
|
| 758 | + exit(); |
|
| 759 | + break; |
|
| 760 | + } |
|
| 761 | + } |
|
| 762 | + exit(); |
|
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | |
@@ -777,127 +777,127 @@ discard block |
||
| 777 | 777 | */ |
| 778 | 778 | function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix) |
| 779 | 779 | {
|
| 780 | - global $wpdb; |
|
| 781 | - //$filter_arr['output_str'] .='###'.$table.'###'; |
|
| 782 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
|
|
| 783 | - $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
|
|
| 784 | - $filter_arr['is_error_during_diagnose'] = true; |
|
| 785 | - |
|
| 786 | - } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
|
|
| 787 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 788 | - $filter_arr['is_error_during_diagnose'] = true; |
|
| 789 | - $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
|
|
| 790 | - $filter_arr['is_error_during_diagnose'] = true; |
|
| 791 | - |
|
| 792 | - if ($fix) {
|
|
| 793 | - $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
|
|
| 794 | - $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
|
|
| 795 | - |
|
| 796 | - if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
|
|
| 797 | - //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
|
|
| 798 | - |
|
| 799 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
|
|
| 800 | - |
|
| 801 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
|
|
| 802 | - $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
|
|
| 803 | - } else {
|
|
| 804 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 805 | - } |
|
| 806 | - |
|
| 807 | - } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
|
|
| 808 | - |
|
| 809 | - $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
|
|
| 810 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
|
|
| 811 | - |
|
| 812 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 813 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
|
|
| 814 | - } else {
|
|
| 815 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 816 | - } |
|
| 817 | - |
|
| 818 | - } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
|
|
| 819 | - |
|
| 820 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
|
|
| 821 | - |
|
| 822 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
|
|
| 823 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
|
|
| 824 | - } else {
|
|
| 825 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 826 | - } |
|
| 827 | - |
|
| 828 | - } |
|
| 829 | - |
|
| 830 | - } |
|
| 831 | - |
|
| 832 | - |
|
| 833 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
|
|
| 834 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 835 | - $filter_arr['is_error_during_diagnose'] = true; |
|
| 836 | - |
|
| 837 | - if ($fix) {
|
|
| 838 | - if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
|
|
| 839 | - if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
|
|
| 840 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
|
|
| 841 | - } else {
|
|
| 842 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
|
|
| 843 | - } |
|
| 844 | - |
|
| 845 | - } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
|
|
| 846 | - if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
|
|
| 847 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
|
|
| 848 | - } else {
|
|
| 849 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
|
|
| 850 | - } |
|
| 851 | - if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 852 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 853 | - } else {
|
|
| 854 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 855 | - } |
|
| 856 | - } else {// else rename the original table to _ms_bak
|
|
| 857 | - if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 858 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
|
|
| 859 | - } else {
|
|
| 860 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
|
|
| 861 | - } |
|
| 862 | - } |
|
| 863 | - } |
|
| 864 | - |
|
| 865 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
|
|
| 866 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 867 | - $filter_arr['is_error_during_diagnose'] = true; |
|
| 868 | - |
|
| 869 | - if ($fix) {
|
|
| 870 | - // if original table exists but new does not, rename |
|
| 871 | - if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 872 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 873 | - } else {
|
|
| 874 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 875 | - } |
|
| 876 | - |
|
| 877 | - } |
|
| 878 | - |
|
| 879 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
|
|
| 880 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 881 | - $filter_arr['is_error_during_diagnose'] = true; |
|
| 882 | - |
|
| 883 | - if ($fix) {
|
|
| 884 | - // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run; |
|
| 885 | - delete_option('geodirlocation_db_version');
|
|
| 886 | - delete_option('geodirevents_db_version');
|
|
| 887 | - delete_option('geodir_reviewrating_db_version');
|
|
| 888 | - delete_option('gdevents_db_version');
|
|
| 889 | - delete_option('geodirectory_db_version');
|
|
| 890 | - delete_option('geodirclaim_db_version');
|
|
| 891 | - delete_option('geodir_custom_posts_db_version');
|
|
| 892 | - delete_option('geodir_reviewratings_db_version');
|
|
| 893 | - delete_option('geodiradvancesearch_db_version');
|
|
| 894 | - $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
|
|
| 895 | - } |
|
| 896 | - |
|
| 897 | - } else {
|
|
| 898 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 899 | - } |
|
| 900 | - return $filter_arr; |
|
| 780 | + global $wpdb; |
|
| 781 | + //$filter_arr['output_str'] .='###'.$table.'###'; |
|
| 782 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
|
|
| 783 | + $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
|
|
| 784 | + $filter_arr['is_error_during_diagnose'] = true; |
|
| 785 | + |
|
| 786 | + } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
|
|
| 787 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 788 | + $filter_arr['is_error_during_diagnose'] = true; |
|
| 789 | + $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
|
|
| 790 | + $filter_arr['is_error_during_diagnose'] = true; |
|
| 791 | + |
|
| 792 | + if ($fix) {
|
|
| 793 | + $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
|
|
| 794 | + $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
|
|
| 795 | + |
|
| 796 | + if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
|
|
| 797 | + //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
|
|
| 798 | + |
|
| 799 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
|
|
| 800 | + |
|
| 801 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
|
|
| 802 | + $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
|
|
| 803 | + } else {
|
|
| 804 | + $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 805 | + } |
|
| 806 | + |
|
| 807 | + } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
|
|
| 808 | + |
|
| 809 | + $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
|
|
| 810 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
|
|
| 811 | + |
|
| 812 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 813 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
|
|
| 814 | + } else {
|
|
| 815 | + $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
|
|
| 819 | + |
|
| 820 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
|
|
| 821 | + |
|
| 822 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
|
|
| 823 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
|
|
| 824 | + } else {
|
|
| 825 | + $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 826 | + } |
|
| 827 | + |
|
| 828 | + } |
|
| 829 | + |
|
| 830 | + } |
|
| 831 | + |
|
| 832 | + |
|
| 833 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
|
|
| 834 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 835 | + $filter_arr['is_error_during_diagnose'] = true; |
|
| 836 | + |
|
| 837 | + if ($fix) {
|
|
| 838 | + if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
|
|
| 839 | + if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
|
|
| 840 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
|
|
| 841 | + } else {
|
|
| 842 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
|
|
| 843 | + } |
|
| 844 | + |
|
| 845 | + } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
|
|
| 846 | + if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
|
|
| 847 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
|
|
| 848 | + } else {
|
|
| 849 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
|
|
| 850 | + } |
|
| 851 | + if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 852 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 853 | + } else {
|
|
| 854 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 855 | + } |
|
| 856 | + } else {// else rename the original table to _ms_bak
|
|
| 857 | + if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 858 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
|
|
| 859 | + } else {
|
|
| 860 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
|
|
| 861 | + } |
|
| 862 | + } |
|
| 863 | + } |
|
| 864 | + |
|
| 865 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
|
|
| 866 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 867 | + $filter_arr['is_error_during_diagnose'] = true; |
|
| 868 | + |
|
| 869 | + if ($fix) {
|
|
| 870 | + // if original table exists but new does not, rename |
|
| 871 | + if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 872 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 873 | + } else {
|
|
| 874 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 875 | + } |
|
| 876 | + |
|
| 877 | + } |
|
| 878 | + |
|
| 879 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
|
|
| 880 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 881 | + $filter_arr['is_error_during_diagnose'] = true; |
|
| 882 | + |
|
| 883 | + if ($fix) {
|
|
| 884 | + // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run; |
|
| 885 | + delete_option('geodirlocation_db_version');
|
|
| 886 | + delete_option('geodirevents_db_version');
|
|
| 887 | + delete_option('geodir_reviewrating_db_version');
|
|
| 888 | + delete_option('gdevents_db_version');
|
|
| 889 | + delete_option('geodirectory_db_version');
|
|
| 890 | + delete_option('geodirclaim_db_version');
|
|
| 891 | + delete_option('geodir_custom_posts_db_version');
|
|
| 892 | + delete_option('geodir_reviewratings_db_version');
|
|
| 893 | + delete_option('geodiradvancesearch_db_version');
|
|
| 894 | + $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
|
|
| 895 | + } |
|
| 896 | + |
|
| 897 | + } else {
|
|
| 898 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 899 | + } |
|
| 900 | + return $filter_arr; |
|
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | |
@@ -911,53 +911,53 @@ discard block |
||
| 911 | 911 | */ |
| 912 | 912 | function geodir_diagnose_tags_sync() |
| 913 | 913 | {
|
| 914 | - global $wpdb, $plugin_prefix; |
|
| 915 | - $fix = isset($_POST['fix']) ? true : false; |
|
| 916 | - |
|
| 917 | - //if($fix){echo 'true';}else{echo 'false';}
|
|
| 918 | - $is_error_during_diagnose = false; |
|
| 919 | - $output_str = ''; |
|
| 920 | - |
|
| 921 | - |
|
| 922 | - $all_postypes = geodir_get_posttypes(); |
|
| 923 | - |
|
| 924 | - if (!empty($all_postypes)) {
|
|
| 925 | - foreach ($all_postypes as $key) {
|
|
| 926 | - // update each GD CPT |
|
| 927 | - $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
|
|
| 928 | - |
|
| 929 | - if (!empty($posts)) {
|
|
| 930 | - |
|
| 931 | - foreach ($posts as $p) {
|
|
| 932 | - $p->post_type = $key; |
|
| 933 | - $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
|
|
| 934 | - if (empty($raw_tags)) {
|
|
| 935 | - $post_tags = ''; |
|
| 936 | - } else {
|
|
| 937 | - $post_tags = implode(",", $raw_tags);
|
|
| 938 | - } |
|
| 939 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
| 940 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
|
|
| 941 | - |
|
| 942 | - } |
|
| 943 | - $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
|
|
| 944 | - } |
|
| 945 | - |
|
| 946 | - } |
|
| 947 | - |
|
| 948 | - } |
|
| 949 | - |
|
| 950 | - if ($is_error_during_diagnose) {
|
|
| 951 | - $info_div_class = "geodir_problem_info"; |
|
| 952 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 953 | - } else {
|
|
| 954 | - $info_div_class = "geodir_noproblem_info"; |
|
| 955 | - $fix_button_txt = ''; |
|
| 956 | - } |
|
| 957 | - echo "<ul class='$info_div_class'>"; |
|
| 958 | - echo $output_str; |
|
| 959 | - echo $fix_button_txt; |
|
| 960 | - echo "</ul>"; |
|
| 914 | + global $wpdb, $plugin_prefix; |
|
| 915 | + $fix = isset($_POST['fix']) ? true : false; |
|
| 916 | + |
|
| 917 | + //if($fix){echo 'true';}else{echo 'false';}
|
|
| 918 | + $is_error_during_diagnose = false; |
|
| 919 | + $output_str = ''; |
|
| 920 | + |
|
| 921 | + |
|
| 922 | + $all_postypes = geodir_get_posttypes(); |
|
| 923 | + |
|
| 924 | + if (!empty($all_postypes)) {
|
|
| 925 | + foreach ($all_postypes as $key) {
|
|
| 926 | + // update each GD CPT |
|
| 927 | + $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
|
|
| 928 | + |
|
| 929 | + if (!empty($posts)) {
|
|
| 930 | + |
|
| 931 | + foreach ($posts as $p) {
|
|
| 932 | + $p->post_type = $key; |
|
| 933 | + $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
|
|
| 934 | + if (empty($raw_tags)) {
|
|
| 935 | + $post_tags = ''; |
|
| 936 | + } else {
|
|
| 937 | + $post_tags = implode(",", $raw_tags);
|
|
| 938 | + } |
|
| 939 | + $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
| 940 | + $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
|
|
| 941 | + |
|
| 942 | + } |
|
| 943 | + $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
|
|
| 944 | + } |
|
| 945 | + |
|
| 946 | + } |
|
| 947 | + |
|
| 948 | + } |
|
| 949 | + |
|
| 950 | + if ($is_error_during_diagnose) {
|
|
| 951 | + $info_div_class = "geodir_problem_info"; |
|
| 952 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 953 | + } else {
|
|
| 954 | + $info_div_class = "geodir_noproblem_info"; |
|
| 955 | + $fix_button_txt = ''; |
|
| 956 | + } |
|
| 957 | + echo "<ul class='$info_div_class'>"; |
|
| 958 | + echo $output_str; |
|
| 959 | + echo $fix_button_txt; |
|
| 960 | + echo "</ul>"; |
|
| 961 | 961 | |
| 962 | 962 | } |
| 963 | 963 | |
@@ -973,75 +973,75 @@ discard block |
||
| 973 | 973 | */ |
| 974 | 974 | function geodir_diagnose_cats_sync() |
| 975 | 975 | {
|
| 976 | - global $wpdb, $plugin_prefix; |
|
| 977 | - $fix = isset($_POST['fix']) ? true : false; |
|
| 976 | + global $wpdb, $plugin_prefix; |
|
| 977 | + $fix = isset($_POST['fix']) ? true : false; |
|
| 978 | 978 | |
| 979 | - //if($fix){echo 'true';}else{echo 'false';}
|
|
| 980 | - $is_error_during_diagnose = false; |
|
| 981 | - $output_str = ''; |
|
| 979 | + //if($fix){echo 'true';}else{echo 'false';}
|
|
| 980 | + $is_error_during_diagnose = false; |
|
| 981 | + $output_str = ''; |
|
| 982 | 982 | |
| 983 | 983 | |
| 984 | - $all_postypes = geodir_get_posttypes(); |
|
| 984 | + $all_postypes = geodir_get_posttypes(); |
|
| 985 | 985 | |
| 986 | - if (!empty($all_postypes)) {
|
|
| 987 | - foreach ($all_postypes as $key) {
|
|
| 988 | - // update each GD CTP |
|
| 989 | - $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
|
|
| 986 | + if (!empty($all_postypes)) {
|
|
| 987 | + foreach ($all_postypes as $key) {
|
|
| 988 | + // update each GD CTP |
|
| 989 | + $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
|
|
| 990 | 990 | |
| 991 | - if (!empty($posts)) {
|
|
| 991 | + if (!empty($posts)) {
|
|
| 992 | 992 | |
| 993 | - foreach ($posts as $p) {
|
|
| 994 | - $p->post_type = $key; |
|
| 995 | - $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
|
|
| 993 | + foreach ($posts as $p) {
|
|
| 994 | + $p->post_type = $key; |
|
| 995 | + $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
|
|
| 996 | 996 | |
| 997 | - if (empty($raw_cats)) {
|
|
| 998 | - $post_categories = get_post_meta($p->post_id, 'post_categories', true); |
|
| 997 | + if (empty($raw_cats)) {
|
|
| 998 | + $post_categories = get_post_meta($p->post_id, 'post_categories', true); |
|
| 999 | 999 | |
| 1000 | - if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
|
|
| 1001 | - $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
|
|
| 1002 | - foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
|
|
| 1003 | - if (is_numeric($cat_part)) {
|
|
| 1004 | - $raw_cats[] = (int)$cat_part; |
|
| 1005 | - } |
|
| 1006 | - } |
|
| 1000 | + if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
|
|
| 1001 | + $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
|
|
| 1002 | + foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
|
|
| 1003 | + if (is_numeric($cat_part)) {
|
|
| 1004 | + $raw_cats[] = (int)$cat_part; |
|
| 1005 | + } |
|
| 1006 | + } |
|
| 1007 | 1007 | |
| 1008 | - } |
|
| 1008 | + } |
|
| 1009 | 1009 | |
| 1010 | - if (!empty($raw_cats)) {
|
|
| 1011 | - $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); |
|
| 1010 | + if (!empty($raw_cats)) {
|
|
| 1011 | + $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); |
|
| 1012 | 1012 | |
| 1013 | - } |
|
| 1013 | + } |
|
| 1014 | 1014 | |
| 1015 | - } |
|
| 1015 | + } |
|
| 1016 | 1016 | |
| 1017 | 1017 | |
| 1018 | - if (empty($raw_cats)) {
|
|
| 1019 | - $post_cats = ''; |
|
| 1020 | - } else {
|
|
| 1021 | - $post_cats = ',' . implode(",", $raw_cats) . ',';
|
|
| 1022 | - } |
|
| 1023 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
| 1024 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
|
|
| 1025 | - } |
|
| 1018 | + if (empty($raw_cats)) {
|
|
| 1019 | + $post_cats = ''; |
|
| 1020 | + } else {
|
|
| 1021 | + $post_cats = ',' . implode(",", $raw_cats) . ',';
|
|
| 1022 | + } |
|
| 1023 | + $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
| 1024 | + $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
|
|
| 1025 | + } |
|
| 1026 | 1026 | |
| 1027 | - } |
|
| 1028 | - $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
|
|
| 1027 | + } |
|
| 1028 | + $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
|
|
| 1029 | 1029 | |
| 1030 | - } |
|
| 1030 | + } |
|
| 1031 | 1031 | |
| 1032 | - } |
|
| 1032 | + } |
|
| 1033 | 1033 | |
| 1034 | - if ($is_error_during_diagnose) {
|
|
| 1035 | - $info_div_class = "geodir_problem_info"; |
|
| 1036 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1037 | - } else {
|
|
| 1038 | - $info_div_class = "geodir_noproblem_info"; |
|
| 1039 | - $fix_button_txt = ''; |
|
| 1040 | - } |
|
| 1041 | - echo "<ul class='$info_div_class'>"; |
|
| 1042 | - echo $output_str; |
|
| 1043 | - echo $fix_button_txt; |
|
| 1044 | - echo "</ul>"; |
|
| 1034 | + if ($is_error_during_diagnose) {
|
|
| 1035 | + $info_div_class = "geodir_problem_info"; |
|
| 1036 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1037 | + } else {
|
|
| 1038 | + $info_div_class = "geodir_noproblem_info"; |
|
| 1039 | + $fix_button_txt = ''; |
|
| 1040 | + } |
|
| 1041 | + echo "<ul class='$info_div_class'>"; |
|
| 1042 | + echo $output_str; |
|
| 1043 | + echo $fix_button_txt; |
|
| 1044 | + echo "</ul>"; |
|
| 1045 | 1045 | |
| 1046 | 1046 | } |
| 1047 | 1047 | |
@@ -1055,61 +1055,61 @@ discard block |
||
| 1055 | 1055 | */ |
| 1056 | 1056 | function geodir_diagnose_version_clear() |
| 1057 | 1057 | {
|
| 1058 | - global $wpdb, $plugin_prefix; |
|
| 1059 | - $fix = isset($_POST['fix']) ? true : false; |
|
| 1060 | - |
|
| 1061 | - //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1062 | - $is_error_during_diagnose = false; |
|
| 1063 | - $output_str = ''; |
|
| 1064 | - |
|
| 1065 | - |
|
| 1066 | - $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
|
|
| 1067 | - 'Payment Manager' => 'geodir_payments_db_version', |
|
| 1068 | - 'GeoDirectory Framework' => 'gdf_db_version', |
|
| 1069 | - 'Advanced Search' => 'geodiradvancesearch_db_version', |
|
| 1070 | - 'Review Rating Manager' => 'geodir_reviewratings_db_version', |
|
| 1071 | - 'Claim Manager' => 'geodirclaim_db_version', |
|
| 1072 | - 'CPT Manager' => 'geodir_custom_posts_db_version', |
|
| 1073 | - 'Location Manager' => 'geodirlocation_db_version', |
|
| 1074 | - 'Payment Manager' => 'geodir_payments_db_version', |
|
| 1075 | - 'Events Manager' => 'geodirevents_db_version', |
|
| 1076 | - ); |
|
| 1077 | - |
|
| 1078 | - /** |
|
| 1079 | - * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers. |
|
| 1080 | - * |
|
| 1081 | - * @since 1.0.0 |
|
| 1082 | - * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
|
|
| 1083 | - */ |
|
| 1084 | - $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
|
|
| 1085 | - |
|
| 1086 | - if (!empty($ver_arr)) {
|
|
| 1087 | - foreach ($ver_arr as $key => $val) {
|
|
| 1088 | - if (delete_option($val)) {
|
|
| 1089 | - $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
|
|
| 1090 | - } else {
|
|
| 1091 | - $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
|
|
| 1092 | - } |
|
| 1093 | - |
|
| 1094 | - } |
|
| 1095 | - |
|
| 1096 | - if ($output_str) {
|
|
| 1097 | - $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
|
|
| 1098 | - } |
|
| 1099 | - |
|
| 1100 | - } |
|
| 1101 | - |
|
| 1102 | - if ($is_error_during_diagnose) {
|
|
| 1103 | - $info_div_class = "geodir_problem_info"; |
|
| 1104 | - $fix_button_txt = ""; |
|
| 1105 | - } else {
|
|
| 1106 | - $info_div_class = "geodir_noproblem_info"; |
|
| 1107 | - $fix_button_txt = ''; |
|
| 1108 | - } |
|
| 1109 | - echo "<ul class='$info_div_class'>"; |
|
| 1110 | - echo $output_str; |
|
| 1111 | - echo $fix_button_txt; |
|
| 1112 | - echo "</ul>"; |
|
| 1058 | + global $wpdb, $plugin_prefix; |
|
| 1059 | + $fix = isset($_POST['fix']) ? true : false; |
|
| 1060 | + |
|
| 1061 | + //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1062 | + $is_error_during_diagnose = false; |
|
| 1063 | + $output_str = ''; |
|
| 1064 | + |
|
| 1065 | + |
|
| 1066 | + $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
|
|
| 1067 | + 'Payment Manager' => 'geodir_payments_db_version', |
|
| 1068 | + 'GeoDirectory Framework' => 'gdf_db_version', |
|
| 1069 | + 'Advanced Search' => 'geodiradvancesearch_db_version', |
|
| 1070 | + 'Review Rating Manager' => 'geodir_reviewratings_db_version', |
|
| 1071 | + 'Claim Manager' => 'geodirclaim_db_version', |
|
| 1072 | + 'CPT Manager' => 'geodir_custom_posts_db_version', |
|
| 1073 | + 'Location Manager' => 'geodirlocation_db_version', |
|
| 1074 | + 'Payment Manager' => 'geodir_payments_db_version', |
|
| 1075 | + 'Events Manager' => 'geodirevents_db_version', |
|
| 1076 | + ); |
|
| 1077 | + |
|
| 1078 | + /** |
|
| 1079 | + * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers. |
|
| 1080 | + * |
|
| 1081 | + * @since 1.0.0 |
|
| 1082 | + * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
|
|
| 1083 | + */ |
|
| 1084 | + $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
|
|
| 1085 | + |
|
| 1086 | + if (!empty($ver_arr)) {
|
|
| 1087 | + foreach ($ver_arr as $key => $val) {
|
|
| 1088 | + if (delete_option($val)) {
|
|
| 1089 | + $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
|
|
| 1090 | + } else {
|
|
| 1091 | + $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
|
|
| 1092 | + } |
|
| 1093 | + |
|
| 1094 | + } |
|
| 1095 | + |
|
| 1096 | + if ($output_str) {
|
|
| 1097 | + $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
|
|
| 1098 | + } |
|
| 1099 | + |
|
| 1100 | + } |
|
| 1101 | + |
|
| 1102 | + if ($is_error_during_diagnose) {
|
|
| 1103 | + $info_div_class = "geodir_problem_info"; |
|
| 1104 | + $fix_button_txt = ""; |
|
| 1105 | + } else {
|
|
| 1106 | + $info_div_class = "geodir_noproblem_info"; |
|
| 1107 | + $fix_button_txt = ''; |
|
| 1108 | + } |
|
| 1109 | + echo "<ul class='$info_div_class'>"; |
|
| 1110 | + echo $output_str; |
|
| 1111 | + echo $fix_button_txt; |
|
| 1112 | + echo "</ul>"; |
|
| 1113 | 1113 | |
| 1114 | 1114 | } |
| 1115 | 1115 | |
@@ -1123,59 +1123,59 @@ discard block |
||
| 1123 | 1123 | */ |
| 1124 | 1124 | function geodir_diagnose_ratings() |
| 1125 | 1125 | {
|
| 1126 | - global $wpdb; |
|
| 1127 | - $fix = isset($_POST['fix']) ? true : false; |
|
| 1128 | - |
|
| 1129 | - //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1130 | - $is_error_during_diagnose = false; |
|
| 1131 | - $output_str = ''; |
|
| 1132 | - |
|
| 1133 | - // check review locations |
|
| 1134 | - if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
|
|
| 1135 | - $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
|
|
| 1136 | - $is_error_during_diagnose = true; |
|
| 1137 | - |
|
| 1138 | - if ($fix) {
|
|
| 1139 | - if (geodir_fix_review_location()) {
|
|
| 1140 | - $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
|
|
| 1141 | - } else {
|
|
| 1142 | - $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1143 | - } |
|
| 1144 | - } |
|
| 1145 | - |
|
| 1146 | - } else {
|
|
| 1147 | - $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
|
|
| 1148 | - } |
|
| 1149 | - |
|
| 1150 | - // check review content |
|
| 1151 | - if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
|
|
| 1152 | - $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
|
|
| 1153 | - $is_error_during_diagnose = true; |
|
| 1154 | - |
|
| 1155 | - if ($fix) {
|
|
| 1156 | - if (geodir_fix_review_content()) {
|
|
| 1157 | - $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
|
|
| 1158 | - } else {
|
|
| 1159 | - $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1160 | - } |
|
| 1161 | - } |
|
| 1162 | - |
|
| 1163 | - } else {
|
|
| 1164 | - $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
|
|
| 1165 | - } |
|
| 1166 | - |
|
| 1167 | - |
|
| 1168 | - if ($is_error_during_diagnose) {
|
|
| 1169 | - $info_div_class = "geodir_problem_info"; |
|
| 1170 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1171 | - } else {
|
|
| 1172 | - $info_div_class = "geodir_noproblem_info"; |
|
| 1173 | - $fix_button_txt = ''; |
|
| 1174 | - } |
|
| 1175 | - echo "<ul class='$info_div_class'>"; |
|
| 1176 | - echo $output_str; |
|
| 1177 | - echo $fix_button_txt; |
|
| 1178 | - echo "</ul>"; |
|
| 1126 | + global $wpdb; |
|
| 1127 | + $fix = isset($_POST['fix']) ? true : false; |
|
| 1128 | + |
|
| 1129 | + //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1130 | + $is_error_during_diagnose = false; |
|
| 1131 | + $output_str = ''; |
|
| 1132 | + |
|
| 1133 | + // check review locations |
|
| 1134 | + if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
|
|
| 1135 | + $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
|
|
| 1136 | + $is_error_during_diagnose = true; |
|
| 1137 | + |
|
| 1138 | + if ($fix) {
|
|
| 1139 | + if (geodir_fix_review_location()) {
|
|
| 1140 | + $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
|
|
| 1141 | + } else {
|
|
| 1142 | + $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1143 | + } |
|
| 1144 | + } |
|
| 1145 | + |
|
| 1146 | + } else {
|
|
| 1147 | + $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
|
|
| 1148 | + } |
|
| 1149 | + |
|
| 1150 | + // check review content |
|
| 1151 | + if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
|
|
| 1152 | + $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
|
|
| 1153 | + $is_error_during_diagnose = true; |
|
| 1154 | + |
|
| 1155 | + if ($fix) {
|
|
| 1156 | + if (geodir_fix_review_content()) {
|
|
| 1157 | + $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
|
|
| 1158 | + } else {
|
|
| 1159 | + $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1160 | + } |
|
| 1161 | + } |
|
| 1162 | + |
|
| 1163 | + } else {
|
|
| 1164 | + $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
|
|
| 1165 | + } |
|
| 1166 | + |
|
| 1167 | + |
|
| 1168 | + if ($is_error_during_diagnose) {
|
|
| 1169 | + $info_div_class = "geodir_problem_info"; |
|
| 1170 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1171 | + } else {
|
|
| 1172 | + $info_div_class = "geodir_noproblem_info"; |
|
| 1173 | + $fix_button_txt = ''; |
|
| 1174 | + } |
|
| 1175 | + echo "<ul class='$info_div_class'>"; |
|
| 1176 | + echo $output_str; |
|
| 1177 | + echo $fix_button_txt; |
|
| 1178 | + echo "</ul>"; |
|
| 1179 | 1179 | |
| 1180 | 1180 | } |
| 1181 | 1181 | |
@@ -1189,57 +1189,57 @@ discard block |
||
| 1189 | 1189 | */ |
| 1190 | 1190 | function geodir_diagnose_multisite_conversion() |
| 1191 | 1191 | {
|
| 1192 | - global $wpdb; |
|
| 1193 | - $fix = isset($_POST['fix']) ? true : false; |
|
| 1194 | - //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1195 | - $is_error_during_diagnose = false; |
|
| 1196 | - $output_str = ''; |
|
| 1197 | - |
|
| 1198 | - $filter_arr = array(); |
|
| 1199 | - $filter_arr['output_str'] = $output_str; |
|
| 1200 | - $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose; |
|
| 1201 | - $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
|
|
| 1202 | - 'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
|
|
| 1203 | - 'geodir_post_icon' => __('Post icon', 'geodirectory'),
|
|
| 1204 | - 'geodir_attachments' => __('Attachments', 'geodirectory'),
|
|
| 1205 | - 'geodir_post_review' => __('Reviews', 'geodirectory'),
|
|
| 1206 | - 'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
|
|
| 1207 | - 'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
|
|
| 1208 | - ); |
|
| 1209 | - |
|
| 1210 | - // allow other addons to hook in and add their checks |
|
| 1211 | - |
|
| 1212 | - /** |
|
| 1213 | - * Filter the array of tables. |
|
| 1214 | - * |
|
| 1215 | - * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks. |
|
| 1216 | - * |
|
| 1217 | - * @since 1.0.0 |
|
| 1218 | - * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
|
|
| 1219 | - */ |
|
| 1220 | - $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
|
|
| 1221 | - |
|
| 1222 | - foreach ($table_arr as $table => $table_name) {
|
|
| 1223 | - // Diagnose table |
|
| 1224 | - $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix); |
|
| 1225 | - } |
|
| 1226 | - |
|
| 1227 | - |
|
| 1228 | - $output_str = $filter_arr['output_str']; |
|
| 1229 | - $is_error_during_diagnose = $filter_arr['is_error_during_diagnose']; |
|
| 1230 | - |
|
| 1231 | - |
|
| 1232 | - if ($is_error_during_diagnose) {
|
|
| 1233 | - $info_div_class = "geodir_problem_info"; |
|
| 1234 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
|
|
| 1235 | - } else {
|
|
| 1236 | - $info_div_class = "geodir_noproblem_info"; |
|
| 1237 | - $fix_button_txt = ''; |
|
| 1238 | - } |
|
| 1239 | - echo "<ul class='$info_div_class'>"; |
|
| 1240 | - echo $output_str; |
|
| 1241 | - echo $fix_button_txt; |
|
| 1242 | - echo "</ul>"; |
|
| 1192 | + global $wpdb; |
|
| 1193 | + $fix = isset($_POST['fix']) ? true : false; |
|
| 1194 | + //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1195 | + $is_error_during_diagnose = false; |
|
| 1196 | + $output_str = ''; |
|
| 1197 | + |
|
| 1198 | + $filter_arr = array(); |
|
| 1199 | + $filter_arr['output_str'] = $output_str; |
|
| 1200 | + $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose; |
|
| 1201 | + $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
|
|
| 1202 | + 'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
|
|
| 1203 | + 'geodir_post_icon' => __('Post icon', 'geodirectory'),
|
|
| 1204 | + 'geodir_attachments' => __('Attachments', 'geodirectory'),
|
|
| 1205 | + 'geodir_post_review' => __('Reviews', 'geodirectory'),
|
|
| 1206 | + 'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
|
|
| 1207 | + 'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
|
|
| 1208 | + ); |
|
| 1209 | + |
|
| 1210 | + // allow other addons to hook in and add their checks |
|
| 1211 | + |
|
| 1212 | + /** |
|
| 1213 | + * Filter the array of tables. |
|
| 1214 | + * |
|
| 1215 | + * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks. |
|
| 1216 | + * |
|
| 1217 | + * @since 1.0.0 |
|
| 1218 | + * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
|
|
| 1219 | + */ |
|
| 1220 | + $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
|
|
| 1221 | + |
|
| 1222 | + foreach ($table_arr as $table => $table_name) {
|
|
| 1223 | + // Diagnose table |
|
| 1224 | + $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix); |
|
| 1225 | + } |
|
| 1226 | + |
|
| 1227 | + |
|
| 1228 | + $output_str = $filter_arr['output_str']; |
|
| 1229 | + $is_error_during_diagnose = $filter_arr['is_error_during_diagnose']; |
|
| 1230 | + |
|
| 1231 | + |
|
| 1232 | + if ($is_error_during_diagnose) {
|
|
| 1233 | + $info_div_class = "geodir_problem_info"; |
|
| 1234 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
|
|
| 1235 | + } else {
|
|
| 1236 | + $info_div_class = "geodir_noproblem_info"; |
|
| 1237 | + $fix_button_txt = ''; |
|
| 1238 | + } |
|
| 1239 | + echo "<ul class='$info_div_class'>"; |
|
| 1240 | + echo $output_str; |
|
| 1241 | + echo $fix_button_txt; |
|
| 1242 | + echo "</ul>"; |
|
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | 1245 | /** |
@@ -1257,39 +1257,39 @@ discard block |
||
| 1257 | 1257 | */ |
| 1258 | 1258 | function geodir_fix_virtual_page($slug, $page_title, $old_id, $option) |
| 1259 | 1259 | {
|
| 1260 | - global $wpdb, $current_user; |
|
| 1261 | - |
|
| 1262 | - if (!empty($old_id)) {
|
|
| 1263 | - wp_delete_post($old_id, true); |
|
| 1264 | - }//delete post if already there |
|
| 1265 | - else {
|
|
| 1266 | - $page_found = $wpdb->get_var( |
|
| 1267 | - $wpdb->prepare( |
|
| 1268 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 1269 | - array($slug) |
|
| 1270 | - ) |
|
| 1271 | - ); |
|
| 1272 | - wp_delete_post($page_found, true); |
|
| 1273 | - |
|
| 1274 | - } |
|
| 1275 | - |
|
| 1276 | - $page_data = array( |
|
| 1277 | - 'post_status' => 'publish', |
|
| 1278 | - 'post_type' => 'page', |
|
| 1279 | - 'post_author' => $current_user->ID, |
|
| 1280 | - 'post_name' => $slug, |
|
| 1281 | - 'post_title' => $page_title, |
|
| 1282 | - 'post_content' => '', |
|
| 1283 | - 'post_parent' => 0, |
|
| 1284 | - 'comment_status' => 'closed' |
|
| 1285 | - ); |
|
| 1286 | - $page_id = wp_insert_post($page_data); |
|
| 1287 | - update_option($option, $page_id); |
|
| 1288 | - if ($page_id) {
|
|
| 1289 | - return true; |
|
| 1290 | - } else {
|
|
| 1291 | - return false; |
|
| 1292 | - } |
|
| 1260 | + global $wpdb, $current_user; |
|
| 1261 | + |
|
| 1262 | + if (!empty($old_id)) {
|
|
| 1263 | + wp_delete_post($old_id, true); |
|
| 1264 | + }//delete post if already there |
|
| 1265 | + else {
|
|
| 1266 | + $page_found = $wpdb->get_var( |
|
| 1267 | + $wpdb->prepare( |
|
| 1268 | + "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 1269 | + array($slug) |
|
| 1270 | + ) |
|
| 1271 | + ); |
|
| 1272 | + wp_delete_post($page_found, true); |
|
| 1273 | + |
|
| 1274 | + } |
|
| 1275 | + |
|
| 1276 | + $page_data = array( |
|
| 1277 | + 'post_status' => 'publish', |
|
| 1278 | + 'post_type' => 'page', |
|
| 1279 | + 'post_author' => $current_user->ID, |
|
| 1280 | + 'post_name' => $slug, |
|
| 1281 | + 'post_title' => $page_title, |
|
| 1282 | + 'post_content' => '', |
|
| 1283 | + 'post_parent' => 0, |
|
| 1284 | + 'comment_status' => 'closed' |
|
| 1285 | + ); |
|
| 1286 | + $page_id = wp_insert_post($page_data); |
|
| 1287 | + update_option($option, $page_id); |
|
| 1288 | + if ($page_id) {
|
|
| 1289 | + return true; |
|
| 1290 | + } else {
|
|
| 1291 | + return false; |
|
| 1292 | + } |
|
| 1293 | 1293 | } |
| 1294 | 1294 | |
| 1295 | 1295 | /** |
@@ -1301,212 +1301,212 @@ discard block |
||
| 1301 | 1301 | */ |
| 1302 | 1302 | function geodir_diagnose_default_pages() |
| 1303 | 1303 | {
|
| 1304 | - global $wpdb; |
|
| 1305 | - $is_error_during_diagnose = false; |
|
| 1306 | - $output_str = ''; |
|
| 1307 | - $fix = isset($_POST['fix']) ? true : false; |
|
| 1308 | - |
|
| 1309 | - ////////////////////////////////// |
|
| 1310 | - /* Diagnose GD Home Page Starts */ |
|
| 1311 | - ////////////////////////////////// |
|
| 1312 | - $option_value = get_option('geodir_home_page');
|
|
| 1313 | - $page = get_post($option_value); |
|
| 1314 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1315 | - |
|
| 1316 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1317 | - $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1318 | - else {
|
|
| 1319 | - $is_error_during_diagnose = true; |
|
| 1320 | - $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1321 | - if ($fix) {
|
|
| 1322 | - if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
|
|
| 1323 | - $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1324 | - } else {
|
|
| 1325 | - $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1326 | - } |
|
| 1327 | - } |
|
| 1328 | - } |
|
| 1329 | - |
|
| 1330 | - //////////////////////////////// |
|
| 1331 | - /* Diagnose GD Home Page Ends */ |
|
| 1332 | - //////////////////////////////// |
|
| 1333 | - |
|
| 1334 | - ////////////////////////////////// |
|
| 1335 | - /* Diagnose Add Listing Page Starts */ |
|
| 1336 | - ////////////////////////////////// |
|
| 1337 | - $option_value = get_option('geodir_add_listing_page');
|
|
| 1338 | - $page = get_post($option_value); |
|
| 1339 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1340 | - |
|
| 1341 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1342 | - $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1343 | - else {
|
|
| 1344 | - $is_error_during_diagnose = true; |
|
| 1345 | - $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1346 | - if ($fix) {
|
|
| 1347 | - if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
|
|
| 1348 | - $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1349 | - } else {
|
|
| 1350 | - $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1351 | - } |
|
| 1352 | - } |
|
| 1353 | - } |
|
| 1354 | - |
|
| 1355 | - //////////////////////////////// |
|
| 1356 | - /* Diagnose Add Listing Page Ends */ |
|
| 1357 | - //////////////////////////////// |
|
| 1358 | - |
|
| 1359 | - |
|
| 1360 | - ////////////////////////////////// |
|
| 1361 | - /* Diagnose Listing Preview Page Starts */ |
|
| 1362 | - ////////////////////////////////// |
|
| 1363 | - $option_value = get_option('geodir_preview_page');
|
|
| 1364 | - $page = get_post($option_value); |
|
| 1365 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1366 | - |
|
| 1367 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1368 | - $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1369 | - else {
|
|
| 1370 | - $is_error_during_diagnose = true; |
|
| 1371 | - $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1372 | - if ($fix) {
|
|
| 1373 | - if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
|
|
| 1374 | - $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1375 | - } else {
|
|
| 1376 | - $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1377 | - } |
|
| 1378 | - } |
|
| 1379 | - } |
|
| 1380 | - |
|
| 1381 | - //////////////////////////////// |
|
| 1382 | - /* Diagnose Listing Preview Page Ends */ |
|
| 1383 | - //////////////////////////////// |
|
| 1384 | - |
|
| 1385 | - ////////////////////////////////// |
|
| 1386 | - /* Diagnose Listing Success Page Starts */ |
|
| 1387 | - ////////////////////////////////// |
|
| 1388 | - $option_value = get_option('geodir_success_page');
|
|
| 1389 | - $page = get_post($option_value); |
|
| 1390 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1391 | - |
|
| 1392 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1393 | - $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1394 | - else {
|
|
| 1395 | - $is_error_during_diagnose = true; |
|
| 1396 | - $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1397 | - if ($fix) {
|
|
| 1398 | - if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
|
|
| 1399 | - $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1400 | - } else {
|
|
| 1401 | - $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1402 | - } |
|
| 1403 | - } |
|
| 1404 | - } |
|
| 1405 | - |
|
| 1406 | - //////////////////////////////// |
|
| 1407 | - /* Diagnose Listing Sucess Page Ends */ |
|
| 1408 | - //////////////////////////////// |
|
| 1409 | - |
|
| 1410 | - ////////////////////////////////// |
|
| 1411 | - /* Diagnose Info Page Starts */ |
|
| 1412 | - ////////////////////////////////// |
|
| 1413 | - $option_value = get_option('geodir_info_page');
|
|
| 1414 | - $page = get_post($option_value); |
|
| 1415 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1416 | - |
|
| 1417 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1418 | - $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1419 | - else {
|
|
| 1420 | - $is_error_during_diagnose = true; |
|
| 1421 | - $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1422 | - if ($fix) {
|
|
| 1423 | - if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
|
|
| 1424 | - $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1425 | - } else {
|
|
| 1426 | - $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1427 | - } |
|
| 1428 | - } |
|
| 1429 | - } |
|
| 1430 | - |
|
| 1431 | - //////////////////////////////// |
|
| 1432 | - /* Diagnose Info Page Ends */ |
|
| 1433 | - //////////////////////////////// |
|
| 1434 | - |
|
| 1435 | - ////////////////////////////////// |
|
| 1436 | - /* Diagnose Login Page Starts */ |
|
| 1437 | - ////////////////////////////////// |
|
| 1438 | - $option_value = get_option('geodir_login_page');
|
|
| 1439 | - $page = get_post($option_value); |
|
| 1440 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1441 | - |
|
| 1442 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1443 | - $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1444 | - else {
|
|
| 1445 | - $is_error_during_diagnose = true; |
|
| 1446 | - $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1447 | - if ($fix) {
|
|
| 1448 | - if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
|
|
| 1449 | - $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1450 | - } else {
|
|
| 1451 | - $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1452 | - } |
|
| 1453 | - } |
|
| 1454 | - } |
|
| 1455 | - |
|
| 1456 | - //////////////////////////////// |
|
| 1457 | - /* Diagnose Info Page Ends */ |
|
| 1458 | - //////////////////////////////// |
|
| 1459 | - |
|
| 1460 | - ////////////////////////////////// |
|
| 1461 | - /* Diagnose Location Page Starts */ |
|
| 1462 | - ////////////////////////////////// |
|
| 1463 | - $option_value = get_option('geodir_location_page');
|
|
| 1464 | - $page = get_post($option_value); |
|
| 1465 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1466 | - |
|
| 1467 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1468 | - $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1469 | - else {
|
|
| 1470 | - $is_error_during_diagnose = true; |
|
| 1471 | - $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1472 | - if ($fix) {
|
|
| 1473 | - if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
|
|
| 1474 | - $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1475 | - } else {
|
|
| 1476 | - $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1477 | - } |
|
| 1478 | - } |
|
| 1479 | - } |
|
| 1480 | - |
|
| 1481 | - //////////////////////////////// |
|
| 1482 | - /* Diagnose Location Page Ends */ |
|
| 1483 | - //////////////////////////////// |
|
| 1484 | - |
|
| 1485 | - $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
|
|
| 1486 | - /** |
|
| 1487 | - * This action is called at the end of the GD Tools page check function. |
|
| 1488 | - * |
|
| 1489 | - * @since 1.5.2 |
|
| 1490 | - */ |
|
| 1491 | - $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
|
|
| 1492 | - |
|
| 1493 | - $output_str = $page_chk_arr['output_str']; |
|
| 1494 | - $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; |
|
| 1495 | - |
|
| 1496 | - if ($is_error_during_diagnose) {
|
|
| 1497 | - if ($fix) {
|
|
| 1498 | - flush_rewrite_rules(); |
|
| 1499 | - } |
|
| 1500 | - $info_div_class = "geodir_problem_info"; |
|
| 1501 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
|
|
| 1502 | - } else {
|
|
| 1503 | - $info_div_class = "geodir_noproblem_info"; |
|
| 1504 | - $fix_button_txt = ''; |
|
| 1505 | - } |
|
| 1506 | - echo "<ul class='$info_div_class'>"; |
|
| 1507 | - echo $output_str; |
|
| 1508 | - echo $fix_button_txt; |
|
| 1509 | - echo "</ul>"; |
|
| 1304 | + global $wpdb; |
|
| 1305 | + $is_error_during_diagnose = false; |
|
| 1306 | + $output_str = ''; |
|
| 1307 | + $fix = isset($_POST['fix']) ? true : false; |
|
| 1308 | + |
|
| 1309 | + ////////////////////////////////// |
|
| 1310 | + /* Diagnose GD Home Page Starts */ |
|
| 1311 | + ////////////////////////////////// |
|
| 1312 | + $option_value = get_option('geodir_home_page');
|
|
| 1313 | + $page = get_post($option_value); |
|
| 1314 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1315 | + |
|
| 1316 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1317 | + $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1318 | + else {
|
|
| 1319 | + $is_error_during_diagnose = true; |
|
| 1320 | + $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1321 | + if ($fix) {
|
|
| 1322 | + if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
|
|
| 1323 | + $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1324 | + } else {
|
|
| 1325 | + $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1326 | + } |
|
| 1327 | + } |
|
| 1328 | + } |
|
| 1329 | + |
|
| 1330 | + //////////////////////////////// |
|
| 1331 | + /* Diagnose GD Home Page Ends */ |
|
| 1332 | + //////////////////////////////// |
|
| 1333 | + |
|
| 1334 | + ////////////////////////////////// |
|
| 1335 | + /* Diagnose Add Listing Page Starts */ |
|
| 1336 | + ////////////////////////////////// |
|
| 1337 | + $option_value = get_option('geodir_add_listing_page');
|
|
| 1338 | + $page = get_post($option_value); |
|
| 1339 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1340 | + |
|
| 1341 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1342 | + $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1343 | + else {
|
|
| 1344 | + $is_error_during_diagnose = true; |
|
| 1345 | + $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1346 | + if ($fix) {
|
|
| 1347 | + if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
|
|
| 1348 | + $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1349 | + } else {
|
|
| 1350 | + $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1351 | + } |
|
| 1352 | + } |
|
| 1353 | + } |
|
| 1354 | + |
|
| 1355 | + //////////////////////////////// |
|
| 1356 | + /* Diagnose Add Listing Page Ends */ |
|
| 1357 | + //////////////////////////////// |
|
| 1358 | + |
|
| 1359 | + |
|
| 1360 | + ////////////////////////////////// |
|
| 1361 | + /* Diagnose Listing Preview Page Starts */ |
|
| 1362 | + ////////////////////////////////// |
|
| 1363 | + $option_value = get_option('geodir_preview_page');
|
|
| 1364 | + $page = get_post($option_value); |
|
| 1365 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1366 | + |
|
| 1367 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1368 | + $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1369 | + else {
|
|
| 1370 | + $is_error_during_diagnose = true; |
|
| 1371 | + $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1372 | + if ($fix) {
|
|
| 1373 | + if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
|
|
| 1374 | + $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1375 | + } else {
|
|
| 1376 | + $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1377 | + } |
|
| 1378 | + } |
|
| 1379 | + } |
|
| 1380 | + |
|
| 1381 | + //////////////////////////////// |
|
| 1382 | + /* Diagnose Listing Preview Page Ends */ |
|
| 1383 | + //////////////////////////////// |
|
| 1384 | + |
|
| 1385 | + ////////////////////////////////// |
|
| 1386 | + /* Diagnose Listing Success Page Starts */ |
|
| 1387 | + ////////////////////////////////// |
|
| 1388 | + $option_value = get_option('geodir_success_page');
|
|
| 1389 | + $page = get_post($option_value); |
|
| 1390 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1391 | + |
|
| 1392 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1393 | + $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1394 | + else {
|
|
| 1395 | + $is_error_during_diagnose = true; |
|
| 1396 | + $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1397 | + if ($fix) {
|
|
| 1398 | + if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
|
|
| 1399 | + $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1400 | + } else {
|
|
| 1401 | + $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1402 | + } |
|
| 1403 | + } |
|
| 1404 | + } |
|
| 1405 | + |
|
| 1406 | + //////////////////////////////// |
|
| 1407 | + /* Diagnose Listing Sucess Page Ends */ |
|
| 1408 | + //////////////////////////////// |
|
| 1409 | + |
|
| 1410 | + ////////////////////////////////// |
|
| 1411 | + /* Diagnose Info Page Starts */ |
|
| 1412 | + ////////////////////////////////// |
|
| 1413 | + $option_value = get_option('geodir_info_page');
|
|
| 1414 | + $page = get_post($option_value); |
|
| 1415 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1416 | + |
|
| 1417 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1418 | + $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1419 | + else {
|
|
| 1420 | + $is_error_during_diagnose = true; |
|
| 1421 | + $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1422 | + if ($fix) {
|
|
| 1423 | + if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
|
|
| 1424 | + $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1425 | + } else {
|
|
| 1426 | + $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1427 | + } |
|
| 1428 | + } |
|
| 1429 | + } |
|
| 1430 | + |
|
| 1431 | + //////////////////////////////// |
|
| 1432 | + /* Diagnose Info Page Ends */ |
|
| 1433 | + //////////////////////////////// |
|
| 1434 | + |
|
| 1435 | + ////////////////////////////////// |
|
| 1436 | + /* Diagnose Login Page Starts */ |
|
| 1437 | + ////////////////////////////////// |
|
| 1438 | + $option_value = get_option('geodir_login_page');
|
|
| 1439 | + $page = get_post($option_value); |
|
| 1440 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1441 | + |
|
| 1442 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1443 | + $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1444 | + else {
|
|
| 1445 | + $is_error_during_diagnose = true; |
|
| 1446 | + $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1447 | + if ($fix) {
|
|
| 1448 | + if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
|
|
| 1449 | + $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1450 | + } else {
|
|
| 1451 | + $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1452 | + } |
|
| 1453 | + } |
|
| 1454 | + } |
|
| 1455 | + |
|
| 1456 | + //////////////////////////////// |
|
| 1457 | + /* Diagnose Info Page Ends */ |
|
| 1458 | + //////////////////////////////// |
|
| 1459 | + |
|
| 1460 | + ////////////////////////////////// |
|
| 1461 | + /* Diagnose Location Page Starts */ |
|
| 1462 | + ////////////////////////////////// |
|
| 1463 | + $option_value = get_option('geodir_location_page');
|
|
| 1464 | + $page = get_post($option_value); |
|
| 1465 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1466 | + |
|
| 1467 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1468 | + $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1469 | + else {
|
|
| 1470 | + $is_error_during_diagnose = true; |
|
| 1471 | + $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1472 | + if ($fix) {
|
|
| 1473 | + if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
|
|
| 1474 | + $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1475 | + } else {
|
|
| 1476 | + $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1477 | + } |
|
| 1478 | + } |
|
| 1479 | + } |
|
| 1480 | + |
|
| 1481 | + //////////////////////////////// |
|
| 1482 | + /* Diagnose Location Page Ends */ |
|
| 1483 | + //////////////////////////////// |
|
| 1484 | + |
|
| 1485 | + $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
|
|
| 1486 | + /** |
|
| 1487 | + * This action is called at the end of the GD Tools page check function. |
|
| 1488 | + * |
|
| 1489 | + * @since 1.5.2 |
|
| 1490 | + */ |
|
| 1491 | + $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
|
|
| 1492 | + |
|
| 1493 | + $output_str = $page_chk_arr['output_str']; |
|
| 1494 | + $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; |
|
| 1495 | + |
|
| 1496 | + if ($is_error_during_diagnose) {
|
|
| 1497 | + if ($fix) {
|
|
| 1498 | + flush_rewrite_rules(); |
|
| 1499 | + } |
|
| 1500 | + $info_div_class = "geodir_problem_info"; |
|
| 1501 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
|
|
| 1502 | + } else {
|
|
| 1503 | + $info_div_class = "geodir_noproblem_info"; |
|
| 1504 | + $fix_button_txt = ''; |
|
| 1505 | + } |
|
| 1506 | + echo "<ul class='$info_div_class'>"; |
|
| 1507 | + echo $output_str; |
|
| 1508 | + echo $fix_button_txt; |
|
| 1509 | + echo "</ul>"; |
|
| 1510 | 1510 | |
| 1511 | 1511 | } |
| 1512 | 1512 | |
@@ -1518,26 +1518,26 @@ discard block |
||
| 1518 | 1518 | * @global object $wpdb WordPress Database object. |
| 1519 | 1519 | */ |
| 1520 | 1520 | function geodir_diagnose_load_db_language() {
|
| 1521 | - global $wpdb; |
|
| 1521 | + global $wpdb; |
|
| 1522 | 1522 | |
| 1523 | 1523 | $is_error_during_diagnose = geodirectory_load_db_language(); |
| 1524 | 1524 | |
| 1525 | - $output_str = ''; |
|
| 1526 | - $fix_button_txt = ''; |
|
| 1525 | + $output_str = ''; |
|
| 1526 | + $fix_button_txt = ''; |
|
| 1527 | 1527 | |
| 1528 | - if ($is_error_during_diagnose) {
|
|
| 1529 | - $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
|
|
| 1528 | + if ($is_error_during_diagnose) {
|
|
| 1529 | + $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
|
|
| 1530 | 1530 | $info_div_class = "geodir_problem_info"; |
| 1531 | - } else {
|
|
| 1532 | - $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
|
|
| 1531 | + } else {
|
|
| 1532 | + $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
|
|
| 1533 | 1533 | $info_div_class = "geodir_noproblem_info"; |
| 1534 | - $fix_button_txt = ''; |
|
| 1535 | - } |
|
| 1534 | + $fix_button_txt = ''; |
|
| 1535 | + } |
|
| 1536 | 1536 | |
| 1537 | 1537 | echo "<ul class='$info_div_class'>"; |
| 1538 | - echo $output_str; |
|
| 1539 | - echo $fix_button_txt; |
|
| 1540 | - echo "</ul>"; |
|
| 1538 | + echo $output_str; |
|
| 1539 | + echo $fix_button_txt; |
|
| 1540 | + echo "</ul>"; |
|
| 1541 | 1541 | |
| 1542 | 1542 | } |
| 1543 | 1543 | |
@@ -1568,23 +1568,23 @@ discard block |
||
| 1568 | 1568 | */ |
| 1569 | 1569 | function geodir_posts_clauses_request($clauses) |
| 1570 | 1570 | {
|
| 1571 | - global $wpdb, $wp_query, $plugin_prefix; |
|
| 1571 | + global $wpdb, $wp_query, $plugin_prefix; |
|
| 1572 | 1572 | |
| 1573 | - if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
|
|
| 1574 | - $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; |
|
| 1573 | + if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
|
|
| 1574 | + $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; |
|
| 1575 | 1575 | |
| 1576 | - $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; |
|
| 1577 | - $clauses['join'] = $join; |
|
| 1576 | + $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; |
|
| 1577 | + $clauses['join'] = $join; |
|
| 1578 | 1578 | |
| 1579 | - $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; |
|
| 1580 | - $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire'; |
|
| 1581 | - $clauses['fields'] = $fields; |
|
| 1579 | + $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; |
|
| 1580 | + $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire'; |
|
| 1581 | + $clauses['fields'] = $fields; |
|
| 1582 | 1582 | |
| 1583 | - $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; |
|
| 1584 | - $orderby = 'gd_expire ' . $order; |
|
| 1585 | - $clauses['orderby'] = $orderby; |
|
| 1586 | - } |
|
| 1587 | - return $clauses; |
|
| 1583 | + $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; |
|
| 1584 | + $orderby = 'gd_expire ' . $order; |
|
| 1585 | + $clauses['orderby'] = $orderby; |
|
| 1586 | + } |
|
| 1587 | + return $clauses; |
|
| 1588 | 1588 | } |
| 1589 | 1589 | |
| 1590 | 1590 | |
@@ -1605,7 +1605,7 @@ discard block |
||
| 1605 | 1605 | */ |
| 1606 | 1606 | function gd_theme_switch_compat_check() |
| 1607 | 1607 | {
|
| 1608 | - gd_set_theme_compat(); |
|
| 1608 | + gd_set_theme_compat(); |
|
| 1609 | 1609 | } |
| 1610 | 1610 | |
| 1611 | 1611 | /** |
@@ -1618,27 +1618,27 @@ discard block |
||
| 1618 | 1618 | */ |
| 1619 | 1619 | function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") |
| 1620 | 1620 | {
|
| 1621 | - if (function_exists('str_getcsv')) {
|
|
| 1622 | - $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape); |
|
| 1623 | - } else {
|
|
| 1624 | - global $current_user; |
|
| 1625 | - $upload_dir = wp_upload_dir(); |
|
| 1626 | - |
|
| 1627 | - $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; |
|
| 1628 | - $handle = fopen($file, 'w'); |
|
| 1629 | - |
|
| 1630 | - fwrite($handle, $input); |
|
| 1631 | - fclose($handle); |
|
| 1632 | - |
|
| 1633 | - $handle = fopen($file, 'rt'); |
|
| 1634 | - if (PHP_VERSION >= '5.3.0') {
|
|
| 1635 | - $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape); |
|
| 1636 | - } else {
|
|
| 1637 | - $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure); |
|
| 1638 | - } |
|
| 1639 | - fclose($handle); |
|
| 1640 | - } |
|
| 1641 | - return $fgetcsv; |
|
| 1621 | + if (function_exists('str_getcsv')) {
|
|
| 1622 | + $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape); |
|
| 1623 | + } else {
|
|
| 1624 | + global $current_user; |
|
| 1625 | + $upload_dir = wp_upload_dir(); |
|
| 1626 | + |
|
| 1627 | + $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; |
|
| 1628 | + $handle = fopen($file, 'w'); |
|
| 1629 | + |
|
| 1630 | + fwrite($handle, $input); |
|
| 1631 | + fclose($handle); |
|
| 1632 | + |
|
| 1633 | + $handle = fopen($file, 'rt'); |
|
| 1634 | + if (PHP_VERSION >= '5.3.0') {
|
|
| 1635 | + $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape); |
|
| 1636 | + } else {
|
|
| 1637 | + $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure); |
|
| 1638 | + } |
|
| 1639 | + fclose($handle); |
|
| 1640 | + } |
|
| 1641 | + return $fgetcsv; |
|
| 1642 | 1642 | } |
| 1643 | 1643 | |
| 1644 | 1644 | add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv');
|
@@ -1653,375 +1653,375 @@ discard block |
||
| 1653 | 1653 | */ |
| 1654 | 1654 | function geodir_ajax_import_csv() |
| 1655 | 1655 | {
|
| 1656 | - error_reporting(0); // hide error to get clean json response |
|
| 1656 | + error_reporting(0); // hide error to get clean json response |
|
| 1657 | 1657 | |
| 1658 | - global $wpdb, $plugin_prefix, $current_user; |
|
| 1659 | - $uploads = wp_upload_dir(); |
|
| 1660 | - ini_set('auto_detect_line_endings', true);
|
|
| 1658 | + global $wpdb, $plugin_prefix, $current_user; |
|
| 1659 | + $uploads = wp_upload_dir(); |
|
| 1660 | + ini_set('auto_detect_line_endings', true);
|
|
| 1661 | 1661 | |
| 1662 | 1662 | $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
| 1663 | 1663 | |
| 1664 | - $task = isset($_POST['task']) ? $_POST['task'] : ''; |
|
| 1665 | - $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL; |
|
| 1666 | - $filename = $uploadedFile; |
|
| 1667 | - |
|
| 1668 | - $uploads = wp_upload_dir(); |
|
| 1669 | - $uploads_dir = $uploads['path']; |
|
| 1670 | - $image_name_arr = explode('/', $filename);
|
|
| 1671 | - $filename = end($image_name_arr); |
|
| 1672 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1673 | - $return = array(); |
|
| 1674 | - $return['file'] = $uploadedFile; |
|
| 1675 | - $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
|
|
| 1676 | - |
|
| 1677 | - if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
|
|
| 1678 | - $wp_filetype = wp_check_filetype_and_ext($target_path, $filename); |
|
| 1679 | - |
|
| 1680 | - if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 1681 | - $return['error'] = NULL; |
|
| 1682 | - |
|
| 1683 | - $return['rows'] = 0; |
|
| 1684 | - |
|
| 1685 | - |
|
| 1686 | - |
|
| 1687 | - if (($handle = fopen($target_path, "r")) !== FALSE) {
|
|
| 1688 | - while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
|
|
| 1689 | - if(is_array($data) && !empty($data)) {
|
|
| 1690 | - $file[] = '"' . implode('","', $data) . '"';
|
|
| 1691 | - } |
|
| 1692 | - } |
|
| 1693 | - fclose($handle); |
|
| 1694 | - $file = $file; |
|
| 1695 | - } |
|
| 1696 | - |
|
| 1697 | - |
|
| 1698 | - |
|
| 1699 | - $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 1700 | - |
|
| 1701 | - |
|
| 1702 | - if (!$return['rows'] > 0) {
|
|
| 1703 | - $return['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 1704 | - } |
|
| 1705 | - } |
|
| 1706 | - } |
|
| 1707 | - if ($task == 'prepare' || !empty($return['error'])) {
|
|
| 1708 | - echo json_encode($return); |
|
| 1709 | - exit; |
|
| 1710 | - } |
|
| 1711 | - |
|
| 1712 | - $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL; |
|
| 1713 | - $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1; |
|
| 1714 | - $count = $importlimit; |
|
| 1715 | - $requested_limit = $importlimit; |
|
| 1716 | - $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0; |
|
| 1717 | - |
|
| 1718 | - if ($count < $totRecords) {
|
|
| 1719 | - $count = $tmpCnt + $count; |
|
| 1720 | - if ($count > $totRecords) {
|
|
| 1721 | - $count = $totRecords; |
|
| 1722 | - } |
|
| 1723 | - } else {
|
|
| 1724 | - $count = $totRecords; |
|
| 1725 | - } |
|
| 1726 | - |
|
| 1727 | - $total_records = 0; |
|
| 1728 | - $rowcount = 0; |
|
| 1729 | - $address_invalid = 0; |
|
| 1730 | - $blank_address = 0; |
|
| 1731 | - $upload_files = 0; |
|
| 1732 | - $invalid_post_type = 0; |
|
| 1733 | - $invalid_title = 0; |
|
| 1734 | - $customKeyarray = array(); |
|
| 1735 | - $gd_post_info = array(); |
|
| 1736 | - $post_location = array(); |
|
| 1737 | - $countpost = 0; |
|
| 1738 | - |
|
| 1739 | - if (!empty($file)) {
|
|
| 1740 | - $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL; |
|
| 1741 | - $customKeyarray = $columns; |
|
| 1742 | - |
|
| 1743 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 1744 | - $return['error'] = CSV_INVAILD_FILE; |
|
| 1745 | - echo json_encode($return); |
|
| 1746 | - exit; |
|
| 1747 | - } |
|
| 1748 | - |
|
| 1749 | - for ($i = 1; $i <= $importlimit; $i++) {
|
|
| 1750 | - $current_index = $tmpCnt + $i; |
|
| 1751 | - if (isset($file[$current_index])) {
|
|
| 1752 | - $total_records++; |
|
| 1753 | - |
|
| 1754 | - $buffer = geodir_str_getcsv($file[$current_index]); |
|
| 1755 | - $post_title = addslashes($buffer[0]); |
|
| 1756 | - $current_post_author = $buffer[1]; |
|
| 1757 | - $post_desc = addslashes($buffer[2]); |
|
| 1758 | - $post_cat = array(); |
|
| 1759 | - $catids_arr = array(); |
|
| 1760 | - $post_cat = trim($buffer[3]); // comma seperated category name |
|
| 1761 | - |
|
| 1762 | - if ($post_cat) {
|
|
| 1763 | - $post_cat_arr = explode(',', $post_cat);
|
|
| 1764 | - |
|
| 1765 | - for ($c = 0; $c < count($post_cat_arr); $c++) {
|
|
| 1766 | - $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); |
|
| 1767 | - |
|
| 1768 | - if (!empty($buffer[5])) {
|
|
| 1769 | - if (in_array($buffer[5], geodir_get_posttypes())) {
|
|
| 1770 | - |
|
| 1771 | - $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); |
|
| 1772 | - |
|
| 1773 | - if (get_term_by('name', $catid, $p_taxonomy[0])) {
|
|
| 1774 | - $cat = get_term_by('name', $catid, $p_taxonomy[0]);
|
|
| 1775 | - $catids_arr[] = $cat->slug; |
|
| 1776 | - } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
|
|
| 1777 | - $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
|
|
| 1778 | - $catids_arr[] = $cat->slug; |
|
| 1779 | - } else {
|
|
| 1780 | - $ret = wp_insert_term($catid, $p_taxonomy[0]); |
|
| 1781 | - if ($ret && !is_wp_error($ret)) {
|
|
| 1782 | - if (get_term_by('name', $catid, $p_taxonomy[0])) {
|
|
| 1783 | - $cat = get_term_by('name', $catid, $p_taxonomy[0]);
|
|
| 1784 | - $catids_arr[] = $cat->slug; |
|
| 1785 | - } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
|
|
| 1786 | - $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
|
|
| 1787 | - $catids_arr[] = $cat->slug; |
|
| 1788 | - } |
|
| 1789 | - } |
|
| 1790 | - } |
|
| 1791 | - } |
|
| 1792 | - } |
|
| 1793 | - } |
|
| 1794 | - } |
|
| 1795 | - |
|
| 1796 | - if (!$catids_arr) {
|
|
| 1797 | - $catids_arr[] = 1; |
|
| 1798 | - } |
|
| 1799 | - |
|
| 1800 | - $post_tags = trim($buffer[4]); // comma seperated tags |
|
| 1801 | - |
|
| 1802 | - $tag_arr = ''; |
|
| 1803 | - if ($post_tags) {
|
|
| 1804 | - $tag_arr = explode(',', $post_tags);
|
|
| 1805 | - } |
|
| 1806 | - |
|
| 1807 | - $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database |
|
| 1808 | - |
|
| 1809 | - $error = ''; |
|
| 1810 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
|
|
| 1811 | - $invalid_post_type++; |
|
| 1812 | - continue; |
|
| 1813 | - } |
|
| 1814 | - |
|
| 1815 | - if ($post_title != '') {
|
|
| 1816 | - $menu_order = 0; |
|
| 1817 | - $image_folder_name = 'uplaod/'; |
|
| 1818 | - |
|
| 1819 | - $image_names = array(); |
|
| 1820 | - |
|
| 1821 | - for ($c = 5; $c < count($customKeyarray); $c++) {
|
|
| 1822 | - $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); |
|
| 1823 | - |
|
| 1824 | - if ($customKeyarray[$c] == 'IMAGE') {
|
|
| 1825 | - $buffer[$c] = trim($buffer[$c]); |
|
| 1826 | - |
|
| 1827 | - if (!empty($buffer[$c])) {
|
|
| 1828 | - $image_names[] = $buffer[$c]; |
|
| 1829 | - } |
|
| 1830 | - } |
|
| 1831 | - |
|
| 1832 | - if ($customKeyarray[$c] == 'alive_days') {
|
|
| 1833 | - if ($buffer[$c] != '0' && $buffer[$c] != '') {
|
|
| 1834 | - $submitdata = date('Y-m-d');
|
|
| 1835 | - |
|
| 1836 | - $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
|
|
| 1837 | - } else {
|
|
| 1838 | - $gd_post_info['expire_date'] = 'Never'; |
|
| 1839 | - } |
|
| 1840 | - } |
|
| 1841 | - |
|
| 1842 | - if ($customKeyarray[$c] == 'post_city') {
|
|
| 1843 | - $post_city = addslashes($buffer[$c]); |
|
| 1844 | - } |
|
| 1845 | - |
|
| 1846 | - if ($customKeyarray[$c] == 'post_region') {
|
|
| 1847 | - $post_region = addslashes($buffer[$c]); |
|
| 1848 | - } |
|
| 1849 | - |
|
| 1850 | - if ($customKeyarray[$c] == 'post_country') {
|
|
| 1851 | - $post_country = addslashes($buffer[$c]); |
|
| 1852 | - } |
|
| 1853 | - |
|
| 1854 | - if ($customKeyarray[$c] == 'post_latitude') {
|
|
| 1855 | - $post_latitude = addslashes($buffer[$c]); |
|
| 1856 | - } |
|
| 1857 | - |
|
| 1858 | - if ($customKeyarray[$c] == 'post_longitude') {
|
|
| 1859 | - $post_longitude = addslashes($buffer[$c]); |
|
| 1860 | - } |
|
| 1664 | + $task = isset($_POST['task']) ? $_POST['task'] : ''; |
|
| 1665 | + $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL; |
|
| 1666 | + $filename = $uploadedFile; |
|
| 1667 | + |
|
| 1668 | + $uploads = wp_upload_dir(); |
|
| 1669 | + $uploads_dir = $uploads['path']; |
|
| 1670 | + $image_name_arr = explode('/', $filename);
|
|
| 1671 | + $filename = end($image_name_arr); |
|
| 1672 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1673 | + $return = array(); |
|
| 1674 | + $return['file'] = $uploadedFile; |
|
| 1675 | + $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
|
|
| 1676 | + |
|
| 1677 | + if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
|
|
| 1678 | + $wp_filetype = wp_check_filetype_and_ext($target_path, $filename); |
|
| 1679 | + |
|
| 1680 | + if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 1681 | + $return['error'] = NULL; |
|
| 1682 | + |
|
| 1683 | + $return['rows'] = 0; |
|
| 1684 | + |
|
| 1685 | + |
|
| 1686 | + |
|
| 1687 | + if (($handle = fopen($target_path, "r")) !== FALSE) {
|
|
| 1688 | + while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
|
|
| 1689 | + if(is_array($data) && !empty($data)) {
|
|
| 1690 | + $file[] = '"' . implode('","', $data) . '"';
|
|
| 1691 | + } |
|
| 1692 | + } |
|
| 1693 | + fclose($handle); |
|
| 1694 | + $file = $file; |
|
| 1695 | + } |
|
| 1696 | + |
|
| 1697 | + |
|
| 1698 | + |
|
| 1699 | + $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 1700 | + |
|
| 1701 | + |
|
| 1702 | + if (!$return['rows'] > 0) {
|
|
| 1703 | + $return['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 1704 | + } |
|
| 1705 | + } |
|
| 1706 | + } |
|
| 1707 | + if ($task == 'prepare' || !empty($return['error'])) {
|
|
| 1708 | + echo json_encode($return); |
|
| 1709 | + exit; |
|
| 1710 | + } |
|
| 1711 | + |
|
| 1712 | + $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL; |
|
| 1713 | + $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1; |
|
| 1714 | + $count = $importlimit; |
|
| 1715 | + $requested_limit = $importlimit; |
|
| 1716 | + $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0; |
|
| 1717 | + |
|
| 1718 | + if ($count < $totRecords) {
|
|
| 1719 | + $count = $tmpCnt + $count; |
|
| 1720 | + if ($count > $totRecords) {
|
|
| 1721 | + $count = $totRecords; |
|
| 1722 | + } |
|
| 1723 | + } else {
|
|
| 1724 | + $count = $totRecords; |
|
| 1725 | + } |
|
| 1726 | + |
|
| 1727 | + $total_records = 0; |
|
| 1728 | + $rowcount = 0; |
|
| 1729 | + $address_invalid = 0; |
|
| 1730 | + $blank_address = 0; |
|
| 1731 | + $upload_files = 0; |
|
| 1732 | + $invalid_post_type = 0; |
|
| 1733 | + $invalid_title = 0; |
|
| 1734 | + $customKeyarray = array(); |
|
| 1735 | + $gd_post_info = array(); |
|
| 1736 | + $post_location = array(); |
|
| 1737 | + $countpost = 0; |
|
| 1738 | + |
|
| 1739 | + if (!empty($file)) {
|
|
| 1740 | + $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL; |
|
| 1741 | + $customKeyarray = $columns; |
|
| 1742 | + |
|
| 1743 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 1744 | + $return['error'] = CSV_INVAILD_FILE; |
|
| 1745 | + echo json_encode($return); |
|
| 1746 | + exit; |
|
| 1747 | + } |
|
| 1748 | + |
|
| 1749 | + for ($i = 1; $i <= $importlimit; $i++) {
|
|
| 1750 | + $current_index = $tmpCnt + $i; |
|
| 1751 | + if (isset($file[$current_index])) {
|
|
| 1752 | + $total_records++; |
|
| 1753 | + |
|
| 1754 | + $buffer = geodir_str_getcsv($file[$current_index]); |
|
| 1755 | + $post_title = addslashes($buffer[0]); |
|
| 1756 | + $current_post_author = $buffer[1]; |
|
| 1757 | + $post_desc = addslashes($buffer[2]); |
|
| 1758 | + $post_cat = array(); |
|
| 1759 | + $catids_arr = array(); |
|
| 1760 | + $post_cat = trim($buffer[3]); // comma seperated category name |
|
| 1761 | + |
|
| 1762 | + if ($post_cat) {
|
|
| 1763 | + $post_cat_arr = explode(',', $post_cat);
|
|
| 1764 | + |
|
| 1765 | + for ($c = 0; $c < count($post_cat_arr); $c++) {
|
|
| 1766 | + $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); |
|
| 1767 | + |
|
| 1768 | + if (!empty($buffer[5])) {
|
|
| 1769 | + if (in_array($buffer[5], geodir_get_posttypes())) {
|
|
| 1770 | + |
|
| 1771 | + $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); |
|
| 1772 | + |
|
| 1773 | + if (get_term_by('name', $catid, $p_taxonomy[0])) {
|
|
| 1774 | + $cat = get_term_by('name', $catid, $p_taxonomy[0]);
|
|
| 1775 | + $catids_arr[] = $cat->slug; |
|
| 1776 | + } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
|
|
| 1777 | + $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
|
|
| 1778 | + $catids_arr[] = $cat->slug; |
|
| 1779 | + } else {
|
|
| 1780 | + $ret = wp_insert_term($catid, $p_taxonomy[0]); |
|
| 1781 | + if ($ret && !is_wp_error($ret)) {
|
|
| 1782 | + if (get_term_by('name', $catid, $p_taxonomy[0])) {
|
|
| 1783 | + $cat = get_term_by('name', $catid, $p_taxonomy[0]);
|
|
| 1784 | + $catids_arr[] = $cat->slug; |
|
| 1785 | + } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
|
|
| 1786 | + $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
|
|
| 1787 | + $catids_arr[] = $cat->slug; |
|
| 1788 | + } |
|
| 1789 | + } |
|
| 1790 | + } |
|
| 1791 | + } |
|
| 1792 | + } |
|
| 1793 | + } |
|
| 1794 | + } |
|
| 1795 | + |
|
| 1796 | + if (!$catids_arr) {
|
|
| 1797 | + $catids_arr[] = 1; |
|
| 1798 | + } |
|
| 1799 | + |
|
| 1800 | + $post_tags = trim($buffer[4]); // comma seperated tags |
|
| 1801 | + |
|
| 1802 | + $tag_arr = ''; |
|
| 1803 | + if ($post_tags) {
|
|
| 1804 | + $tag_arr = explode(',', $post_tags);
|
|
| 1805 | + } |
|
| 1806 | + |
|
| 1807 | + $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database |
|
| 1808 | + |
|
| 1809 | + $error = ''; |
|
| 1810 | + if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
|
|
| 1811 | + $invalid_post_type++; |
|
| 1812 | + continue; |
|
| 1813 | + } |
|
| 1814 | + |
|
| 1815 | + if ($post_title != '') {
|
|
| 1816 | + $menu_order = 0; |
|
| 1817 | + $image_folder_name = 'uplaod/'; |
|
| 1818 | + |
|
| 1819 | + $image_names = array(); |
|
| 1820 | + |
|
| 1821 | + for ($c = 5; $c < count($customKeyarray); $c++) {
|
|
| 1822 | + $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); |
|
| 1823 | + |
|
| 1824 | + if ($customKeyarray[$c] == 'IMAGE') {
|
|
| 1825 | + $buffer[$c] = trim($buffer[$c]); |
|
| 1826 | + |
|
| 1827 | + if (!empty($buffer[$c])) {
|
|
| 1828 | + $image_names[] = $buffer[$c]; |
|
| 1829 | + } |
|
| 1830 | + } |
|
| 1831 | + |
|
| 1832 | + if ($customKeyarray[$c] == 'alive_days') {
|
|
| 1833 | + if ($buffer[$c] != '0' && $buffer[$c] != '') {
|
|
| 1834 | + $submitdata = date('Y-m-d');
|
|
| 1835 | + |
|
| 1836 | + $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
|
|
| 1837 | + } else {
|
|
| 1838 | + $gd_post_info['expire_date'] = 'Never'; |
|
| 1839 | + } |
|
| 1840 | + } |
|
| 1841 | + |
|
| 1842 | + if ($customKeyarray[$c] == 'post_city') {
|
|
| 1843 | + $post_city = addslashes($buffer[$c]); |
|
| 1844 | + } |
|
| 1845 | + |
|
| 1846 | + if ($customKeyarray[$c] == 'post_region') {
|
|
| 1847 | + $post_region = addslashes($buffer[$c]); |
|
| 1848 | + } |
|
| 1849 | + |
|
| 1850 | + if ($customKeyarray[$c] == 'post_country') {
|
|
| 1851 | + $post_country = addslashes($buffer[$c]); |
|
| 1852 | + } |
|
| 1853 | + |
|
| 1854 | + if ($customKeyarray[$c] == 'post_latitude') {
|
|
| 1855 | + $post_latitude = addslashes($buffer[$c]); |
|
| 1856 | + } |
|
| 1857 | + |
|
| 1858 | + if ($customKeyarray[$c] == 'post_longitude') {
|
|
| 1859 | + $post_longitude = addslashes($buffer[$c]); |
|
| 1860 | + } |
|
| 1861 | 1861 | |
| 1862 | 1862 | // Post status |
| 1863 | 1863 | if ($customKeyarray[$c] == 'post_status') {
|
| 1864 | - $post_status = sanitize_key( $buffer[$c] ); |
|
| 1865 | - } |
|
| 1866 | - } |
|
| 1867 | - |
|
| 1868 | - /* ================ before array create ============== */ |
|
| 1869 | - $location_result = geodir_get_default_location(); |
|
| 1870 | - if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
|
|
| 1871 | - $blank_address++; |
|
| 1872 | - continue; |
|
| 1873 | - } else if ($location_result->location_id == 0) {
|
|
| 1874 | - if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
|
|
| 1875 | - $address_invalid++; |
|
| 1876 | - continue; |
|
| 1877 | - } |
|
| 1878 | - } |
|
| 1864 | + $post_status = sanitize_key( $buffer[$c] ); |
|
| 1865 | + } |
|
| 1866 | + } |
|
| 1867 | + |
|
| 1868 | + /* ================ before array create ============== */ |
|
| 1869 | + $location_result = geodir_get_default_location(); |
|
| 1870 | + if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
|
|
| 1871 | + $blank_address++; |
|
| 1872 | + continue; |
|
| 1873 | + } else if ($location_result->location_id == 0) {
|
|
| 1874 | + if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
|
|
| 1875 | + $address_invalid++; |
|
| 1876 | + continue; |
|
| 1877 | + } |
|
| 1878 | + } |
|
| 1879 | 1879 | |
| 1880 | 1880 | // Default post status |
| 1881 | 1881 | $default_status = 'publish'; |
| 1882 | 1882 | $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
| 1883 | 1883 | $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
| 1884 | 1884 | |
| 1885 | - $my_post['post_title'] = $post_title; |
|
| 1886 | - $my_post['post_content'] = $post_desc; |
|
| 1887 | - $my_post['post_type'] = addslashes($buffer[5]); |
|
| 1888 | - $my_post['post_author'] = $current_post_author; |
|
| 1889 | - $my_post['post_status'] = $post_status; |
|
| 1890 | - $my_post['post_category'] = $catids_arr; |
|
| 1891 | - $my_post['post_tags'] = $tag_arr; |
|
| 1892 | - |
|
| 1893 | - $gd_post_info['post_tags'] = $tag_arr; |
|
| 1894 | - $gd_post_info['post_title'] = $post_title; |
|
| 1895 | - $gd_post_info['post_status'] = $post_status; |
|
| 1896 | - $gd_post_info['submit_time'] = time(); |
|
| 1897 | - $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 1898 | - |
|
| 1899 | - $last_postid = wp_insert_post($my_post); |
|
| 1900 | - $countpost++; |
|
| 1901 | - |
|
| 1902 | - // Check if we need to save post location as new location |
|
| 1903 | - if ($location_result->location_id > 0) {
|
|
| 1904 | - if (isset($post_city) && isset($post_region)) {
|
|
| 1905 | - $request_info['post_location'] = array( |
|
| 1906 | - 'city' => $post_city, |
|
| 1907 | - 'region' => $post_region, |
|
| 1908 | - 'country' => $post_country, |
|
| 1909 | - 'geo_lat' => $post_latitude, |
|
| 1910 | - 'geo_lng' => $post_longitude |
|
| 1911 | - ); |
|
| 1912 | - |
|
| 1913 | - $post_location_info = $request_info['post_location']; |
|
| 1914 | - if ($location_id = geodir_add_new_location($post_location_info)) |
|
| 1915 | - $post_location_id = $location_id; |
|
| 1916 | - } else {
|
|
| 1917 | - $post_location_id = 0; |
|
| 1918 | - } |
|
| 1919 | - } else {
|
|
| 1920 | - $post_location_id = 0; |
|
| 1921 | - } |
|
| 1922 | - |
|
| 1923 | - /* ------- get default package info ----- */ |
|
| 1924 | - $payment_info = array(); |
|
| 1925 | - $package_info = array(); |
|
| 1926 | - |
|
| 1927 | - $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
| 1928 | - $package_id = ''; |
|
| 1929 | - if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
|
|
| 1930 | - $package_id = $gd_post_info['package_id']; |
|
| 1931 | - } |
|
| 1932 | - |
|
| 1933 | - if (!empty($package_info)) {
|
|
| 1934 | - $payment_info['package_id'] = $package_info['pid']; |
|
| 1935 | - |
|
| 1936 | - if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
|
|
| 1937 | - $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
|
|
| 1938 | - } else {
|
|
| 1939 | - $payment_info['expire_date'] = 'Never'; |
|
| 1940 | - } |
|
| 1941 | - |
|
| 1942 | - $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
| 1943 | - } |
|
| 1944 | - |
|
| 1945 | - $gd_post_info['post_location_id'] = $post_location_id; |
|
| 1946 | - |
|
| 1947 | - $post_type = get_post_type($last_postid); |
|
| 1948 | - |
|
| 1949 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1950 | - |
|
| 1951 | - geodir_save_post_info($last_postid, $gd_post_info); |
|
| 1952 | - |
|
| 1953 | - if (!empty($image_names)) {
|
|
| 1954 | - $upload_files++; |
|
| 1955 | - $menu_order = 1; |
|
| 1956 | - |
|
| 1957 | - foreach ($image_names as $image_name) {
|
|
| 1958 | - $img_name_arr = explode('.', $image_name);
|
|
| 1959 | - |
|
| 1960 | - $uploads = wp_upload_dir(); |
|
| 1961 | - $sub_dir = $uploads['subdir']; |
|
| 1962 | - |
|
| 1963 | - $arr_file_type = wp_check_filetype($image_name); |
|
| 1964 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 1965 | - |
|
| 1966 | - $attachment = array(); |
|
| 1967 | - $attachment['post_id'] = $last_postid; |
|
| 1968 | - $attachment['title'] = $img_name_arr[0]; |
|
| 1969 | - $attachment['content'] = ''; |
|
| 1970 | - $attachment['file'] = $sub_dir . '/' . $image_name; |
|
| 1971 | - $attachment['mime_type'] = $uploaded_file_type; |
|
| 1972 | - $attachment['menu_order'] = $menu_order; |
|
| 1973 | - $attachment['is_featured'] = 0; |
|
| 1974 | - |
|
| 1975 | - $attachment_set = ''; |
|
| 1976 | - |
|
| 1977 | - foreach ($attachment as $key => $val) {
|
|
| 1978 | - if ($val != '') |
|
| 1979 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 1980 | - } |
|
| 1981 | - $attachment_set = trim($attachment_set, ", "); |
|
| 1982 | - |
|
| 1983 | - $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 1984 | - |
|
| 1985 | - if ($menu_order == 1) {
|
|
| 1986 | - $post_type = get_post_type($last_postid); |
|
| 1987 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
|
|
| 1988 | - } |
|
| 1989 | - $menu_order++; |
|
| 1990 | - } |
|
| 1991 | - } |
|
| 1992 | - |
|
| 1993 | - $gd_post_info['package_id'] = $package_id; |
|
| 1994 | - |
|
| 1995 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 1996 | - do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
|
|
| 1997 | - |
|
| 1998 | - if (!empty($buffer[5])) {
|
|
| 1999 | - if (in_array($buffer[5], geodir_get_posttypes())) {
|
|
| 2000 | - $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); |
|
| 2001 | - wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); |
|
| 2002 | - wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); |
|
| 2003 | - |
|
| 2004 | - $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; |
|
| 2005 | - $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; |
|
| 2006 | - geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); |
|
| 2007 | - } |
|
| 2008 | - } |
|
| 2009 | - } else {
|
|
| 2010 | - $invalid_title++; |
|
| 2011 | - } |
|
| 2012 | - } |
|
| 2013 | - } |
|
| 2014 | - } |
|
| 2015 | - $return['rowcount'] = $countpost; |
|
| 2016 | - $return['invalidcount'] = $address_invalid; |
|
| 2017 | - $return['blank_address'] = $blank_address; |
|
| 2018 | - $return['upload_files'] = $upload_files; |
|
| 2019 | - $return['invalid_post_type'] = $invalid_post_type; |
|
| 2020 | - $return['invalid_title'] = $invalid_title; |
|
| 2021 | - $return['total_records'] = $total_records; |
|
| 2022 | - |
|
| 2023 | - echo json_encode($return); |
|
| 2024 | - exit; |
|
| 1885 | + $my_post['post_title'] = $post_title; |
|
| 1886 | + $my_post['post_content'] = $post_desc; |
|
| 1887 | + $my_post['post_type'] = addslashes($buffer[5]); |
|
| 1888 | + $my_post['post_author'] = $current_post_author; |
|
| 1889 | + $my_post['post_status'] = $post_status; |
|
| 1890 | + $my_post['post_category'] = $catids_arr; |
|
| 1891 | + $my_post['post_tags'] = $tag_arr; |
|
| 1892 | + |
|
| 1893 | + $gd_post_info['post_tags'] = $tag_arr; |
|
| 1894 | + $gd_post_info['post_title'] = $post_title; |
|
| 1895 | + $gd_post_info['post_status'] = $post_status; |
|
| 1896 | + $gd_post_info['submit_time'] = time(); |
|
| 1897 | + $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 1898 | + |
|
| 1899 | + $last_postid = wp_insert_post($my_post); |
|
| 1900 | + $countpost++; |
|
| 1901 | + |
|
| 1902 | + // Check if we need to save post location as new location |
|
| 1903 | + if ($location_result->location_id > 0) {
|
|
| 1904 | + if (isset($post_city) && isset($post_region)) {
|
|
| 1905 | + $request_info['post_location'] = array( |
|
| 1906 | + 'city' => $post_city, |
|
| 1907 | + 'region' => $post_region, |
|
| 1908 | + 'country' => $post_country, |
|
| 1909 | + 'geo_lat' => $post_latitude, |
|
| 1910 | + 'geo_lng' => $post_longitude |
|
| 1911 | + ); |
|
| 1912 | + |
|
| 1913 | + $post_location_info = $request_info['post_location']; |
|
| 1914 | + if ($location_id = geodir_add_new_location($post_location_info)) |
|
| 1915 | + $post_location_id = $location_id; |
|
| 1916 | + } else {
|
|
| 1917 | + $post_location_id = 0; |
|
| 1918 | + } |
|
| 1919 | + } else {
|
|
| 1920 | + $post_location_id = 0; |
|
| 1921 | + } |
|
| 1922 | + |
|
| 1923 | + /* ------- get default package info ----- */ |
|
| 1924 | + $payment_info = array(); |
|
| 1925 | + $package_info = array(); |
|
| 1926 | + |
|
| 1927 | + $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
| 1928 | + $package_id = ''; |
|
| 1929 | + if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
|
|
| 1930 | + $package_id = $gd_post_info['package_id']; |
|
| 1931 | + } |
|
| 1932 | + |
|
| 1933 | + if (!empty($package_info)) {
|
|
| 1934 | + $payment_info['package_id'] = $package_info['pid']; |
|
| 1935 | + |
|
| 1936 | + if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
|
|
| 1937 | + $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
|
|
| 1938 | + } else {
|
|
| 1939 | + $payment_info['expire_date'] = 'Never'; |
|
| 1940 | + } |
|
| 1941 | + |
|
| 1942 | + $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
| 1943 | + } |
|
| 1944 | + |
|
| 1945 | + $gd_post_info['post_location_id'] = $post_location_id; |
|
| 1946 | + |
|
| 1947 | + $post_type = get_post_type($last_postid); |
|
| 1948 | + |
|
| 1949 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1950 | + |
|
| 1951 | + geodir_save_post_info($last_postid, $gd_post_info); |
|
| 1952 | + |
|
| 1953 | + if (!empty($image_names)) {
|
|
| 1954 | + $upload_files++; |
|
| 1955 | + $menu_order = 1; |
|
| 1956 | + |
|
| 1957 | + foreach ($image_names as $image_name) {
|
|
| 1958 | + $img_name_arr = explode('.', $image_name);
|
|
| 1959 | + |
|
| 1960 | + $uploads = wp_upload_dir(); |
|
| 1961 | + $sub_dir = $uploads['subdir']; |
|
| 1962 | + |
|
| 1963 | + $arr_file_type = wp_check_filetype($image_name); |
|
| 1964 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 1965 | + |
|
| 1966 | + $attachment = array(); |
|
| 1967 | + $attachment['post_id'] = $last_postid; |
|
| 1968 | + $attachment['title'] = $img_name_arr[0]; |
|
| 1969 | + $attachment['content'] = ''; |
|
| 1970 | + $attachment['file'] = $sub_dir . '/' . $image_name; |
|
| 1971 | + $attachment['mime_type'] = $uploaded_file_type; |
|
| 1972 | + $attachment['menu_order'] = $menu_order; |
|
| 1973 | + $attachment['is_featured'] = 0; |
|
| 1974 | + |
|
| 1975 | + $attachment_set = ''; |
|
| 1976 | + |
|
| 1977 | + foreach ($attachment as $key => $val) {
|
|
| 1978 | + if ($val != '') |
|
| 1979 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 1980 | + } |
|
| 1981 | + $attachment_set = trim($attachment_set, ", "); |
|
| 1982 | + |
|
| 1983 | + $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 1984 | + |
|
| 1985 | + if ($menu_order == 1) {
|
|
| 1986 | + $post_type = get_post_type($last_postid); |
|
| 1987 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
|
|
| 1988 | + } |
|
| 1989 | + $menu_order++; |
|
| 1990 | + } |
|
| 1991 | + } |
|
| 1992 | + |
|
| 1993 | + $gd_post_info['package_id'] = $package_id; |
|
| 1994 | + |
|
| 1995 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 1996 | + do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
|
|
| 1997 | + |
|
| 1998 | + if (!empty($buffer[5])) {
|
|
| 1999 | + if (in_array($buffer[5], geodir_get_posttypes())) {
|
|
| 2000 | + $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); |
|
| 2001 | + wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); |
|
| 2002 | + wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); |
|
| 2003 | + |
|
| 2004 | + $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; |
|
| 2005 | + $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; |
|
| 2006 | + geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); |
|
| 2007 | + } |
|
| 2008 | + } |
|
| 2009 | + } else {
|
|
| 2010 | + $invalid_title++; |
|
| 2011 | + } |
|
| 2012 | + } |
|
| 2013 | + } |
|
| 2014 | + } |
|
| 2015 | + $return['rowcount'] = $countpost; |
|
| 2016 | + $return['invalidcount'] = $address_invalid; |
|
| 2017 | + $return['blank_address'] = $blank_address; |
|
| 2018 | + $return['upload_files'] = $upload_files; |
|
| 2019 | + $return['invalid_post_type'] = $invalid_post_type; |
|
| 2020 | + $return['invalid_title'] = $invalid_title; |
|
| 2021 | + $return['total_records'] = $total_records; |
|
| 2022 | + |
|
| 2023 | + echo json_encode($return); |
|
| 2024 | + exit; |
|
| 2025 | 2025 | } |
| 2026 | 2026 | |
| 2027 | 2027 | // Add the tab in left sidebar menu fro import & export page. |
@@ -2041,9 +2041,9 @@ discard block |
||
| 2041 | 2041 | * @param $post object $post The post object of the post being saved. |
| 2042 | 2042 | */ |
| 2043 | 2043 | function geodir_update_location_prefix($post_id,$post){
|
| 2044 | - if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
|
|
| 2045 | - update_option('geodir_location_prefix',$post->post_name);
|
|
| 2046 | - } |
|
| 2044 | + if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
|
|
| 2045 | + update_option('geodir_location_prefix',$post->post_name);
|
|
| 2046 | + } |
|
| 2047 | 2047 | |
| 2048 | 2048 | } |
| 2049 | 2049 | |
@@ -2054,50 +2054,50 @@ discard block |
||
| 2054 | 2054 | function geodir_ga_callback(){
|
| 2055 | 2055 | |
| 2056 | 2056 | if(isset($_REQUEST['code']) && $_REQUEST['code']) {
|
| 2057 | - $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; |
|
| 2058 | - $code = "code=".$_REQUEST['code']; |
|
| 2059 | - $grant_type = "&grant_type=authorization_code"; |
|
| 2060 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 2061 | - $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 2062 | - $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
|
|
| 2057 | + $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; |
|
| 2058 | + $code = "code=".$_REQUEST['code']; |
|
| 2059 | + $grant_type = "&grant_type=authorization_code"; |
|
| 2060 | + $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 2061 | + $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 2062 | + $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
|
|
| 2063 | 2063 | |
| 2064 | - $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; |
|
| 2064 | + $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; |
|
| 2065 | 2065 | |
| 2066 | - $response = wp_remote_post($auth_url, array('timeout' => 15));
|
|
| 2066 | + $response = wp_remote_post($auth_url, array('timeout' => 15));
|
|
| 2067 | 2067 | |
| 2068 | - //print_r($response); |
|
| 2068 | + //print_r($response); |
|
| 2069 | 2069 | |
| 2070 | - $error_msg = __('Something went wrong','geodirectory');
|
|
| 2071 | - if(!empty($response['response']['code']) && $response['response']['code']==200){
|
|
| 2070 | + $error_msg = __('Something went wrong','geodirectory');
|
|
| 2071 | + if(!empty($response['response']['code']) && $response['response']['code']==200){
|
|
| 2072 | 2072 | |
| 2073 | - $parts = json_decode($response['body']); |
|
| 2074 | - //print_r($parts); |
|
| 2075 | - if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
|
|
| 2076 | - else{
|
|
| 2073 | + $parts = json_decode($response['body']); |
|
| 2074 | + //print_r($parts); |
|
| 2075 | + if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
|
|
| 2076 | + else{
|
|
| 2077 | 2077 | |
| 2078 | - update_option('gd_ga_access_token', $parts->access_token);
|
|
| 2079 | - update_option('gd_ga_refresh_token', $parts->refresh_token);
|
|
| 2080 | - ?><script>window.close();</script><?php |
|
| 2081 | - } |
|
| 2078 | + update_option('gd_ga_access_token', $parts->access_token);
|
|
| 2079 | + update_option('gd_ga_refresh_token', $parts->refresh_token);
|
|
| 2080 | + ?><script>window.close();</script><?php |
|
| 2081 | + } |
|
| 2082 | 2082 | |
| 2083 | 2083 | |
| 2084 | - } |
|
| 2085 | - elseif(!empty($response['response']['code'])) {
|
|
| 2086 | - $parts = json_decode($response['body']); |
|
| 2084 | + } |
|
| 2085 | + elseif(!empty($response['response']['code'])) {
|
|
| 2086 | + $parts = json_decode($response['body']); |
|
| 2087 | 2087 | |
| 2088 | - if(isset($parts->error)){
|
|
| 2089 | - echo $parts->error.": ".$parts->error_description;exit; |
|
| 2090 | - }else{
|
|
| 2091 | - echo $error_msg." - #2";exit; |
|
| 2092 | - } |
|
| 2088 | + if(isset($parts->error)){
|
|
| 2089 | + echo $parts->error.": ".$parts->error_description;exit; |
|
| 2090 | + }else{
|
|
| 2091 | + echo $error_msg." - #2";exit; |
|
| 2092 | + } |
|
| 2093 | 2093 | |
| 2094 | - }else{
|
|
| 2094 | + }else{
|
|
| 2095 | 2095 | |
| 2096 | - echo $error_msg." - #3";exit; |
|
| 2096 | + echo $error_msg." - #3";exit; |
|
| 2097 | 2097 | |
| 2098 | - } |
|
| 2098 | + } |
|
| 2099 | 2099 | } |
| 2100 | - exit; |
|
| 2100 | + exit; |
|
| 2101 | 2101 | } |
| 2102 | 2102 | |
| 2103 | 2103 | add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 ); |