@@ -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,105 +32,105 @@ 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 | - {
|
|
| 99 | + /** |
|
| 100 | + * Enqueue Admin Scripts. |
|
| 101 | + * |
|
| 102 | + * @since 1.0.0 |
|
| 103 | + * @package GeoDirectory |
|
| 104 | + */ |
|
| 105 | + function geodir_admin_scripts() |
|
| 106 | + {
|
|
| 107 | 107 | |
| 108 | - wp_enqueue_script('jquery');
|
|
| 108 | + wp_enqueue_script('jquery');
|
|
| 109 | 109 | |
| 110 | - 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);
|
|
| 110 | + 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 | 111 | |
| 112 | - wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array(), GEODIRECTORY_VERSION);
|
|
| 113 | - wp_enqueue_script('chosen');
|
|
| 112 | + wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array(), GEODIRECTORY_VERSION);
|
|
| 113 | + wp_enqueue_script('chosen');
|
|
| 114 | 114 | |
| 115 | - wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
|
|
| 116 | - wp_enqueue_script('geodirectory-choose-ajax');
|
|
| 115 | + wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
|
|
| 116 | + wp_enqueue_script('geodirectory-choose-ajax');
|
|
| 117 | 117 | |
| 118 | - if (isset($_REQUEST['listing_type'])) {
|
|
| 119 | - wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
|
|
| 120 | - } |
|
| 118 | + if (isset($_REQUEST['listing_type'])) {
|
|
| 119 | + wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
|
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - wp_enqueue_script('geodirectory-custom-fields-script');
|
|
| 123 | - $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
| 122 | + wp_enqueue_script('geodirectory-custom-fields-script');
|
|
| 123 | + $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
| 124 | 124 | |
| 125 | - wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
|
|
| 125 | + wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
|
|
| 126 | 126 | |
| 127 | - $map_lang = "&language=" . geodir_get_map_default_language(); |
|
| 128 | - /** This filter is documented in geodirectory_template_tags.php */ |
|
| 129 | - $map_extra = apply_filters('geodir_googlemap_script_extra', '');
|
|
| 130 | - wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
|
|
| 127 | + $map_lang = "&language=" . geodir_get_map_default_language(); |
|
| 128 | + /** This filter is documented in geodirectory_template_tags.php */ |
|
| 129 | + $map_extra = apply_filters('geodir_googlemap_script_extra', '');
|
|
| 130 | + wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
|
|
| 131 | 131 | |
| 132 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 133 | - wp_enqueue_script('geodirectory-goMap-script');
|
|
| 132 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 133 | + wp_enqueue_script('geodirectory-goMap-script');
|
|
| 134 | 134 | |
| 135 | 135 | // font awesome rating script |
| 136 | 136 | if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
@@ -141,177 +141,177 @@ discard block |
||
| 141 | 141 | wp_enqueue_script('geodir-jRating-js');
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
|
|
| 145 | - wp_enqueue_script('geodir-on-document-load');
|
|
| 146 | - |
|
| 147 | - |
|
| 148 | - // SCRIPT FOR UPLOAD |
|
| 149 | - wp_enqueue_script('plupload-all');
|
|
| 150 | - wp_enqueue_script('jquery-ui-sortable');
|
|
| 151 | - |
|
| 152 | - wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 153 | - wp_enqueue_script('geodirectory-plupload-script');
|
|
| 154 | - |
|
| 155 | - // SCRIPT FOR UPLOAD END |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - // place js config array for plupload |
|
| 159 | - $plupload_init = array( |
|
| 160 | - 'runtimes' => 'html5,silverlight,flash,html4', |
|
| 161 | - 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
| 162 | - 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
| 163 | - 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
| 164 | - 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
| 165 | - 'multiple_queues' => true, |
|
| 166 | - 'max_file_size' => geodir_max_upload_size(), |
|
| 167 | - 'url' => admin_url('admin-ajax.php'),
|
|
| 168 | - 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
|
| 169 | - 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
|
| 170 | - 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
|
|
| 171 | - 'multipart' => true, |
|
| 172 | - 'urlstream_upload' => true, |
|
| 173 | - 'multi_selection' => false, // will be added per uploader |
|
| 174 | - // additional post data to send to our ajax hook |
|
| 175 | - 'multipart_params' => array( |
|
| 176 | - '_ajax_nonce' => "", // will be added per uploader |
|
| 177 | - 'action' => 'plupload_action', // the ajax action name |
|
| 178 | - 'imgid' => 0 // will be added per uploader |
|
| 179 | - ) |
|
| 180 | - ); |
|
| 181 | - $base_plupload_config = json_encode($plupload_init); |
|
| 182 | - |
|
| 183 | - |
|
| 184 | - $thumb_img_arr = array(); |
|
| 185 | - |
|
| 186 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 187 | - $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 188 | - |
|
| 189 | - $totImg = ''; |
|
| 190 | - $image_limit = ''; |
|
| 191 | - if (!empty($thumb_img_arr)) {
|
|
| 192 | - foreach ($thumb_img_arr as $img) {
|
|
| 193 | - $curImages = $img->src . ","; |
|
| 194 | - } |
|
| 144 | + wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
|
|
| 145 | + wp_enqueue_script('geodir-on-document-load');
|
|
| 146 | + |
|
| 147 | + |
|
| 148 | + // SCRIPT FOR UPLOAD |
|
| 149 | + wp_enqueue_script('plupload-all');
|
|
| 150 | + wp_enqueue_script('jquery-ui-sortable');
|
|
| 151 | + |
|
| 152 | + wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 153 | + wp_enqueue_script('geodirectory-plupload-script');
|
|
| 154 | + |
|
| 155 | + // SCRIPT FOR UPLOAD END |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + // place js config array for plupload |
|
| 159 | + $plupload_init = array( |
|
| 160 | + 'runtimes' => 'html5,silverlight,flash,html4', |
|
| 161 | + 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
| 162 | + 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
| 163 | + 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
| 164 | + 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
| 165 | + 'multiple_queues' => true, |
|
| 166 | + 'max_file_size' => geodir_max_upload_size(), |
|
| 167 | + 'url' => admin_url('admin-ajax.php'),
|
|
| 168 | + 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
|
| 169 | + 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
|
| 170 | + 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
|
|
| 171 | + 'multipart' => true, |
|
| 172 | + 'urlstream_upload' => true, |
|
| 173 | + 'multi_selection' => false, // will be added per uploader |
|
| 174 | + // additional post data to send to our ajax hook |
|
| 175 | + 'multipart_params' => array( |
|
| 176 | + '_ajax_nonce' => "", // will be added per uploader |
|
| 177 | + 'action' => 'plupload_action', // the ajax action name |
|
| 178 | + 'imgid' => 0 // will be added per uploader |
|
| 179 | + ) |
|
| 180 | + ); |
|
| 181 | + $base_plupload_config = json_encode($plupload_init); |
|
| 182 | + |
|
| 183 | + |
|
| 184 | + $thumb_img_arr = array(); |
|
| 185 | + |
|
| 186 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 187 | + $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 188 | + |
|
| 189 | + $totImg = ''; |
|
| 190 | + $image_limit = ''; |
|
| 191 | + if (!empty($thumb_img_arr)) {
|
|
| 192 | + foreach ($thumb_img_arr as $img) {
|
|
| 193 | + $curImages = $img->src . ","; |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - $totImg = count($thumb_img_arr); |
|
| 197 | - } |
|
| 196 | + $totImg = count($thumb_img_arr); |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | 199 | |
| 200 | - $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
|
|
| 201 | - 'totalImg' => $totImg, |
|
| 202 | - 'image_limit' => $image_limit, |
|
| 203 | - 'upload_img_size' => geodir_max_upload_size()); |
|
| 200 | + $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
|
|
| 201 | + 'totalImg' => $totImg, |
|
| 202 | + 'image_limit' => $image_limit, |
|
| 203 | + 'upload_img_size' => geodir_max_upload_size()); |
|
| 204 | 204 | |
| 205 | - wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
|
|
| 205 | + wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
|
|
| 206 | 206 | |
| 207 | - $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
|
|
| 208 | - wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
|
|
| 207 | + $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
|
|
| 208 | + wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
|
|
| 209 | 209 | |
| 210 | 210 | |
| 211 | - wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 212 | - wp_enqueue_script('geodirectory-admin-script');
|
|
| 211 | + wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 212 | + wp_enqueue_script('geodirectory-admin-script');
|
|
| 213 | 213 | |
| 214 | - wp_enqueue_style('farbtastic');
|
|
| 215 | - wp_enqueue_script('farbtastic');
|
|
| 214 | + wp_enqueue_style('farbtastic');
|
|
| 215 | + wp_enqueue_script('farbtastic');
|
|
| 216 | 216 | |
| 217 | - $screen = get_current_screen(); |
|
| 218 | - if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
|
|
| 219 | - wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 220 | - } |
|
| 217 | + $screen = get_current_screen(); |
|
| 218 | + if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
|
|
| 219 | + wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - $ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
|
|
| 223 | - wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
|
|
| 222 | + $ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
|
|
| 223 | + wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
|
|
| 224 | 224 | |
| 225 | - } |
|
| 225 | + } |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | if (!function_exists('geodir_admin_menu')) {
|
| 229 | - /** |
|
| 230 | - * Admin Menus |
|
| 231 | - * |
|
| 232 | - * Sets up the admin menus in wordpress. |
|
| 233 | - * |
|
| 234 | - * @since 1.0.0 |
|
| 235 | - * @package GeoDirectory |
|
| 236 | - * @global array $menu Menu array. |
|
| 237 | - * @global object $geodirectory GeoDirectory plugin object. |
|
| 238 | - */ |
|
| 239 | - function geodir_admin_menu() |
|
| 240 | - {
|
|
| 241 | - global $menu, $geodirectory; |
|
| 229 | + /** |
|
| 230 | + * Admin Menus |
|
| 231 | + * |
|
| 232 | + * Sets up the admin menus in wordpress. |
|
| 233 | + * |
|
| 234 | + * @since 1.0.0 |
|
| 235 | + * @package GeoDirectory |
|
| 236 | + * @global array $menu Menu array. |
|
| 237 | + * @global object $geodirectory GeoDirectory plugin object. |
|
| 238 | + */ |
|
| 239 | + function geodir_admin_menu() |
|
| 240 | + {
|
|
| 241 | + global $menu, $geodirectory; |
|
| 242 | 242 | |
| 243 | - if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
|
| 243 | + if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
|
| 244 | 244 | |
| 245 | - add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 245 | + add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 246 | 246 | |
| 247 | 247 | |
| 248 | - } |
|
| 248 | + } |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | if (!function_exists('geodir_admin_menu_order')) {
|
| 252 | - /** |
|
| 253 | - * Order admin menus. |
|
| 254 | - * |
|
| 255 | - * @since 1.0.0 |
|
| 256 | - * @package GeoDirectory |
|
| 257 | - * @param array $menu_order Menu order array. |
|
| 258 | - * @return array Modified menu order array. |
|
| 259 | - */ |
|
| 260 | - function geodir_admin_menu_order($menu_order) |
|
| 261 | - {
|
|
| 262 | - |
|
| 263 | - // Initialize our custom order array |
|
| 264 | - $geodir_menu_order = array(); |
|
| 265 | - |
|
| 266 | - // Get the index of our custom separator |
|
| 267 | - $geodir_separator = array_search('separator-geodirectory', $menu_order);
|
|
| 268 | - |
|
| 269 | - // Get index of posttype menu |
|
| 270 | - $post_types = geodir_get_posttypes(); |
|
| 271 | - if (!empty($post_types)) {
|
|
| 272 | - foreach ($post_types as $post_type) {
|
|
| 273 | - $geodir_posts = array_search("edit.php?post_type={$post_type}", $menu_order);
|
|
| 274 | - } |
|
| 275 | - } |
|
| 252 | + /** |
|
| 253 | + * Order admin menus. |
|
| 254 | + * |
|
| 255 | + * @since 1.0.0 |
|
| 256 | + * @package GeoDirectory |
|
| 257 | + * @param array $menu_order Menu order array. |
|
| 258 | + * @return array Modified menu order array. |
|
| 259 | + */ |
|
| 260 | + function geodir_admin_menu_order($menu_order) |
|
| 261 | + {
|
|
| 276 | 262 | |
| 277 | - // Loop through menu order and do some rearranging |
|
| 278 | - foreach ($menu_order as $index => $item) : |
|
| 263 | + // Initialize our custom order array |
|
| 264 | + $geodir_menu_order = array(); |
|
| 279 | 265 | |
| 280 | - if ((('geodirectory') == $item)) :
|
|
| 281 | - $geodir_menu_order[] = 'separator-geodirectory'; |
|
| 282 | - if (!empty($post_types)) {
|
|
| 283 | - foreach ($post_types as $post_type) {
|
|
| 284 | - $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
| 285 | - } |
|
| 286 | - } |
|
| 287 | - $geodir_menu_order[] = $item; |
|
| 266 | + // Get the index of our custom separator |
|
| 267 | + $geodir_separator = array_search('separator-geodirectory', $menu_order);
|
|
| 268 | + |
|
| 269 | + // Get index of posttype menu |
|
| 270 | + $post_types = geodir_get_posttypes(); |
|
| 271 | + if (!empty($post_types)) {
|
|
| 272 | + foreach ($post_types as $post_type) {
|
|
| 273 | + $geodir_posts = array_search("edit.php?post_type={$post_type}", $menu_order);
|
|
| 274 | + } |
|
| 275 | + } |
|
| 288 | 276 | |
| 289 | - unset($menu_order[$geodir_separator]); |
|
| 290 | - //unset( $menu_order[$geodir_places] ); |
|
| 291 | - elseif (!in_array($item, array('separator-geodirectory'))) :
|
|
| 292 | - $geodir_menu_order[] = $item; |
|
| 293 | - endif; |
|
| 277 | + // Loop through menu order and do some rearranging |
|
| 278 | + foreach ($menu_order as $index => $item) : |
|
| 294 | 279 | |
| 295 | - endforeach; |
|
| 280 | + if ((('geodirectory') == $item)) :
|
|
| 281 | + $geodir_menu_order[] = 'separator-geodirectory'; |
|
| 282 | + if (!empty($post_types)) {
|
|
| 283 | + foreach ($post_types as $post_type) {
|
|
| 284 | + $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | + $geodir_menu_order[] = $item; |
|
| 296 | 288 | |
| 297 | - // Return order |
|
| 298 | - return $geodir_menu_order; |
|
| 299 | - } |
|
| 289 | + unset($menu_order[$geodir_separator]); |
|
| 290 | + //unset( $menu_order[$geodir_places] ); |
|
| 291 | + elseif (!in_array($item, array('separator-geodirectory'))) :
|
|
| 292 | + $geodir_menu_order[] = $item; |
|
| 293 | + endif; |
|
| 294 | + |
|
| 295 | + endforeach; |
|
| 296 | + |
|
| 297 | + // Return order |
|
| 298 | + return $geodir_menu_order; |
|
| 299 | + } |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | if (!function_exists('geodir_admin_custom_menu_order')) {
|
| 303 | - /** |
|
| 304 | - * Enables custom menu order. |
|
| 305 | - * |
|
| 306 | - * @since 1.0.0 |
|
| 307 | - * @package GeoDirectory |
|
| 308 | - * @return bool |
|
| 309 | - */ |
|
| 310 | - function geodir_admin_custom_menu_order() |
|
| 311 | - {
|
|
| 312 | - if (!current_user_can('manage_options')) return false;
|
|
| 313 | - return true; |
|
| 314 | - } |
|
| 303 | + /** |
|
| 304 | + * Enables custom menu order. |
|
| 305 | + * |
|
| 306 | + * @since 1.0.0 |
|
| 307 | + * @package GeoDirectory |
|
| 308 | + * @return bool |
|
| 309 | + */ |
|
| 310 | + function geodir_admin_custom_menu_order() |
|
| 311 | + {
|
|
| 312 | + if (!current_user_can('manage_options')) return false;
|
|
| 313 | + return true; |
|
| 314 | + } |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
@@ -322,41 +322,41 @@ discard block |
||
| 322 | 322 | */ |
| 323 | 323 | function geodir_before_admin_panel() |
| 324 | 324 | {
|
| 325 | - if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
|
|
| 326 | - echo '<div id="message" class="updated fade"> |
|
| 325 | + if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
|
|
| 326 | + echo '<div id="message" class="updated fade"> |
|
| 327 | 327 | <p style="float:right;">' . __('Like Geodirectory?', 'geodirectory') . ' <a href="http://wordpress.org/extend/plugins/Geodirectory/" target="_blank">' . __('Support us by leaving a rating!', 'geodirectory') . '</a></p>
|
| 328 | 328 | <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
|
| 329 | 329 | </div>'; |
| 330 | 330 | |
| 331 | - } |
|
| 331 | + } |
|
| 332 | 332 | |
| 333 | - if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
|
|
| 334 | - switch ($_REQUEST['msg']) {
|
|
| 335 | - case 'success': |
|
| 336 | - echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
|
|
| 337 | - flush_rewrite_rules(false); |
|
| 333 | + if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
|
|
| 334 | + switch ($_REQUEST['msg']) {
|
|
| 335 | + case 'success': |
|
| 336 | + echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
|
|
| 337 | + flush_rewrite_rules(false); |
|
| 338 | 338 | |
| 339 | - break; |
|
| 339 | + break; |
|
| 340 | 340 | case 'fail': |
| 341 | 341 | $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
| 342 | 342 | |
| 343 | 343 | if ($gderr == 21) |
| 344 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 344 | + echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 345 | 345 | else |
| 346 | 346 | echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
|
| 347 | - break; |
|
| 348 | - } |
|
| 349 | - } |
|
| 347 | + break; |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | - if (!geodir_is_default_location_set()) {
|
|
| 352 | - 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>';
|
|
| 351 | + if (!geodir_is_default_location_set()) {
|
|
| 352 | + 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>';
|
|
| 353 | 353 | |
| 354 | - } |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - if (!function_exists('curl_init')) {
|
|
| 357 | - 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>';
|
|
| 356 | + if (!function_exists('curl_init')) {
|
|
| 357 | + 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>';
|
|
| 358 | 358 | |
| 359 | - } |
|
| 359 | + } |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /** |
@@ -369,19 +369,19 @@ discard block |
||
| 369 | 369 | */ |
| 370 | 370 | function geodir_handle_option_form_submit($current_tab) |
| 371 | 371 | {
|
| 372 | - global $geodir_settings; |
|
| 373 | - if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
|
|
| 374 | - /** |
|
| 375 | - * Contains settings array for current tab. |
|
| 376 | - * |
|
| 377 | - * @since 1.0.0 |
|
| 378 | - * @package GeoDirectory |
|
| 379 | - */ |
|
| 380 | - include_once('option-pages/' . $current_tab . '_array.php');
|
|
| 381 | - } |
|
| 382 | - if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
| 383 | - if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 384 | - if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 372 | + global $geodir_settings; |
|
| 373 | + if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
|
|
| 374 | + /** |
|
| 375 | + * Contains settings array for current tab. |
|
| 376 | + * |
|
| 377 | + * @since 1.0.0 |
|
| 378 | + * @package GeoDirectory |
|
| 379 | + */ |
|
| 380 | + include_once('option-pages/' . $current_tab . '_array.php');
|
|
| 381 | + } |
|
| 382 | + if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
| 383 | + if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 384 | + if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 385 | 385 | |
| 386 | 386 | /** |
| 387 | 387 | * Fires before updating geodirectory admin settings. |
@@ -393,100 +393,100 @@ discard block |
||
| 393 | 393 | */ |
| 394 | 394 | do_action('geodir_before_update_options', $current_tab, $geodir_settings);
|
| 395 | 395 | |
| 396 | - if (!empty($geodir_settings[$current_tab])) |
|
| 397 | - geodir_update_options($geodir_settings[$current_tab]); |
|
| 396 | + if (!empty($geodir_settings[$current_tab])) |
|
| 397 | + geodir_update_options($geodir_settings[$current_tab]); |
|
| 398 | 398 | |
| 399 | - /** |
|
| 400 | - * Called after GeoDirectory options settings are updated. |
|
| 401 | - * |
|
| 402 | - * @since 1.0.0 |
|
| 403 | - * @param array $geodir_settings The array of GeoDirectory settings. |
|
| 404 | - * @see 'geodir_before_update_options' |
|
| 405 | - */ |
|
| 406 | - do_action('geodir_update_options', $geodir_settings);
|
|
| 399 | + /** |
|
| 400 | + * Called after GeoDirectory options settings are updated. |
|
| 401 | + * |
|
| 402 | + * @since 1.0.0 |
|
| 403 | + * @param array $geodir_settings The array of GeoDirectory settings. |
|
| 404 | + * @see 'geodir_before_update_options' |
|
| 405 | + */ |
|
| 406 | + do_action('geodir_update_options', $geodir_settings);
|
|
| 407 | 407 | |
| 408 | - /** |
|
| 409 | - * Called after GeoDirectory options settings are updated. |
|
| 410 | - * |
|
| 411 | - * Provides tab specific settings. |
|
| 412 | - * |
|
| 413 | - * @since 1.0.0 |
|
| 414 | - * @param string $current_tab The current settings tab name. |
|
| 415 | - * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
| 416 | - */ |
|
| 417 | - do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
|
|
| 408 | + /** |
|
| 409 | + * Called after GeoDirectory options settings are updated. |
|
| 410 | + * |
|
| 411 | + * Provides tab specific settings. |
|
| 412 | + * |
|
| 413 | + * @since 1.0.0 |
|
| 414 | + * @param string $current_tab The current settings tab name. |
|
| 415 | + * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
| 416 | + */ |
|
| 417 | + do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
|
|
| 418 | 418 | |
| 419 | - flush_rewrite_rules(false); |
|
| 419 | + flush_rewrite_rules(false); |
|
| 420 | 420 | |
| 421 | - $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
| 421 | + $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
| 422 | 422 | |
| 423 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
|
|
| 423 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
|
|
| 424 | 424 | |
| 425 | - wp_redirect($redirect_url); |
|
| 426 | - exit(); |
|
| 427 | - endif; |
|
| 425 | + wp_redirect($redirect_url); |
|
| 426 | + exit(); |
|
| 427 | + endif; |
|
| 428 | 428 | |
| 429 | 429 | |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | |
| 433 | 433 | if (!function_exists('geodir_autoinstall_admin_header') && get_option('geodir_installed')) {
|
| 434 | - /** |
|
| 435 | - * GeoDirectory dummy data installation. |
|
| 436 | - * |
|
| 437 | - * @since 1.0.0 |
|
| 438 | - * @package GeoDirectory |
|
| 439 | - * @global object $wpdb WordPress Database object. |
|
| 440 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 441 | - * @param string $post_type The post type. |
|
| 442 | - */ |
|
| 443 | - function geodir_autoinstall_admin_header($post_type = 'gd_place') |
|
| 444 | - {
|
|
| 445 | - |
|
| 446 | - global $wpdb, $plugin_prefix; |
|
| 447 | - |
|
| 448 | - if (!geodir_is_default_location_set()) {
|
|
| 449 | - 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>';
|
|
| 450 | - } else {
|
|
| 451 | - |
|
| 452 | - $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab='; |
|
| 453 | - |
|
| 454 | - $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
|
|
| 455 | - |
|
| 456 | - if ($post_counts > 0) {
|
|
| 457 | - $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
|
|
| 458 | - |
|
| 459 | - $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>'; |
|
| 460 | - $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>'; |
|
| 461 | - } else {
|
|
| 462 | - $options_list = ''; |
|
| 463 | - for ($option = 1; $option <= 30; $option++) {
|
|
| 464 | - $selected = ''; |
|
| 465 | - if ($option == 10) |
|
| 466 | - $selected = 'selected="selected"'; |
|
| 467 | - |
|
| 468 | - $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>'; |
|
| 469 | - } |
|
| 434 | + /** |
|
| 435 | + * GeoDirectory dummy data installation. |
|
| 436 | + * |
|
| 437 | + * @since 1.0.0 |
|
| 438 | + * @package GeoDirectory |
|
| 439 | + * @global object $wpdb WordPress Database object. |
|
| 440 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 441 | + * @param string $post_type The post type. |
|
| 442 | + */ |
|
| 443 | + function geodir_autoinstall_admin_header($post_type = 'gd_place') |
|
| 444 | + {
|
|
| 445 | + |
|
| 446 | + global $wpdb, $plugin_prefix; |
|
| 470 | 447 | |
| 471 | - $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
|
|
| 448 | + if (!geodir_is_default_location_set()) {
|
|
| 449 | + 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>';
|
|
| 450 | + } else {
|
|
| 472 | 451 | |
| 473 | - $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>'; |
|
| 474 | - $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>'; |
|
| 452 | + $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab='; |
|
| 475 | 453 | |
| 476 | - } |
|
| 477 | - echo $dummy_msg; |
|
| 478 | - ?> |
|
| 454 | + $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
|
|
| 455 | + |
|
| 456 | + if ($post_counts > 0) {
|
|
| 457 | + $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
|
|
| 458 | + |
|
| 459 | + $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>'; |
|
| 460 | + $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>'; |
|
| 461 | + } else {
|
|
| 462 | + $options_list = ''; |
|
| 463 | + for ($option = 1; $option <= 30; $option++) {
|
|
| 464 | + $selected = ''; |
|
| 465 | + if ($option == 10) |
|
| 466 | + $selected = 'selected="selected"'; |
|
| 467 | + |
|
| 468 | + $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>'; |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
|
|
| 472 | + |
|
| 473 | + $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>'; |
|
| 474 | + $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>'; |
|
| 475 | + |
|
| 476 | + } |
|
| 477 | + echo $dummy_msg; |
|
| 478 | + ?> |
|
| 479 | 479 | <script> |
| 480 | 480 | <?php |
| 481 | 481 | |
| 482 | - $default_location = geodir_get_default_location(); |
|
| 483 | - $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 484 | - $region =isset($default_location->region) ? $default_location->region : ''; |
|
| 485 | - $country =isset($default_location->country) ? $default_location->country : ''; |
|
| 486 | - $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 487 | - $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 482 | + $default_location = geodir_get_default_location(); |
|
| 483 | + $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 484 | + $region =isset($default_location->region) ? $default_location->region : ''; |
|
| 485 | + $country =isset($default_location->country) ? $default_location->country : ''; |
|
| 486 | + $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 487 | + $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 488 | 488 | |
| 489 | - ?> |
|
| 489 | + ?> |
|
| 490 | 490 | var geocoder = new google.maps.Geocoder(); |
| 491 | 491 | var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country;?>'; |
| 492 | 492 | var bound_lat_lng; |
@@ -571,8 +571,8 @@ discard block |
||
| 571 | 571 | } |
| 572 | 572 | </script> |
| 573 | 573 | <?php |
| 574 | - } |
|
| 575 | - } |
|
| 574 | + } |
|
| 575 | + } |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | /** |
@@ -585,19 +585,19 @@ discard block |
||
| 585 | 585 | */ |
| 586 | 586 | function geodir_insert_dummy_posts() |
| 587 | 587 | {
|
| 588 | - geodir_default_taxonomies(); |
|
| 588 | + geodir_default_taxonomies(); |
|
| 589 | 589 | |
| 590 | - ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
|
|
| 590 | + ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
|
|
| 591 | 591 | |
| 592 | - global $wpdb, $current_user; |
|
| 592 | + global $wpdb, $current_user; |
|
| 593 | 593 | |
| 594 | - /** |
|
| 595 | - * Contains dumy post content. |
|
| 596 | - * |
|
| 597 | - * @since 1.0.0 |
|
| 598 | - * @package GeoDirectory |
|
| 599 | - */ |
|
| 600 | - include_once('place_dummy_post.php');
|
|
| 594 | + /** |
|
| 595 | + * Contains dumy post content. |
|
| 596 | + * |
|
| 597 | + * @since 1.0.0 |
|
| 598 | + * @package GeoDirectory |
|
| 599 | + */ |
|
| 600 | + include_once('place_dummy_post.php');
|
|
| 601 | 601 | |
| 602 | 602 | } |
| 603 | 603 | |
@@ -611,18 +611,18 @@ discard block |
||
| 611 | 611 | */ |
| 612 | 612 | function geodir_delete_dummy_posts() |
| 613 | 613 | {
|
| 614 | - global $wpdb, $plugin_prefix; |
|
| 614 | + global $wpdb, $plugin_prefix; |
|
| 615 | 615 | |
| 616 | 616 | |
| 617 | - $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 617 | + $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 618 | 618 | |
| 619 | 619 | |
| 620 | - foreach ($post_ids as $post_ids_obj) {
|
|
| 621 | - wp_delete_post($post_ids_obj->post_id); |
|
| 622 | - } |
|
| 620 | + foreach ($post_ids as $post_ids_obj) {
|
|
| 621 | + wp_delete_post($post_ids_obj->post_id); |
|
| 622 | + } |
|
| 623 | 623 | |
| 624 | - //double check posts are deleted |
|
| 625 | - $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 624 | + //double check posts are deleted |
|
| 625 | + $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | /** |
@@ -638,110 +638,110 @@ discard block |
||
| 638 | 638 | function geodir_default_taxonomies() |
| 639 | 639 | {
|
| 640 | 640 | |
| 641 | - global $wpdb, $dummy_image_path; |
|
| 641 | + global $wpdb, $dummy_image_path; |
|
| 642 | 642 | |
| 643 | - $category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
|
|
| 643 | + $category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
|
|
| 644 | 644 | |
| 645 | - $last_catid = isset($last_catid) ? $last_catid : ''; |
|
| 645 | + $last_catid = isset($last_catid) ? $last_catid : ''; |
|
| 646 | 646 | |
| 647 | - $last_term = get_term($last_catid, 'gd_placecategory'); |
|
| 647 | + $last_term = get_term($last_catid, 'gd_placecategory'); |
|
| 648 | 648 | |
| 649 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 650 | - //print_r($uploads) ; |
|
| 651 | - for ($i = 0; $i < count($category_array); $i++) {
|
|
| 652 | - $parent_catid = 0; |
|
| 653 | - if (is_array($category_array[$i])) {
|
|
| 654 | - $cat_name_arr = $category_array[$i]; |
|
| 655 | - for ($j = 0; $j < count($cat_name_arr); $j++) {
|
|
| 656 | - $catname = $cat_name_arr[$j]; |
|
| 649 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 650 | + //print_r($uploads) ; |
|
| 651 | + for ($i = 0; $i < count($category_array); $i++) {
|
|
| 652 | + $parent_catid = 0; |
|
| 653 | + if (is_array($category_array[$i])) {
|
|
| 654 | + $cat_name_arr = $category_array[$i]; |
|
| 655 | + for ($j = 0; $j < count($cat_name_arr); $j++) {
|
|
| 656 | + $catname = $cat_name_arr[$j]; |
|
| 657 | 657 | |
| 658 | - if (!term_exists($catname, 'gd_placecategory')) {
|
|
| 659 | - $last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
|
|
| 658 | + if (!term_exists($catname, 'gd_placecategory')) {
|
|
| 659 | + $last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
|
|
| 660 | 660 | |
| 661 | - if ($j == 0) {
|
|
| 662 | - $parent_catid = $last_catid; |
|
| 663 | - } |
|
| 661 | + if ($j == 0) {
|
|
| 662 | + $parent_catid = $last_catid; |
|
| 663 | + } |
|
| 664 | 664 | |
| 665 | 665 | |
| 666 | - if (geodir_dummy_folder_exists()) |
|
| 667 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 668 | - else |
|
| 669 | - $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 670 | - $catname = str_replace(' ', '_', $catname);
|
|
| 671 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 666 | + if (geodir_dummy_folder_exists()) |
|
| 667 | + $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 668 | + else |
|
| 669 | + $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 670 | + $catname = str_replace(' ', '_', $catname);
|
|
| 671 | + $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 672 | 672 | |
| 673 | - if (empty($uploaded['error'])) {
|
|
| 674 | - $new_path = $uploaded['file']; |
|
| 675 | - $new_url = $uploaded['url']; |
|
| 676 | - } |
|
| 673 | + if (empty($uploaded['error'])) {
|
|
| 674 | + $new_path = $uploaded['file']; |
|
| 675 | + $new_url = $uploaded['url']; |
|
| 676 | + } |
|
| 677 | 677 | |
| 678 | - $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
| 679 | - |
|
| 680 | - $attachment = array( |
|
| 681 | - 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 682 | - 'post_mime_type' => $wp_filetype['type'], |
|
| 683 | - 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
|
| 684 | - 'post_content' => '', |
|
| 685 | - 'post_status' => 'inherit' |
|
| 686 | - ); |
|
| 687 | - $attach_id = wp_insert_attachment($attachment, $new_path); |
|
| 688 | - |
|
| 689 | - // you must first include the image.php file |
|
| 690 | - // for the function wp_generate_attachment_metadata() to work |
|
| 691 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 692 | - $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
| 693 | - wp_update_attachment_metadata($attach_id, $attach_data); |
|
| 694 | - |
|
| 695 | - if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
|
|
| 696 | - update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
|
|
| 697 | - } |
|
| 698 | - } |
|
| 699 | - } |
|
| 678 | + $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
| 679 | + |
|
| 680 | + $attachment = array( |
|
| 681 | + 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 682 | + 'post_mime_type' => $wp_filetype['type'], |
|
| 683 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
|
| 684 | + 'post_content' => '', |
|
| 685 | + 'post_status' => 'inherit' |
|
| 686 | + ); |
|
| 687 | + $attach_id = wp_insert_attachment($attachment, $new_path); |
|
| 688 | + |
|
| 689 | + // you must first include the image.php file |
|
| 690 | + // for the function wp_generate_attachment_metadata() to work |
|
| 691 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 692 | + $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
| 693 | + wp_update_attachment_metadata($attach_id, $attach_data); |
|
| 694 | + |
|
| 695 | + if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
|
|
| 696 | + update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
|
|
| 697 | + } |
|
| 698 | + } |
|
| 699 | + } |
|
| 700 | 700 | |
| 701 | - } else {
|
|
| 702 | - $catname = $category_array[$i]; |
|
| 701 | + } else {
|
|
| 702 | + $catname = $category_array[$i]; |
|
| 703 | 703 | |
| 704 | - if (!term_exists($catname, 'gd_placecategory')) {
|
|
| 705 | - $last_catid = wp_insert_term($catname, 'gd_placecategory'); |
|
| 704 | + if (!term_exists($catname, 'gd_placecategory')) {
|
|
| 705 | + $last_catid = wp_insert_term($catname, 'gd_placecategory'); |
|
| 706 | 706 | |
| 707 | - if (geodir_dummy_folder_exists()) |
|
| 708 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 709 | - else |
|
| 710 | - $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 711 | - $catname = str_replace(' ', '_', $catname);
|
|
| 712 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 707 | + if (geodir_dummy_folder_exists()) |
|
| 708 | + $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 709 | + else |
|
| 710 | + $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 711 | + $catname = str_replace(' ', '_', $catname);
|
|
| 712 | + $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 713 | 713 | |
| 714 | - if (empty($uploaded['error'])) {
|
|
| 715 | - $new_path = $uploaded['file']; |
|
| 716 | - $new_url = $uploaded['url']; |
|
| 717 | - } |
|
| 714 | + if (empty($uploaded['error'])) {
|
|
| 715 | + $new_path = $uploaded['file']; |
|
| 716 | + $new_url = $uploaded['url']; |
|
| 717 | + } |
|
| 718 | 718 | |
| 719 | - $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
| 719 | + $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
| 720 | 720 | |
| 721 | - $attachment = array( |
|
| 722 | - 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 723 | - 'post_mime_type' => $wp_filetype['type'], |
|
| 724 | - 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
|
| 725 | - 'post_content' => '', |
|
| 726 | - 'post_status' => 'inherit' |
|
| 727 | - ); |
|
| 721 | + $attachment = array( |
|
| 722 | + 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 723 | + 'post_mime_type' => $wp_filetype['type'], |
|
| 724 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
|
| 725 | + 'post_content' => '', |
|
| 726 | + 'post_status' => 'inherit' |
|
| 727 | + ); |
|
| 728 | 728 | |
| 729 | - $attach_id = wp_insert_attachment($attachment, $new_path); |
|
| 729 | + $attach_id = wp_insert_attachment($attachment, $new_path); |
|
| 730 | 730 | |
| 731 | 731 | |
| 732 | - // you must first include the image.php file |
|
| 733 | - // for the function wp_generate_attachment_metadata() to work |
|
| 734 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 735 | - $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
| 736 | - wp_update_attachment_metadata($attach_id, $attach_data); |
|
| 732 | + // you must first include the image.php file |
|
| 733 | + // for the function wp_generate_attachment_metadata() to work |
|
| 734 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 735 | + $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
| 736 | + wp_update_attachment_metadata($attach_id, $attach_data); |
|
| 737 | 737 | |
| 738 | - if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
|
|
| 739 | - update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
|
|
| 740 | - } |
|
| 741 | - } |
|
| 742 | - } |
|
| 738 | + if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
|
|
| 739 | + update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
|
|
| 740 | + } |
|
| 741 | + } |
|
| 742 | + } |
|
| 743 | 743 | |
| 744 | - } |
|
| 744 | + } |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | /** |
@@ -759,145 +759,145 @@ discard block |
||
| 759 | 759 | {
|
| 760 | 760 | // print_r($_POST); print_r($options); exit; |
| 761 | 761 | |
| 762 | - if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
| 762 | + if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
| 763 | 763 | |
| 764 | - foreach ($options as $value) {
|
|
| 765 | - if ($dummy && isset($value['std'])) |
|
| 766 | - $_POST[$value['id']] = $value['std']; |
|
| 764 | + foreach ($options as $value) {
|
|
| 765 | + if ($dummy && isset($value['std'])) |
|
| 766 | + $_POST[$value['id']] = $value['std']; |
|
| 767 | 767 | |
| 768 | 768 | |
| 769 | - if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
| 769 | + if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
| 770 | 770 | |
| 771 | - if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 772 | - update_option($value['id'], $_POST[$value['id']]); |
|
| 773 | - } else {
|
|
| 774 | - update_option($value['id'], 0); |
|
| 775 | - } |
|
| 771 | + if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 772 | + update_option($value['id'], $_POST[$value['id']]); |
|
| 773 | + } else {
|
|
| 774 | + update_option($value['id'], 0); |
|
| 775 | + } |
|
| 776 | 776 | |
| 777 | - elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 778 | - |
|
| 779 | - if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
|
| 780 | - update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
| 781 | - update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
| 782 | - if (isset($_POST[$value['id'] . '_crop'])) : |
|
| 783 | - update_option($value['id'] . '_crop', 1); |
|
| 784 | - else : |
|
| 785 | - update_option($value['id'] . '_crop', 0); |
|
| 786 | - endif; |
|
| 787 | - } else {
|
|
| 788 | - update_option($value['id'] . '_width', $value['std']); |
|
| 789 | - update_option($value['id'] . '_height', $value['std']); |
|
| 790 | - update_option($value['id'] . '_crop', 1); |
|
| 791 | - } |
|
| 777 | + elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 792 | 778 | |
| 793 | - elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 794 | - $post_types = array(); |
|
| 795 | - $categories = array(); |
|
| 796 | - $i = 0; |
|
| 779 | + if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
|
| 780 | + update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
| 781 | + update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
| 782 | + if (isset($_POST[$value['id'] . '_crop'])) : |
|
| 783 | + update_option($value['id'] . '_crop', 1); |
|
| 784 | + else : |
|
| 785 | + update_option($value['id'] . '_crop', 0); |
|
| 786 | + endif; |
|
| 787 | + } else {
|
|
| 788 | + update_option($value['id'] . '_width', $value['std']); |
|
| 789 | + update_option($value['id'] . '_height', $value['std']); |
|
| 790 | + update_option($value['id'] . '_crop', 1); |
|
| 791 | + } |
|
| 797 | 792 | |
| 798 | - if (!empty($_POST['home_map_post_types'])) : |
|
| 799 | - foreach ($_POST['home_map_post_types'] as $post_type) : |
|
| 800 | - $post_types[] = $post_type; |
|
| 801 | - endforeach; |
|
| 802 | - endif; |
|
| 793 | + elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 794 | + $post_types = array(); |
|
| 795 | + $categories = array(); |
|
| 796 | + $i = 0; |
|
| 803 | 797 | |
| 804 | - update_option('geodir_exclude_post_type_on_map', $post_types);
|
|
| 798 | + if (!empty($_POST['home_map_post_types'])) : |
|
| 799 | + foreach ($_POST['home_map_post_types'] as $post_type) : |
|
| 800 | + $post_types[] = $post_type; |
|
| 801 | + endforeach; |
|
| 802 | + endif; |
|
| 805 | 803 | |
| 806 | - if (!empty($_POST['post_category'])) : |
|
| 807 | - foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
| 808 | - $categories[$texonomy] = array(); |
|
| 809 | - foreach ($cat_arr as $category) : |
|
| 810 | - $categories[$texonomy][] = $category; |
|
| 811 | - endforeach; |
|
| 812 | - $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
| 813 | - endforeach; |
|
| 814 | - endif; |
|
| 815 | - update_option('geodir_exclude_cat_on_map', $categories);
|
|
| 816 | - update_option('geodir_exclude_cat_on_map_upgrade', 1);
|
|
| 817 | - elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
| 804 | + update_option('geodir_exclude_post_type_on_map', $post_types);
|
|
| 818 | 805 | |
| 806 | + if (!empty($_POST['post_category'])) : |
|
| 807 | + foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
| 808 | + $categories[$texonomy] = array(); |
|
| 809 | + foreach ($cat_arr as $category) : |
|
| 810 | + $categories[$texonomy][] = $category; |
|
| 811 | + endforeach; |
|
| 812 | + $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
| 813 | + endforeach; |
|
| 814 | + endif; |
|
| 815 | + update_option('geodir_exclude_cat_on_map', $categories);
|
|
| 816 | + update_option('geodir_exclude_cat_on_map_upgrade', 1);
|
|
| 817 | + elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
| 819 | 818 | |
| 820 | - if (!empty($_POST['geodir_default_map_language'])): |
|
| 821 | - update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
|
|
| 822 | - endif; |
|
| 823 | 819 | |
| 820 | + if (!empty($_POST['geodir_default_map_language'])): |
|
| 821 | + update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
|
|
| 822 | + endif; |
|
| 824 | 823 | |
| 825 | - if (!empty($_POST['geodir_default_map_search_pt'])): |
|
| 826 | - update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
|
|
| 827 | - endif; |
|
| 828 | 824 | |
| 825 | + if (!empty($_POST['geodir_default_map_search_pt'])): |
|
| 826 | + update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
|
|
| 827 | + endif; |
|
| 829 | 828 | |
| 830 | - elseif (isset($value['type']) && $value['type'] == 'file') : |
|
| 831 | 829 | |
| 830 | + elseif (isset($value['type']) && $value['type'] == 'file') : |
|
| 832 | 831 | |
| 833 | - if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
|
|
| 834 | 832 | |
| 835 | - if (get_option($value['id'])) {
|
|
| 836 | - $image_name_arr = explode('/', get_option($value['id']));
|
|
| 837 | - $noimg_name = end($image_name_arr); |
|
| 838 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 839 | - if (file_exists($img_path)) |
|
| 840 | - unlink($img_path); |
|
| 841 | - } |
|
| 833 | + if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
|
|
| 842 | 834 | |
| 843 | - update_option($value['id'], ''); |
|
| 844 | - } |
|
| 835 | + if (get_option($value['id'])) {
|
|
| 836 | + $image_name_arr = explode('/', get_option($value['id']));
|
|
| 837 | + $noimg_name = end($image_name_arr); |
|
| 838 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 839 | + if (file_exists($img_path)) |
|
| 840 | + unlink($img_path); |
|
| 841 | + } |
|
| 845 | 842 | |
| 846 | - $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
| 847 | - $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
| 848 | - |
|
| 849 | - if (!empty($filename)): |
|
| 850 | - $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
| 851 | - $uplaods = array(); |
|
| 852 | - |
|
| 853 | - foreach ($uploadedfile as $key => $uplaod): |
|
| 854 | - if ($key == 'name'): |
|
| 855 | - $uplaods[$key] = $filename; |
|
| 856 | - else : |
|
| 857 | - $uplaods[$key] = $uplaod; |
|
| 858 | - endif; |
|
| 859 | - endforeach; |
|
| 860 | - |
|
| 861 | - $uploads = wp_upload_dir(); |
|
| 862 | - |
|
| 863 | - if (get_option($value['id'])) {
|
|
| 864 | - $image_name_arr = explode('/', get_option($value['id']));
|
|
| 865 | - $noimg_name = end($image_name_arr); |
|
| 866 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 867 | - if (file_exists($img_path)) |
|
| 868 | - unlink($img_path); |
|
| 869 | - } |
|
| 843 | + update_option($value['id'], ''); |
|
| 844 | + } |
|
| 870 | 845 | |
| 871 | - $upload_overrides = array('test_form' => false);
|
|
| 872 | - $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
| 846 | + $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
| 847 | + $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
| 848 | + |
|
| 849 | + if (!empty($filename)): |
|
| 850 | + $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
| 851 | + $uplaods = array(); |
|
| 852 | + |
|
| 853 | + foreach ($uploadedfile as $key => $uplaod): |
|
| 854 | + if ($key == 'name'): |
|
| 855 | + $uplaods[$key] = $filename; |
|
| 856 | + else : |
|
| 857 | + $uplaods[$key] = $uplaod; |
|
| 858 | + endif; |
|
| 859 | + endforeach; |
|
| 860 | + |
|
| 861 | + $uploads = wp_upload_dir(); |
|
| 862 | + |
|
| 863 | + if (get_option($value['id'])) {
|
|
| 864 | + $image_name_arr = explode('/', get_option($value['id']));
|
|
| 865 | + $noimg_name = end($image_name_arr); |
|
| 866 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 867 | + if (file_exists($img_path)) |
|
| 868 | + unlink($img_path); |
|
| 869 | + } |
|
| 873 | 870 | |
| 874 | - update_option($value['id'], $movefile['url']); |
|
| 871 | + $upload_overrides = array('test_form' => false);
|
|
| 872 | + $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
| 875 | 873 | |
| 876 | - endif; |
|
| 874 | + update_option($value['id'], $movefile['url']); |
|
| 877 | 875 | |
| 878 | - if (!get_option($value['id']) && isset($value['value'])): |
|
| 879 | - update_option($value['id'], $value['value']); |
|
| 880 | - endif; |
|
| 876 | + endif; |
|
| 881 | 877 | |
| 878 | + if (!get_option($value['id']) && isset($value['value'])): |
|
| 879 | + update_option($value['id'], $value['value']); |
|
| 880 | + endif; |
|
| 882 | 881 | |
| 883 | - else : |
|
| 884 | - // same menu setting per theme. |
|
| 885 | - if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
|
| 886 | - $theme = wp_get_theme(); |
|
| 887 | - update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
|
| 888 | - } |
|
| 889 | 882 | |
| 890 | - if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 891 | - update_option($value['id'], $_POST[$value['id']]); |
|
| 892 | - } else {
|
|
| 893 | - delete_option($value['id']); |
|
| 894 | - } |
|
| 883 | + else : |
|
| 884 | + // same menu setting per theme. |
|
| 885 | + if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
|
| 886 | + $theme = wp_get_theme(); |
|
| 887 | + update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
|
| 888 | + } |
|
| 895 | 889 | |
| 896 | - endif; |
|
| 897 | - } |
|
| 898 | - if ($dummy) |
|
| 899 | - $_POST = array(); |
|
| 900 | - return true; |
|
| 890 | + if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 891 | + update_option($value['id'], $_POST[$value['id']]); |
|
| 892 | + } else {
|
|
| 893 | + delete_option($value['id']); |
|
| 894 | + } |
|
| 895 | + |
|
| 896 | + endif; |
|
| 897 | + } |
|
| 898 | + if ($dummy) |
|
| 899 | + $_POST = array(); |
|
| 900 | + return true; |
|
| 901 | 901 | |
| 902 | 902 | } |
| 903 | 903 | |
@@ -946,33 +946,33 @@ discard block |
||
| 946 | 946 | function places_custom_fields_tab($tabs) |
| 947 | 947 | {
|
| 948 | 948 | |
| 949 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 949 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 950 | 950 | |
| 951 | - if (!empty($geodir_post_types)) {
|
|
| 951 | + if (!empty($geodir_post_types)) {
|
|
| 952 | 952 | |
| 953 | - foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
| 953 | + foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
| 954 | 954 | |
| 955 | - $listing_slug = $geodir_posttype_info['labels']['singular_name']; |
|
| 955 | + $listing_slug = $geodir_posttype_info['labels']['singular_name']; |
|
| 956 | 956 | |
| 957 | - $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
| 958 | - 'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'), |
|
| 959 | - 'subtabs' => array( |
|
| 960 | - array('subtab' => 'custom_fields',
|
|
| 961 | - 'label' => __('Custom Fields', 'geodirectory'),
|
|
| 962 | - 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 963 | - array('subtab' => 'sorting_options',
|
|
| 964 | - 'label' => __('Sorting Options', 'geodirectory'),
|
|
| 965 | - 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 966 | - ), |
|
| 967 | - 'tab_index' => 9, |
|
| 968 | - 'request' => array('listing_type' => $geodir_post_type)
|
|
| 969 | - ); |
|
| 957 | + $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
| 958 | + 'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'), |
|
| 959 | + 'subtabs' => array( |
|
| 960 | + array('subtab' => 'custom_fields',
|
|
| 961 | + 'label' => __('Custom Fields', 'geodirectory'),
|
|
| 962 | + 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 963 | + array('subtab' => 'sorting_options',
|
|
| 964 | + 'label' => __('Sorting Options', 'geodirectory'),
|
|
| 965 | + 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 966 | + ), |
|
| 967 | + 'tab_index' => 9, |
|
| 968 | + 'request' => array('listing_type' => $geodir_post_type)
|
|
| 969 | + ); |
|
| 970 | 970 | |
| 971 | - endforeach; |
|
| 971 | + endforeach; |
|
| 972 | 972 | |
| 973 | - } |
|
| 973 | + } |
|
| 974 | 974 | |
| 975 | - return $tabs; |
|
| 975 | + return $tabs; |
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | |
@@ -988,8 +988,8 @@ discard block |
||
| 988 | 988 | */ |
| 989 | 989 | function geodir_tools_setting_tab($tabs) |
| 990 | 990 | {
|
| 991 | - $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
|
|
| 992 | - return $tabs; |
|
| 991 | + $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
|
|
| 992 | + return $tabs; |
|
| 993 | 993 | } |
| 994 | 994 | |
| 995 | 995 | /** |
@@ -1004,8 +1004,8 @@ discard block |
||
| 1004 | 1004 | */ |
| 1005 | 1005 | function geodir_compatibility_setting_tab($tabs) |
| 1006 | 1006 | {
|
| 1007 | - $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
|
|
| 1008 | - return $tabs; |
|
| 1007 | + $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
|
|
| 1008 | + return $tabs; |
|
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | 1011 | |
@@ -1021,144 +1021,144 @@ discard block |
||
| 1021 | 1021 | */ |
| 1022 | 1022 | function geodir_extend_geodirectory_setting_tab($tabs) |
| 1023 | 1023 | {
|
| 1024 | - $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
|
|
| 1025 | - return $tabs; |
|
| 1024 | + $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
|
|
| 1025 | + return $tabs; |
|
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | |
| 1029 | 1029 | if (!function_exists('geodir_edit_post_columns')) {
|
| 1030 | - /** |
|
| 1031 | - * Modify admin post listing page columns. |
|
| 1032 | - * |
|
| 1033 | - * @since 1.0.0 |
|
| 1034 | - * @package GeoDirectory |
|
| 1035 | - * @param array $columns The column array. |
|
| 1036 | - * @return array Altered column array. |
|
| 1037 | - */ |
|
| 1038 | - function geodir_edit_post_columns($columns) |
|
| 1039 | - {
|
|
| 1040 | - |
|
| 1041 | - $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
|
|
| 1042 | - 'categorys' => __('Categories', 'geodirectory'));
|
|
| 1043 | - |
|
| 1044 | - if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
|
|
| 1045 | - {
|
|
| 1046 | - $offset = 0; // should we prepend $array with $data? |
|
| 1047 | - $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
| 1048 | - } |
|
| 1030 | + /** |
|
| 1031 | + * Modify admin post listing page columns. |
|
| 1032 | + * |
|
| 1033 | + * @since 1.0.0 |
|
| 1034 | + * @package GeoDirectory |
|
| 1035 | + * @param array $columns The column array. |
|
| 1036 | + * @return array Altered column array. |
|
| 1037 | + */ |
|
| 1038 | + function geodir_edit_post_columns($columns) |
|
| 1039 | + {
|
|
| 1049 | 1040 | |
| 1050 | - $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
| 1041 | + $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
|
|
| 1042 | + 'categorys' => __('Categories', 'geodirectory'));
|
|
| 1051 | 1043 | |
| 1052 | - $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
|
|
| 1044 | + if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
|
|
| 1045 | + {
|
|
| 1046 | + $offset = 0; // should we prepend $array with $data? |
|
| 1047 | + $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
| 1048 | + } |
|
| 1053 | 1049 | |
| 1054 | - return $columns; |
|
| 1055 | - } |
|
| 1050 | + $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
| 1051 | + |
|
| 1052 | + $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
|
|
| 1053 | + |
|
| 1054 | + return $columns; |
|
| 1055 | + } |
|
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | 1058 | |
| 1059 | 1059 | if (!function_exists('geodir_manage_post_columns')) {
|
| 1060 | - /** |
|
| 1061 | - * Adds content to our custom post listing page columns. |
|
| 1062 | - * |
|
| 1063 | - * @since 1.0.0 |
|
| 1064 | - * @package GeoDirectory |
|
| 1065 | - * @global object $wpdb WordPress Database object. |
|
| 1066 | - * @global object $post WordPress Post object. |
|
| 1067 | - * @param string $column The column name. |
|
| 1068 | - * @param int $post_id The post ID. |
|
| 1069 | - */ |
|
| 1070 | - function geodir_manage_post_columns($column, $post_id) |
|
| 1071 | - {
|
|
| 1072 | - global $post, $wpdb; |
|
| 1073 | - |
|
| 1074 | - switch ($column): |
|
| 1075 | - /* If displaying the 'city' column. */ |
|
| 1076 | - case 'location' : |
|
| 1077 | - $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
| 1078 | - $location = geodir_get_location($location_id); |
|
| 1079 | - /* If no city is found, output a default message. */ |
|
| 1080 | - if (empty($location)) {
|
|
| 1081 | - _e('Unknown', 'geodirectory');
|
|
| 1082 | - } else {
|
|
| 1083 | - /* If there is a city id, append 'city name' to the text string. */ |
|
| 1084 | - $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
|
|
| 1085 | - echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
| 1086 | - } |
|
| 1087 | - break; |
|
| 1088 | - |
|
| 1089 | - /* If displaying the 'expire' column. */ |
|
| 1090 | - case 'expire' : |
|
| 1091 | - $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
| 1092 | - $d1 = $expire_date; // get expire_date |
|
| 1093 | - $d2 = date('Y-m-d'); // get current date
|
|
| 1094 | - $state = __('days left', 'geodirectory');
|
|
| 1095 | - $date_diff_text = ''; |
|
| 1096 | - $expire_class = 'expire_left'; |
|
| 1097 | - if ($expire_date != 'Never') {
|
|
| 1098 | - if (strtotime($d1) < strtotime($d2)) {
|
|
| 1099 | - $state = __('days overdue', 'geodirectory');
|
|
| 1100 | - $expire_class = 'expire_over'; |
|
| 1101 | - } |
|
| 1102 | - $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the differance in days |
|
| 1103 | - $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
|
| 1104 | - } |
|
| 1105 | - /* If no expire_date is found, output a default message. */ |
|
| 1106 | - if (empty($expire_date)) |
|
| 1107 | - echo __('Unknown', 'geodirectory');
|
|
| 1108 | - /* If there is a expire_date, append 'days left' to the text string. */ |
|
| 1109 | - else |
|
| 1110 | - echo $expire_date . $date_diff_text; |
|
| 1111 | - break; |
|
| 1112 | - |
|
| 1113 | - /* If displaying the 'categorys' column. */ |
|
| 1114 | - case 'categorys' : |
|
| 1115 | - |
|
| 1116 | - /* Get the categorys for the post. */ |
|
| 1117 | - |
|
| 1118 | - |
|
| 1119 | - $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
| 1120 | - |
|
| 1121 | - /* If terms were found. */ |
|
| 1122 | - if (!empty($terms)) {
|
|
| 1123 | - $out = array(); |
|
| 1124 | - /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
| 1125 | - foreach ($terms as $term) {
|
|
| 1126 | - if (!strstr($term->taxonomy, 'tag')) {
|
|
| 1127 | - $out[] = sprintf('<a href="%s">%s</a>',
|
|
| 1128 | - esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
|
|
| 1129 | - esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
|
|
| 1130 | - ); |
|
| 1131 | - } |
|
| 1132 | - } |
|
| 1133 | - /* Join the terms, separating them with a comma. */ |
|
| 1134 | - echo(join(', ', $out));
|
|
| 1135 | - } /* If no terms were found, output a default message. */ |
|
| 1136 | - else {
|
|
| 1137 | - _e('No Categories', 'geodirectory');
|
|
| 1138 | - } |
|
| 1139 | - break; |
|
| 1060 | + /** |
|
| 1061 | + * Adds content to our custom post listing page columns. |
|
| 1062 | + * |
|
| 1063 | + * @since 1.0.0 |
|
| 1064 | + * @package GeoDirectory |
|
| 1065 | + * @global object $wpdb WordPress Database object. |
|
| 1066 | + * @global object $post WordPress Post object. |
|
| 1067 | + * @param string $column The column name. |
|
| 1068 | + * @param int $post_id The post ID. |
|
| 1069 | + */ |
|
| 1070 | + function geodir_manage_post_columns($column, $post_id) |
|
| 1071 | + {
|
|
| 1072 | + global $post, $wpdb; |
|
| 1073 | + |
|
| 1074 | + switch ($column): |
|
| 1075 | + /* If displaying the 'city' column. */ |
|
| 1076 | + case 'location' : |
|
| 1077 | + $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
| 1078 | + $location = geodir_get_location($location_id); |
|
| 1079 | + /* If no city is found, output a default message. */ |
|
| 1080 | + if (empty($location)) {
|
|
| 1081 | + _e('Unknown', 'geodirectory');
|
|
| 1082 | + } else {
|
|
| 1083 | + /* If there is a city id, append 'city name' to the text string. */ |
|
| 1084 | + $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
|
|
| 1085 | + echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
| 1086 | + } |
|
| 1087 | + break; |
|
| 1088 | + |
|
| 1089 | + /* If displaying the 'expire' column. */ |
|
| 1090 | + case 'expire' : |
|
| 1091 | + $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
| 1092 | + $d1 = $expire_date; // get expire_date |
|
| 1093 | + $d2 = date('Y-m-d'); // get current date
|
|
| 1094 | + $state = __('days left', 'geodirectory');
|
|
| 1095 | + $date_diff_text = ''; |
|
| 1096 | + $expire_class = 'expire_left'; |
|
| 1097 | + if ($expire_date != 'Never') {
|
|
| 1098 | + if (strtotime($d1) < strtotime($d2)) {
|
|
| 1099 | + $state = __('days overdue', 'geodirectory');
|
|
| 1100 | + $expire_class = 'expire_over'; |
|
| 1101 | + } |
|
| 1102 | + $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the differance in days |
|
| 1103 | + $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
|
| 1104 | + } |
|
| 1105 | + /* If no expire_date is found, output a default message. */ |
|
| 1106 | + if (empty($expire_date)) |
|
| 1107 | + echo __('Unknown', 'geodirectory');
|
|
| 1108 | + /* If there is a expire_date, append 'days left' to the text string. */ |
|
| 1109 | + else |
|
| 1110 | + echo $expire_date . $date_diff_text; |
|
| 1111 | + break; |
|
| 1140 | 1112 | |
| 1141 | - endswitch; |
|
| 1142 | - } |
|
| 1113 | + /* If displaying the 'categorys' column. */ |
|
| 1114 | + case 'categorys' : |
|
| 1115 | + |
|
| 1116 | + /* Get the categorys for the post. */ |
|
| 1117 | + |
|
| 1118 | + |
|
| 1119 | + $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
| 1120 | + |
|
| 1121 | + /* If terms were found. */ |
|
| 1122 | + if (!empty($terms)) {
|
|
| 1123 | + $out = array(); |
|
| 1124 | + /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
| 1125 | + foreach ($terms as $term) {
|
|
| 1126 | + if (!strstr($term->taxonomy, 'tag')) {
|
|
| 1127 | + $out[] = sprintf('<a href="%s">%s</a>',
|
|
| 1128 | + esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
|
|
| 1129 | + esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
|
|
| 1130 | + ); |
|
| 1131 | + } |
|
| 1132 | + } |
|
| 1133 | + /* Join the terms, separating them with a comma. */ |
|
| 1134 | + echo(join(', ', $out));
|
|
| 1135 | + } /* If no terms were found, output a default message. */ |
|
| 1136 | + else {
|
|
| 1137 | + _e('No Categories', 'geodirectory');
|
|
| 1138 | + } |
|
| 1139 | + break; |
|
| 1140 | + |
|
| 1141 | + endswitch; |
|
| 1142 | + } |
|
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | 1145 | |
| 1146 | 1146 | if (!function_exists('geodir_post_sortable_columns')) {
|
| 1147 | - /** |
|
| 1148 | - * Makes admin post listing page columns sortable. |
|
| 1149 | - * |
|
| 1150 | - * @since 1.0.0 |
|
| 1151 | - * @package GeoDirectory |
|
| 1152 | - * @param array $columns The column array. |
|
| 1153 | - * @return array Altered column array. |
|
| 1154 | - */ |
|
| 1155 | - function geodir_post_sortable_columns($columns) |
|
| 1156 | - {
|
|
| 1157 | - |
|
| 1158 | - $columns['expire'] = 'expire'; |
|
| 1159 | - |
|
| 1160 | - return $columns; |
|
| 1161 | - } |
|
| 1147 | + /** |
|
| 1148 | + * Makes admin post listing page columns sortable. |
|
| 1149 | + * |
|
| 1150 | + * @since 1.0.0 |
|
| 1151 | + * @package GeoDirectory |
|
| 1152 | + * @param array $columns The column array. |
|
| 1153 | + * @return array Altered column array. |
|
| 1154 | + */ |
|
| 1155 | + function geodir_post_sortable_columns($columns) |
|
| 1156 | + {
|
|
| 1157 | + |
|
| 1158 | + $columns['expire'] = 'expire'; |
|
| 1159 | + |
|
| 1160 | + return $columns; |
|
| 1161 | + } |
|
| 1162 | 1162 | } |
| 1163 | 1163 | |
| 1164 | 1164 | /** |
@@ -1172,49 +1172,49 @@ discard block |
||
| 1172 | 1172 | * @param int $post_id The post ID. |
| 1173 | 1173 | */ |
| 1174 | 1174 | function geodir_post_information_save($post_id, $post) {
|
| 1175 | - global $wpdb, $current_user; |
|
| 1175 | + global $wpdb, $current_user; |
|
| 1176 | 1176 | |
| 1177 | - if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 1178 | - return; |
|
| 1179 | - } |
|
| 1177 | + if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 1178 | + return; |
|
| 1179 | + } |
|
| 1180 | 1180 | |
| 1181 | - $geodir_posttypes = geodir_get_posttypes(); |
|
| 1181 | + $geodir_posttypes = geodir_get_posttypes(); |
|
| 1182 | 1182 | |
| 1183 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
|
| 1184 | - return; |
|
| 1183 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
|
| 1184 | + return; |
|
| 1185 | 1185 | |
| 1186 | - if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 1187 | - if (isset($_REQUEST['_status'])) |
|
| 1188 | - geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 1186 | + if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 1187 | + if (isset($_REQUEST['_status'])) |
|
| 1188 | + geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 1189 | 1189 | |
| 1190 | - if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
| 1191 | - return; |
|
| 1190 | + if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
| 1191 | + return; |
|
| 1192 | 1192 | |
| 1193 | - if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
| 1194 | - return; |
|
| 1193 | + if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
| 1194 | + return; |
|
| 1195 | 1195 | |
| 1196 | - if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
| 1197 | - return; |
|
| 1196 | + if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
| 1197 | + return; |
|
| 1198 | 1198 | |
| 1199 | - geodir_save_listing($_REQUEST); |
|
| 1200 | - } |
|
| 1199 | + geodir_save_listing($_REQUEST); |
|
| 1200 | + } |
|
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | 1203 | if (!function_exists('geodir_insert_csv_post_data') && get_option('geodir_installed')) {
|
| 1204 | - /** |
|
| 1205 | - * Function to insert csv post data. |
|
| 1206 | - * |
|
| 1207 | - * @since 1.0.0 |
|
| 1208 | - * @package GeoDirectory |
|
| 1209 | - * @global object $wpdb WordPress Database object. |
|
| 1210 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1211 | - */ |
|
| 1212 | - function geodir_insert_csv_post_data() |
|
| 1213 | - {
|
|
| 1214 | - global $wpdb, $plugin_prefix; |
|
| 1215 | - |
|
| 1216 | - $svalue = ''; |
|
| 1217 | - ?> |
|
| 1204 | + /** |
|
| 1205 | + * Function to insert csv post data. |
|
| 1206 | + * |
|
| 1207 | + * @since 1.0.0 |
|
| 1208 | + * @package GeoDirectory |
|
| 1209 | + * @global object $wpdb WordPress Database object. |
|
| 1210 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1211 | + */ |
|
| 1212 | + function geodir_insert_csv_post_data() |
|
| 1213 | + {
|
|
| 1214 | + global $wpdb, $plugin_prefix; |
|
| 1215 | + |
|
| 1216 | + $svalue = ''; |
|
| 1217 | + ?> |
|
| 1218 | 1218 | <script type="text/javascript"> |
| 1219 | 1219 | jQuery(document).ready(function () {
|
| 1220 | 1220 | jQuery("#import_data").click(function () {
|
@@ -1254,50 +1254,50 @@ discard block |
||
| 1254 | 1254 | </script> |
| 1255 | 1255 | <?php |
| 1256 | 1256 | |
| 1257 | - if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] == 'csv_upload_settings') {
|
|
| 1258 | - if (isset($_REQUEST['msg']) && $_REQUEST['msg'] == 'success') {
|
|
| 1259 | - $rowcount = (int)$_REQUEST['rowcount']; |
|
| 1260 | - $uploads = wp_upload_dir(); |
|
| 1261 | - ?> |
|
| 1257 | + if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] == 'csv_upload_settings') {
|
|
| 1258 | + if (isset($_REQUEST['msg']) && $_REQUEST['msg'] == 'success') {
|
|
| 1259 | + $rowcount = (int)$_REQUEST['rowcount']; |
|
| 1260 | + $uploads = wp_upload_dir(); |
|
| 1261 | + ?> |
|
| 1262 | 1262 | <div class="updated fade below-h2" id="message" style="background-color: rgb(255, 251, 204); margin-left:0px; margin-top:0px; margin-bottom:10px;"> |
| 1263 | 1263 | <?php |
| 1264 | - if ($_REQUEST['invalidcount'] == 0 && $_REQUEST['blank_address'] == 0 && $_REQUEST['invalid_post_type'] == 0 && $_REQUEST['invalid_title'] == 0) {
|
|
| 1265 | - echo '<p>' . CSV_INSERT_DATA . '</p>'; |
|
| 1266 | - } |
|
| 1267 | - echo '<p>'; |
|
| 1268 | - printf(CSV_TOTAL_RECORD, $rowcount); |
|
| 1269 | - echo '</p>'; |
|
| 1270 | - |
|
| 1271 | - if (isset($_REQUEST['invalidcount']) && $_REQUEST['invalidcount'] > 0) {
|
|
| 1272 | - echo '<p>'; |
|
| 1273 | - printf(CSV_INVALID_DEFUALT_ADDRESS, (int)$_REQUEST['invalidcount'], (int)$_REQUEST['total_records']); |
|
| 1274 | - echo '</p>'; |
|
| 1275 | - } |
|
| 1264 | + if ($_REQUEST['invalidcount'] == 0 && $_REQUEST['blank_address'] == 0 && $_REQUEST['invalid_post_type'] == 0 && $_REQUEST['invalid_title'] == 0) {
|
|
| 1265 | + echo '<p>' . CSV_INSERT_DATA . '</p>'; |
|
| 1266 | + } |
|
| 1267 | + echo '<p>'; |
|
| 1268 | + printf(CSV_TOTAL_RECORD, $rowcount); |
|
| 1269 | + echo '</p>'; |
|
| 1270 | + |
|
| 1271 | + if (isset($_REQUEST['invalidcount']) && $_REQUEST['invalidcount'] > 0) {
|
|
| 1272 | + echo '<p>'; |
|
| 1273 | + printf(CSV_INVALID_DEFUALT_ADDRESS, (int)$_REQUEST['invalidcount'], (int)$_REQUEST['total_records']); |
|
| 1274 | + echo '</p>'; |
|
| 1275 | + } |
|
| 1276 | 1276 | |
| 1277 | - if (isset($_REQUEST['blank_address']) && $_REQUEST['blank_address'] > 0) {
|
|
| 1278 | - echo '<p>'; |
|
| 1279 | - printf(CSV_INVALID_TOTAL_RECORD, (int)$_REQUEST['blank_address'], (int)$_REQUEST['total_records']); |
|
| 1280 | - echo '</p>'; |
|
| 1281 | - } |
|
| 1277 | + if (isset($_REQUEST['blank_address']) && $_REQUEST['blank_address'] > 0) {
|
|
| 1278 | + echo '<p>'; |
|
| 1279 | + printf(CSV_INVALID_TOTAL_RECORD, (int)$_REQUEST['blank_address'], (int)$_REQUEST['total_records']); |
|
| 1280 | + echo '</p>'; |
|
| 1281 | + } |
|
| 1282 | 1282 | |
| 1283 | - if (isset($_REQUEST['invalid_post_type']) && $_REQUEST['invalid_post_type'] > 0) {
|
|
| 1284 | - echo '<p>'; |
|
| 1285 | - printf(CSV_INVALID_POST_TYPE, (int)$_REQUEST['invalid_post_type'], (int)$_REQUEST['total_records']); |
|
| 1286 | - echo '</p>'; |
|
| 1287 | - } |
|
| 1283 | + if (isset($_REQUEST['invalid_post_type']) && $_REQUEST['invalid_post_type'] > 0) {
|
|
| 1284 | + echo '<p>'; |
|
| 1285 | + printf(CSV_INVALID_POST_TYPE, (int)$_REQUEST['invalid_post_type'], (int)$_REQUEST['total_records']); |
|
| 1286 | + echo '</p>'; |
|
| 1287 | + } |
|
| 1288 | 1288 | |
| 1289 | - if (isset($_REQUEST['invalid_title']) && $_REQUEST['invalid_title'] > 0) {
|
|
| 1290 | - echo '<p>'; |
|
| 1291 | - printf(CSV_BLANK_POST_TITLE, (int)$_REQUEST['invalid_title'], (int)$_REQUEST['total_records']); |
|
| 1292 | - echo '</p>'; |
|
| 1293 | - } |
|
| 1289 | + if (isset($_REQUEST['invalid_title']) && $_REQUEST['invalid_title'] > 0) {
|
|
| 1290 | + echo '<p>'; |
|
| 1291 | + printf(CSV_BLANK_POST_TITLE, (int)$_REQUEST['invalid_title'], (int)$_REQUEST['total_records']); |
|
| 1292 | + echo '</p>'; |
|
| 1293 | + } |
|
| 1294 | 1294 | |
| 1295 | - if (isset($_REQUEST['upload_files']) && $_REQUEST['upload_files'] > 0) {
|
|
| 1296 | - echo '<p>'; |
|
| 1297 | - printf(CSV_TRANSFER_IMG_FOLDER, $uploads['subdir']); |
|
| 1298 | - echo '</p>'; |
|
| 1299 | - } |
|
| 1300 | - ?> |
|
| 1295 | + if (isset($_REQUEST['upload_files']) && $_REQUEST['upload_files'] > 0) {
|
|
| 1296 | + echo '<p>'; |
|
| 1297 | + printf(CSV_TRANSFER_IMG_FOLDER, $uploads['subdir']); |
|
| 1298 | + echo '</p>'; |
|
| 1299 | + } |
|
| 1300 | + ?> |
|
| 1301 | 1301 | </div> |
| 1302 | 1302 | <?php } ?> |
| 1303 | 1303 | <?php if (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'wrong') { ?>
|
@@ -1312,7 +1312,7 @@ discard block |
||
| 1312 | 1312 | <p><?php echo CSV_UPLOAD_ONLY; ?></p> |
| 1313 | 1313 | </div> |
| 1314 | 1314 | <?php } |
| 1315 | - } ?> |
|
| 1315 | + } ?> |
|
| 1316 | 1316 | <?php /* ?> |
| 1317 | 1317 | <table class="form-table"> |
| 1318 | 1318 | <tbody> |
@@ -1350,10 +1350,10 @@ discard block |
||
| 1350 | 1350 | </table> |
| 1351 | 1351 | <?php */ ?> |
| 1352 | 1352 | <?php |
| 1353 | - $id = "gd_import_csv"; |
|
| 1354 | - $multiple = false; // allow multiple files upload |
|
| 1355 | - $uploads = wp_upload_dir(); |
|
| 1356 | - ?> |
|
| 1353 | + $id = "gd_import_csv"; |
|
| 1354 | + $multiple = false; // allow multiple files upload |
|
| 1355 | + $uploads = wp_upload_dir(); |
|
| 1356 | + ?> |
|
| 1357 | 1357 | <style> |
| 1358 | 1358 | .gd-csv-form-table .filelist div.file:last-child {
|
| 1359 | 1359 | display: block !important; |
@@ -1711,12 +1711,12 @@ discard block |
||
| 1711 | 1711 | <br/> |
| 1712 | 1712 | <a href="<?php echo geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'?>"><?php _e("Download sample csv", 'geodirectory')?></a>
|
| 1713 | 1713 | <?php |
| 1714 | - /** |
|
| 1715 | - * Called just after the sample CSV download link. |
|
| 1716 | - * |
|
| 1717 | - * @since 1.0.0 |
|
| 1718 | - */ |
|
| 1719 | - do_action('geodir_sample_csv_download_link'); ?>
|
|
| 1714 | + /** |
|
| 1715 | + * Called just after the sample CSV download link. |
|
| 1716 | + * |
|
| 1717 | + * @since 1.0.0 |
|
| 1718 | + */ |
|
| 1719 | + do_action('geodir_sample_csv_download_link'); ?>
|
|
| 1720 | 1720 | <span class="ajaxnonceplu" |
| 1721 | 1721 | id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?>"></span><br/> |
| 1722 | 1722 | <br/> |
@@ -1775,362 +1775,362 @@ discard block |
||
| 1775 | 1775 | } |
| 1776 | 1776 | |
| 1777 | 1777 | if (!function_exists('geodir_import_data')) {
|
| 1778 | - /** |
|
| 1779 | - * Imports data from csv file. |
|
| 1780 | - * |
|
| 1781 | - * @since 1.0.0 |
|
| 1782 | - * @package GeoDirectory |
|
| 1783 | - * @global object $wpdb WordPress Database object. |
|
| 1784 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1785 | - * @global object $current_user Current user object. |
|
| 1786 | - */ |
|
| 1787 | - function geodir_import_data() |
|
| 1788 | - {
|
|
| 1778 | + /** |
|
| 1779 | + * Imports data from csv file. |
|
| 1780 | + * |
|
| 1781 | + * @since 1.0.0 |
|
| 1782 | + * @package GeoDirectory |
|
| 1783 | + * @global object $wpdb WordPress Database object. |
|
| 1784 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1785 | + * @global object $current_user Current user object. |
|
| 1786 | + */ |
|
| 1787 | + function geodir_import_data() |
|
| 1788 | + {
|
|
| 1789 | 1789 | |
| 1790 | - global $wpdb, $plugin_prefix, $current_user; |
|
| 1790 | + global $wpdb, $plugin_prefix, $current_user; |
|
| 1791 | 1791 | |
| 1792 | - if (isset($_REQUEST['geodir_import_data']) && !empty($_REQUEST['geodir_import_data'])) {
|
|
| 1793 | - $uploads = wp_upload_dir(); |
|
| 1794 | - $uploads_dir = $uploads['path']; |
|
| 1792 | + if (isset($_REQUEST['geodir_import_data']) && !empty($_REQUEST['geodir_import_data'])) {
|
|
| 1793 | + $uploads = wp_upload_dir(); |
|
| 1794 | + $uploads_dir = $uploads['path']; |
|
| 1795 | 1795 | |
| 1796 | - $curr_img_url = $_REQUEST['filename']; |
|
| 1796 | + $curr_img_url = $_REQUEST['filename']; |
|
| 1797 | 1797 | |
| 1798 | - $image_name_arr = explode('/', $curr_img_url);
|
|
| 1798 | + $image_name_arr = explode('/', $curr_img_url);
|
|
| 1799 | 1799 | |
| 1800 | - $filename = end($image_name_arr); |
|
| 1800 | + $filename = end($image_name_arr); |
|
| 1801 | 1801 | |
| 1802 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1802 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1803 | 1803 | |
| 1804 | - $destination_path = $uploads_dir . '/temp_' . $current_user->data->ID; |
|
| 1804 | + $destination_path = $uploads_dir . '/temp_' . $current_user->data->ID; |
|
| 1805 | 1805 | |
| 1806 | - $csv_target_path = $target_path; |
|
| 1806 | + $csv_target_path = $target_path; |
|
| 1807 | 1807 | |
| 1808 | - ini_set('auto_detect_line_endings', true);
|
|
| 1808 | + ini_set('auto_detect_line_endings', true);
|
|
| 1809 | 1809 | |
| 1810 | - $fd = fopen($target_path, "rt"); |
|
| 1810 | + $fd = fopen($target_path, "rt"); |
|
| 1811 | 1811 | |
| 1812 | - $total_records = 0; |
|
| 1813 | - $rowcount = 0; |
|
| 1814 | - $address_invalid = 0; |
|
| 1815 | - $blank_address = 0; |
|
| 1816 | - $upload_files = 0; |
|
| 1817 | - $invalid_post_type = 0; |
|
| 1818 | - $invalid_title = 0; |
|
| 1812 | + $total_records = 0; |
|
| 1813 | + $rowcount = 0; |
|
| 1814 | + $address_invalid = 0; |
|
| 1815 | + $blank_address = 0; |
|
| 1816 | + $upload_files = 0; |
|
| 1817 | + $invalid_post_type = 0; |
|
| 1818 | + $invalid_title = 0; |
|
| 1819 | 1819 | |
| 1820 | - $customKeyarray = array(); |
|
| 1820 | + $customKeyarray = array(); |
|
| 1821 | 1821 | |
| 1822 | - $gd_post_info = array(); |
|
| 1822 | + $gd_post_info = array(); |
|
| 1823 | 1823 | |
| 1824 | - $post_location = array(); |
|
| 1825 | - $countpost = 0; |
|
| 1824 | + $post_location = array(); |
|
| 1825 | + $countpost = 0; |
|
| 1826 | 1826 | |
| 1827 | - $uploaded_file_type = pathinfo($filename, PATHINFO_EXTENSION); |
|
| 1827 | + $uploaded_file_type = pathinfo($filename, PATHINFO_EXTENSION); |
|
| 1828 | 1828 | |
| 1829 | - $extensionarr = array('csv', 'CSV');
|
|
| 1829 | + $extensionarr = array('csv', 'CSV');
|
|
| 1830 | 1830 | |
| 1831 | - if (in_array($uploaded_file_type, $extensionarr)) {
|
|
| 1831 | + if (in_array($uploaded_file_type, $extensionarr)) {
|
|
| 1832 | 1832 | |
| 1833 | - while (!feof($fd)) {
|
|
| 1834 | - $buffer = fgetcsv($fd, 40960); |
|
| 1833 | + while (!feof($fd)) {
|
|
| 1834 | + $buffer = fgetcsv($fd, 40960); |
|
| 1835 | 1835 | |
| 1836 | - if ($rowcount == 0) {
|
|
| 1837 | - for ($k = 0; $k < count($buffer); $k++) {
|
|
| 1838 | - $customKeyarray[$k] = $buffer[$k]; |
|
| 1839 | - } |
|
| 1836 | + if ($rowcount == 0) {
|
|
| 1837 | + for ($k = 0; $k < count($buffer); $k++) {
|
|
| 1838 | + $customKeyarray[$k] = $buffer[$k]; |
|
| 1839 | + } |
|
| 1840 | 1840 | |
| 1841 | - if ($customKeyarray[0] == '') {
|
|
| 1842 | - echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&emsg=wrong'; |
|
| 1843 | - exit; |
|
| 1844 | - } |
|
| 1845 | - } elseif (!empty($buffer)) {
|
|
| 1846 | - |
|
| 1847 | - $total_records++; |
|
| 1848 | - |
|
| 1849 | - $post_title = addslashes($buffer[0]); |
|
| 1850 | - $current_post_author = $buffer[1]; |
|
| 1851 | - $post_desc = addslashes($buffer[2]); |
|
| 1852 | - $post_cat = array(); |
|
| 1853 | - $catids_arr = array(); |
|
| 1854 | - $post_cat = trim($buffer[3]); // comma seperated category name |
|
| 1855 | - |
|
| 1856 | - if ($post_cat) {
|
|
| 1857 | - $post_cat_arr = explode(',', $post_cat);
|
|
| 1858 | - |
|
| 1859 | - for ($c = 0; $c < count($post_cat_arr); $c++) {
|
|
| 1860 | - $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); |
|
| 1861 | - if (!empty($buffer[5])) {
|
|
| 1862 | - if (in_array($buffer[5], geodir_get_posttypes())) {
|
|
| 1863 | - $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); |
|
| 1864 | - if (get_term_by('name', $catid, $p_taxonomy[0])) {
|
|
| 1865 | - $cat = get_term_by('name', $catid, $p_taxonomy[0]);
|
|
| 1866 | - $catids_arr[] = $cat->slug; |
|
| 1867 | - } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
|
|
| 1868 | - $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
|
|
| 1869 | - $catids_arr[] = $cat->slug; |
|
| 1870 | - } |
|
| 1871 | - } |
|
| 1872 | - } |
|
| 1873 | - } |
|
| 1874 | - } |
|
| 1841 | + if ($customKeyarray[0] == '') {
|
|
| 1842 | + echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&emsg=wrong'; |
|
| 1843 | + exit; |
|
| 1844 | + } |
|
| 1845 | + } elseif (!empty($buffer)) {
|
|
| 1846 | + |
|
| 1847 | + $total_records++; |
|
| 1848 | + |
|
| 1849 | + $post_title = addslashes($buffer[0]); |
|
| 1850 | + $current_post_author = $buffer[1]; |
|
| 1851 | + $post_desc = addslashes($buffer[2]); |
|
| 1852 | + $post_cat = array(); |
|
| 1853 | + $catids_arr = array(); |
|
| 1854 | + $post_cat = trim($buffer[3]); // comma seperated category name |
|
| 1855 | + |
|
| 1856 | + if ($post_cat) {
|
|
| 1857 | + $post_cat_arr = explode(',', $post_cat);
|
|
| 1858 | + |
|
| 1859 | + for ($c = 0; $c < count($post_cat_arr); $c++) {
|
|
| 1860 | + $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); |
|
| 1861 | + if (!empty($buffer[5])) {
|
|
| 1862 | + if (in_array($buffer[5], geodir_get_posttypes())) {
|
|
| 1863 | + $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); |
|
| 1864 | + if (get_term_by('name', $catid, $p_taxonomy[0])) {
|
|
| 1865 | + $cat = get_term_by('name', $catid, $p_taxonomy[0]);
|
|
| 1866 | + $catids_arr[] = $cat->slug; |
|
| 1867 | + } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
|
|
| 1868 | + $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
|
|
| 1869 | + $catids_arr[] = $cat->slug; |
|
| 1870 | + } |
|
| 1871 | + } |
|
| 1872 | + } |
|
| 1873 | + } |
|
| 1874 | + } |
|
| 1875 | 1875 | |
| 1876 | - if (!$catids_arr) {
|
|
| 1877 | - $catids_arr[] = 1; |
|
| 1878 | - } |
|
| 1876 | + if (!$catids_arr) {
|
|
| 1877 | + $catids_arr[] = 1; |
|
| 1878 | + } |
|
| 1879 | 1879 | |
| 1880 | - $post_tags = trim($buffer[4]); // comma seperated tags |
|
| 1880 | + $post_tags = trim($buffer[4]); // comma seperated tags |
|
| 1881 | 1881 | |
| 1882 | - $tag_arr = ''; |
|
| 1883 | - if ($post_tags) {
|
|
| 1882 | + $tag_arr = ''; |
|
| 1883 | + if ($post_tags) {
|
|
| 1884 | 1884 | |
| 1885 | - $tag_arr = explode(',', $post_tags);
|
|
| 1886 | - } |
|
| 1885 | + $tag_arr = explode(',', $post_tags);
|
|
| 1886 | + } |
|
| 1887 | 1887 | |
| 1888 | - $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database |
|
| 1888 | + $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database |
|
| 1889 | 1889 | |
| 1890 | - $error = ''; |
|
| 1891 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
|
|
| 1890 | + $error = ''; |
|
| 1891 | + if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
|
|
| 1892 | 1892 | |
| 1893 | - $invalid_post_type++; |
|
| 1894 | - continue; |
|
| 1893 | + $invalid_post_type++; |
|
| 1894 | + continue; |
|
| 1895 | 1895 | |
| 1896 | - } |
|
| 1896 | + } |
|
| 1897 | 1897 | |
| 1898 | - if ($post_title != '') {
|
|
| 1898 | + if ($post_title != '') {
|
|
| 1899 | 1899 | |
| 1900 | - $menu_order = 0; |
|
| 1900 | + $menu_order = 0; |
|
| 1901 | 1901 | |
| 1902 | - $image_folder_name = 'uplaod/'; |
|
| 1902 | + $image_folder_name = 'uplaod/'; |
|
| 1903 | 1903 | |
| 1904 | - $image_names = array(); |
|
| 1904 | + $image_names = array(); |
|
| 1905 | 1905 | |
| 1906 | - for ($c = 5; $c < count($customKeyarray); $c++) {
|
|
| 1907 | - $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); |
|
| 1906 | + for ($c = 5; $c < count($customKeyarray); $c++) {
|
|
| 1907 | + $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); |
|
| 1908 | 1908 | |
| 1909 | - if ($customKeyarray[$c] == 'IMAGE') {
|
|
| 1910 | - $buffer[$c] = trim($buffer[$c]); |
|
| 1911 | - if (!empty($buffer[$c])) {
|
|
| 1912 | - $image_names[] = $buffer[$c]; |
|
| 1913 | - } |
|
| 1909 | + if ($customKeyarray[$c] == 'IMAGE') {
|
|
| 1910 | + $buffer[$c] = trim($buffer[$c]); |
|
| 1911 | + if (!empty($buffer[$c])) {
|
|
| 1912 | + $image_names[] = $buffer[$c]; |
|
| 1913 | + } |
|
| 1914 | 1914 | |
| 1915 | - } |
|
| 1915 | + } |
|
| 1916 | 1916 | |
| 1917 | - if ($customKeyarray[$c] == 'alive_days') {
|
|
| 1918 | - if ($buffer[$c] != '0' && $buffer[$c] != '') {
|
|
| 1919 | - $submitdata = date('Y-m-d');
|
|
| 1920 | - $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
|
|
| 1921 | - } else {
|
|
| 1922 | - $gd_post_info['expire_date'] = 'Never'; |
|
| 1923 | - } |
|
| 1924 | - } |
|
| 1917 | + if ($customKeyarray[$c] == 'alive_days') {
|
|
| 1918 | + if ($buffer[$c] != '0' && $buffer[$c] != '') {
|
|
| 1919 | + $submitdata = date('Y-m-d');
|
|
| 1920 | + $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
|
|
| 1921 | + } else {
|
|
| 1922 | + $gd_post_info['expire_date'] = 'Never'; |
|
| 1923 | + } |
|
| 1924 | + } |
|
| 1925 | 1925 | |
| 1926 | 1926 | |
| 1927 | - if ($customKeyarray[$c] == 'post_city') {
|
|
| 1928 | - $post_city = addslashes($buffer[$c]); |
|
| 1929 | - } |
|
| 1927 | + if ($customKeyarray[$c] == 'post_city') {
|
|
| 1928 | + $post_city = addslashes($buffer[$c]); |
|
| 1929 | + } |
|
| 1930 | 1930 | |
| 1931 | - if ($customKeyarray[$c] == 'post_region') {
|
|
| 1932 | - $post_region = addslashes($buffer[$c]); |
|
| 1933 | - } |
|
| 1931 | + if ($customKeyarray[$c] == 'post_region') {
|
|
| 1932 | + $post_region = addslashes($buffer[$c]); |
|
| 1933 | + } |
|
| 1934 | 1934 | |
| 1935 | - if ($customKeyarray[$c] == 'post_country') {
|
|
| 1936 | - $post_country = addslashes($buffer[$c]); |
|
| 1937 | - } |
|
| 1935 | + if ($customKeyarray[$c] == 'post_country') {
|
|
| 1936 | + $post_country = addslashes($buffer[$c]); |
|
| 1937 | + } |
|
| 1938 | 1938 | |
| 1939 | - if ($customKeyarray[$c] == 'post_latitude') {
|
|
| 1940 | - $post_latitude = addslashes($buffer[$c]); |
|
| 1941 | - } |
|
| 1939 | + if ($customKeyarray[$c] == 'post_latitude') {
|
|
| 1940 | + $post_latitude = addslashes($buffer[$c]); |
|
| 1941 | + } |
|
| 1942 | 1942 | |
| 1943 | - if ($customKeyarray[$c] == 'post_longitude') {
|
|
| 1944 | - $post_longitude = addslashes($buffer[$c]); |
|
| 1945 | - } |
|
| 1943 | + if ($customKeyarray[$c] == 'post_longitude') {
|
|
| 1944 | + $post_longitude = addslashes($buffer[$c]); |
|
| 1945 | + } |
|
| 1946 | 1946 | |
| 1947 | - } |
|
| 1947 | + } |
|
| 1948 | 1948 | |
| 1949 | - /* ================ before array create ============== */ |
|
| 1949 | + /* ================ before array create ============== */ |
|
| 1950 | 1950 | |
| 1951 | - $location_result = geodir_get_default_location(); |
|
| 1951 | + $location_result = geodir_get_default_location(); |
|
| 1952 | 1952 | |
| 1953 | - 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'] == '')) {
|
|
| 1953 | + 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'] == '')) {
|
|
| 1954 | 1954 | |
| 1955 | - $blank_address++; |
|
| 1956 | - continue; |
|
| 1955 | + $blank_address++; |
|
| 1956 | + continue; |
|
| 1957 | 1957 | |
| 1958 | - } elseif ($location_result->location_id == 0) {
|
|
| 1958 | + } elseif ($location_result->location_id == 0) {
|
|
| 1959 | 1959 | |
| 1960 | - if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || |
|
| 1961 | - (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || |
|
| 1962 | - (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country)) |
|
| 1963 | - ) {
|
|
| 1960 | + if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || |
|
| 1961 | + (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || |
|
| 1962 | + (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country)) |
|
| 1963 | + ) {
|
|
| 1964 | 1964 | |
| 1965 | - $address_invalid++; |
|
| 1966 | - continue; |
|
| 1965 | + $address_invalid++; |
|
| 1966 | + continue; |
|
| 1967 | 1967 | |
| 1968 | - } |
|
| 1968 | + } |
|
| 1969 | 1969 | |
| 1970 | - } |
|
| 1970 | + } |
|
| 1971 | 1971 | |
| 1972 | 1972 | |
| 1973 | - $my_post['post_title'] = $post_title; |
|
| 1974 | - $my_post['post_content'] = $post_desc; |
|
| 1975 | - $my_post['post_type'] = addslashes($buffer[5]); |
|
| 1976 | - $my_post['post_author'] = $current_post_author; |
|
| 1977 | - $my_post['post_status'] = 'publish'; |
|
| 1978 | - $my_post['post_category'] = $catids_arr; |
|
| 1979 | - $my_post['post_tags'] = $tag_arr; |
|
| 1973 | + $my_post['post_title'] = $post_title; |
|
| 1974 | + $my_post['post_content'] = $post_desc; |
|
| 1975 | + $my_post['post_type'] = addslashes($buffer[5]); |
|
| 1976 | + $my_post['post_author'] = $current_post_author; |
|
| 1977 | + $my_post['post_status'] = 'publish'; |
|
| 1978 | + $my_post['post_category'] = $catids_arr; |
|
| 1979 | + $my_post['post_tags'] = $tag_arr; |
|
| 1980 | 1980 | |
| 1981 | 1981 | |
| 1982 | - $gd_post_info['post_tags'] = $tag_arr; |
|
| 1983 | - $gd_post_info['post_title'] = $post_title; |
|
| 1984 | - $gd_post_info['post_status'] = 'publish'; |
|
| 1985 | - $gd_post_info['submit_time'] = time(); |
|
| 1986 | - $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 1982 | + $gd_post_info['post_tags'] = $tag_arr; |
|
| 1983 | + $gd_post_info['post_title'] = $post_title; |
|
| 1984 | + $gd_post_info['post_status'] = 'publish'; |
|
| 1985 | + $gd_post_info['submit_time'] = time(); |
|
| 1986 | + $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 1987 | 1987 | |
| 1988 | 1988 | |
| 1989 | - $last_postid = wp_insert_post($my_post); |
|
| 1990 | - $countpost++; |
|
| 1989 | + $last_postid = wp_insert_post($my_post); |
|
| 1990 | + $countpost++; |
|
| 1991 | 1991 | |
| 1992 | 1992 | |
| 1993 | - // Check if we need to save post location as new location |
|
| 1993 | + // Check if we need to save post location as new location |
|
| 1994 | 1994 | |
| 1995 | - if ($location_result->location_id > 0) {
|
|
| 1996 | - if (isset($post_city) && isset($post_region)) {
|
|
| 1995 | + if ($location_result->location_id > 0) {
|
|
| 1996 | + if (isset($post_city) && isset($post_region)) {
|
|
| 1997 | 1997 | |
| 1998 | - $request_info['post_location'] = array('city' => $post_city,
|
|
| 1999 | - 'region' => $post_region, |
|
| 2000 | - 'country' => $post_country, |
|
| 2001 | - 'geo_lat' => $post_latitude, |
|
| 2002 | - 'geo_lng' => $post_longitude); |
|
| 1998 | + $request_info['post_location'] = array('city' => $post_city,
|
|
| 1999 | + 'region' => $post_region, |
|
| 2000 | + 'country' => $post_country, |
|
| 2001 | + 'geo_lat' => $post_latitude, |
|
| 2002 | + 'geo_lng' => $post_longitude); |
|
| 2003 | 2003 | |
| 2004 | - $post_location_info = $request_info['post_location']; |
|
| 2005 | - if ($location_id = geodir_add_new_location($post_location_info)) |
|
| 2006 | - $post_location_id = $location_id; |
|
| 2004 | + $post_location_info = $request_info['post_location']; |
|
| 2005 | + if ($location_id = geodir_add_new_location($post_location_info)) |
|
| 2006 | + $post_location_id = $location_id; |
|
| 2007 | 2007 | |
| 2008 | - } else {
|
|
| 2009 | - $post_location_id = 0; |
|
| 2010 | - } |
|
| 2011 | - } else {
|
|
| 2012 | - $post_location_id = 0; |
|
| 2013 | - } |
|
| 2008 | + } else {
|
|
| 2009 | + $post_location_id = 0; |
|
| 2010 | + } |
|
| 2011 | + } else {
|
|
| 2012 | + $post_location_id = 0; |
|
| 2013 | + } |
|
| 2014 | 2014 | |
| 2015 | - /* ------- get default package info ----- */ |
|
| 2016 | - $payment_info = array(); |
|
| 2017 | - $package_info = array(); |
|
| 2015 | + /* ------- get default package info ----- */ |
|
| 2016 | + $payment_info = array(); |
|
| 2017 | + $package_info = array(); |
|
| 2018 | 2018 | |
| 2019 | - $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
| 2020 | - $package_id = ''; |
|
| 2021 | - if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
|
|
| 2022 | - $package_id = $gd_post_info['package_id']; |
|
| 2023 | - } |
|
| 2019 | + $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
| 2020 | + $package_id = ''; |
|
| 2021 | + if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
|
|
| 2022 | + $package_id = $gd_post_info['package_id']; |
|
| 2023 | + } |
|
| 2024 | 2024 | |
| 2025 | - if (!empty($package_info)) {
|
|
| 2026 | - $payment_info['package_id'] = $package_info['pid']; |
|
| 2027 | - if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
|
|
| 2028 | - $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
|
|
| 2029 | - } else {
|
|
| 2030 | - $payment_info['expire_date'] = 'Never'; |
|
| 2031 | - } |
|
| 2025 | + if (!empty($package_info)) {
|
|
| 2026 | + $payment_info['package_id'] = $package_info['pid']; |
|
| 2027 | + if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
|
|
| 2028 | + $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
|
|
| 2029 | + } else {
|
|
| 2030 | + $payment_info['expire_date'] = 'Never'; |
|
| 2031 | + } |
|
| 2032 | 2032 | |
| 2033 | - $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
| 2034 | - } |
|
| 2033 | + $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
| 2034 | + } |
|
| 2035 | 2035 | |
| 2036 | 2036 | |
| 2037 | - $gd_post_info['post_location_id'] = $post_location_id; |
|
| 2037 | + $gd_post_info['post_location_id'] = $post_location_id; |
|
| 2038 | 2038 | |
| 2039 | - $post_type = get_post_type($last_postid); |
|
| 2039 | + $post_type = get_post_type($last_postid); |
|
| 2040 | 2040 | |
| 2041 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2041 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2042 | 2042 | |
| 2043 | - geodir_save_post_info($last_postid, $gd_post_info); |
|
| 2043 | + geodir_save_post_info($last_postid, $gd_post_info); |
|
| 2044 | 2044 | |
| 2045 | - if (!empty($image_names)) {
|
|
| 2046 | - $upload_files++; |
|
| 2047 | - $menu_order = 1; |
|
| 2048 | - foreach ($image_names as $image_name) {
|
|
| 2045 | + if (!empty($image_names)) {
|
|
| 2046 | + $upload_files++; |
|
| 2047 | + $menu_order = 1; |
|
| 2048 | + foreach ($image_names as $image_name) {
|
|
| 2049 | 2049 | |
| 2050 | - $img_name_arr = explode('.', $image_name);
|
|
| 2050 | + $img_name_arr = explode('.', $image_name);
|
|
| 2051 | 2051 | |
| 2052 | - $uploads = wp_upload_dir(); |
|
| 2053 | - $sub_dir = $uploads['subdir']; |
|
| 2052 | + $uploads = wp_upload_dir(); |
|
| 2053 | + $sub_dir = $uploads['subdir']; |
|
| 2054 | 2054 | |
| 2055 | - $arr_file_type = wp_check_filetype($image_name); |
|
| 2056 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 2055 | + $arr_file_type = wp_check_filetype($image_name); |
|
| 2056 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 2057 | 2057 | |
| 2058 | - $attachment = array(); |
|
| 2059 | - $attachment['post_id'] = $last_postid; |
|
| 2060 | - $attachment['title'] = $img_name_arr[0]; |
|
| 2061 | - $attachment['content'] = ''; |
|
| 2062 | - $attachment['file'] = $sub_dir . '/' . $image_name; |
|
| 2063 | - $attachment['mime_type'] = $uploaded_file_type; |
|
| 2064 | - $attachment['menu_order'] = $menu_order; |
|
| 2065 | - $attachment['is_featured'] = 0; |
|
| 2058 | + $attachment = array(); |
|
| 2059 | + $attachment['post_id'] = $last_postid; |
|
| 2060 | + $attachment['title'] = $img_name_arr[0]; |
|
| 2061 | + $attachment['content'] = ''; |
|
| 2062 | + $attachment['file'] = $sub_dir . '/' . $image_name; |
|
| 2063 | + $attachment['mime_type'] = $uploaded_file_type; |
|
| 2064 | + $attachment['menu_order'] = $menu_order; |
|
| 2065 | + $attachment['is_featured'] = 0; |
|
| 2066 | 2066 | |
| 2067 | - $attachment_set = ''; |
|
| 2067 | + $attachment_set = ''; |
|
| 2068 | 2068 | |
| 2069 | - foreach ($attachment as $key => $val) {
|
|
| 2070 | - if ($val != '') |
|
| 2071 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 2072 | - } |
|
| 2069 | + foreach ($attachment as $key => $val) {
|
|
| 2070 | + if ($val != '') |
|
| 2071 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 2072 | + } |
|
| 2073 | 2073 | |
| 2074 | - $attachment_set = trim($attachment_set, ", "); |
|
| 2074 | + $attachment_set = trim($attachment_set, ", "); |
|
| 2075 | 2075 | |
| 2076 | - $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 2076 | + $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 2077 | 2077 | |
| 2078 | - if ($menu_order == 1) {
|
|
| 2078 | + if ($menu_order == 1) {
|
|
| 2079 | 2079 | |
| 2080 | - $post_type = get_post_type($last_postid); |
|
| 2080 | + $post_type = get_post_type($last_postid); |
|
| 2081 | 2081 | |
| 2082 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
|
|
| 2082 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
|
|
| 2083 | 2083 | |
| 2084 | - } |
|
| 2084 | + } |
|
| 2085 | 2085 | |
| 2086 | - $menu_order++; |
|
| 2087 | - } |
|
| 2088 | - } |
|
| 2086 | + $menu_order++; |
|
| 2087 | + } |
|
| 2088 | + } |
|
| 2089 | 2089 | |
| 2090 | - $gd_post_info['package_id'] = $package_id; |
|
| 2090 | + $gd_post_info['package_id'] = $package_id; |
|
| 2091 | 2091 | |
| 2092 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 2093 | - do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
|
|
| 2092 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 2093 | + do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
|
|
| 2094 | 2094 | |
| 2095 | - if (!empty($buffer[5])) {
|
|
| 2096 | - if (in_array($buffer[5], geodir_get_posttypes())) {
|
|
| 2095 | + if (!empty($buffer[5])) {
|
|
| 2096 | + if (in_array($buffer[5], geodir_get_posttypes())) {
|
|
| 2097 | 2097 | |
| 2098 | - $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); |
|
| 2099 | - wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); |
|
| 2100 | - wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); |
|
| 2098 | + $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); |
|
| 2099 | + wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); |
|
| 2100 | + wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); |
|
| 2101 | 2101 | |
| 2102 | 2102 | |
| 2103 | - $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; |
|
| 2103 | + $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; |
|
| 2104 | 2104 | |
| 2105 | - $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; |
|
| 2106 | - geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); |
|
| 2105 | + $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; |
|
| 2106 | + geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); |
|
| 2107 | 2107 | |
| 2108 | - } |
|
| 2108 | + } |
|
| 2109 | 2109 | |
| 2110 | - } |
|
| 2110 | + } |
|
| 2111 | + |
|
| 2112 | + } else {
|
|
| 2113 | + $invalid_title++; |
|
| 2114 | + } |
|
| 2115 | + } |
|
| 2116 | + $rowcount++; |
|
| 2117 | + } |
|
| 2118 | + fclose($fd); |
|
| 2119 | + //unlink($csv_target_path); |
|
| 2120 | + //rmdir($destination_path); |
|
| 2121 | + if (!empty($filename)) |
|
| 2122 | + geodir_remove_temp_images(); |
|
| 2111 | 2123 | |
| 2112 | - } else {
|
|
| 2113 | - $invalid_title++; |
|
| 2114 | - } |
|
| 2115 | - } |
|
| 2116 | - $rowcount++; |
|
| 2117 | - } |
|
| 2118 | - fclose($fd); |
|
| 2119 | - //unlink($csv_target_path); |
|
| 2120 | - //rmdir($destination_path); |
|
| 2121 | - if (!empty($filename)) |
|
| 2122 | - geodir_remove_temp_images(); |
|
| 2123 | - |
|
| 2124 | - |
|
| 2125 | - echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&msg=success&rowcount=' . $countpost . '&invalidcount=' . $address_invalid . '&blank_address=' . $blank_address . '&upload_files=' . $upload_files . '&invalid_post_type=' . $invalid_post_type . '&invalid_title=' . $invalid_title . '&total_records=' . $total_records; |
|
| 2126 | - exit; |
|
| 2127 | - } else {
|
|
| 2128 | - echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&emsg=csvonly'; |
|
| 2129 | - exit; |
|
| 2130 | - } |
|
| 2131 | - } |
|
| 2132 | 2124 | |
| 2133 | - } |
|
| 2125 | + echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&msg=success&rowcount=' . $countpost . '&invalidcount=' . $address_invalid . '&blank_address=' . $blank_address . '&upload_files=' . $upload_files . '&invalid_post_type=' . $invalid_post_type . '&invalid_title=' . $invalid_title . '&total_records=' . $total_records; |
|
| 2126 | + exit; |
|
| 2127 | + } else {
|
|
| 2128 | + echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&emsg=csvonly'; |
|
| 2129 | + exit; |
|
| 2130 | + } |
|
| 2131 | + } |
|
| 2132 | + |
|
| 2133 | + } |
|
| 2134 | 2134 | } |
| 2135 | 2135 | |
| 2136 | 2136 | /** |
@@ -2146,105 +2146,105 @@ discard block |
||
| 2146 | 2146 | */ |
| 2147 | 2147 | function geodir_admin_fields($options) |
| 2148 | 2148 | {
|
| 2149 | - global $geodirectory; |
|
| 2150 | - |
|
| 2151 | - $first_title = true; |
|
| 2152 | - $tab_id = ''; |
|
| 2153 | - $i = 0; |
|
| 2154 | - foreach ($options as $value) : |
|
| 2155 | - if (!isset($value['name'])) $value['name'] = ''; |
|
| 2156 | - if (!isset($value['class'])) $value['class'] = ''; |
|
| 2157 | - if (!isset($value['css'])) $value['css'] = ''; |
|
| 2158 | - if (!isset($value['std'])) $value['std'] = ''; |
|
| 2159 | - $desc = ''; |
|
| 2160 | - switch ($value['type']) : |
|
| 2161 | - case 'dummy_installer': |
|
| 2162 | - $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
| 2163 | - geodir_autoinstall_admin_header($post_type); |
|
| 2164 | - break; |
|
| 2165 | - case 'csv_installer': |
|
| 2166 | - geodir_insert_csv_post_data(); |
|
| 2167 | - break; |
|
| 2168 | - case 'title': |
|
| 2169 | - |
|
| 2170 | - if ($i == 0) {
|
|
| 2171 | - echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
| 2172 | - echo '<div class="inner_content_tab_main">'; |
|
| 2173 | - } |
|
| 2149 | + global $geodirectory; |
|
| 2150 | + |
|
| 2151 | + $first_title = true; |
|
| 2152 | + $tab_id = ''; |
|
| 2153 | + $i = 0; |
|
| 2154 | + foreach ($options as $value) : |
|
| 2155 | + if (!isset($value['name'])) $value['name'] = ''; |
|
| 2156 | + if (!isset($value['class'])) $value['class'] = ''; |
|
| 2157 | + if (!isset($value['css'])) $value['css'] = ''; |
|
| 2158 | + if (!isset($value['std'])) $value['std'] = ''; |
|
| 2159 | + $desc = ''; |
|
| 2160 | + switch ($value['type']) : |
|
| 2161 | + case 'dummy_installer': |
|
| 2162 | + $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
| 2163 | + geodir_autoinstall_admin_header($post_type); |
|
| 2164 | + break; |
|
| 2165 | + case 'csv_installer': |
|
| 2166 | + geodir_insert_csv_post_data(); |
|
| 2167 | + break; |
|
| 2168 | + case 'title': |
|
| 2169 | + |
|
| 2170 | + if ($i == 0) {
|
|
| 2171 | + echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
| 2172 | + echo '<div class="inner_content_tab_main">'; |
|
| 2173 | + } |
|
| 2174 | 2174 | |
| 2175 | - $i++; |
|
| 2175 | + $i++; |
|
| 2176 | 2176 | |
| 2177 | - if (isset($value['id']) && $value['id']) |
|
| 2178 | - $tab_id = $value['id']; |
|
| 2177 | + if (isset($value['id']) && $value['id']) |
|
| 2178 | + $tab_id = $value['id']; |
|
| 2179 | 2179 | |
| 2180 | - if (isset($value['desc']) && $value['desc']) |
|
| 2181 | - $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 2180 | + if (isset($value['desc']) && $value['desc']) |
|
| 2181 | + $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 2182 | 2182 | |
| 2183 | - if (isset($value['name']) && $value['name']) {
|
|
| 2184 | - if ($first_title === true) {
|
|
| 2185 | - $first_title = false; |
|
| 2186 | - } else {
|
|
| 2187 | - echo '</div>'; |
|
| 2188 | - } |
|
| 2189 | - echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
| 2183 | + if (isset($value['name']) && $value['name']) {
|
|
| 2184 | + if ($first_title === true) {
|
|
| 2185 | + $first_title = false; |
|
| 2186 | + } else {
|
|
| 2187 | + echo '</div>'; |
|
| 2188 | + } |
|
| 2189 | + echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
| 2190 | 2190 | |
| 2191 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 2192 | - } |
|
| 2191 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 2192 | + } |
|
| 2193 | 2193 | |
| 2194 | - /** |
|
| 2195 | - * Called after a GeoDirectory settings title is output in the GD settings page. |
|
| 2196 | - * |
|
| 2197 | - * The action is called dynamically geodir_settings_$value['id']. |
|
| 2198 | - * |
|
| 2199 | - * @since 1.0.0 |
|
| 2200 | - */ |
|
| 2201 | - do_action('geodir_settings_' . sanitize_title($value['id']));
|
|
| 2202 | - break; |
|
| 2203 | - |
|
| 2204 | - case 'no_tabs': |
|
| 2205 | - |
|
| 2206 | - echo '<div class="inner_content_tab_main">'; |
|
| 2207 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 2208 | - |
|
| 2209 | - break; |
|
| 2210 | - |
|
| 2211 | - case 'sectionstart': |
|
| 2212 | - if (isset($value['desc']) && $value['desc']) |
|
| 2213 | - $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 2214 | - if (isset($value['name']) && $value['name']) |
|
| 2215 | - echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 2216 | - /** |
|
| 2217 | - * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
| 2218 | - * |
|
| 2219 | - * The action is called dynamically geodir_settings_$value['id']_start. |
|
| 2220 | - * |
|
| 2221 | - * @since 1.0.0 |
|
| 2222 | - */ |
|
| 2223 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 2224 | - echo '<table class="form-table">' . "\n\n"; |
|
| 2225 | - |
|
| 2226 | - break; |
|
| 2227 | - case 'sectionend': |
|
| 2228 | - /** |
|
| 2229 | - * Called before a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 2230 | - * |
|
| 2231 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 2232 | - * |
|
| 2233 | - * @since 1.0.0 |
|
| 2234 | - */ |
|
| 2235 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 2236 | - echo '</table>'; |
|
| 2237 | - /** |
|
| 2238 | - * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 2239 | - * |
|
| 2240 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 2241 | - * |
|
| 2242 | - * @since 1.0.0 |
|
| 2243 | - */ |
|
| 2244 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 2245 | - break; |
|
| 2246 | - case 'text': |
|
| 2247 | - ?> |
|
| 2194 | + /** |
|
| 2195 | + * Called after a GeoDirectory settings title is output in the GD settings page. |
|
| 2196 | + * |
|
| 2197 | + * The action is called dynamically geodir_settings_$value['id']. |
|
| 2198 | + * |
|
| 2199 | + * @since 1.0.0 |
|
| 2200 | + */ |
|
| 2201 | + do_action('geodir_settings_' . sanitize_title($value['id']));
|
|
| 2202 | + break; |
|
| 2203 | + |
|
| 2204 | + case 'no_tabs': |
|
| 2205 | + |
|
| 2206 | + echo '<div class="inner_content_tab_main">'; |
|
| 2207 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 2208 | + |
|
| 2209 | + break; |
|
| 2210 | + |
|
| 2211 | + case 'sectionstart': |
|
| 2212 | + if (isset($value['desc']) && $value['desc']) |
|
| 2213 | + $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 2214 | + if (isset($value['name']) && $value['name']) |
|
| 2215 | + echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 2216 | + /** |
|
| 2217 | + * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
| 2218 | + * |
|
| 2219 | + * The action is called dynamically geodir_settings_$value['id']_start. |
|
| 2220 | + * |
|
| 2221 | + * @since 1.0.0 |
|
| 2222 | + */ |
|
| 2223 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 2224 | + echo '<table class="form-table">' . "\n\n"; |
|
| 2225 | + |
|
| 2226 | + break; |
|
| 2227 | + case 'sectionend': |
|
| 2228 | + /** |
|
| 2229 | + * Called before a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 2230 | + * |
|
| 2231 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 2232 | + * |
|
| 2233 | + * @since 1.0.0 |
|
| 2234 | + */ |
|
| 2235 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 2236 | + echo '</table>'; |
|
| 2237 | + /** |
|
| 2238 | + * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 2239 | + * |
|
| 2240 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 2241 | + * |
|
| 2242 | + * @since 1.0.0 |
|
| 2243 | + */ |
|
| 2244 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 2245 | + break; |
|
| 2246 | + case 'text': |
|
| 2247 | + ?> |
|
| 2248 | 2248 | <tr valign="top"> |
| 2249 | 2249 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 2250 | 2250 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -2253,15 +2253,15 @@ discard block |
||
| 2253 | 2253 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 2254 | 2254 | style=" <?php echo esc_attr($value['css']); ?>" |
| 2255 | 2255 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 2256 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2257 | - } else {
|
|
| 2258 | - echo esc_attr($value['std']); |
|
| 2259 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 2256 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2257 | + } else {
|
|
| 2258 | + echo esc_attr($value['std']); |
|
| 2259 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 2260 | 2260 | </tr><?php |
| 2261 | - break; |
|
| 2261 | + break; |
|
| 2262 | 2262 | |
| 2263 | - case 'password': |
|
| 2264 | - ?> |
|
| 2263 | + case 'password': |
|
| 2264 | + ?> |
|
| 2265 | 2265 | <tr valign="top"> |
| 2266 | 2266 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 2267 | 2267 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -2270,42 +2270,42 @@ discard block |
||
| 2270 | 2270 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 2271 | 2271 | style="<?php echo esc_attr($value['css']); ?>" |
| 2272 | 2272 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 2273 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2274 | - } else {
|
|
| 2275 | - echo esc_attr($value['std']); |
|
| 2276 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 2273 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2274 | + } else {
|
|
| 2275 | + echo esc_attr($value['std']); |
|
| 2276 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 2277 | 2277 | </tr><?php |
| 2278 | - break; |
|
| 2278 | + break; |
|
| 2279 | 2279 | |
| 2280 | - case 'html_content': |
|
| 2281 | - ?> |
|
| 2280 | + case 'html_content': |
|
| 2281 | + ?> |
|
| 2282 | 2282 | <tr valign="top"> |
| 2283 | 2283 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 2284 | 2284 | <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td> |
| 2285 | 2285 | </tr><?php |
| 2286 | - break; |
|
| 2286 | + break; |
|
| 2287 | 2287 | |
| 2288 | - case 'color' : |
|
| 2289 | - ?> |
|
| 2288 | + case 'color' : |
|
| 2289 | + ?> |
|
| 2290 | 2290 | <tr valign="top"> |
| 2291 | 2291 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 2292 | 2292 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
| 2293 | 2293 | id="<?php echo esc_attr($value['id']); ?>" type="text" |
| 2294 | 2294 | style="<?php echo esc_attr($value['css']); ?>" |
| 2295 | 2295 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 2296 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2297 | - } else {
|
|
| 2298 | - echo esc_attr($value['std']); |
|
| 2299 | - } ?>" class="colorpick"/> <span |
|
| 2296 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2297 | + } else {
|
|
| 2298 | + echo esc_attr($value['std']); |
|
| 2299 | + } ?>" class="colorpick"/> <span |
|
| 2300 | 2300 | class="description"><?php echo $value['desc']; ?></span> |
| 2301 | 2301 | |
| 2302 | 2302 | <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv" |
| 2303 | 2303 | style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div> |
| 2304 | 2304 | </td> |
| 2305 | 2305 | </tr><?php |
| 2306 | - break; |
|
| 2307 | - case 'image_width' : |
|
| 2308 | - ?> |
|
| 2306 | + break; |
|
| 2307 | + case 'image_width' : |
|
| 2308 | + ?> |
|
| 2309 | 2309 | <tr valign="top"> |
| 2310 | 2310 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 2311 | 2311 | <td class="forminp"> |
@@ -2327,9 +2327,9 @@ discard block |
||
| 2327 | 2327 | |
| 2328 | 2328 | <span class="description"><?php echo $value['desc'] ?></span></td> |
| 2329 | 2329 | </tr><?php |
| 2330 | - break; |
|
| 2331 | - case 'select': |
|
| 2332 | - ?> |
|
| 2330 | + break; |
|
| 2331 | + case 'select': |
|
| 2332 | + ?> |
|
| 2333 | 2333 | <tr valign="top"> |
| 2334 | 2334 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 2335 | 2335 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -2338,30 +2338,30 @@ discard block |
||
| 2338 | 2338 | class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
| 2339 | 2339 | option-ajaxchosen="false"> |
| 2340 | 2340 | <?php |
| 2341 | - foreach ($value['options'] as $key => $val) {
|
|
| 2342 | - $geodir_select_value = ''; |
|
| 2343 | - if (get_option($value['id']) != '') {
|
|
| 2344 | - if (get_option($value['id']) != '' && get_option($value['id']) == $key) |
|
| 2345 | - $geodir_select_value = ' selected="selected" '; |
|
| 2346 | - } else {
|
|
| 2347 | - if ($value['std'] == $key) |
|
| 2348 | - $geodir_select_value = ' selected="selected" '; |
|
| 2349 | - } |
|
| 2341 | + foreach ($value['options'] as $key => $val) {
|
|
| 2342 | + $geodir_select_value = ''; |
|
| 2343 | + if (get_option($value['id']) != '') {
|
|
| 2344 | + if (get_option($value['id']) != '' && get_option($value['id']) == $key) |
|
| 2345 | + $geodir_select_value = ' selected="selected" '; |
|
| 2346 | + } else {
|
|
| 2347 | + if ($value['std'] == $key) |
|
| 2348 | + $geodir_select_value = ' selected="selected" '; |
|
| 2349 | + } |
|
| 2350 | 2350 | |
| 2351 | 2351 | |
| 2352 | - ?> |
|
| 2352 | + ?> |
|
| 2353 | 2353 | <option |
| 2354 | 2354 | value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo ucfirst($val) ?></option> |
| 2355 | 2355 | <?php |
| 2356 | - } |
|
| 2357 | - ?> |
|
| 2356 | + } |
|
| 2357 | + ?> |
|
| 2358 | 2358 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 2359 | 2359 | </td> |
| 2360 | 2360 | </tr><?php |
| 2361 | - break; |
|
| 2361 | + break; |
|
| 2362 | 2362 | |
| 2363 | - case 'multiselect': |
|
| 2364 | - ?> |
|
| 2363 | + case 'multiselect': |
|
| 2364 | + ?> |
|
| 2365 | 2365 | <tr valign="top"> |
| 2366 | 2366 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 2367 | 2367 | <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]" |
@@ -2371,27 +2371,27 @@ discard block |
||
| 2371 | 2371 | data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>" |
| 2372 | 2372 | option-ajaxchosen="false"> |
| 2373 | 2373 | <?php |
| 2374 | - foreach ($value['options'] as $key => $val) {
|
|
| 2375 | - if (strpos($key, 'optgroup_start-') === 0) {
|
|
| 2376 | - ?><optgroup label="<?php echo ucfirst($val); ?>"><?php |
|
| 2377 | - } else if (strpos($key, 'optgroup_end-') === 0) {
|
|
| 2378 | - ?></optgroup><?php |
|
| 2379 | - } else {
|
|
| 2380 | - ?> |
|
| 2374 | + foreach ($value['options'] as $key => $val) {
|
|
| 2375 | + if (strpos($key, 'optgroup_start-') === 0) {
|
|
| 2376 | + ?><optgroup label="<?php echo ucfirst($val); ?>"><?php |
|
| 2377 | + } else if (strpos($key, 'optgroup_end-') === 0) {
|
|
| 2378 | + ?></optgroup><?php |
|
| 2379 | + } else {
|
|
| 2380 | + ?> |
|
| 2381 | 2381 | <option |
| 2382 | 2382 | value="<?php echo esc_attr($key); ?>" <?php if (is_array(get_option($value['id']))) {
|
| 2383 | - if (in_array($key, get_option($value['id']))) { ?> selected="selected" <?php }
|
|
| 2384 | - } ?>><?php echo ucfirst($val) ?></option> |
|
| 2383 | + if (in_array($key, get_option($value['id']))) { ?> selected="selected" <?php }
|
|
| 2384 | + } ?>><?php echo ucfirst($val) ?></option> |
|
| 2385 | 2385 | <?php |
| 2386 | - } |
|
| 2387 | - } |
|
| 2388 | - ?> |
|
| 2386 | + } |
|
| 2387 | + } |
|
| 2388 | + ?> |
|
| 2389 | 2389 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 2390 | 2390 | </td> |
| 2391 | 2391 | </tr><?php |
| 2392 | - break; |
|
| 2393 | - case 'file': |
|
| 2394 | - ?> |
|
| 2392 | + break; |
|
| 2393 | + case 'file': |
|
| 2394 | + ?> |
|
| 2395 | 2395 | <tr valign="top"> |
| 2396 | 2396 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 2397 | 2397 | <td class="forminp"> |
@@ -2411,87 +2411,87 @@ discard block |
||
| 2411 | 2411 | <?php } ?> |
| 2412 | 2412 | </td> |
| 2413 | 2413 | </tr><?php |
| 2414 | - break; |
|
| 2415 | - case 'map_default_settings' : |
|
| 2416 | - ?> |
|
| 2414 | + break; |
|
| 2415 | + case 'map_default_settings' : |
|
| 2416 | + ?> |
|
| 2417 | 2417 | |
| 2418 | 2418 | <tr valign="top"> |
| 2419 | 2419 | <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
|
| 2420 | 2420 | <td width="60%"> |
| 2421 | 2421 | <select name="geodir_default_map_language" style="width:60%"> |
| 2422 | 2422 | <?php |
| 2423 | - $arr_map_langages = array( |
|
| 2424 | - 'ar' => __('ARABIC', 'geodirectory'),
|
|
| 2425 | - 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 2426 | - 'bg' => __('BULGARIAN', 'geodirectory'),
|
|
| 2427 | - 'bn' => __('BENGALI', 'geodirectory'),
|
|
| 2428 | - 'ca' => __('CATALAN', 'geodirectory'),
|
|
| 2429 | - 'cs' => __('CZECH', 'geodirectory'),
|
|
| 2430 | - 'da' => __('DANISH', 'geodirectory'),
|
|
| 2431 | - 'de' => __('GERMAN', 'geodirectory'),
|
|
| 2432 | - 'el' => __('GREEK', 'geodirectory'),
|
|
| 2433 | - 'en' => __('ENGLISH', 'geodirectory'),
|
|
| 2434 | - 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
|
|
| 2435 | - 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
|
|
| 2436 | - 'es' => __('SPANISH', 'geodirectory'),
|
|
| 2437 | - 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 2438 | - 'fa' => __('FARSI', 'geodirectory'),
|
|
| 2439 | - 'fi' => __('FINNISH', 'geodirectory'),
|
|
| 2440 | - 'fil' => __('FILIPINO', 'geodirectory'),
|
|
| 2441 | - 'fr' => __('FRENCH', 'geodirectory'),
|
|
| 2442 | - 'gl' => __('GALICIAN', 'geodirectory'),
|
|
| 2443 | - 'gu' => __('GUJARATI', 'geodirectory'),
|
|
| 2444 | - 'hi' => __('HINDI', 'geodirectory'),
|
|
| 2445 | - 'hr' => __('CROATIAN', 'geodirectory'),
|
|
| 2446 | - 'hu' => __('HUNGARIAN', 'geodirectory'),
|
|
| 2447 | - 'id' => __('INDONESIAN', 'geodirectory'),
|
|
| 2448 | - 'it' => __('ITALIAN', 'geodirectory'),
|
|
| 2449 | - 'iw' => __('HEBREW', 'geodirectory'),
|
|
| 2450 | - 'ja' => __('JAPANESE', 'geodirectory'),
|
|
| 2451 | - 'kn' => __('KANNADA', 'geodirectory'),
|
|
| 2452 | - 'ko' => __('KOREAN', 'geodirectory'),
|
|
| 2453 | - 'lt' => __('LITHUANIAN', 'geodirectory'),
|
|
| 2454 | - 'lv' => __('LATVIAN', 'geodirectory'),
|
|
| 2455 | - 'ml' => __('MALAYALAM', 'geodirectory'),
|
|
| 2456 | - 'mr' => __('MARATHI', 'geodirectory'),
|
|
| 2457 | - 'nl' => __('DUTCH', 'geodirectory'),
|
|
| 2458 | - 'no' => __('NORWEGIAN', 'geodirectory'),
|
|
| 2459 | - 'pl' => __('POLISH', 'geodirectory'),
|
|
| 2460 | - 'pt' => __('PORTUGUESE', 'geodirectory'),
|
|
| 2461 | - 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
|
|
| 2462 | - 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
|
|
| 2463 | - 'ro' => __('ROMANIAN', 'geodirectory'),
|
|
| 2464 | - 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 2465 | - 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 2466 | - 'sk' => __('SLOVAK', 'geodirectory'),
|
|
| 2467 | - 'sl' => __('SLOVENIAN', 'geodirectory'),
|
|
| 2468 | - 'sr' => __('SERBIAN', 'geodirectory'),
|
|
| 2469 | - 'sv' => __(' SWEDISH', 'geodirectory'),
|
|
| 2470 | - 'tl' => __('TAGALOG', 'geodirectory'),
|
|
| 2471 | - 'ta' => __('TAMIL', 'geodirectory'),
|
|
| 2472 | - 'te' => __('TELUGU', 'geodirectory'),
|
|
| 2473 | - 'th' => __('THAI', 'geodirectory'),
|
|
| 2474 | - 'tr' => __('TURKISH', 'geodirectory'),
|
|
| 2475 | - 'uk' => __('UKRAINIAN', 'geodirectory'),
|
|
| 2476 | - 'vi' => __('VIETNAMESE', 'geodirectory'),
|
|
| 2477 | - 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
|
|
| 2478 | - 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
|
|
| 2479 | - ); |
|
| 2480 | - $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 2481 | - if (empty($geodir_default_map_language)) |
|
| 2482 | - $geodir_default_map_language = 'en'; |
|
| 2483 | - foreach ($arr_map_langages as $language_key => $language_txt) {
|
|
| 2484 | - if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
| 2485 | - $geodir_default_language_selected = "selected='selected'"; |
|
| 2486 | - else |
|
| 2487 | - $geodir_default_language_selected = ''; |
|
| 2488 | - |
|
| 2489 | - ?> |
|
| 2423 | + $arr_map_langages = array( |
|
| 2424 | + 'ar' => __('ARABIC', 'geodirectory'),
|
|
| 2425 | + 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 2426 | + 'bg' => __('BULGARIAN', 'geodirectory'),
|
|
| 2427 | + 'bn' => __('BENGALI', 'geodirectory'),
|
|
| 2428 | + 'ca' => __('CATALAN', 'geodirectory'),
|
|
| 2429 | + 'cs' => __('CZECH', 'geodirectory'),
|
|
| 2430 | + 'da' => __('DANISH', 'geodirectory'),
|
|
| 2431 | + 'de' => __('GERMAN', 'geodirectory'),
|
|
| 2432 | + 'el' => __('GREEK', 'geodirectory'),
|
|
| 2433 | + 'en' => __('ENGLISH', 'geodirectory'),
|
|
| 2434 | + 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
|
|
| 2435 | + 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
|
|
| 2436 | + 'es' => __('SPANISH', 'geodirectory'),
|
|
| 2437 | + 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 2438 | + 'fa' => __('FARSI', 'geodirectory'),
|
|
| 2439 | + 'fi' => __('FINNISH', 'geodirectory'),
|
|
| 2440 | + 'fil' => __('FILIPINO', 'geodirectory'),
|
|
| 2441 | + 'fr' => __('FRENCH', 'geodirectory'),
|
|
| 2442 | + 'gl' => __('GALICIAN', 'geodirectory'),
|
|
| 2443 | + 'gu' => __('GUJARATI', 'geodirectory'),
|
|
| 2444 | + 'hi' => __('HINDI', 'geodirectory'),
|
|
| 2445 | + 'hr' => __('CROATIAN', 'geodirectory'),
|
|
| 2446 | + 'hu' => __('HUNGARIAN', 'geodirectory'),
|
|
| 2447 | + 'id' => __('INDONESIAN', 'geodirectory'),
|
|
| 2448 | + 'it' => __('ITALIAN', 'geodirectory'),
|
|
| 2449 | + 'iw' => __('HEBREW', 'geodirectory'),
|
|
| 2450 | + 'ja' => __('JAPANESE', 'geodirectory'),
|
|
| 2451 | + 'kn' => __('KANNADA', 'geodirectory'),
|
|
| 2452 | + 'ko' => __('KOREAN', 'geodirectory'),
|
|
| 2453 | + 'lt' => __('LITHUANIAN', 'geodirectory'),
|
|
| 2454 | + 'lv' => __('LATVIAN', 'geodirectory'),
|
|
| 2455 | + 'ml' => __('MALAYALAM', 'geodirectory'),
|
|
| 2456 | + 'mr' => __('MARATHI', 'geodirectory'),
|
|
| 2457 | + 'nl' => __('DUTCH', 'geodirectory'),
|
|
| 2458 | + 'no' => __('NORWEGIAN', 'geodirectory'),
|
|
| 2459 | + 'pl' => __('POLISH', 'geodirectory'),
|
|
| 2460 | + 'pt' => __('PORTUGUESE', 'geodirectory'),
|
|
| 2461 | + 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
|
|
| 2462 | + 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
|
|
| 2463 | + 'ro' => __('ROMANIAN', 'geodirectory'),
|
|
| 2464 | + 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 2465 | + 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 2466 | + 'sk' => __('SLOVAK', 'geodirectory'),
|
|
| 2467 | + 'sl' => __('SLOVENIAN', 'geodirectory'),
|
|
| 2468 | + 'sr' => __('SERBIAN', 'geodirectory'),
|
|
| 2469 | + 'sv' => __(' SWEDISH', 'geodirectory'),
|
|
| 2470 | + 'tl' => __('TAGALOG', 'geodirectory'),
|
|
| 2471 | + 'ta' => __('TAMIL', 'geodirectory'),
|
|
| 2472 | + 'te' => __('TELUGU', 'geodirectory'),
|
|
| 2473 | + 'th' => __('THAI', 'geodirectory'),
|
|
| 2474 | + 'tr' => __('TURKISH', 'geodirectory'),
|
|
| 2475 | + 'uk' => __('UKRAINIAN', 'geodirectory'),
|
|
| 2476 | + 'vi' => __('VIETNAMESE', 'geodirectory'),
|
|
| 2477 | + 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
|
|
| 2478 | + 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
|
|
| 2479 | + ); |
|
| 2480 | + $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 2481 | + if (empty($geodir_default_map_language)) |
|
| 2482 | + $geodir_default_map_language = 'en'; |
|
| 2483 | + foreach ($arr_map_langages as $language_key => $language_txt) {
|
|
| 2484 | + if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
| 2485 | + $geodir_default_language_selected = "selected='selected'"; |
|
| 2486 | + else |
|
| 2487 | + $geodir_default_language_selected = ''; |
|
| 2488 | + |
|
| 2489 | + ?> |
|
| 2490 | 2490 | <option |
| 2491 | 2491 | value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option> |
| 2492 | 2492 | |
| 2493 | 2493 | <?php } |
| 2494 | - ?> |
|
| 2494 | + ?> |
|
| 2495 | 2495 | </select> |
| 2496 | 2496 | </td> |
| 2497 | 2497 | </tr> |
@@ -2502,46 +2502,46 @@ discard block |
||
| 2502 | 2502 | <td width="60%"> |
| 2503 | 2503 | <select name="geodir_default_map_search_pt" style="width:60%"> |
| 2504 | 2504 | <?php |
| 2505 | - $post_types = geodir_get_posttypes('array');
|
|
| 2506 | - $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
|
|
| 2507 | - if (empty($geodir_default_map_search_pt)) |
|
| 2508 | - $geodir_default_map_search_pt = 'gd_place'; |
|
| 2509 | - if (is_array($post_types)) {
|
|
| 2510 | - foreach ($post_types as $key => $post_types_obj) {
|
|
| 2511 | - if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
| 2512 | - $geodir_search_pt_selected = "selected='selected'"; |
|
| 2513 | - else |
|
| 2514 | - $geodir_search_pt_selected = ''; |
|
| 2515 | - |
|
| 2516 | - ?> |
|
| 2505 | + $post_types = geodir_get_posttypes('array');
|
|
| 2506 | + $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
|
|
| 2507 | + if (empty($geodir_default_map_search_pt)) |
|
| 2508 | + $geodir_default_map_search_pt = 'gd_place'; |
|
| 2509 | + if (is_array($post_types)) {
|
|
| 2510 | + foreach ($post_types as $key => $post_types_obj) {
|
|
| 2511 | + if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
| 2512 | + $geodir_search_pt_selected = "selected='selected'"; |
|
| 2513 | + else |
|
| 2514 | + $geodir_search_pt_selected = ''; |
|
| 2515 | + |
|
| 2516 | + ?> |
|
| 2517 | 2517 | <option |
| 2518 | 2518 | value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo $post_types_obj['labels']['singular_name']; ?></option> |
| 2519 | 2519 | |
| 2520 | 2520 | <?php } |
| 2521 | 2521 | |
| 2522 | - } |
|
| 2522 | + } |
|
| 2523 | 2523 | |
| 2524 | - ?> |
|
| 2524 | + ?> |
|
| 2525 | 2525 | </select> |
| 2526 | 2526 | </td> |
| 2527 | 2527 | </tr> |
| 2528 | 2528 | |
| 2529 | 2529 | <?php |
| 2530 | - break; |
|
| 2530 | + break; |
|
| 2531 | 2531 | |
| 2532 | - case 'map': |
|
| 2533 | - ?> |
|
| 2532 | + case 'map': |
|
| 2533 | + ?> |
|
| 2534 | 2534 | <tr valign="top"> |
| 2535 | 2535 | <td class="forminp"> |
| 2536 | 2536 | <?php |
| 2537 | - global $post_cat, $cat_display; |
|
| 2538 | - $post_types = geodir_get_posttypes('object');
|
|
| 2539 | - $cat_display = 'checkbox'; |
|
| 2540 | - $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
|
| 2541 | - $gd_cats = get_option('geodir_exclude_cat_on_map');
|
|
| 2542 | - $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 2543 | - $count = 1; |
|
| 2544 | - ?> |
|
| 2537 | + global $post_cat, $cat_display; |
|
| 2538 | + $post_types = geodir_get_posttypes('object');
|
|
| 2539 | + $cat_display = 'checkbox'; |
|
| 2540 | + $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
|
| 2541 | + $gd_cats = get_option('geodir_exclude_cat_on_map');
|
|
| 2542 | + $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 2543 | + $count = 1; |
|
| 2544 | + ?> |
|
| 2545 | 2545 | <table width="70%" class="widefat"> |
| 2546 | 2546 | <thead> |
| 2547 | 2547 | <tr> |
@@ -2550,18 +2550,18 @@ discard block |
||
| 2550 | 2550 | <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th> |
| 2551 | 2551 | </tr> |
| 2552 | 2552 | <?php |
| 2553 | - $gd_categs = $gd_cats; |
|
| 2554 | - foreach ($post_types as $key => $post_types_obj) : |
|
| 2555 | - $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
| 2556 | - $gd_taxonomy = geodir_get_taxonomies($key); |
|
| 2557 | - if ($gd_cats_upgrade) {
|
|
| 2558 | - $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
| 2559 | - $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
| 2560 | - $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
| 2561 | - } |
|
| 2562 | - $post_cat = implode(',', $gd_cats);
|
|
| 2563 | - $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
| 2564 | - ?> |
|
| 2553 | + $gd_categs = $gd_cats; |
|
| 2554 | + foreach ($post_types as $key => $post_types_obj) : |
|
| 2555 | + $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
| 2556 | + $gd_taxonomy = geodir_get_taxonomies($key); |
|
| 2557 | + if ($gd_cats_upgrade) {
|
|
| 2558 | + $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
| 2559 | + $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
| 2560 | + $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
| 2561 | + } |
|
| 2562 | + $post_cat = implode(',', $gd_cats);
|
|
| 2563 | + $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
| 2564 | + ?> |
|
| 2565 | 2565 | <tr> |
| 2566 | 2566 | <td valign="top" width="5%"><?php echo $count; ?></td> |
| 2567 | 2567 | <td valign="top" width="25%" id="td_post_types"><input type="checkbox" |
@@ -2582,19 +2582,19 @@ discard block |
||
| 2582 | 2582 | </td> |
| 2583 | 2583 | </tr> |
| 2584 | 2584 | <?php |
| 2585 | - break; |
|
| 2585 | + break; |
|
| 2586 | 2586 | |
| 2587 | - case 'checkbox' : |
|
| 2587 | + case 'checkbox' : |
|
| 2588 | 2588 | |
| 2589 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
| 2590 | - ?> |
|
| 2589 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
| 2590 | + ?> |
|
| 2591 | 2591 | <tr valign="top"> |
| 2592 | 2592 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 2593 | 2593 | <td class="forminp"> |
| 2594 | 2594 | <?php |
| 2595 | - endif; |
|
| 2595 | + endif; |
|
| 2596 | 2596 | |
| 2597 | - ?> |
|
| 2597 | + ?> |
|
| 2598 | 2598 | <fieldset> |
| 2599 | 2599 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 2600 | 2600 | <label for="<?php echo $value['id'] ?>"> |
@@ -2604,49 +2604,49 @@ discard block |
||
| 2604 | 2604 | </fieldset> |
| 2605 | 2605 | <?php |
| 2606 | 2606 | |
| 2607 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
| 2608 | - ?> |
|
| 2607 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
| 2608 | + ?> |
|
| 2609 | 2609 | </td> |
| 2610 | 2610 | </tr> |
| 2611 | 2611 | <?php |
| 2612 | - endif; |
|
| 2612 | + endif; |
|
| 2613 | 2613 | |
| 2614 | - break; |
|
| 2614 | + break; |
|
| 2615 | 2615 | |
| 2616 | - case 'radio' : |
|
| 2616 | + case 'radio' : |
|
| 2617 | 2617 | |
| 2618 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
| 2619 | - ?> |
|
| 2618 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
| 2619 | + ?> |
|
| 2620 | 2620 | <tr valign="top"> |
| 2621 | 2621 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 2622 | 2622 | <td class="forminp"> |
| 2623 | 2623 | <?php |
| 2624 | - endif; |
|
| 2624 | + endif; |
|
| 2625 | 2625 | |
| 2626 | - ?> |
|
| 2626 | + ?> |
|
| 2627 | 2627 | <fieldset> |
| 2628 | 2628 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 2629 | 2629 | <label for="<?php echo $value['id'];?>"> |
| 2630 | 2630 | <input name="<?php echo esc_attr($value['id']); ?>" |
| 2631 | 2631 | id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio" |
| 2632 | 2632 | value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
|
| 2633 | - echo 'checked="checked"'; |
|
| 2634 | - }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 2633 | + echo 'checked="checked"'; |
|
| 2634 | + }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 2635 | 2635 | <?php echo $value['desc']; ?></label><br> |
| 2636 | 2636 | </fieldset> |
| 2637 | 2637 | <?php |
| 2638 | 2638 | |
| 2639 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
| 2640 | - ?> |
|
| 2639 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
| 2640 | + ?> |
|
| 2641 | 2641 | </td> |
| 2642 | 2642 | </tr> |
| 2643 | 2643 | <?php |
| 2644 | - endif; |
|
| 2644 | + endif; |
|
| 2645 | 2645 | |
| 2646 | - break; |
|
| 2646 | + break; |
|
| 2647 | 2647 | |
| 2648 | - case 'textarea': |
|
| 2649 | - ?> |
|
| 2648 | + case 'textarea': |
|
| 2649 | + ?> |
|
| 2650 | 2650 | <tr valign="top"> |
| 2651 | 2651 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 2652 | 2652 | <td class="forminp"> |
@@ -2659,32 +2659,32 @@ discard block |
||
| 2659 | 2659 | |
| 2660 | 2660 | </td> |
| 2661 | 2661 | </tr><?php |
| 2662 | - break; |
|
| 2662 | + break; |
|
| 2663 | 2663 | |
| 2664 | - case 'editor': |
|
| 2665 | - ?> |
|
| 2664 | + case 'editor': |
|
| 2665 | + ?> |
|
| 2666 | 2666 | <tr valign="top"> |
| 2667 | 2667 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 2668 | 2668 | <td class="forminp"><?php |
| 2669 | 2669 | |
| 2670 | - $content = ''; |
|
| 2671 | - if (get_option($value['id'])) |
|
| 2672 | - $content = stripslashes(get_option($value['id'])); |
|
| 2673 | - else |
|
| 2674 | - $content = $value['std']; |
|
| 2670 | + $content = ''; |
|
| 2671 | + if (get_option($value['id'])) |
|
| 2672 | + $content = stripslashes(get_option($value['id'])); |
|
| 2673 | + else |
|
| 2674 | + $content = $value['std']; |
|
| 2675 | 2675 | |
| 2676 | - $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
|
| 2676 | + $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
|
| 2677 | 2677 | |
| 2678 | - wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
| 2678 | + wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
| 2679 | 2679 | |
| 2680 | - ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
| 2680 | + ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
| 2681 | 2681 | |
| 2682 | 2682 | </td> |
| 2683 | 2683 | </tr><?php |
| 2684 | - break; |
|
| 2684 | + break; |
|
| 2685 | 2685 | |
| 2686 | - case 'single_select_page' : |
|
| 2687 | - // WPML |
|
| 2686 | + case 'single_select_page' : |
|
| 2687 | + // WPML |
|
| 2688 | 2688 | $switch_lang = false; |
| 2689 | 2689 | $disabled = ''; |
| 2690 | 2690 | if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
|
@@ -2702,18 +2702,18 @@ discard block |
||
| 2702 | 2702 | // |
| 2703 | 2703 | $page_setting = (int)get_option($value['id']); |
| 2704 | 2704 | |
| 2705 | - $args = array('name' => $value['id'],
|
|
| 2706 | - 'id' => $value['id'], |
|
| 2707 | - 'sort_column' => 'menu_order', |
|
| 2708 | - 'sort_order' => 'ASC', |
|
| 2709 | - 'show_option_none' => ' ', |
|
| 2710 | - 'class' => $value['class'], |
|
| 2711 | - 'echo' => false, |
|
| 2712 | - 'selected' => $page_setting); |
|
| 2705 | + $args = array('name' => $value['id'],
|
|
| 2706 | + 'id' => $value['id'], |
|
| 2707 | + 'sort_column' => 'menu_order', |
|
| 2708 | + 'sort_order' => 'ASC', |
|
| 2709 | + 'show_option_none' => ' ', |
|
| 2710 | + 'class' => $value['class'], |
|
| 2711 | + 'echo' => false, |
|
| 2712 | + 'selected' => $page_setting); |
|
| 2713 | 2713 | |
| 2714 | - if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
| 2714 | + if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
| 2715 | 2715 | |
| 2716 | - ?> |
|
| 2716 | + ?> |
|
| 2717 | 2717 | <tr valign="top" class="single_select_page"> |
| 2718 | 2718 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 2719 | 2719 | <td class="forminp"> |
@@ -2724,18 +2724,18 @@ discard block |
||
| 2724 | 2724 | if ($switch_lang) {
|
| 2725 | 2725 | $sitepress->switch_lang($switch_lang, true); |
| 2726 | 2726 | } |
| 2727 | - break; |
|
| 2728 | - case 'single_select_country' : |
|
| 2729 | - $countries = $geodirectory->countries->countries; |
|
| 2730 | - $country_setting = (string)get_option($value['id']); |
|
| 2731 | - if (strstr($country_setting, ':')) : |
|
| 2732 | - $country = current(explode(':', $country_setting));
|
|
| 2733 | - $state = end(explode(':', $country_setting));
|
|
| 2734 | - else : |
|
| 2735 | - $country = $country_setting; |
|
| 2736 | - $state = '*'; |
|
| 2737 | - endif; |
|
| 2738 | - ?> |
|
| 2727 | + break; |
|
| 2728 | + case 'single_select_country' : |
|
| 2729 | + $countries = $geodirectory->countries->countries; |
|
| 2730 | + $country_setting = (string)get_option($value['id']); |
|
| 2731 | + if (strstr($country_setting, ':')) : |
|
| 2732 | + $country = current(explode(':', $country_setting));
|
|
| 2733 | + $state = end(explode(':', $country_setting));
|
|
| 2734 | + else : |
|
| 2735 | + $country = $country_setting; |
|
| 2736 | + $state = '*'; |
|
| 2737 | + endif; |
|
| 2738 | + ?> |
|
| 2739 | 2739 | <tr valign="top"> |
| 2740 | 2740 | <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th> |
| 2741 | 2741 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -2746,12 +2746,12 @@ discard block |
||
| 2746 | 2746 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 2747 | 2747 | </td> |
| 2748 | 2748 | </tr><?php |
| 2749 | - break; |
|
| 2750 | - case 'multi_select_countries' : |
|
| 2751 | - $countries = $geodirectory->countries->countries; |
|
| 2752 | - asort($countries); |
|
| 2753 | - $selections = (array)get_option($value['id']); |
|
| 2754 | - ?> |
|
| 2749 | + break; |
|
| 2750 | + case 'multi_select_countries' : |
|
| 2751 | + $countries = $geodirectory->countries->countries; |
|
| 2752 | + asort($countries); |
|
| 2753 | + $selections = (array)get_option($value['id']); |
|
| 2754 | + ?> |
|
| 2755 | 2755 | <tr valign="top"> |
| 2756 | 2756 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 2757 | 2757 | <td class="forminp"> |
@@ -2759,22 +2759,22 @@ discard block |
||
| 2759 | 2759 | data-placeholder="<?php _e('Choose countries…', 'geodirectory'); ?>"
|
| 2760 | 2760 | title="Country" class="chosen_select"> |
| 2761 | 2761 | <?php |
| 2762 | - if ($countries) foreach ($countries as $key => $val) : |
|
| 2763 | - echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 2764 | - endforeach; |
|
| 2765 | - ?> |
|
| 2762 | + if ($countries) foreach ($countries as $key => $val) : |
|
| 2763 | + echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 2764 | + endforeach; |
|
| 2765 | + ?> |
|
| 2766 | 2766 | </select> |
| 2767 | 2767 | </td> |
| 2768 | 2768 | </tr> |
| 2769 | 2769 | |
| 2770 | 2770 | <?php |
| 2771 | 2771 | |
| 2772 | - break; |
|
| 2772 | + break; |
|
| 2773 | 2773 | |
| 2774 | - case 'google_analytics' : |
|
| 2775 | - $selections = (array)get_option($value['id']); |
|
| 2776 | - if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
|
|
| 2777 | - ?> |
|
| 2774 | + case 'google_analytics' : |
|
| 2775 | + $selections = (array)get_option($value['id']); |
|
| 2776 | + if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
|
|
| 2777 | + ?> |
|
| 2778 | 2778 | <tr valign="top"> |
| 2779 | 2779 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 2780 | 2780 | <td class="forminp"> |
@@ -2782,19 +2782,19 @@ discard block |
||
| 2782 | 2782 | |
| 2783 | 2783 | <?php |
| 2784 | 2784 | |
| 2785 | - $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
| 2786 | - $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
| 2787 | - $state = "&state=123";//any string |
|
| 2788 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 2789 | - $response_type = "&response_type=code"; |
|
| 2790 | - $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 2791 | - $access_type = "&access_type=offline"; |
|
| 2792 | - $approval_prompt = "&approval_prompt=force"; |
|
| 2785 | + $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
| 2786 | + $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
| 2787 | + $state = "&state=123";//any string |
|
| 2788 | + $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 2789 | + $response_type = "&response_type=code"; |
|
| 2790 | + $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 2791 | + $access_type = "&access_type=offline"; |
|
| 2792 | + $approval_prompt = "&approval_prompt=force"; |
|
| 2793 | 2793 | |
| 2794 | - $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
| 2794 | + $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
| 2795 | 2795 | |
| 2796 | 2796 | |
| 2797 | - ?> |
|
| 2797 | + ?> |
|
| 2798 | 2798 | <script> |
| 2799 | 2799 | function gd_ga_popup() {
|
| 2800 | 2800 | var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
|
@@ -2809,47 +2809,47 @@ discard block |
||
| 2809 | 2809 | </script> |
| 2810 | 2810 | |
| 2811 | 2811 | <?php |
| 2812 | - if (get_option('gd_ga_refresh_token')) {
|
|
| 2813 | - ?> |
|
| 2812 | + if (get_option('gd_ga_refresh_token')) {
|
|
| 2813 | + ?> |
|
| 2814 | 2814 | <span class="button-primary" |
| 2815 | 2815 | onclick="gd_ga_popup();"><?php _e('Re-authorize', 'geodirectory'); ?></span>
|
| 2816 | 2816 | <span |
| 2817 | 2817 | style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
|
| 2818 | 2818 | <?php |
| 2819 | - } else {
|
|
| 2820 | - ?> |
|
| 2819 | + } else {
|
|
| 2820 | + ?> |
|
| 2821 | 2821 | <span class="button-primary" |
| 2822 | 2822 | onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
|
| 2823 | 2823 | <?php |
| 2824 | - } |
|
| 2825 | - ?> |
|
| 2824 | + } |
|
| 2825 | + ?> |
|
| 2826 | 2826 | </td> |
| 2827 | 2827 | </tr> |
| 2828 | 2828 | |
| 2829 | 2829 | <?php |
| 2830 | - } |
|
| 2830 | + } |
|
| 2831 | 2831 | |
| 2832 | - break; |
|
| 2832 | + break; |
|
| 2833 | 2833 | |
| 2834 | - case 'field_seperator' : |
|
| 2834 | + case 'field_seperator' : |
|
| 2835 | 2835 | |
| 2836 | - ?> |
|
| 2836 | + ?> |
|
| 2837 | 2837 | <tr valign="top"> |
| 2838 | 2838 | <td colspan="2" class="forminp geodir_line_seperator"></td> |
| 2839 | 2839 | </tr> |
| 2840 | 2840 | <?php |
| 2841 | 2841 | |
| 2842 | - break; |
|
| 2842 | + break; |
|
| 2843 | 2843 | |
| 2844 | - endswitch; |
|
| 2844 | + endswitch; |
|
| 2845 | 2845 | |
| 2846 | - endforeach; |
|
| 2846 | + endforeach; |
|
| 2847 | 2847 | |
| 2848 | - if ($first_title === false) {
|
|
| 2849 | - echo "</div>"; |
|
| 2850 | - } |
|
| 2848 | + if ($first_title === false) {
|
|
| 2849 | + echo "</div>"; |
|
| 2850 | + } |
|
| 2851 | 2851 | |
| 2852 | - ?> |
|
| 2852 | + ?> |
|
| 2853 | 2853 | |
| 2854 | 2854 | <script type="text/javascript"> |
| 2855 | 2855 | |
@@ -2909,33 +2909,33 @@ discard block |
||
| 2909 | 2909 | */ |
| 2910 | 2910 | function geodir_post_info_setting() |
| 2911 | 2911 | {
|
| 2912 | - global $post, $post_id; |
|
| 2913 | - |
|
| 2914 | - $post_type = get_post_type(); |
|
| 2915 | - |
|
| 2916 | - $package_info = array(); |
|
| 2917 | - |
|
| 2918 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 2919 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
| 2920 | - echo '<div id="geodir_wrapper">'; |
|
| 2921 | - /** |
|
| 2922 | - * Called before the GD custom fields are output in the wp-admin area. |
|
| 2923 | - * |
|
| 2924 | - * @since 1.0.0 |
|
| 2925 | - * @see 'geodir_after_default_field_in_meta_box' |
|
| 2926 | - */ |
|
| 2927 | - do_action('geodir_before_default_field_in_meta_box');
|
|
| 2928 | - //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
| 2929 | - // to display all fields in one information box |
|
| 2930 | - geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
| 2931 | - /** |
|
| 2932 | - * Called after the GD custom fields are output in the wp-admin area. |
|
| 2933 | - * |
|
| 2934 | - * @since 1.0.0 |
|
| 2935 | - * @see 'geodir_before_default_field_in_meta_box' |
|
| 2936 | - */ |
|
| 2937 | - do_action('geodir_after_default_field_in_meta_box');
|
|
| 2938 | - echo '</div>'; |
|
| 2912 | + global $post, $post_id; |
|
| 2913 | + |
|
| 2914 | + $post_type = get_post_type(); |
|
| 2915 | + |
|
| 2916 | + $package_info = array(); |
|
| 2917 | + |
|
| 2918 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 2919 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
| 2920 | + echo '<div id="geodir_wrapper">'; |
|
| 2921 | + /** |
|
| 2922 | + * Called before the GD custom fields are output in the wp-admin area. |
|
| 2923 | + * |
|
| 2924 | + * @since 1.0.0 |
|
| 2925 | + * @see 'geodir_after_default_field_in_meta_box' |
|
| 2926 | + */ |
|
| 2927 | + do_action('geodir_before_default_field_in_meta_box');
|
|
| 2928 | + //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
| 2929 | + // to display all fields in one information box |
|
| 2930 | + geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
| 2931 | + /** |
|
| 2932 | + * Called after the GD custom fields are output in the wp-admin area. |
|
| 2933 | + * |
|
| 2934 | + * @since 1.0.0 |
|
| 2935 | + * @see 'geodir_before_default_field_in_meta_box' |
|
| 2936 | + */ |
|
| 2937 | + do_action('geodir_after_default_field_in_meta_box');
|
|
| 2938 | + echo '</div>'; |
|
| 2939 | 2939 | } |
| 2940 | 2940 | |
| 2941 | 2941 | /** |
@@ -2948,18 +2948,18 @@ discard block |
||
| 2948 | 2948 | */ |
| 2949 | 2949 | function geodir_post_addinfo_setting() |
| 2950 | 2950 | {
|
| 2951 | - global $post, $post_id; |
|
| 2951 | + global $post, $post_id; |
|
| 2952 | 2952 | |
| 2953 | - $post_type = get_post_type(); |
|
| 2953 | + $post_type = get_post_type(); |
|
| 2954 | 2954 | |
| 2955 | - $package_info = array(); |
|
| 2955 | + $package_info = array(); |
|
| 2956 | 2956 | |
| 2957 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 2957 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 2958 | 2958 | |
| 2959 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
| 2960 | - echo '<div id="geodir_wrapper">'; |
|
| 2961 | - geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
| 2962 | - echo '</div>'; |
|
| 2959 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
| 2960 | + echo '<div id="geodir_wrapper">'; |
|
| 2961 | + geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
| 2962 | + echo '</div>'; |
|
| 2963 | 2963 | |
| 2964 | 2964 | } |
| 2965 | 2965 | |
@@ -2973,60 +2973,60 @@ discard block |
||
| 2973 | 2973 | */ |
| 2974 | 2974 | function geodir_post_attachments() |
| 2975 | 2975 | {
|
| 2976 | - global $post, $post_id; |
|
| 2976 | + global $post, $post_id; |
|
| 2977 | 2977 | |
| 2978 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
| 2978 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
| 2979 | 2979 | |
| 2980 | - if (geodir_get_featured_image($post_id, 'thumbnail')) {
|
|
| 2981 | - echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
|
|
| 2982 | - geodir_show_featured_image($post_id, 'thumbnail'); |
|
| 2983 | - } |
|
| 2980 | + if (geodir_get_featured_image($post_id, 'thumbnail')) {
|
|
| 2981 | + echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
|
|
| 2982 | + geodir_show_featured_image($post_id, 'thumbnail'); |
|
| 2983 | + } |
|
| 2984 | 2984 | |
| 2985 | - $image_limit = 0; |
|
| 2985 | + $image_limit = 0; |
|
| 2986 | 2986 | |
| 2987 | - ?> |
|
| 2987 | + ?> |
|
| 2988 | 2988 | |
| 2989 | 2989 | |
| 2990 | 2990 | <h5 class="form_title"> |
| 2991 | 2991 | <?php if ($image_limit != 0 && $image_limit == 1) {
|
| 2992 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 2993 | - } ?> |
|
| 2992 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 2993 | + } ?> |
|
| 2994 | 2994 | <?php if ($image_limit != 0 && $image_limit > 1) {
|
| 2995 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 2996 | - } ?> |
|
| 2995 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 2996 | + } ?> |
|
| 2997 | 2997 | <?php if ($image_limit == 0) {
|
| 2998 | - echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 2999 | - } ?> |
|
| 2998 | + echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 2999 | + } ?> |
|
| 3000 | 3000 | </h5> |
| 3001 | 3001 | |
| 3002 | 3002 | |
| 3003 | 3003 | <?php |
| 3004 | 3004 | |
| 3005 | - $curImages = geodir_get_images($post_id); |
|
| 3006 | - $place_img_array = array(); |
|
| 3005 | + $curImages = geodir_get_images($post_id); |
|
| 3006 | + $place_img_array = array(); |
|
| 3007 | 3007 | |
| 3008 | - if (!empty($curImages)): |
|
| 3009 | - foreach ($curImages as $p_img): |
|
| 3010 | - $place_img_array[] = $p_img->src; |
|
| 3011 | - endforeach; |
|
| 3012 | - endif; |
|
| 3008 | + if (!empty($curImages)): |
|
| 3009 | + foreach ($curImages as $p_img): |
|
| 3010 | + $place_img_array[] = $p_img->src; |
|
| 3011 | + endforeach; |
|
| 3012 | + endif; |
|
| 3013 | 3013 | |
| 3014 | - if (!empty($place_img_array)) |
|
| 3015 | - $curImages = implode(',', $place_img_array);
|
|
| 3014 | + if (!empty($place_img_array)) |
|
| 3015 | + $curImages = implode(',', $place_img_array);
|
|
| 3016 | 3016 | |
| 3017 | 3017 | |
| 3018 | - // adjust values here |
|
| 3019 | - $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 |
|
| 3018 | + // adjust values here |
|
| 3019 | + $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 |
|
| 3020 | 3020 | |
| 3021 | - $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
| 3021 | + $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
| 3022 | 3022 | |
| 3023 | - $multiple = true; // allow multiple files upload |
|
| 3023 | + $multiple = true; // allow multiple files upload |
|
| 3024 | 3024 | |
| 3025 | - $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 3025 | + $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 3026 | 3026 | |
| 3027 | - $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 3027 | + $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 3028 | 3028 | |
| 3029 | - ?> |
|
| 3029 | + ?> |
|
| 3030 | 3030 | |
| 3031 | 3031 | <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;"> |
| 3032 | 3032 | <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/> |
@@ -3068,13 +3068,13 @@ discard block |
||
| 3068 | 3068 | */ |
| 3069 | 3069 | function geodir_action_post_updated($post_ID, $post_after, $post_before) |
| 3070 | 3070 | {
|
| 3071 | - $post_type = get_post_type($post_ID); |
|
| 3071 | + $post_type = get_post_type($post_ID); |
|
| 3072 | 3072 | |
| 3073 | - if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 3074 | - 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) {
|
|
| 3075 | - geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
| 3076 | - } |
|
| 3077 | - } |
|
| 3073 | + if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 3074 | + 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) {
|
|
| 3075 | + geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
| 3076 | + } |
|
| 3077 | + } |
|
| 3078 | 3078 | } |
| 3079 | 3079 | |
| 3080 | 3080 | /** |
@@ -3089,39 +3089,39 @@ discard block |
||
| 3089 | 3089 | */ |
| 3090 | 3090 | function geodir_notification_add_bcc_option($settings) |
| 3091 | 3091 | {
|
| 3092 | - if (!empty($settings)) {
|
|
| 3093 | - $new_settings = array(); |
|
| 3094 | - foreach ($settings as $setting) {
|
|
| 3095 | - if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
|
|
| 3096 | - $geodir_bcc_listing_published_yes = array( |
|
| 3097 | - 'name' => __('Listing published', 'geodirectory'),
|
|
| 3098 | - 'desc' => __('Yes', 'geodirectory'),
|
|
| 3099 | - 'id' => 'geodir_bcc_listing_published', |
|
| 3100 | - 'std' => 'yes', |
|
| 3101 | - 'type' => 'radio', |
|
| 3102 | - 'value' => '1', |
|
| 3103 | - 'radiogroup' => 'start' |
|
| 3104 | - ); |
|
| 3105 | - |
|
| 3106 | - $geodir_bcc_listing_published_no = array( |
|
| 3107 | - 'name' => __('Listing published', 'geodirectory'),
|
|
| 3108 | - 'desc' => __('No', 'geodirectory'),
|
|
| 3109 | - 'id' => 'geodir_bcc_listing_published', |
|
| 3110 | - 'std' => 'yes', |
|
| 3111 | - 'type' => 'radio', |
|
| 3112 | - 'value' => '0', |
|
| 3113 | - 'radiogroup' => 'end' |
|
| 3114 | - ); |
|
| 3115 | - |
|
| 3116 | - $new_settings[] = $geodir_bcc_listing_published_yes; |
|
| 3117 | - $new_settings[] = $geodir_bcc_listing_published_no; |
|
| 3118 | - } |
|
| 3119 | - $new_settings[] = $setting; |
|
| 3120 | - } |
|
| 3121 | - $settings = $new_settings; |
|
| 3122 | - } |
|
| 3092 | + if (!empty($settings)) {
|
|
| 3093 | + $new_settings = array(); |
|
| 3094 | + foreach ($settings as $setting) {
|
|
| 3095 | + if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
|
|
| 3096 | + $geodir_bcc_listing_published_yes = array( |
|
| 3097 | + 'name' => __('Listing published', 'geodirectory'),
|
|
| 3098 | + 'desc' => __('Yes', 'geodirectory'),
|
|
| 3099 | + 'id' => 'geodir_bcc_listing_published', |
|
| 3100 | + 'std' => 'yes', |
|
| 3101 | + 'type' => 'radio', |
|
| 3102 | + 'value' => '1', |
|
| 3103 | + 'radiogroup' => 'start' |
|
| 3104 | + ); |
|
| 3105 | + |
|
| 3106 | + $geodir_bcc_listing_published_no = array( |
|
| 3107 | + 'name' => __('Listing published', 'geodirectory'),
|
|
| 3108 | + 'desc' => __('No', 'geodirectory'),
|
|
| 3109 | + 'id' => 'geodir_bcc_listing_published', |
|
| 3110 | + 'std' => 'yes', |
|
| 3111 | + 'type' => 'radio', |
|
| 3112 | + 'value' => '0', |
|
| 3113 | + 'radiogroup' => 'end' |
|
| 3114 | + ); |
|
| 3115 | + |
|
| 3116 | + $new_settings[] = $geodir_bcc_listing_published_yes; |
|
| 3117 | + $new_settings[] = $geodir_bcc_listing_published_no; |
|
| 3118 | + } |
|
| 3119 | + $new_settings[] = $setting; |
|
| 3120 | + } |
|
| 3121 | + $settings = $new_settings; |
|
| 3122 | + } |
|
| 3123 | 3123 | |
| 3124 | - return $settings; |
|
| 3124 | + return $settings; |
|
| 3125 | 3125 | } |
| 3126 | 3126 | |
| 3127 | 3127 | |
@@ -3136,19 +3136,19 @@ discard block |
||
| 3136 | 3136 | */ |
| 3137 | 3137 | function get_gd_theme_compat_callback() |
| 3138 | 3138 | {
|
| 3139 | - global $wpdb; |
|
| 3140 | - $themes = get_option('gd_theme_compats');
|
|
| 3141 | - |
|
| 3142 | - if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
|
|
| 3143 | - if (isset($_POST['export'])) {
|
|
| 3144 | - echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
| 3145 | - } else {
|
|
| 3146 | - echo json_encode($themes[$_POST['theme']]); |
|
| 3147 | - } |
|
| 3139 | + global $wpdb; |
|
| 3140 | + $themes = get_option('gd_theme_compats');
|
|
| 3148 | 3141 | |
| 3149 | - } |
|
| 3142 | + if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
|
|
| 3143 | + if (isset($_POST['export'])) {
|
|
| 3144 | + echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
| 3145 | + } else {
|
|
| 3146 | + echo json_encode($themes[$_POST['theme']]); |
|
| 3147 | + } |
|
| 3148 | + |
|
| 3149 | + } |
|
| 3150 | 3150 | |
| 3151 | - die(); |
|
| 3151 | + die(); |
|
| 3152 | 3152 | } |
| 3153 | 3153 | |
| 3154 | 3154 | add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback');
|
@@ -3162,20 +3162,20 @@ discard block |
||
| 3162 | 3162 | */ |
| 3163 | 3163 | function get_gd_theme_compat_import_callback() |
| 3164 | 3164 | {
|
| 3165 | - global $wpdb; |
|
| 3166 | - $themes = get_option('gd_theme_compats');
|
|
| 3167 | - if (isset($_POST['theme']) && !empty($_POST['theme'])) {
|
|
| 3168 | - $json = json_decode(stripslashes($_POST['theme']), true); |
|
| 3169 | - if (!empty($json) && is_array($json)) {
|
|
| 3170 | - $key = sanitize_text_field(key($json)); |
|
| 3171 | - $themes[$key] = $json[$key]; |
|
| 3172 | - update_option('gd_theme_compats', $themes);
|
|
| 3173 | - echo $key; |
|
| 3174 | - die(); |
|
| 3175 | - } |
|
| 3176 | - } |
|
| 3177 | - echo '0'; |
|
| 3178 | - die(); |
|
| 3165 | + global $wpdb; |
|
| 3166 | + $themes = get_option('gd_theme_compats');
|
|
| 3167 | + if (isset($_POST['theme']) && !empty($_POST['theme'])) {
|
|
| 3168 | + $json = json_decode(stripslashes($_POST['theme']), true); |
|
| 3169 | + if (!empty($json) && is_array($json)) {
|
|
| 3170 | + $key = sanitize_text_field(key($json)); |
|
| 3171 | + $themes[$key] = $json[$key]; |
|
| 3172 | + update_option('gd_theme_compats', $themes);
|
|
| 3173 | + echo $key; |
|
| 3174 | + die(); |
|
| 3175 | + } |
|
| 3176 | + } |
|
| 3177 | + echo '0'; |
|
| 3178 | + die(); |
|
| 3179 | 3179 | } |
| 3180 | 3180 | |
| 3181 | 3181 | |
@@ -3188,39 +3188,39 @@ discard block |
||
| 3188 | 3188 | */ |
| 3189 | 3189 | function gd_set_theme_compat() |
| 3190 | 3190 | {
|
| 3191 | - global $wpdb; |
|
| 3192 | - $theme = wp_get_theme(); |
|
| 3191 | + global $wpdb; |
|
| 3192 | + $theme = wp_get_theme(); |
|
| 3193 | 3193 | |
| 3194 | - if ($theme->parent()) {
|
|
| 3195 | - $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
|
|
| 3196 | - } else {
|
|
| 3197 | - $theme_name = str_replace(" ", "_", $theme->get('Name'));
|
|
| 3198 | - } |
|
| 3194 | + if ($theme->parent()) {
|
|
| 3195 | + $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
|
|
| 3196 | + } else {
|
|
| 3197 | + $theme_name = str_replace(" ", "_", $theme->get('Name'));
|
|
| 3198 | + } |
|
| 3199 | 3199 | |
| 3200 | - $theme_compats = get_option('gd_theme_compats');
|
|
| 3201 | - $current_compat = get_option('gd_theme_compat');
|
|
| 3202 | - $current_compat = str_replace("_custom", "", $current_compat);
|
|
| 3200 | + $theme_compats = get_option('gd_theme_compats');
|
|
| 3201 | + $current_compat = get_option('gd_theme_compat');
|
|
| 3202 | + $current_compat = str_replace("_custom", "", $current_compat);
|
|
| 3203 | 3203 | |
| 3204 | - if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
|
|
| 3205 | - return; |
|
| 3206 | - }// if already running corect compat then bail |
|
| 3204 | + if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
|
|
| 3205 | + return; |
|
| 3206 | + }// if already running corect compat then bail |
|
| 3207 | 3207 | |
| 3208 | - if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
|
|
| 3209 | - update_option('gd_theme_compat', $theme_name);
|
|
| 3210 | - update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
|
|
| 3208 | + if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
|
|
| 3209 | + update_option('gd_theme_compat', $theme_name);
|
|
| 3210 | + update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
|
|
| 3211 | 3211 | |
| 3212 | - // if there are default options to set then set them |
|
| 3213 | - if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
|
|
| 3212 | + // if there are default options to set then set them |
|
| 3213 | + if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
|
|
| 3214 | 3214 | |
| 3215 | - foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
|
|
| 3216 | - update_option($key, $val); |
|
| 3217 | - } |
|
| 3218 | - } |
|
| 3215 | + foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
|
|
| 3216 | + update_option($key, $val); |
|
| 3217 | + } |
|
| 3218 | + } |
|
| 3219 | 3219 | |
| 3220 | - } else {
|
|
| 3221 | - update_option('gd_theme_compat', '');
|
|
| 3222 | - update_option('theme_compatibility_setting', '');
|
|
| 3223 | - } |
|
| 3220 | + } else {
|
|
| 3221 | + update_option('gd_theme_compat', '');
|
|
| 3222 | + update_option('theme_compatibility_setting', '');
|
|
| 3223 | + } |
|
| 3224 | 3224 | |
| 3225 | 3225 | |
| 3226 | 3226 | } |
@@ -3235,9 +3235,9 @@ discard block |
||
| 3235 | 3235 | */ |
| 3236 | 3236 | function gd_check_avada_compat() |
| 3237 | 3237 | {
|
| 3238 | - if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
|
|
| 3239 | - add_action('admin_notices', 'gd_avada_compat_warning');
|
|
| 3240 | - } |
|
| 3238 | + if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
|
|
| 3239 | + add_action('admin_notices', 'gd_avada_compat_warning');
|
|
| 3240 | + } |
|
| 3241 | 3241 | } |
| 3242 | 3242 | |
| 3243 | 3243 | |
@@ -3250,22 +3250,22 @@ discard block |
||
| 3250 | 3250 | function gd_avada_compat_warning() |
| 3251 | 3251 | {
|
| 3252 | 3252 | |
| 3253 | - /* |
|
| 3253 | + /* |
|
| 3254 | 3254 | $msg_type = error |
| 3255 | 3255 | $msg_type = updated fade |
| 3256 | 3256 | $msg_type = update-nag |
| 3257 | 3257 | */ |
| 3258 | 3258 | |
| 3259 | - $plugin = 'avada-nag'; |
|
| 3260 | - $timestamp = 'avada-nag1234'; |
|
| 3261 | - $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');
|
|
| 3262 | - echo '<div id="' . $timestamp . '" class="error">'; |
|
| 3263 | - echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
| 3264 | - echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 3265 | - echo "<p>$message</p>"; |
|
| 3266 | - echo "</div>"; |
|
| 3259 | + $plugin = 'avada-nag'; |
|
| 3260 | + $timestamp = 'avada-nag1234'; |
|
| 3261 | + $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');
|
|
| 3262 | + echo '<div id="' . $timestamp . '" class="error">'; |
|
| 3263 | + echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
| 3264 | + echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 3265 | + echo "<p>$message</p>"; |
|
| 3266 | + echo "</div>"; |
|
| 3267 | 3267 | |
| 3268 | - ?> |
|
| 3268 | + ?> |
|
| 3269 | 3269 | <script> |
| 3270 | 3270 | function gdRemoveANotification($plugin, $timestamp) {
|
| 3271 | 3271 | |
@@ -3333,10 +3333,10 @@ discard block |
||
| 3333 | 3333 | */ |
| 3334 | 3334 | function geodir_avada_remove_notification() |
| 3335 | 3335 | {
|
| 3336 | - update_option('avada_nag', TRUE);
|
|
| 3336 | + update_option('avada_nag', TRUE);
|
|
| 3337 | 3337 | |
| 3338 | - // Always die in functions echoing ajax content |
|
| 3339 | - die(); |
|
| 3338 | + // Always die in functions echoing ajax content |
|
| 3339 | + die(); |
|
| 3340 | 3340 | } |
| 3341 | 3341 | |
| 3342 | 3342 | |
@@ -3395,7 +3395,7 @@ discard block |
||
| 3395 | 3395 | // Don't allow same slug url for listing and location |
| 3396 | 3396 | if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
|
| 3397 | 3397 | $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
|
| 3398 | - wp_redirect($redirect_url); |
|
| 3398 | + wp_redirect($redirect_url); |
|
| 3399 | 3399 | exit; |
| 3400 | 3400 | } |
| 3401 | 3401 | |
@@ -3425,10 +3425,10 @@ discard block |
||
| 3425 | 3425 | * @package GeoDirectory |
| 3426 | 3426 | */ |
| 3427 | 3427 | function geodir_hide_admin_preview_button() {
|
| 3428 | - global $post_type; |
|
| 3429 | - $post_types = geodir_get_posttypes(); |
|
| 3430 | - if(in_array($post_type, $post_types)) |
|
| 3431 | - echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
|
| 3428 | + global $post_type; |
|
| 3429 | + $post_types = geodir_get_posttypes(); |
|
| 3430 | + if(in_array($post_type, $post_types)) |
|
| 3431 | + echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
|
| 3432 | 3432 | } |
| 3433 | 3433 | add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' ); |
| 3434 | 3434 | add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' ); |
@@ -3443,7 +3443,7 @@ discard block |
||
| 3443 | 3443 | */ |
| 3444 | 3444 | function geodir_import_export_tab( $tabs ) {
|
| 3445 | 3445 | $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
| 3446 | - return $tabs; |
|
| 3446 | + return $tabs; |
|
| 3447 | 3447 | } |
| 3448 | 3448 | |
| 3449 | 3449 | /** |
@@ -3458,26 +3458,26 @@ discard block |
||
| 3458 | 3458 | function geodir_import_export_page() {
|
| 3459 | 3459 | $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
| 3460 | 3460 | $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
| 3461 | - /** |
|
| 3462 | - * Filter sample category data csv file url. |
|
| 3463 | - * |
|
| 3464 | - * @since 1.0.0 |
|
| 3465 | - * @package GeoDirectory |
|
| 3466 | - * |
|
| 3467 | - * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
| 3468 | - */ |
|
| 3461 | + /** |
|
| 3462 | + * Filter sample category data csv file url. |
|
| 3463 | + * |
|
| 3464 | + * @since 1.0.0 |
|
| 3465 | + * @package GeoDirectory |
|
| 3466 | + * |
|
| 3467 | + * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
| 3468 | + */ |
|
| 3469 | 3469 | $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
| 3470 | 3470 | |
| 3471 | 3471 | $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
| 3472 | - /** |
|
| 3473 | - * Filter sample post data csv file url. |
|
| 3474 | - * |
|
| 3475 | - * @since 1.0.0 |
|
| 3476 | - * @package GeoDirectory |
|
| 3477 | - * |
|
| 3478 | - * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
| 3479 | - */ |
|
| 3480 | - $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 3472 | + /** |
|
| 3473 | + * Filter sample post data csv file url. |
|
| 3474 | + * |
|
| 3475 | + * @since 1.0.0 |
|
| 3476 | + * @package GeoDirectory |
|
| 3477 | + * |
|
| 3478 | + * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
| 3479 | + */ |
|
| 3480 | + $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 3481 | 3481 | |
| 3482 | 3482 | $gd_posttypes = geodir_get_posttypes( 'array' ); |
| 3483 | 3483 | |
@@ -3500,14 +3500,14 @@ discard block |
||
| 3500 | 3500 | $gd_chunksize_options[100000] = 100000; |
| 3501 | 3501 | |
| 3502 | 3502 | /** |
| 3503 | - * Filter max entries per export csv file. |
|
| 3504 | - * |
|
| 3505 | - * @since 1.5.6 |
|
| 3506 | - * @package GeoDirectory |
|
| 3507 | - * |
|
| 3508 | - * @param string $gd_chunksize_options Entries options. |
|
| 3509 | - */ |
|
| 3510 | - $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 3503 | + * Filter max entries per export csv file. |
|
| 3504 | + * |
|
| 3505 | + * @since 1.5.6 |
|
| 3506 | + * @package GeoDirectory |
|
| 3507 | + * |
|
| 3508 | + * @param string $gd_chunksize_options Entries options. |
|
| 3509 | + */ |
|
| 3510 | + $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 3511 | 3511 | |
| 3512 | 3512 | $gd_chunksize_option = ''; |
| 3513 | 3513 | foreach ($gd_chunksize_options as $value => $title) {
|
@@ -3523,12 +3523,12 @@ discard block |
||
| 3523 | 3523 | <div class="gd-content-heading"> |
| 3524 | 3524 | |
| 3525 | 3525 | <?php |
| 3526 | - ini_set('max_execution_time', 999999);
|
|
| 3527 | - $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 3528 | - ini_restore('max_execution_time');
|
|
| 3526 | + ini_set('max_execution_time', 999999);
|
|
| 3527 | + $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 3528 | + ini_restore('max_execution_time');
|
|
| 3529 | 3529 | |
| 3530 | - if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 3531 | - ?> |
|
| 3530 | + if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 3531 | + ?> |
|
| 3532 | 3532 | <div id="gd_ie_reqs" class="metabox-holder"> |
| 3533 | 3533 | <div class="meta-box-sortables ui-sortable"> |
| 3534 | 3534 | <div class="postbox"> |
@@ -3694,7 +3694,7 @@ discard block |
||
| 3694 | 3694 | * Called just after the sample CSV download link. |
| 3695 | 3695 | * |
| 3696 | 3696 | * @since 1.0.0 |
| 3697 | - * @package GeoDirectory |
|
| 3697 | + * @package GeoDirectory |
|
| 3698 | 3698 | */ |
| 3699 | 3699 | do_action('geodir_sample_cats_csv_download_link');
|
| 3700 | 3700 | ?> |
@@ -3778,11 +3778,11 @@ discard block |
||
| 3778 | 3778 | * |
| 3779 | 3779 | * Called after the last setting on the GD > Import & Export page. |
| 3780 | 3780 | * @since 1.4.6 |
| 3781 | - * @package GeoDirectory |
|
| 3781 | + * @package GeoDirectory |
|
| 3782 | 3782 | * |
| 3783 | 3783 | * @param array $gd_posttypes GD post types. |
| 3784 | - * @param array $gd_chunksize_options File chunk size options. |
|
| 3785 | - * @param string $nonce Wordpress security token for GD import & export. |
|
| 3784 | + * @param array $gd_chunksize_options File chunk size options. |
|
| 3785 | + * @param string $nonce Wordpress security token for GD import & export. |
|
| 3786 | 3786 | */ |
| 3787 | 3787 | do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
| 3788 | 3788 | ?> |
@@ -4422,44 +4422,44 @@ discard block |
||
| 4422 | 4422 | function geodir_init_filesystem() |
| 4423 | 4423 | {
|
| 4424 | 4424 | |
| 4425 | - if(!function_exists('get_filesystem_method')){
|
|
| 4426 | - require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
| 4427 | - } |
|
| 4428 | - $access_type = get_filesystem_method(); |
|
| 4429 | - if ($access_type === 'direct') {
|
|
| 4430 | - /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
| 4431 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 4432 | - |
|
| 4433 | - /* initialize the API */ |
|
| 4434 | - if (!WP_Filesystem($creds)) {
|
|
| 4435 | - /* any problems and we exit */ |
|
| 4436 | - //return '@@@3'; |
|
| 4437 | - return false; |
|
| 4438 | - } |
|
| 4425 | + if(!function_exists('get_filesystem_method')){
|
|
| 4426 | + require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
| 4427 | + } |
|
| 4428 | + $access_type = get_filesystem_method(); |
|
| 4429 | + if ($access_type === 'direct') {
|
|
| 4430 | + /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
| 4431 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 4432 | + |
|
| 4433 | + /* initialize the API */ |
|
| 4434 | + if (!WP_Filesystem($creds)) {
|
|
| 4435 | + /* any problems and we exit */ |
|
| 4436 | + //return '@@@3'; |
|
| 4437 | + return false; |
|
| 4438 | + } |
|
| 4439 | 4439 | |
| 4440 | - global $wp_filesystem; |
|
| 4441 | - return $wp_filesystem; |
|
| 4442 | - /* do our file manipulations below */ |
|
| 4443 | - } elseif (defined('FTP_USER')) {
|
|
| 4444 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 4445 | - |
|
| 4446 | - /* initialize the API */ |
|
| 4447 | - if (!WP_Filesystem($creds)) {
|
|
| 4448 | - /* any problems and we exit */ |
|
| 4449 | - //return '@@@33'; |
|
| 4450 | - return false; |
|
| 4451 | - } |
|
| 4440 | + global $wp_filesystem; |
|
| 4441 | + return $wp_filesystem; |
|
| 4442 | + /* do our file manipulations below */ |
|
| 4443 | + } elseif (defined('FTP_USER')) {
|
|
| 4444 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 4452 | 4445 | |
| 4453 | - global $wp_filesystem; |
|
| 4454 | - //return '@@@1'; |
|
| 4455 | - return $wp_filesystem; |
|
| 4446 | + /* initialize the API */ |
|
| 4447 | + if (!WP_Filesystem($creds)) {
|
|
| 4448 | + /* any problems and we exit */ |
|
| 4449 | + //return '@@@33'; |
|
| 4450 | + return false; |
|
| 4451 | + } |
|
| 4456 | 4452 | |
| 4457 | - } else {
|
|
| 4458 | - //return '@@@2'; |
|
| 4459 | - /* don't have direct write access. Prompt user with our notice */ |
|
| 4460 | - add_action('admin_notice', 'geodir_filesystem_notice');
|
|
| 4461 | - return false; |
|
| 4462 | - } |
|
| 4453 | + global $wp_filesystem; |
|
| 4454 | + //return '@@@1'; |
|
| 4455 | + return $wp_filesystem; |
|
| 4456 | + |
|
| 4457 | + } else {
|
|
| 4458 | + //return '@@@2'; |
|
| 4459 | + /* don't have direct write access. Prompt user with our notice */ |
|
| 4460 | + add_action('admin_notice', 'geodir_filesystem_notice');
|
|
| 4461 | + return false; |
|
| 4462 | + } |
|
| 4463 | 4463 | |
| 4464 | 4464 | } |
| 4465 | 4465 | |
@@ -4477,10 +4477,10 @@ discard block |
||
| 4477 | 4477 | */ |
| 4478 | 4478 | function geodir_filesystem_notice() |
| 4479 | 4479 | { if ( defined( 'DOING_AJAX' ) ){return;}
|
| 4480 | - $access_type = get_filesystem_method(); |
|
| 4481 | - if ($access_type === 'direct') {
|
|
| 4482 | - } elseif (!defined('FTP_USER')) {
|
|
| 4483 | - ?> |
|
| 4480 | + $access_type = get_filesystem_method(); |
|
| 4481 | + if ($access_type === 'direct') {
|
|
| 4482 | + } elseif (!defined('FTP_USER')) {
|
|
| 4483 | + ?> |
|
| 4484 | 4484 | <div class="error"> |
| 4485 | 4485 | <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'); ?>
|
| 4486 | 4486 | <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> |
@@ -4506,1235 +4506,1235 @@ discard block |
||
| 4506 | 4506 | * @return string Json data. |
| 4507 | 4507 | */ |
| 4508 | 4508 | function geodir_ajax_import_export() {
|
| 4509 | - global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 4509 | + global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 4510 | 4510 | |
| 4511 | - error_reporting(0); |
|
| 4511 | + error_reporting(0); |
|
| 4512 | 4512 | |
| 4513 | - // try to set higher limits for import |
|
| 4514 | - $max_input_time = ini_get('max_input_time');
|
|
| 4515 | - $max_execution_time = ini_get('max_execution_time');
|
|
| 4516 | - $memory_limit= ini_get('memory_limit');
|
|
| 4513 | + // try to set higher limits for import |
|
| 4514 | + $max_input_time = ini_get('max_input_time');
|
|
| 4515 | + $max_execution_time = ini_get('max_execution_time');
|
|
| 4516 | + $memory_limit= ini_get('memory_limit');
|
|
| 4517 | 4517 | |
| 4518 | - if(!$max_input_time || $max_input_time<3000){
|
|
| 4519 | - ini_set('max_input_time', 3000);
|
|
| 4520 | - } |
|
| 4518 | + if(!$max_input_time || $max_input_time<3000){
|
|
| 4519 | + ini_set('max_input_time', 3000);
|
|
| 4520 | + } |
|
| 4521 | 4521 | |
| 4522 | - if(!$max_execution_time || $max_execution_time<3000){
|
|
| 4523 | - ini_set('max_execution_time', 3000);
|
|
| 4524 | - } |
|
| 4522 | + if(!$max_execution_time || $max_execution_time<3000){
|
|
| 4523 | + ini_set('max_execution_time', 3000);
|
|
| 4524 | + } |
|
| 4525 | 4525 | |
| 4526 | - if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 4527 | - if(str_replace('M','',$memory_limit)<256){
|
|
| 4528 | - ini_set('memory_limit', '256M');
|
|
| 4529 | - } |
|
| 4530 | - } |
|
| 4526 | + if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 4527 | + if(str_replace('M','',$memory_limit)<256){
|
|
| 4528 | + ini_set('memory_limit', '256M');
|
|
| 4529 | + } |
|
| 4530 | + } |
|
| 4531 | 4531 | |
| 4532 | - $json = array(); |
|
| 4532 | + $json = array(); |
|
| 4533 | 4533 | |
| 4534 | - if ( !current_user_can( 'manage_options' ) ) {
|
|
| 4535 | - wp_send_json( $json ); |
|
| 4536 | - } |
|
| 4534 | + if ( !current_user_can( 'manage_options' ) ) {
|
|
| 4535 | + wp_send_json( $json ); |
|
| 4536 | + } |
|
| 4537 | 4537 | |
| 4538 | - $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 4539 | - $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 4540 | - $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 4538 | + $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 4539 | + $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 4540 | + $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 4541 | 4541 | |
| 4542 | - if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 4543 | - wp_send_json( $json ); |
|
| 4544 | - } |
|
| 4542 | + if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 4543 | + wp_send_json( $json ); |
|
| 4544 | + } |
|
| 4545 | 4545 | |
| 4546 | - $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 4547 | - $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 4548 | - $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 4549 | - $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 4546 | + $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 4547 | + $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 4548 | + $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 4549 | + $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 4550 | 4550 | |
| 4551 | - $wp_filesystem = geodir_init_filesystem(); |
|
| 4552 | - if (!$wp_filesystem) {
|
|
| 4553 | - $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 4554 | - wp_send_json( $json ); |
|
| 4555 | - } |
|
| 4551 | + $wp_filesystem = geodir_init_filesystem(); |
|
| 4552 | + if (!$wp_filesystem) {
|
|
| 4553 | + $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 4554 | + wp_send_json( $json ); |
|
| 4555 | + } |
|
| 4556 | 4556 | |
| 4557 | - if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 4558 | - $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 4559 | - wp_send_json( $json ); |
|
| 4560 | - } |
|
| 4557 | + if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 4558 | + $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 4559 | + wp_send_json( $json ); |
|
| 4560 | + } |
|
| 4561 | 4561 | |
| 4562 | - $csv_file_dir = geodir_path_import_export( false ); |
|
| 4563 | - if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 4564 | - if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 4565 | - $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4566 | - wp_send_json( $json ); |
|
| 4567 | - } |
|
| 4568 | - } |
|
| 4562 | + $csv_file_dir = geodir_path_import_export( false ); |
|
| 4563 | + if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 4564 | + if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 4565 | + $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4566 | + wp_send_json( $json ); |
|
| 4567 | + } |
|
| 4568 | + } |
|
| 4569 | 4569 | |
| 4570 | - switch ( $task ) {
|
|
| 4571 | - case 'export_posts': {
|
|
| 4572 | - // WPML |
|
| 4573 | - $is_wpml = geodir_is_wpml(); |
|
| 4574 | - if ($is_wpml) {
|
|
| 4575 | - global $sitepress; |
|
| 4576 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 4570 | + switch ( $task ) {
|
|
| 4571 | + case 'export_posts': {
|
|
| 4572 | + // WPML |
|
| 4573 | + $is_wpml = geodir_is_wpml(); |
|
| 4574 | + if ($is_wpml) {
|
|
| 4575 | + global $sitepress; |
|
| 4576 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 4577 | 4577 | |
| 4578 | - $sitepress->switch_lang('all', true);
|
|
| 4579 | - } |
|
| 4580 | - // WPML |
|
| 4581 | - if ( $post_type == 'gd_event' ) {
|
|
| 4582 | - //add_filter( 'geodir_imex_count_posts', 'geodir_imex_count_events', 10, 2 ); |
|
| 4583 | - add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 4584 | - } |
|
| 4585 | - $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 4586 | - $posts_count = geodir_get_posts_count( $post_type ); |
|
| 4587 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 4588 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4589 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4590 | - $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 4578 | + $sitepress->switch_lang('all', true);
|
|
| 4579 | + } |
|
| 4580 | + // WPML |
|
| 4581 | + if ( $post_type == 'gd_event' ) {
|
|
| 4582 | + //add_filter( 'geodir_imex_count_posts', 'geodir_imex_count_events', 10, 2 ); |
|
| 4583 | + add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 4584 | + } |
|
| 4585 | + $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 4586 | + $posts_count = geodir_get_posts_count( $post_type ); |
|
| 4587 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 4588 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4589 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4590 | + $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 4591 | 4591 | |
| 4592 | - $chunk_file_paths = array(); |
|
| 4592 | + $chunk_file_paths = array(); |
|
| 4593 | 4593 | |
| 4594 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4595 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4596 | - $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 4597 | - $percentage = min( $percentage, 100 ); |
|
| 4594 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4595 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4596 | + $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 4597 | + $percentage = min( $percentage, 100 ); |
|
| 4598 | 4598 | |
| 4599 | - $json['percentage'] = $percentage; |
|
| 4600 | - // WPML |
|
| 4601 | - if ($is_wpml) {
|
|
| 4602 | - $sitepress->switch_lang($active_lang, true); |
|
| 4603 | - } |
|
| 4604 | - // WPML |
|
| 4605 | - wp_send_json( $json ); |
|
| 4606 | - exit; |
|
| 4607 | - } else {
|
|
| 4608 | - if ( !$posts_count > 0 ) {
|
|
| 4609 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4610 | - } else {
|
|
| 4611 | - $total_posts = $posts_count; |
|
| 4612 | - if ($chunk_per_page > $total_posts) {
|
|
| 4613 | - $chunk_per_page = $total_posts; |
|
| 4614 | - } |
|
| 4615 | - $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 4599 | + $json['percentage'] = $percentage; |
|
| 4600 | + // WPML |
|
| 4601 | + if ($is_wpml) {
|
|
| 4602 | + $sitepress->switch_lang($active_lang, true); |
|
| 4603 | + } |
|
| 4604 | + // WPML |
|
| 4605 | + wp_send_json( $json ); |
|
| 4606 | + exit; |
|
| 4607 | + } else {
|
|
| 4608 | + if ( !$posts_count > 0 ) {
|
|
| 4609 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4610 | + } else {
|
|
| 4611 | + $total_posts = $posts_count; |
|
| 4612 | + if ($chunk_per_page > $total_posts) {
|
|
| 4613 | + $chunk_per_page = $total_posts; |
|
| 4614 | + } |
|
| 4615 | + $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 4616 | 4616 | |
| 4617 | - $j = $chunk_page_no; |
|
| 4618 | - $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 4617 | + $j = $chunk_page_no; |
|
| 4618 | + $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 4619 | 4619 | |
| 4620 | - $per_page = 500; |
|
| 4621 | - if ($per_page > $chunk_per_page) {
|
|
| 4622 | - $per_page = $chunk_per_page; |
|
| 4623 | - } |
|
| 4624 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4620 | + $per_page = 500; |
|
| 4621 | + if ($per_page > $chunk_per_page) {
|
|
| 4622 | + $per_page = $chunk_per_page; |
|
| 4623 | + } |
|
| 4624 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4625 | 4625 | |
| 4626 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4627 | - $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 4626 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4627 | + $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 4628 | 4628 | |
| 4629 | - $clear = $i == 0 ? true : false; |
|
| 4630 | - geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 4631 | - } |
|
| 4629 | + $clear = $i == 0 ? true : false; |
|
| 4630 | + geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 4631 | + } |
|
| 4632 | 4632 | |
| 4633 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4634 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4635 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4636 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4637 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4633 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4634 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4635 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4636 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4637 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4638 | 4638 | |
| 4639 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 4640 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4641 | - } |
|
| 4639 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 4640 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4641 | + } |
|
| 4642 | 4642 | |
| 4643 | - if ( !empty($chunk_file_paths) ) {
|
|
| 4644 | - $json['total'] = $posts_count; |
|
| 4645 | - $json['files'] = $chunk_file_paths; |
|
| 4646 | - } else {
|
|
| 4647 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4648 | - } |
|
| 4649 | - } |
|
| 4650 | - // WPML |
|
| 4651 | - if ($is_wpml) {
|
|
| 4652 | - $sitepress->switch_lang($active_lang, true); |
|
| 4653 | - } |
|
| 4654 | - // WPML |
|
| 4655 | - wp_send_json( $json ); |
|
| 4656 | - } |
|
| 4657 | - } |
|
| 4658 | - break; |
|
| 4659 | - case 'export_cats': {
|
|
| 4660 | - // WPML |
|
| 4661 | - $is_wpml = geodir_is_wpml(); |
|
| 4662 | - if ($is_wpml) {
|
|
| 4663 | - global $sitepress; |
|
| 4664 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 4643 | + if ( !empty($chunk_file_paths) ) {
|
|
| 4644 | + $json['total'] = $posts_count; |
|
| 4645 | + $json['files'] = $chunk_file_paths; |
|
| 4646 | + } else {
|
|
| 4647 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4648 | + } |
|
| 4649 | + } |
|
| 4650 | + // WPML |
|
| 4651 | + if ($is_wpml) {
|
|
| 4652 | + $sitepress->switch_lang($active_lang, true); |
|
| 4653 | + } |
|
| 4654 | + // WPML |
|
| 4655 | + wp_send_json( $json ); |
|
| 4656 | + } |
|
| 4657 | + } |
|
| 4658 | + break; |
|
| 4659 | + case 'export_cats': {
|
|
| 4660 | + // WPML |
|
| 4661 | + $is_wpml = geodir_is_wpml(); |
|
| 4662 | + if ($is_wpml) {
|
|
| 4663 | + global $sitepress; |
|
| 4664 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 4665 | 4665 | |
| 4666 | - $sitepress->switch_lang('all', true);
|
|
| 4667 | - } |
|
| 4668 | - // WPML |
|
| 4669 | - $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 4666 | + $sitepress->switch_lang('all', true);
|
|
| 4667 | + } |
|
| 4668 | + // WPML |
|
| 4669 | + $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 4670 | 4670 | |
| 4671 | - $terms_count = geodir_get_terms_count( $post_type ); |
|
| 4672 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 4673 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4674 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4675 | - $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 4671 | + $terms_count = geodir_get_terms_count( $post_type ); |
|
| 4672 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 4673 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4674 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4675 | + $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 4676 | 4676 | |
| 4677 | - $chunk_file_paths = array(); |
|
| 4677 | + $chunk_file_paths = array(); |
|
| 4678 | 4678 | |
| 4679 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4680 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4681 | - $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 4682 | - $percentage = min( $percentage, 100 ); |
|
| 4679 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4680 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4681 | + $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 4682 | + $percentage = min( $percentage, 100 ); |
|
| 4683 | 4683 | |
| 4684 | - $json['percentage'] = $percentage; |
|
| 4685 | - // WPML |
|
| 4686 | - if ($is_wpml) {
|
|
| 4687 | - $sitepress->switch_lang($active_lang, true); |
|
| 4688 | - } |
|
| 4689 | - // WPML |
|
| 4690 | - wp_send_json( $json ); |
|
| 4691 | - } else {
|
|
| 4692 | - if ( !$terms_count > 0 ) {
|
|
| 4693 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4694 | - } else {
|
|
| 4695 | - $total_terms = $terms_count; |
|
| 4696 | - if ($chunk_per_page > $terms_count) {
|
|
| 4697 | - $chunk_per_page = $terms_count; |
|
| 4698 | - } |
|
| 4699 | - $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 4684 | + $json['percentage'] = $percentage; |
|
| 4685 | + // WPML |
|
| 4686 | + if ($is_wpml) {
|
|
| 4687 | + $sitepress->switch_lang($active_lang, true); |
|
| 4688 | + } |
|
| 4689 | + // WPML |
|
| 4690 | + wp_send_json( $json ); |
|
| 4691 | + } else {
|
|
| 4692 | + if ( !$terms_count > 0 ) {
|
|
| 4693 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4694 | + } else {
|
|
| 4695 | + $total_terms = $terms_count; |
|
| 4696 | + if ($chunk_per_page > $terms_count) {
|
|
| 4697 | + $chunk_per_page = $terms_count; |
|
| 4698 | + } |
|
| 4699 | + $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 4700 | 4700 | |
| 4701 | - $j = $chunk_page_no; |
|
| 4702 | - $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 4701 | + $j = $chunk_page_no; |
|
| 4702 | + $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 4703 | 4703 | |
| 4704 | - $per_page = 500; |
|
| 4705 | - if ($per_page > $chunk_per_page) {
|
|
| 4706 | - $per_page = $chunk_per_page; |
|
| 4707 | - } |
|
| 4708 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4704 | + $per_page = 500; |
|
| 4705 | + if ($per_page > $chunk_per_page) {
|
|
| 4706 | + $per_page = $chunk_per_page; |
|
| 4707 | + } |
|
| 4708 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4709 | 4709 | |
| 4710 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4711 | - $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 4710 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4711 | + $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 4712 | 4712 | |
| 4713 | - $clear = $i == 0 ? true : false; |
|
| 4714 | - geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 4715 | - } |
|
| 4713 | + $clear = $i == 0 ? true : false; |
|
| 4714 | + geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 4715 | + } |
|
| 4716 | 4716 | |
| 4717 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4718 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4719 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4720 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4721 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4717 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4718 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4719 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4720 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4721 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4722 | 4722 | |
| 4723 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 4724 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4725 | - } |
|
| 4723 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 4724 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4725 | + } |
|
| 4726 | 4726 | |
| 4727 | - if ( !empty($chunk_file_paths) ) {
|
|
| 4728 | - $json['total'] = $terms_count; |
|
| 4729 | - $json['files'] = $chunk_file_paths; |
|
| 4730 | - } else {
|
|
| 4731 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4732 | - } |
|
| 4733 | - } |
|
| 4734 | - // WPML |
|
| 4735 | - if ($is_wpml) {
|
|
| 4736 | - $sitepress->switch_lang($active_lang, true); |
|
| 4737 | - } |
|
| 4738 | - // WPML |
|
| 4739 | - wp_send_json( $json ); |
|
| 4740 | - } |
|
| 4741 | - } |
|
| 4742 | - break; |
|
| 4743 | - case 'export_locations': {
|
|
| 4744 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 4745 | - $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 4746 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4747 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4748 | - $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 4727 | + if ( !empty($chunk_file_paths) ) {
|
|
| 4728 | + $json['total'] = $terms_count; |
|
| 4729 | + $json['files'] = $chunk_file_paths; |
|
| 4730 | + } else {
|
|
| 4731 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4732 | + } |
|
| 4733 | + } |
|
| 4734 | + // WPML |
|
| 4735 | + if ($is_wpml) {
|
|
| 4736 | + $sitepress->switch_lang($active_lang, true); |
|
| 4737 | + } |
|
| 4738 | + // WPML |
|
| 4739 | + wp_send_json( $json ); |
|
| 4740 | + } |
|
| 4741 | + } |
|
| 4742 | + break; |
|
| 4743 | + case 'export_locations': {
|
|
| 4744 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 4745 | + $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 4746 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4747 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4748 | + $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 4749 | 4749 | |
| 4750 | - $items_count = (int)geodir_location_imex_count_locations(); |
|
| 4750 | + $items_count = (int)geodir_location_imex_count_locations(); |
|
| 4751 | 4751 | |
| 4752 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4753 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4754 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 4755 | - $percentage = min( $percentage, 100 ); |
|
| 4752 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4753 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4754 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 4755 | + $percentage = min( $percentage, 100 ); |
|
| 4756 | 4756 | |
| 4757 | - $json['percentage'] = $percentage; |
|
| 4758 | - wp_send_json( $json ); |
|
| 4759 | - } else {
|
|
| 4760 | - $chunk_file_paths = array(); |
|
| 4757 | + $json['percentage'] = $percentage; |
|
| 4758 | + wp_send_json( $json ); |
|
| 4759 | + } else {
|
|
| 4760 | + $chunk_file_paths = array(); |
|
| 4761 | 4761 | |
| 4762 | - if ( !$items_count > 0 ) {
|
|
| 4763 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4764 | - } else {
|
|
| 4765 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 4766 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 4762 | + if ( !$items_count > 0 ) {
|
|
| 4763 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4764 | + } else {
|
|
| 4765 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 4766 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 4767 | 4767 | |
| 4768 | - $j = $chunk_page_no; |
|
| 4769 | - $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 4768 | + $j = $chunk_page_no; |
|
| 4769 | + $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 4770 | 4770 | |
| 4771 | - $per_page = 500; |
|
| 4772 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 4773 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4771 | + $per_page = 500; |
|
| 4772 | + $per_page = min( $per_page, $chunk_per_page ); |
|
| 4773 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4774 | 4774 | |
| 4775 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4776 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 4775 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4776 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 4777 | 4777 | |
| 4778 | - $clear = $i == 0 ? true : false; |
|
| 4779 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 4780 | - } |
|
| 4778 | + $clear = $i == 0 ? true : false; |
|
| 4779 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 4780 | + } |
|
| 4781 | 4781 | |
| 4782 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4783 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4784 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4785 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4786 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4782 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4783 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4784 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4785 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4786 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4787 | 4787 | |
| 4788 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 4789 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4790 | - } |
|
| 4788 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 4789 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4790 | + } |
|
| 4791 | 4791 | |
| 4792 | - if ( !empty($chunk_file_paths) ) {
|
|
| 4793 | - $json['total'] = $items_count; |
|
| 4794 | - $json['files'] = $chunk_file_paths; |
|
| 4795 | - } else {
|
|
| 4796 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 4797 | - } |
|
| 4798 | - } |
|
| 4799 | - wp_send_json( $json ); |
|
| 4800 | - } |
|
| 4801 | - } |
|
| 4802 | - break; |
|
| 4803 | - case 'prepare_import': |
|
| 4804 | - case 'import_cat': |
|
| 4805 | - case 'import_post': |
|
| 4806 | - case 'import_loc': {
|
|
| 4807 | - // WPML |
|
| 4808 | - $is_wpml = geodir_is_wpml(); |
|
| 4809 | - if ($is_wpml) {
|
|
| 4810 | - global $sitepress; |
|
| 4811 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 4812 | - } |
|
| 4813 | - // WPML |
|
| 4792 | + if ( !empty($chunk_file_paths) ) {
|
|
| 4793 | + $json['total'] = $items_count; |
|
| 4794 | + $json['files'] = $chunk_file_paths; |
|
| 4795 | + } else {
|
|
| 4796 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 4797 | + } |
|
| 4798 | + } |
|
| 4799 | + wp_send_json( $json ); |
|
| 4800 | + } |
|
| 4801 | + } |
|
| 4802 | + break; |
|
| 4803 | + case 'prepare_import': |
|
| 4804 | + case 'import_cat': |
|
| 4805 | + case 'import_post': |
|
| 4806 | + case 'import_loc': {
|
|
| 4807 | + // WPML |
|
| 4808 | + $is_wpml = geodir_is_wpml(); |
|
| 4809 | + if ($is_wpml) {
|
|
| 4810 | + global $sitepress; |
|
| 4811 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 4812 | + } |
|
| 4813 | + // WPML |
|
| 4814 | 4814 | |
| 4815 | - ini_set( 'auto_detect_line_endings', true ); |
|
| 4815 | + ini_set( 'auto_detect_line_endings', true ); |
|
| 4816 | 4816 | |
| 4817 | - $uploads = wp_upload_dir(); |
|
| 4818 | - $uploads_dir = $uploads['path']; |
|
| 4819 | - $uploads_subdir = $uploads['subdir']; |
|
| 4817 | + $uploads = wp_upload_dir(); |
|
| 4818 | + $uploads_dir = $uploads['path']; |
|
| 4819 | + $uploads_subdir = $uploads['subdir']; |
|
| 4820 | 4820 | |
| 4821 | - $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 4822 | - $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 4821 | + $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 4822 | + $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 4823 | 4823 | |
| 4824 | - $csv_file_arr = explode( '/', $csv_file ); |
|
| 4825 | - $csv_filename = end( $csv_file_arr ); |
|
| 4826 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 4824 | + $csv_file_arr = explode( '/', $csv_file ); |
|
| 4825 | + $csv_filename = end( $csv_file_arr ); |
|
| 4826 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 4827 | 4827 | |
| 4828 | - $json['file'] = $csv_file; |
|
| 4829 | - $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 4828 | + $json['file'] = $csv_file; |
|
| 4829 | + $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 4830 | 4830 | |
| 4831 | - if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 4832 | - $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 4831 | + if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 4832 | + $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 4833 | 4833 | |
| 4834 | - if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 4835 | - $json['error'] = NULL; |
|
| 4836 | - $json['rows'] = 0; |
|
| 4834 | + if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 4835 | + $json['error'] = NULL; |
|
| 4836 | + $json['rows'] = 0; |
|
| 4837 | 4837 | |
| 4838 | - if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 4839 | - while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 4840 | - if ( !empty( $data ) ) {
|
|
| 4841 | - $file[] = $data; |
|
| 4842 | - } |
|
| 4843 | - } |
|
| 4844 | - fclose($handle); |
|
| 4845 | - } |
|
| 4838 | + if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 4839 | + while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 4840 | + if ( !empty( $data ) ) {
|
|
| 4841 | + $file[] = $data; |
|
| 4842 | + } |
|
| 4843 | + } |
|
| 4844 | + fclose($handle); |
|
| 4845 | + } |
|
| 4846 | 4846 | |
| 4847 | - $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 4847 | + $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 4848 | 4848 | |
| 4849 | - if (!$json['rows'] > 0) {
|
|
| 4850 | - $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 4851 | - } |
|
| 4852 | - } else {
|
|
| 4853 | - wp_send_json( $json ); |
|
| 4854 | - } |
|
| 4855 | - } else {
|
|
| 4856 | - wp_send_json( $json ); |
|
| 4857 | - } |
|
| 4849 | + if (!$json['rows'] > 0) {
|
|
| 4850 | + $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 4851 | + } |
|
| 4852 | + } else {
|
|
| 4853 | + wp_send_json( $json ); |
|
| 4854 | + } |
|
| 4855 | + } else {
|
|
| 4856 | + wp_send_json( $json ); |
|
| 4857 | + } |
|
| 4858 | 4858 | |
| 4859 | - if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 4860 | - wp_send_json( $json ); |
|
| 4861 | - } |
|
| 4859 | + if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 4860 | + wp_send_json( $json ); |
|
| 4861 | + } |
|
| 4862 | 4862 | |
| 4863 | - $total = $json['rows']; |
|
| 4864 | - $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 4865 | - $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 4863 | + $total = $json['rows']; |
|
| 4864 | + $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 4865 | + $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 4866 | 4866 | |
| 4867 | - $count = $limit; |
|
| 4868 | - $requested_limit = $limit; |
|
| 4867 | + $count = $limit; |
|
| 4868 | + $requested_limit = $limit; |
|
| 4869 | 4869 | |
| 4870 | - if ($count < $total) {
|
|
| 4871 | - $count = $processed + $count; |
|
| 4872 | - if ($count > $total) {
|
|
| 4873 | - $count = $total; |
|
| 4874 | - } |
|
| 4875 | - } else {
|
|
| 4876 | - $count = $total; |
|
| 4877 | - } |
|
| 4870 | + if ($count < $total) {
|
|
| 4871 | + $count = $processed + $count; |
|
| 4872 | + if ($count > $total) {
|
|
| 4873 | + $count = $total; |
|
| 4874 | + } |
|
| 4875 | + } else {
|
|
| 4876 | + $count = $total; |
|
| 4877 | + } |
|
| 4878 | 4878 | |
| 4879 | - $created = 0; |
|
| 4880 | - $updated = 0; |
|
| 4881 | - $skipped = 0; |
|
| 4882 | - $invalid = 0; |
|
| 4883 | - $invalid_addr = 0; |
|
| 4884 | - $images = 0; |
|
| 4879 | + $created = 0; |
|
| 4880 | + $updated = 0; |
|
| 4881 | + $skipped = 0; |
|
| 4882 | + $invalid = 0; |
|
| 4883 | + $invalid_addr = 0; |
|
| 4884 | + $images = 0; |
|
| 4885 | 4885 | |
| 4886 | - $invalid_title = 0; |
|
| 4887 | - $customKeyarray = array(); |
|
| 4888 | - $gd_post_info = array(); |
|
| 4889 | - $post_location = array(); |
|
| 4890 | - $countpost = 0; |
|
| 4886 | + $invalid_title = 0; |
|
| 4887 | + $customKeyarray = array(); |
|
| 4888 | + $gd_post_info = array(); |
|
| 4889 | + $post_location = array(); |
|
| 4890 | + $countpost = 0; |
|
| 4891 | 4891 | |
| 4892 | - $post_types = geodir_get_posttypes(); |
|
| 4892 | + $post_types = geodir_get_posttypes(); |
|
| 4893 | 4893 | |
| 4894 | - if ( $task == 'import_cat' ) {
|
|
| 4895 | - if (!empty($file)) {
|
|
| 4896 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4894 | + if ( $task == 'import_cat' ) {
|
|
| 4895 | + if (!empty($file)) {
|
|
| 4896 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4897 | 4897 | |
| 4898 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4899 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 4900 | - wp_send_json( $json ); |
|
| 4901 | - exit; |
|
| 4902 | - } |
|
| 4898 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4899 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 4900 | + wp_send_json( $json ); |
|
| 4901 | + exit; |
|
| 4902 | + } |
|
| 4903 | 4903 | |
| 4904 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4905 | - $index = $processed + $i; |
|
| 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 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 4907 | + if (isset($file[$index])) {
|
|
| 4908 | + $row = $file[$index]; |
|
| 4909 | + $row = array_map( 'trim', $row ); |
|
| 4910 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 4911 | 4911 | |
| 4912 | - $cat_id = ''; |
|
| 4913 | - $cat_name = ''; |
|
| 4914 | - $cat_slug = ''; |
|
| 4915 | - $cat_posttype = ''; |
|
| 4916 | - $cat_parent = ''; |
|
| 4917 | - $cat_description = ''; |
|
| 4918 | - $cat_schema = ''; |
|
| 4919 | - $cat_top_description = ''; |
|
| 4920 | - $cat_image = ''; |
|
| 4921 | - $cat_icon = ''; |
|
| 4922 | - $cat_language = ''; |
|
| 4912 | + $cat_id = ''; |
|
| 4913 | + $cat_name = ''; |
|
| 4914 | + $cat_slug = ''; |
|
| 4915 | + $cat_posttype = ''; |
|
| 4916 | + $cat_parent = ''; |
|
| 4917 | + $cat_description = ''; |
|
| 4918 | + $cat_schema = ''; |
|
| 4919 | + $cat_top_description = ''; |
|
| 4920 | + $cat_image = ''; |
|
| 4921 | + $cat_icon = ''; |
|
| 4922 | + $cat_language = ''; |
|
| 4923 | 4923 | |
| 4924 | - $c = 0; |
|
| 4925 | - foreach ($columns as $column ) {
|
|
| 4926 | - if ( $column == 'cat_id' ) {
|
|
| 4927 | - $cat_id = (int)$row[$c]; |
|
| 4928 | - } else if ( $column == 'cat_name' ) {
|
|
| 4929 | - $cat_name = $row[$c]; |
|
| 4930 | - } else if ( $column == 'cat_slug' ) {
|
|
| 4931 | - $cat_slug = $row[$c]; |
|
| 4932 | - } else if ( $column == 'cat_posttype' ) {
|
|
| 4933 | - $cat_posttype = $row[$c]; |
|
| 4934 | - } else if ( $column == 'cat_parent' ) {
|
|
| 4935 | - $cat_parent = trim($row[$c]); |
|
| 4936 | - } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 4937 | - $cat_schema = $row[$c]; |
|
| 4938 | - } else if ( $column == 'cat_description' ) {
|
|
| 4939 | - $cat_description = $row[$c]; |
|
| 4940 | - } else if ( $column == 'cat_top_description' ) {
|
|
| 4941 | - $cat_top_description = $row[$c]; |
|
| 4942 | - } else if ( $column == 'cat_image' ) {
|
|
| 4943 | - $cat_image = $row[$c]; |
|
| 4944 | - } else if ( $column == 'cat_icon' ) {
|
|
| 4945 | - $cat_icon = $row[$c]; |
|
| 4946 | - } |
|
| 4947 | - // WPML |
|
| 4948 | - if ($is_wpml && $column == 'cat_language') {
|
|
| 4949 | - $cat_language = geodir_strtolower(trim($row[$c])); |
|
| 4950 | - } |
|
| 4951 | - // WPML |
|
| 4952 | - $c++; |
|
| 4953 | - } |
|
| 4924 | + $c = 0; |
|
| 4925 | + foreach ($columns as $column ) {
|
|
| 4926 | + if ( $column == 'cat_id' ) {
|
|
| 4927 | + $cat_id = (int)$row[$c]; |
|
| 4928 | + } else if ( $column == 'cat_name' ) {
|
|
| 4929 | + $cat_name = $row[$c]; |
|
| 4930 | + } else if ( $column == 'cat_slug' ) {
|
|
| 4931 | + $cat_slug = $row[$c]; |
|
| 4932 | + } else if ( $column == 'cat_posttype' ) {
|
|
| 4933 | + $cat_posttype = $row[$c]; |
|
| 4934 | + } else if ( $column == 'cat_parent' ) {
|
|
| 4935 | + $cat_parent = trim($row[$c]); |
|
| 4936 | + } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 4937 | + $cat_schema = $row[$c]; |
|
| 4938 | + } else if ( $column == 'cat_description' ) {
|
|
| 4939 | + $cat_description = $row[$c]; |
|
| 4940 | + } else if ( $column == 'cat_top_description' ) {
|
|
| 4941 | + $cat_top_description = $row[$c]; |
|
| 4942 | + } else if ( $column == 'cat_image' ) {
|
|
| 4943 | + $cat_image = $row[$c]; |
|
| 4944 | + } else if ( $column == 'cat_icon' ) {
|
|
| 4945 | + $cat_icon = $row[$c]; |
|
| 4946 | + } |
|
| 4947 | + // WPML |
|
| 4948 | + if ($is_wpml && $column == 'cat_language') {
|
|
| 4949 | + $cat_language = geodir_strtolower(trim($row[$c])); |
|
| 4950 | + } |
|
| 4951 | + // WPML |
|
| 4952 | + $c++; |
|
| 4953 | + } |
|
| 4954 | 4954 | |
| 4955 | - if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 4956 | - $invalid++; |
|
| 4957 | - continue; |
|
| 4958 | - } |
|
| 4955 | + if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 4956 | + $invalid++; |
|
| 4957 | + continue; |
|
| 4958 | + } |
|
| 4959 | 4959 | |
| 4960 | - // WPML |
|
| 4961 | - if ($is_wpml && $cat_language != '') {
|
|
| 4962 | - $sitepress->switch_lang($cat_language, true); |
|
| 4963 | - } |
|
| 4964 | - // WPML |
|
| 4960 | + // WPML |
|
| 4961 | + if ($is_wpml && $cat_language != '') {
|
|
| 4962 | + $sitepress->switch_lang($cat_language, true); |
|
| 4963 | + } |
|
| 4964 | + // WPML |
|
| 4965 | 4965 | |
| 4966 | - $term_data = array(); |
|
| 4967 | - $term_data['name'] = $cat_name; |
|
| 4968 | - $term_data['slug'] = $cat_slug; |
|
| 4969 | - $term_data['description'] = $cat_description; |
|
| 4970 | - $term_data['cat_schema'] = $cat_schema; |
|
| 4971 | - $term_data['top_description'] = $cat_top_description; |
|
| 4972 | - $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 4973 | - $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 4966 | + $term_data = array(); |
|
| 4967 | + $term_data['name'] = $cat_name; |
|
| 4968 | + $term_data['slug'] = $cat_slug; |
|
| 4969 | + $term_data['description'] = $cat_description; |
|
| 4970 | + $term_data['cat_schema'] = $cat_schema; |
|
| 4971 | + $term_data['top_description'] = $cat_top_description; |
|
| 4972 | + $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 4973 | + $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 4974 | 4974 | |
| 4975 | - //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 4975 | + //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 4976 | 4976 | |
| 4977 | - $taxonomy = $cat_posttype . 'category'; |
|
| 4977 | + $taxonomy = $cat_posttype . 'category'; |
|
| 4978 | 4978 | |
| 4979 | - $term_data['taxonomy'] = $taxonomy; |
|
| 4979 | + $term_data['taxonomy'] = $taxonomy; |
|
| 4980 | 4980 | |
| 4981 | - $term_parent_id = 0; |
|
| 4982 | - if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 4983 | - $term_parent = ''; |
|
| 4981 | + $term_parent_id = 0; |
|
| 4982 | + if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 4983 | + $term_parent = ''; |
|
| 4984 | 4984 | |
| 4985 | - if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 4986 | - $term_parent = $term_parent; |
|
| 4987 | - } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 4988 | - $term_parent = $term_parent; |
|
| 4989 | - } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 4990 | - $term_parent = $term_parent; |
|
| 4991 | - } else {
|
|
| 4992 | - $term_parent_data = array(); |
|
| 4993 | - $term_parent_data['name'] = $cat_parent; |
|
| 4994 | - //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 4995 | - $term_parent_data['taxonomy'] = $taxonomy; |
|
| 4985 | + if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 4986 | + $term_parent = $term_parent; |
|
| 4987 | + } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 4988 | + $term_parent = $term_parent; |
|
| 4989 | + } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 4990 | + $term_parent = $term_parent; |
|
| 4991 | + } else {
|
|
| 4992 | + $term_parent_data = array(); |
|
| 4993 | + $term_parent_data['name'] = $cat_parent; |
|
| 4994 | + //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 4995 | + $term_parent_data['taxonomy'] = $taxonomy; |
|
| 4996 | 4996 | |
| 4997 | - $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 4998 | - } |
|
| 4997 | + $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 4998 | + } |
|
| 4999 | 4999 | |
| 5000 | - if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 5001 | - $term_parent_id = (int)$term_parent->term_id; |
|
| 5002 | - } |
|
| 5003 | - } |
|
| 5004 | - $term_data['parent'] = (int)$term_parent_id; |
|
| 5000 | + if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 5001 | + $term_parent_id = (int)$term_parent->term_id; |
|
| 5002 | + } |
|
| 5003 | + } |
|
| 5004 | + $term_data['parent'] = (int)$term_parent_id; |
|
| 5005 | 5005 | |
| 5006 | - $term_id = NULL; |
|
| 5007 | - if ( $import_choice == 'update' ) {
|
|
| 5008 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 5009 | - $term_data['term_id'] = $term['term_id']; |
|
| 5006 | + $term_id = NULL; |
|
| 5007 | + if ( $import_choice == 'update' ) {
|
|
| 5008 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 5009 | + $term_data['term_id'] = $term['term_id']; |
|
| 5010 | 5010 | |
| 5011 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 5012 | - $updated++; |
|
| 5013 | - } else {
|
|
| 5014 | - $invalid++; |
|
| 5015 | - } |
|
| 5016 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5017 | - $term_data['term_id'] = $term['term_id']; |
|
| 5011 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 5012 | + $updated++; |
|
| 5013 | + } else {
|
|
| 5014 | + $invalid++; |
|
| 5015 | + } |
|
| 5016 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5017 | + $term_data['term_id'] = $term['term_id']; |
|
| 5018 | 5018 | |
| 5019 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 5020 | - $updated++; |
|
| 5021 | - } else {
|
|
| 5022 | - $invalid++; |
|
| 5023 | - } |
|
| 5024 | - } else {
|
|
| 5025 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 5026 | - $created++; |
|
| 5027 | - } else {
|
|
| 5028 | - $invalid++; |
|
| 5029 | - } |
|
| 5030 | - } |
|
| 5031 | - } else if ( $import_choice == 'skip' ) {
|
|
| 5032 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 5033 | - $skipped++; |
|
| 5034 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5035 | - $skipped++; |
|
| 5036 | - } else {
|
|
| 5037 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 5038 | - $created++; |
|
| 5039 | - } else {
|
|
| 5040 | - $invalid++; |
|
| 5041 | - } |
|
| 5042 | - } |
|
| 5043 | - } else {
|
|
| 5044 | - $invalid++; |
|
| 5045 | - } |
|
| 5019 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 5020 | + $updated++; |
|
| 5021 | + } else {
|
|
| 5022 | + $invalid++; |
|
| 5023 | + } |
|
| 5024 | + } else {
|
|
| 5025 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 5026 | + $created++; |
|
| 5027 | + } else {
|
|
| 5028 | + $invalid++; |
|
| 5029 | + } |
|
| 5030 | + } |
|
| 5031 | + } else if ( $import_choice == 'skip' ) {
|
|
| 5032 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 5033 | + $skipped++; |
|
| 5034 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5035 | + $skipped++; |
|
| 5036 | + } else {
|
|
| 5037 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 5038 | + $created++; |
|
| 5039 | + } else {
|
|
| 5040 | + $invalid++; |
|
| 5041 | + } |
|
| 5042 | + } |
|
| 5043 | + } else {
|
|
| 5044 | + $invalid++; |
|
| 5045 | + } |
|
| 5046 | 5046 | |
| 5047 | - if ( $term_id ) {
|
|
| 5048 | - if ( isset( $term_data['top_description'] ) ) {
|
|
| 5049 | - update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 5050 | - } |
|
| 5047 | + if ( $term_id ) {
|
|
| 5048 | + if ( isset( $term_data['top_description'] ) ) {
|
|
| 5049 | + update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 5050 | + } |
|
| 5051 | 5051 | |
| 5052 | - if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 5053 | - update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 5054 | - } |
|
| 5052 | + if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 5053 | + update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 5054 | + } |
|
| 5055 | 5055 | |
| 5056 | - $attachment = false; |
|
| 5057 | - if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 5058 | - $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 5059 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 5056 | + $attachment = false; |
|
| 5057 | + if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 5058 | + $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 5059 | + $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 5060 | 5060 | |
| 5061 | - if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 5062 | - $attachment = true; |
|
| 5063 | - update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 5064 | - } |
|
| 5065 | - } |
|
| 5061 | + if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 5062 | + $attachment = true; |
|
| 5063 | + update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 5064 | + } |
|
| 5065 | + } |
|
| 5066 | 5066 | |
| 5067 | - if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 5068 | - $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 5069 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 5067 | + if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 5068 | + $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 5069 | + $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 5070 | 5070 | |
| 5071 | - if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 5072 | - $attachment = true; |
|
| 5073 | - update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 5074 | - } |
|
| 5075 | - } |
|
| 5071 | + if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 5072 | + $attachment = true; |
|
| 5073 | + update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 5074 | + } |
|
| 5075 | + } |
|
| 5076 | 5076 | |
| 5077 | - if ( $attachment ) {
|
|
| 5078 | - $images++; |
|
| 5079 | - } |
|
| 5080 | - } |
|
| 5077 | + if ( $attachment ) {
|
|
| 5078 | + $images++; |
|
| 5079 | + } |
|
| 5080 | + } |
|
| 5081 | 5081 | |
| 5082 | - // WPML |
|
| 5083 | - if ($is_wpml && $cat_language != '') {
|
|
| 5084 | - $sitepress->switch_lang($active_lang, true); |
|
| 5085 | - } |
|
| 5086 | - // WPML |
|
| 5087 | - } |
|
| 5088 | - } |
|
| 5089 | - } |
|
| 5082 | + // WPML |
|
| 5083 | + if ($is_wpml && $cat_language != '') {
|
|
| 5084 | + $sitepress->switch_lang($active_lang, true); |
|
| 5085 | + } |
|
| 5086 | + // WPML |
|
| 5087 | + } |
|
| 5088 | + } |
|
| 5089 | + } |
|
| 5090 | 5090 | |
| 5091 | - $json = array(); |
|
| 5092 | - $json['processed'] = $limit; |
|
| 5093 | - $json['created'] = $created; |
|
| 5094 | - $json['updated'] = $updated; |
|
| 5095 | - $json['skipped'] = $skipped; |
|
| 5096 | - $json['invalid'] = $invalid; |
|
| 5097 | - $json['images'] = $images; |
|
| 5091 | + $json = array(); |
|
| 5092 | + $json['processed'] = $limit; |
|
| 5093 | + $json['created'] = $created; |
|
| 5094 | + $json['updated'] = $updated; |
|
| 5095 | + $json['skipped'] = $skipped; |
|
| 5096 | + $json['invalid'] = $invalid; |
|
| 5097 | + $json['images'] = $images; |
|
| 5098 | 5098 | |
| 5099 | - wp_send_json( $json ); |
|
| 5100 | - exit; |
|
| 5101 | - } else if ( $task == 'import_post' ) {
|
|
| 5099 | + wp_send_json( $json ); |
|
| 5100 | + exit; |
|
| 5101 | + } else if ( $task == 'import_post' ) {
|
|
| 5102 | 5102 | |
| 5103 | - //run some stuff to make the import quicker |
|
| 5104 | - wp_defer_term_counting( true ); |
|
| 5105 | - wp_defer_comment_counting( true ); |
|
| 5106 | - $wpdb->query( 'SET autocommit = 0;' ); |
|
| 5103 | + //run some stuff to make the import quicker |
|
| 5104 | + wp_defer_term_counting( true ); |
|
| 5105 | + wp_defer_comment_counting( true ); |
|
| 5106 | + $wpdb->query( 'SET autocommit = 0;' ); |
|
| 5107 | 5107 | |
| 5108 | - //remove_all_actions('publish_post');
|
|
| 5109 | - //remove_all_actions('transition_post_status');
|
|
| 5110 | - //remove_all_actions('publish_future_post');
|
|
| 5108 | + //remove_all_actions('publish_post');
|
|
| 5109 | + //remove_all_actions('transition_post_status');
|
|
| 5110 | + //remove_all_actions('publish_future_post');
|
|
| 5111 | 5111 | |
| 5112 | 5112 | |
| 5113 | - if (!empty($file)) {
|
|
| 5114 | - $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 5115 | - $default_status = 'publish'; |
|
| 5116 | - $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 5113 | + if (!empty($file)) {
|
|
| 5114 | + $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 5115 | + $default_status = 'publish'; |
|
| 5116 | + $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 5117 | 5117 | |
| 5118 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 5118 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 5119 | 5119 | |
| 5120 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 5121 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 5122 | - wp_send_json( $json ); |
|
| 5123 | - exit; |
|
| 5124 | - } |
|
| 5120 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 5121 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 5122 | + wp_send_json( $json ); |
|
| 5123 | + exit; |
|
| 5124 | + } |
|
| 5125 | 5125 | |
| 5126 | - $processed_actual=0; |
|
| 5127 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 5128 | - $index = $processed + $i; |
|
| 5129 | - $gd_post = array(); |
|
| 5126 | + $processed_actual=0; |
|
| 5127 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 5128 | + $index = $processed + $i; |
|
| 5129 | + $gd_post = array(); |
|
| 5130 | 5130 | |
| 5131 | - if (isset($file[$index])) {$processed_actual++;
|
|
| 5132 | - $row = $file[$index]; |
|
| 5133 | - $row = array_map( 'trim', $row ); |
|
| 5134 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 5135 | - $row = array_map( 'addslashes_gpc', $row ); |
|
| 5131 | + if (isset($file[$index])) {$processed_actual++;
|
|
| 5132 | + $row = $file[$index]; |
|
| 5133 | + $row = array_map( 'trim', $row ); |
|
| 5134 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 5135 | + $row = array_map( 'addslashes_gpc', $row ); |
|
| 5136 | 5136 | |
| 5137 | - $post_id = ''; |
|
| 5138 | - $post_title = ''; |
|
| 5139 | - $post_author = ''; |
|
| 5140 | - $post_content = ''; |
|
| 5141 | - $post_category_arr = array(); |
|
| 5142 | - $default_category = ''; |
|
| 5143 | - $post_tags = array(); |
|
| 5144 | - $post_type = ''; |
|
| 5145 | - $post_status = ''; |
|
| 5146 | - $geodir_video = ''; |
|
| 5147 | - $post_address = ''; |
|
| 5148 | - $post_city = ''; |
|
| 5149 | - $post_region = ''; |
|
| 5150 | - $post_country = ''; |
|
| 5151 | - $post_zip = ''; |
|
| 5152 | - $post_latitude = ''; |
|
| 5153 | - $post_longitude = ''; |
|
| 5154 | - $geodir_timing = ''; |
|
| 5155 | - $geodir_contact = ''; |
|
| 5156 | - $geodir_email = ''; |
|
| 5157 | - $geodir_website = ''; |
|
| 5158 | - $geodir_twitter = ''; |
|
| 5159 | - $geodir_facebook = ''; |
|
| 5160 | - $geodir_twitter = ''; |
|
| 5161 | - $post_images = array(); |
|
| 5137 | + $post_id = ''; |
|
| 5138 | + $post_title = ''; |
|
| 5139 | + $post_author = ''; |
|
| 5140 | + $post_content = ''; |
|
| 5141 | + $post_category_arr = array(); |
|
| 5142 | + $default_category = ''; |
|
| 5143 | + $post_tags = array(); |
|
| 5144 | + $post_type = ''; |
|
| 5145 | + $post_status = ''; |
|
| 5146 | + $geodir_video = ''; |
|
| 5147 | + $post_address = ''; |
|
| 5148 | + $post_city = ''; |
|
| 5149 | + $post_region = ''; |
|
| 5150 | + $post_country = ''; |
|
| 5151 | + $post_zip = ''; |
|
| 5152 | + $post_latitude = ''; |
|
| 5153 | + $post_longitude = ''; |
|
| 5154 | + $geodir_timing = ''; |
|
| 5155 | + $geodir_contact = ''; |
|
| 5156 | + $geodir_email = ''; |
|
| 5157 | + $geodir_website = ''; |
|
| 5158 | + $geodir_twitter = ''; |
|
| 5159 | + $geodir_facebook = ''; |
|
| 5160 | + $geodir_twitter = ''; |
|
| 5161 | + $post_images = array(); |
|
| 5162 | 5162 | |
| 5163 | - $expire_date = 'Never'; |
|
| 5163 | + $expire_date = 'Never'; |
|
| 5164 | 5164 | |
| 5165 | - $language = ''; |
|
| 5166 | - $original_post_id = ''; |
|
| 5165 | + $language = ''; |
|
| 5166 | + $original_post_id = ''; |
|
| 5167 | 5167 | |
| 5168 | - $c = 0; |
|
| 5169 | - foreach ($columns as $column ) {
|
|
| 5170 | - $gd_post[$column] = $row[$c]; |
|
| 5168 | + $c = 0; |
|
| 5169 | + foreach ($columns as $column ) {
|
|
| 5170 | + $gd_post[$column] = $row[$c]; |
|
| 5171 | 5171 | |
| 5172 | - if ( $column == 'post_id' ) {
|
|
| 5173 | - $post_id = $row[$c]; |
|
| 5174 | - } else if ( $column == 'post_title' ) {
|
|
| 5175 | - $post_title = $row[$c]; |
|
| 5176 | - } else if ( $column == 'post_author' ) {
|
|
| 5177 | - $post_author = $row[$c]; |
|
| 5178 | - } else if ( $column == 'post_content' ) {
|
|
| 5179 | - $post_content = $row[$c]; |
|
| 5180 | - } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 5181 | - $post_category_arr = explode( ',', $row[$c] ); |
|
| 5182 | - } else if ( $column == 'default_category' ) {
|
|
| 5183 | - $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 5184 | - } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 5185 | - $post_tags = explode( ',', $row[$c] ); |
|
| 5186 | - } else if ( $column == 'post_type' ) {
|
|
| 5187 | - $post_type = $row[$c]; |
|
| 5188 | - } else if ( $column == 'post_status' ) {
|
|
| 5189 | - $post_status = sanitize_key( $row[$c] ); |
|
| 5190 | - } else if ( $column == 'is_featured' ) {
|
|
| 5191 | - $is_featured = (int)$row[$c]; |
|
| 5192 | - } else if ( $column == 'geodir_video' ) {
|
|
| 5193 | - $geodir_video = $row[$c]; |
|
| 5194 | - } else if ( $column == 'post_address' ) {
|
|
| 5195 | - $post_address = $row[$c]; |
|
| 5196 | - } else if ( $column == 'post_city' ) {
|
|
| 5197 | - $post_city = $row[$c]; |
|
| 5198 | - } else if ( $column == 'post_region' ) {
|
|
| 5199 | - $post_region = $row[$c]; |
|
| 5200 | - } else if ( $column == 'post_country' ) {
|
|
| 5201 | - $post_country = $row[$c]; |
|
| 5202 | - } else if ( $column == 'post_zip' ) {
|
|
| 5203 | - $post_zip = $row[$c]; |
|
| 5204 | - } else if ( $column == 'post_latitude' ) {
|
|
| 5205 | - $post_latitude = $row[$c]; |
|
| 5206 | - } else if ( $column == 'post_longitude' ) {
|
|
| 5207 | - $post_longitude = $row[$c]; |
|
| 5208 | - } else if ( $column == 'geodir_timing' ) {
|
|
| 5209 | - $geodir_timing = $row[$c]; |
|
| 5210 | - } else if ( $column == 'geodir_contact' ) {
|
|
| 5211 | - $geodir_contact = $row[$c]; |
|
| 5212 | - } else if ( $column == 'geodir_email' ) {
|
|
| 5213 | - $geodir_email = $row[$c]; |
|
| 5214 | - } else if ( $column == 'geodir_website' ) {
|
|
| 5215 | - $geodir_website = $row[$c]; |
|
| 5216 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 5217 | - $geodir_twitter = $row[$c]; |
|
| 5218 | - } else if ( $column == 'geodir_facebook' ) {
|
|
| 5219 | - $geodir_facebook = $row[$c]; |
|
| 5220 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 5221 | - $geodir_twitter = $row[$c]; |
|
| 5222 | - } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 5223 | - $post_images[] = $row[$c]; |
|
| 5224 | - } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 5225 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 5226 | - } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 5227 | - $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 5228 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 5229 | - } |
|
| 5230 | - // WPML |
|
| 5231 | - if ($is_wpml) {
|
|
| 5232 | - if ($column == 'language') {
|
|
| 5233 | - $language = geodir_strtolower(trim($row[$c])); |
|
| 5234 | - } else if ($column == 'original_post_id') {
|
|
| 5235 | - $original_post_id = (int)$row[$c]; |
|
| 5236 | - } |
|
| 5237 | - } |
|
| 5238 | - // WPML |
|
| 5239 | - $c++; |
|
| 5240 | - } |
|
| 5172 | + if ( $column == 'post_id' ) {
|
|
| 5173 | + $post_id = $row[$c]; |
|
| 5174 | + } else if ( $column == 'post_title' ) {
|
|
| 5175 | + $post_title = $row[$c]; |
|
| 5176 | + } else if ( $column == 'post_author' ) {
|
|
| 5177 | + $post_author = $row[$c]; |
|
| 5178 | + } else if ( $column == 'post_content' ) {
|
|
| 5179 | + $post_content = $row[$c]; |
|
| 5180 | + } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 5181 | + $post_category_arr = explode( ',', $row[$c] ); |
|
| 5182 | + } else if ( $column == 'default_category' ) {
|
|
| 5183 | + $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 5184 | + } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 5185 | + $post_tags = explode( ',', $row[$c] ); |
|
| 5186 | + } else if ( $column == 'post_type' ) {
|
|
| 5187 | + $post_type = $row[$c]; |
|
| 5188 | + } else if ( $column == 'post_status' ) {
|
|
| 5189 | + $post_status = sanitize_key( $row[$c] ); |
|
| 5190 | + } else if ( $column == 'is_featured' ) {
|
|
| 5191 | + $is_featured = (int)$row[$c]; |
|
| 5192 | + } else if ( $column == 'geodir_video' ) {
|
|
| 5193 | + $geodir_video = $row[$c]; |
|
| 5194 | + } else if ( $column == 'post_address' ) {
|
|
| 5195 | + $post_address = $row[$c]; |
|
| 5196 | + } else if ( $column == 'post_city' ) {
|
|
| 5197 | + $post_city = $row[$c]; |
|
| 5198 | + } else if ( $column == 'post_region' ) {
|
|
| 5199 | + $post_region = $row[$c]; |
|
| 5200 | + } else if ( $column == 'post_country' ) {
|
|
| 5201 | + $post_country = $row[$c]; |
|
| 5202 | + } else if ( $column == 'post_zip' ) {
|
|
| 5203 | + $post_zip = $row[$c]; |
|
| 5204 | + } else if ( $column == 'post_latitude' ) {
|
|
| 5205 | + $post_latitude = $row[$c]; |
|
| 5206 | + } else if ( $column == 'post_longitude' ) {
|
|
| 5207 | + $post_longitude = $row[$c]; |
|
| 5208 | + } else if ( $column == 'geodir_timing' ) {
|
|
| 5209 | + $geodir_timing = $row[$c]; |
|
| 5210 | + } else if ( $column == 'geodir_contact' ) {
|
|
| 5211 | + $geodir_contact = $row[$c]; |
|
| 5212 | + } else if ( $column == 'geodir_email' ) {
|
|
| 5213 | + $geodir_email = $row[$c]; |
|
| 5214 | + } else if ( $column == 'geodir_website' ) {
|
|
| 5215 | + $geodir_website = $row[$c]; |
|
| 5216 | + } else if ( $column == 'geodir_twitter' ) {
|
|
| 5217 | + $geodir_twitter = $row[$c]; |
|
| 5218 | + } else if ( $column == 'geodir_facebook' ) {
|
|
| 5219 | + $geodir_facebook = $row[$c]; |
|
| 5220 | + } else if ( $column == 'geodir_twitter' ) {
|
|
| 5221 | + $geodir_twitter = $row[$c]; |
|
| 5222 | + } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 5223 | + $post_images[] = $row[$c]; |
|
| 5224 | + } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 5225 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 5226 | + } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 5227 | + $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 5228 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 5229 | + } |
|
| 5230 | + // WPML |
|
| 5231 | + if ($is_wpml) {
|
|
| 5232 | + if ($column == 'language') {
|
|
| 5233 | + $language = geodir_strtolower(trim($row[$c])); |
|
| 5234 | + } else if ($column == 'original_post_id') {
|
|
| 5235 | + $original_post_id = (int)$row[$c]; |
|
| 5236 | + } |
|
| 5237 | + } |
|
| 5238 | + // WPML |
|
| 5239 | + $c++; |
|
| 5240 | + } |
|
| 5241 | 5241 | |
| 5242 | - // WPML |
|
| 5243 | - if ($is_wpml && $language != '') {
|
|
| 5244 | - $sitepress->switch_lang($language, true); |
|
| 5245 | - } |
|
| 5246 | - // WPML |
|
| 5242 | + // WPML |
|
| 5243 | + if ($is_wpml && $language != '') {
|
|
| 5244 | + $sitepress->switch_lang($language, true); |
|
| 5245 | + } |
|
| 5246 | + // WPML |
|
| 5247 | 5247 | |
| 5248 | - $gd_post['IMAGE'] = $post_images; |
|
| 5248 | + $gd_post['IMAGE'] = $post_images; |
|
| 5249 | 5249 | |
| 5250 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 5251 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 5250 | + $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 5251 | + $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 5252 | 5252 | |
| 5253 | - $valid = true; |
|
| 5253 | + $valid = true; |
|
| 5254 | 5254 | |
| 5255 | - if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 5256 | - $invalid++; |
|
| 5257 | - $valid = false; |
|
| 5258 | - } |
|
| 5255 | + if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 5256 | + $invalid++; |
|
| 5257 | + $valid = false; |
|
| 5258 | + } |
|
| 5259 | 5259 | |
| 5260 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5261 | - if ( $location_allowed ) {
|
|
| 5262 | - $location_result = geodir_get_default_location(); |
|
| 5263 | - if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 5264 | - $invalid_addr++; |
|
| 5265 | - $valid = false; |
|
| 5266 | - } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 5267 | - 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 ) ) ) {
|
|
| 5268 | - $invalid_addr++; |
|
| 5269 | - $valid = false; |
|
| 5270 | - } else {
|
|
| 5271 | - if (!function_exists('geodir_location_plugin_activated')) {
|
|
| 5272 | - $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. |
|
| 5273 | - } |
|
| 5274 | - } |
|
| 5275 | - } |
|
| 5276 | - } |
|
| 5260 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5261 | + if ( $location_allowed ) {
|
|
| 5262 | + $location_result = geodir_get_default_location(); |
|
| 5263 | + if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 5264 | + $invalid_addr++; |
|
| 5265 | + $valid = false; |
|
| 5266 | + } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 5267 | + 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 ) ) ) {
|
|
| 5268 | + $invalid_addr++; |
|
| 5269 | + $valid = false; |
|
| 5270 | + } else {
|
|
| 5271 | + if (!function_exists('geodir_location_plugin_activated')) {
|
|
| 5272 | + $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. |
|
| 5273 | + } |
|
| 5274 | + } |
|
| 5275 | + } |
|
| 5276 | + } |
|
| 5277 | 5277 | |
| 5278 | - if ( !$valid ) {
|
|
| 5279 | - continue; |
|
| 5280 | - } |
|
| 5278 | + if ( !$valid ) {
|
|
| 5279 | + continue; |
|
| 5280 | + } |
|
| 5281 | 5281 | |
| 5282 | - $cat_taxonomy = $post_type . 'category'; |
|
| 5283 | - $tags_taxonomy = $post_type . '_tags'; |
|
| 5282 | + $cat_taxonomy = $post_type . 'category'; |
|
| 5283 | + $tags_taxonomy = $post_type . '_tags'; |
|
| 5284 | 5284 | |
| 5285 | - if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 5286 | - $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 5287 | - } |
|
| 5285 | + if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 5286 | + $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 5287 | + } |
|
| 5288 | 5288 | |
| 5289 | - $post_category = array(); |
|
| 5290 | - $default_category_id = NULL; |
|
| 5291 | - if ( !empty( $post_category_arr ) ) {
|
|
| 5292 | - foreach ( $post_category_arr as $value ) {
|
|
| 5293 | - $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 5289 | + $post_category = array(); |
|
| 5290 | + $default_category_id = NULL; |
|
| 5291 | + if ( !empty( $post_category_arr ) ) {
|
|
| 5292 | + foreach ( $post_category_arr as $value ) {
|
|
| 5293 | + $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 5294 | 5294 | |
| 5295 | - if ( $category_name != '' ) {
|
|
| 5296 | - $term_category = array(); |
|
| 5295 | + if ( $category_name != '' ) {
|
|
| 5296 | + $term_category = array(); |
|
| 5297 | 5297 | |
| 5298 | - if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 5299 | - $term_category = $term; |
|
| 5300 | - } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 5301 | - $term_category = $term; |
|
| 5302 | - } else {
|
|
| 5303 | - $term_data = array(); |
|
| 5304 | - $term_data['name'] = $category_name; |
|
| 5305 | - //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 5306 | - $term_data['taxonomy'] = $cat_taxonomy; |
|
| 5298 | + if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 5299 | + $term_category = $term; |
|
| 5300 | + } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 5301 | + $term_category = $term; |
|
| 5302 | + } else {
|
|
| 5303 | + $term_data = array(); |
|
| 5304 | + $term_data['name'] = $category_name; |
|
| 5305 | + //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 5306 | + $term_data['taxonomy'] = $cat_taxonomy; |
|
| 5307 | 5307 | |
| 5308 | - $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 5309 | - if ( $term_id ) {
|
|
| 5310 | - $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 5311 | - } |
|
| 5312 | - } |
|
| 5308 | + $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 5309 | + if ( $term_id ) {
|
|
| 5310 | + $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 5311 | + } |
|
| 5312 | + } |
|
| 5313 | 5313 | |
| 5314 | - if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 5315 | - //$post_category[] = $term_category->slug; |
|
| 5316 | - $post_category[] = intval($term_category->term_id); |
|
| 5314 | + if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 5315 | + //$post_category[] = $term_category->slug; |
|
| 5316 | + $post_category[] = intval($term_category->term_id); |
|
| 5317 | 5317 | |
| 5318 | - if ($category_name == $default_category) {
|
|
| 5319 | - $default_category_id = intval($term_category->term_id); |
|
| 5320 | - } |
|
| 5321 | - } |
|
| 5322 | - } |
|
| 5323 | - } |
|
| 5324 | - } |
|
| 5318 | + if ($category_name == $default_category) {
|
|
| 5319 | + $default_category_id = intval($term_category->term_id); |
|
| 5320 | + } |
|
| 5321 | + } |
|
| 5322 | + } |
|
| 5323 | + } |
|
| 5324 | + } |
|
| 5325 | 5325 | |
| 5326 | - $save_post = array(); |
|
| 5327 | - $save_post['post_title'] = $post_title; |
|
| 5328 | - $save_post['post_content'] = $post_content; |
|
| 5329 | - $save_post['post_type'] = $post_type; |
|
| 5330 | - $save_post['post_author'] = $post_author; |
|
| 5331 | - $save_post['post_status'] = $post_status; |
|
| 5332 | - $save_post['post_category'] = $post_category; |
|
| 5333 | - $save_post['post_tags'] = $post_tags; |
|
| 5334 | - |
|
| 5335 | - $saved_post_id = NULL; |
|
| 5336 | - if ( $import_choice == 'update' ) {
|
|
| 5337 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 5338 | - $save_post['ID'] = $post_id; |
|
| 5326 | + $save_post = array(); |
|
| 5327 | + $save_post['post_title'] = $post_title; |
|
| 5328 | + $save_post['post_content'] = $post_content; |
|
| 5329 | + $save_post['post_type'] = $post_type; |
|
| 5330 | + $save_post['post_author'] = $post_author; |
|
| 5331 | + $save_post['post_status'] = $post_status; |
|
| 5332 | + $save_post['post_category'] = $post_category; |
|
| 5333 | + $save_post['post_tags'] = $post_tags; |
|
| 5334 | + |
|
| 5335 | + $saved_post_id = NULL; |
|
| 5336 | + if ( $import_choice == 'update' ) {
|
|
| 5337 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 5338 | + $save_post['ID'] = $post_id; |
|
| 5339 | 5339 | |
| 5340 | - if ( wp_update_post( $save_post ) ) {
|
|
| 5341 | - $saved_post_id = $post_id; |
|
| 5342 | - $updated++; |
|
| 5343 | - } |
|
| 5344 | - } else {
|
|
| 5345 | - if ( $saved_post_id = wp_insert_post( $save_post ) ) {
|
|
| 5346 | - $created++; |
|
| 5347 | - } |
|
| 5348 | - } |
|
| 5340 | + if ( wp_update_post( $save_post ) ) {
|
|
| 5341 | + $saved_post_id = $post_id; |
|
| 5342 | + $updated++; |
|
| 5343 | + } |
|
| 5344 | + } else {
|
|
| 5345 | + if ( $saved_post_id = wp_insert_post( $save_post ) ) {
|
|
| 5346 | + $created++; |
|
| 5347 | + } |
|
| 5348 | + } |
|
| 5349 | 5349 | |
| 5350 | - if ( !$saved_post_id > 0 ) {
|
|
| 5351 | - $invalid++; |
|
| 5352 | - } |
|
| 5353 | - } else if ( $import_choice == 'skip' ) {
|
|
| 5354 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 5355 | - $skipped++; |
|
| 5356 | - } else {
|
|
| 5357 | - if ( $saved_post_id = wp_insert_post( $save_post ) ) {
|
|
| 5358 | - $created++; |
|
| 5359 | - } else {
|
|
| 5360 | - $invalid++; |
|
| 5361 | - } |
|
| 5362 | - } |
|
| 5363 | - } else {
|
|
| 5364 | - $invalid++; |
|
| 5365 | - } |
|
| 5350 | + if ( !$saved_post_id > 0 ) {
|
|
| 5351 | + $invalid++; |
|
| 5352 | + } |
|
| 5353 | + } else if ( $import_choice == 'skip' ) {
|
|
| 5354 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 5355 | + $skipped++; |
|
| 5356 | + } else {
|
|
| 5357 | + if ( $saved_post_id = wp_insert_post( $save_post ) ) {
|
|
| 5358 | + $created++; |
|
| 5359 | + } else {
|
|
| 5360 | + $invalid++; |
|
| 5361 | + } |
|
| 5362 | + } |
|
| 5363 | + } else {
|
|
| 5364 | + $invalid++; |
|
| 5365 | + } |
|
| 5366 | 5366 | |
| 5367 | - if ( (int)$saved_post_id > 0 ) {
|
|
| 5368 | - // WPML |
|
| 5369 | - if ($is_wpml && $original_post_id > 0 && $language != '') {
|
|
| 5370 | - $wpml_post_type = 'post_' . $post_type; |
|
| 5371 | - $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 5372 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 5367 | + if ( (int)$saved_post_id > 0 ) {
|
|
| 5368 | + // WPML |
|
| 5369 | + if ($is_wpml && $original_post_id > 0 && $language != '') {
|
|
| 5370 | + $wpml_post_type = 'post_' . $post_type; |
|
| 5371 | + $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 5372 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 5373 | 5373 | |
| 5374 | - $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 5374 | + $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 5375 | 5375 | |
| 5376 | - $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 5377 | - } |
|
| 5378 | - // WPML |
|
| 5379 | - $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 5376 | + $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 5377 | + } |
|
| 5378 | + // WPML |
|
| 5379 | + $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 5380 | 5380 | |
| 5381 | - $gd_post['post_id'] = $saved_post_id; |
|
| 5382 | - $gd_post['ID'] = $saved_post_id; |
|
| 5383 | - $gd_post['post_tags'] = $post_tags; |
|
| 5384 | - $gd_post['post_title'] = $post_title; |
|
| 5385 | - $gd_post['post_status'] = $post_status; |
|
| 5386 | - $gd_post['submit_time'] = time(); |
|
| 5387 | - $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 5381 | + $gd_post['post_id'] = $saved_post_id; |
|
| 5382 | + $gd_post['ID'] = $saved_post_id; |
|
| 5383 | + $gd_post['post_tags'] = $post_tags; |
|
| 5384 | + $gd_post['post_title'] = $post_title; |
|
| 5385 | + $gd_post['post_status'] = $post_status; |
|
| 5386 | + $gd_post['submit_time'] = time(); |
|
| 5387 | + $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 5388 | 5388 | |
| 5389 | - // post location |
|
| 5390 | - $post_location_id = 0; |
|
| 5391 | - if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 5392 | - $post_location_info = array( |
|
| 5393 | - 'city' => $post_city, |
|
| 5394 | - 'region' => $post_region, |
|
| 5395 | - 'country' => $post_country, |
|
| 5396 | - 'geo_lat' => $post_latitude, |
|
| 5397 | - 'geo_lng' => $post_longitude |
|
| 5398 | - ); |
|
| 5399 | - if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 5400 | - $post_location_id = $location_id; |
|
| 5401 | - } |
|
| 5402 | - } |
|
| 5403 | - $gd_post['post_location_id'] = $post_location_id; |
|
| 5389 | + // post location |
|
| 5390 | + $post_location_id = 0; |
|
| 5391 | + if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 5392 | + $post_location_info = array( |
|
| 5393 | + 'city' => $post_city, |
|
| 5394 | + 'region' => $post_region, |
|
| 5395 | + 'country' => $post_country, |
|
| 5396 | + 'geo_lat' => $post_latitude, |
|
| 5397 | + 'geo_lng' => $post_longitude |
|
| 5398 | + ); |
|
| 5399 | + if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 5400 | + $post_location_id = $location_id; |
|
| 5401 | + } |
|
| 5402 | + } |
|
| 5403 | + $gd_post['post_location_id'] = $post_location_id; |
|
| 5404 | 5404 | |
| 5405 | - // post package info |
|
| 5406 | - $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 5407 | - if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 5408 | - $package_id = $gd_post_info->package_id; |
|
| 5409 | - } |
|
| 5405 | + // post package info |
|
| 5406 | + $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 5407 | + if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 5408 | + $package_id = $gd_post_info->package_id; |
|
| 5409 | + } |
|
| 5410 | 5410 | |
| 5411 | - $package_info = array(); |
|
| 5412 | - if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 5413 | - $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 5411 | + $package_info = array(); |
|
| 5412 | + if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 5413 | + $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 5414 | 5414 | |
| 5415 | - if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 5416 | - $package_info = array(); |
|
| 5417 | - } |
|
| 5418 | - } |
|
| 5415 | + if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 5416 | + $package_info = array(); |
|
| 5417 | + } |
|
| 5418 | + } |
|
| 5419 | 5419 | |
| 5420 | - if (empty($package_info)) {
|
|
| 5421 | - $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 5422 | - } |
|
| 5420 | + if (empty($package_info)) {
|
|
| 5421 | + $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 5422 | + } |
|
| 5423 | 5423 | |
| 5424 | - if (!empty($package_info)) {
|
|
| 5425 | - $package_id = $package_info['pid']; |
|
| 5424 | + if (!empty($package_info)) {
|
|
| 5425 | + $package_id = $package_info['pid']; |
|
| 5426 | 5426 | |
| 5427 | - if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 5428 | - $gd_post['expire_date'] = $expire_date; |
|
| 5429 | - } else {
|
|
| 5430 | - if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 5431 | - $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 5432 | - $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 5433 | - } else {
|
|
| 5434 | - $gd_post['expire_date'] = 'Never'; |
|
| 5435 | - } |
|
| 5436 | - } |
|
| 5427 | + if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 5428 | + $gd_post['expire_date'] = $expire_date; |
|
| 5429 | + } else {
|
|
| 5430 | + if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 5431 | + $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 5432 | + $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 5433 | + } else {
|
|
| 5434 | + $gd_post['expire_date'] = 'Never'; |
|
| 5435 | + } |
|
| 5436 | + } |
|
| 5437 | 5437 | |
| 5438 | - $gd_post['package_id'] = $package_id; |
|
| 5439 | - } |
|
| 5438 | + $gd_post['package_id'] = $package_id; |
|
| 5439 | + } |
|
| 5440 | 5440 | |
| 5441 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5441 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5442 | 5442 | |
| 5443 | - if ($post_type == 'gd_event') {
|
|
| 5444 | - $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 5445 | - } |
|
| 5443 | + if ($post_type == 'gd_event') {
|
|
| 5444 | + $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 5445 | + } |
|
| 5446 | 5446 | |
| 5447 | - if (isset($gd_post['post_id'])) {
|
|
| 5448 | - unset($gd_post['post_id']); |
|
| 5449 | - } |
|
| 5447 | + if (isset($gd_post['post_id'])) {
|
|
| 5448 | + unset($gd_post['post_id']); |
|
| 5449 | + } |
|
| 5450 | 5450 | |
| 5451 | - // Export franchise fields |
|
| 5452 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 5453 | - if ($is_franchise_active) {
|
|
| 5454 | - if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 5455 | - $gd_franchise_lock = array(); |
|
| 5451 | + // Export franchise fields |
|
| 5452 | + $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 5453 | + if ($is_franchise_active) {
|
|
| 5454 | + if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 5455 | + $gd_franchise_lock = array(); |
|
| 5456 | 5456 | |
| 5457 | - if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 5458 | - $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 5459 | - $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 5460 | - $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 5461 | - } |
|
| 5457 | + if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 5458 | + $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 5459 | + $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 5460 | + $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 5461 | + } |
|
| 5462 | 5462 | |
| 5463 | - update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 5464 | - update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 5465 | - } else {
|
|
| 5466 | - if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 5467 | - geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 5468 | - } |
|
| 5469 | - } |
|
| 5470 | - } |
|
| 5463 | + update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 5464 | + update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 5465 | + } else {
|
|
| 5466 | + if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 5467 | + geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 5468 | + } |
|
| 5469 | + } |
|
| 5470 | + } |
|
| 5471 | 5471 | |
| 5472 | - if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 5473 | - $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 5474 | - if ($default_category_id) {
|
|
| 5475 | - $save_post['post_default_category'] = $default_category_id; |
|
| 5476 | - $gd_post['default_category'] = $default_category_id; |
|
| 5477 | - } |
|
| 5478 | - $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 5479 | - } |
|
| 5472 | + if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 5473 | + $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 5474 | + if ($default_category_id) {
|
|
| 5475 | + $save_post['post_default_category'] = $default_category_id; |
|
| 5476 | + $gd_post['default_category'] = $default_category_id; |
|
| 5477 | + } |
|
| 5478 | + $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 5479 | + } |
|
| 5480 | 5480 | |
| 5481 | - // Save post info |
|
| 5482 | - geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 5483 | - // post taxonomies |
|
| 5484 | - if ( !empty( $save_post['post_category'] ) ) {
|
|
| 5485 | - wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 5481 | + // Save post info |
|
| 5482 | + geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 5483 | + // post taxonomies |
|
| 5484 | + if ( !empty( $save_post['post_category'] ) ) {
|
|
| 5485 | + wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 5486 | 5486 | |
| 5487 | - $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 5488 | - if ($default_category_id) {
|
|
| 5489 | - $post_default_category = $default_category_id; |
|
| 5490 | - } |
|
| 5491 | - $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 5492 | - $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 5493 | - $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 5487 | + $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 5488 | + if ($default_category_id) {
|
|
| 5489 | + $post_default_category = $default_category_id; |
|
| 5490 | + } |
|
| 5491 | + $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 5492 | + $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 5493 | + $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 5494 | 5494 | |
| 5495 | - if ($post_category_str != '' && $post_default_category) {
|
|
| 5496 | - $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 5497 | - } |
|
| 5495 | + if ($post_category_str != '' && $post_default_category) {
|
|
| 5496 | + $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 5497 | + } |
|
| 5498 | 5498 | |
| 5499 | - $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 5499 | + $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 5500 | 5500 | |
| 5501 | - geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 5502 | - } |
|
| 5501 | + geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 5502 | + } |
|
| 5503 | 5503 | |
| 5504 | - if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 5505 | - wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 5506 | - } |
|
| 5504 | + if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 5505 | + wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 5506 | + } |
|
| 5507 | 5507 | |
| 5508 | - // Post images |
|
| 5509 | - if ( !empty( $post_images ) ) {
|
|
| 5510 | - $post_images = array_unique($post_images); |
|
| 5508 | + // Post images |
|
| 5509 | + if ( !empty( $post_images ) ) {
|
|
| 5510 | + $post_images = array_unique($post_images); |
|
| 5511 | 5511 | |
| 5512 | - $old_post_images_arr = array(); |
|
| 5513 | - $saved_post_images_arr = array(); |
|
| 5512 | + $old_post_images_arr = array(); |
|
| 5513 | + $saved_post_images_arr = array(); |
|
| 5514 | 5514 | |
| 5515 | - $order = 1; |
|
| 5515 | + $order = 1; |
|
| 5516 | 5516 | |
| 5517 | - $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 5518 | - if (!empty($old_post_images)) {
|
|
| 5519 | - foreach( $old_post_images as $old_post_image ) {
|
|
| 5520 | - if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 5521 | - $old_post_images_arr[] = $old_post_image->file; |
|
| 5522 | - } |
|
| 5523 | - } |
|
| 5524 | - } |
|
| 5517 | + $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 5518 | + if (!empty($old_post_images)) {
|
|
| 5519 | + foreach( $old_post_images as $old_post_image ) {
|
|
| 5520 | + if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 5521 | + $old_post_images_arr[] = $old_post_image->file; |
|
| 5522 | + } |
|
| 5523 | + } |
|
| 5524 | + } |
|
| 5525 | 5525 | |
| 5526 | - foreach ( $post_images as $post_image ) {
|
|
| 5527 | - $image_name = basename( $post_image ); |
|
| 5528 | - $saved_post_images_arr[] = $image_name; |
|
| 5526 | + foreach ( $post_images as $post_image ) {
|
|
| 5527 | + $image_name = basename( $post_image ); |
|
| 5528 | + $saved_post_images_arr[] = $image_name; |
|
| 5529 | 5529 | |
| 5530 | - if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 5531 | - continue; // Skip if image already exists. |
|
| 5532 | - } |
|
| 5530 | + if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 5531 | + continue; // Skip if image already exists. |
|
| 5532 | + } |
|
| 5533 | 5533 | |
| 5534 | - $image_name_parts = explode( '.', $image_name ); |
|
| 5535 | - array_pop( $image_name_parts ); |
|
| 5536 | - $proper_image_name = implode( '.', $image_name_parts ); |
|
| 5534 | + $image_name_parts = explode( '.', $image_name ); |
|
| 5535 | + array_pop( $image_name_parts ); |
|
| 5536 | + $proper_image_name = implode( '.', $image_name_parts ); |
|
| 5537 | 5537 | |
| 5538 | - $arr_file_type = wp_check_filetype( $image_name ); |
|
| 5538 | + $arr_file_type = wp_check_filetype( $image_name ); |
|
| 5539 | 5539 | |
| 5540 | - if ( !empty( $arr_file_type ) ) {
|
|
| 5541 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 5540 | + if ( !empty( $arr_file_type ) ) {
|
|
| 5541 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 5542 | 5542 | |
| 5543 | - $attachment = array(); |
|
| 5544 | - $attachment['post_id'] = $saved_post_id; |
|
| 5545 | - $attachment['title'] = $proper_image_name; |
|
| 5546 | - $attachment['content'] = ''; |
|
| 5547 | - $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 5548 | - $attachment['mime_type'] = $uploaded_file_type; |
|
| 5549 | - $attachment['menu_order'] = $order; |
|
| 5550 | - $attachment['is_featured'] = 0; |
|
| 5551 | - |
|
| 5552 | - $attachment_set = ''; |
|
| 5553 | - foreach ( $attachment as $key => $val ) {
|
|
| 5554 | - if ( $val != '' ) {
|
|
| 5555 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 5556 | - } |
|
| 5557 | - } |
|
| 5558 | - $attachment_set = trim( $attachment_set, ", " ); |
|
| 5543 | + $attachment = array(); |
|
| 5544 | + $attachment['post_id'] = $saved_post_id; |
|
| 5545 | + $attachment['title'] = $proper_image_name; |
|
| 5546 | + $attachment['content'] = ''; |
|
| 5547 | + $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 5548 | + $attachment['mime_type'] = $uploaded_file_type; |
|
| 5549 | + $attachment['menu_order'] = $order; |
|
| 5550 | + $attachment['is_featured'] = 0; |
|
| 5551 | + |
|
| 5552 | + $attachment_set = ''; |
|
| 5553 | + foreach ( $attachment as $key => $val ) {
|
|
| 5554 | + if ( $val != '' ) {
|
|
| 5555 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 5556 | + } |
|
| 5557 | + } |
|
| 5558 | + $attachment_set = trim( $attachment_set, ", " ); |
|
| 5559 | 5559 | |
| 5560 | - // Add new attachment |
|
| 5561 | - $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 5560 | + // Add new attachment |
|
| 5561 | + $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 5562 | 5562 | |
| 5563 | - $order++; |
|
| 5564 | - } |
|
| 5565 | - } |
|
| 5563 | + $order++; |
|
| 5564 | + } |
|
| 5565 | + } |
|
| 5566 | 5566 | |
| 5567 | - $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 5568 | - // Remove previous attachment |
|
| 5569 | - $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 5567 | + $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 5568 | + // Remove previous attachment |
|
| 5569 | + $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 5570 | 5570 | |
| 5571 | - if ( !empty( $saved_post_images_arr ) ) {
|
|
| 5572 | - $menu_order = 1; |
|
| 5571 | + if ( !empty( $saved_post_images_arr ) ) {
|
|
| 5572 | + $menu_order = 1; |
|
| 5573 | 5573 | |
| 5574 | - foreach ( $saved_post_images_arr as $img_name ) {
|
|
| 5575 | - $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 ) ) ); |
|
| 5574 | + foreach ( $saved_post_images_arr as $img_name ) {
|
|
| 5575 | + $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 ) ) ); |
|
| 5576 | 5576 | |
| 5577 | - if( $menu_order == 1 ) {
|
|
| 5578 | - 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 ) ) ) ) {
|
|
| 5579 | - $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) ); |
|
| 5580 | - } |
|
| 5581 | - } |
|
| 5582 | - $menu_order++; |
|
| 5583 | - } |
|
| 5584 | - } |
|
| 5577 | + if( $menu_order == 1 ) {
|
|
| 5578 | + 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 ) ) ) ) {
|
|
| 5579 | + $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) ); |
|
| 5580 | + } |
|
| 5581 | + } |
|
| 5582 | + $menu_order++; |
|
| 5583 | + } |
|
| 5584 | + } |
|
| 5585 | 5585 | |
| 5586 | - if ( $order > 1 ) {
|
|
| 5587 | - $images++; |
|
| 5588 | - } |
|
| 5589 | - } |
|
| 5586 | + if ( $order > 1 ) {
|
|
| 5587 | + $images++; |
|
| 5588 | + } |
|
| 5589 | + } |
|
| 5590 | 5590 | |
| 5591 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 5592 | - do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 5591 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 5592 | + do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 5593 | 5593 | |
| 5594 | - if (isset($is_featured)) {
|
|
| 5595 | - geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 5596 | - } |
|
| 5597 | - if (isset($gd_post['expire_date'])) {
|
|
| 5598 | - geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 5599 | - } |
|
| 5600 | - } |
|
| 5594 | + if (isset($is_featured)) {
|
|
| 5595 | + geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 5596 | + } |
|
| 5597 | + if (isset($gd_post['expire_date'])) {
|
|
| 5598 | + geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 5599 | + } |
|
| 5600 | + } |
|
| 5601 | 5601 | |
| 5602 | - // WPML |
|
| 5603 | - if ($is_wpml && $language != '') {
|
|
| 5604 | - $sitepress->switch_lang($active_lang, true); |
|
| 5605 | - } |
|
| 5606 | - // WPML |
|
| 5607 | - } |
|
| 5608 | - } |
|
| 5609 | - } |
|
| 5602 | + // WPML |
|
| 5603 | + if ($is_wpml && $language != '') {
|
|
| 5604 | + $sitepress->switch_lang($active_lang, true); |
|
| 5605 | + } |
|
| 5606 | + // WPML |
|
| 5607 | + } |
|
| 5608 | + } |
|
| 5609 | + } |
|
| 5610 | 5610 | |
| 5611 | - //undo some stuff to make the import quicker |
|
| 5612 | - wp_defer_term_counting( false ); |
|
| 5613 | - wp_defer_comment_counting( false ); |
|
| 5614 | - $wpdb->query( 'COMMIT;' ); |
|
| 5615 | - $wpdb->query( 'SET autocommit = 1;' ); |
|
| 5616 | - |
|
| 5617 | - $json = array(); |
|
| 5618 | - $json['processed'] = $processed_actual; |
|
| 5619 | - $json['created'] = $created; |
|
| 5620 | - $json['updated'] = $updated; |
|
| 5621 | - $json['skipped'] = $skipped; |
|
| 5622 | - $json['invalid'] = $invalid; |
|
| 5623 | - $json['invalid_addr'] = $invalid_addr; |
|
| 5624 | - $json['images'] = $images; |
|
| 5611 | + //undo some stuff to make the import quicker |
|
| 5612 | + wp_defer_term_counting( false ); |
|
| 5613 | + wp_defer_comment_counting( false ); |
|
| 5614 | + $wpdb->query( 'COMMIT;' ); |
|
| 5615 | + $wpdb->query( 'SET autocommit = 1;' ); |
|
| 5616 | + |
|
| 5617 | + $json = array(); |
|
| 5618 | + $json['processed'] = $processed_actual; |
|
| 5619 | + $json['created'] = $created; |
|
| 5620 | + $json['updated'] = $updated; |
|
| 5621 | + $json['skipped'] = $skipped; |
|
| 5622 | + $json['invalid'] = $invalid; |
|
| 5623 | + $json['invalid_addr'] = $invalid_addr; |
|
| 5624 | + $json['images'] = $images; |
|
| 5625 | 5625 | |
| 5626 | - wp_send_json( $json ); |
|
| 5627 | - exit; |
|
| 5628 | - } else if ( $task == 'import_loc' ) {
|
|
| 5629 | - global $gd_post_types; |
|
| 5630 | - $gd_post_types = $post_types; |
|
| 5626 | + wp_send_json( $json ); |
|
| 5627 | + exit; |
|
| 5628 | + } else if ( $task == 'import_loc' ) {
|
|
| 5629 | + global $gd_post_types; |
|
| 5630 | + $gd_post_types = $post_types; |
|
| 5631 | 5631 | |
| 5632 | - if (!empty($file)) {
|
|
| 5633 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 5632 | + if (!empty($file)) {
|
|
| 5633 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 5634 | 5634 | |
| 5635 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 5636 | - $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 5637 | - wp_send_json( $json ); |
|
| 5638 | - } |
|
| 5635 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 5636 | + $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 5637 | + wp_send_json( $json ); |
|
| 5638 | + } |
|
| 5639 | 5639 | |
| 5640 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 5641 | - $index = $processed + $i; |
|
| 5640 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 5641 | + $index = $processed + $i; |
|
| 5642 | 5642 | |
| 5643 | - if (isset($file[$index])) {
|
|
| 5644 | - $row = $file[$index]; |
|
| 5645 | - $row = array_map( 'trim', $row ); |
|
| 5646 | - $data = array(); |
|
| 5643 | + if (isset($file[$index])) {
|
|
| 5644 | + $row = $file[$index]; |
|
| 5645 | + $row = array_map( 'trim', $row ); |
|
| 5646 | + $data = array(); |
|
| 5647 | 5647 | |
| 5648 | - foreach ($columns as $c => $column ) {
|
|
| 5649 | - 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'))) {
|
|
| 5650 | - $data[$column] = $row[$c]; |
|
| 5651 | - } |
|
| 5652 | - } |
|
| 5648 | + foreach ($columns as $c => $column ) {
|
|
| 5649 | + 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'))) {
|
|
| 5650 | + $data[$column] = $row[$c]; |
|
| 5651 | + } |
|
| 5652 | + } |
|
| 5653 | 5653 | |
| 5654 | - if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 5655 | - $invalid++; |
|
| 5656 | - continue; |
|
| 5657 | - } |
|
| 5654 | + if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 5655 | + $invalid++; |
|
| 5656 | + continue; |
|
| 5657 | + } |
|
| 5658 | 5658 | |
| 5659 | - $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 5659 | + $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 5660 | 5660 | |
| 5661 | - if ( $import_choice == 'update' ) {
|
|
| 5662 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 5663 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 5664 | - $updated++; |
|
| 5665 | - } else {
|
|
| 5666 | - $invalid++; |
|
| 5667 | - } |
|
| 5668 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 5669 | - $data['location_id'] = (int)$location->location_id; |
|
| 5661 | + if ( $import_choice == 'update' ) {
|
|
| 5662 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 5663 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 5664 | + $updated++; |
|
| 5665 | + } else {
|
|
| 5666 | + $invalid++; |
|
| 5667 | + } |
|
| 5668 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 5669 | + $data['location_id'] = (int)$location->location_id; |
|
| 5670 | 5670 | |
| 5671 | - if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 5672 | - $data['location_id'] = (int)$location->location_id; |
|
| 5673 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 5674 | - $data['location_id'] = (int)$location->location_id; |
|
| 5675 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 5676 | - $data['location_id'] = (int)$location->location_id; |
|
| 5677 | - } |
|
| 5671 | + if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 5672 | + $data['location_id'] = (int)$location->location_id; |
|
| 5673 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 5674 | + $data['location_id'] = (int)$location->location_id; |
|
| 5675 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 5676 | + $data['location_id'] = (int)$location->location_id; |
|
| 5677 | + } |
|
| 5678 | 5678 | |
| 5679 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 5680 | - $updated++; |
|
| 5681 | - } else {
|
|
| 5682 | - $invalid++; |
|
| 5683 | - } |
|
| 5684 | - } else {
|
|
| 5685 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 5686 | - $created++; |
|
| 5687 | - } else {
|
|
| 5688 | - $invalid++; |
|
| 5689 | - } |
|
| 5690 | - } |
|
| 5691 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 5692 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 5693 | - $skipped++; |
|
| 5694 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 5695 | - $skipped++; |
|
| 5696 | - } else {
|
|
| 5697 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 5698 | - $created++; |
|
| 5699 | - } else {
|
|
| 5700 | - $invalid++; |
|
| 5701 | - } |
|
| 5702 | - } |
|
| 5703 | - } else {
|
|
| 5704 | - $invalid++; |
|
| 5705 | - } |
|
| 5706 | - } |
|
| 5707 | - } |
|
| 5708 | - } |
|
| 5679 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 5680 | + $updated++; |
|
| 5681 | + } else {
|
|
| 5682 | + $invalid++; |
|
| 5683 | + } |
|
| 5684 | + } else {
|
|
| 5685 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 5686 | + $created++; |
|
| 5687 | + } else {
|
|
| 5688 | + $invalid++; |
|
| 5689 | + } |
|
| 5690 | + } |
|
| 5691 | + } elseif ( $import_choice == 'skip' ) {
|
|
| 5692 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 5693 | + $skipped++; |
|
| 5694 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 5695 | + $skipped++; |
|
| 5696 | + } else {
|
|
| 5697 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 5698 | + $created++; |
|
| 5699 | + } else {
|
|
| 5700 | + $invalid++; |
|
| 5701 | + } |
|
| 5702 | + } |
|
| 5703 | + } else {
|
|
| 5704 | + $invalid++; |
|
| 5705 | + } |
|
| 5706 | + } |
|
| 5707 | + } |
|
| 5708 | + } |
|
| 5709 | 5709 | |
| 5710 | - $json = array(); |
|
| 5711 | - $json['processed'] = $limit; |
|
| 5712 | - $json['created'] = $created; |
|
| 5713 | - $json['updated'] = $updated; |
|
| 5714 | - $json['skipped'] = $skipped; |
|
| 5715 | - $json['invalid'] = $invalid; |
|
| 5716 | - $json['images'] = $images; |
|
| 5710 | + $json = array(); |
|
| 5711 | + $json['processed'] = $limit; |
|
| 5712 | + $json['created'] = $created; |
|
| 5713 | + $json['updated'] = $updated; |
|
| 5714 | + $json['skipped'] = $skipped; |
|
| 5715 | + $json['invalid'] = $invalid; |
|
| 5716 | + $json['images'] = $images; |
|
| 5717 | 5717 | |
| 5718 | - wp_send_json( $json ); |
|
| 5719 | - } |
|
| 5720 | - } |
|
| 5721 | - break; |
|
| 5722 | - case 'import_finish':{
|
|
| 5723 | - /** |
|
| 5724 | - * Run an action when an import finishes. |
|
| 5725 | - * |
|
| 5726 | - * This action can be used to fire functions after an import ends. |
|
| 5727 | - * |
|
| 5728 | - * @since 1.5.3 |
|
| 5729 | - * @package GeoDirectory |
|
| 5730 | - */ |
|
| 5731 | - do_action('geodir_import_finished');
|
|
| 5732 | - } |
|
| 5733 | - break; |
|
| 5718 | + wp_send_json( $json ); |
|
| 5719 | + } |
|
| 5720 | + } |
|
| 5721 | + break; |
|
| 5722 | + case 'import_finish':{
|
|
| 5723 | + /** |
|
| 5724 | + * Run an action when an import finishes. |
|
| 5725 | + * |
|
| 5726 | + * This action can be used to fire functions after an import ends. |
|
| 5727 | + * |
|
| 5728 | + * @since 1.5.3 |
|
| 5729 | + * @package GeoDirectory |
|
| 5730 | + */ |
|
| 5731 | + do_action('geodir_import_finished');
|
|
| 5732 | + } |
|
| 5733 | + break; |
|
| 5734 | 5734 | |
| 5735 | - } |
|
| 5736 | - echo '0'; |
|
| 5737 | - wp_die(); |
|
| 5735 | + } |
|
| 5736 | + echo '0'; |
|
| 5737 | + wp_die(); |
|
| 5738 | 5738 | } |
| 5739 | 5739 | |
| 5740 | 5740 | /** |
@@ -5778,12 +5778,12 @@ discard block |
||
| 5778 | 5778 | $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
| 5779 | 5779 | } |
| 5780 | 5780 | |
| 5781 | - if( !empty( $term ) ) {
|
|
| 5781 | + if( !empty( $term ) ) {
|
|
| 5782 | 5782 | $result = wp_insert_term( $term, $taxonomy, $args ); |
| 5783 | - if( !is_wp_error( $result ) ) {
|
|
| 5784 | - return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5785 | - } |
|
| 5786 | - } |
|
| 5783 | + if( !is_wp_error( $result ) ) {
|
|
| 5784 | + return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5785 | + } |
|
| 5786 | + } |
|
| 5787 | 5787 | |
| 5788 | 5788 | return false; |
| 5789 | 5789 | } |
@@ -5830,16 +5830,16 @@ discard block |
||
| 5830 | 5830 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
| 5831 | 5831 | |
| 5832 | 5832 | if( !is_wp_error( $result ) ) {
|
| 5833 | - return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5834 | - } |
|
| 5833 | + return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5834 | + } |
|
| 5835 | 5835 | } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
| 5836 | 5836 | $term_data['term_id'] = $term_info['term_id']; |
| 5837 | 5837 | |
| 5838 | 5838 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
| 5839 | 5839 | |
| 5840 | 5840 | if( !is_wp_error( $result ) ) {
|
| 5841 | - return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5842 | - } |
|
| 5841 | + return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5842 | + } |
|
| 5843 | 5843 | } else {
|
| 5844 | 5844 | return geodir_imex_insert_term( $taxonomy, $term_data ); |
| 5845 | 5845 | } |
@@ -5864,7 +5864,7 @@ discard block |
||
| 5864 | 5864 | * Modify returned post counts for the current post type. |
| 5865 | 5865 | * |
| 5866 | 5866 | * @since 1.4.6 |
| 5867 | - * @package GeoDirectory |
|
| 5867 | + * @package GeoDirectory |
|
| 5868 | 5868 | * |
| 5869 | 5869 | * @param int $posts_count Post counts. |
| 5870 | 5870 | * @param string $post_type Post type. |
@@ -6004,7 +6004,7 @@ discard block |
||
| 6004 | 6004 | $csv_rows[] = $csv_row; |
| 6005 | 6005 | |
| 6006 | 6006 | $images_count = 5; |
| 6007 | - $xx=0; |
|
| 6007 | + $xx=0; |
|
| 6008 | 6008 | foreach ( $posts as $post ) {$xx++;
|
| 6009 | 6009 | $post_id = $post['ID']; |
| 6010 | 6010 | |
@@ -6244,7 +6244,7 @@ discard block |
||
| 6244 | 6244 | * Modify returned posts SQL query for the current post type. |
| 6245 | 6245 | * |
| 6246 | 6246 | * @since 1.4.6 |
| 6247 | - * @package GeoDirectory |
|
| 6247 | + * @package GeoDirectory |
|
| 6248 | 6248 | * |
| 6249 | 6249 | * @param int $query The SQL query. |
| 6250 | 6250 | * @param string $post_type Post type. |
@@ -6257,7 +6257,7 @@ discard block |
||
| 6257 | 6257 | * Modify returned post results for the current post type. |
| 6258 | 6258 | * |
| 6259 | 6259 | * @since 1.4.6 |
| 6260 | - * @package GeoDirectory |
|
| 6260 | + * @package GeoDirectory |
|
| 6261 | 6261 | * |
| 6262 | 6262 | * @param object $results An object containing all post ids. |
| 6263 | 6263 | * @param string $post_type Post type. |
@@ -6983,44 +6983,44 @@ discard block |
||
| 6983 | 6983 | */ |
| 6984 | 6984 | function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') |
| 6985 | 6985 | {
|
| 6986 | - global $wpdb, $current_user; |
|
| 6987 | - |
|
| 6988 | - $option_value = get_option($option); |
|
| 6989 | - |
|
| 6990 | - if ($option_value > 0) : |
|
| 6991 | - if (get_post($option_value)) : |
|
| 6992 | - // Page exists |
|
| 6993 | - return; |
|
| 6994 | - endif; |
|
| 6995 | - endif; |
|
| 6996 | - |
|
| 6997 | - |
|
| 6998 | - $page_found = $wpdb->get_var( |
|
| 6999 | - $wpdb->prepare( |
|
| 7000 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 7001 | - array($slug) |
|
| 7002 | - ) |
|
| 7003 | - ); |
|
| 7004 | - |
|
| 7005 | - if ($page_found) : |
|
| 7006 | - // Page exists |
|
| 7007 | - if (!$option_value) update_option($option, $page_found); |
|
| 7008 | - return; |
|
| 7009 | - endif; |
|
| 7010 | - |
|
| 7011 | - $page_data = array( |
|
| 7012 | - 'post_status' => $status, |
|
| 7013 | - 'post_type' => 'page', |
|
| 7014 | - 'post_author' => $current_user->ID, |
|
| 7015 | - 'post_name' => $slug, |
|
| 7016 | - 'post_title' => $page_title, |
|
| 7017 | - 'post_content' => $page_content, |
|
| 7018 | - 'post_parent' => $post_parent, |
|
| 7019 | - 'comment_status' => 'closed' |
|
| 7020 | - ); |
|
| 7021 | - $page_id = wp_insert_post($page_data); |
|
| 7022 | - |
|
| 7023 | - add_option($option, $page_id); |
|
| 6986 | + global $wpdb, $current_user; |
|
| 6987 | + |
|
| 6988 | + $option_value = get_option($option); |
|
| 6989 | + |
|
| 6990 | + if ($option_value > 0) : |
|
| 6991 | + if (get_post($option_value)) : |
|
| 6992 | + // Page exists |
|
| 6993 | + return; |
|
| 6994 | + endif; |
|
| 6995 | + endif; |
|
| 6996 | + |
|
| 6997 | + |
|
| 6998 | + $page_found = $wpdb->get_var( |
|
| 6999 | + $wpdb->prepare( |
|
| 7000 | + "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 7001 | + array($slug) |
|
| 7002 | + ) |
|
| 7003 | + ); |
|
| 7004 | + |
|
| 7005 | + if ($page_found) : |
|
| 7006 | + // Page exists |
|
| 7007 | + if (!$option_value) update_option($option, $page_found); |
|
| 7008 | + return; |
|
| 7009 | + endif; |
|
| 7010 | + |
|
| 7011 | + $page_data = array( |
|
| 7012 | + 'post_status' => $status, |
|
| 7013 | + 'post_type' => 'page', |
|
| 7014 | + 'post_author' => $current_user->ID, |
|
| 7015 | + 'post_name' => $slug, |
|
| 7016 | + 'post_title' => $page_title, |
|
| 7017 | + 'post_content' => $page_content, |
|
| 7018 | + 'post_parent' => $post_parent, |
|
| 7019 | + 'comment_status' => 'closed' |
|
| 7020 | + ); |
|
| 7021 | + $page_id = wp_insert_post($page_data); |
|
| 7022 | + |
|
| 7023 | + add_option($option, $page_id); |
|
| 7024 | 7024 | |
| 7025 | 7025 | } |
| 7026 | 7026 | |
@@ -7051,9 +7051,9 @@ discard block |
||
| 7051 | 7051 | * @package GeoDirectory |
| 7052 | 7052 | */ |
| 7053 | 7053 | function geodir_admin_upgrade_notice() {
|
| 7054 | - $class = "error"; |
|
| 7055 | - $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 7056 | - echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
| 7054 | + $class = "error"; |
|
| 7055 | + $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 7056 | + echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
| 7057 | 7057 | } |
| 7058 | 7058 | |
| 7059 | 7059 | |
@@ -7069,18 +7069,18 @@ discard block |
||
| 7069 | 7069 | */ |
| 7070 | 7070 | function geodire_admin_upgrade_notice( $plugin_data, $r ) |
| 7071 | 7071 | {
|
| 7072 | - // readme contents |
|
| 7073 | - $args = array( |
|
| 7074 | - 'timeout' => 15, |
|
| 7075 | - 'redirection' => 5 |
|
| 7076 | - ); |
|
| 7077 | - $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
| 7078 | - $data = wp_remote_get( $url, $args ); |
|
| 7072 | + // readme contents |
|
| 7073 | + $args = array( |
|
| 7074 | + 'timeout' => 15, |
|
| 7075 | + 'redirection' => 5 |
|
| 7076 | + ); |
|
| 7077 | + $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
| 7078 | + $data = wp_remote_get( $url, $args ); |
|
| 7079 | 7079 | |
| 7080 | - if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
|
| 7080 | + if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
|
| 7081 | 7081 | |
| 7082 | - geodir_in_plugin_update_message($data['body']); |
|
| 7083 | - } |
|
| 7082 | + geodir_in_plugin_update_message($data['body']); |
|
| 7083 | + } |
|
| 7084 | 7084 | } |
| 7085 | 7085 | |
| 7086 | 7086 | |
@@ -7088,28 +7088,28 @@ discard block |
||
| 7088 | 7088 | * @param string $body http response body |
| 7089 | 7089 | */ |
| 7090 | 7090 | function geodir_in_plugin_update_message($content) {
|
| 7091 | - // Output Upgrade Notice |
|
| 7092 | - $matches = null; |
|
| 7093 | - $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 7094 | - $upgrade_notice = ''; |
|
| 7095 | - if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 7096 | - if(empty($matches)){return;}
|
|
| 7097 | - //print_r($matches ); |
|
| 7098 | - $version = trim( $matches[1] ); |
|
| 7099 | - if($version && $version>GEODIRECTORY_VERSION){
|
|
| 7100 | - |
|
| 7101 | - |
|
| 7102 | - $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 7103 | - if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
|
|
| 7104 | - $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
| 7105 | - foreach ( $notices as $index => $line ) {
|
|
| 7106 | - $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 7107 | - } |
|
| 7108 | - $upgrade_notice .= '</div> '; |
|
| 7109 | - } |
|
| 7110 | - } |
|
| 7111 | - } |
|
| 7112 | - echo $upgrade_notice; |
|
| 7091 | + // Output Upgrade Notice |
|
| 7092 | + $matches = null; |
|
| 7093 | + $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 7094 | + $upgrade_notice = ''; |
|
| 7095 | + if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 7096 | + if(empty($matches)){return;}
|
|
| 7097 | + //print_r($matches ); |
|
| 7098 | + $version = trim( $matches[1] ); |
|
| 7099 | + if($version && $version>GEODIRECTORY_VERSION){
|
|
| 7100 | + |
|
| 7101 | + |
|
| 7102 | + $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 7103 | + if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
|
|
| 7104 | + $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
| 7105 | + foreach ( $notices as $index => $line ) {
|
|
| 7106 | + $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 7107 | + } |
|
| 7108 | + $upgrade_notice .= '</div> '; |
|
| 7109 | + } |
|
| 7110 | + } |
|
| 7111 | + } |
|
| 7112 | + echo $upgrade_notice; |
|
| 7113 | 7113 | } |
| 7114 | 7114 | |
| 7115 | 7115 | /** |
@@ -183,8 +183,9 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | $thumb_img_arr = array(); |
| 185 | 185 | |
| 186 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 187 | - $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 186 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
| 187 | + $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 188 | + } |
|
| 188 | 189 | |
| 189 | 190 | $totImg = ''; |
| 190 | 191 | $image_limit = ''; |
@@ -240,7 +241,9 @@ discard block |
||
| 240 | 241 | {
|
| 241 | 242 | global $menu, $geodirectory; |
| 242 | 243 | |
| 243 | - if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
|
| 244 | + if (current_user_can('manage_options')) { |
|
| 245 | + $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory'); |
|
| 246 | + } |
|
| 244 | 247 | |
| 245 | 248 | add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
| 246 | 249 | |
@@ -309,7 +312,9 @@ discard block |
||
| 309 | 312 | */ |
| 310 | 313 | function geodir_admin_custom_menu_order() |
| 311 | 314 | {
|
| 312 | - if (!current_user_can('manage_options')) return false;
|
|
| 315 | + if (!current_user_can('manage_options')) { |
|
| 316 | + return false; |
|
| 317 | + } |
|
| 313 | 318 | return true; |
| 314 | 319 | } |
| 315 | 320 | } |
@@ -340,10 +345,11 @@ discard block |
||
| 340 | 345 | case 'fail': |
| 341 | 346 | $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
| 342 | 347 | |
| 343 | - if ($gderr == 21) |
|
| 344 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 345 | - else |
|
| 346 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 348 | + if ($gderr == 21) { |
|
| 349 | + 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>'; |
|
| 350 | + } else { |
|
| 351 | + echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>'; |
|
| 352 | + } |
|
| 347 | 353 | break; |
| 348 | 354 | } |
| 349 | 355 | } |
@@ -380,8 +386,12 @@ discard block |
||
| 380 | 386 | include_once('option-pages/' . $current_tab . '_array.php');
|
| 381 | 387 | } |
| 382 | 388 | if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
| 383 | - if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 384 | - if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 389 | + if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) { |
|
| 390 | + die(__('Action failed. Please refresh the page and retry.', 'geodirectory')); |
|
| 391 | + } |
|
| 392 | + if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) { |
|
| 393 | + die(__('Action failed. Please refresh the page and retry.', 'geodirectory')); |
|
| 394 | + } |
|
| 385 | 395 | |
| 386 | 396 | /** |
| 387 | 397 | * Fires before updating geodirectory admin settings. |
@@ -393,8 +403,9 @@ discard block |
||
| 393 | 403 | */ |
| 394 | 404 | do_action('geodir_before_update_options', $current_tab, $geodir_settings);
|
| 395 | 405 | |
| 396 | - if (!empty($geodir_settings[$current_tab])) |
|
| 397 | - geodir_update_options($geodir_settings[$current_tab]); |
|
| 406 | + if (!empty($geodir_settings[$current_tab])) { |
|
| 407 | + geodir_update_options($geodir_settings[$current_tab]); |
|
| 408 | + } |
|
| 398 | 409 | |
| 399 | 410 | /** |
| 400 | 411 | * Called after GeoDirectory options settings are updated. |
@@ -462,8 +473,9 @@ discard block |
||
| 462 | 473 | $options_list = ''; |
| 463 | 474 | for ($option = 1; $option <= 30; $option++) {
|
| 464 | 475 | $selected = ''; |
| 465 | - if ($option == 10) |
|
| 466 | - $selected = 'selected="selected"'; |
|
| 476 | + if ($option == 10) { |
|
| 477 | + $selected = 'selected="selected"'; |
|
| 478 | + } |
|
| 467 | 479 | |
| 468 | 480 | $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>'; |
| 469 | 481 | } |
@@ -663,10 +675,11 @@ discard block |
||
| 663 | 675 | } |
| 664 | 676 | |
| 665 | 677 | |
| 666 | - if (geodir_dummy_folder_exists()) |
|
| 667 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 668 | - else |
|
| 669 | - $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 678 | + if (geodir_dummy_folder_exists()) { |
|
| 679 | + $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 680 | + } else { |
|
| 681 | + $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 682 | + } |
|
| 670 | 683 | $catname = str_replace(' ', '_', $catname);
|
| 671 | 684 | $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
| 672 | 685 | |
@@ -704,10 +717,11 @@ discard block |
||
| 704 | 717 | if (!term_exists($catname, 'gd_placecategory')) {
|
| 705 | 718 | $last_catid = wp_insert_term($catname, 'gd_placecategory'); |
| 706 | 719 | |
| 707 | - if (geodir_dummy_folder_exists()) |
|
| 708 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 709 | - else |
|
| 710 | - $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 720 | + if (geodir_dummy_folder_exists()) { |
|
| 721 | + $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 722 | + } else { |
|
| 723 | + $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 724 | + } |
|
| 711 | 725 | $catname = str_replace(' ', '_', $catname);
|
| 712 | 726 | $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
| 713 | 727 | |
@@ -759,11 +773,14 @@ discard block |
||
| 759 | 773 | {
|
| 760 | 774 | // print_r($_POST); print_r($options); exit; |
| 761 | 775 | |
| 762 | - if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
| 776 | + if ((!isset($_POST) || !$_POST) && !$dummy) { |
|
| 777 | + return false; |
|
| 778 | + } |
|
| 763 | 779 | |
| 764 | 780 | foreach ($options as $value) {
|
| 765 | - if ($dummy && isset($value['std'])) |
|
| 766 | - $_POST[$value['id']] = $value['std']; |
|
| 781 | + if ($dummy && isset($value['std'])) { |
|
| 782 | + $_POST[$value['id']] = $value['std']; |
|
| 783 | + } |
|
| 767 | 784 | |
| 768 | 785 | |
| 769 | 786 | if (isset($value['type']) && $value['type'] == 'checkbox') : |
@@ -772,25 +789,23 @@ discard block |
||
| 772 | 789 | update_option($value['id'], $_POST[$value['id']]); |
| 773 | 790 | } else {
|
| 774 | 791 | update_option($value['id'], 0); |
| 775 | - } |
|
| 776 | - |
|
| 777 | - elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 792 | + } elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 778 | 793 | |
| 779 | 794 | if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
| 780 | 795 | update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
| 781 | 796 | update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
| 782 | 797 | if (isset($_POST[$value['id'] . '_crop'])) : |
| 783 | 798 | update_option($value['id'] . '_crop', 1); |
| 784 | - else : |
|
| 785 | - update_option($value['id'] . '_crop', 0); |
|
| 799 | + else { |
|
| 800 | + : |
|
| 801 | + update_option($value['id'] . '_crop', 0); |
|
| 802 | + } |
|
| 786 | 803 | endif; |
| 787 | 804 | } else {
|
| 788 | 805 | update_option($value['id'] . '_width', $value['std']); |
| 789 | 806 | update_option($value['id'] . '_height', $value['std']); |
| 790 | 807 | update_option($value['id'] . '_crop', 1); |
| 791 | - } |
|
| 792 | - |
|
| 793 | - elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 808 | + } elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 794 | 809 | $post_types = array(); |
| 795 | 810 | $categories = array(); |
| 796 | 811 | $i = 0; |
@@ -836,8 +851,9 @@ discard block |
||
| 836 | 851 | $image_name_arr = explode('/', get_option($value['id']));
|
| 837 | 852 | $noimg_name = end($image_name_arr); |
| 838 | 853 | $img_path = $uploads['path'] . '/' . $noimg_name; |
| 839 | - if (file_exists($img_path)) |
|
| 840 | - unlink($img_path); |
|
| 854 | + if (file_exists($img_path)) { |
|
| 855 | + unlink($img_path); |
|
| 856 | + } |
|
| 841 | 857 | } |
| 842 | 858 | |
| 843 | 859 | update_option($value['id'], ''); |
@@ -853,8 +869,10 @@ discard block |
||
| 853 | 869 | foreach ($uploadedfile as $key => $uplaod): |
| 854 | 870 | if ($key == 'name'): |
| 855 | 871 | $uplaods[$key] = $filename; |
| 856 | - else : |
|
| 857 | - $uplaods[$key] = $uplaod; |
|
| 872 | + else { |
|
| 873 | + : |
|
| 874 | + $uplaods[$key] = $uplaod; |
|
| 875 | + } |
|
| 858 | 876 | endif; |
| 859 | 877 | endforeach; |
| 860 | 878 | |
@@ -864,8 +882,9 @@ discard block |
||
| 864 | 882 | $image_name_arr = explode('/', get_option($value['id']));
|
| 865 | 883 | $noimg_name = end($image_name_arr); |
| 866 | 884 | $img_path = $uploads['path'] . '/' . $noimg_name; |
| 867 | - if (file_exists($img_path)) |
|
| 868 | - unlink($img_path); |
|
| 885 | + if (file_exists($img_path)) { |
|
| 886 | + unlink($img_path); |
|
| 887 | + } |
|
| 869 | 888 | } |
| 870 | 889 | |
| 871 | 890 | $upload_overrides = array('test_form' => false);
|
@@ -880,10 +899,12 @@ discard block |
||
| 880 | 899 | endif; |
| 881 | 900 | |
| 882 | 901 | |
| 883 | - else : |
|
| 902 | + else { |
|
| 903 | + : |
|
| 884 | 904 | // same menu setting per theme. |
| 885 | 905 | if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
| 886 | - $theme = wp_get_theme(); |
|
| 906 | + $theme = wp_get_theme(); |
|
| 907 | + } |
|
| 887 | 908 | update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
| 888 | 909 | } |
| 889 | 910 | |
@@ -895,8 +916,9 @@ discard block |
||
| 895 | 916 | |
| 896 | 917 | endif; |
| 897 | 918 | } |
| 898 | - if ($dummy) |
|
| 899 | - $_POST = array(); |
|
| 919 | + if ($dummy) { |
|
| 920 | + $_POST = array(); |
|
| 921 | + } |
|
| 900 | 922 | return true; |
| 901 | 923 | |
| 902 | 924 | } |
@@ -1041,9 +1063,12 @@ discard block |
||
| 1041 | 1063 | $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
|
| 1042 | 1064 | 'categorys' => __('Categories', 'geodirectory'));
|
| 1043 | 1065 | |
| 1044 | - if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
|
|
| 1066 | + if (($offset = array_search('author', array_keys($columns))) === false) { |
|
| 1067 | + // if the key doesn't exist |
|
| 1045 | 1068 | {
|
| 1046 | - $offset = 0; // should we prepend $array with $data? |
|
| 1069 | + $offset = 0; |
|
| 1070 | + } |
|
| 1071 | + // should we prepend $array with $data? |
|
| 1047 | 1072 | $offset = count($columns); // or should we append $array with $data? lets pick this one... |
| 1048 | 1073 | } |
| 1049 | 1074 | |
@@ -1103,11 +1128,13 @@ discard block |
||
| 1103 | 1128 | $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
| 1104 | 1129 | } |
| 1105 | 1130 | /* If no expire_date is found, output a default message. */ |
| 1106 | - if (empty($expire_date)) |
|
| 1107 | - echo __('Unknown', 'geodirectory');
|
|
| 1131 | + if (empty($expire_date)) { |
|
| 1132 | + echo __('Unknown', 'geodirectory'); |
|
| 1133 | + } |
|
| 1108 | 1134 | /* If there is a expire_date, append 'days left' to the text string. */ |
| 1109 | - else |
|
| 1110 | - echo $expire_date . $date_diff_text; |
|
| 1135 | + else { |
|
| 1136 | + echo $expire_date . $date_diff_text; |
|
| 1137 | + } |
|
| 1111 | 1138 | break; |
| 1112 | 1139 | |
| 1113 | 1140 | /* If displaying the 'categorys' column. */ |
@@ -1180,21 +1207,26 @@ discard block |
||
| 1180 | 1207 | |
| 1181 | 1208 | $geodir_posttypes = geodir_get_posttypes(); |
| 1182 | 1209 | |
| 1183 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
|
| 1184 | - return; |
|
| 1210 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 1211 | + return; |
|
| 1212 | + } |
|
| 1185 | 1213 | |
| 1186 | 1214 | if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
| 1187 | - if (isset($_REQUEST['_status'])) |
|
| 1188 | - geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 1215 | + if (isset($_REQUEST['_status'])) { |
|
| 1216 | + geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 1217 | + } |
|
| 1189 | 1218 | |
| 1190 | - if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
| 1191 | - return; |
|
| 1219 | + if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) { |
|
| 1220 | + return; |
|
| 1221 | + } |
|
| 1192 | 1222 | |
| 1193 | - if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
| 1194 | - return; |
|
| 1223 | + if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) { |
|
| 1224 | + return; |
|
| 1225 | + } |
|
| 1195 | 1226 | |
| 1196 | - if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
| 1197 | - return; |
|
| 1227 | + if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) { |
|
| 1228 | + return; |
|
| 1229 | + } |
|
| 1198 | 1230 | |
| 1199 | 1231 | geodir_save_listing($_REQUEST); |
| 1200 | 1232 | } |
@@ -2002,8 +2034,9 @@ discard block |
||
| 2002 | 2034 | 'geo_lng' => $post_longitude); |
| 2003 | 2035 | |
| 2004 | 2036 | $post_location_info = $request_info['post_location']; |
| 2005 | - if ($location_id = geodir_add_new_location($post_location_info)) |
|
| 2006 | - $post_location_id = $location_id; |
|
| 2037 | + if ($location_id = geodir_add_new_location($post_location_info)) { |
|
| 2038 | + $post_location_id = $location_id; |
|
| 2039 | + } |
|
| 2007 | 2040 | |
| 2008 | 2041 | } else {
|
| 2009 | 2042 | $post_location_id = 0; |
@@ -2067,8 +2100,9 @@ discard block |
||
| 2067 | 2100 | $attachment_set = ''; |
| 2068 | 2101 | |
| 2069 | 2102 | foreach ($attachment as $key => $val) {
|
| 2070 | - if ($val != '') |
|
| 2071 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 2103 | + if ($val != '') { |
|
| 2104 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 2105 | + } |
|
| 2072 | 2106 | } |
| 2073 | 2107 | |
| 2074 | 2108 | $attachment_set = trim($attachment_set, ", "); |
@@ -2118,8 +2152,9 @@ discard block |
||
| 2118 | 2152 | fclose($fd); |
| 2119 | 2153 | //unlink($csv_target_path); |
| 2120 | 2154 | //rmdir($destination_path); |
| 2121 | - if (!empty($filename)) |
|
| 2122 | - geodir_remove_temp_images(); |
|
| 2155 | + if (!empty($filename)) { |
|
| 2156 | + geodir_remove_temp_images(); |
|
| 2157 | + } |
|
| 2123 | 2158 | |
| 2124 | 2159 | |
| 2125 | 2160 | echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&msg=success&rowcount=' . $countpost . '&invalidcount=' . $address_invalid . '&blank_address=' . $blank_address . '&upload_files=' . $upload_files . '&invalid_post_type=' . $invalid_post_type . '&invalid_title=' . $invalid_title . '&total_records=' . $total_records; |
@@ -2152,10 +2187,18 @@ discard block |
||
| 2152 | 2187 | $tab_id = ''; |
| 2153 | 2188 | $i = 0; |
| 2154 | 2189 | foreach ($options as $value) : |
| 2155 | - if (!isset($value['name'])) $value['name'] = ''; |
|
| 2156 | - if (!isset($value['class'])) $value['class'] = ''; |
|
| 2157 | - if (!isset($value['css'])) $value['css'] = ''; |
|
| 2158 | - if (!isset($value['std'])) $value['std'] = ''; |
|
| 2190 | + if (!isset($value['name'])) { |
|
| 2191 | + $value['name'] = ''; |
|
| 2192 | + } |
|
| 2193 | + if (!isset($value['class'])) { |
|
| 2194 | + $value['class'] = ''; |
|
| 2195 | + } |
|
| 2196 | + if (!isset($value['css'])) { |
|
| 2197 | + $value['css'] = ''; |
|
| 2198 | + } |
|
| 2199 | + if (!isset($value['std'])) { |
|
| 2200 | + $value['std'] = ''; |
|
| 2201 | + } |
|
| 2159 | 2202 | $desc = ''; |
| 2160 | 2203 | switch ($value['type']) : |
| 2161 | 2204 | case 'dummy_installer': |
@@ -2174,11 +2217,13 @@ discard block |
||
| 2174 | 2217 | |
| 2175 | 2218 | $i++; |
| 2176 | 2219 | |
| 2177 | - if (isset($value['id']) && $value['id']) |
|
| 2178 | - $tab_id = $value['id']; |
|
| 2220 | + if (isset($value['id']) && $value['id']) { |
|
| 2221 | + $tab_id = $value['id']; |
|
| 2222 | + } |
|
| 2179 | 2223 | |
| 2180 | - if (isset($value['desc']) && $value['desc']) |
|
| 2181 | - $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 2224 | + if (isset($value['desc']) && $value['desc']) { |
|
| 2225 | + $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 2226 | + } |
|
| 2182 | 2227 | |
| 2183 | 2228 | if (isset($value['name']) && $value['name']) {
|
| 2184 | 2229 | if ($first_title === true) {
|
@@ -2209,10 +2254,12 @@ discard block |
||
| 2209 | 2254 | break; |
| 2210 | 2255 | |
| 2211 | 2256 | case 'sectionstart': |
| 2212 | - if (isset($value['desc']) && $value['desc']) |
|
| 2213 | - $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 2214 | - if (isset($value['name']) && $value['name']) |
|
| 2215 | - echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 2257 | + if (isset($value['desc']) && $value['desc']) { |
|
| 2258 | + $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 2259 | + } |
|
| 2260 | + if (isset($value['name']) && $value['name']) { |
|
| 2261 | + echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 2262 | + } |
|
| 2216 | 2263 | /** |
| 2217 | 2264 | * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
| 2218 | 2265 | * |
@@ -2220,7 +2267,9 @@ discard block |
||
| 2220 | 2267 | * |
| 2221 | 2268 | * @since 1.0.0 |
| 2222 | 2269 | */ |
| 2223 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 2270 | + if (isset($value['id']) && $value['id']) { |
|
| 2271 | + do_action('geodir_settings_' . sanitize_title($value['id']) . '_start'); |
|
| 2272 | + } |
|
| 2224 | 2273 | echo '<table class="form-table">' . "\n\n"; |
| 2225 | 2274 | |
| 2226 | 2275 | break; |
@@ -2232,7 +2281,9 @@ discard block |
||
| 2232 | 2281 | * |
| 2233 | 2282 | * @since 1.0.0 |
| 2234 | 2283 | */ |
| 2235 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 2284 | + if (isset($value['id']) && $value['id']) { |
|
| 2285 | + do_action('geodir_settings_' . sanitize_title($value['id']) . '_end'); |
|
| 2286 | + } |
|
| 2236 | 2287 | echo '</table>'; |
| 2237 | 2288 | /** |
| 2238 | 2289 | * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
@@ -2241,7 +2292,9 @@ discard block |
||
| 2241 | 2292 | * |
| 2242 | 2293 | * @since 1.0.0 |
| 2243 | 2294 | */ |
| 2244 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 2295 | + if (isset($value['id']) && $value['id']) { |
|
| 2296 | + do_action('geodir_settings_' . sanitize_title($value['id']) . '_after'); |
|
| 2297 | + } |
|
| 2245 | 2298 | break; |
| 2246 | 2299 | case 'text': |
| 2247 | 2300 | ?> |
@@ -2313,17 +2366,32 @@ discard block |
||
| 2313 | 2366 | <?php _e('Width', 'geodirectory'); ?> <input
|
| 2314 | 2367 | name="<?php echo esc_attr($value['id']); ?>_width" |
| 2315 | 2368 | id="<?php echo esc_attr($value['id']); ?>_width" type="text" size="3" |
| 2316 | - value="<?php if ($size = get_option($value['id'] . '_width')) echo stripslashes($size); else echo $value['std']; ?>"/> |
|
| 2369 | + value="<?php if ($size = get_option($value['id'] . '_width')) { |
|
| 2370 | + echo stripslashes($size); |
|
| 2371 | +} else { |
|
| 2372 | + echo $value['std']; |
|
| 2373 | +} |
|
| 2374 | +?>"/> |
|
| 2317 | 2375 | |
| 2318 | 2376 | <?php _e('Height', 'geodirectory'); ?> <input
|
| 2319 | 2377 | name="<?php echo esc_attr($value['id']); ?>_height" |
| 2320 | 2378 | id="<?php echo esc_attr($value['id']); ?>_height" type="text" size="3" |
| 2321 | - value="<?php if ($size = get_option($value['id'] . '_height')) echo stripslashes($size); else echo $value['std']; ?>"/> |
|
| 2379 | + value="<?php if ($size = get_option($value['id'] . '_height')) { |
|
| 2380 | + echo stripslashes($size); |
|
| 2381 | +} else { |
|
| 2382 | + echo $value['std']; |
|
| 2383 | +} |
|
| 2384 | +?>"/> |
|
| 2322 | 2385 | |
| 2323 | 2386 | <label><?php _e('Hard Crop', 'geodirectory'); ?> <input
|
| 2324 | 2387 | name="<?php echo esc_attr($value['id']); ?>_crop" |
| 2325 | 2388 | id="<?php echo esc_attr($value['id']); ?>_crop" |
| 2326 | - type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') checked(get_option($value['id'] . '_crop'), 1); else checked(1); ?> /></label> |
|
| 2389 | + type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') { |
|
| 2390 | + checked(get_option($value['id'] . '_crop'), 1); |
|
| 2391 | +} else { |
|
| 2392 | + checked(1); |
|
| 2393 | +} |
|
| 2394 | +?> /></label> |
|
| 2327 | 2395 | |
| 2328 | 2396 | <span class="description"><?php echo $value['desc'] ?></span></td> |
| 2329 | 2397 | </tr><?php |
@@ -2335,17 +2403,22 @@ discard block |
||
| 2335 | 2403 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
| 2336 | 2404 | id="<?php echo esc_attr($value['id']); ?>" |
| 2337 | 2405 | style="<?php echo esc_attr($value['css']); ?>" |
| 2338 | - class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
|
| 2406 | + class="<?php if (isset($value['class'])) { |
|
| 2407 | + echo $value['class']; |
|
| 2408 | +} |
|
| 2409 | +?>" |
|
| 2339 | 2410 | option-ajaxchosen="false"> |
| 2340 | 2411 | <?php |
| 2341 | 2412 | foreach ($value['options'] as $key => $val) {
|
| 2342 | 2413 | $geodir_select_value = ''; |
| 2343 | 2414 | if (get_option($value['id']) != '') {
|
| 2344 | - if (get_option($value['id']) != '' && get_option($value['id']) == $key) |
|
| 2345 | - $geodir_select_value = ' selected="selected" '; |
|
| 2415 | + if (get_option($value['id']) != '' && get_option($value['id']) == $key) { |
|
| 2416 | + $geodir_select_value = ' selected="selected" '; |
|
| 2417 | + } |
|
| 2346 | 2418 | } else {
|
| 2347 | - if ($value['std'] == $key) |
|
| 2348 | - $geodir_select_value = ' selected="selected" '; |
|
| 2419 | + if ($value['std'] == $key) { |
|
| 2420 | + $geodir_select_value = ' selected="selected" '; |
|
| 2421 | + } |
|
| 2349 | 2422 | } |
| 2350 | 2423 | |
| 2351 | 2424 | |
@@ -2367,8 +2440,14 @@ discard block |
||
| 2367 | 2440 | <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]" |
| 2368 | 2441 | id="<?php echo esc_attr($value['id']); ?>" |
| 2369 | 2442 | style="<?php echo esc_attr($value['css']); ?>" |
| 2370 | - class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
|
| 2371 | - data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>" |
|
| 2443 | + class="<?php if (isset($value['class'])) { |
|
| 2444 | + echo $value['class']; |
|
| 2445 | +} |
|
| 2446 | +?>" |
|
| 2447 | + data-placeholder="<?php if (isset($value['placeholder_text'])) { |
|
| 2448 | + echo $value['placeholder_text']; |
|
| 2449 | +} |
|
| 2450 | +?>" |
|
| 2372 | 2451 | option-ajaxchosen="false"> |
| 2373 | 2452 | <?php |
| 2374 | 2453 | foreach ($value['options'] as $key => $val) {
|
@@ -2397,7 +2476,10 @@ discard block |
||
| 2397 | 2476 | <td class="forminp"> |
| 2398 | 2477 | <input type="file" name="<?php echo esc_attr($value['id']); ?>" |
| 2399 | 2478 | id="<?php echo esc_attr($value['id']); ?>" style="<?php echo esc_attr($value['css']); ?>" |
| 2400 | - class="<?php if (isset($value['class'])) echo $value['class']; ?>"/> |
|
| 2479 | + class="<?php if (isset($value['class'])) { |
|
| 2480 | + echo $value['class']; |
|
| 2481 | +} |
|
| 2482 | +?>"/> |
|
| 2401 | 2483 | <?php if (get_option($value['id'])) { ?>
|
| 2402 | 2484 | <input type="hidden" name="<?php echo esc_attr($value['id']); ?>_remove" |
| 2403 | 2485 | id="<?php echo esc_attr($value['id']); ?>_remove" value="0"> |
@@ -2478,13 +2560,15 @@ discard block |
||
| 2478 | 2560 | 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
|
| 2479 | 2561 | ); |
| 2480 | 2562 | $geodir_default_map_language = get_option('geodir_default_map_language');
|
| 2481 | - if (empty($geodir_default_map_language)) |
|
| 2482 | - $geodir_default_map_language = 'en'; |
|
| 2563 | + if (empty($geodir_default_map_language)) { |
|
| 2564 | + $geodir_default_map_language = 'en'; |
|
| 2565 | + } |
|
| 2483 | 2566 | foreach ($arr_map_langages as $language_key => $language_txt) {
|
| 2484 | - if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
| 2485 | - $geodir_default_language_selected = "selected='selected'"; |
|
| 2486 | - else |
|
| 2487 | - $geodir_default_language_selected = ''; |
|
| 2567 | + if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) { |
|
| 2568 | + $geodir_default_language_selected = "selected='selected'"; |
|
| 2569 | + } else { |
|
| 2570 | + $geodir_default_language_selected = ''; |
|
| 2571 | + } |
|
| 2488 | 2572 | |
| 2489 | 2573 | ?> |
| 2490 | 2574 | <option |
@@ -2504,14 +2588,16 @@ discard block |
||
| 2504 | 2588 | <?php |
| 2505 | 2589 | $post_types = geodir_get_posttypes('array');
|
| 2506 | 2590 | $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
|
| 2507 | - if (empty($geodir_default_map_search_pt)) |
|
| 2508 | - $geodir_default_map_search_pt = 'gd_place'; |
|
| 2591 | + if (empty($geodir_default_map_search_pt)) { |
|
| 2592 | + $geodir_default_map_search_pt = 'gd_place'; |
|
| 2593 | + } |
|
| 2509 | 2594 | if (is_array($post_types)) {
|
| 2510 | 2595 | foreach ($post_types as $key => $post_types_obj) {
|
| 2511 | - if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
| 2512 | - $geodir_search_pt_selected = "selected='selected'"; |
|
| 2513 | - else |
|
| 2514 | - $geodir_search_pt_selected = ''; |
|
| 2596 | + if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) { |
|
| 2597 | + $geodir_search_pt_selected = "selected='selected'"; |
|
| 2598 | + } else { |
|
| 2599 | + $geodir_search_pt_selected = ''; |
|
| 2600 | + } |
|
| 2515 | 2601 | |
| 2516 | 2602 | ?> |
| 2517 | 2603 | <option |
@@ -2631,7 +2717,7 @@ discard block |
||
| 2631 | 2717 | id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio" |
| 2632 | 2718 | value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
|
| 2633 | 2719 | echo 'checked="checked"'; |
| 2634 | - }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 2720 | + } elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 2635 | 2721 | <?php echo $value['desc']; ?></label><br> |
| 2636 | 2722 | </fieldset> |
| 2637 | 2723 | <?php |
@@ -2651,10 +2737,18 @@ discard block |
||
| 2651 | 2737 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 2652 | 2738 | <td class="forminp"> |
| 2653 | 2739 | <textarea |
| 2654 | - <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>" |
|
| 2740 | + <?php if (isset($value['args'])) { |
|
| 2741 | + echo $value['args'] . ' '; |
|
| 2742 | +} |
|
| 2743 | +?>name="<?php echo esc_attr($value['id']); ?>" |
|
| 2655 | 2744 | id="<?php echo esc_attr($value['id']); ?>" |
| 2656 | 2745 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 2657 | - 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 |
|
| 2746 | + style="<?php echo esc_attr($value['css']); ?>"><?php if (get_option($value['id'])) { |
|
| 2747 | + echo esc_textarea(stripslashes(get_option($value['id']))); |
|
| 2748 | +} else { |
|
| 2749 | + echo esc_textarea($value['std']); |
|
| 2750 | +} |
|
| 2751 | +?></textarea><span |
|
| 2658 | 2752 | class="description"><?php echo $value['desc'] ?></span> |
| 2659 | 2753 | |
| 2660 | 2754 | </td> |
@@ -2668,10 +2762,11 @@ discard block |
||
| 2668 | 2762 | <td class="forminp"><?php |
| 2669 | 2763 | |
| 2670 | 2764 | $content = ''; |
| 2671 | - if (get_option($value['id'])) |
|
| 2672 | - $content = stripslashes(get_option($value['id'])); |
|
| 2673 | - else |
|
| 2674 | - $content = $value['std']; |
|
| 2765 | + if (get_option($value['id'])) { |
|
| 2766 | + $content = stripslashes(get_option($value['id'])); |
|
| 2767 | + } else { |
|
| 2768 | + $content = $value['std']; |
|
| 2769 | + } |
|
| 2675 | 2770 | |
| 2676 | 2771 | $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
| 2677 | 2772 | |
@@ -2711,7 +2806,9 @@ discard block |
||
| 2711 | 2806 | 'echo' => false, |
| 2712 | 2807 | 'selected' => $page_setting); |
| 2713 | 2808 | |
| 2714 | - if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
| 2809 | + if (isset($value['args'])) { |
|
| 2810 | + $args = wp_parse_args($value['args'], $args); |
|
| 2811 | + } |
|
| 2715 | 2812 | |
| 2716 | 2813 | ?> |
| 2717 | 2814 | <tr valign="top" class="single_select_page"> |
@@ -2731,8 +2828,10 @@ discard block |
||
| 2731 | 2828 | if (strstr($country_setting, ':')) : |
| 2732 | 2829 | $country = current(explode(':', $country_setting));
|
| 2733 | 2830 | $state = end(explode(':', $country_setting));
|
| 2734 | - else : |
|
| 2735 | - $country = $country_setting; |
|
| 2831 | + else { |
|
| 2832 | + : |
|
| 2833 | + $country = $country_setting; |
|
| 2834 | + } |
|
| 2736 | 2835 | $state = '*'; |
| 2737 | 2836 | endif; |
| 2738 | 2837 | ?> |
@@ -2759,8 +2858,10 @@ discard block |
||
| 2759 | 2858 | data-placeholder="<?php _e('Choose countries…', 'geodirectory'); ?>"
|
| 2760 | 2859 | title="Country" class="chosen_select"> |
| 2761 | 2860 | <?php |
| 2762 | - if ($countries) foreach ($countries as $key => $val) : |
|
| 2763 | - echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 2861 | + if ($countries) { |
|
| 2862 | + foreach ($countries as $key => $val) : |
|
| 2863 | + echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 2864 | + } |
|
| 2764 | 2865 | endforeach; |
| 2765 | 2866 | ?> |
| 2766 | 2867 | </select> |
@@ -3011,8 +3112,9 @@ discard block |
||
| 3011 | 3112 | endforeach; |
| 3012 | 3113 | endif; |
| 3013 | 3114 | |
| 3014 | - if (!empty($place_img_array)) |
|
| 3015 | - $curImages = implode(',', $place_img_array);
|
|
| 3115 | + if (!empty($place_img_array)) { |
|
| 3116 | + $curImages = implode(',', $place_img_array); |
|
| 3117 | + } |
|
| 3016 | 3118 | |
| 3017 | 3119 | |
| 3018 | 3120 | // adjust values here |
@@ -3359,16 +3461,17 @@ discard block |
||
| 3359 | 3461 | |
| 3360 | 3462 | $post_type = NULL; |
| 3361 | 3463 | |
| 3362 | - if ($post && isset($post->post_type)) |
|
| 3363 | - $post_type = $post->post_type; |
|
| 3364 | - elseif ($typenow) |
|
| 3365 | - $post_type = $typenow; |
|
| 3366 | - elseif ($current_screen && isset($current_screen->post_type)) |
|
| 3367 | - $post_type = $current_screen->post_type; |
|
| 3368 | - elseif (isset($_REQUEST['post_type'])) |
|
| 3369 | - $post_type = sanitize_key($_REQUEST['post_type']); |
|
| 3370 | - elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 3371 | - $post_type = get_post_type($_REQUEST['post']); |
|
| 3464 | + if ($post && isset($post->post_type)) { |
|
| 3465 | + $post_type = $post->post_type; |
|
| 3466 | + } elseif ($typenow) { |
|
| 3467 | + $post_type = $typenow; |
|
| 3468 | + } elseif ($current_screen && isset($current_screen->post_type)) { |
|
| 3469 | + $post_type = $current_screen->post_type; |
|
| 3470 | + } elseif (isset($_REQUEST['post_type'])) { |
|
| 3471 | + $post_type = sanitize_key($_REQUEST['post_type']); |
|
| 3472 | + } elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) { |
|
| 3473 | + $post_type = get_post_type($_REQUEST['post']); |
|
| 3474 | + } |
|
| 3372 | 3475 | |
| 3373 | 3476 | return $post_type; |
| 3374 | 3477 | } |
@@ -3427,9 +3530,10 @@ discard block |
||
| 3427 | 3530 | function geodir_hide_admin_preview_button() {
|
| 3428 | 3531 | global $post_type; |
| 3429 | 3532 | $post_types = geodir_get_posttypes(); |
| 3430 | - if(in_array($post_type, $post_types)) |
|
| 3431 | - echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
|
| 3432 | -} |
|
| 3533 | + if(in_array($post_type, $post_types)) { |
|
| 3534 | + echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>'; |
|
| 3535 | + } |
|
| 3536 | + } |
|
| 3433 | 3537 | add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' ); |
| 3434 | 3538 | add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' ); |
| 3435 | 3539 | |
@@ -6223,8 +6327,9 @@ discard block |
||
| 6223 | 6327 | function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
| 6224 | 6328 | global $wpdb, $plugin_prefix; |
| 6225 | 6329 | |
| 6226 | - if ( ! post_type_exists( $post_type ) ) |
|
| 6227 | - return new stdClass; |
|
| 6330 | + if ( ! post_type_exists( $post_type ) ) { |
|
| 6331 | + return new stdClass; |
|
| 6332 | + } |
|
| 6228 | 6333 | |
| 6229 | 6334 | $table = $plugin_prefix . $post_type . '_detail'; |
| 6230 | 6335 | |
@@ -7004,7 +7109,9 @@ discard block |
||
| 7004 | 7109 | |
| 7005 | 7110 | if ($page_found) : |
| 7006 | 7111 | // Page exists |
| 7007 | - if (!$option_value) update_option($option, $page_found); |
|
| 7112 | + if (!$option_value) { |
|
| 7113 | + update_option($option, $page_found); |
|
| 7114 | + } |
|
| 7008 | 7115 | return; |
| 7009 | 7116 | endif; |
| 7010 | 7117 | |