@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | function geodir_deactivation() |
| 16 | 16 | {
|
| 17 | 17 | |
| 18 | - // Update installed variable |
|
| 19 | - update_option("geodir_installed", 0);
|
|
| 18 | + // Update installed variable |
|
| 19 | + update_option("geodir_installed", 0);
|
|
| 20 | 20 | |
| 21 | - // Remove rewrite rules and then recreate rewrite rules. |
|
| 22 | - flush_rewrite_rules(); |
|
| 21 | + // Remove rewrite rules and then recreate rewrite rules. |
|
| 22 | + flush_rewrite_rules(); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
@@ -32,124 +32,124 @@ discard block |
||
| 32 | 32 | function geodir_uninstall() |
| 33 | 33 | {
|
| 34 | 34 | |
| 35 | - delete_option('geodir_default_data_installed');
|
|
| 35 | + delete_option('geodir_default_data_installed');
|
|
| 36 | 36 | |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | if (!function_exists('geodir_admin_styles')) {
|
| 40 | - /** |
|
| 41 | - * Enqueue Admin Styles. |
|
| 42 | - * |
|
| 43 | - * @since 1.0.0 |
|
| 44 | - * @package GeoDirectory |
|
| 45 | - */ |
|
| 46 | - function geodir_admin_styles() |
|
| 47 | - {
|
|
| 40 | + /** |
|
| 41 | + * Enqueue Admin Styles. |
|
| 42 | + * |
|
| 43 | + * @since 1.0.0 |
|
| 44 | + * @package GeoDirectory |
|
| 45 | + */ |
|
| 46 | + function geodir_admin_styles() |
|
| 47 | + {
|
|
| 48 | 48 | |
| 49 | - wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
|
|
| 50 | - wp_enqueue_style('geodirectory-admin-css');
|
|
| 49 | + wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
|
|
| 50 | + wp_enqueue_style('geodirectory-admin-css');
|
|
| 51 | 51 | |
| 52 | - wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
|
|
| 53 | - wp_enqueue_style('geodirectory-frontend-style');
|
|
| 52 | + wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
|
|
| 53 | + wp_enqueue_style('geodirectory-frontend-style');
|
|
| 54 | 54 | |
| 55 | - wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
|
|
| 56 | - wp_enqueue_style('geodir-chosen-style');
|
|
| 55 | + wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
|
|
| 56 | + wp_enqueue_style('geodir-chosen-style');
|
|
| 57 | 57 | |
| 58 | - wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
|
|
| 59 | - wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
|
|
| 58 | + wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
|
|
| 59 | + wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
|
|
| 60 | 60 | |
| 61 | - wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
|
|
| 62 | - wp_enqueue_style('geodirectory-jquery-ui-css');
|
|
| 61 | + wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
|
|
| 62 | + wp_enqueue_style('geodirectory-jquery-ui-css');
|
|
| 63 | 63 | |
| 64 | - wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
|
|
| 65 | - wp_enqueue_style('geodirectory-custom-fields-css');
|
|
| 64 | + wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
|
|
| 65 | + wp_enqueue_style('geodirectory-custom-fields-css');
|
|
| 66 | 66 | |
| 67 | - wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
|
|
| 68 | - wp_enqueue_style('geodirectory-pluplodar-css');
|
|
| 67 | + wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
|
|
| 68 | + wp_enqueue_style('geodirectory-pluplodar-css');
|
|
| 69 | 69 | |
| 70 | - wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
|
|
| 71 | - wp_enqueue_style('geodir-rating-style');
|
|
| 70 | + wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
|
|
| 71 | + wp_enqueue_style('geodir-rating-style');
|
|
| 72 | 72 | |
| 73 | - wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
|
|
| 74 | - wp_enqueue_style('geodir-rtl-style');
|
|
| 73 | + wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
|
|
| 74 | + wp_enqueue_style('geodir-rtl-style');
|
|
| 75 | 75 | |
| 76 | - } |
|
| 76 | + } |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | if (!function_exists('geodir_admin_styles_req')) {
|
| 80 | - /** |
|
| 81 | - * Loads stylesheets from CDN. |
|
| 82 | - * |
|
| 83 | - * @since 1.0.0 |
|
| 84 | - * @package GeoDirectory |
|
| 85 | - */ |
|
| 86 | - function geodir_admin_styles_req() |
|
| 87 | - {
|
|
| 80 | + /** |
|
| 81 | + * Loads stylesheets from CDN. |
|
| 82 | + * |
|
| 83 | + * @since 1.0.0 |
|
| 84 | + * @package GeoDirectory |
|
| 85 | + */ |
|
| 86 | + function geodir_admin_styles_req() |
|
| 87 | + {
|
|
| 88 | 88 | |
| 89 | - wp_register_style('geodirectory-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
|
|
| 90 | - wp_enqueue_style('geodirectory-font-awesome');
|
|
| 89 | + wp_register_style('geodirectory-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
|
|
| 90 | + wp_enqueue_style('geodirectory-font-awesome');
|
|
| 91 | 91 | |
| 92 | - wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 93 | - wp_enqueue_script('geodirectory-admin');
|
|
| 92 | + wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 93 | + wp_enqueue_script('geodirectory-admin');
|
|
| 94 | 94 | |
| 95 | - } |
|
| 95 | + } |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | if (!function_exists('geodir_admin_scripts')) {
|
| 99 | - /** |
|
| 100 | - * Enqueue Admin Scripts. |
|
| 101 | - * |
|
| 102 | - * @since 1.0.0 |
|
| 103 | - * @package GeoDirectory |
|
| 104 | - */ |
|
| 105 | - function geodir_admin_scripts() |
|
| 106 | - {
|
|
| 107 | - $geodir_map_name = geodir_map_name(); |
|
| 99 | + /** |
|
| 100 | + * Enqueue Admin Scripts. |
|
| 101 | + * |
|
| 102 | + * @since 1.0.0 |
|
| 103 | + * @package GeoDirectory |
|
| 104 | + */ |
|
| 105 | + function geodir_admin_scripts() |
|
| 106 | + {
|
|
| 107 | + $geodir_map_name = geodir_map_name(); |
|
| 108 | 108 | |
| 109 | - wp_enqueue_script('jquery');
|
|
| 109 | + wp_enqueue_script('jquery');
|
|
| 110 | 110 | |
| 111 | - wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
|
|
| 111 | + wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
|
|
| 112 | 112 | |
| 113 | - wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 114 | - wp_enqueue_script('chosen');
|
|
| 113 | + wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 114 | + wp_enqueue_script('chosen');
|
|
| 115 | 115 | |
| 116 | - wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
|
|
| 117 | - wp_enqueue_script('geodirectory-choose-ajax');
|
|
| 116 | + wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
|
|
| 117 | + wp_enqueue_script('geodirectory-choose-ajax');
|
|
| 118 | 118 | |
| 119 | - if (isset($_REQUEST['listing_type'])) {
|
|
| 120 | - wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
|
|
| 121 | - } |
|
| 119 | + if (isset($_REQUEST['listing_type'])) {
|
|
| 120 | + wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
|
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - wp_enqueue_script('geodirectory-custom-fields-script');
|
|
| 124 | - $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
| 123 | + wp_enqueue_script('geodirectory-custom-fields-script');
|
|
| 124 | + $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
| 125 | 125 | |
| 126 | - wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
|
|
| 126 | + wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
|
|
| 127 | 127 | |
| 128 | - if (in_array($geodir_map_name, array('auto', 'google'))) {
|
|
| 129 | - $map_lang = "&language=" . geodir_get_map_default_language(); |
|
| 130 | - /** This filter is documented in geodirectory_template_tags.php */ |
|
| 131 | - $map_extra = apply_filters('geodir_googlemap_script_extra', '');
|
|
| 132 | - wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
|
|
| 133 | - } |
|
| 128 | + if (in_array($geodir_map_name, array('auto', 'google'))) {
|
|
| 129 | + $map_lang = "&language=" . geodir_get_map_default_language(); |
|
| 130 | + /** This filter is documented in geodirectory_template_tags.php */ |
|
| 131 | + $map_extra = apply_filters('geodir_googlemap_script_extra', '');
|
|
| 132 | + wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
|
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - if ($geodir_map_name == 'osm') {
|
|
| 136 | - // Leaflet OpenStreetMap |
|
| 137 | - wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 138 | - wp_enqueue_style('geodirectory-leaflet-style');
|
|
| 135 | + if ($geodir_map_name == 'osm') {
|
|
| 136 | + // Leaflet OpenStreetMap |
|
| 137 | + wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 138 | + wp_enqueue_style('geodirectory-leaflet-style');
|
|
| 139 | 139 | |
| 140 | - wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 141 | - wp_enqueue_script('geodirectory-leaflet-script');
|
|
| 140 | + wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 141 | + wp_enqueue_script('geodirectory-leaflet-script');
|
|
| 142 | 142 | |
| 143 | - wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
|
|
| 144 | - wp_enqueue_script('geodirectory-leaflet-geo-script');
|
|
| 145 | - } |
|
| 146 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 143 | + wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
|
|
| 144 | + wp_enqueue_script('geodirectory-leaflet-geo-script');
|
|
| 145 | + } |
|
| 146 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 147 | 147 | |
| 148 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 149 | - wp_enqueue_script('geodirectory-goMap-script');
|
|
| 148 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 149 | + wp_enqueue_script('geodirectory-goMap-script');
|
|
| 150 | 150 | |
| 151 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 152 | - wp_enqueue_script('geodirectory-goMap-script');
|
|
| 151 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 152 | + wp_enqueue_script('geodirectory-goMap-script');
|
|
| 153 | 153 | |
| 154 | 154 | // font awesome rating script |
| 155 | 155 | if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
@@ -160,167 +160,167 @@ discard block |
||
| 160 | 160 | wp_enqueue_script('geodir-jRating-js');
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
|
|
| 164 | - wp_enqueue_script('geodir-on-document-load');
|
|
| 165 | - |
|
| 166 | - |
|
| 167 | - // SCRIPT FOR UPLOAD |
|
| 168 | - wp_enqueue_script('plupload-all');
|
|
| 169 | - wp_enqueue_script('jquery-ui-sortable');
|
|
| 170 | - |
|
| 171 | - wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 172 | - wp_enqueue_script('geodirectory-plupload-script');
|
|
| 173 | - |
|
| 174 | - // SCRIPT FOR UPLOAD END |
|
| 175 | - |
|
| 176 | - |
|
| 177 | - // place js config array for plupload |
|
| 178 | - $plupload_init = array( |
|
| 179 | - 'runtimes' => 'html5,silverlight,flash,html4', |
|
| 180 | - 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
| 181 | - 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
| 182 | - 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
| 183 | - 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
| 184 | - 'multiple_queues' => true, |
|
| 185 | - 'max_file_size' => geodir_max_upload_size(), |
|
| 186 | - 'url' => admin_url('admin-ajax.php'),
|
|
| 187 | - 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
|
| 188 | - 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
|
| 189 | - 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
|
|
| 190 | - 'multipart' => true, |
|
| 191 | - 'urlstream_upload' => true, |
|
| 192 | - 'multi_selection' => false, // will be added per uploader |
|
| 193 | - // additional post data to send to our ajax hook |
|
| 194 | - 'multipart_params' => array( |
|
| 195 | - '_ajax_nonce' => "", // will be added per uploader |
|
| 196 | - 'action' => 'plupload_action', // the ajax action name |
|
| 197 | - 'imgid' => 0 // will be added per uploader |
|
| 198 | - ) |
|
| 199 | - ); |
|
| 200 | - $base_plupload_config = json_encode($plupload_init); |
|
| 201 | - |
|
| 202 | - |
|
| 203 | - $thumb_img_arr = array(); |
|
| 204 | - |
|
| 205 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 206 | - $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 207 | - |
|
| 208 | - $totImg = ''; |
|
| 209 | - $image_limit = ''; |
|
| 210 | - if (!empty($thumb_img_arr)) {
|
|
| 211 | - $totImg = count($thumb_img_arr); |
|
| 212 | - } |
|
| 163 | + wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
|
|
| 164 | + wp_enqueue_script('geodir-on-document-load');
|
|
| 165 | + |
|
| 166 | + |
|
| 167 | + // SCRIPT FOR UPLOAD |
|
| 168 | + wp_enqueue_script('plupload-all');
|
|
| 169 | + wp_enqueue_script('jquery-ui-sortable');
|
|
| 170 | + |
|
| 171 | + wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 172 | + wp_enqueue_script('geodirectory-plupload-script');
|
|
| 173 | + |
|
| 174 | + // SCRIPT FOR UPLOAD END |
|
| 175 | + |
|
| 176 | + |
|
| 177 | + // place js config array for plupload |
|
| 178 | + $plupload_init = array( |
|
| 179 | + 'runtimes' => 'html5,silverlight,flash,html4', |
|
| 180 | + 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
| 181 | + 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
| 182 | + 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
| 183 | + 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
| 184 | + 'multiple_queues' => true, |
|
| 185 | + 'max_file_size' => geodir_max_upload_size(), |
|
| 186 | + 'url' => admin_url('admin-ajax.php'),
|
|
| 187 | + 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
|
| 188 | + 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
|
| 189 | + 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
|
|
| 190 | + 'multipart' => true, |
|
| 191 | + 'urlstream_upload' => true, |
|
| 192 | + 'multi_selection' => false, // will be added per uploader |
|
| 193 | + // additional post data to send to our ajax hook |
|
| 194 | + 'multipart_params' => array( |
|
| 195 | + '_ajax_nonce' => "", // will be added per uploader |
|
| 196 | + 'action' => 'plupload_action', // the ajax action name |
|
| 197 | + 'imgid' => 0 // will be added per uploader |
|
| 198 | + ) |
|
| 199 | + ); |
|
| 200 | + $base_plupload_config = json_encode($plupload_init); |
|
| 201 | + |
|
| 202 | + |
|
| 203 | + $thumb_img_arr = array(); |
|
| 204 | + |
|
| 205 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 206 | + $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 207 | + |
|
| 208 | + $totImg = ''; |
|
| 209 | + $image_limit = ''; |
|
| 210 | + if (!empty($thumb_img_arr)) {
|
|
| 211 | + $totImg = count($thumb_img_arr); |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
|
|
| 215 | - 'totalImg' => $totImg, |
|
| 216 | - 'image_limit' => $image_limit, |
|
| 217 | - 'upload_img_size' => geodir_max_upload_size()); |
|
| 214 | + $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
|
|
| 215 | + 'totalImg' => $totImg, |
|
| 216 | + 'image_limit' => $image_limit, |
|
| 217 | + 'upload_img_size' => geodir_max_upload_size()); |
|
| 218 | 218 | |
| 219 | - wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
|
|
| 219 | + wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
|
|
| 220 | 220 | |
| 221 | - $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
|
|
| 222 | - wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
|
|
| 221 | + $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
|
|
| 222 | + wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
|
|
| 223 | 223 | |
| 224 | 224 | |
| 225 | - wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 226 | - wp_enqueue_script('geodirectory-admin-script');
|
|
| 225 | + wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 226 | + wp_enqueue_script('geodirectory-admin-script');
|
|
| 227 | 227 | |
| 228 | - wp_enqueue_style('farbtastic');
|
|
| 229 | - wp_enqueue_script('farbtastic');
|
|
| 228 | + wp_enqueue_style('farbtastic');
|
|
| 229 | + wp_enqueue_script('farbtastic');
|
|
| 230 | 230 | |
| 231 | - $screen = get_current_screen(); |
|
| 232 | - if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
|
|
| 233 | - wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 234 | - } |
|
| 231 | + $screen = get_current_screen(); |
|
| 232 | + if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
|
|
| 233 | + wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - $ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
|
|
| 237 | - wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
|
|
| 236 | + $ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
|
|
| 237 | + wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
|
|
| 238 | 238 | |
| 239 | - } |
|
| 239 | + } |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | if (!function_exists('geodir_admin_menu')) {
|
| 243 | - /** |
|
| 244 | - * Admin Menus |
|
| 245 | - * |
|
| 246 | - * Sets up the admin menus in wordpress. |
|
| 247 | - * |
|
| 248 | - * @since 1.0.0 |
|
| 249 | - * @package GeoDirectory |
|
| 250 | - * @global array $menu Menu array. |
|
| 251 | - * @global object $geodirectory GeoDirectory plugin object. |
|
| 252 | - */ |
|
| 253 | - function geodir_admin_menu() |
|
| 254 | - {
|
|
| 255 | - global $menu, $geodirectory; |
|
| 243 | + /** |
|
| 244 | + * Admin Menus |
|
| 245 | + * |
|
| 246 | + * Sets up the admin menus in wordpress. |
|
| 247 | + * |
|
| 248 | + * @since 1.0.0 |
|
| 249 | + * @package GeoDirectory |
|
| 250 | + * @global array $menu Menu array. |
|
| 251 | + * @global object $geodirectory GeoDirectory plugin object. |
|
| 252 | + */ |
|
| 253 | + function geodir_admin_menu() |
|
| 254 | + {
|
|
| 255 | + global $menu, $geodirectory; |
|
| 256 | 256 | |
| 257 | - if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
|
| 257 | + if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
|
| 258 | 258 | |
| 259 | - add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 259 | + add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 260 | 260 | |
| 261 | 261 | |
| 262 | - } |
|
| 262 | + } |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | if (!function_exists('geodir_admin_menu_order')) {
|
| 266 | - /** |
|
| 267 | - * Order admin menus. |
|
| 268 | - * |
|
| 269 | - * @since 1.0.0 |
|
| 270 | - * @package GeoDirectory |
|
| 271 | - * @param array $menu_order Menu order array. |
|
| 272 | - * @return array Modified menu order array. |
|
| 273 | - */ |
|
| 274 | - function geodir_admin_menu_order($menu_order) |
|
| 275 | - {
|
|
| 276 | - |
|
| 277 | - // Initialize our custom order array |
|
| 278 | - $geodir_menu_order = array(); |
|
| 279 | - |
|
| 280 | - // Get the index of our custom separator |
|
| 281 | - $geodir_separator = array_search('separator-geodirectory', $menu_order);
|
|
| 282 | - |
|
| 283 | - // Get index of posttype menu |
|
| 284 | - $post_types = geodir_get_posttypes(); |
|
| 285 | - |
|
| 286 | - // Loop through menu order and do some rearranging |
|
| 287 | - foreach ($menu_order as $index => $item) : |
|
| 288 | - |
|
| 289 | - if ((('geodirectory') == $item)) :
|
|
| 290 | - $geodir_menu_order[] = 'separator-geodirectory'; |
|
| 291 | - if (!empty($post_types)) {
|
|
| 292 | - foreach ($post_types as $post_type) {
|
|
| 293 | - $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
| 294 | - } |
|
| 295 | - } |
|
| 296 | - $geodir_menu_order[] = $item; |
|
| 266 | + /** |
|
| 267 | + * Order admin menus. |
|
| 268 | + * |
|
| 269 | + * @since 1.0.0 |
|
| 270 | + * @package GeoDirectory |
|
| 271 | + * @param array $menu_order Menu order array. |
|
| 272 | + * @return array Modified menu order array. |
|
| 273 | + */ |
|
| 274 | + function geodir_admin_menu_order($menu_order) |
|
| 275 | + {
|
|
| 297 | 276 | |
| 298 | - unset($menu_order[$geodir_separator]); |
|
| 299 | - //unset( $menu_order[$geodir_places] ); |
|
| 300 | - elseif (!in_array($item, array('separator-geodirectory'))) :
|
|
| 301 | - $geodir_menu_order[] = $item; |
|
| 302 | - endif; |
|
| 277 | + // Initialize our custom order array |
|
| 278 | + $geodir_menu_order = array(); |
|
| 303 | 279 | |
| 304 | - endforeach; |
|
| 280 | + // Get the index of our custom separator |
|
| 281 | + $geodir_separator = array_search('separator-geodirectory', $menu_order);
|
|
| 305 | 282 | |
| 306 | - // Return order |
|
| 307 | - return $geodir_menu_order; |
|
| 308 | - } |
|
| 283 | + // Get index of posttype menu |
|
| 284 | + $post_types = geodir_get_posttypes(); |
|
| 285 | + |
|
| 286 | + // Loop through menu order and do some rearranging |
|
| 287 | + foreach ($menu_order as $index => $item) : |
|
| 288 | + |
|
| 289 | + if ((('geodirectory') == $item)) :
|
|
| 290 | + $geodir_menu_order[] = 'separator-geodirectory'; |
|
| 291 | + if (!empty($post_types)) {
|
|
| 292 | + foreach ($post_types as $post_type) {
|
|
| 293 | + $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | + $geodir_menu_order[] = $item; |
|
| 297 | + |
|
| 298 | + unset($menu_order[$geodir_separator]); |
|
| 299 | + //unset( $menu_order[$geodir_places] ); |
|
| 300 | + elseif (!in_array($item, array('separator-geodirectory'))) :
|
|
| 301 | + $geodir_menu_order[] = $item; |
|
| 302 | + endif; |
|
| 303 | + |
|
| 304 | + endforeach; |
|
| 305 | + |
|
| 306 | + // Return order |
|
| 307 | + return $geodir_menu_order; |
|
| 308 | + } |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | if (!function_exists('geodir_admin_custom_menu_order')) {
|
| 312 | - /** |
|
| 313 | - * Enables custom menu order. |
|
| 314 | - * |
|
| 315 | - * @since 1.0.0 |
|
| 316 | - * @package GeoDirectory |
|
| 317 | - * @return bool |
|
| 318 | - */ |
|
| 319 | - function geodir_admin_custom_menu_order() |
|
| 320 | - {
|
|
| 321 | - if (!current_user_can('manage_options')) return false;
|
|
| 322 | - return true; |
|
| 323 | - } |
|
| 312 | + /** |
|
| 313 | + * Enables custom menu order. |
|
| 314 | + * |
|
| 315 | + * @since 1.0.0 |
|
| 316 | + * @package GeoDirectory |
|
| 317 | + * @return bool |
|
| 318 | + */ |
|
| 319 | + function geodir_admin_custom_menu_order() |
|
| 320 | + {
|
|
| 321 | + if (!current_user_can('manage_options')) return false;
|
|
| 322 | + return true; |
|
| 323 | + } |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
@@ -331,41 +331,41 @@ discard block |
||
| 331 | 331 | */ |
| 332 | 332 | function geodir_before_admin_panel() |
| 333 | 333 | {
|
| 334 | - if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
|
|
| 335 | - echo '<div id="message" class="updated fade"> |
|
| 334 | + if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
|
|
| 335 | + echo '<div id="message" class="updated fade"> |
|
| 336 | 336 | <p style="float:right;">' . __('Like Geodirectory?', 'geodirectory') . ' <a href="http://wordpress.org/extend/plugins/Geodirectory/" target="_blank">' . __('Support us by leaving a rating!', 'geodirectory') . '</a></p>
|
| 337 | 337 | <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
|
| 338 | 338 | </div>'; |
| 339 | 339 | |
| 340 | - } |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
|
|
| 343 | - switch ($_REQUEST['msg']) {
|
|
| 344 | - case 'success': |
|
| 345 | - echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
|
|
| 346 | - flush_rewrite_rules(false); |
|
| 342 | + if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
|
|
| 343 | + switch ($_REQUEST['msg']) {
|
|
| 344 | + case 'success': |
|
| 345 | + echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
|
|
| 346 | + flush_rewrite_rules(false); |
|
| 347 | 347 | |
| 348 | - break; |
|
| 348 | + break; |
|
| 349 | 349 | case 'fail': |
| 350 | 350 | $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
| 351 | 351 | |
| 352 | 352 | if ($gderr == 21) |
| 353 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 353 | + echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 354 | 354 | else |
| 355 | 355 | echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
|
| 356 | - break; |
|
| 357 | - } |
|
| 358 | - } |
|
| 356 | + break; |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | - if (!geodir_is_default_location_set()) {
|
|
| 361 | - echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 360 | + if (!geodir_is_default_location_set()) {
|
|
| 361 | + echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 362 | 362 | |
| 363 | - } |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | - if (!function_exists('curl_init')) {
|
|
| 366 | - echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
|
|
| 365 | + if (!function_exists('curl_init')) {
|
|
| 366 | + echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
|
|
| 367 | 367 | |
| 368 | - } |
|
| 368 | + } |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -378,19 +378,19 @@ discard block |
||
| 378 | 378 | */ |
| 379 | 379 | function geodir_handle_option_form_submit($current_tab) |
| 380 | 380 | {
|
| 381 | - global $geodir_settings; |
|
| 382 | - if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
|
|
| 383 | - /** |
|
| 384 | - * Contains settings array for current tab. |
|
| 385 | - * |
|
| 386 | - * @since 1.0.0 |
|
| 387 | - * @package GeoDirectory |
|
| 388 | - */ |
|
| 389 | - include_once('option-pages/' . $current_tab . '_array.php');
|
|
| 390 | - } |
|
| 391 | - if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
| 392 | - if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 393 | - if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 381 | + global $geodir_settings; |
|
| 382 | + if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
|
|
| 383 | + /** |
|
| 384 | + * Contains settings array for current tab. |
|
| 385 | + * |
|
| 386 | + * @since 1.0.0 |
|
| 387 | + * @package GeoDirectory |
|
| 388 | + */ |
|
| 389 | + include_once('option-pages/' . $current_tab . '_array.php');
|
|
| 390 | + } |
|
| 391 | + if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
| 392 | + if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 393 | + if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 394 | 394 | |
| 395 | 395 | /** |
| 396 | 396 | * Fires before updating geodirectory admin settings. |
@@ -402,98 +402,98 @@ discard block |
||
| 402 | 402 | */ |
| 403 | 403 | do_action('geodir_before_update_options', $current_tab, $geodir_settings);
|
| 404 | 404 | |
| 405 | - if (!empty($geodir_settings[$current_tab])) |
|
| 406 | - geodir_update_options($geodir_settings[$current_tab]); |
|
| 405 | + if (!empty($geodir_settings[$current_tab])) |
|
| 406 | + geodir_update_options($geodir_settings[$current_tab]); |
|
| 407 | 407 | |
| 408 | - /** |
|
| 409 | - * Called after GeoDirectory options settings are updated. |
|
| 410 | - * |
|
| 411 | - * @since 1.0.0 |
|
| 412 | - * @param array $geodir_settings The array of GeoDirectory settings. |
|
| 413 | - * @see 'geodir_before_update_options' |
|
| 414 | - */ |
|
| 415 | - do_action('geodir_update_options', $geodir_settings);
|
|
| 408 | + /** |
|
| 409 | + * Called after GeoDirectory options settings are updated. |
|
| 410 | + * |
|
| 411 | + * @since 1.0.0 |
|
| 412 | + * @param array $geodir_settings The array of GeoDirectory settings. |
|
| 413 | + * @see 'geodir_before_update_options' |
|
| 414 | + */ |
|
| 415 | + do_action('geodir_update_options', $geodir_settings);
|
|
| 416 | 416 | |
| 417 | - /** |
|
| 418 | - * Called after GeoDirectory options settings are updated. |
|
| 419 | - * |
|
| 420 | - * Provides tab specific settings. |
|
| 421 | - * |
|
| 422 | - * @since 1.0.0 |
|
| 423 | - * @param string $current_tab The current settings tab name. |
|
| 424 | - * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
| 425 | - */ |
|
| 426 | - do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
|
|
| 417 | + /** |
|
| 418 | + * Called after GeoDirectory options settings are updated. |
|
| 419 | + * |
|
| 420 | + * Provides tab specific settings. |
|
| 421 | + * |
|
| 422 | + * @since 1.0.0 |
|
| 423 | + * @param string $current_tab The current settings tab name. |
|
| 424 | + * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
| 425 | + */ |
|
| 426 | + do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
|
|
| 427 | 427 | |
| 428 | - flush_rewrite_rules(false); |
|
| 428 | + flush_rewrite_rules(false); |
|
| 429 | 429 | |
| 430 | - $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
| 430 | + $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
| 431 | 431 | |
| 432 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
|
|
| 432 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
|
|
| 433 | 433 | |
| 434 | - wp_redirect($redirect_url); |
|
| 435 | - exit(); |
|
| 436 | - endif; |
|
| 434 | + wp_redirect($redirect_url); |
|
| 435 | + exit(); |
|
| 436 | + endif; |
|
| 437 | 437 | |
| 438 | 438 | |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | |
| 442 | 442 | if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined( 'GD_TESTING_MODE' ))) {
|
| 443 | - /** |
|
| 444 | - * GeoDirectory dummy data installation. |
|
| 445 | - * |
|
| 446 | - * @since 1.0.0 |
|
| 447 | - * @package GeoDirectory |
|
| 448 | - * @global object $wpdb WordPress Database object. |
|
| 449 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 450 | - * @param string $post_type The post type. |
|
| 451 | - */ |
|
| 452 | - function geodir_autoinstall_admin_header($post_type = 'gd_place') |
|
| 453 | - {
|
|
| 443 | + /** |
|
| 444 | + * GeoDirectory dummy data installation. |
|
| 445 | + * |
|
| 446 | + * @since 1.0.0 |
|
| 447 | + * @package GeoDirectory |
|
| 448 | + * @global object $wpdb WordPress Database object. |
|
| 449 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 450 | + * @param string $post_type The post type. |
|
| 451 | + */ |
|
| 452 | + function geodir_autoinstall_admin_header($post_type = 'gd_place') |
|
| 453 | + {
|
|
| 454 | 454 | |
| 455 | - global $wpdb, $plugin_prefix; |
|
| 455 | + global $wpdb, $plugin_prefix; |
|
| 456 | 456 | |
| 457 | - if (!geodir_is_default_location_set()) {
|
|
| 458 | - echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 459 | - } else {
|
|
| 457 | + if (!geodir_is_default_location_set()) {
|
|
| 458 | + echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 459 | + } else {
|
|
| 460 | 460 | |
| 461 | - $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab='; |
|
| 461 | + $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab='; |
|
| 462 | 462 | |
| 463 | - $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
|
|
| 463 | + $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
|
|
| 464 | 464 | |
| 465 | - if ($post_counts > 0) {
|
|
| 466 | - $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
|
|
| 465 | + if ($post_counts > 0) {
|
|
| 466 | + $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
|
|
| 467 | 467 | |
| 468 | - $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . SAMPLE_DATA_SHOW_MSG . '</b><br /><a id="geodir_dummy_delete" class="button_delete" onclick="geodir_autoinstall(this,\'geodir_dummy_delete\',\'' . $nonce . '\',\'' . $post_type . '\')" href="javascript:void(0);" redirect_to="' . $geodir_url . '" >' . DELETE_BTN_SAMPLE_MSG . '</a></p></div>'; |
|
| 469 | - $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_DELETE_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /></p></div>'; |
|
| 470 | - } else {
|
|
| 471 | - $options_list = ''; |
|
| 472 | - for ($option = 1; $option <= 30; $option++) {
|
|
| 473 | - $selected = ''; |
|
| 474 | - if ($option == 10) |
|
| 475 | - $selected = 'selected="selected"'; |
|
| 468 | + $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . SAMPLE_DATA_SHOW_MSG . '</b><br /><a id="geodir_dummy_delete" class="button_delete" onclick="geodir_autoinstall(this,\'geodir_dummy_delete\',\'' . $nonce . '\',\'' . $post_type . '\')" href="javascript:void(0);" redirect_to="' . $geodir_url . '" >' . DELETE_BTN_SAMPLE_MSG . '</a></p></div>'; |
|
| 469 | + $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_DELETE_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /></p></div>'; |
|
| 470 | + } else {
|
|
| 471 | + $options_list = ''; |
|
| 472 | + for ($option = 1; $option <= 30; $option++) {
|
|
| 473 | + $selected = ''; |
|
| 474 | + if ($option == 10) |
|
| 475 | + $selected = 'selected="selected"'; |
|
| 476 | 476 | |
| 477 | - $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>'; |
|
| 478 | - } |
|
| 477 | + $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>'; |
|
| 478 | + } |
|
| 479 | 479 | |
| 480 | - $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
|
|
| 480 | + $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
|
|
| 481 | 481 | |
| 482 | - $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . AUTO_INSATALL_MSG . '</b><br /><select class="selected_sample_data">' . $options_list . '</select><a id="geodir_dummy_insert" class="button_insert" href="javascript:void(0);" onclick="geodir_autoinstall(this,\'geodir_dummy_insert\',\'' . $nonce . '\',\'' . $post_type . '\')" redirect_to="' . $geodir_url . '" >' . INSERT_BTN_SAMPLE_MSG . '</a></p></div>'; |
|
| 483 | - $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_IMPORT_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /><br><span class="dummy_post_inserted"></span></div>'; |
|
| 482 | + $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . AUTO_INSATALL_MSG . '</b><br /><select class="selected_sample_data">' . $options_list . '</select><a id="geodir_dummy_insert" class="button_insert" href="javascript:void(0);" onclick="geodir_autoinstall(this,\'geodir_dummy_insert\',\'' . $nonce . '\',\'' . $post_type . '\')" redirect_to="' . $geodir_url . '" >' . INSERT_BTN_SAMPLE_MSG . '</a></p></div>'; |
|
| 483 | + $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_IMPORT_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /><br><span class="dummy_post_inserted"></span></div>'; |
|
| 484 | 484 | |
| 485 | - } |
|
| 486 | - echo $dummy_msg; |
|
| 487 | - ?> |
|
| 485 | + } |
|
| 486 | + echo $dummy_msg; |
|
| 487 | + ?> |
|
| 488 | 488 | <script> |
| 489 | 489 | <?php |
| 490 | - $default_location = geodir_get_default_location(); |
|
| 491 | - $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 492 | - $region =isset($default_location->region) ? $default_location->region : ''; |
|
| 493 | - $country =isset($default_location->country) ? $default_location->country : ''; |
|
| 494 | - $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 495 | - $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 496 | - ?> |
|
| 490 | + $default_location = geodir_get_default_location(); |
|
| 491 | + $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 492 | + $region =isset($default_location->region) ? $default_location->region : ''; |
|
| 493 | + $country =isset($default_location->country) ? $default_location->country : ''; |
|
| 494 | + $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 495 | + $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 496 | + ?> |
|
| 497 | 497 | var geocoder = window.gdMaps == 'google' ? new google.maps.Geocoder() : null; |
| 498 | 498 | var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country;?>'; |
| 499 | 499 | var bound_lat_lng; |
@@ -584,8 +584,8 @@ discard block |
||
| 584 | 584 | } |
| 585 | 585 | </script> |
| 586 | 586 | <?php |
| 587 | - } |
|
| 588 | - } |
|
| 587 | + } |
|
| 588 | + } |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | /** |
@@ -598,20 +598,20 @@ discard block |
||
| 598 | 598 | */ |
| 599 | 599 | function geodir_insert_dummy_posts() |
| 600 | 600 | {
|
| 601 | - geodir_default_taxonomies(); |
|
| 601 | + geodir_default_taxonomies(); |
|
| 602 | 602 | |
| 603 | - ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
|
|
| 603 | + ini_set('max_execution_time', 999999); //300 seconds = 5 minutes
|
|
| 604 | 604 | |
| 605 | - global $wpdb, $current_user; |
|
| 605 | + global $wpdb, $current_user; |
|
| 606 | 606 | |
| 607 | - /** |
|
| 608 | - * Contains dummy post content. |
|
| 609 | - * |
|
| 610 | - * @since 1.0.0 |
|
| 611 | - * @package GeoDirectory |
|
| 612 | - */ |
|
| 613 | - include_once('place_dummy_post.php');
|
|
| 614 | - delete_transient( 'cached_dummy_images' ); |
|
| 607 | + /** |
|
| 608 | + * Contains dummy post content. |
|
| 609 | + * |
|
| 610 | + * @since 1.0.0 |
|
| 611 | + * @package GeoDirectory |
|
| 612 | + */ |
|
| 613 | + include_once('place_dummy_post.php');
|
|
| 614 | + delete_transient( 'cached_dummy_images' ); |
|
| 615 | 615 | |
| 616 | 616 | } |
| 617 | 617 | |
@@ -625,18 +625,18 @@ discard block |
||
| 625 | 625 | */ |
| 626 | 626 | function geodir_delete_dummy_posts() |
| 627 | 627 | {
|
| 628 | - global $wpdb, $plugin_prefix; |
|
| 628 | + global $wpdb, $plugin_prefix; |
|
| 629 | 629 | |
| 630 | 630 | |
| 631 | - $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 631 | + $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 632 | 632 | |
| 633 | 633 | |
| 634 | - foreach ($post_ids as $post_ids_obj) {
|
|
| 635 | - wp_delete_post($post_ids_obj->post_id); |
|
| 636 | - } |
|
| 634 | + foreach ($post_ids as $post_ids_obj) {
|
|
| 635 | + wp_delete_post($post_ids_obj->post_id); |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | - //double check posts are deleted |
|
| 639 | - $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 638 | + //double check posts are deleted |
|
| 639 | + $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | /** |
@@ -650,114 +650,114 @@ discard block |
||
| 650 | 650 | * @global string $dummy_image_path The dummy image path. |
| 651 | 651 | */ |
| 652 | 652 | function geodir_default_taxonomies() {
|
| 653 | - global $wpdb, $dummy_image_path; |
|
| 653 | + global $wpdb, $dummy_image_path; |
|
| 654 | 654 | |
| 655 | - $category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
|
|
| 655 | + $category_array = array('Attractions', 'Hotels', 'Restaurants', 'Food Nightlife', 'Festival', 'Videos', 'Feature');
|
|
| 656 | 656 | |
| 657 | - $last_catid = ''; |
|
| 657 | + $last_catid = ''; |
|
| 658 | 658 | |
| 659 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 659 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 660 | 660 | |
| 661 | - for ($i = 0; $i < count($category_array); $i++) {
|
|
| 662 | - $parent_catid = 0; |
|
| 663 | - if (is_array($category_array[$i])) {
|
|
| 664 | - $cat_name_arr = $category_array[$i]; |
|
| 665 | - for ($j = 0; $j < count($cat_name_arr); $j++) {
|
|
| 666 | - $catname = $cat_name_arr[$j]; |
|
| 661 | + for ($i = 0; $i < count($category_array); $i++) {
|
|
| 662 | + $parent_catid = 0; |
|
| 663 | + if (is_array($category_array[$i])) {
|
|
| 664 | + $cat_name_arr = $category_array[$i]; |
|
| 665 | + for ($j = 0; $j < count($cat_name_arr); $j++) {
|
|
| 666 | + $catname = $cat_name_arr[$j]; |
|
| 667 | 667 | |
| 668 | - if (!term_exists($catname, 'gd_placecategory')) {
|
|
| 669 | - $last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
|
|
| 668 | + if (!term_exists($catname, 'gd_placecategory')) {
|
|
| 669 | + $last_catid = wp_insert_term($catname, 'gd_placecategory', $args = array('parent' => $parent_catid));
|
|
| 670 | 670 | |
| 671 | - if ($j == 0) {
|
|
| 672 | - $parent_catid = $last_catid; |
|
| 673 | - } |
|
| 671 | + if ($j == 0) {
|
|
| 672 | + $parent_catid = $last_catid; |
|
| 673 | + } |
|
| 674 | 674 | |
| 675 | 675 | |
| 676 | - if (geodir_dummy_folder_exists()) |
|
| 677 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 678 | - else |
|
| 679 | - $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 676 | + if (geodir_dummy_folder_exists()) |
|
| 677 | + $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 678 | + else |
|
| 679 | + $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 680 | 680 | |
| 681 | - $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
|
|
| 681 | + $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
|
|
| 682 | 682 | |
| 683 | - $catname = str_replace(' ', '_', $catname);
|
|
| 684 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 683 | + $catname = str_replace(' ', '_', $catname);
|
|
| 684 | + $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 685 | 685 | |
| 686 | - if (empty($uploaded['error'])) {
|
|
| 687 | - $new_path = $uploaded['file']; |
|
| 688 | - $new_url = $uploaded['url']; |
|
| 689 | - } |
|
| 686 | + if (empty($uploaded['error'])) {
|
|
| 687 | + $new_path = $uploaded['file']; |
|
| 688 | + $new_url = $uploaded['url']; |
|
| 689 | + } |
|
| 690 | 690 | |
| 691 | - $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
| 692 | - |
|
| 693 | - $attachment = array( |
|
| 694 | - 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 695 | - 'post_mime_type' => $wp_filetype['type'], |
|
| 696 | - 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
|
| 697 | - 'post_content' => '', |
|
| 698 | - 'post_status' => 'inherit' |
|
| 699 | - ); |
|
| 700 | - $attach_id = wp_insert_attachment($attachment, $new_path); |
|
| 701 | - |
|
| 702 | - // you must first include the image.php file |
|
| 703 | - // for the function wp_generate_attachment_metadata() to work |
|
| 704 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 705 | - $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
| 706 | - wp_update_attachment_metadata($attach_id, $attach_data); |
|
| 707 | - |
|
| 708 | - if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
|
|
| 709 | - update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
|
|
| 710 | - } |
|
| 711 | - } |
|
| 712 | - } |
|
| 691 | + $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
| 692 | + |
|
| 693 | + $attachment = array( |
|
| 694 | + 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 695 | + 'post_mime_type' => $wp_filetype['type'], |
|
| 696 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
|
| 697 | + 'post_content' => '', |
|
| 698 | + 'post_status' => 'inherit' |
|
| 699 | + ); |
|
| 700 | + $attach_id = wp_insert_attachment($attachment, $new_path); |
|
| 701 | + |
|
| 702 | + // you must first include the image.php file |
|
| 703 | + // for the function wp_generate_attachment_metadata() to work |
|
| 704 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 705 | + $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
| 706 | + wp_update_attachment_metadata($attach_id, $attach_data); |
|
| 707 | + |
|
| 708 | + if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
|
|
| 709 | + update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => 'icon', 'src' => $new_url), 'gd_place');
|
|
| 710 | + } |
|
| 711 | + } |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | - } else {
|
|
| 715 | - $catname = $category_array[$i]; |
|
| 714 | + } else {
|
|
| 715 | + $catname = $category_array[$i]; |
|
| 716 | 716 | |
| 717 | - if (!term_exists($catname, 'gd_placecategory')) {
|
|
| 718 | - $last_catid = wp_insert_term($catname, 'gd_placecategory'); |
|
| 717 | + if (!term_exists($catname, 'gd_placecategory')) {
|
|
| 718 | + $last_catid = wp_insert_term($catname, 'gd_placecategory'); |
|
| 719 | 719 | |
| 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'; |
|
| 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 | 724 | |
| 725 | - $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
|
|
| 725 | + $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
|
|
| 726 | 726 | |
| 727 | - $catname = str_replace(' ', '_', $catname);
|
|
| 728 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 727 | + $catname = str_replace(' ', '_', $catname);
|
|
| 728 | + $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 729 | 729 | |
| 730 | - if (empty($uploaded['error'])) {
|
|
| 731 | - $new_path = $uploaded['file']; |
|
| 732 | - $new_url = $uploaded['url']; |
|
| 733 | - } |
|
| 730 | + if (empty($uploaded['error'])) {
|
|
| 731 | + $new_path = $uploaded['file']; |
|
| 732 | + $new_url = $uploaded['url']; |
|
| 733 | + } |
|
| 734 | 734 | |
| 735 | - $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
| 735 | + $wp_filetype = wp_check_filetype(basename($new_path), null); |
|
| 736 | 736 | |
| 737 | - $attachment = array( |
|
| 738 | - 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 739 | - 'post_mime_type' => $wp_filetype['type'], |
|
| 740 | - 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
|
| 741 | - 'post_content' => '', |
|
| 742 | - 'post_status' => 'inherit' |
|
| 743 | - ); |
|
| 737 | + $attachment = array( |
|
| 738 | + 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 739 | + 'post_mime_type' => $wp_filetype['type'], |
|
| 740 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
|
| 741 | + 'post_content' => '', |
|
| 742 | + 'post_status' => 'inherit' |
|
| 743 | + ); |
|
| 744 | 744 | |
| 745 | - $attach_id = wp_insert_attachment($attachment, $new_path); |
|
| 745 | + $attach_id = wp_insert_attachment($attachment, $new_path); |
|
| 746 | 746 | |
| 747 | 747 | |
| 748 | - // you must first include the image.php file |
|
| 749 | - // for the function wp_generate_attachment_metadata() to work |
|
| 750 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 751 | - $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
| 752 | - wp_update_attachment_metadata($attach_id, $attach_data); |
|
| 748 | + // you must first include the image.php file |
|
| 749 | + // for the function wp_generate_attachment_metadata() to work |
|
| 750 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 751 | + $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
|
| 752 | + wp_update_attachment_metadata($attach_id, $attach_data); |
|
| 753 | 753 | |
| 754 | - if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
|
|
| 755 | - update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
|
|
| 756 | - } |
|
| 757 | - } |
|
| 758 | - } |
|
| 754 | + if (!get_tax_meta($last_catid['term_id'], 'ct_cat_icon', false, 'gd_place')) {
|
|
| 755 | + update_tax_meta($last_catid['term_id'], 'ct_cat_icon', array('id' => $attach_id, 'src' => $new_url), 'gd_place');
|
|
| 756 | + } |
|
| 757 | + } |
|
| 758 | + } |
|
| 759 | 759 | |
| 760 | - } |
|
| 760 | + } |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | /** |
@@ -772,144 +772,144 @@ discard block |
||
| 772 | 772 | * @return bool Returns true if saved. |
| 773 | 773 | */ |
| 774 | 774 | function geodir_update_options($options, $dummy = false) {
|
| 775 | - if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
| 775 | + if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
| 776 | 776 | |
| 777 | - foreach ($options as $value) {
|
|
| 778 | - if ($dummy && isset($value['std'])) |
|
| 779 | - $_POST[$value['id']] = $value['std']; |
|
| 777 | + foreach ($options as $value) {
|
|
| 778 | + if ($dummy && isset($value['std'])) |
|
| 779 | + $_POST[$value['id']] = $value['std']; |
|
| 780 | 780 | |
| 781 | 781 | |
| 782 | - if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
| 782 | + if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
| 783 | 783 | |
| 784 | - if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 785 | - update_option($value['id'], $_POST[$value['id']]); |
|
| 786 | - } else {
|
|
| 787 | - update_option($value['id'], 0); |
|
| 788 | - } |
|
| 784 | + if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 785 | + update_option($value['id'], $_POST[$value['id']]); |
|
| 786 | + } else {
|
|
| 787 | + update_option($value['id'], 0); |
|
| 788 | + } |
|
| 789 | 789 | |
| 790 | - elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 790 | + elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 791 | 791 | |
| 792 | - if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
|
| 793 | - update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
| 794 | - update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
| 795 | - if (isset($_POST[$value['id'] . '_crop'])) : |
|
| 796 | - update_option($value['id'] . '_crop', 1); |
|
| 797 | - else : |
|
| 798 | - update_option($value['id'] . '_crop', 0); |
|
| 799 | - endif; |
|
| 800 | - } else {
|
|
| 801 | - update_option($value['id'] . '_width', $value['std']); |
|
| 802 | - update_option($value['id'] . '_height', $value['std']); |
|
| 803 | - update_option($value['id'] . '_crop', 1); |
|
| 804 | - } |
|
| 792 | + if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
|
| 793 | + update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
| 794 | + update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
| 795 | + if (isset($_POST[$value['id'] . '_crop'])) : |
|
| 796 | + update_option($value['id'] . '_crop', 1); |
|
| 797 | + else : |
|
| 798 | + update_option($value['id'] . '_crop', 0); |
|
| 799 | + endif; |
|
| 800 | + } else {
|
|
| 801 | + update_option($value['id'] . '_width', $value['std']); |
|
| 802 | + update_option($value['id'] . '_height', $value['std']); |
|
| 803 | + update_option($value['id'] . '_crop', 1); |
|
| 804 | + } |
|
| 805 | 805 | |
| 806 | - elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 807 | - $post_types = array(); |
|
| 808 | - $categories = array(); |
|
| 806 | + elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 807 | + $post_types = array(); |
|
| 808 | + $categories = array(); |
|
| 809 | 809 | |
| 810 | - if (!empty($_POST['home_map_post_types'])) : |
|
| 811 | - foreach ($_POST['home_map_post_types'] as $post_type) : |
|
| 812 | - $post_types[] = $post_type; |
|
| 813 | - endforeach; |
|
| 814 | - endif; |
|
| 810 | + if (!empty($_POST['home_map_post_types'])) : |
|
| 811 | + foreach ($_POST['home_map_post_types'] as $post_type) : |
|
| 812 | + $post_types[] = $post_type; |
|
| 813 | + endforeach; |
|
| 814 | + endif; |
|
| 815 | 815 | |
| 816 | - update_option('geodir_exclude_post_type_on_map', $post_types);
|
|
| 816 | + update_option('geodir_exclude_post_type_on_map', $post_types);
|
|
| 817 | 817 | |
| 818 | - if (!empty($_POST['post_category'])) : |
|
| 819 | - foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
| 820 | - $categories[$texonomy] = array(); |
|
| 821 | - foreach ($cat_arr as $category) : |
|
| 822 | - $categories[$texonomy][] = $category; |
|
| 823 | - endforeach; |
|
| 824 | - $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
| 825 | - endforeach; |
|
| 826 | - endif; |
|
| 827 | - update_option('geodir_exclude_cat_on_map', $categories);
|
|
| 828 | - update_option('geodir_exclude_cat_on_map_upgrade', 1);
|
|
| 829 | - elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
| 818 | + if (!empty($_POST['post_category'])) : |
|
| 819 | + foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
| 820 | + $categories[$texonomy] = array(); |
|
| 821 | + foreach ($cat_arr as $category) : |
|
| 822 | + $categories[$texonomy][] = $category; |
|
| 823 | + endforeach; |
|
| 824 | + $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
| 825 | + endforeach; |
|
| 826 | + endif; |
|
| 827 | + update_option('geodir_exclude_cat_on_map', $categories);
|
|
| 828 | + update_option('geodir_exclude_cat_on_map_upgrade', 1);
|
|
| 829 | + elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
| 830 | 830 | |
| 831 | 831 | |
| 832 | - if (!empty($_POST['geodir_default_map_language'])): |
|
| 833 | - update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
|
|
| 834 | - endif; |
|
| 832 | + if (!empty($_POST['geodir_default_map_language'])): |
|
| 833 | + update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
|
|
| 834 | + endif; |
|
| 835 | 835 | |
| 836 | 836 | |
| 837 | - if (!empty($_POST['geodir_default_map_search_pt'])): |
|
| 838 | - update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
|
|
| 839 | - endif; |
|
| 837 | + if (!empty($_POST['geodir_default_map_search_pt'])): |
|
| 838 | + update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
|
|
| 839 | + endif; |
|
| 840 | 840 | |
| 841 | 841 | |
| 842 | - elseif (isset($value['type']) && $value['type'] == 'file') : |
|
| 842 | + elseif (isset($value['type']) && $value['type'] == 'file') : |
|
| 843 | 843 | |
| 844 | 844 | |
| 845 | - if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
|
|
| 845 | + if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
|
|
| 846 | 846 | |
| 847 | - if (get_option($value['id'])) {
|
|
| 848 | - $image_name_arr = explode('/', get_option($value['id']));
|
|
| 849 | - $noimg_name = end($image_name_arr); |
|
| 850 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 851 | - if (file_exists($img_path)) |
|
| 852 | - unlink($img_path); |
|
| 853 | - } |
|
| 847 | + if (get_option($value['id'])) {
|
|
| 848 | + $image_name_arr = explode('/', get_option($value['id']));
|
|
| 849 | + $noimg_name = end($image_name_arr); |
|
| 850 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 851 | + if (file_exists($img_path)) |
|
| 852 | + unlink($img_path); |
|
| 853 | + } |
|
| 854 | 854 | |
| 855 | - update_option($value['id'], ''); |
|
| 856 | - } |
|
| 855 | + update_option($value['id'], ''); |
|
| 856 | + } |
|
| 857 | 857 | |
| 858 | - $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
| 859 | - $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
| 860 | - |
|
| 861 | - if (!empty($filename)): |
|
| 862 | - $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
| 863 | - $uplaods = array(); |
|
| 864 | - |
|
| 865 | - foreach ($uploadedfile as $key => $uplaod): |
|
| 866 | - if ($key == 'name'): |
|
| 867 | - $uplaods[$key] = $filename; |
|
| 868 | - else : |
|
| 869 | - $uplaods[$key] = $uplaod; |
|
| 870 | - endif; |
|
| 871 | - endforeach; |
|
| 872 | - |
|
| 873 | - $uploads = wp_upload_dir(); |
|
| 874 | - |
|
| 875 | - if (get_option($value['id'])) {
|
|
| 876 | - $image_name_arr = explode('/', get_option($value['id']));
|
|
| 877 | - $noimg_name = end($image_name_arr); |
|
| 878 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 879 | - if (file_exists($img_path)) |
|
| 880 | - unlink($img_path); |
|
| 881 | - } |
|
| 858 | + $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
| 859 | + $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
| 860 | + |
|
| 861 | + if (!empty($filename)): |
|
| 862 | + $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
| 863 | + $uplaods = array(); |
|
| 864 | + |
|
| 865 | + foreach ($uploadedfile as $key => $uplaod): |
|
| 866 | + if ($key == 'name'): |
|
| 867 | + $uplaods[$key] = $filename; |
|
| 868 | + else : |
|
| 869 | + $uplaods[$key] = $uplaod; |
|
| 870 | + endif; |
|
| 871 | + endforeach; |
|
| 872 | + |
|
| 873 | + $uploads = wp_upload_dir(); |
|
| 874 | + |
|
| 875 | + if (get_option($value['id'])) {
|
|
| 876 | + $image_name_arr = explode('/', get_option($value['id']));
|
|
| 877 | + $noimg_name = end($image_name_arr); |
|
| 878 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 879 | + if (file_exists($img_path)) |
|
| 880 | + unlink($img_path); |
|
| 881 | + } |
|
| 882 | 882 | |
| 883 | - $upload_overrides = array('test_form' => false);
|
|
| 884 | - $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
| 883 | + $upload_overrides = array('test_form' => false);
|
|
| 884 | + $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
| 885 | 885 | |
| 886 | - update_option($value['id'], $movefile['url']); |
|
| 886 | + update_option($value['id'], $movefile['url']); |
|
| 887 | 887 | |
| 888 | - endif; |
|
| 888 | + endif; |
|
| 889 | 889 | |
| 890 | - if (!get_option($value['id']) && isset($value['value'])): |
|
| 891 | - update_option($value['id'], $value['value']); |
|
| 892 | - endif; |
|
| 890 | + if (!get_option($value['id']) && isset($value['value'])): |
|
| 891 | + update_option($value['id'], $value['value']); |
|
| 892 | + endif; |
|
| 893 | 893 | |
| 894 | 894 | |
| 895 | - else : |
|
| 896 | - // same menu setting per theme. |
|
| 897 | - if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
|
| 898 | - $theme = wp_get_theme(); |
|
| 899 | - update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
|
| 900 | - } |
|
| 895 | + else : |
|
| 896 | + // same menu setting per theme. |
|
| 897 | + if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
|
| 898 | + $theme = wp_get_theme(); |
|
| 899 | + update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
|
| 900 | + } |
|
| 901 | 901 | |
| 902 | - if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 903 | - update_option($value['id'], $_POST[$value['id']]); |
|
| 904 | - } else {
|
|
| 905 | - delete_option($value['id']); |
|
| 906 | - } |
|
| 902 | + if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 903 | + update_option($value['id'], $_POST[$value['id']]); |
|
| 904 | + } else {
|
|
| 905 | + delete_option($value['id']); |
|
| 906 | + } |
|
| 907 | 907 | |
| 908 | - endif; |
|
| 909 | - } |
|
| 910 | - if ($dummy) |
|
| 911 | - $_POST = array(); |
|
| 912 | - return true; |
|
| 908 | + endif; |
|
| 909 | + } |
|
| 910 | + if ($dummy) |
|
| 911 | + $_POST = array(); |
|
| 912 | + return true; |
|
| 913 | 913 | |
| 914 | 914 | } |
| 915 | 915 | |
@@ -958,33 +958,33 @@ discard block |
||
| 958 | 958 | function places_custom_fields_tab($tabs) |
| 959 | 959 | {
|
| 960 | 960 | |
| 961 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 961 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 962 | 962 | |
| 963 | - if (!empty($geodir_post_types)) {
|
|
| 963 | + if (!empty($geodir_post_types)) {
|
|
| 964 | 964 | |
| 965 | - foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
| 965 | + foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
| 966 | 966 | |
| 967 | - $listing_slug = $geodir_posttype_info['labels']['singular_name']; |
|
| 967 | + $listing_slug = $geodir_posttype_info['labels']['singular_name']; |
|
| 968 | 968 | |
| 969 | - $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
| 970 | - 'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'), |
|
| 971 | - 'subtabs' => array( |
|
| 972 | - array('subtab' => 'custom_fields',
|
|
| 973 | - 'label' => __('Custom Fields', 'geodirectory'),
|
|
| 974 | - 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 975 | - array('subtab' => 'sorting_options',
|
|
| 976 | - 'label' => __('Sorting Options', 'geodirectory'),
|
|
| 977 | - 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 978 | - ), |
|
| 979 | - 'tab_index' => 9, |
|
| 980 | - 'request' => array('listing_type' => $geodir_post_type)
|
|
| 981 | - ); |
|
| 969 | + $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
| 970 | + 'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'), |
|
| 971 | + 'subtabs' => array( |
|
| 972 | + array('subtab' => 'custom_fields',
|
|
| 973 | + 'label' => __('Custom Fields', 'geodirectory'),
|
|
| 974 | + 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 975 | + array('subtab' => 'sorting_options',
|
|
| 976 | + 'label' => __('Sorting Options', 'geodirectory'),
|
|
| 977 | + 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 978 | + ), |
|
| 979 | + 'tab_index' => 9, |
|
| 980 | + 'request' => array('listing_type' => $geodir_post_type)
|
|
| 981 | + ); |
|
| 982 | 982 | |
| 983 | - endforeach; |
|
| 983 | + endforeach; |
|
| 984 | 984 | |
| 985 | - } |
|
| 985 | + } |
|
| 986 | 986 | |
| 987 | - return $tabs; |
|
| 987 | + return $tabs; |
|
| 988 | 988 | } |
| 989 | 989 | |
| 990 | 990 | |
@@ -1000,9 +1000,9 @@ discard block |
||
| 1000 | 1000 | */ |
| 1001 | 1001 | function geodir_tools_setting_tab($tabs) |
| 1002 | 1002 | {
|
| 1003 | - wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 1004 | - $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
|
|
| 1005 | - return $tabs; |
|
| 1003 | + wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 1004 | + $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
|
|
| 1005 | + return $tabs; |
|
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | /** |
@@ -1017,8 +1017,8 @@ discard block |
||
| 1017 | 1017 | */ |
| 1018 | 1018 | function geodir_compatibility_setting_tab($tabs) |
| 1019 | 1019 | {
|
| 1020 | - $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
|
|
| 1021 | - return $tabs; |
|
| 1020 | + $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
|
|
| 1021 | + return $tabs; |
|
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | |
@@ -1034,144 +1034,144 @@ discard block |
||
| 1034 | 1034 | */ |
| 1035 | 1035 | function geodir_extend_geodirectory_setting_tab($tabs) |
| 1036 | 1036 | {
|
| 1037 | - $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
|
|
| 1038 | - return $tabs; |
|
| 1037 | + $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
|
|
| 1038 | + return $tabs; |
|
| 1039 | 1039 | } |
| 1040 | 1040 | |
| 1041 | 1041 | |
| 1042 | 1042 | if (!function_exists('geodir_edit_post_columns')) {
|
| 1043 | - /** |
|
| 1044 | - * Modify admin post listing page columns. |
|
| 1045 | - * |
|
| 1046 | - * @since 1.0.0 |
|
| 1047 | - * @package GeoDirectory |
|
| 1048 | - * @param array $columns The column array. |
|
| 1049 | - * @return array Altered column array. |
|
| 1050 | - */ |
|
| 1051 | - function geodir_edit_post_columns($columns) |
|
| 1052 | - {
|
|
| 1053 | - |
|
| 1054 | - $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
|
|
| 1055 | - 'categorys' => __('Categories', 'geodirectory'));
|
|
| 1056 | - |
|
| 1057 | - if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
|
|
| 1058 | - {
|
|
| 1059 | - $offset = 0; // should we prepend $array with $data? |
|
| 1060 | - $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
| 1061 | - } |
|
| 1043 | + /** |
|
| 1044 | + * Modify admin post listing page columns. |
|
| 1045 | + * |
|
| 1046 | + * @since 1.0.0 |
|
| 1047 | + * @package GeoDirectory |
|
| 1048 | + * @param array $columns The column array. |
|
| 1049 | + * @return array Altered column array. |
|
| 1050 | + */ |
|
| 1051 | + function geodir_edit_post_columns($columns) |
|
| 1052 | + {
|
|
| 1062 | 1053 | |
| 1063 | - $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
| 1054 | + $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
|
|
| 1055 | + 'categorys' => __('Categories', 'geodirectory'));
|
|
| 1064 | 1056 | |
| 1065 | - $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
|
|
| 1057 | + if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
|
|
| 1058 | + {
|
|
| 1059 | + $offset = 0; // should we prepend $array with $data? |
|
| 1060 | + $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
| 1061 | + } |
|
| 1066 | 1062 | |
| 1067 | - return $columns; |
|
| 1068 | - } |
|
| 1063 | + $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
| 1064 | + |
|
| 1065 | + $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
|
|
| 1066 | + |
|
| 1067 | + return $columns; |
|
| 1068 | + } |
|
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | 1071 | |
| 1072 | 1072 | if (!function_exists('geodir_manage_post_columns')) {
|
| 1073 | - /** |
|
| 1074 | - * Adds content to our custom post listing page columns. |
|
| 1075 | - * |
|
| 1076 | - * @since 1.0.0 |
|
| 1077 | - * @package GeoDirectory |
|
| 1078 | - * @global object $wpdb WordPress Database object. |
|
| 1079 | - * @global object $post WordPress Post object. |
|
| 1080 | - * @param string $column The column name. |
|
| 1081 | - * @param int $post_id The post ID. |
|
| 1082 | - */ |
|
| 1083 | - function geodir_manage_post_columns($column, $post_id) |
|
| 1084 | - {
|
|
| 1085 | - global $post, $wpdb; |
|
| 1086 | - |
|
| 1087 | - switch ($column): |
|
| 1088 | - /* If displaying the 'city' column. */ |
|
| 1089 | - case 'location' : |
|
| 1090 | - $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
| 1091 | - $location = geodir_get_location($location_id); |
|
| 1092 | - /* If no city is found, output a default message. */ |
|
| 1093 | - if (empty($location)) {
|
|
| 1094 | - _e('Unknown', 'geodirectory');
|
|
| 1095 | - } else {
|
|
| 1096 | - /* If there is a city id, append 'city name' to the text string. */ |
|
| 1097 | - $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
|
|
| 1098 | - echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
| 1099 | - } |
|
| 1100 | - break; |
|
| 1101 | - |
|
| 1102 | - /* If displaying the 'expire' column. */ |
|
| 1103 | - case 'expire' : |
|
| 1104 | - $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
| 1105 | - $d1 = $expire_date; // get expire_date |
|
| 1106 | - $d2 = date('Y-m-d'); // get current date
|
|
| 1107 | - $state = __('days left', 'geodirectory');
|
|
| 1108 | - $date_diff_text = ''; |
|
| 1109 | - $expire_class = 'expire_left'; |
|
| 1110 | - if ($expire_date != 'Never') {
|
|
| 1111 | - if (strtotime($d1) < strtotime($d2)) {
|
|
| 1112 | - $state = __('days overdue', 'geodirectory');
|
|
| 1113 | - $expire_class = 'expire_over'; |
|
| 1114 | - } |
|
| 1115 | - $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
|
| 1116 | - $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
|
| 1117 | - } |
|
| 1118 | - /* If no expire_date is found, output a default message. */ |
|
| 1119 | - if (empty($expire_date)) |
|
| 1120 | - echo __('Unknown', 'geodirectory');
|
|
| 1121 | - /* If there is a expire_date, append 'days left' to the text string. */ |
|
| 1122 | - else |
|
| 1123 | - echo $expire_date . $date_diff_text; |
|
| 1124 | - break; |
|
| 1125 | - |
|
| 1126 | - /* If displaying the 'categorys' column. */ |
|
| 1127 | - case 'categorys' : |
|
| 1128 | - |
|
| 1129 | - /* Get the categorys for the post. */ |
|
| 1130 | - |
|
| 1131 | - |
|
| 1132 | - $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
| 1133 | - |
|
| 1134 | - /* If terms were found. */ |
|
| 1135 | - if (!empty($terms)) {
|
|
| 1136 | - $out = array(); |
|
| 1137 | - /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
| 1138 | - foreach ($terms as $term) {
|
|
| 1139 | - if (!strstr($term->taxonomy, 'tag')) {
|
|
| 1140 | - $out[] = sprintf('<a href="%s">%s</a>',
|
|
| 1141 | - esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
|
|
| 1142 | - esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
|
|
| 1143 | - ); |
|
| 1144 | - } |
|
| 1145 | - } |
|
| 1146 | - /* Join the terms, separating them with a comma. */ |
|
| 1147 | - echo(join(', ', $out));
|
|
| 1148 | - } /* If no terms were found, output a default message. */ |
|
| 1149 | - else {
|
|
| 1150 | - _e('No Categories', 'geodirectory');
|
|
| 1151 | - } |
|
| 1152 | - break; |
|
| 1073 | + /** |
|
| 1074 | + * Adds content to our custom post listing page columns. |
|
| 1075 | + * |
|
| 1076 | + * @since 1.0.0 |
|
| 1077 | + * @package GeoDirectory |
|
| 1078 | + * @global object $wpdb WordPress Database object. |
|
| 1079 | + * @global object $post WordPress Post object. |
|
| 1080 | + * @param string $column The column name. |
|
| 1081 | + * @param int $post_id The post ID. |
|
| 1082 | + */ |
|
| 1083 | + function geodir_manage_post_columns($column, $post_id) |
|
| 1084 | + {
|
|
| 1085 | + global $post, $wpdb; |
|
| 1086 | + |
|
| 1087 | + switch ($column): |
|
| 1088 | + /* If displaying the 'city' column. */ |
|
| 1089 | + case 'location' : |
|
| 1090 | + $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
| 1091 | + $location = geodir_get_location($location_id); |
|
| 1092 | + /* If no city is found, output a default message. */ |
|
| 1093 | + if (empty($location)) {
|
|
| 1094 | + _e('Unknown', 'geodirectory');
|
|
| 1095 | + } else {
|
|
| 1096 | + /* If there is a city id, append 'city name' to the text string. */ |
|
| 1097 | + $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
|
|
| 1098 | + echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
| 1099 | + } |
|
| 1100 | + break; |
|
| 1101 | + |
|
| 1102 | + /* If displaying the 'expire' column. */ |
|
| 1103 | + case 'expire' : |
|
| 1104 | + $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
| 1105 | + $d1 = $expire_date; // get expire_date |
|
| 1106 | + $d2 = date('Y-m-d'); // get current date
|
|
| 1107 | + $state = __('days left', 'geodirectory');
|
|
| 1108 | + $date_diff_text = ''; |
|
| 1109 | + $expire_class = 'expire_left'; |
|
| 1110 | + if ($expire_date != 'Never') {
|
|
| 1111 | + if (strtotime($d1) < strtotime($d2)) {
|
|
| 1112 | + $state = __('days overdue', 'geodirectory');
|
|
| 1113 | + $expire_class = 'expire_over'; |
|
| 1114 | + } |
|
| 1115 | + $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
|
| 1116 | + $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
|
| 1117 | + } |
|
| 1118 | + /* If no expire_date is found, output a default message. */ |
|
| 1119 | + if (empty($expire_date)) |
|
| 1120 | + echo __('Unknown', 'geodirectory');
|
|
| 1121 | + /* If there is a expire_date, append 'days left' to the text string. */ |
|
| 1122 | + else |
|
| 1123 | + echo $expire_date . $date_diff_text; |
|
| 1124 | + break; |
|
| 1153 | 1125 | |
| 1154 | - endswitch; |
|
| 1155 | - } |
|
| 1126 | + /* If displaying the 'categorys' column. */ |
|
| 1127 | + case 'categorys' : |
|
| 1128 | + |
|
| 1129 | + /* Get the categorys for the post. */ |
|
| 1130 | + |
|
| 1131 | + |
|
| 1132 | + $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
| 1133 | + |
|
| 1134 | + /* If terms were found. */ |
|
| 1135 | + if (!empty($terms)) {
|
|
| 1136 | + $out = array(); |
|
| 1137 | + /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
| 1138 | + foreach ($terms as $term) {
|
|
| 1139 | + if (!strstr($term->taxonomy, 'tag')) {
|
|
| 1140 | + $out[] = sprintf('<a href="%s">%s</a>',
|
|
| 1141 | + esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
|
|
| 1142 | + esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
|
|
| 1143 | + ); |
|
| 1144 | + } |
|
| 1145 | + } |
|
| 1146 | + /* Join the terms, separating them with a comma. */ |
|
| 1147 | + echo(join(', ', $out));
|
|
| 1148 | + } /* If no terms were found, output a default message. */ |
|
| 1149 | + else {
|
|
| 1150 | + _e('No Categories', 'geodirectory');
|
|
| 1151 | + } |
|
| 1152 | + break; |
|
| 1153 | + |
|
| 1154 | + endswitch; |
|
| 1155 | + } |
|
| 1156 | 1156 | } |
| 1157 | 1157 | |
| 1158 | 1158 | |
| 1159 | 1159 | if (!function_exists('geodir_post_sortable_columns')) {
|
| 1160 | - /** |
|
| 1161 | - * Makes admin post listing page columns sortable. |
|
| 1162 | - * |
|
| 1163 | - * @since 1.0.0 |
|
| 1164 | - * @package GeoDirectory |
|
| 1165 | - * @param array $columns The column array. |
|
| 1166 | - * @return array Altered column array. |
|
| 1167 | - */ |
|
| 1168 | - function geodir_post_sortable_columns($columns) |
|
| 1169 | - {
|
|
| 1170 | - |
|
| 1171 | - $columns['expire'] = 'expire'; |
|
| 1172 | - |
|
| 1173 | - return $columns; |
|
| 1174 | - } |
|
| 1160 | + /** |
|
| 1161 | + * Makes admin post listing page columns sortable. |
|
| 1162 | + * |
|
| 1163 | + * @since 1.0.0 |
|
| 1164 | + * @package GeoDirectory |
|
| 1165 | + * @param array $columns The column array. |
|
| 1166 | + * @return array Altered column array. |
|
| 1167 | + */ |
|
| 1168 | + function geodir_post_sortable_columns($columns) |
|
| 1169 | + {
|
|
| 1170 | + |
|
| 1171 | + $columns['expire'] = 'expire'; |
|
| 1172 | + |
|
| 1173 | + return $columns; |
|
| 1174 | + } |
|
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | /** |
@@ -1185,32 +1185,32 @@ discard block |
||
| 1185 | 1185 | * @param int $post_id The post ID. |
| 1186 | 1186 | */ |
| 1187 | 1187 | function geodir_post_information_save($post_id, $post) {
|
| 1188 | - global $wpdb, $current_user; |
|
| 1188 | + global $wpdb, $current_user; |
|
| 1189 | 1189 | |
| 1190 | - if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 1191 | - return; |
|
| 1192 | - } |
|
| 1190 | + if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 1191 | + return; |
|
| 1192 | + } |
|
| 1193 | 1193 | |
| 1194 | - $geodir_posttypes = geodir_get_posttypes(); |
|
| 1194 | + $geodir_posttypes = geodir_get_posttypes(); |
|
| 1195 | 1195 | |
| 1196 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
|
| 1197 | - return; |
|
| 1196 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
|
| 1197 | + return; |
|
| 1198 | 1198 | |
| 1199 | - if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 1200 | - if (isset($_REQUEST['_status'])) |
|
| 1201 | - geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 1199 | + if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 1200 | + if (isset($_REQUEST['_status'])) |
|
| 1201 | + geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 1202 | 1202 | |
| 1203 | - if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
| 1204 | - return; |
|
| 1203 | + if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
| 1204 | + return; |
|
| 1205 | 1205 | |
| 1206 | - if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
| 1207 | - return; |
|
| 1206 | + if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
| 1207 | + return; |
|
| 1208 | 1208 | |
| 1209 | - if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
| 1210 | - return; |
|
| 1209 | + if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
| 1210 | + return; |
|
| 1211 | 1211 | |
| 1212 | - geodir_save_listing($_REQUEST); |
|
| 1213 | - } |
|
| 1212 | + geodir_save_listing($_REQUEST); |
|
| 1213 | + } |
|
| 1214 | 1214 | } |
| 1215 | 1215 | |
| 1216 | 1216 | /** |
@@ -1226,102 +1226,102 @@ discard block |
||
| 1226 | 1226 | */ |
| 1227 | 1227 | function geodir_admin_fields($options) |
| 1228 | 1228 | {
|
| 1229 | - global $geodirectory; |
|
| 1230 | - |
|
| 1231 | - $first_title = true; |
|
| 1232 | - $tab_id = ''; |
|
| 1233 | - $i = 0; |
|
| 1234 | - foreach ($options as $value) : |
|
| 1235 | - if (!isset($value['name'])) $value['name'] = ''; |
|
| 1236 | - if (!isset($value['class'])) $value['class'] = ''; |
|
| 1237 | - if (!isset($value['css'])) $value['css'] = ''; |
|
| 1238 | - if (!isset($value['std'])) $value['std'] = ''; |
|
| 1239 | - $desc = ''; |
|
| 1240 | - switch ($value['type']) : |
|
| 1241 | - case 'dummy_installer': |
|
| 1242 | - $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
| 1243 | - geodir_autoinstall_admin_header($post_type); |
|
| 1244 | - break; |
|
| 1245 | - case 'title': |
|
| 1246 | - |
|
| 1247 | - if ($i == 0) {
|
|
| 1248 | - echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
| 1249 | - echo '<div class="inner_content_tab_main">'; |
|
| 1250 | - } |
|
| 1229 | + global $geodirectory; |
|
| 1230 | + |
|
| 1231 | + $first_title = true; |
|
| 1232 | + $tab_id = ''; |
|
| 1233 | + $i = 0; |
|
| 1234 | + foreach ($options as $value) : |
|
| 1235 | + if (!isset($value['name'])) $value['name'] = ''; |
|
| 1236 | + if (!isset($value['class'])) $value['class'] = ''; |
|
| 1237 | + if (!isset($value['css'])) $value['css'] = ''; |
|
| 1238 | + if (!isset($value['std'])) $value['std'] = ''; |
|
| 1239 | + $desc = ''; |
|
| 1240 | + switch ($value['type']) : |
|
| 1241 | + case 'dummy_installer': |
|
| 1242 | + $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
| 1243 | + geodir_autoinstall_admin_header($post_type); |
|
| 1244 | + break; |
|
| 1245 | + case 'title': |
|
| 1246 | + |
|
| 1247 | + if ($i == 0) {
|
|
| 1248 | + echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
| 1249 | + echo '<div class="inner_content_tab_main">'; |
|
| 1250 | + } |
|
| 1251 | 1251 | |
| 1252 | - $i++; |
|
| 1252 | + $i++; |
|
| 1253 | 1253 | |
| 1254 | - if (isset($value['id']) && $value['id']) |
|
| 1255 | - $tab_id = $value['id']; |
|
| 1254 | + if (isset($value['id']) && $value['id']) |
|
| 1255 | + $tab_id = $value['id']; |
|
| 1256 | 1256 | |
| 1257 | - if (isset($value['desc']) && $value['desc']) |
|
| 1258 | - $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 1257 | + if (isset($value['desc']) && $value['desc']) |
|
| 1258 | + $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 1259 | 1259 | |
| 1260 | - if (isset($value['name']) && $value['name']) {
|
|
| 1261 | - if ($first_title === true) {
|
|
| 1262 | - $first_title = false; |
|
| 1263 | - } else {
|
|
| 1264 | - echo '</div>'; |
|
| 1265 | - } |
|
| 1266 | - echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
| 1260 | + if (isset($value['name']) && $value['name']) {
|
|
| 1261 | + if ($first_title === true) {
|
|
| 1262 | + $first_title = false; |
|
| 1263 | + } else {
|
|
| 1264 | + echo '</div>'; |
|
| 1265 | + } |
|
| 1266 | + echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
| 1267 | 1267 | |
| 1268 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1269 | - } |
|
| 1268 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1269 | + } |
|
| 1270 | 1270 | |
| 1271 | - /** |
|
| 1272 | - * Called after a GeoDirectory settings title is output in the GD settings page. |
|
| 1273 | - * |
|
| 1274 | - * The action is called dynamically geodir_settings_$value['id']. |
|
| 1275 | - * |
|
| 1276 | - * @since 1.0.0 |
|
| 1277 | - */ |
|
| 1278 | - do_action('geodir_settings_' . sanitize_title($value['id']));
|
|
| 1279 | - break; |
|
| 1280 | - |
|
| 1281 | - case 'no_tabs': |
|
| 1282 | - |
|
| 1283 | - echo '<div class="inner_content_tab_main">'; |
|
| 1284 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1285 | - |
|
| 1286 | - break; |
|
| 1287 | - |
|
| 1288 | - case 'sectionstart': |
|
| 1289 | - if (isset($value['desc']) && $value['desc']) |
|
| 1290 | - $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 1291 | - if (isset($value['name']) && $value['name']) |
|
| 1292 | - echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 1293 | - /** |
|
| 1294 | - * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
| 1295 | - * |
|
| 1296 | - * The action is called dynamically geodir_settings_$value['id']_start. |
|
| 1297 | - * |
|
| 1298 | - * @since 1.0.0 |
|
| 1299 | - */ |
|
| 1300 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 1301 | - echo '<table class="form-table">' . "\n\n"; |
|
| 1302 | - |
|
| 1303 | - break; |
|
| 1304 | - case 'sectionend': |
|
| 1305 | - /** |
|
| 1306 | - * Called before a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 1307 | - * |
|
| 1308 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 1309 | - * |
|
| 1310 | - * @since 1.0.0 |
|
| 1311 | - */ |
|
| 1312 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 1313 | - echo '</table>'; |
|
| 1314 | - /** |
|
| 1315 | - * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 1316 | - * |
|
| 1317 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 1318 | - * |
|
| 1319 | - * @since 1.0.0 |
|
| 1320 | - */ |
|
| 1321 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 1322 | - break; |
|
| 1323 | - case 'text': |
|
| 1324 | - ?> |
|
| 1271 | + /** |
|
| 1272 | + * Called after a GeoDirectory settings title is output in the GD settings page. |
|
| 1273 | + * |
|
| 1274 | + * The action is called dynamically geodir_settings_$value['id']. |
|
| 1275 | + * |
|
| 1276 | + * @since 1.0.0 |
|
| 1277 | + */ |
|
| 1278 | + do_action('geodir_settings_' . sanitize_title($value['id']));
|
|
| 1279 | + break; |
|
| 1280 | + |
|
| 1281 | + case 'no_tabs': |
|
| 1282 | + |
|
| 1283 | + echo '<div class="inner_content_tab_main">'; |
|
| 1284 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1285 | + |
|
| 1286 | + break; |
|
| 1287 | + |
|
| 1288 | + case 'sectionstart': |
|
| 1289 | + if (isset($value['desc']) && $value['desc']) |
|
| 1290 | + $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 1291 | + if (isset($value['name']) && $value['name']) |
|
| 1292 | + echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 1293 | + /** |
|
| 1294 | + * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
| 1295 | + * |
|
| 1296 | + * The action is called dynamically geodir_settings_$value['id']_start. |
|
| 1297 | + * |
|
| 1298 | + * @since 1.0.0 |
|
| 1299 | + */ |
|
| 1300 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 1301 | + echo '<table class="form-table">' . "\n\n"; |
|
| 1302 | + |
|
| 1303 | + break; |
|
| 1304 | + case 'sectionend': |
|
| 1305 | + /** |
|
| 1306 | + * Called before a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 1307 | + * |
|
| 1308 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 1309 | + * |
|
| 1310 | + * @since 1.0.0 |
|
| 1311 | + */ |
|
| 1312 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 1313 | + echo '</table>'; |
|
| 1314 | + /** |
|
| 1315 | + * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 1316 | + * |
|
| 1317 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 1318 | + * |
|
| 1319 | + * @since 1.0.0 |
|
| 1320 | + */ |
|
| 1321 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 1322 | + break; |
|
| 1323 | + case 'text': |
|
| 1324 | + ?> |
|
| 1325 | 1325 | <tr valign="top"> |
| 1326 | 1326 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1327 | 1327 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1330,15 +1330,15 @@ discard block |
||
| 1330 | 1330 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 1331 | 1331 | style=" <?php echo esc_attr($value['css']); ?>" |
| 1332 | 1332 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1333 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1334 | - } else {
|
|
| 1335 | - echo esc_attr($value['std']); |
|
| 1336 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1333 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1334 | + } else {
|
|
| 1335 | + echo esc_attr($value['std']); |
|
| 1336 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1337 | 1337 | </tr><?php |
| 1338 | - break; |
|
| 1338 | + break; |
|
| 1339 | 1339 | |
| 1340 | - case 'password': |
|
| 1341 | - ?> |
|
| 1340 | + case 'password': |
|
| 1341 | + ?> |
|
| 1342 | 1342 | <tr valign="top"> |
| 1343 | 1343 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1344 | 1344 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1347,42 +1347,42 @@ discard block |
||
| 1347 | 1347 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 1348 | 1348 | style="<?php echo esc_attr($value['css']); ?>" |
| 1349 | 1349 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1350 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1351 | - } else {
|
|
| 1352 | - echo esc_attr($value['std']); |
|
| 1353 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1350 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1351 | + } else {
|
|
| 1352 | + echo esc_attr($value['std']); |
|
| 1353 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1354 | 1354 | </tr><?php |
| 1355 | - break; |
|
| 1355 | + break; |
|
| 1356 | 1356 | |
| 1357 | - case 'html_content': |
|
| 1358 | - ?> |
|
| 1357 | + case 'html_content': |
|
| 1358 | + ?> |
|
| 1359 | 1359 | <tr valign="top"> |
| 1360 | 1360 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1361 | 1361 | <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td> |
| 1362 | 1362 | </tr><?php |
| 1363 | - break; |
|
| 1363 | + break; |
|
| 1364 | 1364 | |
| 1365 | - case 'color' : |
|
| 1366 | - ?> |
|
| 1365 | + case 'color' : |
|
| 1366 | + ?> |
|
| 1367 | 1367 | <tr valign="top"> |
| 1368 | 1368 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1369 | 1369 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
| 1370 | 1370 | id="<?php echo esc_attr($value['id']); ?>" type="text" |
| 1371 | 1371 | style="<?php echo esc_attr($value['css']); ?>" |
| 1372 | 1372 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1373 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1374 | - } else {
|
|
| 1375 | - echo esc_attr($value['std']); |
|
| 1376 | - } ?>" class="colorpick"/> <span |
|
| 1373 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1374 | + } else {
|
|
| 1375 | + echo esc_attr($value['std']); |
|
| 1376 | + } ?>" class="colorpick"/> <span |
|
| 1377 | 1377 | class="description"><?php echo $value['desc']; ?></span> |
| 1378 | 1378 | |
| 1379 | 1379 | <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv" |
| 1380 | 1380 | style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div> |
| 1381 | 1381 | </td> |
| 1382 | 1382 | </tr><?php |
| 1383 | - break; |
|
| 1384 | - case 'image_width' : |
|
| 1385 | - ?> |
|
| 1383 | + break; |
|
| 1384 | + case 'image_width' : |
|
| 1385 | + ?> |
|
| 1386 | 1386 | <tr valign="top"> |
| 1387 | 1387 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1388 | 1388 | <td class="forminp"> |
@@ -1404,11 +1404,11 @@ discard block |
||
| 1404 | 1404 | |
| 1405 | 1405 | <span class="description"><?php echo $value['desc'] ?></span></td> |
| 1406 | 1406 | </tr><?php |
| 1407 | - break; |
|
| 1408 | - case 'select': |
|
| 1409 | - $option_value = get_option($value['id']); |
|
| 1410 | - $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value; |
|
| 1411 | - ?> |
|
| 1407 | + break; |
|
| 1408 | + case 'select': |
|
| 1409 | + $option_value = get_option($value['id']); |
|
| 1410 | + $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value; |
|
| 1411 | + ?> |
|
| 1412 | 1412 | <tr valign="top"> |
| 1413 | 1413 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1414 | 1414 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -1417,33 +1417,33 @@ discard block |
||
| 1417 | 1417 | class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
| 1418 | 1418 | option-ajaxchosen="false"> |
| 1419 | 1419 | <?php |
| 1420 | - foreach ($value['options'] as $key => $val) {
|
|
| 1421 | - $geodir_select_value = ''; |
|
| 1422 | - if ($option_value != '') {
|
|
| 1423 | - if ($option_value != '' && $option_value == $key) |
|
| 1424 | - $geodir_select_value = ' selected="selected" '; |
|
| 1425 | - } else {
|
|
| 1426 | - if ($value['std'] == $key) |
|
| 1427 | - $geodir_select_value = ' selected="selected" '; |
|
| 1428 | - } |
|
| 1429 | - ?> |
|
| 1420 | + foreach ($value['options'] as $key => $val) {
|
|
| 1421 | + $geodir_select_value = ''; |
|
| 1422 | + if ($option_value != '') {
|
|
| 1423 | + if ($option_value != '' && $option_value == $key) |
|
| 1424 | + $geodir_select_value = ' selected="selected" '; |
|
| 1425 | + } else {
|
|
| 1426 | + if ($value['std'] == $key) |
|
| 1427 | + $geodir_select_value = ' selected="selected" '; |
|
| 1428 | + } |
|
| 1429 | + ?> |
|
| 1430 | 1430 | <option |
| 1431 | 1431 | value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo ucfirst($val) ?></option> |
| 1432 | 1432 | <?php |
| 1433 | - } |
|
| 1434 | - ?> |
|
| 1433 | + } |
|
| 1434 | + ?> |
|
| 1435 | 1435 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1436 | 1436 | </td> |
| 1437 | 1437 | </tr><?php |
| 1438 | - break; |
|
| 1438 | + break; |
|
| 1439 | 1439 | |
| 1440 | - case 'multiselect': |
|
| 1441 | - $option_values = get_option($value['id']); |
|
| 1442 | - if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
|
|
| 1443 | - $option_values = $value['std']; |
|
| 1444 | - } |
|
| 1445 | - $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values; |
|
| 1446 | - ?> |
|
| 1440 | + case 'multiselect': |
|
| 1441 | + $option_values = get_option($value['id']); |
|
| 1442 | + if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
|
|
| 1443 | + $option_values = $value['std']; |
|
| 1444 | + } |
|
| 1445 | + $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values; |
|
| 1446 | + ?> |
|
| 1447 | 1447 | <tr valign="top"> |
| 1448 | 1448 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1449 | 1449 | <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]" |
@@ -1453,25 +1453,25 @@ discard block |
||
| 1453 | 1453 | data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>" |
| 1454 | 1454 | option-ajaxchosen="false"> |
| 1455 | 1455 | <?php |
| 1456 | - foreach ($value['options'] as $key => $val) {
|
|
| 1457 | - if (strpos($key, 'optgroup_start-') === 0) {
|
|
| 1458 | - ?><optgroup label="<?php echo ucfirst($val); ?>"><?php |
|
| 1459 | - } else if (strpos($key, 'optgroup_end-') === 0) {
|
|
| 1460 | - ?></optgroup><?php |
|
| 1461 | - } else {
|
|
| 1462 | - ?> |
|
| 1456 | + foreach ($value['options'] as $key => $val) {
|
|
| 1457 | + if (strpos($key, 'optgroup_start-') === 0) {
|
|
| 1458 | + ?><optgroup label="<?php echo ucfirst($val); ?>"><?php |
|
| 1459 | + } else if (strpos($key, 'optgroup_end-') === 0) {
|
|
| 1460 | + ?></optgroup><?php |
|
| 1461 | + } else {
|
|
| 1462 | + ?> |
|
| 1463 | 1463 | <option |
| 1464 | 1464 | value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option> |
| 1465 | 1465 | <?php |
| 1466 | - } |
|
| 1467 | - } |
|
| 1468 | - ?> |
|
| 1466 | + } |
|
| 1467 | + } |
|
| 1468 | + ?> |
|
| 1469 | 1469 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1470 | 1470 | </td> |
| 1471 | 1471 | </tr><?php |
| 1472 | - break; |
|
| 1473 | - case 'file': |
|
| 1474 | - ?> |
|
| 1472 | + break; |
|
| 1473 | + case 'file': |
|
| 1474 | + ?> |
|
| 1475 | 1475 | <tr valign="top"> |
| 1476 | 1476 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1477 | 1477 | <td class="forminp"> |
@@ -1491,87 +1491,87 @@ discard block |
||
| 1491 | 1491 | <?php } ?> |
| 1492 | 1492 | </td> |
| 1493 | 1493 | </tr><?php |
| 1494 | - break; |
|
| 1495 | - case 'map_default_settings' : |
|
| 1496 | - ?> |
|
| 1494 | + break; |
|
| 1495 | + case 'map_default_settings' : |
|
| 1496 | + ?> |
|
| 1497 | 1497 | |
| 1498 | 1498 | <tr valign="top"> |
| 1499 | 1499 | <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
|
| 1500 | 1500 | <td width="60%"> |
| 1501 | 1501 | <select name="geodir_default_map_language" style="width:60%"> |
| 1502 | 1502 | <?php |
| 1503 | - $arr_map_langages = array( |
|
| 1504 | - 'ar' => __('ARABIC', 'geodirectory'),
|
|
| 1505 | - 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1506 | - 'bg' => __('BULGARIAN', 'geodirectory'),
|
|
| 1507 | - 'bn' => __('BENGALI', 'geodirectory'),
|
|
| 1508 | - 'ca' => __('CATALAN', 'geodirectory'),
|
|
| 1509 | - 'cs' => __('CZECH', 'geodirectory'),
|
|
| 1510 | - 'da' => __('DANISH', 'geodirectory'),
|
|
| 1511 | - 'de' => __('GERMAN', 'geodirectory'),
|
|
| 1512 | - 'el' => __('GREEK', 'geodirectory'),
|
|
| 1513 | - 'en' => __('ENGLISH', 'geodirectory'),
|
|
| 1514 | - 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
|
|
| 1515 | - 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
|
|
| 1516 | - 'es' => __('SPANISH', 'geodirectory'),
|
|
| 1517 | - 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1518 | - 'fa' => __('FARSI', 'geodirectory'),
|
|
| 1519 | - 'fi' => __('FINNISH', 'geodirectory'),
|
|
| 1520 | - 'fil' => __('FILIPINO', 'geodirectory'),
|
|
| 1521 | - 'fr' => __('FRENCH', 'geodirectory'),
|
|
| 1522 | - 'gl' => __('GALICIAN', 'geodirectory'),
|
|
| 1523 | - 'gu' => __('GUJARATI', 'geodirectory'),
|
|
| 1524 | - 'hi' => __('HINDI', 'geodirectory'),
|
|
| 1525 | - 'hr' => __('CROATIAN', 'geodirectory'),
|
|
| 1526 | - 'hu' => __('HUNGARIAN', 'geodirectory'),
|
|
| 1527 | - 'id' => __('INDONESIAN', 'geodirectory'),
|
|
| 1528 | - 'it' => __('ITALIAN', 'geodirectory'),
|
|
| 1529 | - 'iw' => __('HEBREW', 'geodirectory'),
|
|
| 1530 | - 'ja' => __('JAPANESE', 'geodirectory'),
|
|
| 1531 | - 'kn' => __('KANNADA', 'geodirectory'),
|
|
| 1532 | - 'ko' => __('KOREAN', 'geodirectory'),
|
|
| 1533 | - 'lt' => __('LITHUANIAN', 'geodirectory'),
|
|
| 1534 | - 'lv' => __('LATVIAN', 'geodirectory'),
|
|
| 1535 | - 'ml' => __('MALAYALAM', 'geodirectory'),
|
|
| 1536 | - 'mr' => __('MARATHI', 'geodirectory'),
|
|
| 1537 | - 'nl' => __('DUTCH', 'geodirectory'),
|
|
| 1538 | - 'no' => __('NORWEGIAN', 'geodirectory'),
|
|
| 1539 | - 'pl' => __('POLISH', 'geodirectory'),
|
|
| 1540 | - 'pt' => __('PORTUGUESE', 'geodirectory'),
|
|
| 1541 | - 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
|
|
| 1542 | - 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
|
|
| 1543 | - 'ro' => __('ROMANIAN', 'geodirectory'),
|
|
| 1544 | - 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1545 | - 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1546 | - 'sk' => __('SLOVAK', 'geodirectory'),
|
|
| 1547 | - 'sl' => __('SLOVENIAN', 'geodirectory'),
|
|
| 1548 | - 'sr' => __('SERBIAN', 'geodirectory'),
|
|
| 1549 | - 'sv' => __(' SWEDISH', 'geodirectory'),
|
|
| 1550 | - 'tl' => __('TAGALOG', 'geodirectory'),
|
|
| 1551 | - 'ta' => __('TAMIL', 'geodirectory'),
|
|
| 1552 | - 'te' => __('TELUGU', 'geodirectory'),
|
|
| 1553 | - 'th' => __('THAI', 'geodirectory'),
|
|
| 1554 | - 'tr' => __('TURKISH', 'geodirectory'),
|
|
| 1555 | - 'uk' => __('UKRAINIAN', 'geodirectory'),
|
|
| 1556 | - 'vi' => __('VIETNAMESE', 'geodirectory'),
|
|
| 1557 | - 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
|
|
| 1558 | - 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
|
|
| 1559 | - ); |
|
| 1560 | - $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 1561 | - if (empty($geodir_default_map_language)) |
|
| 1562 | - $geodir_default_map_language = 'en'; |
|
| 1563 | - foreach ($arr_map_langages as $language_key => $language_txt) {
|
|
| 1564 | - if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
| 1565 | - $geodir_default_language_selected = "selected='selected'"; |
|
| 1566 | - else |
|
| 1567 | - $geodir_default_language_selected = ''; |
|
| 1568 | - |
|
| 1569 | - ?> |
|
| 1503 | + $arr_map_langages = array( |
|
| 1504 | + 'ar' => __('ARABIC', 'geodirectory'),
|
|
| 1505 | + 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1506 | + 'bg' => __('BULGARIAN', 'geodirectory'),
|
|
| 1507 | + 'bn' => __('BENGALI', 'geodirectory'),
|
|
| 1508 | + 'ca' => __('CATALAN', 'geodirectory'),
|
|
| 1509 | + 'cs' => __('CZECH', 'geodirectory'),
|
|
| 1510 | + 'da' => __('DANISH', 'geodirectory'),
|
|
| 1511 | + 'de' => __('GERMAN', 'geodirectory'),
|
|
| 1512 | + 'el' => __('GREEK', 'geodirectory'),
|
|
| 1513 | + 'en' => __('ENGLISH', 'geodirectory'),
|
|
| 1514 | + 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
|
|
| 1515 | + 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
|
|
| 1516 | + 'es' => __('SPANISH', 'geodirectory'),
|
|
| 1517 | + 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1518 | + 'fa' => __('FARSI', 'geodirectory'),
|
|
| 1519 | + 'fi' => __('FINNISH', 'geodirectory'),
|
|
| 1520 | + 'fil' => __('FILIPINO', 'geodirectory'),
|
|
| 1521 | + 'fr' => __('FRENCH', 'geodirectory'),
|
|
| 1522 | + 'gl' => __('GALICIAN', 'geodirectory'),
|
|
| 1523 | + 'gu' => __('GUJARATI', 'geodirectory'),
|
|
| 1524 | + 'hi' => __('HINDI', 'geodirectory'),
|
|
| 1525 | + 'hr' => __('CROATIAN', 'geodirectory'),
|
|
| 1526 | + 'hu' => __('HUNGARIAN', 'geodirectory'),
|
|
| 1527 | + 'id' => __('INDONESIAN', 'geodirectory'),
|
|
| 1528 | + 'it' => __('ITALIAN', 'geodirectory'),
|
|
| 1529 | + 'iw' => __('HEBREW', 'geodirectory'),
|
|
| 1530 | + 'ja' => __('JAPANESE', 'geodirectory'),
|
|
| 1531 | + 'kn' => __('KANNADA', 'geodirectory'),
|
|
| 1532 | + 'ko' => __('KOREAN', 'geodirectory'),
|
|
| 1533 | + 'lt' => __('LITHUANIAN', 'geodirectory'),
|
|
| 1534 | + 'lv' => __('LATVIAN', 'geodirectory'),
|
|
| 1535 | + 'ml' => __('MALAYALAM', 'geodirectory'),
|
|
| 1536 | + 'mr' => __('MARATHI', 'geodirectory'),
|
|
| 1537 | + 'nl' => __('DUTCH', 'geodirectory'),
|
|
| 1538 | + 'no' => __('NORWEGIAN', 'geodirectory'),
|
|
| 1539 | + 'pl' => __('POLISH', 'geodirectory'),
|
|
| 1540 | + 'pt' => __('PORTUGUESE', 'geodirectory'),
|
|
| 1541 | + 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
|
|
| 1542 | + 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
|
|
| 1543 | + 'ro' => __('ROMANIAN', 'geodirectory'),
|
|
| 1544 | + 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1545 | + 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1546 | + 'sk' => __('SLOVAK', 'geodirectory'),
|
|
| 1547 | + 'sl' => __('SLOVENIAN', 'geodirectory'),
|
|
| 1548 | + 'sr' => __('SERBIAN', 'geodirectory'),
|
|
| 1549 | + 'sv' => __(' SWEDISH', 'geodirectory'),
|
|
| 1550 | + 'tl' => __('TAGALOG', 'geodirectory'),
|
|
| 1551 | + 'ta' => __('TAMIL', 'geodirectory'),
|
|
| 1552 | + 'te' => __('TELUGU', 'geodirectory'),
|
|
| 1553 | + 'th' => __('THAI', 'geodirectory'),
|
|
| 1554 | + 'tr' => __('TURKISH', 'geodirectory'),
|
|
| 1555 | + 'uk' => __('UKRAINIAN', 'geodirectory'),
|
|
| 1556 | + 'vi' => __('VIETNAMESE', 'geodirectory'),
|
|
| 1557 | + 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
|
|
| 1558 | + 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
|
|
| 1559 | + ); |
|
| 1560 | + $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 1561 | + if (empty($geodir_default_map_language)) |
|
| 1562 | + $geodir_default_map_language = 'en'; |
|
| 1563 | + foreach ($arr_map_langages as $language_key => $language_txt) {
|
|
| 1564 | + if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
| 1565 | + $geodir_default_language_selected = "selected='selected'"; |
|
| 1566 | + else |
|
| 1567 | + $geodir_default_language_selected = ''; |
|
| 1568 | + |
|
| 1569 | + ?> |
|
| 1570 | 1570 | <option |
| 1571 | 1571 | value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option> |
| 1572 | 1572 | |
| 1573 | 1573 | <?php } |
| 1574 | - ?> |
|
| 1574 | + ?> |
|
| 1575 | 1575 | </select> |
| 1576 | 1576 | </td> |
| 1577 | 1577 | </tr> |
@@ -1582,46 +1582,46 @@ discard block |
||
| 1582 | 1582 | <td width="60%"> |
| 1583 | 1583 | <select name="geodir_default_map_search_pt" style="width:60%"> |
| 1584 | 1584 | <?php |
| 1585 | - $post_types = geodir_get_posttypes('array');
|
|
| 1586 | - $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
|
|
| 1587 | - if (empty($geodir_default_map_search_pt)) |
|
| 1588 | - $geodir_default_map_search_pt = 'gd_place'; |
|
| 1589 | - if (is_array($post_types)) {
|
|
| 1590 | - foreach ($post_types as $key => $post_types_obj) {
|
|
| 1591 | - if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
| 1592 | - $geodir_search_pt_selected = "selected='selected'"; |
|
| 1593 | - else |
|
| 1594 | - $geodir_search_pt_selected = ''; |
|
| 1595 | - |
|
| 1596 | - ?> |
|
| 1585 | + $post_types = geodir_get_posttypes('array');
|
|
| 1586 | + $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
|
|
| 1587 | + if (empty($geodir_default_map_search_pt)) |
|
| 1588 | + $geodir_default_map_search_pt = 'gd_place'; |
|
| 1589 | + if (is_array($post_types)) {
|
|
| 1590 | + foreach ($post_types as $key => $post_types_obj) {
|
|
| 1591 | + if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
| 1592 | + $geodir_search_pt_selected = "selected='selected'"; |
|
| 1593 | + else |
|
| 1594 | + $geodir_search_pt_selected = ''; |
|
| 1595 | + |
|
| 1596 | + ?> |
|
| 1597 | 1597 | <option |
| 1598 | 1598 | value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo $post_types_obj['labels']['singular_name']; ?></option> |
| 1599 | 1599 | |
| 1600 | 1600 | <?php } |
| 1601 | 1601 | |
| 1602 | - } |
|
| 1602 | + } |
|
| 1603 | 1603 | |
| 1604 | - ?> |
|
| 1604 | + ?> |
|
| 1605 | 1605 | </select> |
| 1606 | 1606 | </td> |
| 1607 | 1607 | </tr> |
| 1608 | 1608 | |
| 1609 | 1609 | <?php |
| 1610 | - break; |
|
| 1610 | + break; |
|
| 1611 | 1611 | |
| 1612 | - case 'map': |
|
| 1613 | - ?> |
|
| 1612 | + case 'map': |
|
| 1613 | + ?> |
|
| 1614 | 1614 | <tr valign="top"> |
| 1615 | 1615 | <td class="forminp"> |
| 1616 | 1616 | <?php |
| 1617 | - global $post_cat, $cat_display; |
|
| 1618 | - $post_types = geodir_get_posttypes('object');
|
|
| 1619 | - $cat_display = 'checkbox'; |
|
| 1620 | - $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
|
| 1621 | - $gd_cats = get_option('geodir_exclude_cat_on_map');
|
|
| 1622 | - $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 1623 | - $count = 1; |
|
| 1624 | - ?> |
|
| 1617 | + global $post_cat, $cat_display; |
|
| 1618 | + $post_types = geodir_get_posttypes('object');
|
|
| 1619 | + $cat_display = 'checkbox'; |
|
| 1620 | + $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
|
| 1621 | + $gd_cats = get_option('geodir_exclude_cat_on_map');
|
|
| 1622 | + $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 1623 | + $count = 1; |
|
| 1624 | + ?> |
|
| 1625 | 1625 | <table width="70%" class="widefat"> |
| 1626 | 1626 | <thead> |
| 1627 | 1627 | <tr> |
@@ -1630,18 +1630,18 @@ discard block |
||
| 1630 | 1630 | <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th> |
| 1631 | 1631 | </tr> |
| 1632 | 1632 | <?php |
| 1633 | - $gd_categs = $gd_cats; |
|
| 1634 | - foreach ($post_types as $key => $post_types_obj) : |
|
| 1635 | - $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
| 1636 | - $gd_taxonomy = geodir_get_taxonomies($key); |
|
| 1637 | - if ($gd_cats_upgrade) {
|
|
| 1638 | - $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
| 1639 | - $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
| 1640 | - $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
| 1641 | - } |
|
| 1642 | - $post_cat = implode(',', $gd_cats);
|
|
| 1643 | - $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
| 1644 | - ?> |
|
| 1633 | + $gd_categs = $gd_cats; |
|
| 1634 | + foreach ($post_types as $key => $post_types_obj) : |
|
| 1635 | + $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
| 1636 | + $gd_taxonomy = geodir_get_taxonomies($key); |
|
| 1637 | + if ($gd_cats_upgrade) {
|
|
| 1638 | + $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
| 1639 | + $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
| 1640 | + $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
| 1641 | + } |
|
| 1642 | + $post_cat = implode(',', $gd_cats);
|
|
| 1643 | + $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
| 1644 | + ?> |
|
| 1645 | 1645 | <tr> |
| 1646 | 1646 | <td valign="top" width="5%"><?php echo $count; ?></td> |
| 1647 | 1647 | <td valign="top" width="25%" id="td_post_types"><input type="checkbox" |
@@ -1662,19 +1662,19 @@ discard block |
||
| 1662 | 1662 | </td> |
| 1663 | 1663 | </tr> |
| 1664 | 1664 | <?php |
| 1665 | - break; |
|
| 1665 | + break; |
|
| 1666 | 1666 | |
| 1667 | - case 'checkbox' : |
|
| 1667 | + case 'checkbox' : |
|
| 1668 | 1668 | |
| 1669 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
| 1670 | - ?> |
|
| 1669 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
| 1670 | + ?> |
|
| 1671 | 1671 | <tr valign="top"> |
| 1672 | 1672 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1673 | 1673 | <td class="forminp"> |
| 1674 | 1674 | <?php |
| 1675 | - endif; |
|
| 1675 | + endif; |
|
| 1676 | 1676 | |
| 1677 | - ?> |
|
| 1677 | + ?> |
|
| 1678 | 1678 | <fieldset> |
| 1679 | 1679 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 1680 | 1680 | <label for="<?php echo $value['id'] ?>"> |
@@ -1684,49 +1684,49 @@ discard block |
||
| 1684 | 1684 | </fieldset> |
| 1685 | 1685 | <?php |
| 1686 | 1686 | |
| 1687 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
| 1688 | - ?> |
|
| 1687 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
| 1688 | + ?> |
|
| 1689 | 1689 | </td> |
| 1690 | 1690 | </tr> |
| 1691 | 1691 | <?php |
| 1692 | - endif; |
|
| 1692 | + endif; |
|
| 1693 | 1693 | |
| 1694 | - break; |
|
| 1694 | + break; |
|
| 1695 | 1695 | |
| 1696 | - case 'radio' : |
|
| 1696 | + case 'radio' : |
|
| 1697 | 1697 | |
| 1698 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
| 1699 | - ?> |
|
| 1698 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
| 1699 | + ?> |
|
| 1700 | 1700 | <tr valign="top"> |
| 1701 | 1701 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1702 | 1702 | <td class="forminp"> |
| 1703 | 1703 | <?php |
| 1704 | - endif; |
|
| 1704 | + endif; |
|
| 1705 | 1705 | |
| 1706 | - ?> |
|
| 1706 | + ?> |
|
| 1707 | 1707 | <fieldset> |
| 1708 | 1708 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 1709 | 1709 | <label for="<?php echo $value['id'];?>"> |
| 1710 | 1710 | <input name="<?php echo esc_attr($value['id']); ?>" |
| 1711 | 1711 | id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio" |
| 1712 | 1712 | value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
|
| 1713 | - echo 'checked="checked"'; |
|
| 1714 | - }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 1713 | + echo 'checked="checked"'; |
|
| 1714 | + }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 1715 | 1715 | <?php echo $value['desc']; ?></label><br> |
| 1716 | 1716 | </fieldset> |
| 1717 | 1717 | <?php |
| 1718 | 1718 | |
| 1719 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
| 1720 | - ?> |
|
| 1719 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
| 1720 | + ?> |
|
| 1721 | 1721 | </td> |
| 1722 | 1722 | </tr> |
| 1723 | 1723 | <?php |
| 1724 | - endif; |
|
| 1724 | + endif; |
|
| 1725 | 1725 | |
| 1726 | - break; |
|
| 1726 | + break; |
|
| 1727 | 1727 | |
| 1728 | - case 'textarea': |
|
| 1729 | - ?> |
|
| 1728 | + case 'textarea': |
|
| 1729 | + ?> |
|
| 1730 | 1730 | <tr valign="top"> |
| 1731 | 1731 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1732 | 1732 | <td class="forminp"> |
@@ -1739,30 +1739,30 @@ discard block |
||
| 1739 | 1739 | |
| 1740 | 1740 | </td> |
| 1741 | 1741 | </tr><?php |
| 1742 | - break; |
|
| 1742 | + break; |
|
| 1743 | 1743 | |
| 1744 | - case 'editor': |
|
| 1745 | - ?> |
|
| 1744 | + case 'editor': |
|
| 1745 | + ?> |
|
| 1746 | 1746 | <tr valign="top"> |
| 1747 | 1747 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1748 | 1748 | <td class="forminp"><?php |
| 1749 | - if (get_option($value['id'])) |
|
| 1750 | - $content = stripslashes(get_option($value['id'])); |
|
| 1751 | - else |
|
| 1752 | - $content = $value['std']; |
|
| 1749 | + if (get_option($value['id'])) |
|
| 1750 | + $content = stripslashes(get_option($value['id'])); |
|
| 1751 | + else |
|
| 1752 | + $content = $value['std']; |
|
| 1753 | 1753 | |
| 1754 | - $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
|
| 1754 | + $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
|
| 1755 | 1755 | |
| 1756 | - wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
| 1756 | + wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
| 1757 | 1757 | |
| 1758 | - ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
| 1758 | + ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
| 1759 | 1759 | |
| 1760 | 1760 | </td> |
| 1761 | 1761 | </tr><?php |
| 1762 | - break; |
|
| 1762 | + break; |
|
| 1763 | 1763 | |
| 1764 | - case 'single_select_page' : |
|
| 1765 | - // WPML |
|
| 1764 | + case 'single_select_page' : |
|
| 1765 | + // WPML |
|
| 1766 | 1766 | $switch_lang = false; |
| 1767 | 1767 | $disabled = ''; |
| 1768 | 1768 | if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
|
@@ -1780,18 +1780,18 @@ discard block |
||
| 1780 | 1780 | // |
| 1781 | 1781 | $page_setting = (int)get_option($value['id']); |
| 1782 | 1782 | |
| 1783 | - $args = array('name' => $value['id'],
|
|
| 1784 | - 'id' => $value['id'], |
|
| 1785 | - 'sort_column' => 'menu_order', |
|
| 1786 | - 'sort_order' => 'ASC', |
|
| 1787 | - 'show_option_none' => ' ', |
|
| 1788 | - 'class' => $value['class'], |
|
| 1789 | - 'echo' => false, |
|
| 1790 | - 'selected' => $page_setting); |
|
| 1783 | + $args = array('name' => $value['id'],
|
|
| 1784 | + 'id' => $value['id'], |
|
| 1785 | + 'sort_column' => 'menu_order', |
|
| 1786 | + 'sort_order' => 'ASC', |
|
| 1787 | + 'show_option_none' => ' ', |
|
| 1788 | + 'class' => $value['class'], |
|
| 1789 | + 'echo' => false, |
|
| 1790 | + 'selected' => $page_setting); |
|
| 1791 | 1791 | |
| 1792 | - if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
| 1792 | + if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
| 1793 | 1793 | |
| 1794 | - ?> |
|
| 1794 | + ?> |
|
| 1795 | 1795 | <tr valign="top" class="single_select_page"> |
| 1796 | 1796 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1797 | 1797 | <td class="forminp"> |
@@ -1802,17 +1802,17 @@ discard block |
||
| 1802 | 1802 | if ($switch_lang) {
|
| 1803 | 1803 | $sitepress->switch_lang($switch_lang, true); |
| 1804 | 1804 | } |
| 1805 | - break; |
|
| 1806 | - case 'single_select_country' : |
|
| 1807 | - $country_setting = (string)get_option($value['id']); |
|
| 1808 | - if (strstr($country_setting, ':')) : |
|
| 1809 | - $country = current(explode(':', $country_setting));
|
|
| 1810 | - $state = end(explode(':', $country_setting));
|
|
| 1811 | - else : |
|
| 1812 | - $country = $country_setting; |
|
| 1813 | - $state = '*'; |
|
| 1814 | - endif; |
|
| 1815 | - ?> |
|
| 1805 | + break; |
|
| 1806 | + case 'single_select_country' : |
|
| 1807 | + $country_setting = (string)get_option($value['id']); |
|
| 1808 | + if (strstr($country_setting, ':')) : |
|
| 1809 | + $country = current(explode(':', $country_setting));
|
|
| 1810 | + $state = end(explode(':', $country_setting));
|
|
| 1811 | + else : |
|
| 1812 | + $country = $country_setting; |
|
| 1813 | + $state = '*'; |
|
| 1814 | + endif; |
|
| 1815 | + ?> |
|
| 1816 | 1816 | <tr valign="top"> |
| 1817 | 1817 | <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th> |
| 1818 | 1818 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -1823,12 +1823,12 @@ discard block |
||
| 1823 | 1823 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1824 | 1824 | </td> |
| 1825 | 1825 | </tr><?php |
| 1826 | - break; |
|
| 1827 | - case 'multi_select_countries' : |
|
| 1828 | - $countries = $geodirectory->countries->countries; |
|
| 1829 | - asort($countries); |
|
| 1830 | - $selections = (array)get_option($value['id']); |
|
| 1831 | - ?> |
|
| 1826 | + break; |
|
| 1827 | + case 'multi_select_countries' : |
|
| 1828 | + $countries = $geodirectory->countries->countries; |
|
| 1829 | + asort($countries); |
|
| 1830 | + $selections = (array)get_option($value['id']); |
|
| 1831 | + ?> |
|
| 1832 | 1832 | <tr valign="top"> |
| 1833 | 1833 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1834 | 1834 | <td class="forminp"> |
@@ -1836,22 +1836,22 @@ discard block |
||
| 1836 | 1836 | data-placeholder="<?php _e('Choose countries…', 'geodirectory'); ?>"
|
| 1837 | 1837 | title="Country" class="chosen_select"> |
| 1838 | 1838 | <?php |
| 1839 | - if ($countries) foreach ($countries as $key => $val) : |
|
| 1840 | - echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 1841 | - endforeach; |
|
| 1842 | - ?> |
|
| 1839 | + if ($countries) foreach ($countries as $key => $val) : |
|
| 1840 | + echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 1841 | + endforeach; |
|
| 1842 | + ?> |
|
| 1843 | 1843 | </select> |
| 1844 | 1844 | </td> |
| 1845 | 1845 | </tr> |
| 1846 | 1846 | |
| 1847 | 1847 | <?php |
| 1848 | 1848 | |
| 1849 | - break; |
|
| 1849 | + break; |
|
| 1850 | 1850 | |
| 1851 | - case 'google_analytics' : |
|
| 1852 | - $selections = (array)get_option($value['id']); |
|
| 1853 | - if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
|
|
| 1854 | - ?> |
|
| 1851 | + case 'google_analytics' : |
|
| 1852 | + $selections = (array)get_option($value['id']); |
|
| 1853 | + if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
|
|
| 1854 | + ?> |
|
| 1855 | 1855 | <tr valign="top"> |
| 1856 | 1856 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1857 | 1857 | <td class="forminp"> |
@@ -1859,19 +1859,19 @@ discard block |
||
| 1859 | 1859 | |
| 1860 | 1860 | <?php |
| 1861 | 1861 | |
| 1862 | - $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
| 1863 | - $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
| 1864 | - $state = "&state=123";//any string |
|
| 1865 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 1866 | - $response_type = "&response_type=code"; |
|
| 1867 | - $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 1868 | - $access_type = "&access_type=offline"; |
|
| 1869 | - $approval_prompt = "&approval_prompt=force"; |
|
| 1862 | + $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
| 1863 | + $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
| 1864 | + $state = "&state=123";//any string |
|
| 1865 | + $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 1866 | + $response_type = "&response_type=code"; |
|
| 1867 | + $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 1868 | + $access_type = "&access_type=offline"; |
|
| 1869 | + $approval_prompt = "&approval_prompt=force"; |
|
| 1870 | 1870 | |
| 1871 | - $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
| 1871 | + $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
| 1872 | 1872 | |
| 1873 | 1873 | |
| 1874 | - ?> |
|
| 1874 | + ?> |
|
| 1875 | 1875 | <script> |
| 1876 | 1876 | function gd_ga_popup() {
|
| 1877 | 1877 | var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
|
@@ -1886,47 +1886,47 @@ discard block |
||
| 1886 | 1886 | </script> |
| 1887 | 1887 | |
| 1888 | 1888 | <?php |
| 1889 | - if (get_option('gd_ga_refresh_token')) {
|
|
| 1890 | - ?> |
|
| 1889 | + if (get_option('gd_ga_refresh_token')) {
|
|
| 1890 | + ?> |
|
| 1891 | 1891 | <span class="button-primary" |
| 1892 | 1892 | onclick="gd_ga_popup();"><?php _e('Re-authorize', 'geodirectory'); ?></span>
|
| 1893 | 1893 | <span |
| 1894 | 1894 | style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
|
| 1895 | 1895 | <?php |
| 1896 | - } else {
|
|
| 1897 | - ?> |
|
| 1896 | + } else {
|
|
| 1897 | + ?> |
|
| 1898 | 1898 | <span class="button-primary" |
| 1899 | 1899 | onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
|
| 1900 | 1900 | <?php |
| 1901 | - } |
|
| 1902 | - ?> |
|
| 1901 | + } |
|
| 1902 | + ?> |
|
| 1903 | 1903 | </td> |
| 1904 | 1904 | </tr> |
| 1905 | 1905 | |
| 1906 | 1906 | <?php |
| 1907 | - } |
|
| 1907 | + } |
|
| 1908 | 1908 | |
| 1909 | - break; |
|
| 1909 | + break; |
|
| 1910 | 1910 | |
| 1911 | - case 'field_seperator' : |
|
| 1911 | + case 'field_seperator' : |
|
| 1912 | 1912 | |
| 1913 | - ?> |
|
| 1913 | + ?> |
|
| 1914 | 1914 | <tr valign="top"> |
| 1915 | 1915 | <td colspan="2" class="forminp geodir_line_seperator"></td> |
| 1916 | 1916 | </tr> |
| 1917 | 1917 | <?php |
| 1918 | 1918 | |
| 1919 | - break; |
|
| 1919 | + break; |
|
| 1920 | 1920 | |
| 1921 | - endswitch; |
|
| 1921 | + endswitch; |
|
| 1922 | 1922 | |
| 1923 | - endforeach; |
|
| 1923 | + endforeach; |
|
| 1924 | 1924 | |
| 1925 | - if ($first_title === false) {
|
|
| 1926 | - echo "</div>"; |
|
| 1927 | - } |
|
| 1925 | + if ($first_title === false) {
|
|
| 1926 | + echo "</div>"; |
|
| 1927 | + } |
|
| 1928 | 1928 | |
| 1929 | - ?> |
|
| 1929 | + ?> |
|
| 1930 | 1930 | |
| 1931 | 1931 | <script type="text/javascript"> |
| 1932 | 1932 | |
@@ -1986,33 +1986,33 @@ discard block |
||
| 1986 | 1986 | */ |
| 1987 | 1987 | function geodir_post_info_setting() |
| 1988 | 1988 | {
|
| 1989 | - global $post, $post_id; |
|
| 1990 | - |
|
| 1991 | - $post_type = get_post_type(); |
|
| 1992 | - |
|
| 1993 | - $package_info = array(); |
|
| 1994 | - |
|
| 1995 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1996 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
| 1997 | - echo '<div id="geodir_wrapper">'; |
|
| 1998 | - /** |
|
| 1999 | - * Called before the GD custom fields are output in the wp-admin area. |
|
| 2000 | - * |
|
| 2001 | - * @since 1.0.0 |
|
| 2002 | - * @see 'geodir_after_default_field_in_meta_box' |
|
| 2003 | - */ |
|
| 2004 | - do_action('geodir_before_default_field_in_meta_box');
|
|
| 2005 | - //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
| 2006 | - // to display all fields in one information box |
|
| 2007 | - geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
| 2008 | - /** |
|
| 2009 | - * Called after the GD custom fields are output in the wp-admin area. |
|
| 2010 | - * |
|
| 2011 | - * @since 1.0.0 |
|
| 2012 | - * @see 'geodir_before_default_field_in_meta_box' |
|
| 2013 | - */ |
|
| 2014 | - do_action('geodir_after_default_field_in_meta_box');
|
|
| 2015 | - echo '</div>'; |
|
| 1989 | + global $post, $post_id; |
|
| 1990 | + |
|
| 1991 | + $post_type = get_post_type(); |
|
| 1992 | + |
|
| 1993 | + $package_info = array(); |
|
| 1994 | + |
|
| 1995 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1996 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
| 1997 | + echo '<div id="geodir_wrapper">'; |
|
| 1998 | + /** |
|
| 1999 | + * Called before the GD custom fields are output in the wp-admin area. |
|
| 2000 | + * |
|
| 2001 | + * @since 1.0.0 |
|
| 2002 | + * @see 'geodir_after_default_field_in_meta_box' |
|
| 2003 | + */ |
|
| 2004 | + do_action('geodir_before_default_field_in_meta_box');
|
|
| 2005 | + //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
| 2006 | + // to display all fields in one information box |
|
| 2007 | + geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
| 2008 | + /** |
|
| 2009 | + * Called after the GD custom fields are output in the wp-admin area. |
|
| 2010 | + * |
|
| 2011 | + * @since 1.0.0 |
|
| 2012 | + * @see 'geodir_before_default_field_in_meta_box' |
|
| 2013 | + */ |
|
| 2014 | + do_action('geodir_after_default_field_in_meta_box');
|
|
| 2015 | + echo '</div>'; |
|
| 2016 | 2016 | } |
| 2017 | 2017 | |
| 2018 | 2018 | /** |
@@ -2025,18 +2025,18 @@ discard block |
||
| 2025 | 2025 | */ |
| 2026 | 2026 | function geodir_post_addinfo_setting() |
| 2027 | 2027 | {
|
| 2028 | - global $post, $post_id; |
|
| 2028 | + global $post, $post_id; |
|
| 2029 | 2029 | |
| 2030 | - $post_type = get_post_type(); |
|
| 2030 | + $post_type = get_post_type(); |
|
| 2031 | 2031 | |
| 2032 | - $package_info = array(); |
|
| 2032 | + $package_info = array(); |
|
| 2033 | 2033 | |
| 2034 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 2034 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 2035 | 2035 | |
| 2036 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
| 2037 | - echo '<div id="geodir_wrapper">'; |
|
| 2038 | - geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
| 2039 | - echo '</div>'; |
|
| 2036 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
| 2037 | + echo '<div id="geodir_wrapper">'; |
|
| 2038 | + geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
| 2039 | + echo '</div>'; |
|
| 2040 | 2040 | |
| 2041 | 2041 | } |
| 2042 | 2042 | |
@@ -2050,60 +2050,60 @@ discard block |
||
| 2050 | 2050 | */ |
| 2051 | 2051 | function geodir_post_attachments() |
| 2052 | 2052 | {
|
| 2053 | - global $post, $post_id; |
|
| 2053 | + global $post, $post_id; |
|
| 2054 | 2054 | |
| 2055 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
| 2055 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
| 2056 | 2056 | |
| 2057 | - if (geodir_get_featured_image($post_id, 'thumbnail')) {
|
|
| 2058 | - echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
|
|
| 2059 | - geodir_show_featured_image($post_id, 'thumbnail'); |
|
| 2060 | - } |
|
| 2057 | + if (geodir_get_featured_image($post_id, 'thumbnail')) {
|
|
| 2058 | + echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
|
|
| 2059 | + geodir_show_featured_image($post_id, 'thumbnail'); |
|
| 2060 | + } |
|
| 2061 | 2061 | |
| 2062 | - $image_limit = 0; |
|
| 2062 | + $image_limit = 0; |
|
| 2063 | 2063 | |
| 2064 | - ?> |
|
| 2064 | + ?> |
|
| 2065 | 2065 | |
| 2066 | 2066 | |
| 2067 | 2067 | <h5 class="form_title"> |
| 2068 | 2068 | <?php if ($image_limit != 0 && $image_limit == 1) {
|
| 2069 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 2070 | - } ?> |
|
| 2069 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 2070 | + } ?> |
|
| 2071 | 2071 | <?php if ($image_limit != 0 && $image_limit > 1) {
|
| 2072 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 2073 | - } ?> |
|
| 2072 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 2073 | + } ?> |
|
| 2074 | 2074 | <?php if ($image_limit == 0) {
|
| 2075 | - echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 2076 | - } ?> |
|
| 2075 | + echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 2076 | + } ?> |
|
| 2077 | 2077 | </h5> |
| 2078 | 2078 | |
| 2079 | 2079 | |
| 2080 | 2080 | <?php |
| 2081 | 2081 | |
| 2082 | - $curImages = geodir_get_images($post_id); |
|
| 2083 | - $place_img_array = array(); |
|
| 2082 | + $curImages = geodir_get_images($post_id); |
|
| 2083 | + $place_img_array = array(); |
|
| 2084 | 2084 | |
| 2085 | - if (!empty($curImages)): |
|
| 2086 | - foreach ($curImages as $p_img): |
|
| 2087 | - $place_img_array[] = $p_img->src; |
|
| 2088 | - endforeach; |
|
| 2089 | - endif; |
|
| 2085 | + if (!empty($curImages)): |
|
| 2086 | + foreach ($curImages as $p_img): |
|
| 2087 | + $place_img_array[] = $p_img->src; |
|
| 2088 | + endforeach; |
|
| 2089 | + endif; |
|
| 2090 | 2090 | |
| 2091 | - if (!empty($place_img_array)) |
|
| 2092 | - $curImages = implode(',', $place_img_array);
|
|
| 2091 | + if (!empty($place_img_array)) |
|
| 2092 | + $curImages = implode(',', $place_img_array);
|
|
| 2093 | 2093 | |
| 2094 | 2094 | |
| 2095 | - // adjust values here |
|
| 2096 | - $id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls |
|
| 2095 | + // adjust values here |
|
| 2096 | + $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 |
|
| 2097 | 2097 | |
| 2098 | - $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
| 2098 | + $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
| 2099 | 2099 | |
| 2100 | - $multiple = true; // allow multiple files upload |
|
| 2100 | + $multiple = true; // allow multiple files upload |
|
| 2101 | 2101 | |
| 2102 | - $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 2102 | + $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 2103 | 2103 | |
| 2104 | - $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 2104 | + $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 2105 | 2105 | |
| 2106 | - ?> |
|
| 2106 | + ?> |
|
| 2107 | 2107 | |
| 2108 | 2108 | <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;"> |
| 2109 | 2109 | <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/> |
@@ -2145,13 +2145,13 @@ discard block |
||
| 2145 | 2145 | */ |
| 2146 | 2146 | function geodir_action_post_updated($post_ID, $post_after, $post_before) |
| 2147 | 2147 | {
|
| 2148 | - $post_type = get_post_type($post_ID); |
|
| 2148 | + $post_type = get_post_type($post_ID); |
|
| 2149 | 2149 | |
| 2150 | - if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 2151 | - 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) {
|
|
| 2152 | - geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
| 2153 | - } |
|
| 2154 | - } |
|
| 2150 | + if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 2151 | + 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) {
|
|
| 2152 | + geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
| 2153 | + } |
|
| 2154 | + } |
|
| 2155 | 2155 | } |
| 2156 | 2156 | |
| 2157 | 2157 | /** |
@@ -2166,39 +2166,39 @@ discard block |
||
| 2166 | 2166 | */ |
| 2167 | 2167 | function geodir_notification_add_bcc_option($settings) |
| 2168 | 2168 | {
|
| 2169 | - if (!empty($settings)) {
|
|
| 2170 | - $new_settings = array(); |
|
| 2171 | - foreach ($settings as $setting) {
|
|
| 2172 | - if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
|
|
| 2173 | - $geodir_bcc_listing_published_yes = array( |
|
| 2174 | - 'name' => __('Listing published', 'geodirectory'),
|
|
| 2175 | - 'desc' => __('Yes', 'geodirectory'),
|
|
| 2176 | - 'id' => 'geodir_bcc_listing_published', |
|
| 2177 | - 'std' => 'yes', |
|
| 2178 | - 'type' => 'radio', |
|
| 2179 | - 'value' => '1', |
|
| 2180 | - 'radiogroup' => 'start' |
|
| 2181 | - ); |
|
| 2182 | - |
|
| 2183 | - $geodir_bcc_listing_published_no = array( |
|
| 2184 | - 'name' => __('Listing published', 'geodirectory'),
|
|
| 2185 | - 'desc' => __('No', 'geodirectory'),
|
|
| 2186 | - 'id' => 'geodir_bcc_listing_published', |
|
| 2187 | - 'std' => 'yes', |
|
| 2188 | - 'type' => 'radio', |
|
| 2189 | - 'value' => '0', |
|
| 2190 | - 'radiogroup' => 'end' |
|
| 2191 | - ); |
|
| 2192 | - |
|
| 2193 | - $new_settings[] = $geodir_bcc_listing_published_yes; |
|
| 2194 | - $new_settings[] = $geodir_bcc_listing_published_no; |
|
| 2195 | - } |
|
| 2196 | - $new_settings[] = $setting; |
|
| 2197 | - } |
|
| 2198 | - $settings = $new_settings; |
|
| 2199 | - } |
|
| 2169 | + if (!empty($settings)) {
|
|
| 2170 | + $new_settings = array(); |
|
| 2171 | + foreach ($settings as $setting) {
|
|
| 2172 | + if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
|
|
| 2173 | + $geodir_bcc_listing_published_yes = array( |
|
| 2174 | + 'name' => __('Listing published', 'geodirectory'),
|
|
| 2175 | + 'desc' => __('Yes', 'geodirectory'),
|
|
| 2176 | + 'id' => 'geodir_bcc_listing_published', |
|
| 2177 | + 'std' => 'yes', |
|
| 2178 | + 'type' => 'radio', |
|
| 2179 | + 'value' => '1', |
|
| 2180 | + 'radiogroup' => 'start' |
|
| 2181 | + ); |
|
| 2182 | + |
|
| 2183 | + $geodir_bcc_listing_published_no = array( |
|
| 2184 | + 'name' => __('Listing published', 'geodirectory'),
|
|
| 2185 | + 'desc' => __('No', 'geodirectory'),
|
|
| 2186 | + 'id' => 'geodir_bcc_listing_published', |
|
| 2187 | + 'std' => 'yes', |
|
| 2188 | + 'type' => 'radio', |
|
| 2189 | + 'value' => '0', |
|
| 2190 | + 'radiogroup' => 'end' |
|
| 2191 | + ); |
|
| 2192 | + |
|
| 2193 | + $new_settings[] = $geodir_bcc_listing_published_yes; |
|
| 2194 | + $new_settings[] = $geodir_bcc_listing_published_no; |
|
| 2195 | + } |
|
| 2196 | + $new_settings[] = $setting; |
|
| 2197 | + } |
|
| 2198 | + $settings = $new_settings; |
|
| 2199 | + } |
|
| 2200 | 2200 | |
| 2201 | - return $settings; |
|
| 2201 | + return $settings; |
|
| 2202 | 2202 | } |
| 2203 | 2203 | |
| 2204 | 2204 | |
@@ -2213,19 +2213,19 @@ discard block |
||
| 2213 | 2213 | */ |
| 2214 | 2214 | function get_gd_theme_compat_callback() |
| 2215 | 2215 | {
|
| 2216 | - global $wpdb; |
|
| 2217 | - $themes = get_option('gd_theme_compats');
|
|
| 2218 | - |
|
| 2219 | - if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
|
|
| 2220 | - if (isset($_POST['export'])) {
|
|
| 2221 | - echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
| 2222 | - } else {
|
|
| 2223 | - echo json_encode($themes[$_POST['theme']]); |
|
| 2224 | - } |
|
| 2216 | + global $wpdb; |
|
| 2217 | + $themes = get_option('gd_theme_compats');
|
|
| 2225 | 2218 | |
| 2226 | - } |
|
| 2219 | + if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
|
|
| 2220 | + if (isset($_POST['export'])) {
|
|
| 2221 | + echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
| 2222 | + } else {
|
|
| 2223 | + echo json_encode($themes[$_POST['theme']]); |
|
| 2224 | + } |
|
| 2225 | + |
|
| 2226 | + } |
|
| 2227 | 2227 | |
| 2228 | - die(); |
|
| 2228 | + die(); |
|
| 2229 | 2229 | } |
| 2230 | 2230 | |
| 2231 | 2231 | add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback');
|
@@ -2239,20 +2239,20 @@ discard block |
||
| 2239 | 2239 | */ |
| 2240 | 2240 | function get_gd_theme_compat_import_callback() |
| 2241 | 2241 | {
|
| 2242 | - global $wpdb; |
|
| 2243 | - $themes = get_option('gd_theme_compats');
|
|
| 2244 | - if (isset($_POST['theme']) && !empty($_POST['theme'])) {
|
|
| 2245 | - $json = json_decode(stripslashes($_POST['theme']), true); |
|
| 2246 | - if (!empty($json) && is_array($json)) {
|
|
| 2247 | - $key = sanitize_text_field(key($json)); |
|
| 2248 | - $themes[$key] = $json[$key]; |
|
| 2249 | - update_option('gd_theme_compats', $themes);
|
|
| 2250 | - echo $key; |
|
| 2251 | - die(); |
|
| 2252 | - } |
|
| 2253 | - } |
|
| 2254 | - echo '0'; |
|
| 2255 | - die(); |
|
| 2242 | + global $wpdb; |
|
| 2243 | + $themes = get_option('gd_theme_compats');
|
|
| 2244 | + if (isset($_POST['theme']) && !empty($_POST['theme'])) {
|
|
| 2245 | + $json = json_decode(stripslashes($_POST['theme']), true); |
|
| 2246 | + if (!empty($json) && is_array($json)) {
|
|
| 2247 | + $key = sanitize_text_field(key($json)); |
|
| 2248 | + $themes[$key] = $json[$key]; |
|
| 2249 | + update_option('gd_theme_compats', $themes);
|
|
| 2250 | + echo $key; |
|
| 2251 | + die(); |
|
| 2252 | + } |
|
| 2253 | + } |
|
| 2254 | + echo '0'; |
|
| 2255 | + die(); |
|
| 2256 | 2256 | } |
| 2257 | 2257 | |
| 2258 | 2258 | |
@@ -2265,39 +2265,39 @@ discard block |
||
| 2265 | 2265 | */ |
| 2266 | 2266 | function gd_set_theme_compat() |
| 2267 | 2267 | {
|
| 2268 | - global $wpdb; |
|
| 2269 | - $theme = wp_get_theme(); |
|
| 2268 | + global $wpdb; |
|
| 2269 | + $theme = wp_get_theme(); |
|
| 2270 | 2270 | |
| 2271 | - if ($theme->parent()) {
|
|
| 2272 | - $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
|
|
| 2273 | - } else {
|
|
| 2274 | - $theme_name = str_replace(" ", "_", $theme->get('Name'));
|
|
| 2275 | - } |
|
| 2271 | + if ($theme->parent()) {
|
|
| 2272 | + $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
|
|
| 2273 | + } else {
|
|
| 2274 | + $theme_name = str_replace(" ", "_", $theme->get('Name'));
|
|
| 2275 | + } |
|
| 2276 | 2276 | |
| 2277 | - $theme_compats = get_option('gd_theme_compats');
|
|
| 2278 | - $current_compat = get_option('gd_theme_compat');
|
|
| 2279 | - $current_compat = str_replace("_custom", "", $current_compat);
|
|
| 2277 | + $theme_compats = get_option('gd_theme_compats');
|
|
| 2278 | + $current_compat = get_option('gd_theme_compat');
|
|
| 2279 | + $current_compat = str_replace("_custom", "", $current_compat);
|
|
| 2280 | 2280 | |
| 2281 | - if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
|
|
| 2282 | - return; |
|
| 2283 | - }// if already running correct compat then bail |
|
| 2281 | + if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) {
|
|
| 2282 | + return; |
|
| 2283 | + }// if already running correct compat then bail |
|
| 2284 | 2284 | |
| 2285 | - if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
|
|
| 2286 | - update_option('gd_theme_compat', $theme_name);
|
|
| 2287 | - update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
|
|
| 2285 | + if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
|
|
| 2286 | + update_option('gd_theme_compat', $theme_name);
|
|
| 2287 | + update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
|
|
| 2288 | 2288 | |
| 2289 | - // if there are default options to set then set them |
|
| 2290 | - if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
|
|
| 2289 | + // if there are default options to set then set them |
|
| 2290 | + if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
|
|
| 2291 | 2291 | |
| 2292 | - foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
|
|
| 2293 | - update_option($key, $val); |
|
| 2294 | - } |
|
| 2295 | - } |
|
| 2292 | + foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
|
|
| 2293 | + update_option($key, $val); |
|
| 2294 | + } |
|
| 2295 | + } |
|
| 2296 | 2296 | |
| 2297 | - } else {
|
|
| 2298 | - update_option('gd_theme_compat', '');
|
|
| 2299 | - update_option('theme_compatibility_setting', '');
|
|
| 2300 | - } |
|
| 2297 | + } else {
|
|
| 2298 | + update_option('gd_theme_compat', '');
|
|
| 2299 | + update_option('theme_compatibility_setting', '');
|
|
| 2300 | + } |
|
| 2301 | 2301 | |
| 2302 | 2302 | |
| 2303 | 2303 | } |
@@ -2312,9 +2312,9 @@ discard block |
||
| 2312 | 2312 | */ |
| 2313 | 2313 | function gd_check_avada_compat() |
| 2314 | 2314 | {
|
| 2315 | - if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
|
|
| 2316 | - add_action('admin_notices', 'gd_avada_compat_warning');
|
|
| 2317 | - } |
|
| 2315 | + if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
|
|
| 2316 | + add_action('admin_notices', 'gd_avada_compat_warning');
|
|
| 2317 | + } |
|
| 2318 | 2318 | } |
| 2319 | 2319 | |
| 2320 | 2320 | |
@@ -2327,22 +2327,22 @@ discard block |
||
| 2327 | 2327 | function gd_avada_compat_warning() |
| 2328 | 2328 | {
|
| 2329 | 2329 | |
| 2330 | - /* |
|
| 2330 | + /* |
|
| 2331 | 2331 | $msg_type = error |
| 2332 | 2332 | $msg_type = updated fade |
| 2333 | 2333 | $msg_type = update-nag |
| 2334 | 2334 | */ |
| 2335 | 2335 | |
| 2336 | - $plugin = 'avada-nag'; |
|
| 2337 | - $timestamp = 'avada-nag1234'; |
|
| 2338 | - $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');
|
|
| 2339 | - echo '<div id="' . $timestamp . '" class="error">'; |
|
| 2340 | - echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
| 2341 | - echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 2342 | - echo "<p>$message</p>"; |
|
| 2343 | - echo "</div>"; |
|
| 2336 | + $plugin = 'avada-nag'; |
|
| 2337 | + $timestamp = 'avada-nag1234'; |
|
| 2338 | + $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');
|
|
| 2339 | + echo '<div id="' . $timestamp . '" class="error">'; |
|
| 2340 | + echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
| 2341 | + echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 2342 | + echo "<p>$message</p>"; |
|
| 2343 | + echo "</div>"; |
|
| 2344 | 2344 | |
| 2345 | - ?> |
|
| 2345 | + ?> |
|
| 2346 | 2346 | <script> |
| 2347 | 2347 | function gdRemoveANotification($plugin, $timestamp) {
|
| 2348 | 2348 | |
@@ -2410,10 +2410,10 @@ discard block |
||
| 2410 | 2410 | */ |
| 2411 | 2411 | function geodir_avada_remove_notification() |
| 2412 | 2412 | {
|
| 2413 | - update_option('avada_nag', TRUE);
|
|
| 2413 | + update_option('avada_nag', TRUE);
|
|
| 2414 | 2414 | |
| 2415 | - // Always die in functions echoing ajax content |
|
| 2416 | - die(); |
|
| 2415 | + // Always die in functions echoing ajax content |
|
| 2416 | + die(); |
|
| 2417 | 2417 | } |
| 2418 | 2418 | |
| 2419 | 2419 | |
@@ -2435,9 +2435,9 @@ discard block |
||
| 2435 | 2435 | global $post, $typenow, $current_screen; |
| 2436 | 2436 | |
| 2437 | 2437 | $post_type = NULL; |
| 2438 | - if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 2438 | + if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 2439 | 2439 | $post_type = get_post_type($_REQUEST['post']); |
| 2440 | - elseif ($post && isset($post->post_type)) |
|
| 2440 | + elseif ($post && isset($post->post_type)) |
|
| 2441 | 2441 | $post_type = $post->post_type; |
| 2442 | 2442 | elseif ($typenow) |
| 2443 | 2443 | $post_type = $typenow; |
@@ -2472,7 +2472,7 @@ discard block |
||
| 2472 | 2472 | // Don't allow same slug url for listing and location |
| 2473 | 2473 | if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
|
| 2474 | 2474 | $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
|
| 2475 | - wp_redirect($redirect_url); |
|
| 2475 | + wp_redirect($redirect_url); |
|
| 2476 | 2476 | exit; |
| 2477 | 2477 | } |
| 2478 | 2478 | |
@@ -2502,10 +2502,10 @@ discard block |
||
| 2502 | 2502 | * @package GeoDirectory |
| 2503 | 2503 | */ |
| 2504 | 2504 | function geodir_hide_admin_preview_button() {
|
| 2505 | - global $post_type; |
|
| 2506 | - $post_types = geodir_get_posttypes(); |
|
| 2507 | - if(in_array($post_type, $post_types)) |
|
| 2508 | - echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
|
| 2505 | + global $post_type; |
|
| 2506 | + $post_types = geodir_get_posttypes(); |
|
| 2507 | + if(in_array($post_type, $post_types)) |
|
| 2508 | + echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
|
| 2509 | 2509 | } |
| 2510 | 2510 | add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' ); |
| 2511 | 2511 | add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' ); |
@@ -2520,7 +2520,7 @@ discard block |
||
| 2520 | 2520 | */ |
| 2521 | 2521 | function geodir_import_export_tab( $tabs ) {
|
| 2522 | 2522 | $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
| 2523 | - return $tabs; |
|
| 2523 | + return $tabs; |
|
| 2524 | 2524 | } |
| 2525 | 2525 | |
| 2526 | 2526 | /** |
@@ -2535,26 +2535,26 @@ discard block |
||
| 2535 | 2535 | function geodir_import_export_page() {
|
| 2536 | 2536 | $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
| 2537 | 2537 | $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
| 2538 | - /** |
|
| 2539 | - * Filter sample category data csv file url. |
|
| 2540 | - * |
|
| 2541 | - * @since 1.0.0 |
|
| 2542 | - * @package GeoDirectory |
|
| 2543 | - * |
|
| 2544 | - * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
| 2545 | - */ |
|
| 2538 | + /** |
|
| 2539 | + * Filter sample category data csv file url. |
|
| 2540 | + * |
|
| 2541 | + * @since 1.0.0 |
|
| 2542 | + * @package GeoDirectory |
|
| 2543 | + * |
|
| 2544 | + * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
| 2545 | + */ |
|
| 2546 | 2546 | $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
| 2547 | 2547 | |
| 2548 | 2548 | $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
| 2549 | - /** |
|
| 2550 | - * Filter sample post data csv file url. |
|
| 2551 | - * |
|
| 2552 | - * @since 1.0.0 |
|
| 2553 | - * @package GeoDirectory |
|
| 2554 | - * |
|
| 2555 | - * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
| 2556 | - */ |
|
| 2557 | - $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 2549 | + /** |
|
| 2550 | + * Filter sample post data csv file url. |
|
| 2551 | + * |
|
| 2552 | + * @since 1.0.0 |
|
| 2553 | + * @package GeoDirectory |
|
| 2554 | + * |
|
| 2555 | + * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
| 2556 | + */ |
|
| 2557 | + $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 2558 | 2558 | |
| 2559 | 2559 | $gd_posttypes = geodir_get_posttypes( 'array' ); |
| 2560 | 2560 | |
@@ -2577,14 +2577,14 @@ discard block |
||
| 2577 | 2577 | $gd_chunksize_options[100000] = 100000; |
| 2578 | 2578 | |
| 2579 | 2579 | /** |
| 2580 | - * Filter max entries per export csv file. |
|
| 2581 | - * |
|
| 2582 | - * @since 1.5.6 |
|
| 2583 | - * @package GeoDirectory |
|
| 2584 | - * |
|
| 2585 | - * @param string $gd_chunksize_options Entries options. |
|
| 2586 | - */ |
|
| 2587 | - $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 2580 | + * Filter max entries per export csv file. |
|
| 2581 | + * |
|
| 2582 | + * @since 1.5.6 |
|
| 2583 | + * @package GeoDirectory |
|
| 2584 | + * |
|
| 2585 | + * @param string $gd_chunksize_options Entries options. |
|
| 2586 | + */ |
|
| 2587 | + $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 2588 | 2588 | |
| 2589 | 2589 | $gd_chunksize_option = ''; |
| 2590 | 2590 | foreach ($gd_chunksize_options as $value => $title) {
|
@@ -2600,12 +2600,12 @@ discard block |
||
| 2600 | 2600 | <div class="gd-content-heading"> |
| 2601 | 2601 | |
| 2602 | 2602 | <?php |
| 2603 | - ini_set('max_execution_time', 999999);
|
|
| 2604 | - $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 2605 | - ini_restore('max_execution_time');
|
|
| 2603 | + ini_set('max_execution_time', 999999);
|
|
| 2604 | + $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 2605 | + ini_restore('max_execution_time');
|
|
| 2606 | 2606 | |
| 2607 | - if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 2608 | - ?> |
|
| 2607 | + if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 2608 | + ?> |
|
| 2609 | 2609 | <div id="gd_ie_reqs" class="metabox-holder"> |
| 2610 | 2610 | <div class="meta-box-sortables ui-sortable"> |
| 2611 | 2611 | <div class="postbox"> |
@@ -2774,7 +2774,7 @@ discard block |
||
| 2774 | 2774 | * Called just after the sample CSV download link. |
| 2775 | 2775 | * |
| 2776 | 2776 | * @since 1.0.0 |
| 2777 | - * @package GeoDirectory |
|
| 2777 | + * @package GeoDirectory |
|
| 2778 | 2778 | */ |
| 2779 | 2779 | do_action('geodir_sample_cats_csv_download_link');
|
| 2780 | 2780 | ?> |
@@ -2859,11 +2859,11 @@ discard block |
||
| 2859 | 2859 | * |
| 2860 | 2860 | * Called after the last setting on the GD > Import & Export page. |
| 2861 | 2861 | * @since 1.4.6 |
| 2862 | - * @package GeoDirectory |
|
| 2862 | + * @package GeoDirectory |
|
| 2863 | 2863 | * |
| 2864 | 2864 | * @param array $gd_posttypes GD post types. |
| 2865 | - * @param array $gd_chunksize_options File chunk size options. |
|
| 2866 | - * @param string $nonce Wordpress security token for GD import & export. |
|
| 2865 | + * @param array $gd_chunksize_options File chunk size options. |
|
| 2866 | + * @param string $nonce Wordpress security token for GD import & export. |
|
| 2867 | 2867 | */ |
| 2868 | 2868 | do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
| 2869 | 2869 | ?> |
@@ -3520,44 +3520,44 @@ discard block |
||
| 3520 | 3520 | function geodir_init_filesystem() |
| 3521 | 3521 | {
|
| 3522 | 3522 | |
| 3523 | - if(!function_exists('get_filesystem_method')){
|
|
| 3524 | - require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
| 3525 | - } |
|
| 3526 | - $access_type = get_filesystem_method(); |
|
| 3527 | - if ($access_type === 'direct') {
|
|
| 3528 | - /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
| 3529 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3530 | - |
|
| 3531 | - /* initialize the API */ |
|
| 3532 | - if (!WP_Filesystem($creds)) {
|
|
| 3533 | - /* any problems and we exit */ |
|
| 3534 | - //return '@@@3'; |
|
| 3535 | - return false; |
|
| 3536 | - } |
|
| 3537 | - |
|
| 3538 | - global $wp_filesystem; |
|
| 3539 | - return $wp_filesystem; |
|
| 3540 | - /* do our file manipulations below */ |
|
| 3541 | - } elseif (defined('FTP_USER')) {
|
|
| 3542 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3523 | + if(!function_exists('get_filesystem_method')){
|
|
| 3524 | + require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
| 3525 | + } |
|
| 3526 | + $access_type = get_filesystem_method(); |
|
| 3527 | + if ($access_type === 'direct') {
|
|
| 3528 | + /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
| 3529 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3530 | + |
|
| 3531 | + /* initialize the API */ |
|
| 3532 | + if (!WP_Filesystem($creds)) {
|
|
| 3533 | + /* any problems and we exit */ |
|
| 3534 | + //return '@@@3'; |
|
| 3535 | + return false; |
|
| 3536 | + } |
|
| 3543 | 3537 | |
| 3544 | - /* initialize the API */ |
|
| 3545 | - if (!WP_Filesystem($creds)) {
|
|
| 3546 | - /* any problems and we exit */ |
|
| 3547 | - //return '@@@33'; |
|
| 3548 | - return false; |
|
| 3549 | - } |
|
| 3538 | + global $wp_filesystem; |
|
| 3539 | + return $wp_filesystem; |
|
| 3540 | + /* do our file manipulations below */ |
|
| 3541 | + } elseif (defined('FTP_USER')) {
|
|
| 3542 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3543 | + |
|
| 3544 | + /* initialize the API */ |
|
| 3545 | + if (!WP_Filesystem($creds)) {
|
|
| 3546 | + /* any problems and we exit */ |
|
| 3547 | + //return '@@@33'; |
|
| 3548 | + return false; |
|
| 3549 | + } |
|
| 3550 | 3550 | |
| 3551 | - global $wp_filesystem; |
|
| 3552 | - //return '@@@1'; |
|
| 3553 | - return $wp_filesystem; |
|
| 3551 | + global $wp_filesystem; |
|
| 3552 | + //return '@@@1'; |
|
| 3553 | + return $wp_filesystem; |
|
| 3554 | 3554 | |
| 3555 | - } else {
|
|
| 3556 | - //return '@@@2'; |
|
| 3557 | - /* don't have direct write access. Prompt user with our notice */ |
|
| 3558 | - add_action('admin_notice', 'geodir_filesystem_notice');
|
|
| 3559 | - return false; |
|
| 3560 | - } |
|
| 3555 | + } else {
|
|
| 3556 | + //return '@@@2'; |
|
| 3557 | + /* don't have direct write access. Prompt user with our notice */ |
|
| 3558 | + add_action('admin_notice', 'geodir_filesystem_notice');
|
|
| 3559 | + return false; |
|
| 3560 | + } |
|
| 3561 | 3561 | |
| 3562 | 3562 | } |
| 3563 | 3563 | |
@@ -3575,10 +3575,10 @@ discard block |
||
| 3575 | 3575 | */ |
| 3576 | 3576 | function geodir_filesystem_notice() |
| 3577 | 3577 | { if ( defined( 'DOING_AJAX' ) ){return;}
|
| 3578 | - $access_type = get_filesystem_method(); |
|
| 3579 | - if ($access_type === 'direct') {
|
|
| 3580 | - } elseif (!defined('FTP_USER')) {
|
|
| 3581 | - ?> |
|
| 3578 | + $access_type = get_filesystem_method(); |
|
| 3579 | + if ($access_type === 'direct') {
|
|
| 3580 | + } elseif (!defined('FTP_USER')) {
|
|
| 3581 | + ?> |
|
| 3582 | 3582 | <div class="error"> |
| 3583 | 3583 | <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'); ?>
|
| 3584 | 3584 | <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> |
@@ -3604,1514 +3604,1514 @@ discard block |
||
| 3604 | 3604 | * @return string Json data. |
| 3605 | 3605 | */ |
| 3606 | 3606 | function geodir_ajax_import_export() {
|
| 3607 | - global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 3607 | + global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 3608 | 3608 | |
| 3609 | - error_reporting(0); |
|
| 3609 | + error_reporting(0); |
|
| 3610 | 3610 | |
| 3611 | - // try to set higher limits for import |
|
| 3612 | - $max_input_time = ini_get('max_input_time');
|
|
| 3613 | - $max_execution_time = ini_get('max_execution_time');
|
|
| 3614 | - $memory_limit= ini_get('memory_limit');
|
|
| 3611 | + // try to set higher limits for import |
|
| 3612 | + $max_input_time = ini_get('max_input_time');
|
|
| 3613 | + $max_execution_time = ini_get('max_execution_time');
|
|
| 3614 | + $memory_limit= ini_get('memory_limit');
|
|
| 3615 | 3615 | |
| 3616 | - if(!$max_input_time || $max_input_time<3000){
|
|
| 3617 | - ini_set('max_input_time', 3000);
|
|
| 3618 | - } |
|
| 3616 | + if(!$max_input_time || $max_input_time<3000){
|
|
| 3617 | + ini_set('max_input_time', 3000);
|
|
| 3618 | + } |
|
| 3619 | 3619 | |
| 3620 | - if(!$max_execution_time || $max_execution_time<3000){
|
|
| 3621 | - ini_set('max_execution_time', 3000);
|
|
| 3622 | - } |
|
| 3620 | + if(!$max_execution_time || $max_execution_time<3000){
|
|
| 3621 | + ini_set('max_execution_time', 3000);
|
|
| 3622 | + } |
|
| 3623 | 3623 | |
| 3624 | - if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 3625 | - if(str_replace('M','',$memory_limit)<256){
|
|
| 3626 | - ini_set('memory_limit', '256M');
|
|
| 3627 | - } |
|
| 3628 | - } |
|
| 3624 | + if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 3625 | + if(str_replace('M','',$memory_limit)<256){
|
|
| 3626 | + ini_set('memory_limit', '256M');
|
|
| 3627 | + } |
|
| 3628 | + } |
|
| 3629 | 3629 | |
| 3630 | - $json = array(); |
|
| 3630 | + $json = array(); |
|
| 3631 | 3631 | |
| 3632 | - if ( !current_user_can( 'manage_options' ) ) {
|
|
| 3633 | - wp_send_json( $json ); |
|
| 3634 | - } |
|
| 3632 | + if ( !current_user_can( 'manage_options' ) ) {
|
|
| 3633 | + wp_send_json( $json ); |
|
| 3634 | + } |
|
| 3635 | 3635 | |
| 3636 | - $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 3637 | - $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 3638 | - $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 3636 | + $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 3637 | + $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 3638 | + $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 3639 | 3639 | |
| 3640 | - if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 3641 | - wp_send_json( $json ); |
|
| 3642 | - } |
|
| 3640 | + if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 3641 | + wp_send_json( $json ); |
|
| 3642 | + } |
|
| 3643 | 3643 | |
| 3644 | - $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 3645 | - $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 3646 | - $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 3647 | - $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 3644 | + $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 3645 | + $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 3646 | + $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 3647 | + $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 3648 | 3648 | |
| 3649 | - $wp_filesystem = geodir_init_filesystem(); |
|
| 3650 | - if (!$wp_filesystem) {
|
|
| 3651 | - $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 3652 | - wp_send_json( $json ); |
|
| 3653 | - } |
|
| 3649 | + $wp_filesystem = geodir_init_filesystem(); |
|
| 3650 | + if (!$wp_filesystem) {
|
|
| 3651 | + $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 3652 | + wp_send_json( $json ); |
|
| 3653 | + } |
|
| 3654 | 3654 | |
| 3655 | - if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 3656 | - $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 3657 | - wp_send_json( $json ); |
|
| 3658 | - } |
|
| 3655 | + if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 3656 | + $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 3657 | + wp_send_json( $json ); |
|
| 3658 | + } |
|
| 3659 | 3659 | |
| 3660 | - $csv_file_dir = geodir_path_import_export( false ); |
|
| 3661 | - if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 3662 | - if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 3663 | - $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3664 | - wp_send_json( $json ); |
|
| 3665 | - } |
|
| 3666 | - } |
|
| 3660 | + $csv_file_dir = geodir_path_import_export( false ); |
|
| 3661 | + if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 3662 | + if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 3663 | + $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3664 | + wp_send_json( $json ); |
|
| 3665 | + } |
|
| 3666 | + } |
|
| 3667 | 3667 | |
| 3668 | - $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 3669 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 3670 | - |
|
| 3671 | - switch ( $task ) {
|
|
| 3672 | - case 'export_posts': {
|
|
| 3673 | - // WPML |
|
| 3674 | - $is_wpml = geodir_is_wpml(); |
|
| 3675 | - if ($is_wpml) {
|
|
| 3676 | - global $sitepress; |
|
| 3677 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3668 | + $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 3669 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 3670 | + |
|
| 3671 | + switch ( $task ) {
|
|
| 3672 | + case 'export_posts': {
|
|
| 3673 | + // WPML |
|
| 3674 | + $is_wpml = geodir_is_wpml(); |
|
| 3675 | + if ($is_wpml) {
|
|
| 3676 | + global $sitepress; |
|
| 3677 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3678 | 3678 | |
| 3679 | - $sitepress->switch_lang('all', true);
|
|
| 3680 | - } |
|
| 3681 | - // WPML |
|
| 3682 | - if ( $post_type == 'gd_event' ) {
|
|
| 3683 | - add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 3684 | - } |
|
| 3685 | - $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 3686 | - $posts_count = geodir_get_posts_count( $post_type ); |
|
| 3687 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3688 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3689 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3690 | - $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 3679 | + $sitepress->switch_lang('all', true);
|
|
| 3680 | + } |
|
| 3681 | + // WPML |
|
| 3682 | + if ( $post_type == 'gd_event' ) {
|
|
| 3683 | + add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 3684 | + } |
|
| 3685 | + $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 3686 | + $posts_count = geodir_get_posts_count( $post_type ); |
|
| 3687 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3688 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3689 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3690 | + $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 3691 | 3691 | |
| 3692 | - $chunk_file_paths = array(); |
|
| 3692 | + $chunk_file_paths = array(); |
|
| 3693 | 3693 | |
| 3694 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3695 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3696 | - $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 3697 | - $percentage = min( $percentage, 100 ); |
|
| 3694 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3695 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3696 | + $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 3697 | + $percentage = min( $percentage, 100 ); |
|
| 3698 | 3698 | |
| 3699 | - $json['percentage'] = $percentage; |
|
| 3700 | - // WPML |
|
| 3701 | - if ($is_wpml) {
|
|
| 3702 | - $sitepress->switch_lang($active_lang, true); |
|
| 3703 | - } |
|
| 3704 | - // WPML |
|
| 3705 | - wp_send_json( $json ); |
|
| 3706 | - gd_die(); |
|
| 3707 | - } else {
|
|
| 3708 | - if ( !$posts_count > 0 ) {
|
|
| 3709 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3710 | - } else {
|
|
| 3711 | - $total_posts = $posts_count; |
|
| 3712 | - if ($chunk_per_page > $total_posts) {
|
|
| 3713 | - $chunk_per_page = $total_posts; |
|
| 3714 | - } |
|
| 3715 | - $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 3699 | + $json['percentage'] = $percentage; |
|
| 3700 | + // WPML |
|
| 3701 | + if ($is_wpml) {
|
|
| 3702 | + $sitepress->switch_lang($active_lang, true); |
|
| 3703 | + } |
|
| 3704 | + // WPML |
|
| 3705 | + wp_send_json( $json ); |
|
| 3706 | + gd_die(); |
|
| 3707 | + } else {
|
|
| 3708 | + if ( !$posts_count > 0 ) {
|
|
| 3709 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3710 | + } else {
|
|
| 3711 | + $total_posts = $posts_count; |
|
| 3712 | + if ($chunk_per_page > $total_posts) {
|
|
| 3713 | + $chunk_per_page = $total_posts; |
|
| 3714 | + } |
|
| 3715 | + $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 3716 | 3716 | |
| 3717 | - $j = $chunk_page_no; |
|
| 3718 | - $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 3717 | + $j = $chunk_page_no; |
|
| 3718 | + $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 3719 | 3719 | |
| 3720 | - $per_page = 500; |
|
| 3721 | - if ($per_page > $chunk_per_page) {
|
|
| 3722 | - $per_page = $chunk_per_page; |
|
| 3723 | - } |
|
| 3724 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3720 | + $per_page = 500; |
|
| 3721 | + if ($per_page > $chunk_per_page) {
|
|
| 3722 | + $per_page = $chunk_per_page; |
|
| 3723 | + } |
|
| 3724 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3725 | 3725 | |
| 3726 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3727 | - $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 3726 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3727 | + $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 3728 | 3728 | |
| 3729 | - $clear = $i == 0 ? true : false; |
|
| 3730 | - geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 3731 | - } |
|
| 3729 | + $clear = $i == 0 ? true : false; |
|
| 3730 | + geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 3731 | + } |
|
| 3732 | 3732 | |
| 3733 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3734 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3735 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3736 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3737 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3733 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3734 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3735 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3736 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3737 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3738 | 3738 | |
| 3739 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3740 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3741 | - } |
|
| 3739 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3740 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3741 | + } |
|
| 3742 | 3742 | |
| 3743 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3744 | - $json['total'] = $posts_count; |
|
| 3745 | - $json['files'] = $chunk_file_paths; |
|
| 3746 | - } else {
|
|
| 3747 | - if ($j > 1) {
|
|
| 3748 | - $json['total'] = $posts_count; |
|
| 3749 | - $json['files'] = array(); |
|
| 3750 | - } else {
|
|
| 3751 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3752 | - } |
|
| 3753 | - } |
|
| 3754 | - } |
|
| 3755 | - // WPML |
|
| 3756 | - if ($is_wpml) {
|
|
| 3757 | - $sitepress->switch_lang($active_lang, true); |
|
| 3758 | - } |
|
| 3759 | - // WPML |
|
| 3760 | - wp_send_json( $json ); |
|
| 3761 | - } |
|
| 3762 | - } |
|
| 3763 | - break; |
|
| 3764 | - case 'export_cats': {
|
|
| 3765 | - // WPML |
|
| 3766 | - $is_wpml = geodir_is_wpml(); |
|
| 3767 | - if ($is_wpml) {
|
|
| 3768 | - global $sitepress; |
|
| 3769 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3743 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3744 | + $json['total'] = $posts_count; |
|
| 3745 | + $json['files'] = $chunk_file_paths; |
|
| 3746 | + } else {
|
|
| 3747 | + if ($j > 1) {
|
|
| 3748 | + $json['total'] = $posts_count; |
|
| 3749 | + $json['files'] = array(); |
|
| 3750 | + } else {
|
|
| 3751 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3752 | + } |
|
| 3753 | + } |
|
| 3754 | + } |
|
| 3755 | + // WPML |
|
| 3756 | + if ($is_wpml) {
|
|
| 3757 | + $sitepress->switch_lang($active_lang, true); |
|
| 3758 | + } |
|
| 3759 | + // WPML |
|
| 3760 | + wp_send_json( $json ); |
|
| 3761 | + } |
|
| 3762 | + } |
|
| 3763 | + break; |
|
| 3764 | + case 'export_cats': {
|
|
| 3765 | + // WPML |
|
| 3766 | + $is_wpml = geodir_is_wpml(); |
|
| 3767 | + if ($is_wpml) {
|
|
| 3768 | + global $sitepress; |
|
| 3769 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3770 | 3770 | |
| 3771 | - $sitepress->switch_lang('all', true);
|
|
| 3772 | - } |
|
| 3773 | - // WPML |
|
| 3774 | - $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 3771 | + $sitepress->switch_lang('all', true);
|
|
| 3772 | + } |
|
| 3773 | + // WPML |
|
| 3774 | + $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 3775 | 3775 | |
| 3776 | - $terms_count = geodir_get_terms_count( $post_type ); |
|
| 3777 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3778 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3779 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3780 | - $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 3776 | + $terms_count = geodir_get_terms_count( $post_type ); |
|
| 3777 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3778 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3779 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3780 | + $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 3781 | 3781 | |
| 3782 | - $chunk_file_paths = array(); |
|
| 3782 | + $chunk_file_paths = array(); |
|
| 3783 | 3783 | |
| 3784 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3785 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3786 | - $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 3787 | - $percentage = min( $percentage, 100 ); |
|
| 3784 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3785 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3786 | + $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 3787 | + $percentage = min( $percentage, 100 ); |
|
| 3788 | 3788 | |
| 3789 | - $json['percentage'] = $percentage; |
|
| 3790 | - // WPML |
|
| 3791 | - if ($is_wpml) {
|
|
| 3792 | - $sitepress->switch_lang($active_lang, true); |
|
| 3793 | - } |
|
| 3794 | - // WPML |
|
| 3795 | - wp_send_json( $json ); |
|
| 3796 | - } else {
|
|
| 3797 | - if ( !$terms_count > 0 ) {
|
|
| 3798 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3799 | - } else {
|
|
| 3800 | - $total_terms = $terms_count; |
|
| 3801 | - if ($chunk_per_page > $terms_count) {
|
|
| 3802 | - $chunk_per_page = $terms_count; |
|
| 3803 | - } |
|
| 3804 | - $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 3789 | + $json['percentage'] = $percentage; |
|
| 3790 | + // WPML |
|
| 3791 | + if ($is_wpml) {
|
|
| 3792 | + $sitepress->switch_lang($active_lang, true); |
|
| 3793 | + } |
|
| 3794 | + // WPML |
|
| 3795 | + wp_send_json( $json ); |
|
| 3796 | + } else {
|
|
| 3797 | + if ( !$terms_count > 0 ) {
|
|
| 3798 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3799 | + } else {
|
|
| 3800 | + $total_terms = $terms_count; |
|
| 3801 | + if ($chunk_per_page > $terms_count) {
|
|
| 3802 | + $chunk_per_page = $terms_count; |
|
| 3803 | + } |
|
| 3804 | + $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 3805 | 3805 | |
| 3806 | - $j = $chunk_page_no; |
|
| 3807 | - $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 3806 | + $j = $chunk_page_no; |
|
| 3807 | + $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 3808 | 3808 | |
| 3809 | - $per_page = 500; |
|
| 3810 | - if ($per_page > $chunk_per_page) {
|
|
| 3811 | - $per_page = $chunk_per_page; |
|
| 3812 | - } |
|
| 3813 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3809 | + $per_page = 500; |
|
| 3810 | + if ($per_page > $chunk_per_page) {
|
|
| 3811 | + $per_page = $chunk_per_page; |
|
| 3812 | + } |
|
| 3813 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3814 | 3814 | |
| 3815 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3816 | - $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 3815 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3816 | + $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 3817 | 3817 | |
| 3818 | - $clear = $i == 0 ? true : false; |
|
| 3819 | - geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 3820 | - } |
|
| 3818 | + $clear = $i == 0 ? true : false; |
|
| 3819 | + geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 3820 | + } |
|
| 3821 | 3821 | |
| 3822 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3823 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3824 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3825 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3826 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3822 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3823 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3824 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3825 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3826 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3827 | 3827 | |
| 3828 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3829 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3830 | - } |
|
| 3828 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3829 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3830 | + } |
|
| 3831 | 3831 | |
| 3832 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3833 | - $json['total'] = $terms_count; |
|
| 3834 | - $json['files'] = $chunk_file_paths; |
|
| 3835 | - } else {
|
|
| 3836 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3837 | - } |
|
| 3838 | - } |
|
| 3839 | - // WPML |
|
| 3840 | - if ($is_wpml) {
|
|
| 3841 | - $sitepress->switch_lang($active_lang, true); |
|
| 3842 | - } |
|
| 3843 | - // WPML |
|
| 3844 | - wp_send_json( $json ); |
|
| 3845 | - } |
|
| 3846 | - } |
|
| 3847 | - break; |
|
| 3848 | - case 'export_locations': {
|
|
| 3849 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3850 | - $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 3851 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3852 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3853 | - $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 3832 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3833 | + $json['total'] = $terms_count; |
|
| 3834 | + $json['files'] = $chunk_file_paths; |
|
| 3835 | + } else {
|
|
| 3836 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3837 | + } |
|
| 3838 | + } |
|
| 3839 | + // WPML |
|
| 3840 | + if ($is_wpml) {
|
|
| 3841 | + $sitepress->switch_lang($active_lang, true); |
|
| 3842 | + } |
|
| 3843 | + // WPML |
|
| 3844 | + wp_send_json( $json ); |
|
| 3845 | + } |
|
| 3846 | + } |
|
| 3847 | + break; |
|
| 3848 | + case 'export_locations': {
|
|
| 3849 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3850 | + $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 3851 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3852 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3853 | + $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 3854 | 3854 | |
| 3855 | - $items_count = (int)geodir_location_imex_count_locations(); |
|
| 3855 | + $items_count = (int)geodir_location_imex_count_locations(); |
|
| 3856 | 3856 | |
| 3857 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3858 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3859 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3860 | - $percentage = min( $percentage, 100 ); |
|
| 3857 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3858 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3859 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3860 | + $percentage = min( $percentage, 100 ); |
|
| 3861 | 3861 | |
| 3862 | - $json['percentage'] = $percentage; |
|
| 3863 | - wp_send_json( $json ); |
|
| 3864 | - } else {
|
|
| 3865 | - $chunk_file_paths = array(); |
|
| 3862 | + $json['percentage'] = $percentage; |
|
| 3863 | + wp_send_json( $json ); |
|
| 3864 | + } else {
|
|
| 3865 | + $chunk_file_paths = array(); |
|
| 3866 | 3866 | |
| 3867 | - if ( !$items_count > 0 ) {
|
|
| 3868 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3869 | - } else {
|
|
| 3870 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3871 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3867 | + if ( !$items_count > 0 ) {
|
|
| 3868 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3869 | + } else {
|
|
| 3870 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3871 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3872 | 3872 | |
| 3873 | - $j = $chunk_page_no; |
|
| 3874 | - $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 3873 | + $j = $chunk_page_no; |
|
| 3874 | + $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 3875 | 3875 | |
| 3876 | - $per_page = 500; |
|
| 3877 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 3878 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3876 | + $per_page = 500; |
|
| 3877 | + $per_page = min( $per_page, $chunk_per_page ); |
|
| 3878 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3879 | 3879 | |
| 3880 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3881 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3880 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3881 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3882 | 3882 | |
| 3883 | - $clear = $i == 0 ? true : false; |
|
| 3884 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3885 | - } |
|
| 3883 | + $clear = $i == 0 ? true : false; |
|
| 3884 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3885 | + } |
|
| 3886 | 3886 | |
| 3887 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3888 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3889 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3890 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3891 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3887 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3888 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3889 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3890 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3891 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3892 | 3892 | |
| 3893 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3894 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3895 | - } |
|
| 3893 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3894 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3895 | + } |
|
| 3896 | 3896 | |
| 3897 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3898 | - $json['total'] = $items_count; |
|
| 3899 | - $json['files'] = $chunk_file_paths; |
|
| 3900 | - } else {
|
|
| 3901 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3902 | - } |
|
| 3903 | - } |
|
| 3904 | - wp_send_json( $json ); |
|
| 3905 | - } |
|
| 3906 | - } |
|
| 3907 | - break; |
|
| 3908 | - case 'export_hoods': {
|
|
| 3909 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3910 | - $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
| 3911 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3912 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3913 | - $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
| 3897 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3898 | + $json['total'] = $items_count; |
|
| 3899 | + $json['files'] = $chunk_file_paths; |
|
| 3900 | + } else {
|
|
| 3901 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3902 | + } |
|
| 3903 | + } |
|
| 3904 | + wp_send_json( $json ); |
|
| 3905 | + } |
|
| 3906 | + } |
|
| 3907 | + break; |
|
| 3908 | + case 'export_hoods': {
|
|
| 3909 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3910 | + $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
| 3911 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3912 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3913 | + $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
| 3914 | 3914 | |
| 3915 | - $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
| 3915 | + $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
| 3916 | 3916 | |
| 3917 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3918 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3919 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3920 | - $percentage = min( $percentage, 100 ); |
|
| 3917 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3918 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3919 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3920 | + $percentage = min( $percentage, 100 ); |
|
| 3921 | 3921 | |
| 3922 | - $json['percentage'] = $percentage; |
|
| 3923 | - wp_send_json( $json ); |
|
| 3924 | - } else {
|
|
| 3925 | - $chunk_file_paths = array(); |
|
| 3922 | + $json['percentage'] = $percentage; |
|
| 3923 | + wp_send_json( $json ); |
|
| 3924 | + } else {
|
|
| 3925 | + $chunk_file_paths = array(); |
|
| 3926 | 3926 | |
| 3927 | - if ( !$items_count > 0 ) {
|
|
| 3928 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3929 | - } else {
|
|
| 3930 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3931 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3927 | + if ( !$items_count > 0 ) {
|
|
| 3928 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3929 | + } else {
|
|
| 3930 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3931 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3932 | 3932 | |
| 3933 | - $j = $chunk_page_no; |
|
| 3934 | - $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
| 3933 | + $j = $chunk_page_no; |
|
| 3934 | + $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
| 3935 | 3935 | |
| 3936 | - $per_page = 500; |
|
| 3937 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 3938 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3936 | + $per_page = 500; |
|
| 3937 | + $per_page = min( $per_page, $chunk_per_page ); |
|
| 3938 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3939 | 3939 | |
| 3940 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3941 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3940 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3941 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3942 | 3942 | |
| 3943 | - $clear = $i == 0 ? true : false; |
|
| 3944 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3945 | - } |
|
| 3943 | + $clear = $i == 0 ? true : false; |
|
| 3944 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3945 | + } |
|
| 3946 | 3946 | |
| 3947 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3948 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3949 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3950 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3951 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3947 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3948 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3949 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3950 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3951 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3952 | 3952 | |
| 3953 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3954 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3955 | - } |
|
| 3953 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3954 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3955 | + } |
|
| 3956 | 3956 | |
| 3957 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3958 | - $json['total'] = $items_count; |
|
| 3959 | - $json['files'] = $chunk_file_paths; |
|
| 3960 | - } else {
|
|
| 3961 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3962 | - } |
|
| 3963 | - } |
|
| 3964 | - wp_send_json( $json ); |
|
| 3965 | - } |
|
| 3966 | - } |
|
| 3967 | - break; |
|
| 3968 | - case 'prepare_import': |
|
| 3969 | - case 'import_cat': |
|
| 3970 | - case 'import_post': |
|
| 3971 | - case 'import_loc': |
|
| 3972 | - case 'import_hood': {
|
|
| 3973 | - // WPML |
|
| 3974 | - $is_wpml = geodir_is_wpml(); |
|
| 3975 | - if ($is_wpml) {
|
|
| 3976 | - global $sitepress; |
|
| 3977 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3978 | - } |
|
| 3979 | - // WPML |
|
| 3957 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3958 | + $json['total'] = $items_count; |
|
| 3959 | + $json['files'] = $chunk_file_paths; |
|
| 3960 | + } else {
|
|
| 3961 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3962 | + } |
|
| 3963 | + } |
|
| 3964 | + wp_send_json( $json ); |
|
| 3965 | + } |
|
| 3966 | + } |
|
| 3967 | + break; |
|
| 3968 | + case 'prepare_import': |
|
| 3969 | + case 'import_cat': |
|
| 3970 | + case 'import_post': |
|
| 3971 | + case 'import_loc': |
|
| 3972 | + case 'import_hood': {
|
|
| 3973 | + // WPML |
|
| 3974 | + $is_wpml = geodir_is_wpml(); |
|
| 3975 | + if ($is_wpml) {
|
|
| 3976 | + global $sitepress; |
|
| 3977 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3978 | + } |
|
| 3979 | + // WPML |
|
| 3980 | 3980 | |
| 3981 | - ini_set( 'auto_detect_line_endings', true ); |
|
| 3981 | + ini_set( 'auto_detect_line_endings', true ); |
|
| 3982 | 3982 | |
| 3983 | - $uploads = wp_upload_dir(); |
|
| 3984 | - $uploads_dir = $uploads['path']; |
|
| 3985 | - $uploads_subdir = $uploads['subdir']; |
|
| 3983 | + $uploads = wp_upload_dir(); |
|
| 3984 | + $uploads_dir = $uploads['path']; |
|
| 3985 | + $uploads_subdir = $uploads['subdir']; |
|
| 3986 | 3986 | |
| 3987 | - $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 3988 | - $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 3987 | + $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 3988 | + $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 3989 | 3989 | |
| 3990 | - $csv_file_arr = explode( '/', $csv_file ); |
|
| 3991 | - $csv_filename = end( $csv_file_arr ); |
|
| 3992 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 3990 | + $csv_file_arr = explode( '/', $csv_file ); |
|
| 3991 | + $csv_filename = end( $csv_file_arr ); |
|
| 3992 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 3993 | 3993 | |
| 3994 | - $json['file'] = $csv_file; |
|
| 3995 | - $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 3996 | - $file = array(); |
|
| 3994 | + $json['file'] = $csv_file; |
|
| 3995 | + $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 3996 | + $file = array(); |
|
| 3997 | 3997 | |
| 3998 | - if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 3999 | - $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 3998 | + if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 3999 | + $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 4000 | 4000 | |
| 4001 | - if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 4002 | - $json['error'] = NULL; |
|
| 4003 | - $json['rows'] = 0; |
|
| 4001 | + if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 4002 | + $json['error'] = NULL; |
|
| 4003 | + $json['rows'] = 0; |
|
| 4004 | 4004 | |
| 4005 | - if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 4006 | - while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 4007 | - if ( !empty( $data ) ) {
|
|
| 4008 | - $file[] = $data; |
|
| 4009 | - } |
|
| 4010 | - } |
|
| 4011 | - fclose($handle); |
|
| 4012 | - } |
|
| 4005 | + if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 4006 | + while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 4007 | + if ( !empty( $data ) ) {
|
|
| 4008 | + $file[] = $data; |
|
| 4009 | + } |
|
| 4010 | + } |
|
| 4011 | + fclose($handle); |
|
| 4012 | + } |
|
| 4013 | 4013 | |
| 4014 | - $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 4014 | + $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 4015 | 4015 | |
| 4016 | - if (!$json['rows'] > 0) {
|
|
| 4017 | - $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 4018 | - } |
|
| 4019 | - } else {
|
|
| 4020 | - wp_send_json( $json ); |
|
| 4021 | - } |
|
| 4022 | - } else {
|
|
| 4023 | - wp_send_json( $json ); |
|
| 4024 | - } |
|
| 4016 | + if (!$json['rows'] > 0) {
|
|
| 4017 | + $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 4018 | + } |
|
| 4019 | + } else {
|
|
| 4020 | + wp_send_json( $json ); |
|
| 4021 | + } |
|
| 4022 | + } else {
|
|
| 4023 | + wp_send_json( $json ); |
|
| 4024 | + } |
|
| 4025 | 4025 | |
| 4026 | - if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 4027 | - wp_send_json( $json ); |
|
| 4028 | - } |
|
| 4026 | + if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 4027 | + wp_send_json( $json ); |
|
| 4028 | + } |
|
| 4029 | 4029 | |
| 4030 | - $total = $json['rows']; |
|
| 4031 | - $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 4032 | - $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 4030 | + $total = $json['rows']; |
|
| 4031 | + $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 4032 | + $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 4033 | 4033 | |
| 4034 | - $count = $limit; |
|
| 4034 | + $count = $limit; |
|
| 4035 | 4035 | |
| 4036 | - if ($count < $total) {
|
|
| 4037 | - $count = $processed + $count; |
|
| 4038 | - if ($count > $total) {
|
|
| 4039 | - $count = $total; |
|
| 4040 | - } |
|
| 4041 | - } else {
|
|
| 4042 | - $count = $total; |
|
| 4043 | - } |
|
| 4036 | + if ($count < $total) {
|
|
| 4037 | + $count = $processed + $count; |
|
| 4038 | + if ($count > $total) {
|
|
| 4039 | + $count = $total; |
|
| 4040 | + } |
|
| 4041 | + } else {
|
|
| 4042 | + $count = $total; |
|
| 4043 | + } |
|
| 4044 | 4044 | |
| 4045 | - $created = 0; |
|
| 4046 | - $updated = 0; |
|
| 4047 | - $skipped = 0; |
|
| 4048 | - $invalid = 0; |
|
| 4049 | - $invalid_addr = 0; |
|
| 4050 | - $images = 0; |
|
| 4045 | + $created = 0; |
|
| 4046 | + $updated = 0; |
|
| 4047 | + $skipped = 0; |
|
| 4048 | + $invalid = 0; |
|
| 4049 | + $invalid_addr = 0; |
|
| 4050 | + $images = 0; |
|
| 4051 | 4051 | |
| 4052 | - $gd_post_info = array(); |
|
| 4053 | - $countpost = 0; |
|
| 4052 | + $gd_post_info = array(); |
|
| 4053 | + $countpost = 0; |
|
| 4054 | 4054 | |
| 4055 | - $post_types = geodir_get_posttypes(); |
|
| 4055 | + $post_types = geodir_get_posttypes(); |
|
| 4056 | 4056 | |
| 4057 | - if ( $task == 'import_cat' ) {
|
|
| 4058 | - if (!empty($file)) {
|
|
| 4059 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4057 | + if ( $task == 'import_cat' ) {
|
|
| 4058 | + if (!empty($file)) {
|
|
| 4059 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4060 | 4060 | |
| 4061 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4062 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 4063 | - wp_send_json( $json ); |
|
| 4064 | - exit; |
|
| 4065 | - } |
|
| 4061 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4062 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 4063 | + wp_send_json( $json ); |
|
| 4064 | + exit; |
|
| 4065 | + } |
|
| 4066 | 4066 | |
| 4067 | - $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
|
|
| 4067 | + $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
|
|
| 4068 | 4068 | |
| 4069 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4070 | - $index = $processed + $i; |
|
| 4069 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4070 | + $index = $processed + $i; |
|
| 4071 | 4071 | |
| 4072 | - if (isset($file[$index])) {
|
|
| 4073 | - $row = $file[$index]; |
|
| 4074 | - $row = array_map( 'trim', $row ); |
|
| 4075 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 4072 | + if (isset($file[$index])) {
|
|
| 4073 | + $row = $file[$index]; |
|
| 4074 | + $row = array_map( 'trim', $row ); |
|
| 4075 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 4076 | 4076 | |
| 4077 | - $cat_id = ''; |
|
| 4078 | - $cat_name = ''; |
|
| 4079 | - $cat_slug = ''; |
|
| 4080 | - $cat_posttype = ''; |
|
| 4081 | - $cat_parent = ''; |
|
| 4082 | - $cat_description = ''; |
|
| 4083 | - $cat_schema = ''; |
|
| 4084 | - $cat_top_description = ''; |
|
| 4085 | - $cat_image = ''; |
|
| 4086 | - $cat_icon = ''; |
|
| 4087 | - $cat_language = ''; |
|
| 4088 | - $cat_id_original = ''; |
|
| 4077 | + $cat_id = ''; |
|
| 4078 | + $cat_name = ''; |
|
| 4079 | + $cat_slug = ''; |
|
| 4080 | + $cat_posttype = ''; |
|
| 4081 | + $cat_parent = ''; |
|
| 4082 | + $cat_description = ''; |
|
| 4083 | + $cat_schema = ''; |
|
| 4084 | + $cat_top_description = ''; |
|
| 4085 | + $cat_image = ''; |
|
| 4086 | + $cat_icon = ''; |
|
| 4087 | + $cat_language = ''; |
|
| 4088 | + $cat_id_original = ''; |
|
| 4089 | 4089 | |
| 4090 | - $c = 0; |
|
| 4091 | - foreach ($columns as $column ) {
|
|
| 4092 | - if ( $column == 'cat_id' ) {
|
|
| 4093 | - $cat_id = (int)$row[$c]; |
|
| 4094 | - } else if ( $column == 'cat_name' ) {
|
|
| 4095 | - $cat_name = $row[$c]; |
|
| 4096 | - } else if ( $column == 'cat_slug' ) {
|
|
| 4097 | - $cat_slug = $row[$c]; |
|
| 4098 | - } else if ( $column == 'cat_posttype' ) {
|
|
| 4099 | - $cat_posttype = $row[$c]; |
|
| 4100 | - } else if ( $column == 'cat_parent' ) {
|
|
| 4101 | - $cat_parent = trim($row[$c]); |
|
| 4102 | - } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 4103 | - $cat_schema = $row[$c]; |
|
| 4104 | - } else if ( $column == 'cat_description' ) {
|
|
| 4105 | - $cat_description = $row[$c]; |
|
| 4106 | - } else if ( $column == 'cat_top_description' ) {
|
|
| 4107 | - $cat_top_description = $row[$c]; |
|
| 4108 | - } else if ( $column == 'cat_image' ) {
|
|
| 4109 | - $cat_image = $row[$c]; |
|
| 4110 | - } else if ( $column == 'cat_icon' ) {
|
|
| 4111 | - $cat_icon = $row[$c]; |
|
| 4112 | - } |
|
| 4113 | - // WPML |
|
| 4114 | - if ( $is_wpml ) {
|
|
| 4115 | - if ( $column == 'cat_language' ) {
|
|
| 4116 | - $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
| 4117 | - } else if ( $column == 'cat_id_original' ) {
|
|
| 4118 | - $cat_id_original = (int)$row[$c]; |
|
| 4119 | - } |
|
| 4120 | - } |
|
| 4121 | - // WPML |
|
| 4122 | - $c++; |
|
| 4123 | - } |
|
| 4090 | + $c = 0; |
|
| 4091 | + foreach ($columns as $column ) {
|
|
| 4092 | + if ( $column == 'cat_id' ) {
|
|
| 4093 | + $cat_id = (int)$row[$c]; |
|
| 4094 | + } else if ( $column == 'cat_name' ) {
|
|
| 4095 | + $cat_name = $row[$c]; |
|
| 4096 | + } else if ( $column == 'cat_slug' ) {
|
|
| 4097 | + $cat_slug = $row[$c]; |
|
| 4098 | + } else if ( $column == 'cat_posttype' ) {
|
|
| 4099 | + $cat_posttype = $row[$c]; |
|
| 4100 | + } else if ( $column == 'cat_parent' ) {
|
|
| 4101 | + $cat_parent = trim($row[$c]); |
|
| 4102 | + } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 4103 | + $cat_schema = $row[$c]; |
|
| 4104 | + } else if ( $column == 'cat_description' ) {
|
|
| 4105 | + $cat_description = $row[$c]; |
|
| 4106 | + } else if ( $column == 'cat_top_description' ) {
|
|
| 4107 | + $cat_top_description = $row[$c]; |
|
| 4108 | + } else if ( $column == 'cat_image' ) {
|
|
| 4109 | + $cat_image = $row[$c]; |
|
| 4110 | + } else if ( $column == 'cat_icon' ) {
|
|
| 4111 | + $cat_icon = $row[$c]; |
|
| 4112 | + } |
|
| 4113 | + // WPML |
|
| 4114 | + if ( $is_wpml ) {
|
|
| 4115 | + if ( $column == 'cat_language' ) {
|
|
| 4116 | + $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
| 4117 | + } else if ( $column == 'cat_id_original' ) {
|
|
| 4118 | + $cat_id_original = (int)$row[$c]; |
|
| 4119 | + } |
|
| 4120 | + } |
|
| 4121 | + // WPML |
|
| 4122 | + $c++; |
|
| 4123 | + } |
|
| 4124 | 4124 | |
| 4125 | - if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 4126 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4125 | + if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 4126 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4127 | 4127 | |
| 4128 | - $invalid++; |
|
| 4129 | - continue; |
|
| 4130 | - } |
|
| 4128 | + $invalid++; |
|
| 4129 | + continue; |
|
| 4130 | + } |
|
| 4131 | 4131 | |
| 4132 | - // WPML |
|
| 4133 | - if ($is_wpml && $cat_language != '') {
|
|
| 4134 | - $sitepress->switch_lang($cat_language, true); |
|
| 4135 | - } |
|
| 4136 | - // WPML |
|
| 4132 | + // WPML |
|
| 4133 | + if ($is_wpml && $cat_language != '') {
|
|
| 4134 | + $sitepress->switch_lang($cat_language, true); |
|
| 4135 | + } |
|
| 4136 | + // WPML |
|
| 4137 | 4137 | |
| 4138 | - $term_data = array(); |
|
| 4139 | - $term_data['name'] = $cat_name; |
|
| 4140 | - $term_data['slug'] = $cat_slug; |
|
| 4141 | - $term_data['description'] = $cat_description; |
|
| 4142 | - $term_data['cat_schema'] = $cat_schema; |
|
| 4143 | - $term_data['top_description'] = $cat_top_description; |
|
| 4144 | - $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 4145 | - $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 4138 | + $term_data = array(); |
|
| 4139 | + $term_data['name'] = $cat_name; |
|
| 4140 | + $term_data['slug'] = $cat_slug; |
|
| 4141 | + $term_data['description'] = $cat_description; |
|
| 4142 | + $term_data['cat_schema'] = $cat_schema; |
|
| 4143 | + $term_data['top_description'] = $cat_top_description; |
|
| 4144 | + $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 4145 | + $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 4146 | 4146 | |
| 4147 | - //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 4147 | + //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 4148 | 4148 | |
| 4149 | - $taxonomy = $cat_posttype . 'category'; |
|
| 4149 | + $taxonomy = $cat_posttype . 'category'; |
|
| 4150 | 4150 | |
| 4151 | - $term_data['taxonomy'] = $taxonomy; |
|
| 4151 | + $term_data['taxonomy'] = $taxonomy; |
|
| 4152 | 4152 | |
| 4153 | - $term_parent_id = 0; |
|
| 4154 | - if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 4155 | - $term_parent = ''; |
|
| 4153 | + $term_parent_id = 0; |
|
| 4154 | + if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 4155 | + $term_parent = ''; |
|
| 4156 | 4156 | |
| 4157 | - if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 4158 | - // |
|
| 4159 | - } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 4160 | - // |
|
| 4161 | - } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 4162 | - // |
|
| 4163 | - } else {
|
|
| 4164 | - $term_parent_data = array(); |
|
| 4165 | - $term_parent_data['name'] = $cat_parent; |
|
| 4166 | - //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 4167 | - $term_parent_data['taxonomy'] = $taxonomy; |
|
| 4157 | + if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 4158 | + // |
|
| 4159 | + } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 4160 | + // |
|
| 4161 | + } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 4162 | + // |
|
| 4163 | + } else {
|
|
| 4164 | + $term_parent_data = array(); |
|
| 4165 | + $term_parent_data['name'] = $cat_parent; |
|
| 4166 | + //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 4167 | + $term_parent_data['taxonomy'] = $taxonomy; |
|
| 4168 | 4168 | |
| 4169 | - $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 4170 | - } |
|
| 4169 | + $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 4170 | + } |
|
| 4171 | 4171 | |
| 4172 | - if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 4173 | - $term_parent_id = (int)$term_parent->term_id; |
|
| 4174 | - } |
|
| 4175 | - } |
|
| 4176 | - $term_data['parent'] = (int)$term_parent_id; |
|
| 4172 | + if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 4173 | + $term_parent_id = (int)$term_parent->term_id; |
|
| 4174 | + } |
|
| 4175 | + } |
|
| 4176 | + $term_data['parent'] = (int)$term_parent_id; |
|
| 4177 | 4177 | |
| 4178 | - $term_id = NULL; |
|
| 4179 | - if ( $import_choice == 'update' ) {
|
|
| 4180 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 4181 | - $term_data['term_id'] = $term['term_id']; |
|
| 4178 | + $term_id = NULL; |
|
| 4179 | + if ( $import_choice == 'update' ) {
|
|
| 4180 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 4181 | + $term_data['term_id'] = $term['term_id']; |
|
| 4182 | 4182 | |
| 4183 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 4184 | - $updated++; |
|
| 4185 | - } else {
|
|
| 4186 | - $invalid++; |
|
| 4187 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4188 | - } |
|
| 4189 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 4190 | - $term_data['term_id'] = $term['term_id']; |
|
| 4183 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 4184 | + $updated++; |
|
| 4185 | + } else {
|
|
| 4186 | + $invalid++; |
|
| 4187 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4188 | + } |
|
| 4189 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 4190 | + $term_data['term_id'] = $term['term_id']; |
|
| 4191 | 4191 | |
| 4192 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 4193 | - $updated++; |
|
| 4194 | - } else {
|
|
| 4195 | - $invalid++; |
|
| 4196 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4197 | - } |
|
| 4198 | - } else {
|
|
| 4199 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 4200 | - $created++; |
|
| 4201 | - } else {
|
|
| 4202 | - $invalid++; |
|
| 4203 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4204 | - } |
|
| 4205 | - } |
|
| 4206 | - } else if ( $import_choice == 'skip' ) {
|
|
| 4207 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 4208 | - $skipped++; |
|
| 4209 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 4210 | - $skipped++; |
|
| 4211 | - } else {
|
|
| 4212 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 4213 | - $created++; |
|
| 4214 | - } else {
|
|
| 4215 | - $invalid++; |
|
| 4216 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4217 | - } |
|
| 4218 | - } |
|
| 4219 | - } else {
|
|
| 4220 | - $invalid++; |
|
| 4221 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4222 | - } |
|
| 4192 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 4193 | + $updated++; |
|
| 4194 | + } else {
|
|
| 4195 | + $invalid++; |
|
| 4196 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4197 | + } |
|
| 4198 | + } else {
|
|
| 4199 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 4200 | + $created++; |
|
| 4201 | + } else {
|
|
| 4202 | + $invalid++; |
|
| 4203 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4204 | + } |
|
| 4205 | + } |
|
| 4206 | + } else if ( $import_choice == 'skip' ) {
|
|
| 4207 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 4208 | + $skipped++; |
|
| 4209 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 4210 | + $skipped++; |
|
| 4211 | + } else {
|
|
| 4212 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 4213 | + $created++; |
|
| 4214 | + } else {
|
|
| 4215 | + $invalid++; |
|
| 4216 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4217 | + } |
|
| 4218 | + } |
|
| 4219 | + } else {
|
|
| 4220 | + $invalid++; |
|
| 4221 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4222 | + } |
|
| 4223 | 4223 | |
| 4224 | - if ( $term_id ) {
|
|
| 4225 | - // WPML |
|
| 4226 | - if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
|
|
| 4227 | - $wpml_element_type = 'tax_' . $taxonomy; |
|
| 4228 | - $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
| 4229 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 4230 | - |
|
| 4231 | - $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
| 4224 | + if ( $term_id ) {
|
|
| 4225 | + // WPML |
|
| 4226 | + if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
|
|
| 4227 | + $wpml_element_type = 'tax_' . $taxonomy; |
|
| 4228 | + $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
| 4229 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 4230 | + |
|
| 4231 | + $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
| 4232 | 4232 | |
| 4233 | - $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
| 4234 | - } |
|
| 4235 | - // WPML |
|
| 4233 | + $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
| 4234 | + } |
|
| 4235 | + // WPML |
|
| 4236 | 4236 | |
| 4237 | - if ( isset( $term_data['top_description'] ) ) {
|
|
| 4238 | - update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 4239 | - } |
|
| 4237 | + if ( isset( $term_data['top_description'] ) ) {
|
|
| 4238 | + update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 4239 | + } |
|
| 4240 | 4240 | |
| 4241 | - if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 4242 | - update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 4243 | - } |
|
| 4241 | + if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 4242 | + update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 4243 | + } |
|
| 4244 | 4244 | |
| 4245 | - $attachment = false; |
|
| 4246 | - if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 4247 | - $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 4248 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 4245 | + $attachment = false; |
|
| 4246 | + if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 4247 | + $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 4248 | + $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 4249 | 4249 | |
| 4250 | - if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 4251 | - $attachment = true; |
|
| 4252 | - update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 4253 | - } |
|
| 4254 | - } |
|
| 4250 | + if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 4251 | + $attachment = true; |
|
| 4252 | + update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 4253 | + } |
|
| 4254 | + } |
|
| 4255 | 4255 | |
| 4256 | - if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 4257 | - $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 4258 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 4256 | + if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 4257 | + $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 4258 | + $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 4259 | 4259 | |
| 4260 | - if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 4261 | - $attachment = true; |
|
| 4262 | - update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 4263 | - } |
|
| 4264 | - } |
|
| 4260 | + if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 4261 | + $attachment = true; |
|
| 4262 | + update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 4263 | + } |
|
| 4264 | + } |
|
| 4265 | 4265 | |
| 4266 | - if ( $attachment ) {
|
|
| 4267 | - $images++; |
|
| 4268 | - } |
|
| 4269 | - } |
|
| 4266 | + if ( $attachment ) {
|
|
| 4267 | + $images++; |
|
| 4268 | + } |
|
| 4269 | + } |
|
| 4270 | 4270 | |
| 4271 | - // WPML |
|
| 4272 | - if ($is_wpml && $cat_language != '') {
|
|
| 4273 | - $sitepress->switch_lang($active_lang, true); |
|
| 4274 | - } |
|
| 4275 | - // WPML |
|
| 4276 | - } |
|
| 4277 | - } |
|
| 4278 | - } |
|
| 4271 | + // WPML |
|
| 4272 | + if ($is_wpml && $cat_language != '') {
|
|
| 4273 | + $sitepress->switch_lang($active_lang, true); |
|
| 4274 | + } |
|
| 4275 | + // WPML |
|
| 4276 | + } |
|
| 4277 | + } |
|
| 4278 | + } |
|
| 4279 | 4279 | |
| 4280 | - $json = array(); |
|
| 4281 | - $json['processed'] = $limit; |
|
| 4282 | - $json['created'] = $created; |
|
| 4283 | - $json['updated'] = $updated; |
|
| 4284 | - $json['skipped'] = $skipped; |
|
| 4285 | - $json['invalid'] = $invalid; |
|
| 4286 | - $json['images'] = $images; |
|
| 4280 | + $json = array(); |
|
| 4281 | + $json['processed'] = $limit; |
|
| 4282 | + $json['created'] = $created; |
|
| 4283 | + $json['updated'] = $updated; |
|
| 4284 | + $json['skipped'] = $skipped; |
|
| 4285 | + $json['invalid'] = $invalid; |
|
| 4286 | + $json['images'] = $images; |
|
| 4287 | 4287 | |
| 4288 | - wp_send_json( $json ); |
|
| 4289 | - exit; |
|
| 4290 | - } else if ( $task == 'import_post' ) {
|
|
| 4291 | - //run some stuff to make the import quicker |
|
| 4292 | - wp_defer_term_counting( true ); |
|
| 4293 | - wp_defer_comment_counting( true ); |
|
| 4294 | - $wpdb->query( 'SET autocommit = 0;' ); |
|
| 4295 | - |
|
| 4296 | - //remove_all_actions('publish_post');
|
|
| 4297 | - //remove_all_actions('transition_post_status');
|
|
| 4298 | - //remove_all_actions('publish_future_post');
|
|
| 4299 | - |
|
| 4300 | - if (!empty($file)) {
|
|
| 4301 | - $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 4302 | - $default_status = 'publish'; |
|
| 4303 | - $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 4288 | + wp_send_json( $json ); |
|
| 4289 | + exit; |
|
| 4290 | + } else if ( $task == 'import_post' ) {
|
|
| 4291 | + //run some stuff to make the import quicker |
|
| 4292 | + wp_defer_term_counting( true ); |
|
| 4293 | + wp_defer_comment_counting( true ); |
|
| 4294 | + $wpdb->query( 'SET autocommit = 0;' ); |
|
| 4295 | + |
|
| 4296 | + //remove_all_actions('publish_post');
|
|
| 4297 | + //remove_all_actions('transition_post_status');
|
|
| 4298 | + //remove_all_actions('publish_future_post');
|
|
| 4299 | + |
|
| 4300 | + if (!empty($file)) {
|
|
| 4301 | + $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 4302 | + $default_status = 'publish'; |
|
| 4303 | + $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 4304 | 4304 | |
| 4305 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4305 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4306 | 4306 | |
| 4307 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4308 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 4309 | - wp_send_json( $json ); |
|
| 4310 | - exit; |
|
| 4311 | - } |
|
| 4307 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4308 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 4309 | + wp_send_json( $json ); |
|
| 4310 | + exit; |
|
| 4311 | + } |
|
| 4312 | 4312 | |
| 4313 | - $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
|
|
| 4314 | - $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
| 4315 | - $processed_actual = 0; |
|
| 4316 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4317 | - $index = $processed + $i; |
|
| 4318 | - $gd_post = array(); |
|
| 4313 | + $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
|
|
| 4314 | + $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
| 4315 | + $processed_actual = 0; |
|
| 4316 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4317 | + $index = $processed + $i; |
|
| 4318 | + $gd_post = array(); |
|
| 4319 | 4319 | |
| 4320 | - if (isset($file[$index])) {
|
|
| 4321 | - $processed_actual++; |
|
| 4322 | - $row = $file[$index]; |
|
| 4323 | - $row = array_map( 'trim', $row ); |
|
| 4324 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 4325 | - $row = array_map( 'addslashes_gpc', $row ); |
|
| 4320 | + if (isset($file[$index])) {
|
|
| 4321 | + $processed_actual++; |
|
| 4322 | + $row = $file[$index]; |
|
| 4323 | + $row = array_map( 'trim', $row ); |
|
| 4324 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 4325 | + $row = array_map( 'addslashes_gpc', $row ); |
|
| 4326 | 4326 | |
| 4327 | - $post_id = ''; |
|
| 4328 | - $post_title = ''; |
|
| 4329 | - $post_author = ''; |
|
| 4330 | - $post_content = ''; |
|
| 4331 | - $post_category_arr = array(); |
|
| 4332 | - $default_category = ''; |
|
| 4333 | - $post_tags = array(); |
|
| 4334 | - $post_type = ''; |
|
| 4335 | - $post_status = ''; |
|
| 4336 | - $geodir_video = ''; |
|
| 4337 | - $post_address = ''; |
|
| 4338 | - $post_city = ''; |
|
| 4339 | - $post_region = ''; |
|
| 4340 | - $post_country = ''; |
|
| 4341 | - $post_zip = ''; |
|
| 4342 | - $post_latitude = ''; |
|
| 4343 | - $post_longitude = ''; |
|
| 4344 | - $post_neighbourhood = ''; |
|
| 4345 | - $neighbourhood_latitude = ''; |
|
| 4346 | - $neighbourhood_longitude = ''; |
|
| 4347 | - $geodir_timing = ''; |
|
| 4348 | - $geodir_contact = ''; |
|
| 4349 | - $geodir_email = ''; |
|
| 4350 | - $geodir_website = ''; |
|
| 4351 | - $geodir_twitter = ''; |
|
| 4352 | - $geodir_facebook = ''; |
|
| 4353 | - $geodir_twitter = ''; |
|
| 4354 | - $post_images = array(); |
|
| 4327 | + $post_id = ''; |
|
| 4328 | + $post_title = ''; |
|
| 4329 | + $post_author = ''; |
|
| 4330 | + $post_content = ''; |
|
| 4331 | + $post_category_arr = array(); |
|
| 4332 | + $default_category = ''; |
|
| 4333 | + $post_tags = array(); |
|
| 4334 | + $post_type = ''; |
|
| 4335 | + $post_status = ''; |
|
| 4336 | + $geodir_video = ''; |
|
| 4337 | + $post_address = ''; |
|
| 4338 | + $post_city = ''; |
|
| 4339 | + $post_region = ''; |
|
| 4340 | + $post_country = ''; |
|
| 4341 | + $post_zip = ''; |
|
| 4342 | + $post_latitude = ''; |
|
| 4343 | + $post_longitude = ''; |
|
| 4344 | + $post_neighbourhood = ''; |
|
| 4345 | + $neighbourhood_latitude = ''; |
|
| 4346 | + $neighbourhood_longitude = ''; |
|
| 4347 | + $geodir_timing = ''; |
|
| 4348 | + $geodir_contact = ''; |
|
| 4349 | + $geodir_email = ''; |
|
| 4350 | + $geodir_website = ''; |
|
| 4351 | + $geodir_twitter = ''; |
|
| 4352 | + $geodir_facebook = ''; |
|
| 4353 | + $geodir_twitter = ''; |
|
| 4354 | + $post_images = array(); |
|
| 4355 | 4355 | |
| 4356 | - $expire_date = 'Never'; |
|
| 4356 | + $expire_date = 'Never'; |
|
| 4357 | 4357 | |
| 4358 | - $language = ''; |
|
| 4359 | - $original_post_id = ''; |
|
| 4358 | + $language = ''; |
|
| 4359 | + $original_post_id = ''; |
|
| 4360 | 4360 | |
| 4361 | - $c = 0; |
|
| 4362 | - foreach ($columns as $column ) {
|
|
| 4363 | - $gd_post[$column] = $row[$c]; |
|
| 4361 | + $c = 0; |
|
| 4362 | + foreach ($columns as $column ) {
|
|
| 4363 | + $gd_post[$column] = $row[$c]; |
|
| 4364 | 4364 | |
| 4365 | - if ( $column == 'post_id' ) {
|
|
| 4366 | - $post_id = $row[$c]; |
|
| 4367 | - } else if ( $column == 'post_title' ) {
|
|
| 4368 | - $post_title = sanitize_text_field($row[$c]); |
|
| 4369 | - } else if ( $column == 'post_author' ) {
|
|
| 4370 | - $post_author = $row[$c]; |
|
| 4371 | - } else if ( $column == 'post_content' ) {
|
|
| 4372 | - $post_content = $row[$c]; |
|
| 4373 | - } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 4374 | - $post_category_arr = explode( ',', $row[$c] ); |
|
| 4375 | - } else if ( $column == 'default_category' ) {
|
|
| 4376 | - $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 4377 | - } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 4378 | - $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
| 4379 | - } else if ( $column == 'post_type' ) {
|
|
| 4380 | - $post_type = $row[$c]; |
|
| 4381 | - } else if ( $column == 'post_status' ) {
|
|
| 4382 | - $post_status = sanitize_key( $row[$c] ); |
|
| 4383 | - } else if ( $column == 'is_featured' ) {
|
|
| 4384 | - $is_featured = (int)$row[$c]; |
|
| 4385 | - } else if ( $column == 'geodir_video' ) {
|
|
| 4386 | - $geodir_video = $row[$c]; |
|
| 4387 | - } else if ( $column == 'post_address' ) {
|
|
| 4388 | - $post_address = sanitize_text_field($row[$c]); |
|
| 4389 | - } else if ( $column == 'post_city' ) {
|
|
| 4390 | - $post_city = sanitize_text_field($row[$c]); |
|
| 4391 | - } else if ( $column == 'post_region' ) {
|
|
| 4392 | - $post_region = sanitize_text_field($row[$c]); |
|
| 4393 | - } else if ( $column == 'post_country' ) {
|
|
| 4394 | - $post_country = sanitize_text_field($row[$c]); |
|
| 4395 | - } else if ( $column == 'post_zip' ) {
|
|
| 4396 | - $post_zip = sanitize_text_field($row[$c]); |
|
| 4397 | - } else if ( $column == 'post_latitude' ) {
|
|
| 4398 | - $post_latitude = sanitize_text_field($row[$c]); |
|
| 4399 | - } else if ( $column == 'post_longitude' ) {
|
|
| 4400 | - $post_longitude = sanitize_text_field($row[$c]); |
|
| 4401 | - } else if ( $column == 'post_neighbourhood' ) {
|
|
| 4402 | - $post_neighbourhood = sanitize_text_field($row[$c]); |
|
| 4403 | - unset($gd_post[$column]); |
|
| 4404 | - } else if ( $column == 'neighbourhood_latitude' ) {
|
|
| 4405 | - $neighbourhood_latitude = sanitize_text_field($row[$c]); |
|
| 4406 | - } else if ( $column == 'neighbourhood_longitude' ) {
|
|
| 4407 | - $neighbourhood_longitude = sanitize_text_field($row[$c]); |
|
| 4408 | - } else if ( $column == 'geodir_timing' ) {
|
|
| 4409 | - $geodir_timing = sanitize_text_field($row[$c]); |
|
| 4410 | - } else if ( $column == 'geodir_contact' ) {
|
|
| 4411 | - $geodir_contact = sanitize_text_field($row[$c]); |
|
| 4412 | - } else if ( $column == 'geodir_email' ) {
|
|
| 4413 | - $geodir_email = sanitize_email($row[$c]); |
|
| 4414 | - } else if ( $column == 'geodir_website' ) {
|
|
| 4415 | - $geodir_website = sanitize_text_field($row[$c]); |
|
| 4416 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 4417 | - $geodir_twitter = sanitize_text_field($row[$c]); |
|
| 4418 | - } else if ( $column == 'geodir_facebook' ) {
|
|
| 4419 | - $geodir_facebook = sanitize_text_field($row[$c]); |
|
| 4420 | - } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 4421 | - $post_images[] = $row[$c]; |
|
| 4422 | - } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 4423 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 4424 | - } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 4425 | - $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 4426 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 4427 | - } |
|
| 4428 | - // WPML |
|
| 4429 | - if ($is_wpml) {
|
|
| 4430 | - if ($column == 'language') {
|
|
| 4431 | - $language = geodir_strtolower(trim($row[$c])); |
|
| 4432 | - } else if ($column == 'original_post_id') {
|
|
| 4433 | - $original_post_id = (int)$row[$c]; |
|
| 4434 | - } |
|
| 4435 | - } |
|
| 4436 | - // WPML |
|
| 4437 | - $c++; |
|
| 4438 | - } |
|
| 4365 | + if ( $column == 'post_id' ) {
|
|
| 4366 | + $post_id = $row[$c]; |
|
| 4367 | + } else if ( $column == 'post_title' ) {
|
|
| 4368 | + $post_title = sanitize_text_field($row[$c]); |
|
| 4369 | + } else if ( $column == 'post_author' ) {
|
|
| 4370 | + $post_author = $row[$c]; |
|
| 4371 | + } else if ( $column == 'post_content' ) {
|
|
| 4372 | + $post_content = $row[$c]; |
|
| 4373 | + } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 4374 | + $post_category_arr = explode( ',', $row[$c] ); |
|
| 4375 | + } else if ( $column == 'default_category' ) {
|
|
| 4376 | + $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 4377 | + } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 4378 | + $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
| 4379 | + } else if ( $column == 'post_type' ) {
|
|
| 4380 | + $post_type = $row[$c]; |
|
| 4381 | + } else if ( $column == 'post_status' ) {
|
|
| 4382 | + $post_status = sanitize_key( $row[$c] ); |
|
| 4383 | + } else if ( $column == 'is_featured' ) {
|
|
| 4384 | + $is_featured = (int)$row[$c]; |
|
| 4385 | + } else if ( $column == 'geodir_video' ) {
|
|
| 4386 | + $geodir_video = $row[$c]; |
|
| 4387 | + } else if ( $column == 'post_address' ) {
|
|
| 4388 | + $post_address = sanitize_text_field($row[$c]); |
|
| 4389 | + } else if ( $column == 'post_city' ) {
|
|
| 4390 | + $post_city = sanitize_text_field($row[$c]); |
|
| 4391 | + } else if ( $column == 'post_region' ) {
|
|
| 4392 | + $post_region = sanitize_text_field($row[$c]); |
|
| 4393 | + } else if ( $column == 'post_country' ) {
|
|
| 4394 | + $post_country = sanitize_text_field($row[$c]); |
|
| 4395 | + } else if ( $column == 'post_zip' ) {
|
|
| 4396 | + $post_zip = sanitize_text_field($row[$c]); |
|
| 4397 | + } else if ( $column == 'post_latitude' ) {
|
|
| 4398 | + $post_latitude = sanitize_text_field($row[$c]); |
|
| 4399 | + } else if ( $column == 'post_longitude' ) {
|
|
| 4400 | + $post_longitude = sanitize_text_field($row[$c]); |
|
| 4401 | + } else if ( $column == 'post_neighbourhood' ) {
|
|
| 4402 | + $post_neighbourhood = sanitize_text_field($row[$c]); |
|
| 4403 | + unset($gd_post[$column]); |
|
| 4404 | + } else if ( $column == 'neighbourhood_latitude' ) {
|
|
| 4405 | + $neighbourhood_latitude = sanitize_text_field($row[$c]); |
|
| 4406 | + } else if ( $column == 'neighbourhood_longitude' ) {
|
|
| 4407 | + $neighbourhood_longitude = sanitize_text_field($row[$c]); |
|
| 4408 | + } else if ( $column == 'geodir_timing' ) {
|
|
| 4409 | + $geodir_timing = sanitize_text_field($row[$c]); |
|
| 4410 | + } else if ( $column == 'geodir_contact' ) {
|
|
| 4411 | + $geodir_contact = sanitize_text_field($row[$c]); |
|
| 4412 | + } else if ( $column == 'geodir_email' ) {
|
|
| 4413 | + $geodir_email = sanitize_email($row[$c]); |
|
| 4414 | + } else if ( $column == 'geodir_website' ) {
|
|
| 4415 | + $geodir_website = sanitize_text_field($row[$c]); |
|
| 4416 | + } else if ( $column == 'geodir_twitter' ) {
|
|
| 4417 | + $geodir_twitter = sanitize_text_field($row[$c]); |
|
| 4418 | + } else if ( $column == 'geodir_facebook' ) {
|
|
| 4419 | + $geodir_facebook = sanitize_text_field($row[$c]); |
|
| 4420 | + } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 4421 | + $post_images[] = $row[$c]; |
|
| 4422 | + } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 4423 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 4424 | + } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 4425 | + $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 4426 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 4427 | + } |
|
| 4428 | + // WPML |
|
| 4429 | + if ($is_wpml) {
|
|
| 4430 | + if ($column == 'language') {
|
|
| 4431 | + $language = geodir_strtolower(trim($row[$c])); |
|
| 4432 | + } else if ($column == 'original_post_id') {
|
|
| 4433 | + $original_post_id = (int)$row[$c]; |
|
| 4434 | + } |
|
| 4435 | + } |
|
| 4436 | + // WPML |
|
| 4437 | + $c++; |
|
| 4438 | + } |
|
| 4439 | 4439 | |
| 4440 | - // WPML |
|
| 4441 | - if ($is_wpml && $language != '') {
|
|
| 4442 | - $sitepress->switch_lang($language, true); |
|
| 4443 | - } |
|
| 4444 | - // WPML |
|
| 4440 | + // WPML |
|
| 4441 | + if ($is_wpml && $language != '') {
|
|
| 4442 | + $sitepress->switch_lang($language, true); |
|
| 4443 | + } |
|
| 4444 | + // WPML |
|
| 4445 | 4445 | |
| 4446 | - $gd_post['IMAGE'] = $post_images; |
|
| 4446 | + $gd_post['IMAGE'] = $post_images; |
|
| 4447 | 4447 | |
| 4448 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 4449 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 4448 | + $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 4449 | + $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 4450 | 4450 | |
| 4451 | - $valid = true; |
|
| 4451 | + $valid = true; |
|
| 4452 | 4452 | |
| 4453 | - if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 4454 | - $invalid++; |
|
| 4455 | - $valid = false; |
|
| 4456 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4457 | - } |
|
| 4453 | + if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 4454 | + $invalid++; |
|
| 4455 | + $valid = false; |
|
| 4456 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4457 | + } |
|
| 4458 | 4458 | |
| 4459 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 4460 | - if ( $location_allowed ) {
|
|
| 4461 | - $location_result = geodir_get_default_location(); |
|
| 4462 | - if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 4463 | - $invalid_addr++; |
|
| 4464 | - $valid = false; |
|
| 4465 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) ); |
|
| 4466 | - } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 4467 | - 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 ) ) ) {
|
|
| 4468 | - $invalid_addr++; |
|
| 4469 | - $valid = false; |
|
| 4470 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) ); |
|
| 4471 | - } else {
|
|
| 4472 | - if (!$location_manager) {
|
|
| 4473 | - $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. |
|
| 4474 | - } |
|
| 4475 | - } |
|
| 4476 | - } |
|
| 4477 | - } |
|
| 4459 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 4460 | + if ( $location_allowed ) {
|
|
| 4461 | + $location_result = geodir_get_default_location(); |
|
| 4462 | + if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 4463 | + $invalid_addr++; |
|
| 4464 | + $valid = false; |
|
| 4465 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) ); |
|
| 4466 | + } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 4467 | + 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 ) ) ) {
|
|
| 4468 | + $invalid_addr++; |
|
| 4469 | + $valid = false; |
|
| 4470 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) ); |
|
| 4471 | + } else {
|
|
| 4472 | + if (!$location_manager) {
|
|
| 4473 | + $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. |
|
| 4474 | + } |
|
| 4475 | + } |
|
| 4476 | + } |
|
| 4477 | + } |
|
| 4478 | 4478 | |
| 4479 | - if ( !$valid ) {
|
|
| 4480 | - continue; |
|
| 4481 | - } |
|
| 4479 | + if ( !$valid ) {
|
|
| 4480 | + continue; |
|
| 4481 | + } |
|
| 4482 | 4482 | |
| 4483 | - $cat_taxonomy = $post_type . 'category'; |
|
| 4484 | - $tags_taxonomy = $post_type . '_tags'; |
|
| 4483 | + $cat_taxonomy = $post_type . 'category'; |
|
| 4484 | + $tags_taxonomy = $post_type . '_tags'; |
|
| 4485 | 4485 | |
| 4486 | - if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 4487 | - $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 4488 | - } |
|
| 4486 | + if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 4487 | + $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 4488 | + } |
|
| 4489 | 4489 | |
| 4490 | - $post_category = array(); |
|
| 4491 | - $default_category_id = NULL; |
|
| 4492 | - if ( !empty( $post_category_arr ) ) {
|
|
| 4493 | - foreach ( $post_category_arr as $value ) {
|
|
| 4494 | - $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 4490 | + $post_category = array(); |
|
| 4491 | + $default_category_id = NULL; |
|
| 4492 | + if ( !empty( $post_category_arr ) ) {
|
|
| 4493 | + foreach ( $post_category_arr as $value ) {
|
|
| 4494 | + $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 4495 | 4495 | |
| 4496 | - if ( $category_name != '' ) {
|
|
| 4497 | - $term_category = array(); |
|
| 4496 | + if ( $category_name != '' ) {
|
|
| 4497 | + $term_category = array(); |
|
| 4498 | 4498 | |
| 4499 | - if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 4500 | - $term_category = $term; |
|
| 4501 | - } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 4502 | - $term_category = $term; |
|
| 4503 | - } else {
|
|
| 4504 | - $term_data = array(); |
|
| 4505 | - $term_data['name'] = $category_name; |
|
| 4506 | - $term_data['taxonomy'] = $cat_taxonomy; |
|
| 4499 | + if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 4500 | + $term_category = $term; |
|
| 4501 | + } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 4502 | + $term_category = $term; |
|
| 4503 | + } else {
|
|
| 4504 | + $term_data = array(); |
|
| 4505 | + $term_data['name'] = $category_name; |
|
| 4506 | + $term_data['taxonomy'] = $cat_taxonomy; |
|
| 4507 | 4507 | |
| 4508 | - $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 4509 | - if ( $term_id ) {
|
|
| 4510 | - $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 4511 | - } |
|
| 4512 | - } |
|
| 4508 | + $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 4509 | + if ( $term_id ) {
|
|
| 4510 | + $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 4511 | + } |
|
| 4512 | + } |
|
| 4513 | 4513 | |
| 4514 | - if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 4515 | - $post_category[] = intval($term_category->term_id); |
|
| 4514 | + if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 4515 | + $post_category[] = intval($term_category->term_id); |
|
| 4516 | 4516 | |
| 4517 | - if ($category_name == $default_category) {
|
|
| 4518 | - $default_category_id = intval($term_category->term_id); |
|
| 4519 | - } |
|
| 4520 | - } |
|
| 4521 | - } |
|
| 4522 | - } |
|
| 4523 | - } |
|
| 4517 | + if ($category_name == $default_category) {
|
|
| 4518 | + $default_category_id = intval($term_category->term_id); |
|
| 4519 | + } |
|
| 4520 | + } |
|
| 4521 | + } |
|
| 4522 | + } |
|
| 4523 | + } |
|
| 4524 | 4524 | |
| 4525 | - $save_post = array(); |
|
| 4526 | - $save_post['post_title'] = $post_title; |
|
| 4527 | - $save_post['post_content'] = $post_content; |
|
| 4528 | - $save_post['post_type'] = $post_type; |
|
| 4529 | - $save_post['post_author'] = $post_author; |
|
| 4530 | - $save_post['post_status'] = $post_status; |
|
| 4531 | - $save_post['post_category'] = $post_category; |
|
| 4532 | - $save_post['post_tags'] = $post_tags; |
|
| 4533 | - |
|
| 4534 | - $saved_post_id = NULL; |
|
| 4535 | - if ( $import_choice == 'update' ) {
|
|
| 4536 | - $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
| 4525 | + $save_post = array(); |
|
| 4526 | + $save_post['post_title'] = $post_title; |
|
| 4527 | + $save_post['post_content'] = $post_content; |
|
| 4528 | + $save_post['post_type'] = $post_type; |
|
| 4529 | + $save_post['post_author'] = $post_author; |
|
| 4530 | + $save_post['post_status'] = $post_status; |
|
| 4531 | + $save_post['post_category'] = $post_category; |
|
| 4532 | + $save_post['post_tags'] = $post_tags; |
|
| 4533 | + |
|
| 4534 | + $saved_post_id = NULL; |
|
| 4535 | + if ( $import_choice == 'update' ) {
|
|
| 4536 | + $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
| 4537 | 4537 | |
| 4538 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4539 | - $save_post['ID'] = $post_id; |
|
| 4538 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4539 | + $save_post['ID'] = $post_id; |
|
| 4540 | 4540 | |
| 4541 | - if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
|
|
| 4542 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4543 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4544 | - $saved_post_id = 0; |
|
| 4545 | - } else {
|
|
| 4546 | - $saved_post_id = $post_id; |
|
| 4547 | - $updated++; |
|
| 4548 | - } |
|
| 4549 | - } |
|
| 4550 | - } else {
|
|
| 4551 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4552 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4553 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4554 | - $saved_post_id = 0; |
|
| 4555 | - } else {
|
|
| 4556 | - $created++; |
|
| 4557 | - } |
|
| 4558 | - } |
|
| 4559 | - } |
|
| 4541 | + if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
|
|
| 4542 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4543 | + $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4544 | + $saved_post_id = 0; |
|
| 4545 | + } else {
|
|
| 4546 | + $saved_post_id = $post_id; |
|
| 4547 | + $updated++; |
|
| 4548 | + } |
|
| 4549 | + } |
|
| 4550 | + } else {
|
|
| 4551 | + if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4552 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4553 | + $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4554 | + $saved_post_id = 0; |
|
| 4555 | + } else {
|
|
| 4556 | + $created++; |
|
| 4557 | + } |
|
| 4558 | + } |
|
| 4559 | + } |
|
| 4560 | 4560 | |
| 4561 | - if ( !$saved_post_id > 0 ) {
|
|
| 4562 | - $invalid++; |
|
| 4563 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
| 4564 | - } |
|
| 4565 | - } else if ( $import_choice == 'skip' ) {
|
|
| 4566 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4567 | - $skipped++; |
|
| 4568 | - } else {
|
|
| 4569 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4570 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4571 | - $invalid++; |
|
| 4561 | + if ( !$saved_post_id > 0 ) {
|
|
| 4562 | + $invalid++; |
|
| 4563 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
| 4564 | + } |
|
| 4565 | + } else if ( $import_choice == 'skip' ) {
|
|
| 4566 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4567 | + $skipped++; |
|
| 4568 | + } else {
|
|
| 4569 | + if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4570 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4571 | + $invalid++; |
|
| 4572 | 4572 | |
| 4573 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
| 4574 | - $saved_post_id = 0; |
|
| 4575 | - } else {
|
|
| 4576 | - $created++; |
|
| 4577 | - } |
|
| 4578 | - } else {
|
|
| 4579 | - $invalid++; |
|
| 4573 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
| 4574 | + $saved_post_id = 0; |
|
| 4575 | + } else {
|
|
| 4576 | + $created++; |
|
| 4577 | + } |
|
| 4578 | + } else {
|
|
| 4579 | + $invalid++; |
|
| 4580 | 4580 | |
| 4581 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4582 | - } |
|
| 4583 | - } |
|
| 4584 | - } else {
|
|
| 4585 | - $invalid++; |
|
| 4581 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4582 | + } |
|
| 4583 | + } |
|
| 4584 | + } else {
|
|
| 4585 | + $invalid++; |
|
| 4586 | 4586 | |
| 4587 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4588 | - } |
|
| 4587 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4588 | + } |
|
| 4589 | 4589 | |
| 4590 | - if ( (int)$saved_post_id > 0 ) {
|
|
| 4591 | - // WPML |
|
| 4592 | - if ($is_wpml && $original_post_id > 0 && $language != '') {
|
|
| 4593 | - $wpml_post_type = 'post_' . $post_type; |
|
| 4594 | - $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 4595 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 4590 | + if ( (int)$saved_post_id > 0 ) {
|
|
| 4591 | + // WPML |
|
| 4592 | + if ($is_wpml && $original_post_id > 0 && $language != '') {
|
|
| 4593 | + $wpml_post_type = 'post_' . $post_type; |
|
| 4594 | + $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 4595 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 4596 | 4596 | |
| 4597 | - $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 4597 | + $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 4598 | 4598 | |
| 4599 | - $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 4600 | - } |
|
| 4601 | - // WPML |
|
| 4602 | - $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 4599 | + $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 4600 | + } |
|
| 4601 | + // WPML |
|
| 4602 | + $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 4603 | 4603 | |
| 4604 | - $gd_post['post_id'] = $saved_post_id; |
|
| 4605 | - $gd_post['ID'] = $saved_post_id; |
|
| 4606 | - $gd_post['post_tags'] = $post_tags; |
|
| 4607 | - $gd_post['post_title'] = $post_title; |
|
| 4608 | - $gd_post['post_status'] = $post_status; |
|
| 4609 | - $gd_post['submit_time'] = time(); |
|
| 4610 | - $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 4604 | + $gd_post['post_id'] = $saved_post_id; |
|
| 4605 | + $gd_post['ID'] = $saved_post_id; |
|
| 4606 | + $gd_post['post_tags'] = $post_tags; |
|
| 4607 | + $gd_post['post_title'] = $post_title; |
|
| 4608 | + $gd_post['post_status'] = $post_status; |
|
| 4609 | + $gd_post['submit_time'] = time(); |
|
| 4610 | + $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 4611 | 4611 | |
| 4612 | - // post location |
|
| 4613 | - $post_location_id = 0; |
|
| 4614 | - if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 4615 | - $gd_post['post_neighbourhood'] = ''; |
|
| 4612 | + // post location |
|
| 4613 | + $post_location_id = 0; |
|
| 4614 | + if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 4615 | + $gd_post['post_neighbourhood'] = ''; |
|
| 4616 | 4616 | |
| 4617 | - $post_location_info = array( |
|
| 4618 | - 'city' => $post_city, |
|
| 4619 | - 'region' => $post_region, |
|
| 4620 | - 'country' => $post_country, |
|
| 4621 | - 'geo_lat' => $post_latitude, |
|
| 4622 | - 'geo_lng' => $post_longitude |
|
| 4623 | - ); |
|
| 4624 | - if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 4625 | - $post_location_id = $location_id; |
|
| 4626 | - } |
|
| 4617 | + $post_location_info = array( |
|
| 4618 | + 'city' => $post_city, |
|
| 4619 | + 'region' => $post_region, |
|
| 4620 | + 'country' => $post_country, |
|
| 4621 | + 'geo_lat' => $post_latitude, |
|
| 4622 | + 'geo_lng' => $post_longitude |
|
| 4623 | + ); |
|
| 4624 | + if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 4625 | + $post_location_id = $location_id; |
|
| 4626 | + } |
|
| 4627 | 4627 | |
| 4628 | - if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
|
|
| 4629 | - $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id); |
|
| 4628 | + if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
|
|
| 4629 | + $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id); |
|
| 4630 | 4630 | |
| 4631 | - $hood_data = array(); |
|
| 4632 | - $hood_data['hood_location_id'] = $post_location_id; |
|
| 4633 | - $hood_data['hood_name'] = $post_neighbourhood; |
|
| 4631 | + $hood_data = array(); |
|
| 4632 | + $hood_data['hood_location_id'] = $post_location_id; |
|
| 4633 | + $hood_data['hood_name'] = $post_neighbourhood; |
|
| 4634 | 4634 | |
| 4635 | - if (!empty($neighbourhood_info)) {
|
|
| 4636 | - $hood_data['hood_id'] = $neighbourhood_info->hood_id; |
|
| 4637 | - $hood_data['hood_slug'] = $neighbourhood_info->hood_slug; |
|
| 4635 | + if (!empty($neighbourhood_info)) {
|
|
| 4636 | + $hood_data['hood_id'] = $neighbourhood_info->hood_id; |
|
| 4637 | + $hood_data['hood_slug'] = $neighbourhood_info->hood_slug; |
|
| 4638 | 4638 | |
| 4639 | - if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4640 | - $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4641 | - $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4642 | - } |
|
| 4643 | - } |
|
| 4639 | + if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4640 | + $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4641 | + $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4642 | + } |
|
| 4643 | + } |
|
| 4644 | 4644 | |
| 4645 | - if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4646 | - $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4647 | - $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4648 | - } |
|
| 4645 | + if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4646 | + $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4647 | + $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4648 | + } |
|
| 4649 | 4649 | |
| 4650 | - $hood_data['hood_latitude'] = $post_latitude; |
|
| 4651 | - $hood_data['hood_longitude'] = $post_longitude; |
|
| 4650 | + $hood_data['hood_latitude'] = $post_latitude; |
|
| 4651 | + $hood_data['hood_longitude'] = $post_longitude; |
|
| 4652 | 4652 | |
| 4653 | - $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data); |
|
| 4654 | - if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
|
|
| 4655 | - $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug; |
|
| 4656 | - } |
|
| 4657 | - } |
|
| 4658 | - } |
|
| 4659 | - $gd_post['post_location_id'] = $post_location_id; |
|
| 4653 | + $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data); |
|
| 4654 | + if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
|
|
| 4655 | + $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug; |
|
| 4656 | + } |
|
| 4657 | + } |
|
| 4658 | + } |
|
| 4659 | + $gd_post['post_location_id'] = $post_location_id; |
|
| 4660 | 4660 | |
| 4661 | - // post package info |
|
| 4662 | - $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 4663 | - if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 4664 | - $package_id = $gd_post_info->package_id; |
|
| 4665 | - } |
|
| 4661 | + // post package info |
|
| 4662 | + $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 4663 | + if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 4664 | + $package_id = $gd_post_info->package_id; |
|
| 4665 | + } |
|
| 4666 | 4666 | |
| 4667 | - $package_info = array(); |
|
| 4668 | - if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 4669 | - $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 4667 | + $package_info = array(); |
|
| 4668 | + if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 4669 | + $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 4670 | 4670 | |
| 4671 | - if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 4672 | - $package_info = array(); |
|
| 4673 | - } |
|
| 4674 | - } |
|
| 4671 | + if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 4672 | + $package_info = array(); |
|
| 4673 | + } |
|
| 4674 | + } |
|
| 4675 | 4675 | |
| 4676 | - if (empty($package_info)) {
|
|
| 4677 | - $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 4678 | - } |
|
| 4676 | + if (empty($package_info)) {
|
|
| 4677 | + $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 4678 | + } |
|
| 4679 | 4679 | |
| 4680 | - if (!empty($package_info)) {
|
|
| 4681 | - $package_id = $package_info['pid']; |
|
| 4680 | + if (!empty($package_info)) {
|
|
| 4681 | + $package_id = $package_info['pid']; |
|
| 4682 | 4682 | |
| 4683 | - if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 4684 | - $gd_post['expire_date'] = $expire_date; |
|
| 4685 | - } else {
|
|
| 4686 | - if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 4687 | - $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 4688 | - $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 4689 | - } else {
|
|
| 4690 | - $gd_post['expire_date'] = 'Never'; |
|
| 4691 | - } |
|
| 4692 | - } |
|
| 4683 | + if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 4684 | + $gd_post['expire_date'] = $expire_date; |
|
| 4685 | + } else {
|
|
| 4686 | + if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 4687 | + $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 4688 | + $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 4689 | + } else {
|
|
| 4690 | + $gd_post['expire_date'] = 'Never'; |
|
| 4691 | + } |
|
| 4692 | + } |
|
| 4693 | 4693 | |
| 4694 | - $gd_post['package_id'] = $package_id; |
|
| 4695 | - } |
|
| 4694 | + $gd_post['package_id'] = $package_id; |
|
| 4695 | + } |
|
| 4696 | 4696 | |
| 4697 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 4697 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 4698 | 4698 | |
| 4699 | - if ($post_type == 'gd_event') {
|
|
| 4700 | - $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 4701 | - } |
|
| 4699 | + if ($post_type == 'gd_event') {
|
|
| 4700 | + $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 4701 | + } |
|
| 4702 | 4702 | |
| 4703 | - if (isset($gd_post['post_id'])) {
|
|
| 4704 | - unset($gd_post['post_id']); |
|
| 4705 | - } |
|
| 4703 | + if (isset($gd_post['post_id'])) {
|
|
| 4704 | + unset($gd_post['post_id']); |
|
| 4705 | + } |
|
| 4706 | 4706 | |
| 4707 | - // Export franchise fields |
|
| 4708 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 4709 | - if ($is_franchise_active) {
|
|
| 4710 | - if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 4711 | - $gd_franchise_lock = array(); |
|
| 4707 | + // Export franchise fields |
|
| 4708 | + $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 4709 | + if ($is_franchise_active) {
|
|
| 4710 | + if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 4711 | + $gd_franchise_lock = array(); |
|
| 4712 | 4712 | |
| 4713 | - if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 4714 | - $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 4715 | - $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 4716 | - $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 4717 | - } |
|
| 4713 | + if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 4714 | + $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 4715 | + $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 4716 | + $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 4717 | + } |
|
| 4718 | 4718 | |
| 4719 | - update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 4720 | - update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 4721 | - } else {
|
|
| 4722 | - if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 4723 | - geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 4724 | - } |
|
| 4725 | - } |
|
| 4726 | - } |
|
| 4719 | + update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 4720 | + update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 4721 | + } else {
|
|
| 4722 | + if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 4723 | + geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 4724 | + } |
|
| 4725 | + } |
|
| 4726 | + } |
|
| 4727 | 4727 | |
| 4728 | - if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 4729 | - $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 4730 | - if ($default_category_id) {
|
|
| 4731 | - $save_post['post_default_category'] = $default_category_id; |
|
| 4732 | - $gd_post['default_category'] = $default_category_id; |
|
| 4733 | - } |
|
| 4734 | - $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 4735 | - } |
|
| 4728 | + if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 4729 | + $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 4730 | + if ($default_category_id) {
|
|
| 4731 | + $save_post['post_default_category'] = $default_category_id; |
|
| 4732 | + $gd_post['default_category'] = $default_category_id; |
|
| 4733 | + } |
|
| 4734 | + $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 4735 | + } |
|
| 4736 | 4736 | |
| 4737 | - // Save post info |
|
| 4738 | - geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 4739 | - // post taxonomies |
|
| 4740 | - if ( !empty( $save_post['post_category'] ) ) {
|
|
| 4741 | - wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 4737 | + // Save post info |
|
| 4738 | + geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 4739 | + // post taxonomies |
|
| 4740 | + if ( !empty( $save_post['post_category'] ) ) {
|
|
| 4741 | + wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 4742 | 4742 | |
| 4743 | - $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 4744 | - if ($default_category_id) {
|
|
| 4745 | - $post_default_category = $default_category_id; |
|
| 4746 | - } |
|
| 4747 | - $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 4748 | - $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 4749 | - $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 4743 | + $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 4744 | + if ($default_category_id) {
|
|
| 4745 | + $post_default_category = $default_category_id; |
|
| 4746 | + } |
|
| 4747 | + $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 4748 | + $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 4749 | + $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 4750 | 4750 | |
| 4751 | - if ($post_category_str != '' && $post_default_category) {
|
|
| 4752 | - $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 4753 | - } |
|
| 4751 | + if ($post_category_str != '' && $post_default_category) {
|
|
| 4752 | + $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 4753 | + } |
|
| 4754 | 4754 | |
| 4755 | - $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 4755 | + $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 4756 | 4756 | |
| 4757 | - geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 4758 | - } |
|
| 4757 | + geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 4758 | + } |
|
| 4759 | 4759 | |
| 4760 | - if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 4761 | - wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 4762 | - } |
|
| 4760 | + if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 4761 | + wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 4762 | + } |
|
| 4763 | 4763 | |
| 4764 | - // Post images |
|
| 4765 | - if ( !empty( $post_images ) ) {
|
|
| 4766 | - $post_images = array_unique($post_images); |
|
| 4764 | + // Post images |
|
| 4765 | + if ( !empty( $post_images ) ) {
|
|
| 4766 | + $post_images = array_unique($post_images); |
|
| 4767 | 4767 | |
| 4768 | - $old_post_images_arr = array(); |
|
| 4769 | - $saved_post_images_arr = array(); |
|
| 4768 | + $old_post_images_arr = array(); |
|
| 4769 | + $saved_post_images_arr = array(); |
|
| 4770 | 4770 | |
| 4771 | - $order = 1; |
|
| 4771 | + $order = 1; |
|
| 4772 | 4772 | |
| 4773 | - $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 4774 | - if (!empty($old_post_images)) {
|
|
| 4775 | - foreach( $old_post_images as $old_post_image ) {
|
|
| 4776 | - if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 4777 | - $old_post_images_arr[] = $old_post_image->file; |
|
| 4778 | - } |
|
| 4779 | - } |
|
| 4780 | - } |
|
| 4773 | + $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 4774 | + if (!empty($old_post_images)) {
|
|
| 4775 | + foreach( $old_post_images as $old_post_image ) {
|
|
| 4776 | + if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 4777 | + $old_post_images_arr[] = $old_post_image->file; |
|
| 4778 | + } |
|
| 4779 | + } |
|
| 4780 | + } |
|
| 4781 | 4781 | |
| 4782 | - foreach ( $post_images as $post_image ) {
|
|
| 4783 | - $image_name = basename( $post_image ); |
|
| 4784 | - $saved_post_images_arr[] = $image_name; |
|
| 4782 | + foreach ( $post_images as $post_image ) {
|
|
| 4783 | + $image_name = basename( $post_image ); |
|
| 4784 | + $saved_post_images_arr[] = $image_name; |
|
| 4785 | 4785 | |
| 4786 | - if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 4787 | - continue; // Skip if image already exists. |
|
| 4788 | - } |
|
| 4786 | + if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 4787 | + continue; // Skip if image already exists. |
|
| 4788 | + } |
|
| 4789 | 4789 | |
| 4790 | - $image_name_parts = explode( '.', $image_name ); |
|
| 4791 | - array_pop( $image_name_parts ); |
|
| 4792 | - $proper_image_name = implode( '.', $image_name_parts ); |
|
| 4790 | + $image_name_parts = explode( '.', $image_name ); |
|
| 4791 | + array_pop( $image_name_parts ); |
|
| 4792 | + $proper_image_name = implode( '.', $image_name_parts ); |
|
| 4793 | 4793 | |
| 4794 | - $arr_file_type = wp_check_filetype( $image_name ); |
|
| 4794 | + $arr_file_type = wp_check_filetype( $image_name ); |
|
| 4795 | 4795 | |
| 4796 | - if ( !empty( $arr_file_type ) ) {
|
|
| 4797 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 4796 | + if ( !empty( $arr_file_type ) ) {
|
|
| 4797 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 4798 | 4798 | |
| 4799 | - $attachment = array(); |
|
| 4800 | - $attachment['post_id'] = $saved_post_id; |
|
| 4801 | - $attachment['title'] = $proper_image_name; |
|
| 4802 | - $attachment['content'] = ''; |
|
| 4803 | - $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 4804 | - $attachment['mime_type'] = $uploaded_file_type; |
|
| 4805 | - $attachment['menu_order'] = $order; |
|
| 4806 | - $attachment['is_featured'] = 0; |
|
| 4807 | - |
|
| 4808 | - $attachment_set = ''; |
|
| 4809 | - foreach ( $attachment as $key => $val ) {
|
|
| 4810 | - if ( $val != '' ) {
|
|
| 4811 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 4812 | - } |
|
| 4813 | - } |
|
| 4814 | - $attachment_set = trim( $attachment_set, ", " ); |
|
| 4799 | + $attachment = array(); |
|
| 4800 | + $attachment['post_id'] = $saved_post_id; |
|
| 4801 | + $attachment['title'] = $proper_image_name; |
|
| 4802 | + $attachment['content'] = ''; |
|
| 4803 | + $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 4804 | + $attachment['mime_type'] = $uploaded_file_type; |
|
| 4805 | + $attachment['menu_order'] = $order; |
|
| 4806 | + $attachment['is_featured'] = 0; |
|
| 4807 | + |
|
| 4808 | + $attachment_set = ''; |
|
| 4809 | + foreach ( $attachment as $key => $val ) {
|
|
| 4810 | + if ( $val != '' ) {
|
|
| 4811 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 4812 | + } |
|
| 4813 | + } |
|
| 4814 | + $attachment_set = trim( $attachment_set, ", " ); |
|
| 4815 | 4815 | |
| 4816 | - // Add new attachment |
|
| 4817 | - $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 4816 | + // Add new attachment |
|
| 4817 | + $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 4818 | 4818 | |
| 4819 | - $order++; |
|
| 4820 | - } |
|
| 4821 | - } |
|
| 4819 | + $order++; |
|
| 4820 | + } |
|
| 4821 | + } |
|
| 4822 | 4822 | |
| 4823 | - $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 4824 | - // Remove previous attachment |
|
| 4825 | - $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 4823 | + $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 4824 | + // Remove previous attachment |
|
| 4825 | + $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 4826 | 4826 | |
| 4827 | - if ( !empty( $saved_post_images_arr ) ) {
|
|
| 4828 | - $menu_order = 1; |
|
| 4827 | + if ( !empty( $saved_post_images_arr ) ) {
|
|
| 4828 | + $menu_order = 1; |
|
| 4829 | 4829 | |
| 4830 | - foreach ( $saved_post_images_arr as $img_name ) {
|
|
| 4831 | - $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 ) ) ); |
|
| 4830 | + foreach ( $saved_post_images_arr as $img_name ) {
|
|
| 4831 | + $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 ) ) ); |
|
| 4832 | 4832 | |
| 4833 | - if( $menu_order == 1 ) {
|
|
| 4834 | - 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 ) ) ) ) {
|
|
| 4835 | - $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) ); |
|
| 4836 | - } |
|
| 4837 | - } |
|
| 4838 | - $menu_order++; |
|
| 4839 | - } |
|
| 4840 | - } |
|
| 4833 | + if( $menu_order == 1 ) {
|
|
| 4834 | + 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 ) ) ) ) {
|
|
| 4835 | + $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) ); |
|
| 4836 | + } |
|
| 4837 | + } |
|
| 4838 | + $menu_order++; |
|
| 4839 | + } |
|
| 4840 | + } |
|
| 4841 | 4841 | |
| 4842 | - if ( $order > 1 ) {
|
|
| 4843 | - $images++; |
|
| 4844 | - } |
|
| 4845 | - } |
|
| 4842 | + if ( $order > 1 ) {
|
|
| 4843 | + $images++; |
|
| 4844 | + } |
|
| 4845 | + } |
|
| 4846 | 4846 | |
| 4847 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 4848 | - do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 4847 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 4848 | + do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 4849 | 4849 | |
| 4850 | - if (isset($is_featured)) {
|
|
| 4851 | - geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 4852 | - } |
|
| 4853 | - if (isset($gd_post['expire_date'])) {
|
|
| 4854 | - geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 4855 | - } |
|
| 4856 | - } |
|
| 4850 | + if (isset($is_featured)) {
|
|
| 4851 | + geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 4852 | + } |
|
| 4853 | + if (isset($gd_post['expire_date'])) {
|
|
| 4854 | + geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 4855 | + } |
|
| 4856 | + } |
|
| 4857 | 4857 | |
| 4858 | - // WPML |
|
| 4859 | - if ($is_wpml && $language != '') {
|
|
| 4860 | - $sitepress->switch_lang($active_lang, true); |
|
| 4861 | - } |
|
| 4862 | - // WPML |
|
| 4863 | - } |
|
| 4864 | - } |
|
| 4865 | - } |
|
| 4858 | + // WPML |
|
| 4859 | + if ($is_wpml && $language != '') {
|
|
| 4860 | + $sitepress->switch_lang($active_lang, true); |
|
| 4861 | + } |
|
| 4862 | + // WPML |
|
| 4863 | + } |
|
| 4864 | + } |
|
| 4865 | + } |
|
| 4866 | 4866 | |
| 4867 | - //undo some stuff to make the import quicker |
|
| 4868 | - wp_defer_term_counting( false ); |
|
| 4869 | - wp_defer_comment_counting( false ); |
|
| 4870 | - $wpdb->query( 'COMMIT;' ); |
|
| 4871 | - $wpdb->query( 'SET autocommit = 1;' ); |
|
| 4872 | - |
|
| 4873 | - $json = array(); |
|
| 4874 | - $json['processed'] = $processed_actual; |
|
| 4875 | - $json['created'] = $created; |
|
| 4876 | - $json['updated'] = $updated; |
|
| 4877 | - $json['skipped'] = $skipped; |
|
| 4878 | - $json['invalid'] = $invalid; |
|
| 4879 | - $json['invalid_addr'] = $invalid_addr; |
|
| 4880 | - $json['images'] = $images; |
|
| 4867 | + //undo some stuff to make the import quicker |
|
| 4868 | + wp_defer_term_counting( false ); |
|
| 4869 | + wp_defer_comment_counting( false ); |
|
| 4870 | + $wpdb->query( 'COMMIT;' ); |
|
| 4871 | + $wpdb->query( 'SET autocommit = 1;' ); |
|
| 4872 | + |
|
| 4873 | + $json = array(); |
|
| 4874 | + $json['processed'] = $processed_actual; |
|
| 4875 | + $json['created'] = $created; |
|
| 4876 | + $json['updated'] = $updated; |
|
| 4877 | + $json['skipped'] = $skipped; |
|
| 4878 | + $json['invalid'] = $invalid; |
|
| 4879 | + $json['invalid_addr'] = $invalid_addr; |
|
| 4880 | + $json['images'] = $images; |
|
| 4881 | 4881 | |
| 4882 | - wp_send_json( $json ); |
|
| 4883 | - exit; |
|
| 4884 | - } else if ( $task == 'import_loc' ) {
|
|
| 4885 | - global $gd_post_types; |
|
| 4886 | - $gd_post_types = $post_types; |
|
| 4882 | + wp_send_json( $json ); |
|
| 4883 | + exit; |
|
| 4884 | + } else if ( $task == 'import_loc' ) {
|
|
| 4885 | + global $gd_post_types; |
|
| 4886 | + $gd_post_types = $post_types; |
|
| 4887 | 4887 | |
| 4888 | - if (!empty($file)) {
|
|
| 4889 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4888 | + if (!empty($file)) {
|
|
| 4889 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4890 | 4890 | |
| 4891 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4892 | - $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4893 | - wp_send_json( $json ); |
|
| 4894 | - } |
|
| 4891 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4892 | + $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4893 | + wp_send_json( $json ); |
|
| 4894 | + } |
|
| 4895 | 4895 | |
| 4896 | - $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
|
|
| 4897 | - $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
| 4898 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4899 | - $index = $processed + $i; |
|
| 4896 | + $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
|
|
| 4897 | + $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
| 4898 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4899 | + $index = $processed + $i; |
|
| 4900 | 4900 | |
| 4901 | - if (isset($file[$index])) {
|
|
| 4902 | - $row = $file[$index]; |
|
| 4903 | - $row = array_map( 'trim', $row ); |
|
| 4904 | - $data = array(); |
|
| 4901 | + if (isset($file[$index])) {
|
|
| 4902 | + $row = $file[$index]; |
|
| 4903 | + $row = array_map( 'trim', $row ); |
|
| 4904 | + $data = array(); |
|
| 4905 | 4905 | |
| 4906 | - foreach ($columns as $c => $column ) {
|
|
| 4907 | - 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'))) {
|
|
| 4908 | - $data[$column] = $row[$c]; |
|
| 4909 | - } |
|
| 4910 | - } |
|
| 4906 | + foreach ($columns as $c => $column ) {
|
|
| 4907 | + 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'))) {
|
|
| 4908 | + $data[$column] = $row[$c]; |
|
| 4909 | + } |
|
| 4910 | + } |
|
| 4911 | 4911 | |
| 4912 | - if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 4913 | - $invalid++; |
|
| 4914 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4915 | - continue; |
|
| 4916 | - } |
|
| 4912 | + if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 4913 | + $invalid++; |
|
| 4914 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4915 | + continue; |
|
| 4916 | + } |
|
| 4917 | 4917 | |
| 4918 | - $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 4918 | + $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 4919 | 4919 | |
| 4920 | - if ( $import_choice == 'update' ) {
|
|
| 4921 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4922 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4923 | - $updated++; |
|
| 4924 | - } else {
|
|
| 4925 | - $invalid++; |
|
| 4926 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4927 | - } |
|
| 4928 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4929 | - $data['location_id'] = (int)$location->location_id; |
|
| 4920 | + if ( $import_choice == 'update' ) {
|
|
| 4921 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4922 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4923 | + $updated++; |
|
| 4924 | + } else {
|
|
| 4925 | + $invalid++; |
|
| 4926 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4927 | + } |
|
| 4928 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4929 | + $data['location_id'] = (int)$location->location_id; |
|
| 4930 | 4930 | |
| 4931 | - if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 4932 | - $data['location_id'] = (int)$location->location_id; |
|
| 4933 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 4934 | - $data['location_id'] = (int)$location->location_id; |
|
| 4935 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 4936 | - $data['location_id'] = (int)$location->location_id; |
|
| 4937 | - } |
|
| 4931 | + if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 4932 | + $data['location_id'] = (int)$location->location_id; |
|
| 4933 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 4934 | + $data['location_id'] = (int)$location->location_id; |
|
| 4935 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 4936 | + $data['location_id'] = (int)$location->location_id; |
|
| 4937 | + } |
|
| 4938 | 4938 | |
| 4939 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4940 | - $updated++; |
|
| 4941 | - } else {
|
|
| 4942 | - $invalid++; |
|
| 4943 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4944 | - } |
|
| 4945 | - } else {
|
|
| 4946 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4947 | - $created++; |
|
| 4948 | - } else {
|
|
| 4949 | - $invalid++; |
|
| 4950 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4951 | - } |
|
| 4952 | - } |
|
| 4953 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 4954 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4955 | - $skipped++; |
|
| 4956 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4957 | - $skipped++; |
|
| 4958 | - } else {
|
|
| 4959 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4960 | - $created++; |
|
| 4961 | - } else {
|
|
| 4962 | - $invalid++; |
|
| 4963 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4964 | - } |
|
| 4965 | - } |
|
| 4966 | - } else {
|
|
| 4967 | - $invalid++; |
|
| 4968 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4969 | - } |
|
| 4970 | - } |
|
| 4971 | - } |
|
| 4972 | - } |
|
| 4939 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4940 | + $updated++; |
|
| 4941 | + } else {
|
|
| 4942 | + $invalid++; |
|
| 4943 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4944 | + } |
|
| 4945 | + } else {
|
|
| 4946 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4947 | + $created++; |
|
| 4948 | + } else {
|
|
| 4949 | + $invalid++; |
|
| 4950 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4951 | + } |
|
| 4952 | + } |
|
| 4953 | + } elseif ( $import_choice == 'skip' ) {
|
|
| 4954 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4955 | + $skipped++; |
|
| 4956 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4957 | + $skipped++; |
|
| 4958 | + } else {
|
|
| 4959 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4960 | + $created++; |
|
| 4961 | + } else {
|
|
| 4962 | + $invalid++; |
|
| 4963 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4964 | + } |
|
| 4965 | + } |
|
| 4966 | + } else {
|
|
| 4967 | + $invalid++; |
|
| 4968 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4969 | + } |
|
| 4970 | + } |
|
| 4971 | + } |
|
| 4972 | + } |
|
| 4973 | 4973 | |
| 4974 | - $json = array(); |
|
| 4975 | - $json['processed'] = $limit; |
|
| 4976 | - $json['created'] = $created; |
|
| 4977 | - $json['updated'] = $updated; |
|
| 4978 | - $json['skipped'] = $skipped; |
|
| 4979 | - $json['invalid'] = $invalid; |
|
| 4980 | - $json['images'] = $images; |
|
| 4974 | + $json = array(); |
|
| 4975 | + $json['processed'] = $limit; |
|
| 4976 | + $json['created'] = $created; |
|
| 4977 | + $json['updated'] = $updated; |
|
| 4978 | + $json['skipped'] = $skipped; |
|
| 4979 | + $json['invalid'] = $invalid; |
|
| 4980 | + $json['images'] = $images; |
|
| 4981 | 4981 | |
| 4982 | - wp_send_json( $json ); |
|
| 4983 | - } else if ( $task == 'import_hood' ) {
|
|
| 4984 | - if (!empty($file)) {
|
|
| 4985 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4982 | + wp_send_json( $json ); |
|
| 4983 | + } else if ( $task == 'import_hood' ) {
|
|
| 4984 | + if (!empty($file)) {
|
|
| 4985 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4986 | 4986 | |
| 4987 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4988 | - $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4989 | - wp_send_json( $json ); |
|
| 4990 | - } |
|
| 4987 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4988 | + $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4989 | + wp_send_json( $json ); |
|
| 4990 | + } |
|
| 4991 | 4991 | |
| 4992 | - $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
|
|
| 4993 | - $gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' ); |
|
| 4994 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4995 | - $index = $processed + $i; |
|
| 4992 | + $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
|
|
| 4993 | + $gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' ); |
|
| 4994 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4995 | + $index = $processed + $i; |
|
| 4996 | 4996 | |
| 4997 | - if (isset($file[$index])) {
|
|
| 4998 | - $row = $file[$index]; |
|
| 4999 | - $row = array_map( 'trim', $row ); |
|
| 5000 | - $data = array(); |
|
| 4997 | + if (isset($file[$index])) {
|
|
| 4998 | + $row = $file[$index]; |
|
| 4999 | + $row = array_map( 'trim', $row ); |
|
| 5000 | + $data = array(); |
|
| 5001 | 5001 | |
| 5002 | - foreach ($columns as $c => $column) {
|
|
| 5003 | - if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
|
|
| 5004 | - $data[$column] = sanitize_text_field($row[$c]); |
|
| 5005 | - } |
|
| 5006 | - } |
|
| 5002 | + foreach ($columns as $c => $column) {
|
|
| 5003 | + if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
|
|
| 5004 | + $data[$column] = sanitize_text_field($row[$c]); |
|
| 5005 | + } |
|
| 5006 | + } |
|
| 5007 | 5007 | |
| 5008 | - if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
|
|
| 5009 | - $invalid++; |
|
| 5010 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5011 | - continue; |
|
| 5012 | - } |
|
| 5008 | + if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
|
|
| 5009 | + $invalid++; |
|
| 5010 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5011 | + continue; |
|
| 5012 | + } |
|
| 5013 | 5013 | |
| 5014 | - $location_info = array(); |
|
| 5015 | - if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
|
|
| 5016 | - $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
|
|
| 5017 | - } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
|
|
| 5018 | - $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
|
|
| 5019 | - } |
|
| 5014 | + $location_info = array(); |
|
| 5015 | + if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
|
|
| 5016 | + $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
|
|
| 5017 | + } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
|
|
| 5018 | + $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
|
|
| 5019 | + } |
|
| 5020 | 5020 | |
| 5021 | - if (empty($location_info)) {
|
|
| 5022 | - $invalid++; |
|
| 5023 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5024 | - continue; |
|
| 5025 | - } |
|
| 5021 | + if (empty($location_info)) {
|
|
| 5022 | + $invalid++; |
|
| 5023 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5024 | + continue; |
|
| 5025 | + } |
|
| 5026 | 5026 | |
| 5027 | - $location_id = $location_info->location_id; |
|
| 5027 | + $location_id = $location_info->location_id; |
|
| 5028 | 5028 | |
| 5029 | - $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0; |
|
| 5029 | + $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0; |
|
| 5030 | 5030 | |
| 5031 | - $hood_data = array(); |
|
| 5032 | - $hood_data['hood_name'] = $data['neighbourhood_name']; |
|
| 5033 | - $hood_data['hood_slug'] = $data['neighbourhood_slug']; |
|
| 5034 | - $hood_data['hood_latitude'] = $data['latitude']; |
|
| 5035 | - $hood_data['hood_longitude'] = $data['longitude']; |
|
| 5036 | - $hood_data['hood_location_id'] = $location_id; |
|
| 5031 | + $hood_data = array(); |
|
| 5032 | + $hood_data['hood_name'] = $data['neighbourhood_name']; |
|
| 5033 | + $hood_data['hood_slug'] = $data['neighbourhood_slug']; |
|
| 5034 | + $hood_data['hood_latitude'] = $data['latitude']; |
|
| 5035 | + $hood_data['hood_longitude'] = $data['longitude']; |
|
| 5036 | + $hood_data['hood_location_id'] = $location_id; |
|
| 5037 | 5037 | |
| 5038 | - if ( $import_choice == 'update' ) {
|
|
| 5039 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 5040 | - $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
| 5038 | + if ( $import_choice == 'update' ) {
|
|
| 5039 | + if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 5040 | + $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
| 5041 | 5041 | |
| 5042 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5043 | - $updated++; |
|
| 5044 | - } else {
|
|
| 5045 | - $invalid++; |
|
| 5046 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5047 | - } |
|
| 5048 | - } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 5049 | - $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
| 5042 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5043 | + $updated++; |
|
| 5044 | + } else {
|
|
| 5045 | + $invalid++; |
|
| 5046 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5047 | + } |
|
| 5048 | + } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 5049 | + $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
| 5050 | 5050 | |
| 5051 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5052 | - $updated++; |
|
| 5053 | - } else {
|
|
| 5054 | - $invalid++; |
|
| 5055 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5056 | - } |
|
| 5057 | - } else {
|
|
| 5058 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5059 | - $created++; |
|
| 5060 | - } else {
|
|
| 5061 | - $invalid++; |
|
| 5062 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5063 | - } |
|
| 5064 | - } |
|
| 5065 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 5066 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 5067 | - $skipped++; |
|
| 5068 | - } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 5069 | - $skipped++; |
|
| 5070 | - } else {
|
|
| 5051 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5052 | + $updated++; |
|
| 5053 | + } else {
|
|
| 5054 | + $invalid++; |
|
| 5055 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5056 | + } |
|
| 5057 | + } else {
|
|
| 5058 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5059 | + $created++; |
|
| 5060 | + } else {
|
|
| 5061 | + $invalid++; |
|
| 5062 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5063 | + } |
|
| 5064 | + } |
|
| 5065 | + } elseif ( $import_choice == 'skip' ) {
|
|
| 5066 | + if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 5067 | + $skipped++; |
|
| 5068 | + } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 5069 | + $skipped++; |
|
| 5070 | + } else {
|
|
| 5071 | 5071 | |
| 5072 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5073 | - $created++; |
|
| 5074 | - } else {
|
|
| 5075 | - $invalid++; |
|
| 5076 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5077 | - } |
|
| 5078 | - } |
|
| 5079 | - } else {
|
|
| 5080 | - $invalid++; |
|
| 5081 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5082 | - } |
|
| 5083 | - } |
|
| 5084 | - } |
|
| 5085 | - } |
|
| 5072 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 5073 | + $created++; |
|
| 5074 | + } else {
|
|
| 5075 | + $invalid++; |
|
| 5076 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5077 | + } |
|
| 5078 | + } |
|
| 5079 | + } else {
|
|
| 5080 | + $invalid++; |
|
| 5081 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5082 | + } |
|
| 5083 | + } |
|
| 5084 | + } |
|
| 5085 | + } |
|
| 5086 | 5086 | |
| 5087 | - $json = array(); |
|
| 5088 | - $json['processed'] = $limit; |
|
| 5089 | - $json['created'] = $created; |
|
| 5090 | - $json['updated'] = $updated; |
|
| 5091 | - $json['skipped'] = $skipped; |
|
| 5092 | - $json['invalid'] = $invalid; |
|
| 5093 | - $json['images'] = $images; |
|
| 5087 | + $json = array(); |
|
| 5088 | + $json['processed'] = $limit; |
|
| 5089 | + $json['created'] = $created; |
|
| 5090 | + $json['updated'] = $updated; |
|
| 5091 | + $json['skipped'] = $skipped; |
|
| 5092 | + $json['invalid'] = $invalid; |
|
| 5093 | + $json['images'] = $images; |
|
| 5094 | 5094 | |
| 5095 | - wp_send_json( $json ); |
|
| 5096 | - } |
|
| 5097 | - } |
|
| 5098 | - break; |
|
| 5099 | - case 'import_finish':{
|
|
| 5100 | - /** |
|
| 5101 | - * Run an action when an import finishes. |
|
| 5102 | - * |
|
| 5103 | - * This action can be used to fire functions after an import ends. |
|
| 5104 | - * |
|
| 5105 | - * @since 1.5.3 |
|
| 5106 | - * @package GeoDirectory |
|
| 5107 | - */ |
|
| 5108 | - do_action('geodir_import_finished');
|
|
| 5109 | - } |
|
| 5110 | - break; |
|
| 5095 | + wp_send_json( $json ); |
|
| 5096 | + } |
|
| 5097 | + } |
|
| 5098 | + break; |
|
| 5099 | + case 'import_finish':{
|
|
| 5100 | + /** |
|
| 5101 | + * Run an action when an import finishes. |
|
| 5102 | + * |
|
| 5103 | + * This action can be used to fire functions after an import ends. |
|
| 5104 | + * |
|
| 5105 | + * @since 1.5.3 |
|
| 5106 | + * @package GeoDirectory |
|
| 5107 | + */ |
|
| 5108 | + do_action('geodir_import_finished');
|
|
| 5109 | + } |
|
| 5110 | + break; |
|
| 5111 | 5111 | |
| 5112 | - } |
|
| 5113 | - echo '0'; |
|
| 5114 | - gd_die(); |
|
| 5112 | + } |
|
| 5113 | + echo '0'; |
|
| 5114 | + gd_die(); |
|
| 5115 | 5115 | } |
| 5116 | 5116 | |
| 5117 | 5117 | /** |
@@ -5155,12 +5155,12 @@ discard block |
||
| 5155 | 5155 | $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
| 5156 | 5156 | } |
| 5157 | 5157 | |
| 5158 | - if( !empty( $term ) ) {
|
|
| 5158 | + if( !empty( $term ) ) {
|
|
| 5159 | 5159 | $result = wp_insert_term( $term, $taxonomy, $args ); |
| 5160 | - if( !is_wp_error( $result ) ) {
|
|
| 5161 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5162 | - } |
|
| 5163 | - } |
|
| 5160 | + if( !is_wp_error( $result ) ) {
|
|
| 5161 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5162 | + } |
|
| 5163 | + } |
|
| 5164 | 5164 | |
| 5165 | 5165 | return false; |
| 5166 | 5166 | } |
@@ -5206,16 +5206,16 @@ discard block |
||
| 5206 | 5206 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
| 5207 | 5207 | |
| 5208 | 5208 | if( !is_wp_error( $result ) ) {
|
| 5209 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5210 | - } |
|
| 5209 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5210 | + } |
|
| 5211 | 5211 | } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
| 5212 | 5212 | $term_data['term_id'] = $term_info['term_id']; |
| 5213 | 5213 | |
| 5214 | 5214 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
| 5215 | 5215 | |
| 5216 | 5216 | if( !is_wp_error( $result ) ) {
|
| 5217 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5218 | - } |
|
| 5217 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5218 | + } |
|
| 5219 | 5219 | } else {
|
| 5220 | 5220 | return geodir_imex_insert_term( $taxonomy, $term_data ); |
| 5221 | 5221 | } |
@@ -5236,37 +5236,37 @@ discard block |
||
| 5236 | 5236 | * @return int Posts count. |
| 5237 | 5237 | */ |
| 5238 | 5238 | function geodir_get_posts_count( $post_type ) {
|
| 5239 | - global $wpdb, $plugin_prefix; |
|
| 5239 | + global $wpdb, $plugin_prefix; |
|
| 5240 | 5240 | |
| 5241 | - if ( !post_type_exists( $post_type ) ) {
|
|
| 5242 | - return 0; |
|
| 5243 | - } |
|
| 5241 | + if ( !post_type_exists( $post_type ) ) {
|
|
| 5242 | + return 0; |
|
| 5243 | + } |
|
| 5244 | 5244 | |
| 5245 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5245 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5246 | 5246 | |
| 5247 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5248 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5249 | - $where_statuses = ''; |
|
| 5250 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5251 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5252 | - } |
|
| 5247 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5248 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5249 | + $where_statuses = ''; |
|
| 5250 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5251 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5252 | + } |
|
| 5253 | 5253 | |
| 5254 | - $query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
|
|
| 5254 | + $query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
|
|
| 5255 | 5255 | |
| 5256 | - $posts_count = (int)$wpdb->get_var( $query ); |
|
| 5256 | + $posts_count = (int)$wpdb->get_var( $query ); |
|
| 5257 | 5257 | |
| 5258 | - /** |
|
| 5259 | - * Modify returned post counts for the current post type. |
|
| 5260 | - * |
|
| 5261 | - * @since 1.4.6 |
|
| 5262 | - * @package GeoDirectory |
|
| 5263 | - * |
|
| 5264 | - * @param int $posts_count Post counts. |
|
| 5265 | - * @param string $post_type Post type. |
|
| 5266 | - */ |
|
| 5267 | - $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5268 | - |
|
| 5269 | - return $posts_count; |
|
| 5258 | + /** |
|
| 5259 | + * Modify returned post counts for the current post type. |
|
| 5260 | + * |
|
| 5261 | + * @since 1.4.6 |
|
| 5262 | + * @package GeoDirectory |
|
| 5263 | + * |
|
| 5264 | + * @param int $posts_count Post counts. |
|
| 5265 | + * @param string $post_type Post type. |
|
| 5266 | + */ |
|
| 5267 | + $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5268 | + |
|
| 5269 | + return $posts_count; |
|
| 5270 | 5270 | } |
| 5271 | 5271 | |
| 5272 | 5272 | /** |
@@ -5294,9 +5294,9 @@ discard block |
||
| 5294 | 5294 | |
| 5295 | 5295 | if ( !empty( $posts ) ) {
|
| 5296 | 5296 | $is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' ); |
| 5297 | - $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 5298 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5299 | - $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
|
|
| 5297 | + $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 5298 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5299 | + $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
|
|
| 5300 | 5300 | |
| 5301 | 5301 | $csv_row = array(); |
| 5302 | 5302 | $csv_row[] = 'post_id'; |
@@ -5340,11 +5340,11 @@ discard block |
||
| 5340 | 5340 | $csv_row[] = 'post_zip'; |
| 5341 | 5341 | $csv_row[] = 'post_latitude'; |
| 5342 | 5342 | $csv_row[] = 'post_longitude'; |
| 5343 | - if ($neighbourhood_active) {
|
|
| 5344 | - $csv_row[] = 'post_neighbourhood'; |
|
| 5345 | - $csv_row[] = 'neighbourhood_latitude'; |
|
| 5346 | - $csv_row[] = 'neighbourhood_longitude'; |
|
| 5347 | - } |
|
| 5343 | + if ($neighbourhood_active) {
|
|
| 5344 | + $csv_row[] = 'post_neighbourhood'; |
|
| 5345 | + $csv_row[] = 'neighbourhood_latitude'; |
|
| 5346 | + $csv_row[] = 'neighbourhood_longitude'; |
|
| 5347 | + } |
|
| 5348 | 5348 | $csv_row[] = 'geodir_timing'; |
| 5349 | 5349 | $csv_row[] = 'geodir_contact'; |
| 5350 | 5350 | $csv_row[] = 'geodir_email'; |
@@ -5379,7 +5379,7 @@ discard block |
||
| 5379 | 5379 | $csv_rows[] = $csv_row; |
| 5380 | 5380 | |
| 5381 | 5381 | $images_count = 5; |
| 5382 | - $xx=0; |
|
| 5382 | + $xx=0; |
|
| 5383 | 5383 | foreach ( $posts as $post ) {$xx++;
|
| 5384 | 5384 | $post_id = $post['ID']; |
| 5385 | 5385 | |
@@ -5522,21 +5522,21 @@ discard block |
||
| 5522 | 5522 | $csv_row[] = $post_info['post_zip']; // post_zip |
| 5523 | 5523 | $csv_row[] = $post_info['post_latitude']; // post_latitude |
| 5524 | 5524 | $csv_row[] = $post_info['post_longitude']; // post_longitude |
| 5525 | - if ($neighbourhood_active) {
|
|
| 5526 | - $post_neighbourhood = ''; |
|
| 5527 | - $neighbourhood_latitude = ''; |
|
| 5528 | - $neighbourhood_longitude = ''; |
|
| 5529 | - if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
|
|
| 5530 | - if (!empty($hood_info)) {
|
|
| 5531 | - $post_neighbourhood = $hood_info->hood_name; |
|
| 5532 | - $neighbourhood_latitude = $hood_info->hood_latitude; |
|
| 5533 | - $neighbourhood_longitude = $hood_info->hood_longitude; |
|
| 5534 | - } |
|
| 5535 | - } |
|
| 5536 | - $csv_row[] = $post_neighbourhood; // post_neighbourhood |
|
| 5537 | - $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude |
|
| 5538 | - $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude |
|
| 5539 | - } |
|
| 5525 | + if ($neighbourhood_active) {
|
|
| 5526 | + $post_neighbourhood = ''; |
|
| 5527 | + $neighbourhood_latitude = ''; |
|
| 5528 | + $neighbourhood_longitude = ''; |
|
| 5529 | + if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
|
|
| 5530 | + if (!empty($hood_info)) {
|
|
| 5531 | + $post_neighbourhood = $hood_info->hood_name; |
|
| 5532 | + $neighbourhood_latitude = $hood_info->hood_latitude; |
|
| 5533 | + $neighbourhood_longitude = $hood_info->hood_longitude; |
|
| 5534 | + } |
|
| 5535 | + } |
|
| 5536 | + $csv_row[] = $post_neighbourhood; // post_neighbourhood |
|
| 5537 | + $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude |
|
| 5538 | + $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude |
|
| 5539 | + } |
|
| 5540 | 5540 | $csv_row[] = $post_info['geodir_timing']; // geodir_timing |
| 5541 | 5541 | $csv_row[] = $post_info['geodir_contact']; // geodir_contact |
| 5542 | 5542 | $csv_row[] = $post_info['geodir_email']; // geodir_email |
@@ -5607,55 +5607,55 @@ discard block |
||
| 5607 | 5607 | * @return array Array of posts data. |
| 5608 | 5608 | */ |
| 5609 | 5609 | function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
| 5610 | - global $wpdb, $plugin_prefix; |
|
| 5610 | + global $wpdb, $plugin_prefix; |
|
| 5611 | 5611 | |
| 5612 | - if ( ! post_type_exists( $post_type ) ) |
|
| 5613 | - return new stdClass; |
|
| 5612 | + if ( ! post_type_exists( $post_type ) ) |
|
| 5613 | + return new stdClass; |
|
| 5614 | 5614 | |
| 5615 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5615 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5616 | 5616 | |
| 5617 | - $limit = ''; |
|
| 5618 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 5619 | - $offset = ( $page_no - 1 ) * $per_page; |
|
| 5617 | + $limit = ''; |
|
| 5618 | + if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 5619 | + $offset = ( $page_no - 1 ) * $per_page; |
|
| 5620 | 5620 | |
| 5621 | - if ( $offset > 0 ) {
|
|
| 5622 | - $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 5623 | - } else {
|
|
| 5624 | - $limit = " LIMIT " . $per_page; |
|
| 5625 | - } |
|
| 5626 | - } |
|
| 5621 | + if ( $offset > 0 ) {
|
|
| 5622 | + $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 5623 | + } else {
|
|
| 5624 | + $limit = " LIMIT " . $per_page; |
|
| 5625 | + } |
|
| 5626 | + } |
|
| 5627 | 5627 | |
| 5628 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5629 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5630 | - $where_statuses = ''; |
|
| 5631 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5632 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5633 | - } |
|
| 5628 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5629 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5630 | + $where_statuses = ''; |
|
| 5631 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5632 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5633 | + } |
|
| 5634 | + |
|
| 5635 | + $query = "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit;
|
|
| 5636 | + /** |
|
| 5637 | + * Modify returned posts SQL query for the current post type. |
|
| 5638 | + * |
|
| 5639 | + * @since 1.4.6 |
|
| 5640 | + * @package GeoDirectory |
|
| 5641 | + * |
|
| 5642 | + * @param int $query The SQL query. |
|
| 5643 | + * @param string $post_type Post type. |
|
| 5644 | + */ |
|
| 5645 | + $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 5646 | + |
|
| 5647 | + $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 5634 | 5648 | |
| 5635 | - $query = "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit;
|
|
| 5636 | - /** |
|
| 5637 | - * Modify returned posts SQL query for the current post type. |
|
| 5638 | - * |
|
| 5639 | - * @since 1.4.6 |
|
| 5640 | - * @package GeoDirectory |
|
| 5641 | - * |
|
| 5642 | - * @param int $query The SQL query. |
|
| 5643 | - * @param string $post_type Post type. |
|
| 5644 | - */ |
|
| 5645 | - $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 5646 | - |
|
| 5647 | - $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 5648 | - |
|
| 5649 | - /** |
|
| 5650 | - * Modify returned post results for the current post type. |
|
| 5651 | - * |
|
| 5652 | - * @since 1.4.6 |
|
| 5653 | - * @package GeoDirectory |
|
| 5654 | - * |
|
| 5655 | - * @param object $results An object containing all post ids. |
|
| 5656 | - * @param string $post_type Post type. |
|
| 5657 | - */ |
|
| 5658 | - return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 5649 | + /** |
|
| 5650 | + * Modify returned post results for the current post type. |
|
| 5651 | + * |
|
| 5652 | + * @since 1.4.6 |
|
| 5653 | + * @package GeoDirectory |
|
| 5654 | + * |
|
| 5655 | + * @param object $results An object containing all post ids. |
|
| 5656 | + * @param string $post_type Post type. |
|
| 5657 | + */ |
|
| 5658 | + return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 5659 | 5659 | } |
| 5660 | 5660 | |
| 5661 | 5661 | /** |
@@ -5673,23 +5673,23 @@ discard block |
||
| 5673 | 5673 | * @return string The SQL query. |
| 5674 | 5674 | */ |
| 5675 | 5675 | function geodir_imex_get_events_query( $query, $post_type ) {
|
| 5676 | - if ( $post_type == 'gd_event' ) {
|
|
| 5677 | - global $wpdb, $plugin_prefix; |
|
| 5676 | + if ( $post_type == 'gd_event' ) {
|
|
| 5677 | + global $wpdb, $plugin_prefix; |
|
| 5678 | 5678 | |
| 5679 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5680 | - $schedule_table = EVENT_SCHEDULE; |
|
| 5679 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5680 | + $schedule_table = EVENT_SCHEDULE; |
|
| 5681 | 5681 | |
| 5682 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5683 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5684 | - $where_statuses = ''; |
|
| 5685 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5686 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5687 | - } |
|
| 5682 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5683 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5684 | + $where_statuses = ''; |
|
| 5685 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5686 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5687 | + } |
|
| 5688 | 5688 | |
| 5689 | - $query = "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC";
|
|
| 5690 | - } |
|
| 5689 | + $query = "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC";
|
|
| 5690 | + } |
|
| 5691 | 5691 | |
| 5692 | - return $query; |
|
| 5692 | + return $query; |
|
| 5693 | 5693 | } |
| 5694 | 5694 | |
| 5695 | 5695 | /** |
@@ -5711,36 +5711,36 @@ discard block |
||
| 5711 | 5711 | * @return int Total terms count. |
| 5712 | 5712 | */ |
| 5713 | 5713 | function geodir_get_terms_count( $post_type ) {
|
| 5714 | - $args = array( 'hide_empty' => 0 ); |
|
| 5714 | + $args = array( 'hide_empty' => 0 ); |
|
| 5715 | 5715 | |
| 5716 | - remove_all_filters( 'get_terms' ); |
|
| 5716 | + remove_all_filters( 'get_terms' ); |
|
| 5717 | 5717 | |
| 5718 | - $taxonomy = $post_type . 'category'; |
|
| 5718 | + $taxonomy = $post_type . 'category'; |
|
| 5719 | 5719 | |
| 5720 | - // WPML |
|
| 5721 | - $is_wpml = geodir_is_wpml(); |
|
| 5722 | - $active_lang = 'all'; |
|
| 5723 | - if ( $is_wpml ) {
|
|
| 5724 | - global $sitepress; |
|
| 5725 | - $active_lang = $sitepress->get_current_language(); |
|
| 5720 | + // WPML |
|
| 5721 | + $is_wpml = geodir_is_wpml(); |
|
| 5722 | + $active_lang = 'all'; |
|
| 5723 | + if ( $is_wpml ) {
|
|
| 5724 | + global $sitepress; |
|
| 5725 | + $active_lang = $sitepress->get_current_language(); |
|
| 5726 | 5726 | |
| 5727 | - if ( $active_lang != 'all' ) {
|
|
| 5728 | - $sitepress->switch_lang( 'all', true ); |
|
| 5729 | - } |
|
| 5730 | - } |
|
| 5731 | - // WPML |
|
| 5727 | + if ( $active_lang != 'all' ) {
|
|
| 5728 | + $sitepress->switch_lang( 'all', true ); |
|
| 5729 | + } |
|
| 5730 | + } |
|
| 5731 | + // WPML |
|
| 5732 | 5732 | |
| 5733 | - $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 5733 | + $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 5734 | 5734 | |
| 5735 | - // WPML |
|
| 5736 | - if ( $is_wpml && $active_lang !== 'all' ) {
|
|
| 5737 | - global $sitepress; |
|
| 5738 | - $sitepress->switch_lang( $active_lang, true ); |
|
| 5739 | - } |
|
| 5740 | - // WPML |
|
| 5741 | - $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 5735 | + // WPML |
|
| 5736 | + if ( $is_wpml && $active_lang !== 'all' ) {
|
|
| 5737 | + global $sitepress; |
|
| 5738 | + $sitepress->switch_lang( $active_lang, true ); |
|
| 5739 | + } |
|
| 5740 | + // WPML |
|
| 5741 | + $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 5742 | 5742 | |
| 5743 | - return $count_terms; |
|
| 5743 | + return $count_terms; |
|
| 5744 | 5744 | } |
| 5745 | 5745 | |
| 5746 | 5746 | /** |
@@ -5779,11 +5779,11 @@ discard block |
||
| 5779 | 5779 | $csv_row[] = 'cat_posttype'; |
| 5780 | 5780 | $csv_row[] = 'cat_parent'; |
| 5781 | 5781 | $csv_row[] = 'cat_schema'; |
| 5782 | - // WPML |
|
| 5782 | + // WPML |
|
| 5783 | 5783 | $is_wpml = geodir_is_wpml(); |
| 5784 | 5784 | if ($is_wpml) {
|
| 5785 | 5785 | $csv_row[] = 'cat_language'; |
| 5786 | - $csv_row[] = 'cat_id_original'; |
|
| 5786 | + $csv_row[] = 'cat_id_original'; |
|
| 5787 | 5787 | } |
| 5788 | 5788 | // WPML |
| 5789 | 5789 | $csv_row[] = 'cat_description'; |
@@ -5813,10 +5813,10 @@ discard block |
||
| 5813 | 5813 | $csv_row[] = $post_type; |
| 5814 | 5814 | $csv_row[] = $cat_parent; |
| 5815 | 5815 | $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); |
| 5816 | - // WPML |
|
| 5816 | + // WPML |
|
| 5817 | 5817 | if ($is_wpml) {
|
| 5818 | 5818 | $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); |
| 5819 | - $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
| 5819 | + $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
| 5820 | 5820 | } |
| 5821 | 5821 | // WPML |
| 5822 | 5822 | $csv_row[] = $term->description; |
@@ -6412,43 +6412,43 @@ discard block |
||
| 6412 | 6412 | * @param string $status Post status. |
| 6413 | 6413 | */ |
| 6414 | 6414 | function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') {
|
| 6415 | - global $wpdb, $current_user; |
|
| 6416 | - |
|
| 6417 | - $option_value = get_option($option); |
|
| 6418 | - |
|
| 6419 | - if ($option_value > 0) : |
|
| 6420 | - if (get_post($option_value)) : |
|
| 6421 | - // Page exists |
|
| 6422 | - return; |
|
| 6423 | - endif; |
|
| 6424 | - endif; |
|
| 6425 | - |
|
| 6426 | - $page_found = $wpdb->get_var( |
|
| 6427 | - $wpdb->prepare( |
|
| 6428 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 6429 | - array($slug) |
|
| 6430 | - ) |
|
| 6431 | - ); |
|
| 6432 | - |
|
| 6433 | - if ($page_found) : |
|
| 6434 | - // Page exists |
|
| 6435 | - if (!$option_value) update_option($option, $page_found); |
|
| 6436 | - return; |
|
| 6437 | - endif; |
|
| 6438 | - |
|
| 6439 | - $page_data = array( |
|
| 6440 | - 'post_status' => $status, |
|
| 6441 | - 'post_type' => 'page', |
|
| 6442 | - 'post_author' => $current_user->ID, |
|
| 6443 | - 'post_name' => $slug, |
|
| 6444 | - 'post_title' => $page_title, |
|
| 6445 | - 'post_content' => $page_content, |
|
| 6446 | - 'post_parent' => $post_parent, |
|
| 6447 | - 'comment_status' => 'closed' |
|
| 6448 | - ); |
|
| 6449 | - $page_id = wp_insert_post($page_data); |
|
| 6450 | - |
|
| 6451 | - add_option($option, $page_id); |
|
| 6415 | + global $wpdb, $current_user; |
|
| 6416 | + |
|
| 6417 | + $option_value = get_option($option); |
|
| 6418 | + |
|
| 6419 | + if ($option_value > 0) : |
|
| 6420 | + if (get_post($option_value)) : |
|
| 6421 | + // Page exists |
|
| 6422 | + return; |
|
| 6423 | + endif; |
|
| 6424 | + endif; |
|
| 6425 | + |
|
| 6426 | + $page_found = $wpdb->get_var( |
|
| 6427 | + $wpdb->prepare( |
|
| 6428 | + "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 6429 | + array($slug) |
|
| 6430 | + ) |
|
| 6431 | + ); |
|
| 6432 | + |
|
| 6433 | + if ($page_found) : |
|
| 6434 | + // Page exists |
|
| 6435 | + if (!$option_value) update_option($option, $page_found); |
|
| 6436 | + return; |
|
| 6437 | + endif; |
|
| 6438 | + |
|
| 6439 | + $page_data = array( |
|
| 6440 | + 'post_status' => $status, |
|
| 6441 | + 'post_type' => 'page', |
|
| 6442 | + 'post_author' => $current_user->ID, |
|
| 6443 | + 'post_name' => $slug, |
|
| 6444 | + 'post_title' => $page_title, |
|
| 6445 | + 'post_content' => $page_content, |
|
| 6446 | + 'post_parent' => $post_parent, |
|
| 6447 | + 'comment_status' => 'closed' |
|
| 6448 | + ); |
|
| 6449 | + $page_id = wp_insert_post($page_data); |
|
| 6450 | + |
|
| 6451 | + add_option($option, $page_id); |
|
| 6452 | 6452 | |
| 6453 | 6453 | } |
| 6454 | 6454 | |
@@ -6479,9 +6479,9 @@ discard block |
||
| 6479 | 6479 | * @package GeoDirectory |
| 6480 | 6480 | */ |
| 6481 | 6481 | function geodir_admin_upgrade_notice() {
|
| 6482 | - $class = "error"; |
|
| 6483 | - $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 6484 | - echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
| 6482 | + $class = "error"; |
|
| 6483 | + $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 6484 | + echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
| 6485 | 6485 | } |
| 6486 | 6486 | |
| 6487 | 6487 | /** |
@@ -6494,18 +6494,18 @@ discard block |
||
| 6494 | 6494 | */ |
| 6495 | 6495 | function geodire_admin_upgrade_notice( $plugin_data, $r ) |
| 6496 | 6496 | {
|
| 6497 | - // readme contents |
|
| 6498 | - $args = array( |
|
| 6499 | - 'timeout' => 15, |
|
| 6500 | - 'redirection' => 5 |
|
| 6501 | - ); |
|
| 6502 | - $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
| 6503 | - $data = wp_remote_get( $url, $args ); |
|
| 6497 | + // readme contents |
|
| 6498 | + $args = array( |
|
| 6499 | + 'timeout' => 15, |
|
| 6500 | + 'redirection' => 5 |
|
| 6501 | + ); |
|
| 6502 | + $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
| 6503 | + $data = wp_remote_get( $url, $args ); |
|
| 6504 | 6504 | |
| 6505 | - if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
|
| 6505 | + if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
|
| 6506 | 6506 | |
| 6507 | - geodir_in_plugin_update_message($data['body']); |
|
| 6508 | - } |
|
| 6507 | + geodir_in_plugin_update_message($data['body']); |
|
| 6508 | + } |
|
| 6509 | 6509 | } |
| 6510 | 6510 | |
| 6511 | 6511 | |
@@ -6513,28 +6513,28 @@ discard block |
||
| 6513 | 6513 | * @param string $content http response body |
| 6514 | 6514 | */ |
| 6515 | 6515 | function geodir_in_plugin_update_message($content) {
|
| 6516 | - // Output Upgrade Notice |
|
| 6517 | - $matches = null; |
|
| 6518 | - $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 6519 | - $upgrade_notice = ''; |
|
| 6520 | - if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 6521 | - if(empty($matches)){return;}
|
|
| 6522 | - |
|
| 6523 | - $version = trim( $matches[1] ); |
|
| 6524 | - if($version && $version>GEODIRECTORY_VERSION){
|
|
| 6525 | - |
|
| 6526 | - |
|
| 6527 | - $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 6528 | - if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
|
|
| 6529 | - $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
| 6530 | - foreach ( $notices as $index => $line ) {
|
|
| 6531 | - $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 6532 | - } |
|
| 6533 | - $upgrade_notice .= '</div> '; |
|
| 6534 | - } |
|
| 6535 | - } |
|
| 6536 | - } |
|
| 6537 | - echo $upgrade_notice; |
|
| 6516 | + // Output Upgrade Notice |
|
| 6517 | + $matches = null; |
|
| 6518 | + $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 6519 | + $upgrade_notice = ''; |
|
| 6520 | + if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 6521 | + if(empty($matches)){return;}
|
|
| 6522 | + |
|
| 6523 | + $version = trim( $matches[1] ); |
|
| 6524 | + if($version && $version>GEODIRECTORY_VERSION){
|
|
| 6525 | + |
|
| 6526 | + |
|
| 6527 | + $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 6528 | + if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
|
|
| 6529 | + $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
| 6530 | + foreach ( $notices as $index => $line ) {
|
|
| 6531 | + $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 6532 | + } |
|
| 6533 | + $upgrade_notice .= '</div> '; |
|
| 6534 | + } |
|
| 6535 | + } |
|
| 6536 | + } |
|
| 6537 | + echo $upgrade_notice; |
|
| 6538 | 6538 | } |
| 6539 | 6539 | |
| 6540 | 6540 | /** |
@@ -6567,19 +6567,19 @@ discard block |
||
| 6567 | 6567 | * @param array Listing statuses to be skipped. |
| 6568 | 6568 | */ |
| 6569 | 6569 | function geodir_imex_export_skip_statuses() {
|
| 6570 | - $statuses = array( 'trash', 'auto-draft' ); |
|
| 6570 | + $statuses = array( 'trash', 'auto-draft' ); |
|
| 6571 | 6571 | |
| 6572 | - /** |
|
| 6573 | - * Filter the statuses to skip during GD export listings. |
|
| 6574 | - * |
|
| 6575 | - * @since 1.6.0 |
|
| 6576 | - * @package GeoDirectory |
|
| 6577 | - * |
|
| 6578 | - * @param array $statuses Listing statuses to be skipped. |
|
| 6579 | - */ |
|
| 6580 | - $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
| 6572 | + /** |
|
| 6573 | + * Filter the statuses to skip during GD export listings. |
|
| 6574 | + * |
|
| 6575 | + * @since 1.6.0 |
|
| 6576 | + * @package GeoDirectory |
|
| 6577 | + * |
|
| 6578 | + * @param array $statuses Listing statuses to be skipped. |
|
| 6579 | + */ |
|
| 6580 | + $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
| 6581 | 6581 | |
| 6582 | - return $statuses; |
|
| 6582 | + return $statuses; |
|
| 6583 | 6583 | } |
| 6584 | 6584 | |
| 6585 | 6585 | /** |
@@ -6591,15 +6591,15 @@ discard block |
||
| 6591 | 6591 | * @since 1.6.3 |
| 6592 | 6592 | */ |
| 6593 | 6593 | function geodir_admin_dequeue_scripts() {
|
| 6594 | - // EDD |
|
| 6595 | - if (wp_script_is('jquery-chosen', 'enqueued')) {
|
|
| 6596 | - wp_dequeue_script('jquery-chosen');
|
|
| 6597 | - } |
|
| 6594 | + // EDD |
|
| 6595 | + if (wp_script_is('jquery-chosen', 'enqueued')) {
|
|
| 6596 | + wp_dequeue_script('jquery-chosen');
|
|
| 6597 | + } |
|
| 6598 | 6598 | |
| 6599 | - // Ultimate Addons for Visual Composer |
|
| 6600 | - if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
|
|
| 6601 | - wp_dequeue_script('ultimate-vc-backend-script');
|
|
| 6602 | - } |
|
| 6599 | + // Ultimate Addons for Visual Composer |
|
| 6600 | + if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
|
|
| 6601 | + wp_dequeue_script('ultimate-vc-backend-script');
|
|
| 6602 | + } |
|
| 6603 | 6603 | } |
| 6604 | 6604 | |
| 6605 | 6605 | /* |
@@ -46,31 +46,31 @@ discard block |
||
| 46 | 46 | function geodir_admin_styles() |
| 47 | 47 | {
|
| 48 | 48 | |
| 49 | - wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
|
|
| 49 | + wp_register_style('geodirectory-admin-css', geodir_plugin_url().'/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
|
|
| 50 | 50 | wp_enqueue_style('geodirectory-admin-css');
|
| 51 | 51 | |
| 52 | - wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
|
|
| 52 | + wp_register_style('geodirectory-frontend-style', geodir_plugin_url().'/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
|
|
| 53 | 53 | wp_enqueue_style('geodirectory-frontend-style');
|
| 54 | 54 | |
| 55 | - wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
|
|
| 55 | + wp_register_style('geodir-chosen-style', geodir_plugin_url().'/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
|
|
| 56 | 56 | wp_enqueue_style('geodir-chosen-style');
|
| 57 | 57 | |
| 58 | - wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
|
|
| 58 | + wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url().'/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
|
|
| 59 | 59 | wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
|
| 60 | 60 | |
| 61 | - wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
|
|
| 61 | + wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url().'/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
|
|
| 62 | 62 | wp_enqueue_style('geodirectory-jquery-ui-css');
|
| 63 | 63 | |
| 64 | - wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
|
|
| 64 | + wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url().'/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
|
|
| 65 | 65 | wp_enqueue_style('geodirectory-custom-fields-css');
|
| 66 | 66 | |
| 67 | - wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
|
|
| 67 | + wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url().'/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
|
|
| 68 | 68 | wp_enqueue_style('geodirectory-pluplodar-css');
|
| 69 | 69 | |
| 70 | - wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
|
|
| 70 | + wp_register_style('geodir-rating-style', geodir_plugin_url().'/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
|
|
| 71 | 71 | wp_enqueue_style('geodir-rating-style');
|
| 72 | 72 | |
| 73 | - wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
|
|
| 73 | + wp_register_style('geodir-rtl-style', geodir_plugin_url().'/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
|
|
| 74 | 74 | wp_enqueue_style('geodir-rtl-style');
|
| 75 | 75 | |
| 76 | 76 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | wp_register_style('geodirectory-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
|
| 90 | 90 | wp_enqueue_style('geodirectory-font-awesome');
|
| 91 | 91 | |
| 92 | - wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 92 | + wp_register_script('geodirectory-admin', geodir_plugin_url().'/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 93 | 93 | wp_enqueue_script('geodirectory-admin');
|
| 94 | 94 | |
| 95 | 95 | } |
@@ -108,59 +108,59 @@ discard block |
||
| 108 | 108 | |
| 109 | 109 | wp_enqueue_script('jquery');
|
| 110 | 110 | |
| 111 | - wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
|
|
| 111 | + wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url().'/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
|
|
| 112 | 112 | |
| 113 | - wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 113 | + wp_register_script('chosen', geodir_plugin_url().'/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 114 | 114 | wp_enqueue_script('chosen');
|
| 115 | 115 | |
| 116 | - wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
|
|
| 116 | + wp_register_script('geodirectory-choose-ajax', geodir_plugin_url().'/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
|
|
| 117 | 117 | wp_enqueue_script('geodirectory-choose-ajax');
|
| 118 | 118 | |
| 119 | 119 | if (isset($_REQUEST['listing_type'])) {
|
| 120 | - wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
|
|
| 120 | + wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url().'/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
|
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | wp_enqueue_script('geodirectory-custom-fields-script');
|
| 124 | - $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
| 124 | + $plugin_path = geodir_plugin_url().'/geodirectory-functions/cat-meta-functions'; |
|
| 125 | 125 | |
| 126 | - wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
|
|
| 126 | + wp_enqueue_script('tax-meta-clss', $plugin_path.'/js/tax-meta-clss.js', array('jquery'), null, true);
|
|
| 127 | 127 | |
| 128 | 128 | if (in_array($geodir_map_name, array('auto', 'google'))) {
|
| 129 | - $map_lang = "&language=" . geodir_get_map_default_language(); |
|
| 129 | + $map_lang = "&language=".geodir_get_map_default_language(); |
|
| 130 | 130 | /** This filter is documented in geodirectory_template_tags.php */ |
| 131 | 131 | $map_extra = apply_filters('geodir_googlemap_script_extra', '');
|
| 132 | - wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?' . $map_lang . $map_extra, '', NULL);
|
|
| 132 | + wp_enqueue_script('geodirectory-googlemap-script', '//maps.google.com/maps/api/js?'.$map_lang.$map_extra, '', NULL);
|
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | if ($geodir_map_name == 'osm') {
|
| 136 | 136 | // Leaflet OpenStreetMap |
| 137 | - wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 137 | + wp_register_style('geodirectory-leaflet-style', geodir_plugin_url().'/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 138 | 138 | wp_enqueue_style('geodirectory-leaflet-style');
|
| 139 | 139 | |
| 140 | - wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 140 | + wp_register_script('geodirectory-leaflet-script', geodir_plugin_url().'/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 141 | 141 | wp_enqueue_script('geodirectory-leaflet-script');
|
| 142 | 142 | |
| 143 | - wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
|
|
| 143 | + wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url().'/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
|
|
| 144 | 144 | wp_enqueue_script('geodirectory-leaflet-geo-script');
|
| 145 | 145 | } |
| 146 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 146 | + wp_enqueue_script('jquery-ui-autocomplete');
|
|
| 147 | 147 | |
| 148 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 148 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url().'/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
|
|
| 149 | 149 | wp_enqueue_script('geodirectory-goMap-script');
|
| 150 | 150 | |
| 151 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 151 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url().'/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 152 | 152 | wp_enqueue_script('geodirectory-goMap-script');
|
| 153 | 153 | |
| 154 | 154 | // font awesome rating script |
| 155 | 155 | if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
| 156 | - wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 156 | + wp_register_script('geodir-barrating-js', geodir_plugin_url().'/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 157 | 157 | wp_enqueue_script('geodir-barrating-js');
|
| 158 | 158 | } else { // default rating script
|
| 159 | - wp_register_script('geodir-jRating-js', geodir_plugin_url() . '/geodirectory-assets/js/jRating.jquery.js', array(), GEODIRECTORY_VERSION);
|
|
| 159 | + wp_register_script('geodir-jRating-js', geodir_plugin_url().'/geodirectory-assets/js/jRating.jquery.js', array(), GEODIRECTORY_VERSION);
|
|
| 160 | 160 | wp_enqueue_script('geodir-jRating-js');
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
|
|
| 163 | + wp_register_script('geodir-on-document-load', geodir_plugin_url().'/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
|
|
| 164 | 164 | wp_enqueue_script('geodir-on-document-load');
|
| 165 | 165 | |
| 166 | 166 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | wp_enqueue_script('plupload-all');
|
| 169 | 169 | wp_enqueue_script('jquery-ui-sortable');
|
| 170 | 170 | |
| 171 | - wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 171 | + wp_register_script('geodirectory-plupload-script', geodir_plugin_url().'/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 172 | 172 | wp_enqueue_script('geodirectory-plupload-script');
|
| 173 | 173 | |
| 174 | 174 | // SCRIPT FOR UPLOAD END |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
|
| 223 | 223 | |
| 224 | 224 | |
| 225 | - wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 225 | + wp_register_script('geodirectory-admin-script', geodir_plugin_url().'/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 226 | 226 | wp_enqueue_script('geodirectory-admin-script');
|
| 227 | 227 | |
| 228 | 228 | wp_enqueue_style('farbtastic');
|
@@ -230,10 +230,10 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | $screen = get_current_screen(); |
| 232 | 232 | if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
|
| 233 | - wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 233 | + wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url().'/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - $ajax_cons_data = array('url' => __(get_option('siteurl') . '?geodir_ajax=true'));
|
|
| 236 | + $ajax_cons_data = array('url' => __(get_option('siteurl').'?geodir_ajax=true'));
|
|
| 237 | 237 | wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
|
| 238 | 238 | |
| 239 | 239 | } |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
| 258 | 258 | |
| 259 | - add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 259 | + add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url().'/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 260 | 260 | |
| 261 | 261 | |
| 262 | 262 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | $geodir_menu_order[] = 'separator-geodirectory'; |
| 291 | 291 | if (!empty($post_types)) {
|
| 292 | 292 | foreach ($post_types as $post_type) {
|
| 293 | - $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
| 293 | + $geodir_menu_order[] = 'edit.php?post_type='.$post_type; |
|
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | $geodir_menu_order[] = $item; |
@@ -333,8 +333,8 @@ discard block |
||
| 333 | 333 | {
|
| 334 | 334 | if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
|
| 335 | 335 | echo '<div id="message" class="updated fade"> |
| 336 | - <p style="float:right;">' . __('Like Geodirectory?', 'geodirectory') . ' <a href="http://wordpress.org/extend/plugins/Geodirectory/" target="_blank">' . __('Support us by leaving a rating!', 'geodirectory') . '</a></p>
|
|
| 337 | - <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
|
|
| 336 | + <p style="float:right;">' . __('Like Geodirectory?', 'geodirectory').' <a href="http://wordpress.org/extend/plugins/Geodirectory/" target="_blank">'.__('Support us by leaving a rating!', 'geodirectory').'</a></p>
|
|
| 337 | + <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory').'</strong></p>
|
|
| 338 | 338 | </div>'; |
| 339 | 339 | |
| 340 | 340 | } |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
|
| 343 | 343 | switch ($_REQUEST['msg']) {
|
| 344 | 344 | case 'success': |
| 345 | - echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
|
|
| 345 | + echo '<div id="message" class="updated fade"><p><strong>'.__('Your settings have been saved.', 'geodirectory').'</strong></p></div>';
|
|
| 346 | 346 | flush_rewrite_rules(false); |
| 347 | 347 | |
| 348 | 348 | break; |
@@ -350,20 +350,20 @@ discard block |
||
| 350 | 350 | $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
| 351 | 351 | |
| 352 | 352 | if ($gderr == 21) |
| 353 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 353 | + echo '<div id="message" class="error fade"><p><strong>'.__('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory').'</strong></p></div>';
|
|
| 354 | 354 | else |
| 355 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 355 | + echo '<div id="message" class="error fade"><p><strong>'.__('Error: Your settings have not been saved, please try again.', 'geodirectory').'</strong></p></div>';
|
|
| 356 | 356 | break; |
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | if (!geodir_is_default_location_set()) {
|
| 361 | - echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 361 | + echo '<div class="updated fade"><p><strong>'.sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\''.admin_url('admin.php?page=geodirectory&tab=default_location_settings').'\'>', '</a>').'</strong></p></div>';
|
|
| 362 | 362 | |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | if (!function_exists('curl_init')) {
|
| 366 | - echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
|
|
| 366 | + echo '<div class="error"><p><strong>'.__('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory').'</strong></p></div>';
|
|
| 367 | 367 | |
| 368 | 368 | } |
| 369 | 369 | } |
@@ -379,18 +379,18 @@ discard block |
||
| 379 | 379 | function geodir_handle_option_form_submit($current_tab) |
| 380 | 380 | {
|
| 381 | 381 | global $geodir_settings; |
| 382 | - if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
|
|
| 382 | + if (file_exists(dirname(__FILE__).'/option-pages/'.$current_tab.'_array.php')) {
|
|
| 383 | 383 | /** |
| 384 | 384 | * Contains settings array for current tab. |
| 385 | 385 | * |
| 386 | 386 | * @since 1.0.0 |
| 387 | 387 | * @package GeoDirectory |
| 388 | 388 | */ |
| 389 | - include_once('option-pages/' . $current_tab . '_array.php');
|
|
| 389 | + include_once('option-pages/'.$current_tab.'_array.php');
|
|
| 390 | 390 | } |
| 391 | 391 | if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
| 392 | 392 | if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
| 393 | - if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 393 | + if (!wp_verify_nonce($_REQUEST['_wpnonce-'.$current_tab], 'geodir-settings-'.$current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 394 | 394 | |
| 395 | 395 | /** |
| 396 | 396 | * Fires before updating geodirectory admin settings. |
@@ -423,13 +423,13 @@ discard block |
||
| 423 | 423 | * @param string $current_tab The current settings tab name. |
| 424 | 424 | * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
| 425 | 425 | */ |
| 426 | - do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
|
|
| 426 | + do_action('geodir_update_options_'.$current_tab, $geodir_settings[$current_tab]);
|
|
| 427 | 427 | |
| 428 | 428 | flush_rewrite_rules(false); |
| 429 | 429 | |
| 430 | 430 | $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
| 431 | 431 | |
| 432 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
|
|
| 432 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$_REQUEST['active_tab'].'&msg=success');
|
|
| 433 | 433 | |
| 434 | 434 | wp_redirect($redirect_url); |
| 435 | 435 | exit(); |
@@ -439,7 +439,7 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | |
| 442 | -if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined( 'GD_TESTING_MODE' ))) {
|
|
| 442 | +if (!function_exists('geodir_autoinstall_admin_header') && (get_option('geodir_installed') || defined('GD_TESTING_MODE'))) {
|
|
| 443 | 443 | /** |
| 444 | 444 | * GeoDirectory dummy data installation. |
| 445 | 445 | * |
@@ -455,18 +455,18 @@ discard block |
||
| 455 | 455 | global $wpdb, $plugin_prefix; |
| 456 | 456 | |
| 457 | 457 | if (!geodir_is_default_location_set()) {
|
| 458 | - echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 458 | + echo '<div class="updated fade"><p><strong>'.sprintf(__('Please %sclick here%s to set a default location, this will help to set location of all dummy data.', 'geodirectory'), '<a href=\''.admin_url('admin.php?page=geodirectory&tab=default_location_settings').'\'>', '</a>').'</strong></p></div>';
|
|
| 459 | 459 | } else {
|
| 460 | 460 | |
| 461 | - $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab='; |
|
| 461 | + $geodir_url = admin_url().'admin.php?page=geodirectory&tab=general_settings&active_tab='; |
|
| 462 | 462 | |
| 463 | - $post_counts = $wpdb->get_var("SELECT count(post_id) FROM " . $plugin_prefix . $post_type . "_detail WHERE post_dummy='1'");
|
|
| 463 | + $post_counts = $wpdb->get_var("SELECT count(post_id) FROM ".$plugin_prefix.$post_type."_detail WHERE post_dummy='1'");
|
|
| 464 | 464 | |
| 465 | 465 | if ($post_counts > 0) {
|
| 466 | 466 | $nonce = wp_create_nonce('geodir_dummy_posts_delete_noncename');
|
| 467 | 467 | |
| 468 | - $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . SAMPLE_DATA_SHOW_MSG . '</b><br /><a id="geodir_dummy_delete" class="button_delete" onclick="geodir_autoinstall(this,\'geodir_dummy_delete\',\'' . $nonce . '\',\'' . $post_type . '\')" href="javascript:void(0);" redirect_to="' . $geodir_url . '" >' . DELETE_BTN_SAMPLE_MSG . '</a></p></div>'; |
|
| 469 | - $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_DELETE_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /></p></div>'; |
|
| 468 | + $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>'.SAMPLE_DATA_SHOW_MSG.'</b><br /><a id="geodir_dummy_delete" class="button_delete" onclick="geodir_autoinstall(this,\'geodir_dummy_delete\',\''.$nonce.'\',\''.$post_type.'\')" href="javascript:void(0);" redirect_to="'.$geodir_url.'" >'.DELETE_BTN_SAMPLE_MSG.'</a></p></div>'; |
|
| 469 | + $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>'.GEODIR_SAMPLE_DATA_DELETE_MSG.'</b><br><img src="'.geodir_plugin_url().'/geodirectory-assets/images/loadingAnimation.gif" /></p></div>'; |
|
| 470 | 470 | } else {
|
| 471 | 471 | $options_list = ''; |
| 472 | 472 | for ($option = 1; $option <= 30; $option++) {
|
@@ -474,13 +474,13 @@ discard block |
||
| 474 | 474 | if ($option == 10) |
| 475 | 475 | $selected = 'selected="selected"'; |
| 476 | 476 | |
| 477 | - $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>'; |
|
| 477 | + $options_list .= '<option '.$selected.' value="'.$option.'">'.$option.'</option>'; |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | $nonce = wp_create_nonce('geodir_dummy_posts_insert_noncename');
|
| 481 | 481 | |
| 482 | - $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>' . AUTO_INSATALL_MSG . '</b><br /><select class="selected_sample_data">' . $options_list . '</select><a id="geodir_dummy_insert" class="button_insert" href="javascript:void(0);" onclick="geodir_autoinstall(this,\'geodir_dummy_insert\',\'' . $nonce . '\',\'' . $post_type . '\')" redirect_to="' . $geodir_url . '" >' . INSERT_BTN_SAMPLE_MSG . '</a></p></div>'; |
|
| 483 | - $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>' . GEODIR_SAMPLE_DATA_IMPORT_MSG . '</b><br><img src="' . geodir_plugin_url() . '/geodirectory-assets/images/loadingAnimation.gif" /><br><span class="dummy_post_inserted"></span></div>'; |
|
| 482 | + $dummy_msg = '<div id="" class="geodir_auto_install updated highlight fade"><p><b>'.AUTO_INSATALL_MSG.'</b><br /><select class="selected_sample_data">'.$options_list.'</select><a id="geodir_dummy_insert" class="button_insert" href="javascript:void(0);" onclick="geodir_autoinstall(this,\'geodir_dummy_insert\',\''.$nonce.'\',\''.$post_type.'\')" redirect_to="'.$geodir_url.'" >'.INSERT_BTN_SAMPLE_MSG.'</a></p></div>'; |
|
| 483 | + $dummy_msg .= '<div id="" style="display:none;" class="geodir_show_progress updated highlight fade"><p><b>'.GEODIR_SAMPLE_DATA_IMPORT_MSG.'</b><br><img src="'.geodir_plugin_url().'/geodirectory-assets/images/loadingAnimation.gif" /><br><span class="dummy_post_inserted"></span></div>'; |
|
| 484 | 484 | |
| 485 | 485 | } |
| 486 | 486 | echo $dummy_msg; |
@@ -488,14 +488,14 @@ discard block |
||
| 488 | 488 | <script> |
| 489 | 489 | <?php |
| 490 | 490 | $default_location = geodir_get_default_location(); |
| 491 | - $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 492 | - $region =isset($default_location->region) ? $default_location->region : ''; |
|
| 493 | - $country =isset($default_location->country) ? $default_location->country : ''; |
|
| 494 | - $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 495 | - $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 491 | + $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 492 | + $region = isset($default_location->region) ? $default_location->region : ''; |
|
| 493 | + $country = isset($default_location->country) ? $default_location->country : ''; |
|
| 494 | + $city_latitude = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 495 | + $city_longitude = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 496 | 496 | ?> |
| 497 | 497 | var geocoder = window.gdMaps == 'google' ? new google.maps.Geocoder() : null; |
| 498 | - var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country;?>'; |
|
| 498 | + var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country; ?>'; |
|
| 499 | 499 | var bound_lat_lng; |
| 500 | 500 | var latlng = ['<?php echo $city_latitude; ?>', <?php echo $city_longitude; ?>]; |
| 501 | 501 | var lat = <?php echo $city_latitude; ?>; |
@@ -538,7 +538,7 @@ discard block |
||
| 538 | 538 | ); |
| 539 | 539 | |
| 540 | 540 | } else {
|
| 541 | - alert("<?php _e('Geocode was not successful for the following reason:','geodirectory');?> " + status);
|
|
| 541 | + alert("<?php _e('Geocode was not successful for the following reason:', 'geodirectory'); ?> " + status);
|
|
| 542 | 542 | } |
| 543 | 543 | }); |
| 544 | 544 | } |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | var total_dummy_post_count = jQuery('#sub_' + active_tab).find('.selected_sample_data').val();
|
| 552 | 552 | |
| 553 | 553 | if (id == 'geodir_dummy_delete') {
|
| 554 | - if (confirm('<?php _e('Are you sure you want to delete dummy data?' , 'geodirectory'); ?>')) {
|
|
| 554 | + if (confirm('<?php _e('Are you sure you want to delete dummy data?', 'geodirectory'); ?>')) {
|
|
| 555 | 555 | jQuery('#sub_' + active_tab).find('.geodir_auto_install').hide();
|
| 556 | 556 | jQuery('#sub_' + active_tab).find('.geodir_show_progress').show();
|
| 557 | 557 | jQuery.post('<?php echo geodir_get_ajax_url(); ?>&geodir_autofill=' + id + '&posttype=' + posttype + '&_wpnonce=' + nonce,
|
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | jQuery.post('<?php echo geodir_get_ajax_url(); ?>&geodir_autofill=' + id + '&posttype=' + posttype + '&insert_dummy_post_index=' + dummy_post_index + '&city_bound_lat1=' + bound_lat_lng[0] + '&city_bound_lng1=' + bound_lat_lng[1] + '&city_bound_lat2=' + bound_lat_lng[2] + '&city_bound_lng2=' + bound_lat_lng[3] + '&_wpnonce=' + nonce,
|
| 571 | 571 | function (data) {
|
| 572 | 572 | |
| 573 | - jQuery(obj).closest('form').find('.dummy_post_inserted').html('<?php _e('Dummy post(s) inserted:','geodirectory');?> ' + dummy_post_index + ' <?php _e('of' ,'geodirectory'); ?> ' + total_dummy_post_count + '');
|
|
| 573 | + jQuery(obj).closest('form').find('.dummy_post_inserted').html('<?php _e('Dummy post(s) inserted:', 'geodirectory'); ?> ' + dummy_post_index + ' <?php _e('of', 'geodirectory'); ?> ' + total_dummy_post_count + '');
|
|
| 574 | 574 | dummy_post_index++; |
| 575 | 575 | if (dummy_post_index <= total_dummy_post_count) |
| 576 | 576 | geodir_autoinstall(obj, id, nonce, posttype); |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | * @package GeoDirectory |
| 612 | 612 | */ |
| 613 | 613 | include_once('place_dummy_post.php');
|
| 614 | - delete_transient( 'cached_dummy_images' ); |
|
| 614 | + delete_transient('cached_dummy_images');
|
|
| 615 | 615 | |
| 616 | 616 | } |
| 617 | 617 | |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | global $wpdb, $plugin_prefix; |
| 629 | 629 | |
| 630 | 630 | |
| 631 | - $post_ids = $wpdb->get_results("SELECT post_id FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 631 | + $post_ids = $wpdb->get_results("SELECT post_id FROM ".$plugin_prefix."gd_place_detail WHERE post_dummy='1'");
|
|
| 632 | 632 | |
| 633 | 633 | |
| 634 | 634 | foreach ($post_ids as $post_ids_obj) {
|
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | //double check posts are deleted |
| 639 | - $wpdb->get_results("DELETE FROM " . $plugin_prefix . "gd_place_detail WHERE post_dummy='1'");
|
|
| 639 | + $wpdb->get_results("DELETE FROM ".$plugin_prefix."gd_place_detail WHERE post_dummy='1'");
|
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | /** |
@@ -674,14 +674,14 @@ discard block |
||
| 674 | 674 | |
| 675 | 675 | |
| 676 | 676 | if (geodir_dummy_folder_exists()) |
| 677 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 677 | + $dummy_image_url = geodir_plugin_url()."/geodirectory-admin/dummy/cat_icon"; |
|
| 678 | 678 | else |
| 679 | 679 | $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
| 680 | 680 | |
| 681 | 681 | $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
|
| 682 | 682 | |
| 683 | 683 | $catname = str_replace(' ', '_', $catname);
|
| 684 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 684 | + $uploaded = (array) fetch_remote_file("$dummy_image_url/".$catname.".png");
|
|
| 685 | 685 | |
| 686 | 686 | if (empty($uploaded['error'])) {
|
| 687 | 687 | $new_path = $uploaded['file']; |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | $wp_filetype = wp_check_filetype(basename($new_path), null); |
| 692 | 692 | |
| 693 | 693 | $attachment = array( |
| 694 | - 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 694 | + 'guid' => $uploads['baseurl'].'/'.basename($new_path), |
|
| 695 | 695 | 'post_mime_type' => $wp_filetype['type'], |
| 696 | 696 | 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
| 697 | 697 | 'post_content' => '', |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | |
| 702 | 702 | // you must first include the image.php file |
| 703 | 703 | // for the function wp_generate_attachment_metadata() to work |
| 704 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 704 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
| 705 | 705 | $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
| 706 | 706 | wp_update_attachment_metadata($attach_id, $attach_data); |
| 707 | 707 | |
@@ -718,14 +718,14 @@ discard block |
||
| 718 | 718 | $last_catid = wp_insert_term($catname, 'gd_placecategory'); |
| 719 | 719 | |
| 720 | 720 | if (geodir_dummy_folder_exists()) |
| 721 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 721 | + $dummy_image_url = geodir_plugin_url()."/geodirectory-admin/dummy/cat_icon"; |
|
| 722 | 722 | else |
| 723 | 723 | $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
| 724 | 724 | |
| 725 | 725 | $dummy_image_url = apply_filters('place_dummy_cat_image_url', $dummy_image_url);
|
| 726 | 726 | |
| 727 | 727 | $catname = str_replace(' ', '_', $catname);
|
| 728 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 728 | + $uploaded = (array) fetch_remote_file("$dummy_image_url/".$catname.".png");
|
|
| 729 | 729 | |
| 730 | 730 | if (empty($uploaded['error'])) {
|
| 731 | 731 | $new_path = $uploaded['file']; |
@@ -735,7 +735,7 @@ discard block |
||
| 735 | 735 | $wp_filetype = wp_check_filetype(basename($new_path), null); |
| 736 | 736 | |
| 737 | 737 | $attachment = array( |
| 738 | - 'guid' => $uploads['baseurl'] . '/' . basename($new_path), |
|
| 738 | + 'guid' => $uploads['baseurl'].'/'.basename($new_path), |
|
| 739 | 739 | 'post_mime_type' => $wp_filetype['type'], |
| 740 | 740 | 'post_title' => preg_replace('/\.[^.]+$/', '', basename($new_path)),
|
| 741 | 741 | 'post_content' => '', |
@@ -747,7 +747,7 @@ discard block |
||
| 747 | 747 | |
| 748 | 748 | // you must first include the image.php file |
| 749 | 749 | // for the function wp_generate_attachment_metadata() to work |
| 750 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 750 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
| 751 | 751 | $attach_data = wp_generate_attachment_metadata($attach_id, $new_path); |
| 752 | 752 | wp_update_attachment_metadata($attach_id, $attach_data); |
| 753 | 753 | |
@@ -789,18 +789,18 @@ discard block |
||
| 789 | 789 | |
| 790 | 790 | elseif (isset($value['type']) && $value['type'] == 'image_width') : |
| 791 | 791 | |
| 792 | - if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
|
| 793 | - update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
| 794 | - update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
| 795 | - if (isset($_POST[$value['id'] . '_crop'])) : |
|
| 796 | - update_option($value['id'] . '_crop', 1); |
|
| 792 | + if (isset($value['id']) && isset($_POST[$value['id'].'_width'])) {
|
|
| 793 | + update_option($value['id'].'_width', $_POST[$value['id'].'_width']); |
|
| 794 | + update_option($value['id'].'_height', $_POST[$value['id'].'_height']); |
|
| 795 | + if (isset($_POST[$value['id'].'_crop'])) : |
|
| 796 | + update_option($value['id'].'_crop', 1); |
|
| 797 | 797 | else : |
| 798 | - update_option($value['id'] . '_crop', 0); |
|
| 798 | + update_option($value['id'].'_crop', 0); |
|
| 799 | 799 | endif; |
| 800 | 800 | } else {
|
| 801 | - update_option($value['id'] . '_width', $value['std']); |
|
| 802 | - update_option($value['id'] . '_height', $value['std']); |
|
| 803 | - update_option($value['id'] . '_crop', 1); |
|
| 801 | + update_option($value['id'].'_width', $value['std']); |
|
| 802 | + update_option($value['id'].'_height', $value['std']); |
|
| 803 | + update_option($value['id'].'_crop', 1); |
|
| 804 | 804 | } |
| 805 | 805 | |
| 806 | 806 | elseif (isset($value['type']) && $value['type'] == 'map') : |
@@ -842,12 +842,12 @@ discard block |
||
| 842 | 842 | elseif (isset($value['type']) && $value['type'] == 'file') : |
| 843 | 843 | |
| 844 | 844 | |
| 845 | - if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
|
|
| 845 | + if (isset($_POST[$value['id'].'_remove']) && $_POST[$value['id'].'_remove']) {// if remove is set then remove the file
|
|
| 846 | 846 | |
| 847 | 847 | if (get_option($value['id'])) {
|
| 848 | 848 | $image_name_arr = explode('/', get_option($value['id']));
|
| 849 | 849 | $noimg_name = end($image_name_arr); |
| 850 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 850 | + $img_path = $uploads['path'].'/'.$noimg_name; |
|
| 851 | 851 | if (file_exists($img_path)) |
| 852 | 852 | unlink($img_path); |
| 853 | 853 | } |
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | if (get_option($value['id'])) {
|
| 876 | 876 | $image_name_arr = explode('/', get_option($value['id']));
|
| 877 | 877 | $noimg_name = end($image_name_arr); |
| 878 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 878 | + $img_path = $uploads['path'].'/'.$noimg_name; |
|
| 879 | 879 | if (file_exists($img_path)) |
| 880 | 880 | unlink($img_path); |
| 881 | 881 | } |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | // same menu setting per theme. |
| 897 | 897 | if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
| 898 | 898 | $theme = wp_get_theme(); |
| 899 | - update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
|
| 899 | + update_option('geodir_theme_location_nav_'.$theme->name, $_POST[$value['id']]);
|
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | if (isset($value['id']) && isset($_POST[$value['id']])) {
|
@@ -966,8 +966,8 @@ discard block |
||
| 966 | 966 | |
| 967 | 967 | $listing_slug = $geodir_posttype_info['labels']['singular_name']; |
| 968 | 968 | |
| 969 | - $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
| 970 | - 'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'), |
|
| 969 | + $tabs[$geodir_post_type.'_fields_settings'] = array( |
|
| 970 | + 'label' => __(ucfirst($listing_slug).' Settings', 'geodirectory'), |
|
| 971 | 971 | 'subtabs' => array( |
| 972 | 972 | array('subtab' => 'custom_fields',
|
| 973 | 973 | 'label' => __('Custom Fields', 'geodirectory'),
|
@@ -1000,7 +1000,7 @@ discard block |
||
| 1000 | 1000 | */ |
| 1001 | 1001 | function geodir_tools_setting_tab($tabs) |
| 1002 | 1002 | {
|
| 1003 | - wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 1003 | + wp_enqueue_script('jquery-ui-progressbar');
|
|
| 1004 | 1004 | $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
|
| 1005 | 1005 | return $tabs; |
| 1006 | 1006 | } |
@@ -1034,7 +1034,7 @@ discard block |
||
| 1034 | 1034 | */ |
| 1035 | 1035 | function geodir_extend_geodirectory_setting_tab($tabs) |
| 1036 | 1036 | {
|
| 1037 | - $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
|
|
| 1037 | + $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory').' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
|
|
| 1038 | 1038 | return $tabs; |
| 1039 | 1039 | } |
| 1040 | 1040 | |
@@ -1094,8 +1094,8 @@ discard block |
||
| 1094 | 1094 | _e('Unknown', 'geodirectory');
|
| 1095 | 1095 | } else {
|
| 1096 | 1096 | /* If there is a city id, append 'city name' to the text string. */ |
| 1097 | - $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
|
|
| 1098 | - echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
| 1097 | + $add_location_id = $location_id > 0 ? ' ('.$location_id.')' : '';
|
|
| 1098 | + echo(__($location->country, 'geodirectory').'-'.$location->region.'-'.$location->city.$add_location_id); |
|
| 1099 | 1099 | } |
| 1100 | 1100 | break; |
| 1101 | 1101 | |
@@ -1113,14 +1113,14 @@ discard block |
||
| 1113 | 1113 | $expire_class = 'expire_over'; |
| 1114 | 1114 | } |
| 1115 | 1115 | $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
| 1116 | - $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
|
| 1116 | + $date_diff_text = '<br /><span class="'.$expire_class.'">('.$date_diff.' '.$state.')</span>';
|
|
| 1117 | 1117 | } |
| 1118 | 1118 | /* If no expire_date is found, output a default message. */ |
| 1119 | 1119 | if (empty($expire_date)) |
| 1120 | 1120 | echo __('Unknown', 'geodirectory');
|
| 1121 | 1121 | /* If there is a expire_date, append 'days left' to the text string. */ |
| 1122 | 1122 | else |
| 1123 | - echo $expire_date . $date_diff_text; |
|
| 1123 | + echo $expire_date.$date_diff_text; |
|
| 1124 | 1124 | break; |
| 1125 | 1125 | |
| 1126 | 1126 | /* If displaying the 'categorys' column. */ |
@@ -1187,7 +1187,7 @@ discard block |
||
| 1187 | 1187 | function geodir_post_information_save($post_id, $post) {
|
| 1188 | 1188 | global $wpdb, $current_user; |
| 1189 | 1189 | |
| 1190 | - if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 1190 | + if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) {
|
|
| 1191 | 1191 | return; |
| 1192 | 1192 | } |
| 1193 | 1193 | |
@@ -1255,7 +1255,7 @@ discard block |
||
| 1255 | 1255 | $tab_id = $value['id']; |
| 1256 | 1256 | |
| 1257 | 1257 | if (isset($value['desc']) && $value['desc']) |
| 1258 | - $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 1258 | + $desc = '<span style=" text-transform:none;">:- '.$value['desc'].'</span>'; |
|
| 1259 | 1259 | |
| 1260 | 1260 | if (isset($value['name']) && $value['name']) {
|
| 1261 | 1261 | if ($first_title === true) {
|
@@ -1263,9 +1263,9 @@ discard block |
||
| 1263 | 1263 | } else {
|
| 1264 | 1264 | echo '</div>'; |
| 1265 | 1265 | } |
| 1266 | - echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
| 1266 | + echo '<dd id="'.trim($tab_id).'" class="geodir_option_tabs" ><a href="javascript:void(0);">'.$value['name'].'</a></dd>'; |
|
| 1267 | 1267 | |
| 1268 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1268 | + echo '<div id="sub_'.trim($tab_id).'" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1269 | 1269 | } |
| 1270 | 1270 | |
| 1271 | 1271 | /** |
@@ -1275,21 +1275,21 @@ discard block |
||
| 1275 | 1275 | * |
| 1276 | 1276 | * @since 1.0.0 |
| 1277 | 1277 | */ |
| 1278 | - do_action('geodir_settings_' . sanitize_title($value['id']));
|
|
| 1278 | + do_action('geodir_settings_'.sanitize_title($value['id']));
|
|
| 1279 | 1279 | break; |
| 1280 | 1280 | |
| 1281 | 1281 | case 'no_tabs': |
| 1282 | 1282 | |
| 1283 | 1283 | echo '<div class="inner_content_tab_main">'; |
| 1284 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1284 | + echo '<div id="sub_'.trim($tab_id).'" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 1285 | 1285 | |
| 1286 | 1286 | break; |
| 1287 | 1287 | |
| 1288 | 1288 | case 'sectionstart': |
| 1289 | 1289 | if (isset($value['desc']) && $value['desc']) |
| 1290 | - $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 1290 | + $desc = '<span style=" text-transform:none;"> - '.$value['desc'].'</span>'; |
|
| 1291 | 1291 | if (isset($value['name']) && $value['name']) |
| 1292 | - echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 1292 | + echo '<h3>'.$value['name'].$desc.'</h3>'; |
|
| 1293 | 1293 | /** |
| 1294 | 1294 | * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
| 1295 | 1295 | * |
@@ -1297,8 +1297,8 @@ discard block |
||
| 1297 | 1297 | * |
| 1298 | 1298 | * @since 1.0.0 |
| 1299 | 1299 | */ |
| 1300 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 1301 | - echo '<table class="form-table">' . "\n\n"; |
|
| 1300 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_start');
|
|
| 1301 | + echo '<table class="form-table">'."\n\n"; |
|
| 1302 | 1302 | |
| 1303 | 1303 | break; |
| 1304 | 1304 | case 'sectionend': |
@@ -1309,7 +1309,7 @@ discard block |
||
| 1309 | 1309 | * |
| 1310 | 1310 | * @since 1.0.0 |
| 1311 | 1311 | */ |
| 1312 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 1312 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_end');
|
|
| 1313 | 1313 | echo '</table>'; |
| 1314 | 1314 | /** |
| 1315 | 1315 | * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
@@ -1318,7 +1318,7 @@ discard block |
||
| 1318 | 1318 | * |
| 1319 | 1319 | * @since 1.0.0 |
| 1320 | 1320 | */ |
| 1321 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 1321 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_'.sanitize_title($value['id']).'_after');
|
|
| 1322 | 1322 | break; |
| 1323 | 1323 | case 'text': |
| 1324 | 1324 | ?> |
@@ -1327,7 +1327,7 @@ discard block |
||
| 1327 | 1327 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
| 1328 | 1328 | id="<?php echo esc_attr($value['id']); ?>" |
| 1329 | 1329 | type="<?php echo esc_attr($value['type']); ?>" |
| 1330 | - <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 1330 | + <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 1331 | 1331 | style=" <?php echo esc_attr($value['css']); ?>" |
| 1332 | 1332 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1333 | 1333 | echo esc_attr(stripslashes(get_option($value['id']))); |
@@ -1344,7 +1344,7 @@ discard block |
||
| 1344 | 1344 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
| 1345 | 1345 | id="<?php echo esc_attr($value['id']); ?>" |
| 1346 | 1346 | type="<?php echo esc_attr($value['type']); ?>" |
| 1347 | - <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 1347 | + <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 1348 | 1348 | style="<?php echo esc_attr($value['css']); ?>" |
| 1349 | 1349 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1350 | 1350 | echo esc_attr(stripslashes(get_option($value['id']))); |
@@ -1390,17 +1390,17 @@ discard block |
||
| 1390 | 1390 | <?php _e('Width', 'geodirectory'); ?> <input
|
| 1391 | 1391 | name="<?php echo esc_attr($value['id']); ?>_width" |
| 1392 | 1392 | id="<?php echo esc_attr($value['id']); ?>_width" type="text" size="3" |
| 1393 | - value="<?php if ($size = get_option($value['id'] . '_width')) echo stripslashes($size); else echo $value['std']; ?>"/> |
|
| 1393 | + value="<?php if ($size = get_option($value['id'].'_width')) echo stripslashes($size); else echo $value['std']; ?>"/> |
|
| 1394 | 1394 | |
| 1395 | 1395 | <?php _e('Height', 'geodirectory'); ?> <input
|
| 1396 | 1396 | name="<?php echo esc_attr($value['id']); ?>_height" |
| 1397 | 1397 | id="<?php echo esc_attr($value['id']); ?>_height" type="text" size="3" |
| 1398 | - value="<?php if ($size = get_option($value['id'] . '_height')) echo stripslashes($size); else echo $value['std']; ?>"/> |
|
| 1398 | + value="<?php if ($size = get_option($value['id'].'_height')) echo stripslashes($size); else echo $value['std']; ?>"/> |
|
| 1399 | 1399 | |
| 1400 | 1400 | <label><?php _e('Hard Crop', 'geodirectory'); ?> <input
|
| 1401 | 1401 | name="<?php echo esc_attr($value['id']); ?>_crop" |
| 1402 | 1402 | id="<?php echo esc_attr($value['id']); ?>_crop" |
| 1403 | - type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') checked(get_option($value['id'] . '_crop'), 1); else checked(1); ?> /></label> |
|
| 1403 | + type="checkbox" <?php if (get_option($value['id'].'_crop') != '') checked(get_option($value['id'].'_crop'), 1); else checked(1); ?> /></label> |
|
| 1404 | 1404 | |
| 1405 | 1405 | <span class="description"><?php echo $value['desc'] ?></span></td> |
| 1406 | 1406 | </tr><?php |
@@ -1450,7 +1450,7 @@ discard block |
||
| 1450 | 1450 | id="<?php echo esc_attr($value['id']); ?>" |
| 1451 | 1451 | style="<?php echo esc_attr($value['css']); ?>" |
| 1452 | 1452 | class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
| 1453 | - data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>" |
|
| 1453 | + data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text']; ?>" |
|
| 1454 | 1454 | option-ajaxchosen="false"> |
| 1455 | 1455 | <?php |
| 1456 | 1456 | foreach ($value['options'] as $key => $val) {
|
@@ -1461,7 +1461,7 @@ discard block |
||
| 1461 | 1461 | } else {
|
| 1462 | 1462 | ?> |
| 1463 | 1463 | <option |
| 1464 | - value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option> |
|
| 1464 | + value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values))); ?>><?php echo ucfirst($val) ?></option> |
|
| 1465 | 1465 | <?php |
| 1466 | 1466 | } |
| 1467 | 1467 | } |
@@ -1496,7 +1496,7 @@ discard block |
||
| 1496 | 1496 | ?> |
| 1497 | 1497 | |
| 1498 | 1498 | <tr valign="top"> |
| 1499 | - <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
|
|
| 1499 | + <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory'); ?></th>
|
|
| 1500 | 1500 | <td width="60%"> |
| 1501 | 1501 | <select name="geodir_default_map_language" style="width:60%"> |
| 1502 | 1502 | <?php |
@@ -1578,7 +1578,7 @@ discard block |
||
| 1578 | 1578 | |
| 1579 | 1579 | <tr valign="top"> |
| 1580 | 1580 | <th class="titledesc" |
| 1581 | - width="40%"><?php _e('Default post type search on map', 'geodirectory');?></th>
|
|
| 1581 | + width="40%"><?php _e('Default post type search on map', 'geodirectory'); ?></th>
|
|
| 1582 | 1582 | <td width="60%"> |
| 1583 | 1583 | <select name="geodir_default_map_search_pt" style="width:60%"> |
| 1584 | 1584 | <?php |
@@ -1619,7 +1619,7 @@ discard block |
||
| 1619 | 1619 | $cat_display = 'checkbox'; |
| 1620 | 1620 | $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
| 1621 | 1621 | $gd_cats = get_option('geodir_exclude_cat_on_map');
|
| 1622 | - $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 1622 | + $gd_cats_upgrade = (int) get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 1623 | 1623 | $count = 1; |
| 1624 | 1624 | ?> |
| 1625 | 1625 | <table width="70%" class="widefat"> |
@@ -1648,7 +1648,7 @@ discard block |
||
| 1648 | 1648 | name="home_map_post_types[]" |
| 1649 | 1649 | id="<?php echo esc_attr($value['id']); ?>" |
| 1650 | 1650 | value="<?php echo $key; ?>" |
| 1651 | - class="map_post_type" <?php echo $checked;?> /> |
|
| 1651 | + class="map_post_type" <?php echo $checked; ?> /> |
|
| 1652 | 1652 | <?php echo $post_types_obj->labels->singular_name; ?></td> |
| 1653 | 1653 | <td width="40%"> |
| 1654 | 1654 | <div class="home_map_category" style="overflow:auto;width:200px;height:100px;" |
@@ -1706,12 +1706,12 @@ discard block |
||
| 1706 | 1706 | ?> |
| 1707 | 1707 | <fieldset> |
| 1708 | 1708 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 1709 | - <label for="<?php echo $value['id'];?>"> |
|
| 1709 | + <label for="<?php echo $value['id']; ?>"> |
|
| 1710 | 1710 | <input name="<?php echo esc_attr($value['id']); ?>" |
| 1711 | - id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio" |
|
| 1711 | + id="<?php echo esc_attr($value['id'].$value['value']); ?>" type="radio" |
|
| 1712 | 1712 | value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
|
| 1713 | 1713 | echo 'checked="checked"'; |
| 1714 | - }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 1714 | + }elseif (get_option($value['id']) == '' && $value['std'] == $value['value']) {echo 'checked="checked"'; } ?> />
|
|
| 1715 | 1715 | <?php echo $value['desc']; ?></label><br> |
| 1716 | 1716 | </fieldset> |
| 1717 | 1717 | <?php |
@@ -1731,9 +1731,9 @@ discard block |
||
| 1731 | 1731 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1732 | 1732 | <td class="forminp"> |
| 1733 | 1733 | <textarea |
| 1734 | - <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>" |
|
| 1734 | + <?php if (isset($value['args'])) echo $value['args'].' '; ?>name="<?php echo esc_attr($value['id']); ?>" |
|
| 1735 | 1735 | id="<?php echo esc_attr($value['id']); ?>" |
| 1736 | - <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 1736 | + <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 1737 | 1737 | 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 |
| 1738 | 1738 | class="description"><?php echo $value['desc'] ?></span> |
| 1739 | 1739 | |
@@ -1778,7 +1778,7 @@ discard block |
||
| 1778 | 1778 | } |
| 1779 | 1779 | } |
| 1780 | 1780 | // |
| 1781 | - $page_setting = (int)get_option($value['id']); |
|
| 1781 | + $page_setting = (int) get_option($value['id']); |
|
| 1782 | 1782 | |
| 1783 | 1783 | $args = array('name' => $value['id'],
|
| 1784 | 1784 | 'id' => $value['id'], |
@@ -1795,7 +1795,7 @@ discard block |
||
| 1795 | 1795 | <tr valign="top" class="single_select_page"> |
| 1796 | 1796 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1797 | 1797 | <td class="forminp"> |
| 1798 | - <?php echo str_replace(' id=', " data-placeholder='" . __('Select a page...', 'geodirectory') . "' style='" . $value['css'] . "' class='" . $value['class'] . "' " . $disabled . " id=", wp_dropdown_pages($args)); ?>
|
|
| 1798 | + <?php echo str_replace(' id=', " data-placeholder='".__('Select a page...', 'geodirectory')."' style='".$value['css']."' class='".$value['class']."' ".$disabled." id=", wp_dropdown_pages($args)); ?>
|
|
| 1799 | 1799 | <span class="description"><?php echo $value['desc'] ?></span> |
| 1800 | 1800 | </td> |
| 1801 | 1801 | </tr><?php |
@@ -1804,7 +1804,7 @@ discard block |
||
| 1804 | 1804 | } |
| 1805 | 1805 | break; |
| 1806 | 1806 | case 'single_select_country' : |
| 1807 | - $country_setting = (string)get_option($value['id']); |
|
| 1807 | + $country_setting = (string) get_option($value['id']); |
|
| 1808 | 1808 | if (strstr($country_setting, ':')) : |
| 1809 | 1809 | $country = current(explode(':', $country_setting));
|
| 1810 | 1810 | $state = end(explode(':', $country_setting));
|
@@ -1827,7 +1827,7 @@ discard block |
||
| 1827 | 1827 | case 'multi_select_countries' : |
| 1828 | 1828 | $countries = $geodirectory->countries->countries; |
| 1829 | 1829 | asort($countries); |
| 1830 | - $selections = (array)get_option($value['id']); |
|
| 1830 | + $selections = (array) get_option($value['id']); |
|
| 1831 | 1831 | ?> |
| 1832 | 1832 | <tr valign="top"> |
| 1833 | 1833 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
@@ -1837,7 +1837,7 @@ discard block |
||
| 1837 | 1837 | title="Country" class="chosen_select"> |
| 1838 | 1838 | <?php |
| 1839 | 1839 | if ($countries) foreach ($countries as $key => $val) : |
| 1840 | - echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 1840 | + echo '<option value="'.$key.'" '.selected(in_array($key, $selections), true, false).'>'.$val.'</option>'; |
|
| 1841 | 1841 | endforeach; |
| 1842 | 1842 | ?> |
| 1843 | 1843 | </select> |
@@ -1849,8 +1849,8 @@ discard block |
||
| 1849 | 1849 | break; |
| 1850 | 1850 | |
| 1851 | 1851 | case 'google_analytics' : |
| 1852 | - $selections = (array)get_option($value['id']); |
|
| 1853 | - if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
|
|
| 1852 | + $selections = (array) get_option($value['id']); |
|
| 1853 | + if (get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret')) {
|
|
| 1854 | 1854 | ?> |
| 1855 | 1855 | <tr valign="top"> |
| 1856 | 1856 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
@@ -1861,20 +1861,20 @@ discard block |
||
| 1861 | 1861 | |
| 1862 | 1862 | $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
| 1863 | 1863 | $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
| 1864 | - $state = "&state=123";//any string |
|
| 1865 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 1864 | + $state = "&state=123"; //any string |
|
| 1865 | + $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback";
|
|
| 1866 | 1866 | $response_type = "&response_type=code"; |
| 1867 | 1867 | $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
| 1868 | 1868 | $access_type = "&access_type=offline"; |
| 1869 | 1869 | $approval_prompt = "&approval_prompt=force"; |
| 1870 | 1870 | |
| 1871 | - $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
| 1871 | + $auth_url = $oAuthURL.$scope.$state.$redirect_uri.$response_type.$client_id.$access_type.$approval_prompt; |
|
| 1872 | 1872 | |
| 1873 | 1873 | |
| 1874 | 1874 | ?> |
| 1875 | 1875 | <script> |
| 1876 | 1876 | function gd_ga_popup() {
|
| 1877 | - var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
|
|
| 1877 | + var win = window.open("<?php echo $auth_url; ?>", "Google Analytics", "");
|
|
| 1878 | 1878 | var pollTimer = window.setInterval(function () {
|
| 1879 | 1879 | if (win.closed !== false) { // !== is required for compatibility with Opera
|
| 1880 | 1880 | window.clearInterval(pollTimer); |
@@ -1896,7 +1896,7 @@ discard block |
||
| 1896 | 1896 | } else {
|
| 1897 | 1897 | ?> |
| 1898 | 1898 | <span class="button-primary" |
| 1899 | - onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
|
|
| 1899 | + onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory'); ?></span>
|
|
| 1900 | 1900 | <?php |
| 1901 | 1901 | } |
| 1902 | 1902 | ?> |
@@ -1967,9 +1967,9 @@ discard block |
||
| 1967 | 1967 | |
| 1968 | 1968 | <?php if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] != '') { ?>
|
| 1969 | 1969 | jQuery('.geodir_option_tabs').removeClass('gd-tab-active');
|
| 1970 | - jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').addClass('gd-tab-active');
|
|
| 1970 | + jQuery('#<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').addClass('gd-tab-active');
|
|
| 1971 | 1971 | jQuery('.gd-content-heading').hide();
|
| 1972 | - jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']);?>').show();
|
|
| 1972 | + jQuery('#sub_<?php echo sanitize_text_field($_REQUEST['active_tab']); ?>').show();
|
|
| 1973 | 1973 | <?php } ?> |
| 1974 | 1974 | }); |
| 1975 | 1975 | </script> |
@@ -2055,7 +2055,7 @@ discard block |
||
| 2055 | 2055 | wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
| 2056 | 2056 | |
| 2057 | 2057 | if (geodir_get_featured_image($post_id, 'thumbnail')) {
|
| 2058 | - echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
|
|
| 2058 | + echo '<h4>'.__('Featured Image', 'geodirectory').'</h4>';
|
|
| 2059 | 2059 | geodir_show_featured_image($post_id, 'thumbnail'); |
| 2060 | 2060 | } |
| 2061 | 2061 | |
@@ -2066,13 +2066,13 @@ discard block |
||
| 2066 | 2066 | |
| 2067 | 2067 | <h5 class="form_title"> |
| 2068 | 2068 | <?php if ($image_limit != 0 && $image_limit == 1) {
|
| 2069 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 2069 | + echo '<br /><small>('.__('You can upload', 'geodirectory').' '.$image_limit.' '.__('image with this package', 'geodirectory').')</small>';
|
|
| 2070 | 2070 | } ?> |
| 2071 | 2071 | <?php if ($image_limit != 0 && $image_limit > 1) {
|
| 2072 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 2072 | + echo '<br /><small>('.__('You can upload', 'geodirectory').' '.$image_limit.' '.__('images with this package', 'geodirectory').')</small>';
|
|
| 2073 | 2073 | } ?> |
| 2074 | 2074 | <?php if ($image_limit == 0) {
|
| 2075 | - echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 2075 | + echo '<br /><small>('.__('You can upload unlimited images with this package', 'geodirectory').')</small>';
|
|
| 2076 | 2076 | } ?> |
| 2077 | 2077 | </h5> |
| 2078 | 2078 | |
@@ -2111,10 +2111,10 @@ discard block |
||
| 2111 | 2111 | <div |
| 2112 | 2112 | class="plupload-upload-uic hide-if-no-js <?php if ($multiple): ?>plupload-upload-uic-multiple<?php endif; ?>" |
| 2113 | 2113 | id="<?php echo $id; ?>plupload-upload-ui"> |
| 2114 | - <h4><?php _e('Drop files to upload', 'geodirectory');?></h4>
|
|
| 2114 | + <h4><?php _e('Drop files to upload', 'geodirectory'); ?></h4>
|
|
| 2115 | 2115 | <input id="<?php echo $id; ?>plupload-browse-button" type="button" |
| 2116 | 2116 | value="<?php _e('Select Files', 'geodirectory'); ?>" class="button"/>
|
| 2117 | - <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?>"></span> |
|
| 2117 | + <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id.'pluploadan'); ?>"></span> |
|
| 2118 | 2118 | <?php if ($width && $height): ?> |
| 2119 | 2119 | <span class="plupload-resize"></span> |
| 2120 | 2120 | <span class="plupload-width" id="plupload-width<?php echo $width; ?>"></span> |
@@ -2126,7 +2126,7 @@ discard block |
||
| 2126 | 2126 | id="<?php echo $id; ?>plupload-thumbs" style="border-top:1px solid #ccc; padding-top:10px;"> |
| 2127 | 2127 | </div> |
| 2128 | 2128 | <span |
| 2129 | - id="upload-msg"><?php _e('Please drag & drop the images to rearrange the order', 'geodirectory');?></span>
|
|
| 2129 | + id="upload-msg"><?php _e('Please drag & drop the images to rearrange the order', 'geodirectory'); ?></span>
|
|
| 2130 | 2130 | <span id="<?php echo $id; ?>upload-error" style="display:none"></span> |
| 2131 | 2131 | </div> |
| 2132 | 2132 | |
@@ -2336,9 +2336,9 @@ discard block |
||
| 2336 | 2336 | $plugin = 'avada-nag'; |
| 2337 | 2337 | $timestamp = 'avada-nag1234'; |
| 2338 | 2338 | $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');
|
| 2339 | - echo '<div id="' . $timestamp . '" class="error">'; |
|
| 2340 | - echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
| 2341 | - echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 2339 | + echo '<div id="'.$timestamp.'" class="error">'; |
|
| 2340 | + echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\''.$plugin.'\',\''.$timestamp.'\');" ><i class="fa fa-times"></i></span>'; |
|
| 2341 | + echo "<img class='gd-icon-noti' src='".plugin_dir_url('')."geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 2342 | 2342 | echo "<p>$message</p>"; |
| 2343 | 2343 | echo "</div>"; |
| 2344 | 2344 | |
@@ -2471,7 +2471,7 @@ discard block |
||
| 2471 | 2471 | |
| 2472 | 2472 | // Don't allow same slug url for listing and location |
| 2473 | 2473 | if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
|
| 2474 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
|
|
| 2474 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$active_tab.'&msg=fail&gderr=21');
|
|
| 2475 | 2475 | wp_redirect($redirect_url); |
| 2476 | 2476 | exit; |
| 2477 | 2477 | } |
@@ -2483,7 +2483,7 @@ discard block |
||
| 2483 | 2483 | $default_language = $sitepress->get_default_language(); |
| 2484 | 2484 | |
| 2485 | 2485 | if ($current_language != 'all' && $current_language != $default_language) {
|
| 2486 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab);
|
|
| 2486 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab='.$current_tab.'&active_tab='.$active_tab);
|
|
| 2487 | 2487 | wp_redirect($redirect_url); |
| 2488 | 2488 | exit; |
| 2489 | 2489 | } |
@@ -2504,11 +2504,11 @@ discard block |
||
| 2504 | 2504 | function geodir_hide_admin_preview_button() {
|
| 2505 | 2505 | global $post_type; |
| 2506 | 2506 | $post_types = geodir_get_posttypes(); |
| 2507 | - if(in_array($post_type, $post_types)) |
|
| 2507 | + if (in_array($post_type, $post_types)) |
|
| 2508 | 2508 | echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
| 2509 | 2509 | } |
| 2510 | -add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' ); |
|
| 2511 | -add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' ); |
|
| 2510 | +add_action('admin_head-post-new.php', 'geodir_hide_admin_preview_button');
|
|
| 2511 | +add_action('admin_head-post.php', 'geodir_hide_admin_preview_button');
|
|
| 2512 | 2512 | |
| 2513 | 2513 | /** |
| 2514 | 2514 | * Add the tab in left sidebar menu fro import & export page. |
@@ -2518,8 +2518,8 @@ discard block |
||
| 2518 | 2518 | * |
| 2519 | 2519 | * @return array Array of tab data. |
| 2520 | 2520 | */ |
| 2521 | -function geodir_import_export_tab( $tabs ) {
|
|
| 2522 | - $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
|
| 2521 | +function geodir_import_export_tab($tabs) {
|
|
| 2522 | + $tabs['import_export'] = array('label' => __('Import & Export', 'geodirectory'));
|
|
| 2523 | 2523 | return $tabs; |
| 2524 | 2524 | } |
| 2525 | 2525 | |
@@ -2533,8 +2533,8 @@ discard block |
||
| 2533 | 2533 | * @return string Html content. |
| 2534 | 2534 | */ |
| 2535 | 2535 | function geodir_import_export_page() {
|
| 2536 | - $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
|
| 2537 | - $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
|
| 2536 | + $nonce = wp_create_nonce('geodir_import_export_nonce');
|
|
| 2537 | + $gd_cats_sample_csv = geodir_plugin_url().'/geodirectory-assets/gd_sample_categories.csv'; |
|
| 2538 | 2538 | /** |
| 2539 | 2539 | * Filter sample category data csv file url. |
| 2540 | 2540 | * |
@@ -2543,9 +2543,9 @@ discard block |
||
| 2543 | 2543 | * |
| 2544 | 2544 | * @param string $gd_cats_sample_csv Sample category data csv file url. |
| 2545 | 2545 | */ |
| 2546 | - $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
|
| 2546 | + $gd_cats_sample_csv = apply_filters('geodir_export_cats_sample_csv', $gd_cats_sample_csv);
|
|
| 2547 | 2547 | |
| 2548 | - $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
|
| 2548 | + $gd_posts_sample_csv = geodir_plugin_url().'/geodirectory-assets/place_listing.csv'; |
|
| 2549 | 2549 | /** |
| 2550 | 2550 | * Filter sample post data csv file url. |
| 2551 | 2551 | * |
@@ -2554,15 +2554,15 @@ discard block |
||
| 2554 | 2554 | * |
| 2555 | 2555 | * @param string $gd_posts_sample_csv Sample post data csv file url. |
| 2556 | 2556 | */ |
| 2557 | - $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 2557 | + $gd_posts_sample_csv = apply_filters('geodir_export_posts_sample_csv', $gd_posts_sample_csv);
|
|
| 2558 | 2558 | |
| 2559 | - $gd_posttypes = geodir_get_posttypes( 'array' ); |
|
| 2559 | + $gd_posttypes = geodir_get_posttypes('array');
|
|
| 2560 | 2560 | |
| 2561 | 2561 | $gd_posttypes_option = ''; |
| 2562 | - foreach ( $gd_posttypes as $gd_posttype => $row ) {
|
|
| 2563 | - $gd_posttypes_option .= '<option value="' . $gd_posttype . '" data-cats="' . (int)geodir_get_terms_count( $gd_posttype ) . '" data-posts="' . (int)geodir_get_posts_count( $gd_posttype ) . '">' . __( $row['labels']['name'], 'geodirectory' ) . '</option>'; |
|
| 2562 | + foreach ($gd_posttypes as $gd_posttype => $row) {
|
|
| 2563 | + $gd_posttypes_option .= '<option value="'.$gd_posttype.'" data-cats="'.(int) geodir_get_terms_count($gd_posttype).'" data-posts="'.(int) geodir_get_posts_count($gd_posttype).'">'.__($row['labels']['name'], 'geodirectory').'</option>'; |
|
| 2564 | 2564 | } |
| 2565 | - wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 2565 | + wp_enqueue_script('jquery-ui-progressbar');
|
|
| 2566 | 2566 | |
| 2567 | 2567 | $gd_chunksize_options = array(); |
| 2568 | 2568 | $gd_chunksize_options[100] = 100; |
@@ -2584,49 +2584,49 @@ discard block |
||
| 2584 | 2584 | * |
| 2585 | 2585 | * @param string $gd_chunksize_options Entries options. |
| 2586 | 2586 | */ |
| 2587 | - $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 2587 | + $gd_chunksize_options = apply_filters('geodir_export_csv_chunksize_options', $gd_chunksize_options);
|
|
| 2588 | 2588 | |
| 2589 | 2589 | $gd_chunksize_option = ''; |
| 2590 | 2590 | foreach ($gd_chunksize_options as $value => $title) {
|
| 2591 | - $gd_chunksize_option .= '<option value="' . $value . '" ' . selected($value, 5000, false) . '>' . $title . '</option>'; |
|
| 2591 | + $gd_chunksize_option .= '<option value="'.$value.'" '.selected($value, 5000, false).'>'.$title.'</option>'; |
|
| 2592 | 2592 | } |
| 2593 | 2593 | |
| 2594 | 2594 | $uploads = wp_upload_dir(); |
| 2595 | 2595 | ?> |
| 2596 | 2596 | </form> |
| 2597 | 2597 | <div class="inner_content_tab_main gd-import-export"> |
| 2598 | - <h3><?php _e( 'GD Import & Export CSV', 'geodirectory' ) ;?></h3> |
|
| 2599 | - <span class="description"><?php _e( 'Import & export csv for GD listings & categories.', 'geodirectory' ) ;?></span> |
|
| 2598 | + <h3><?php _e('GD Import & Export CSV', 'geodirectory'); ?></h3>
|
|
| 2599 | + <span class="description"><?php _e('Import & export csv for GD listings & categories.', 'geodirectory'); ?></span>
|
|
| 2600 | 2600 | <div class="gd-content-heading"> |
| 2601 | 2601 | |
| 2602 | 2602 | <?php |
| 2603 | 2603 | ini_set('max_execution_time', 999999);
|
| 2604 | - $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 2604 | + $ini_max_execution_time_check = @ini_get('max_execution_time');
|
|
| 2605 | 2605 | ini_restore('max_execution_time');
|
| 2606 | 2606 | |
| 2607 | - if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 2607 | + if ($ini_max_execution_time_check != 999999) { // only show these setting to the user if we can't change the ini setting
|
|
| 2608 | 2608 | ?> |
| 2609 | 2609 | <div id="gd_ie_reqs" class="metabox-holder"> |
| 2610 | 2610 | <div class="meta-box-sortables ui-sortable"> |
| 2611 | 2611 | <div class="postbox"> |
| 2612 | - <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'PHP Requirements for GD Import & Export CSV', 'geodirectory' );?></span></h3> |
|
| 2612 | + <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('PHP Requirements for GD Import & Export CSV', 'geodirectory'); ?></span></h3>
|
|
| 2613 | 2613 | <div class="inside"> |
| 2614 | - <span class="description"><?php echo __( 'Note: In case GD import & export csv not working for larger data then please check and configure following php settings.', 'geodirectory' );?></span> |
|
| 2614 | + <span class="description"><?php echo __('Note: In case GD import & export csv not working for larger data then please check and configure following php settings.', 'geodirectory'); ?></span>
|
|
| 2615 | 2615 | <table class="form-table"> |
| 2616 | 2616 | <thead> |
| 2617 | 2617 | <tr> |
| 2618 | - <th><?php _e( 'PHP Settings', 'geodirectory' );?></th><th><?php _e( 'Current Value', 'geodirectory' );?></th><th><?php _e( 'Recommended Value', 'geodirectory' );?></th> |
|
| 2618 | + <th><?php _e('PHP Settings', 'geodirectory'); ?></th><th><?php _e('Current Value', 'geodirectory'); ?></th><th><?php _e('Recommended Value', 'geodirectory'); ?></th>
|
|
| 2619 | 2619 | </tr> |
| 2620 | 2620 | </thead> |
| 2621 | 2621 | <tbody> |
| 2622 | 2622 | <tr> |
| 2623 | - <td>max_input_time</td><td><?php echo @ini_get( 'max_input_time' );?></td><td>3000</td> |
|
| 2623 | + <td>max_input_time</td><td><?php echo @ini_get('max_input_time'); ?></td><td>3000</td>
|
|
| 2624 | 2624 | </tr> |
| 2625 | 2625 | <tr> |
| 2626 | - <td>max_execution_time</td><td><?php echo @ini_get( 'max_execution_time' );?></td><td>3000</td> |
|
| 2626 | + <td>max_execution_time</td><td><?php echo @ini_get('max_execution_time'); ?></td><td>3000</td>
|
|
| 2627 | 2627 | </tr> |
| 2628 | 2628 | <tr> |
| 2629 | - <td>memory_limit</td><td><?php echo @ini_get( 'memory_limit' );?></td><td>256M</td> |
|
| 2629 | + <td>memory_limit</td><td><?php echo @ini_get('memory_limit'); ?></td><td>256M</td>
|
|
| 2630 | 2630 | </tr> |
| 2631 | 2631 | </tbody> |
| 2632 | 2632 | </table> |
@@ -2638,21 +2638,21 @@ discard block |
||
| 2638 | 2638 | <div id="gd_ie_imposts" class="metabox-holder"> |
| 2639 | 2639 | <div class="meta-box-sortables ui-sortable"> |
| 2640 | 2640 | <div id="gd_ie_im_posts" class="postbox gd-hndle-pbox"> |
| 2641 | - <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Listings: Import CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button> |
|
| 2642 | - <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Import CSV', 'geodirectory' );?></span></h3> |
|
| 2641 | + <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Listings: Import CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
|
|
| 2642 | + <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Listings: Import CSV', 'geodirectory'); ?></span></h3>
|
|
| 2643 | 2643 | <div class="inside"> |
| 2644 | 2644 | <table class="form-table"> |
| 2645 | 2645 | <tbody> |
| 2646 | 2646 | <tr> |
| 2647 | 2647 | <td class="gd-imex-box"> |
| 2648 | 2648 | <div class="gd-im-choices"> |
| 2649 | - <p><input type="radio" value="update" name="gd_im_choicepost" id="gd_im_pchoice_u" /><label for="gd_im_pchoice_u"><?php _e( 'Update listing if post with post_id already exists.', 'geodirectory' );?></label></p> |
|
| 2650 | - <p><input type="radio" checked="checked" value="skip" name="gd_im_choicepost" id="gd_im_pchoice_s" /><label for="gd_im_pchoice_s"><?php _e( 'Ignore listing if post with post_id already exists.', 'geodirectory' );?></label></p> |
|
| 2649 | + <p><input type="radio" value="update" name="gd_im_choicepost" id="gd_im_pchoice_u" /><label for="gd_im_pchoice_u"><?php _e('Update listing if post with post_id already exists.', 'geodirectory'); ?></label></p>
|
|
| 2650 | + <p><input type="radio" checked="checked" value="skip" name="gd_im_choicepost" id="gd_im_pchoice_s" /><label for="gd_im_pchoice_s"><?php _e('Ignore listing if post with post_id already exists.', 'geodirectory'); ?></label></p>
|
|
| 2651 | 2651 | </div> |
| 2652 | 2652 | <div class="plupload-upload-uic hide-if-no-js" id="gd_im_postplupload-upload-ui"> |
| 2653 | 2653 | <input type="text" readonly="readonly" name="gd_im_post_file" class="gd-imex-file gd_im_post_file" id="gd_im_post" onclick="jQuery('#gd_im_postplupload-browse-button').trigger('click');" />
|
| 2654 | - <input id="gd_im_postplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-pupload button-primary" /><input type="button" value="<?php echo esc_attr( __( 'Download Sample CSV', 'geodirectory' ) );?>" class="button-secondary" name="gd_ie_imposts_sample" id="gd_ie_imposts_sample"> |
|
| 2655 | - <input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv;?>" /> |
|
| 2654 | + <input id="gd_im_postplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-pupload button-primary" /><input type="button" value="<?php echo esc_attr(__('Download Sample CSV', 'geodirectory')); ?>" class="button-secondary" name="gd_ie_imposts_sample" id="gd_ie_imposts_sample">
|
|
| 2655 | + <input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv; ?>" /> |
|
| 2656 | 2656 | <?php |
| 2657 | 2657 | /** |
| 2658 | 2658 | * Called just after the sample CSV download link. |
@@ -2661,7 +2661,7 @@ discard block |
||
| 2661 | 2661 | */ |
| 2662 | 2662 | do_action('geodir_sample_csv_download_link');
|
| 2663 | 2663 | ?> |
| 2664 | - <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_postpluploadan' ); ?>"></span> |
|
| 2664 | + <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_postpluploadan'); ?>"></span>
|
|
| 2665 | 2665 | <div class="filelist"></div> |
| 2666 | 2666 | </div> |
| 2667 | 2667 | <span id="gd_im_catupload-error" style="display:none"></span> |
@@ -2679,7 +2679,7 @@ discard block |
||
| 2679 | 2679 | <input type="hidden" id="gd_terminateaction" value="continue"/> |
| 2680 | 2680 | </div> |
| 2681 | 2681 | <div class="gd-import-progress" id="gd-import-progress" style="display:none"> |
| 2682 | - <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
|
|
| 2682 | + <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
|
|
| 2683 | 2683 | id="gd-import-done">0</font> / <font id="gd-import-total">0</font> ( <font |
| 2684 | 2684 | id="gd-import-perc">0%</font> ) |
| 2685 | 2685 | <div class="gd-fileprogress"></div> |
@@ -2691,10 +2691,10 @@ discard block |
||
| 2691 | 2691 | <div class="gd-imex-btns" style="display:none;"> |
| 2692 | 2692 | <input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/> |
| 2693 | 2693 | <input onclick="gd_imex_PrepareImport(this, 'post')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" /> |
| 2694 | - <input onclick="gd_imex_ContinueImport(this, 'post')" type="button" value="<?php _e( "Continue Import Data", 'geodirectory' );?>" id="gd_continue_data" class="button-primary" style="display:none"/> |
|
| 2695 | - <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory');?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'post')"/>
|
|
| 2694 | + <input onclick="gd_imex_ContinueImport(this, 'post')" type="button" value="<?php _e("Continue Import Data", 'geodirectory'); ?>" id="gd_continue_data" class="button-primary" style="display:none"/>
|
|
| 2695 | + <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory'); ?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'post')"/>
|
|
| 2696 | 2696 | <div id="gd_process_data" style="display:none"> |
| 2697 | - <span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
|
|
| 2697 | + <span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
|
|
| 2698 | 2698 | </div> |
| 2699 | 2699 | </div> |
| 2700 | 2700 | </td> |
@@ -2708,26 +2708,26 @@ discard block |
||
| 2708 | 2708 | <div id="gd_ie_excategs" class="metabox-holder"> |
| 2709 | 2709 | <div class="meta-box-sortables ui-sortable"> |
| 2710 | 2710 | <div id="gd_ie_ex_posts" class="postbox gd-hndle-pbox"> |
| 2711 | - <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - Listings: Export CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button> |
|
| 2712 | - <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Export CSV', 'geodirectory' );?></span></h3> |
|
| 2711 | + <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - Listings: Export CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
|
|
| 2712 | + <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Listings: Export CSV', 'geodirectory'); ?></span></h3>
|
|
| 2713 | 2713 | <div class="inside"> |
| 2714 | 2714 | <table class="form-table"> |
| 2715 | 2715 | <tbody> |
| 2716 | 2716 | <tr> |
| 2717 | 2717 | <td class="fld"><label for="gd_post_type"> |
| 2718 | - <?php _e( 'Post Type:', 'geodirectory' );?> |
|
| 2718 | + <?php _e('Post Type:', 'geodirectory'); ?>
|
|
| 2719 | 2719 | </label></td> |
| 2720 | 2720 | <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"> |
| 2721 | - <?php echo $gd_posttypes_option;?> |
|
| 2721 | + <?php echo $gd_posttypes_option; ?> |
|
| 2722 | 2722 | </select></td> |
| 2723 | 2723 | </tr> |
| 2724 | 2724 | <tr> |
| 2725 | - <td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td> |
|
| 2726 | - <td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option;?></select><span class="description"><?php _e( 'Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory' );?></span></td> |
|
| 2725 | + <td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
|
|
| 2726 | + <td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option; ?></select><span class="description"><?php _e('Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory'); ?></span></td>
|
|
| 2727 | 2727 | </tr> |
| 2728 | 2728 | <tr> |
| 2729 | 2729 | <td class="fld" style="vertical-align:top"><label> |
| 2730 | - <?php _e( 'Progress:', 'geodirectory' );?> |
|
| 2730 | + <?php _e('Progress:', 'geodirectory'); ?>
|
|
| 2731 | 2731 | </label></td> |
| 2732 | 2732 | <td><div id='gd_progressbar_box'> |
| 2733 | 2733 | <div id="gd_progressbar" class="gd_progressbar"> |
@@ -2735,13 +2735,13 @@ discard block |
||
| 2735 | 2735 | </div> |
| 2736 | 2736 | </div> |
| 2737 | 2737 | <p style="display:inline-block"> |
| 2738 | - <?php _e( 'Elapsed Time:', 'geodirectory' );?> |
|
| 2738 | + <?php _e('Elapsed Time:', 'geodirectory'); ?>
|
|
| 2739 | 2739 | </p> |
| 2740 | 2740 | |
| 2741 | 2741 | <p id="gd_timer" class="gd_timer">00:00:00</p></td> |
| 2742 | 2742 | </tr> |
| 2743 | 2743 | <tr class="gd-ie-actions"> |
| 2744 | - <td style="vertical-align:top"><input type="submit" value="<?php echo esc_attr( __( 'Export CSV', 'geodirectory' ) );?>" class="button-primary" name="gd_ie_exposts_submit" id="gd_ie_exposts_submit"> |
|
| 2744 | + <td style="vertical-align:top"><input type="submit" value="<?php echo esc_attr(__('Export CSV', 'geodirectory')); ?>" class="button-primary" name="gd_ie_exposts_submit" id="gd_ie_exposts_submit">
|
|
| 2745 | 2745 | </td> |
| 2746 | 2746 | <td id="gd_ie_ex_files" class="gd-ie-files"></td> |
| 2747 | 2747 | </tr> |
@@ -2754,21 +2754,21 @@ discard block |
||
| 2754 | 2754 | <div id="gd_ie_imcategs" class="metabox-holder"> |
| 2755 | 2755 | <div class="meta-box-sortables ui-sortable"> |
| 2756 | 2756 | <div id="gd_ie_imcats" class="postbox gd-hndle-pbox"> |
| 2757 | - <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Categories: Import CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button> |
|
| 2758 | - <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Import CSV', 'geodirectory' );?></span></h3> |
|
| 2757 | + <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Categories: Import CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
|
|
| 2758 | + <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Categories: Import CSV', 'geodirectory'); ?></span></h3>
|
|
| 2759 | 2759 | <div class="inside"> |
| 2760 | 2760 | <table class="form-table"> |
| 2761 | 2761 | <tbody> |
| 2762 | 2762 | <tr> |
| 2763 | 2763 | <td class="gd-imex-box"> |
| 2764 | 2764 | <div class="gd-im-choices"> |
| 2765 | - <p><input type="radio" value="update" name="gd_im_choicecat" id="gd_im_cchoice_u" /><label for="gd_im_cchoice_u"><?php _e( 'Update item if item with cat_id/cat_slug already exists.', 'geodirectory' );?></label></p> |
|
| 2766 | - <p><input type="radio" checked="checked" value="skip" name="gd_im_choicecat" id="gd_im_cchoice_s" /><label for="gd_im_cchoice_s"><?php _e( 'Ignore item if item with cat_id/cat_slug already exists.', 'geodirectory' );?></label></p> |
|
| 2765 | + <p><input type="radio" value="update" name="gd_im_choicecat" id="gd_im_cchoice_u" /><label for="gd_im_cchoice_u"><?php _e('Update item if item with cat_id/cat_slug already exists.', 'geodirectory'); ?></label></p>
|
|
| 2766 | + <p><input type="radio" checked="checked" value="skip" name="gd_im_choicecat" id="gd_im_cchoice_s" /><label for="gd_im_cchoice_s"><?php _e('Ignore item if item with cat_id/cat_slug already exists.', 'geodirectory'); ?></label></p>
|
|
| 2767 | 2767 | </div> |
| 2768 | 2768 | <div class="plupload-upload-uic hide-if-no-js" id="gd_im_catplupload-upload-ui"> |
| 2769 | 2769 | <input type="text" readonly="readonly" name="gd_im_cat_file" class="gd-imex-file gd_im_cat_file" id="gd_im_cat" onclick="jQuery('#gd_im_catplupload-browse-button').trigger('click');" />
|
| 2770 | - <input id="gd_im_catplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-cupload button-primary" /><input type="button" value="<?php echo esc_attr( __( 'Download Sample CSV', 'geodirectory' ) );?>" class="button-secondary" name="gd_ie_imcats_sample" id="gd_ie_imcats_sample"> |
|
| 2771 | - <input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv;?>" /> |
|
| 2770 | + <input id="gd_im_catplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-cupload button-primary" /><input type="button" value="<?php echo esc_attr(__('Download Sample CSV', 'geodirectory')); ?>" class="button-secondary" name="gd_ie_imcats_sample" id="gd_ie_imcats_sample">
|
|
| 2771 | + <input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv; ?>" /> |
|
| 2772 | 2772 | <?php |
| 2773 | 2773 | /** |
| 2774 | 2774 | * Called just after the sample CSV download link. |
@@ -2778,7 +2778,7 @@ discard block |
||
| 2778 | 2778 | */ |
| 2779 | 2779 | do_action('geodir_sample_cats_csv_download_link');
|
| 2780 | 2780 | ?> |
| 2781 | - <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_catpluploadan' ); ?>"></span> |
|
| 2781 | + <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_catpluploadan'); ?>"></span>
|
|
| 2782 | 2782 | <div class="filelist"></div> |
| 2783 | 2783 | </div> |
| 2784 | 2784 | <span id="gd_im_catupload-error" style="display:none"></span> |
@@ -2795,7 +2795,7 @@ discard block |
||
| 2795 | 2795 | <input type="hidden" id="gd_terminateaction" value="continue"/> |
| 2796 | 2796 | </div> |
| 2797 | 2797 | <div class="gd-import-progress" id="gd-import-progress" style="display:none"> |
| 2798 | - <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
|
|
| 2798 | + <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
|
|
| 2799 | 2799 | id="gd-import-done">0</font> / <font id="gd-import-total">0</font> ( <font |
| 2800 | 2800 | id="gd-import-perc">0%</font> ) |
| 2801 | 2801 | <div class="gd-fileprogress"></div> |
@@ -2807,10 +2807,10 @@ discard block |
||
| 2807 | 2807 | <div class="gd-imex-btns" style="display:none;"> |
| 2808 | 2808 | <input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/> |
| 2809 | 2809 | <input onclick="gd_imex_PrepareImport(this, 'cat')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" /> |
| 2810 | - <input onclick="gd_imex_ContinueImport(this, 'cat')" type="button" value="<?php _e( "Continue Import Data", 'geodirectory' );?>" id="gd_continue_data" class="button-primary" style="display:none"/> |
|
| 2811 | - <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory');?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'cat')"/>
|
|
| 2810 | + <input onclick="gd_imex_ContinueImport(this, 'cat')" type="button" value="<?php _e("Continue Import Data", 'geodirectory'); ?>" id="gd_continue_data" class="button-primary" style="display:none"/>
|
|
| 2811 | + <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory'); ?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'cat')"/>
|
|
| 2812 | 2812 | <div id="gd_process_data" style="display:none"> |
| 2813 | - <span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
|
|
| 2813 | + <span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
|
|
| 2814 | 2814 | </div> |
| 2815 | 2815 | </div> |
| 2816 | 2816 | </td> |
@@ -2824,26 +2824,26 @@ discard block |
||
| 2824 | 2824 | <div id="gd_ie_excategs" class="metabox-holder"> |
| 2825 | 2825 | <div class="meta-box-sortables ui-sortable"> |
| 2826 | 2826 | <div id="gd_ie_ex_cats" class="postbox gd-hndle-pbox"> |
| 2827 | - <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e( 'Toggle panel - GD Categories: Export CSV', 'geodirectory' );?></span><span aria-hidden="true" class="toggle-indicator"></span></button> |
|
| 2828 | - <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Export CSV', 'geodirectory' );?></span></h3> |
|
| 2827 | + <button class="handlediv button-link" type="button"><span class="screen-reader-text"><?php _e('Toggle panel - GD Categories: Export CSV', 'geodirectory'); ?></span><span aria-hidden="true" class="toggle-indicator"></span></button>
|
|
| 2828 | + <h3 class="hndle gd-hndle-click"><span style='vertical-align:top;'><?php echo __('GD Categories: Export CSV', 'geodirectory'); ?></span></h3>
|
|
| 2829 | 2829 | <div class="inside"> |
| 2830 | 2830 | <table class="form-table"> |
| 2831 | 2831 | <tbody> |
| 2832 | 2832 | <tr> |
| 2833 | - <td class="fld"><label for="gd_post_type"><?php _e( 'Post Type:', 'geodirectory' );?></label></td> |
|
| 2834 | - <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option;?></select></td> |
|
| 2833 | + <td class="fld"><label for="gd_post_type"><?php _e('Post Type:', 'geodirectory'); ?></label></td>
|
|
| 2834 | + <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option; ?></select></td> |
|
| 2835 | 2835 | </tr> |
| 2836 | 2836 | <tr> |
| 2837 | - <td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td> |
|
| 2838 | - <td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option;?></select><span class="description"><?php _e( 'Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory' );?></span></td> |
|
| 2837 | + <td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
|
|
| 2838 | + <td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option; ?></select><span class="description"><?php _e('Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory'); ?></span></td>
|
|
| 2839 | 2839 | </tr> |
| 2840 | 2840 | <tr> |
| 2841 | - <td class="fld" style="vertical-align:top"><label><?php _e( 'Progress:', 'geodirectory' );?></label></td> |
|
| 2842 | - <td><div id='gd_progressbar_box'><div id="gd_progressbar" class="gd_progressbar"><div class="gd-progress-label"></div></div></div><p style="display:inline-block"><?php _e( 'Elapsed Time:', 'geodirectory' );?></p> <p id="gd_timer" class="gd_timer">00:00:00</p></td> |
|
| 2841 | + <td class="fld" style="vertical-align:top"><label><?php _e('Progress:', 'geodirectory'); ?></label></td>
|
|
| 2842 | + <td><div id='gd_progressbar_box'><div id="gd_progressbar" class="gd_progressbar"><div class="gd-progress-label"></div></div></div><p style="display:inline-block"><?php _e('Elapsed Time:', 'geodirectory'); ?></p> <p id="gd_timer" class="gd_timer">00:00:00</p></td>
|
|
| 2843 | 2843 | </tr> |
| 2844 | 2844 | <tr class="gd-ie-actions"> |
| 2845 | 2845 | <td style="vertical-align:top"> |
| 2846 | - <input type="submit" value="<?php echo esc_attr( __( 'Export CSV', 'geodirectory' ) );?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit"> |
|
| 2846 | + <input type="submit" value="<?php echo esc_attr(__('Export CSV', 'geodirectory')); ?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
|
|
| 2847 | 2847 | </td> |
| 2848 | 2848 | <td id="gd_ie_ex_files" class="gd-ie-files"></td> |
| 2849 | 2849 | </tr> |
@@ -2865,7 +2865,7 @@ discard block |
||
| 2865 | 2865 | * @param array $gd_chunksize_options File chunk size options. |
| 2866 | 2866 | * @param string $nonce Wordpress security token for GD import & export. |
| 2867 | 2867 | */ |
| 2868 | - do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
|
| 2868 | + do_action('geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce);
|
|
| 2869 | 2869 | ?> |
| 2870 | 2870 | </div> |
| 2871 | 2871 | </div> |
@@ -2884,7 +2884,7 @@ discard block |
||
| 2884 | 2884 | jQuery.ajax({
|
| 2885 | 2885 | url: ajaxurl, |
| 2886 | 2886 | type: "POST", |
| 2887 | - data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce;?>', |
|
| 2887 | + data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce; ?>', |
|
| 2888 | 2888 | dataType: 'json', |
| 2889 | 2889 | cache: false, |
| 2890 | 2890 | success: function(data) {
|
@@ -2936,7 +2936,7 @@ discard block |
||
| 2936 | 2936 | |
| 2937 | 2937 | jQuery(cont).find('.filelist .file').remove();
|
| 2938 | 2938 | |
| 2939 | - jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr( PLZ_SELECT_CSV_FILE );?></p>");
|
|
| 2939 | + jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr(PLZ_SELECT_CSV_FILE); ?></p>");
|
|
| 2940 | 2940 | jQuery('#gd-import-msg', cont).show();
|
| 2941 | 2941 | |
| 2942 | 2942 | return false; |
@@ -2995,7 +2995,7 @@ discard block |
||
| 2995 | 2995 | jQuery.ajax({
|
| 2996 | 2996 | url: ajaxurl, |
| 2997 | 2997 | type: "POST", |
| 2998 | - data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce;?>', |
|
| 2998 | + data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce; ?>', |
|
| 2999 | 2999 | dataType : 'json', |
| 3000 | 3000 | cache: false, |
| 3001 | 3001 | success: function (data) {
|
@@ -3184,27 +3184,27 @@ discard block |
||
| 3184 | 3184 | |
| 3185 | 3185 | var gdMsg = '<p></p>'; |
| 3186 | 3186 | if ( processed > 0 ) {
|
| 3187 | - var msgParse = '<p><?php echo addslashes( sprintf( __( 'Total %s item(s) found.', 'geodirectory' ), '%s' ) );?></p>'; |
|
| 3187 | + var msgParse = '<p><?php echo addslashes(sprintf(__('Total %s item(s) found.', 'geodirectory'), '%s')); ?></p>';
|
|
| 3188 | 3188 | msgParse = msgParse.replace("%s", processed);
|
| 3189 | 3189 | gdMsg += msgParse; |
| 3190 | 3190 | } |
| 3191 | 3191 | |
| 3192 | 3192 | if ( updated > 0 ) {
|
| 3193 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) updated.', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 3193 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) updated.', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 3194 | 3194 | msgParse = msgParse.replace("%s", updated);
|
| 3195 | 3195 | msgParse = msgParse.replace("%d", processed);
|
| 3196 | 3196 | gdMsg += msgParse; |
| 3197 | 3197 | } |
| 3198 | 3198 | |
| 3199 | 3199 | if ( created > 0 ) {
|
| 3200 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) added.', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 3200 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) added.', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 3201 | 3201 | msgParse = msgParse.replace("%s", created);
|
| 3202 | 3202 | msgParse = msgParse.replace("%d", processed);
|
| 3203 | 3203 | gdMsg += msgParse; |
| 3204 | 3204 | } |
| 3205 | 3205 | |
| 3206 | 3206 | if ( skipped > 0 ) {
|
| 3207 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) ignored due to already exists.', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 3207 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) ignored due to already exists.', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 3208 | 3208 | msgParse = msgParse.replace("%s", skipped);
|
| 3209 | 3209 | msgParse = msgParse.replace("%d", processed);
|
| 3210 | 3210 | gdMsg += msgParse; |
@@ -3214,17 +3214,17 @@ discard block |
||
| 3214 | 3214 | if (type=='loc') {
|
| 3215 | 3215 | invalid_addr = invalid; |
| 3216 | 3216 | } |
| 3217 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 3217 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 3218 | 3218 | msgParse = msgParse.replace("%s", invalid_addr);
|
| 3219 | 3219 | msgParse = msgParse.replace("%d", total);
|
| 3220 | 3220 | gdMsg += msgParse; |
| 3221 | 3221 | } |
| 3222 | 3222 | |
| 3223 | 3223 | if (invalid > 0 && type!='loc') {
|
| 3224 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to blank title/invalid post type/invalid characters used in data.', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 3224 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to blank title/invalid post type/invalid characters used in data.', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 3225 | 3225 | |
| 3226 | 3226 | if (type=='hood') {
|
| 3227 | - msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 3227 | + msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 3228 | 3228 | } |
| 3229 | 3229 | msgParse = msgParse.replace("%s", invalid);
|
| 3230 | 3230 | msgParse = msgParse.replace("%d", total);
|
@@ -3232,7 +3232,7 @@ discard block |
||
| 3232 | 3232 | } |
| 3233 | 3233 | |
| 3234 | 3234 | if (images > 0) {
|
| 3235 | - gdMsg += '<p><?php echo addslashes( sprintf( CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'] ) );?></p>'; |
|
| 3235 | + gdMsg += '<p><?php echo addslashes(sprintf(CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'])); ?></p>'; |
|
| 3236 | 3236 | } |
| 3237 | 3237 | gdMsg += '<p></p>'; |
| 3238 | 3238 | jQuery('#gd-import-msg', cont).find('#message').removeClass('error').addClass('updated').html(gdMsg);
|
@@ -3381,7 +3381,7 @@ discard block |
||
| 3381 | 3381 | |
| 3382 | 3382 | function gd_process_export_posts(el, post_type, total_posts, chunk_size, pages, page) {
|
| 3383 | 3383 | if (page < 2) {
|
| 3384 | - gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>'); |
|
| 3384 | + gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
|
|
| 3385 | 3385 | jQuery(el).find('#gd_timer').text('00:00:01');
|
| 3386 | 3386 | jQuery('#gd_ie_ex_files', el).html('');
|
| 3387 | 3387 | } |
@@ -3389,7 +3389,7 @@ discard block |
||
| 3389 | 3389 | jQuery.ajax({
|
| 3390 | 3390 | url: ajaxurl, |
| 3391 | 3391 | type: "POST", |
| 3392 | - data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page, |
|
| 3392 | + data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page, |
|
| 3393 | 3393 | dataType : 'json', |
| 3394 | 3394 | cache: false, |
| 3395 | 3395 | beforeSend: function (jqXHR, settings) {},
|
@@ -3403,11 +3403,11 @@ discard block |
||
| 3403 | 3403 | } else {
|
| 3404 | 3404 | if (pages < page || pages == page) {
|
| 3405 | 3405 | window.clearInterval(timer_posts); |
| 3406 | - gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
|
|
| 3406 | + gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
|
|
| 3407 | 3407 | } else {
|
| 3408 | 3408 | var percentage = Math.round(((page * chunk_size) / total_posts) * 100); |
| 3409 | 3409 | percentage = percentage > 100 ? 100 : percentage; |
| 3410 | - gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
|
|
| 3410 | + gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
|
|
| 3411 | 3411 | } |
| 3412 | 3412 | if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
|
| 3413 | 3413 | var obj_files = data.files; |
@@ -3437,7 +3437,7 @@ discard block |
||
| 3437 | 3437 | |
| 3438 | 3438 | function gd_process_export_cats(el, post_type, total_cats, chunk_size, pages, page) {
|
| 3439 | 3439 | if (page < 2) {
|
| 3440 | - gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>'); |
|
| 3440 | + gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
|
|
| 3441 | 3441 | jQuery(el).find('#gd_timer').text('00:00:01');
|
| 3442 | 3442 | jQuery('#gd_ie_ex_files', el).html('');
|
| 3443 | 3443 | } |
@@ -3445,7 +3445,7 @@ discard block |
||
| 3445 | 3445 | jQuery.ajax({
|
| 3446 | 3446 | url: ajaxurl, |
| 3447 | 3447 | type: "POST", |
| 3448 | - data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page, |
|
| 3448 | + data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page, |
|
| 3449 | 3449 | dataType : 'json', |
| 3450 | 3450 | cache: false, |
| 3451 | 3451 | beforeSend: function (jqXHR, settings) {},
|
@@ -3459,11 +3459,11 @@ discard block |
||
| 3459 | 3459 | } else {
|
| 3460 | 3460 | if (pages < page || pages == page) {
|
| 3461 | 3461 | window.clearInterval(timer_cats); |
| 3462 | - gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
|
|
| 3462 | + gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
|
|
| 3463 | 3463 | } else {
|
| 3464 | 3464 | var percentage = Math.round(((page * chunk_size) / total_cats) * 100); |
| 3465 | 3465 | percentage = percentage > 100 ? 100 : percentage; |
| 3466 | - gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e( 'Exporting...', 'geodirectory' );?>');
|
|
| 3466 | + gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e('Exporting...', 'geodirectory'); ?>');
|
|
| 3467 | 3467 | } |
| 3468 | 3468 | if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
|
| 3469 | 3469 | var obj_files = data.files; |
@@ -3520,13 +3520,13 @@ discard block |
||
| 3520 | 3520 | function geodir_init_filesystem() |
| 3521 | 3521 | {
|
| 3522 | 3522 | |
| 3523 | - if(!function_exists('get_filesystem_method')){
|
|
| 3523 | + if (!function_exists('get_filesystem_method')) {
|
|
| 3524 | 3524 | require_once(ABSPATH."/wp-admin/includes/file.php"); |
| 3525 | 3525 | } |
| 3526 | 3526 | $access_type = get_filesystem_method(); |
| 3527 | 3527 | if ($access_type === 'direct') {
|
| 3528 | 3528 | /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
| 3529 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3529 | + $creds = request_filesystem_credentials(trailingslashit(site_url()).'wp-admin/', '', false, false, array()); |
|
| 3530 | 3530 | |
| 3531 | 3531 | /* initialize the API */ |
| 3532 | 3532 | if (!WP_Filesystem($creds)) {
|
@@ -3539,7 +3539,7 @@ discard block |
||
| 3539 | 3539 | return $wp_filesystem; |
| 3540 | 3540 | /* do our file manipulations below */ |
| 3541 | 3541 | } elseif (defined('FTP_USER')) {
|
| 3542 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3542 | + $creds = request_filesystem_credentials(trailingslashit(site_url()).'wp-admin/', '', false, false, array()); |
|
| 3543 | 3543 | |
| 3544 | 3544 | /* initialize the API */ |
| 3545 | 3545 | if (!WP_Filesystem($creds)) {
|
@@ -3574,7 +3574,7 @@ discard block |
||
| 3574 | 3574 | * @package GeoDirectory |
| 3575 | 3575 | */ |
| 3576 | 3576 | function geodir_filesystem_notice() |
| 3577 | -{ if ( defined( 'DOING_AJAX' ) ){return;}
|
|
| 3577 | +{ if (defined('DOING_AJAX')) {return; }
|
|
| 3578 | 3578 | $access_type = get_filesystem_method(); |
| 3579 | 3579 | if ($access_type === 'direct') {
|
| 3580 | 3580 | } elseif (!defined('FTP_USER')) {
|
@@ -3611,64 +3611,64 @@ discard block |
||
| 3611 | 3611 | // try to set higher limits for import |
| 3612 | 3612 | $max_input_time = ini_get('max_input_time');
|
| 3613 | 3613 | $max_execution_time = ini_get('max_execution_time');
|
| 3614 | - $memory_limit= ini_get('memory_limit');
|
|
| 3614 | + $memory_limit = ini_get('memory_limit');
|
|
| 3615 | 3615 | |
| 3616 | - if(!$max_input_time || $max_input_time<3000){
|
|
| 3616 | + if (!$max_input_time || $max_input_time < 3000) {
|
|
| 3617 | 3617 | ini_set('max_input_time', 3000);
|
| 3618 | 3618 | } |
| 3619 | 3619 | |
| 3620 | - if(!$max_execution_time || $max_execution_time<3000){
|
|
| 3620 | + if (!$max_execution_time || $max_execution_time < 3000) {
|
|
| 3621 | 3621 | ini_set('max_execution_time', 3000);
|
| 3622 | 3622 | } |
| 3623 | 3623 | |
| 3624 | - if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 3625 | - if(str_replace('M','',$memory_limit)<256){
|
|
| 3624 | + if ($memory_limit && str_replace('M', '', $memory_limit)) {
|
|
| 3625 | + if (str_replace('M', '', $memory_limit) < 256) {
|
|
| 3626 | 3626 | ini_set('memory_limit', '256M');
|
| 3627 | 3627 | } |
| 3628 | 3628 | } |
| 3629 | 3629 | |
| 3630 | 3630 | $json = array(); |
| 3631 | 3631 | |
| 3632 | - if ( !current_user_can( 'manage_options' ) ) {
|
|
| 3633 | - wp_send_json( $json ); |
|
| 3632 | + if (!current_user_can('manage_options')) {
|
|
| 3633 | + wp_send_json($json); |
|
| 3634 | 3634 | } |
| 3635 | 3635 | |
| 3636 | - $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 3637 | - $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 3638 | - $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 3636 | + $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : NULL; |
|
| 3637 | + $nonce = isset($_REQUEST['_nonce']) ? $_REQUEST['_nonce'] : NULL; |
|
| 3638 | + $stat = isset($_REQUEST['_st']) ? $_REQUEST['_st'] : false; |
|
| 3639 | 3639 | |
| 3640 | - if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 3641 | - wp_send_json( $json ); |
|
| 3640 | + if (!wp_verify_nonce($nonce, 'geodir_import_export_nonce')) {
|
|
| 3641 | + wp_send_json($json); |
|
| 3642 | 3642 | } |
| 3643 | 3643 | |
| 3644 | - $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 3645 | - $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 3644 | + $post_type = isset($_REQUEST['_pt']) ? $_REQUEST['_pt'] : NULL; |
|
| 3645 | + $chunk_per_page = isset($_REQUEST['_n']) ? absint($_REQUEST['_n']) : NULL; |
|
| 3646 | 3646 | $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
| 3647 | - $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 3647 | + $chunk_page_no = isset($_REQUEST['_p']) ? absint($_REQUEST['_p']) : 1; |
|
| 3648 | 3648 | |
| 3649 | 3649 | $wp_filesystem = geodir_init_filesystem(); |
| 3650 | 3650 | if (!$wp_filesystem) {
|
| 3651 | - $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 3652 | - wp_send_json( $json ); |
|
| 3651 | + $json['error'] = __('Filesystem ERROR: Could not access filesystem.', 'geodirectory');
|
|
| 3652 | + wp_send_json($json); |
|
| 3653 | 3653 | } |
| 3654 | 3654 | |
| 3655 | 3655 | if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
| 3656 | - $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 3657 | - wp_send_json( $json ); |
|
| 3656 | + $json['error'] = __('Filesystem ERROR: '.$wp_filesystem->errors->get_error_message(), 'geodirectory');
|
|
| 3657 | + wp_send_json($json); |
|
| 3658 | 3658 | } |
| 3659 | 3659 | |
| 3660 | - $csv_file_dir = geodir_path_import_export( false ); |
|
| 3661 | - if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 3662 | - if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 3663 | - $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3664 | - wp_send_json( $json ); |
|
| 3660 | + $csv_file_dir = geodir_path_import_export(false); |
|
| 3661 | + if (!$wp_filesystem->is_dir($csv_file_dir)) {
|
|
| 3662 | + if (!$wp_filesystem->mkdir($csv_file_dir, FS_CHMOD_DIR)) {
|
|
| 3663 | + $json['error'] = __('ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory');
|
|
| 3664 | + wp_send_json($json); |
|
| 3665 | 3665 | } |
| 3666 | 3666 | } |
| 3667 | 3667 | |
| 3668 | 3668 | $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
| 3669 | 3669 | $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
| 3670 | 3670 | |
| 3671 | - switch ( $task ) {
|
|
| 3671 | + switch ($task) {
|
|
| 3672 | 3672 | case 'export_posts': {
|
| 3673 | 3673 | // WPML |
| 3674 | 3674 | $is_wpml = geodir_is_wpml(); |
@@ -3679,22 +3679,22 @@ discard block |
||
| 3679 | 3679 | $sitepress->switch_lang('all', true);
|
| 3680 | 3680 | } |
| 3681 | 3681 | // WPML |
| 3682 | - if ( $post_type == 'gd_event' ) {
|
|
| 3683 | - add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 3682 | + if ($post_type == 'gd_event') {
|
|
| 3683 | + add_filter('geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2);
|
|
| 3684 | 3684 | } |
| 3685 | - $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 3686 | - $posts_count = geodir_get_posts_count( $post_type ); |
|
| 3687 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3688 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3689 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3690 | - $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 3685 | + $file_name = $post_type.'_'.date('dmyHi');
|
|
| 3686 | + $posts_count = geodir_get_posts_count($post_type); |
|
| 3687 | + $file_url_base = geodir_path_import_export().'/'; |
|
| 3688 | + $file_url = $file_url_base.$file_name.'.csv'; |
|
| 3689 | + $file_path = $csv_file_dir.'/'.$file_name.'.csv'; |
|
| 3690 | + $file_path_temp = $csv_file_dir.'/'.$post_type.'_'.$nonce.'.csv'; |
|
| 3691 | 3691 | |
| 3692 | 3692 | $chunk_file_paths = array(); |
| 3693 | 3693 | |
| 3694 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3695 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3696 | - $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 3697 | - $percentage = min( $percentage, 100 ); |
|
| 3694 | + if (isset($_REQUEST['_st'])) {
|
|
| 3695 | + $line_count = (int) geodir_import_export_line_count($file_path_temp); |
|
| 3696 | + $percentage = count($posts_count) > 0 && $line_count > 0 ? ceil($line_count / $posts_count) * 100 : 0; |
|
| 3697 | + $percentage = min($percentage, 100); |
|
| 3698 | 3698 | |
| 3699 | 3699 | $json['percentage'] = $percentage; |
| 3700 | 3700 | // WPML |
@@ -3702,45 +3702,45 @@ discard block |
||
| 3702 | 3702 | $sitepress->switch_lang($active_lang, true); |
| 3703 | 3703 | } |
| 3704 | 3704 | // WPML |
| 3705 | - wp_send_json( $json ); |
|
| 3705 | + wp_send_json($json); |
|
| 3706 | 3706 | gd_die(); |
| 3707 | 3707 | } else {
|
| 3708 | - if ( !$posts_count > 0 ) {
|
|
| 3709 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3708 | + if (!$posts_count > 0) {
|
|
| 3709 | + $json['error'] = __('No records to export.', 'geodirectory');
|
|
| 3710 | 3710 | } else {
|
| 3711 | 3711 | $total_posts = $posts_count; |
| 3712 | 3712 | if ($chunk_per_page > $total_posts) {
|
| 3713 | 3713 | $chunk_per_page = $total_posts; |
| 3714 | 3714 | } |
| 3715 | - $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 3715 | + $chunk_total_pages = ceil($total_posts / $chunk_per_page); |
|
| 3716 | 3716 | |
| 3717 | 3717 | $j = $chunk_page_no; |
| 3718 | - $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 3718 | + $chunk_save_posts = geodir_imex_get_posts($post_type, $chunk_per_page, $j); |
|
| 3719 | 3719 | |
| 3720 | 3720 | $per_page = 500; |
| 3721 | 3721 | if ($per_page > $chunk_per_page) {
|
| 3722 | 3722 | $per_page = $chunk_per_page; |
| 3723 | 3723 | } |
| 3724 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3724 | + $total_pages = ceil($chunk_per_page / $per_page); |
|
| 3725 | 3725 | |
| 3726 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3727 | - $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 3726 | + for ($i = 0; $i <= $total_pages; $i++) {
|
|
| 3727 | + $save_posts = array_slice($chunk_save_posts, ($i * $per_page), $per_page); |
|
| 3728 | 3728 | |
| 3729 | 3729 | $clear = $i == 0 ? true : false; |
| 3730 | - geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 3730 | + geodir_save_csv_data($file_path_temp, $save_posts, $clear); |
|
| 3731 | 3731 | } |
| 3732 | 3732 | |
| 3733 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3734 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3735 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3736 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3737 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3733 | + if ($wp_filesystem->exists($file_path_temp)) {
|
|
| 3734 | + $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : ''; |
|
| 3735 | + $chunk_file_name = $file_name.$chunk_page_no.'.csv'; |
|
| 3736 | + $file_path = $csv_file_dir.'/'.$chunk_file_name; |
|
| 3737 | + $wp_filesystem->move($file_path_temp, $file_path, true); |
|
| 3738 | 3738 | |
| 3739 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3740 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3739 | + $file_url = $file_url_base.$chunk_file_name; |
|
| 3740 | + $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3741 | 3741 | } |
| 3742 | 3742 | |
| 3743 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3743 | + if (!empty($chunk_file_paths)) {
|
|
| 3744 | 3744 | $json['total'] = $posts_count; |
| 3745 | 3745 | $json['files'] = $chunk_file_paths; |
| 3746 | 3746 | } else {
|
@@ -3748,7 +3748,7 @@ discard block |
||
| 3748 | 3748 | $json['total'] = $posts_count; |
| 3749 | 3749 | $json['files'] = array(); |
| 3750 | 3750 | } else {
|
| 3751 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3751 | + $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
|
|
| 3752 | 3752 | } |
| 3753 | 3753 | } |
| 3754 | 3754 | } |
@@ -3757,7 +3757,7 @@ discard block |
||
| 3757 | 3757 | $sitepress->switch_lang($active_lang, true); |
| 3758 | 3758 | } |
| 3759 | 3759 | // WPML |
| 3760 | - wp_send_json( $json ); |
|
| 3760 | + wp_send_json($json); |
|
| 3761 | 3761 | } |
| 3762 | 3762 | } |
| 3763 | 3763 | break; |
@@ -3771,20 +3771,20 @@ discard block |
||
| 3771 | 3771 | $sitepress->switch_lang('all', true);
|
| 3772 | 3772 | } |
| 3773 | 3773 | // WPML |
| 3774 | - $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 3774 | + $file_name = $post_type.'category_'.date('dmyHi');
|
|
| 3775 | 3775 | |
| 3776 | - $terms_count = geodir_get_terms_count( $post_type ); |
|
| 3777 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3778 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3779 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3780 | - $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 3776 | + $terms_count = geodir_get_terms_count($post_type); |
|
| 3777 | + $file_url_base = geodir_path_import_export().'/'; |
|
| 3778 | + $file_url = $file_url_base.$file_name.'.csv'; |
|
| 3779 | + $file_path = $csv_file_dir.'/'.$file_name.'.csv'; |
|
| 3780 | + $file_path_temp = $csv_file_dir.'/'.$post_type.'category_'.$nonce.'.csv'; |
|
| 3781 | 3781 | |
| 3782 | 3782 | $chunk_file_paths = array(); |
| 3783 | 3783 | |
| 3784 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3785 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3786 | - $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 3787 | - $percentage = min( $percentage, 100 ); |
|
| 3784 | + if (isset($_REQUEST['_st'])) {
|
|
| 3785 | + $line_count = (int) geodir_import_export_line_count($file_path_temp); |
|
| 3786 | + $percentage = count($terms_count) > 0 && $line_count > 0 ? ceil($line_count / $terms_count) * 100 : 0; |
|
| 3787 | + $percentage = min($percentage, 100); |
|
| 3788 | 3788 | |
| 3789 | 3789 | $json['percentage'] = $percentage; |
| 3790 | 3790 | // WPML |
@@ -3792,48 +3792,48 @@ discard block |
||
| 3792 | 3792 | $sitepress->switch_lang($active_lang, true); |
| 3793 | 3793 | } |
| 3794 | 3794 | // WPML |
| 3795 | - wp_send_json( $json ); |
|
| 3795 | + wp_send_json($json); |
|
| 3796 | 3796 | } else {
|
| 3797 | - if ( !$terms_count > 0 ) {
|
|
| 3798 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3797 | + if (!$terms_count > 0) {
|
|
| 3798 | + $json['error'] = __('No records to export.', 'geodirectory');
|
|
| 3799 | 3799 | } else {
|
| 3800 | 3800 | $total_terms = $terms_count; |
| 3801 | 3801 | if ($chunk_per_page > $terms_count) {
|
| 3802 | 3802 | $chunk_per_page = $terms_count; |
| 3803 | 3803 | } |
| 3804 | - $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 3804 | + $chunk_total_pages = ceil($total_terms / $chunk_per_page); |
|
| 3805 | 3805 | |
| 3806 | 3806 | $j = $chunk_page_no; |
| 3807 | - $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 3807 | + $chunk_save_terms = geodir_imex_get_terms($post_type, $chunk_per_page, $j); |
|
| 3808 | 3808 | |
| 3809 | 3809 | $per_page = 500; |
| 3810 | 3810 | if ($per_page > $chunk_per_page) {
|
| 3811 | 3811 | $per_page = $chunk_per_page; |
| 3812 | 3812 | } |
| 3813 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3813 | + $total_pages = ceil($chunk_per_page / $per_page); |
|
| 3814 | 3814 | |
| 3815 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3816 | - $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 3815 | + for ($i = 0; $i <= $total_pages; $i++) {
|
|
| 3816 | + $save_terms = array_slice($chunk_save_terms, ($i * $per_page), $per_page); |
|
| 3817 | 3817 | |
| 3818 | 3818 | $clear = $i == 0 ? true : false; |
| 3819 | - geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 3819 | + geodir_save_csv_data($file_path_temp, $save_terms, $clear); |
|
| 3820 | 3820 | } |
| 3821 | 3821 | |
| 3822 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3823 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3824 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3825 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3826 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3822 | + if ($wp_filesystem->exists($file_path_temp)) {
|
|
| 3823 | + $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : ''; |
|
| 3824 | + $chunk_file_name = $file_name.$chunk_page_no.'.csv'; |
|
| 3825 | + $file_path = $csv_file_dir.'/'.$chunk_file_name; |
|
| 3826 | + $wp_filesystem->move($file_path_temp, $file_path, true); |
|
| 3827 | 3827 | |
| 3828 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3829 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3828 | + $file_url = $file_url_base.$chunk_file_name; |
|
| 3829 | + $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3830 | 3830 | } |
| 3831 | 3831 | |
| 3832 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3832 | + if (!empty($chunk_file_paths)) {
|
|
| 3833 | 3833 | $json['total'] = $terms_count; |
| 3834 | 3834 | $json['files'] = $chunk_file_paths; |
| 3835 | 3835 | } else {
|
| 3836 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3836 | + $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
|
|
| 3837 | 3837 | } |
| 3838 | 3838 | } |
| 3839 | 3839 | // WPML |
@@ -3841,127 +3841,127 @@ discard block |
||
| 3841 | 3841 | $sitepress->switch_lang($active_lang, true); |
| 3842 | 3842 | } |
| 3843 | 3843 | // WPML |
| 3844 | - wp_send_json( $json ); |
|
| 3844 | + wp_send_json($json); |
|
| 3845 | 3845 | } |
| 3846 | 3846 | } |
| 3847 | 3847 | break; |
| 3848 | 3848 | case 'export_locations': {
|
| 3849 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3850 | - $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 3851 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3852 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3853 | - $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 3849 | + $file_url_base = geodir_path_import_export().'/'; |
|
| 3850 | + $file_name = 'gd_locations_'.date('dmyHi');
|
|
| 3851 | + $file_url = $file_url_base.$file_name.'.csv'; |
|
| 3852 | + $file_path = $csv_file_dir.'/'.$file_name.'.csv'; |
|
| 3853 | + $file_path_temp = $csv_file_dir.'/gd_locations_'.$nonce.'.csv'; |
|
| 3854 | 3854 | |
| 3855 | - $items_count = (int)geodir_location_imex_count_locations(); |
|
| 3855 | + $items_count = (int) geodir_location_imex_count_locations(); |
|
| 3856 | 3856 | |
| 3857 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3858 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3859 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3860 | - $percentage = min( $percentage, 100 ); |
|
| 3857 | + if (isset($_REQUEST['_st'])) {
|
|
| 3858 | + $line_count = (int) geodir_import_export_line_count($file_path_temp); |
|
| 3859 | + $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0; |
|
| 3860 | + $percentage = min($percentage, 100); |
|
| 3861 | 3861 | |
| 3862 | 3862 | $json['percentage'] = $percentage; |
| 3863 | - wp_send_json( $json ); |
|
| 3863 | + wp_send_json($json); |
|
| 3864 | 3864 | } else {
|
| 3865 | 3865 | $chunk_file_paths = array(); |
| 3866 | 3866 | |
| 3867 | - if ( !$items_count > 0 ) {
|
|
| 3868 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3867 | + if (!$items_count > 0) {
|
|
| 3868 | + $json['error'] = __('No records to export.', 'geodirectory');
|
|
| 3869 | 3869 | } else {
|
| 3870 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3871 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3870 | + $chunk_per_page = min($chunk_per_page, $items_count); |
|
| 3871 | + $chunk_total_pages = ceil($items_count / $chunk_per_page); |
|
| 3872 | 3872 | |
| 3873 | 3873 | $j = $chunk_page_no; |
| 3874 | - $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 3874 | + $chunk_save_items = geodir_location_imex_locations_data($chunk_per_page, $j); |
|
| 3875 | 3875 | |
| 3876 | 3876 | $per_page = 500; |
| 3877 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 3878 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3877 | + $per_page = min($per_page, $chunk_per_page); |
|
| 3878 | + $total_pages = ceil($chunk_per_page / $per_page); |
|
| 3879 | 3879 | |
| 3880 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3881 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3880 | + for ($i = 0; $i <= $total_pages; $i++) {
|
|
| 3881 | + $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page); |
|
| 3882 | 3882 | |
| 3883 | 3883 | $clear = $i == 0 ? true : false; |
| 3884 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3884 | + geodir_save_csv_data($file_path_temp, $save_items, $clear); |
|
| 3885 | 3885 | } |
| 3886 | 3886 | |
| 3887 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3888 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3889 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3890 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3891 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3887 | + if ($wp_filesystem->exists($file_path_temp)) {
|
|
| 3888 | + $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : ''; |
|
| 3889 | + $chunk_file_name = $file_name.$chunk_page_no.'.csv'; |
|
| 3890 | + $file_path = $csv_file_dir.'/'.$chunk_file_name; |
|
| 3891 | + $wp_filesystem->move($file_path_temp, $file_path, true); |
|
| 3892 | 3892 | |
| 3893 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3894 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3893 | + $file_url = $file_url_base.$chunk_file_name; |
|
| 3894 | + $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3895 | 3895 | } |
| 3896 | 3896 | |
| 3897 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3897 | + if (!empty($chunk_file_paths)) {
|
|
| 3898 | 3898 | $json['total'] = $items_count; |
| 3899 | 3899 | $json['files'] = $chunk_file_paths; |
| 3900 | 3900 | } else {
|
| 3901 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3901 | + $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
|
|
| 3902 | 3902 | } |
| 3903 | 3903 | } |
| 3904 | - wp_send_json( $json ); |
|
| 3904 | + wp_send_json($json); |
|
| 3905 | 3905 | } |
| 3906 | 3906 | } |
| 3907 | 3907 | break; |
| 3908 | 3908 | case 'export_hoods': {
|
| 3909 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3910 | - $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
| 3911 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3912 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3913 | - $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
| 3909 | + $file_url_base = geodir_path_import_export().'/'; |
|
| 3910 | + $file_name = 'gd_neighbourhoods_'.date('dmyHi');
|
|
| 3911 | + $file_url = $file_url_base.$file_name.'.csv'; |
|
| 3912 | + $file_path = $csv_file_dir.'/'.$file_name.'.csv'; |
|
| 3913 | + $file_path_temp = $csv_file_dir.'/gd_neighbourhoods_'.$nonce.'.csv'; |
|
| 3914 | 3914 | |
| 3915 | - $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
| 3915 | + $items_count = (int) geodir_location_imex_count_neighbourhoods(); |
|
| 3916 | 3916 | |
| 3917 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3918 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3919 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3920 | - $percentage = min( $percentage, 100 ); |
|
| 3917 | + if (isset($_REQUEST['_st'])) {
|
|
| 3918 | + $line_count = (int) geodir_import_export_line_count($file_path_temp); |
|
| 3919 | + $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0; |
|
| 3920 | + $percentage = min($percentage, 100); |
|
| 3921 | 3921 | |
| 3922 | 3922 | $json['percentage'] = $percentage; |
| 3923 | - wp_send_json( $json ); |
|
| 3923 | + wp_send_json($json); |
|
| 3924 | 3924 | } else {
|
| 3925 | 3925 | $chunk_file_paths = array(); |
| 3926 | 3926 | |
| 3927 | - if ( !$items_count > 0 ) {
|
|
| 3928 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3927 | + if (!$items_count > 0) {
|
|
| 3928 | + $json['error'] = __('No records to export.', 'geodirectory');
|
|
| 3929 | 3929 | } else {
|
| 3930 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3931 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3930 | + $chunk_per_page = min($chunk_per_page, $items_count); |
|
| 3931 | + $chunk_total_pages = ceil($items_count / $chunk_per_page); |
|
| 3932 | 3932 | |
| 3933 | 3933 | $j = $chunk_page_no; |
| 3934 | - $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
| 3934 | + $chunk_save_items = geodir_location_imex_neighbourhoods_data($chunk_per_page, $j); |
|
| 3935 | 3935 | |
| 3936 | 3936 | $per_page = 500; |
| 3937 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 3938 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3937 | + $per_page = min($per_page, $chunk_per_page); |
|
| 3938 | + $total_pages = ceil($chunk_per_page / $per_page); |
|
| 3939 | 3939 | |
| 3940 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3941 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3940 | + for ($i = 0; $i <= $total_pages; $i++) {
|
|
| 3941 | + $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page); |
|
| 3942 | 3942 | |
| 3943 | 3943 | $clear = $i == 0 ? true : false; |
| 3944 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3944 | + geodir_save_csv_data($file_path_temp, $save_items, $clear); |
|
| 3945 | 3945 | } |
| 3946 | 3946 | |
| 3947 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3948 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3949 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3950 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3951 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3947 | + if ($wp_filesystem->exists($file_path_temp)) {
|
|
| 3948 | + $chunk_page_no = $chunk_total_pages > 1 ? '-'.$j : ''; |
|
| 3949 | + $chunk_file_name = $file_name.$chunk_page_no.'.csv'; |
|
| 3950 | + $file_path = $csv_file_dir.'/'.$chunk_file_name; |
|
| 3951 | + $wp_filesystem->move($file_path_temp, $file_path, true); |
|
| 3952 | 3952 | |
| 3953 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3954 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3953 | + $file_url = $file_url_base.$chunk_file_name; |
|
| 3954 | + $chunk_file_paths[] = array('i' => $j.'.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3955 | 3955 | } |
| 3956 | 3956 | |
| 3957 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3957 | + if (!empty($chunk_file_paths)) {
|
|
| 3958 | 3958 | $json['total'] = $items_count; |
| 3959 | 3959 | $json['files'] = $chunk_file_paths; |
| 3960 | 3960 | } else {
|
| 3961 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3961 | + $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
|
|
| 3962 | 3962 | } |
| 3963 | 3963 | } |
| 3964 | - wp_send_json( $json ); |
|
| 3964 | + wp_send_json($json); |
|
| 3965 | 3965 | } |
| 3966 | 3966 | } |
| 3967 | 3967 | break; |
@@ -3978,33 +3978,33 @@ discard block |
||
| 3978 | 3978 | } |
| 3979 | 3979 | // WPML |
| 3980 | 3980 | |
| 3981 | - ini_set( 'auto_detect_line_endings', true ); |
|
| 3981 | + ini_set('auto_detect_line_endings', true);
|
|
| 3982 | 3982 | |
| 3983 | 3983 | $uploads = wp_upload_dir(); |
| 3984 | 3984 | $uploads_dir = $uploads['path']; |
| 3985 | 3985 | $uploads_subdir = $uploads['subdir']; |
| 3986 | 3986 | |
| 3987 | - $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 3988 | - $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 3987 | + $csv_file = isset($_POST['_file']) ? $_POST['_file'] : NULL; |
|
| 3988 | + $import_choice = isset($_REQUEST['_ch']) ? $_REQUEST['_ch'] : 'skip'; |
|
| 3989 | 3989 | |
| 3990 | - $csv_file_arr = explode( '/', $csv_file ); |
|
| 3991 | - $csv_filename = end( $csv_file_arr ); |
|
| 3992 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 3990 | + $csv_file_arr = explode('/', $csv_file);
|
|
| 3991 | + $csv_filename = end($csv_file_arr); |
|
| 3992 | + $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$csv_filename; |
|
| 3993 | 3993 | |
| 3994 | 3994 | $json['file'] = $csv_file; |
| 3995 | - $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 3995 | + $json['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
|
|
| 3996 | 3996 | $file = array(); |
| 3997 | 3997 | |
| 3998 | - if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 3999 | - $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 3998 | + if ($csv_file && $wp_filesystem->is_file($target_path) && $wp_filesystem->exists($target_path)) {
|
|
| 3999 | + $wp_filetype = wp_check_filetype_and_ext($target_path, $csv_filename); |
|
| 4000 | 4000 | |
| 4001 | 4001 | if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
| 4002 | 4002 | $json['error'] = NULL; |
| 4003 | 4003 | $json['rows'] = 0; |
| 4004 | 4004 | |
| 4005 | - if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 4006 | - while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 4007 | - if ( !empty( $data ) ) {
|
|
| 4005 | + if (($handle = fopen($target_path, "r")) !== FALSE) {
|
|
| 4006 | + while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) {
|
|
| 4007 | + if (!empty($data)) {
|
|
| 4008 | 4008 | $file[] = $data; |
| 4009 | 4009 | } |
| 4010 | 4010 | } |
@@ -4017,19 +4017,19 @@ discard block |
||
| 4017 | 4017 | $json['error'] = __('No data found in csv file.', 'geodirectory');
|
| 4018 | 4018 | } |
| 4019 | 4019 | } else {
|
| 4020 | - wp_send_json( $json ); |
|
| 4020 | + wp_send_json($json); |
|
| 4021 | 4021 | } |
| 4022 | 4022 | } else {
|
| 4023 | - wp_send_json( $json ); |
|
| 4023 | + wp_send_json($json); |
|
| 4024 | 4024 | } |
| 4025 | 4025 | |
| 4026 | - if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 4027 | - wp_send_json( $json ); |
|
| 4026 | + if ($task == 'prepare_import' || !empty($json['error'])) {
|
|
| 4027 | + wp_send_json($json); |
|
| 4028 | 4028 | } |
| 4029 | 4029 | |
| 4030 | 4030 | $total = $json['rows']; |
| 4031 | - $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 4032 | - $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 4031 | + $limit = isset($_POST['limit']) ? (int) $_POST['limit'] : 1; |
|
| 4032 | + $processed = isset($_POST['processed']) ? (int) $_POST['processed'] : 0; |
|
| 4033 | 4033 | |
| 4034 | 4034 | $count = $limit; |
| 4035 | 4035 | |
@@ -4054,13 +4054,13 @@ discard block |
||
| 4054 | 4054 | |
| 4055 | 4055 | $post_types = geodir_get_posttypes(); |
| 4056 | 4056 | |
| 4057 | - if ( $task == 'import_cat' ) {
|
|
| 4057 | + if ($task == 'import_cat') {
|
|
| 4058 | 4058 | if (!empty($file)) {
|
| 4059 | 4059 | $columns = isset($file[0]) ? $file[0] : NULL; |
| 4060 | 4060 | |
| 4061 | 4061 | if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
| 4062 | 4062 | $json['error'] = CSV_INVAILD_FILE; |
| 4063 | - wp_send_json( $json ); |
|
| 4063 | + wp_send_json($json); |
|
| 4064 | 4064 | exit; |
| 4065 | 4065 | } |
| 4066 | 4066 | |
@@ -4071,7 +4071,7 @@ discard block |
||
| 4071 | 4071 | |
| 4072 | 4072 | if (isset($file[$index])) {
|
| 4073 | 4073 | $row = $file[$index]; |
| 4074 | - $row = array_map( 'trim', $row ); |
|
| 4074 | + $row = array_map('trim', $row);
|
|
| 4075 | 4075 | //$row = array_map( 'utf8_encode', $row ); |
| 4076 | 4076 | |
| 4077 | 4077 | $cat_id = ''; |
@@ -4088,42 +4088,42 @@ discard block |
||
| 4088 | 4088 | $cat_id_original = ''; |
| 4089 | 4089 | |
| 4090 | 4090 | $c = 0; |
| 4091 | - foreach ($columns as $column ) {
|
|
| 4092 | - if ( $column == 'cat_id' ) {
|
|
| 4093 | - $cat_id = (int)$row[$c]; |
|
| 4094 | - } else if ( $column == 'cat_name' ) {
|
|
| 4091 | + foreach ($columns as $column) {
|
|
| 4092 | + if ($column == 'cat_id') {
|
|
| 4093 | + $cat_id = (int) $row[$c]; |
|
| 4094 | + } else if ($column == 'cat_name') {
|
|
| 4095 | 4095 | $cat_name = $row[$c]; |
| 4096 | - } else if ( $column == 'cat_slug' ) {
|
|
| 4096 | + } else if ($column == 'cat_slug') {
|
|
| 4097 | 4097 | $cat_slug = $row[$c]; |
| 4098 | - } else if ( $column == 'cat_posttype' ) {
|
|
| 4098 | + } else if ($column == 'cat_posttype') {
|
|
| 4099 | 4099 | $cat_posttype = $row[$c]; |
| 4100 | - } else if ( $column == 'cat_parent' ) {
|
|
| 4100 | + } else if ($column == 'cat_parent') {
|
|
| 4101 | 4101 | $cat_parent = trim($row[$c]); |
| 4102 | - } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 4102 | + } else if ($column == 'cat_schema' && $row[$c] != '') {
|
|
| 4103 | 4103 | $cat_schema = $row[$c]; |
| 4104 | - } else if ( $column == 'cat_description' ) {
|
|
| 4104 | + } else if ($column == 'cat_description') {
|
|
| 4105 | 4105 | $cat_description = $row[$c]; |
| 4106 | - } else if ( $column == 'cat_top_description' ) {
|
|
| 4106 | + } else if ($column == 'cat_top_description') {
|
|
| 4107 | 4107 | $cat_top_description = $row[$c]; |
| 4108 | - } else if ( $column == 'cat_image' ) {
|
|
| 4108 | + } else if ($column == 'cat_image') {
|
|
| 4109 | 4109 | $cat_image = $row[$c]; |
| 4110 | - } else if ( $column == 'cat_icon' ) {
|
|
| 4110 | + } else if ($column == 'cat_icon') {
|
|
| 4111 | 4111 | $cat_icon = $row[$c]; |
| 4112 | 4112 | } |
| 4113 | 4113 | // WPML |
| 4114 | - if ( $is_wpml ) {
|
|
| 4115 | - if ( $column == 'cat_language' ) {
|
|
| 4116 | - $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
| 4117 | - } else if ( $column == 'cat_id_original' ) {
|
|
| 4118 | - $cat_id_original = (int)$row[$c]; |
|
| 4114 | + if ($is_wpml) {
|
|
| 4115 | + if ($column == 'cat_language') {
|
|
| 4116 | + $cat_language = geodir_strtolower(trim($row[$c])); |
|
| 4117 | + } else if ($column == 'cat_id_original') {
|
|
| 4118 | + $cat_id_original = (int) $row[$c]; |
|
| 4119 | 4119 | } |
| 4120 | 4120 | } |
| 4121 | 4121 | // WPML |
| 4122 | 4122 | $c++; |
| 4123 | 4123 | } |
| 4124 | 4124 | |
| 4125 | - if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 4126 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4125 | + if ($cat_name == '' || !in_array($cat_posttype, $post_types)) {
|
|
| 4126 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank title/invalid post type', 'geodirectory'));
|
|
| 4127 | 4127 | |
| 4128 | 4128 | $invalid++; |
| 4129 | 4129 | continue; |
@@ -4141,24 +4141,24 @@ discard block |
||
| 4141 | 4141 | $term_data['description'] = $cat_description; |
| 4142 | 4142 | $term_data['cat_schema'] = $cat_schema; |
| 4143 | 4143 | $term_data['top_description'] = $cat_top_description; |
| 4144 | - $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 4145 | - $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 4144 | + $term_data['image'] = $cat_image != '' ? basename($cat_image) : ''; |
|
| 4145 | + $term_data['icon'] = $cat_icon != '' ? basename($cat_icon) : ''; |
|
| 4146 | 4146 | |
| 4147 | 4147 | //$term_data = array_map( 'utf8_encode', $term_data ); |
| 4148 | 4148 | |
| 4149 | - $taxonomy = $cat_posttype . 'category'; |
|
| 4149 | + $taxonomy = $cat_posttype.'category'; |
|
| 4150 | 4150 | |
| 4151 | 4151 | $term_data['taxonomy'] = $taxonomy; |
| 4152 | 4152 | |
| 4153 | 4153 | $term_parent_id = 0; |
| 4154 | - if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 4154 | + if ($cat_parent != "" || (int) $cat_parent > 0) {
|
|
| 4155 | 4155 | $term_parent = ''; |
| 4156 | 4156 | |
| 4157 | - if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 4157 | + if ($term_parent = get_term_by('name', $cat_parent, $taxonomy)) {
|
|
| 4158 | 4158 | // |
| 4159 | - } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 4159 | + } else if ($term_parent = get_term_by('slug', $cat_parent, $taxonomy)) {
|
|
| 4160 | 4160 | // |
| 4161 | - } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 4161 | + } else if ($term_parent = get_term_by('id', $cat_parent, $taxonomy)) {
|
|
| 4162 | 4162 | // |
| 4163 | 4163 | } else {
|
| 4164 | 4164 | $term_parent_data = array(); |
@@ -4166,104 +4166,104 @@ discard block |
||
| 4166 | 4166 | //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
| 4167 | 4167 | $term_parent_data['taxonomy'] = $taxonomy; |
| 4168 | 4168 | |
| 4169 | - $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 4169 | + $term_parent_id = (int) geodir_imex_insert_term($taxonomy, $term_parent_data); |
|
| 4170 | 4170 | } |
| 4171 | 4171 | |
| 4172 | - if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 4173 | - $term_parent_id = (int)$term_parent->term_id; |
|
| 4172 | + if (!empty($term_parent) && !is_wp_error($term_parent)) {
|
|
| 4173 | + $term_parent_id = (int) $term_parent->term_id; |
|
| 4174 | 4174 | } |
| 4175 | 4175 | } |
| 4176 | - $term_data['parent'] = (int)$term_parent_id; |
|
| 4176 | + $term_data['parent'] = (int) $term_parent_id; |
|
| 4177 | 4177 | |
| 4178 | 4178 | $term_id = NULL; |
| 4179 | - if ( $import_choice == 'update' ) {
|
|
| 4180 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 4179 | + if ($import_choice == 'update') {
|
|
| 4180 | + if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
|
|
| 4181 | 4181 | $term_data['term_id'] = $term['term_id']; |
| 4182 | 4182 | |
| 4183 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 4183 | + if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
|
|
| 4184 | 4184 | $updated++; |
| 4185 | 4185 | } else {
|
| 4186 | 4186 | $invalid++; |
| 4187 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4187 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
|
|
| 4188 | 4188 | } |
| 4189 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 4189 | + } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
|
|
| 4190 | 4190 | $term_data['term_id'] = $term['term_id']; |
| 4191 | 4191 | |
| 4192 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 4192 | + if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
|
|
| 4193 | 4193 | $updated++; |
| 4194 | 4194 | } else {
|
| 4195 | 4195 | $invalid++; |
| 4196 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4196 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
|
|
| 4197 | 4197 | } |
| 4198 | 4198 | } else {
|
| 4199 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 4199 | + if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
|
|
| 4200 | 4200 | $created++; |
| 4201 | 4201 | } else {
|
| 4202 | 4202 | $invalid++; |
| 4203 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4203 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
|
|
| 4204 | 4204 | } |
| 4205 | 4205 | } |
| 4206 | - } else if ( $import_choice == 'skip' ) {
|
|
| 4207 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 4206 | + } else if ($import_choice == 'skip') {
|
|
| 4207 | + if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
|
|
| 4208 | 4208 | $skipped++; |
| 4209 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 4209 | + } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
|
|
| 4210 | 4210 | $skipped++; |
| 4211 | 4211 | } else {
|
| 4212 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 4212 | + if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
|
|
| 4213 | 4213 | $created++; |
| 4214 | 4214 | } else {
|
| 4215 | 4215 | $invalid++; |
| 4216 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4216 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
|
|
| 4217 | 4217 | } |
| 4218 | 4218 | } |
| 4219 | 4219 | } else {
|
| 4220 | 4220 | $invalid++; |
| 4221 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 4221 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory'));
|
|
| 4222 | 4222 | } |
| 4223 | 4223 | |
| 4224 | - if ( $term_id ) {
|
|
| 4224 | + if ($term_id) {
|
|
| 4225 | 4225 | // WPML |
| 4226 | 4226 | if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
|
| 4227 | - $wpml_element_type = 'tax_' . $taxonomy; |
|
| 4228 | - $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
| 4227 | + $wpml_element_type = 'tax_'.$taxonomy; |
|
| 4228 | + $source_language = geodir_get_language_for_element($cat_id_original, $wpml_element_type); |
|
| 4229 | 4229 | $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
| 4230 | 4230 | |
| 4231 | - $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
| 4231 | + $trid = $sitepress->get_element_trid($cat_id_original, $wpml_element_type); |
|
| 4232 | 4232 | |
| 4233 | - $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
| 4233 | + $sitepress->set_element_language_details($term_id, $wpml_element_type, $trid, $cat_language, $source_language); |
|
| 4234 | 4234 | } |
| 4235 | 4235 | // WPML |
| 4236 | 4236 | |
| 4237 | - if ( isset( $term_data['top_description'] ) ) {
|
|
| 4238 | - update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 4237 | + if (isset($term_data['top_description'])) {
|
|
| 4238 | + update_tax_meta($term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype); |
|
| 4239 | 4239 | } |
| 4240 | 4240 | |
| 4241 | - if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 4242 | - update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 4241 | + if (isset($term_data['cat_schema'])) {
|
|
| 4242 | + update_tax_meta($term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype); |
|
| 4243 | 4243 | } |
| 4244 | 4244 | |
| 4245 | 4245 | $attachment = false; |
| 4246 | - if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 4247 | - $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 4248 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 4246 | + if (isset($term_data['image']) && $term_data['image'] != '') {
|
|
| 4247 | + $cat_image = geodir_get_default_catimage($term_id, $cat_posttype); |
|
| 4248 | + $cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : ''; |
|
| 4249 | 4249 | |
| 4250 | - if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 4250 | + if (basename($cat_image) != $term_data['image']) {
|
|
| 4251 | 4251 | $attachment = true; |
| 4252 | - update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 4252 | + update_tax_meta($term_id, 'ct_cat_default_img', array('id' => 'image', 'src' => $uploads['url'].'/'.$term_data['image']), $cat_posttype);
|
|
| 4253 | 4253 | } |
| 4254 | 4254 | } |
| 4255 | 4255 | |
| 4256 | - if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 4257 | - $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 4258 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 4256 | + if (isset($term_data['icon']) && $term_data['icon'] != '') {
|
|
| 4257 | + $cat_icon = get_tax_meta($term_id, 'ct_cat_icon', false, $cat_posttype); |
|
| 4258 | + $cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : ''; |
|
| 4259 | 4259 | |
| 4260 | - if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 4260 | + if (basename($cat_icon) != $term_data['icon']) {
|
|
| 4261 | 4261 | $attachment = true; |
| 4262 | - update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 4262 | + update_tax_meta($term_id, 'ct_cat_icon', array('id' => 'icon', 'src' => $uploads['url'].'/'.$term_data['icon']), $cat_posttype);
|
|
| 4263 | 4263 | } |
| 4264 | 4264 | } |
| 4265 | 4265 | |
| 4266 | - if ( $attachment ) {
|
|
| 4266 | + if ($attachment) {
|
|
| 4267 | 4267 | $images++; |
| 4268 | 4268 | } |
| 4269 | 4269 | } |
@@ -4285,13 +4285,13 @@ discard block |
||
| 4285 | 4285 | $json['invalid'] = $invalid; |
| 4286 | 4286 | $json['images'] = $images; |
| 4287 | 4287 | |
| 4288 | - wp_send_json( $json ); |
|
| 4288 | + wp_send_json($json); |
|
| 4289 | 4289 | exit; |
| 4290 | - } else if ( $task == 'import_post' ) {
|
|
| 4290 | + } else if ($task == 'import_post') {
|
|
| 4291 | 4291 | //run some stuff to make the import quicker |
| 4292 | - wp_defer_term_counting( true ); |
|
| 4293 | - wp_defer_comment_counting( true ); |
|
| 4294 | - $wpdb->query( 'SET autocommit = 0;' ); |
|
| 4292 | + wp_defer_term_counting(true); |
|
| 4293 | + wp_defer_comment_counting(true); |
|
| 4294 | + $wpdb->query('SET autocommit = 0;');
|
|
| 4295 | 4295 | |
| 4296 | 4296 | //remove_all_actions('publish_post');
|
| 4297 | 4297 | //remove_all_actions('transition_post_status');
|
@@ -4300,18 +4300,18 @@ discard block |
||
| 4300 | 4300 | if (!empty($file)) {
|
| 4301 | 4301 | $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
| 4302 | 4302 | $default_status = 'publish'; |
| 4303 | - $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 4303 | + $current_date = date_i18n('Y-m-d', time());
|
|
| 4304 | 4304 | |
| 4305 | 4305 | $columns = isset($file[0]) ? $file[0] : NULL; |
| 4306 | 4306 | |
| 4307 | 4307 | if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
| 4308 | 4308 | $json['error'] = CSV_INVAILD_FILE; |
| 4309 | - wp_send_json( $json ); |
|
| 4309 | + wp_send_json($json); |
|
| 4310 | 4310 | exit; |
| 4311 | 4311 | } |
| 4312 | 4312 | |
| 4313 | 4313 | $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
|
| 4314 | - $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
| 4314 | + $wp_chars_error = __('(check & remove if any invalid characters used in data)', 'geodirectory');
|
|
| 4315 | 4315 | $processed_actual = 0; |
| 4316 | 4316 | for ($i = 1; $i <= $limit; $i++) {
|
| 4317 | 4317 | $index = $processed + $i; |
@@ -4320,9 +4320,9 @@ discard block |
||
| 4320 | 4320 | if (isset($file[$index])) {
|
| 4321 | 4321 | $processed_actual++; |
| 4322 | 4322 | $row = $file[$index]; |
| 4323 | - $row = array_map( 'trim', $row ); |
|
| 4323 | + $row = array_map('trim', $row);
|
|
| 4324 | 4324 | //$row = array_map( 'utf8_encode', $row ); |
| 4325 | - $row = array_map( 'addslashes_gpc', $row ); |
|
| 4325 | + $row = array_map('addslashes_gpc', $row);
|
|
| 4326 | 4326 | |
| 4327 | 4327 | $post_id = ''; |
| 4328 | 4328 | $post_title = ''; |
@@ -4359,78 +4359,78 @@ discard block |
||
| 4359 | 4359 | $original_post_id = ''; |
| 4360 | 4360 | |
| 4361 | 4361 | $c = 0; |
| 4362 | - foreach ($columns as $column ) {
|
|
| 4362 | + foreach ($columns as $column) {
|
|
| 4363 | 4363 | $gd_post[$column] = $row[$c]; |
| 4364 | 4364 | |
| 4365 | - if ( $column == 'post_id' ) {
|
|
| 4365 | + if ($column == 'post_id') {
|
|
| 4366 | 4366 | $post_id = $row[$c]; |
| 4367 | - } else if ( $column == 'post_title' ) {
|
|
| 4367 | + } else if ($column == 'post_title') {
|
|
| 4368 | 4368 | $post_title = sanitize_text_field($row[$c]); |
| 4369 | - } else if ( $column == 'post_author' ) {
|
|
| 4369 | + } else if ($column == 'post_author') {
|
|
| 4370 | 4370 | $post_author = $row[$c]; |
| 4371 | - } else if ( $column == 'post_content' ) {
|
|
| 4371 | + } else if ($column == 'post_content') {
|
|
| 4372 | 4372 | $post_content = $row[$c]; |
| 4373 | - } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 4374 | - $post_category_arr = explode( ',', $row[$c] ); |
|
| 4375 | - } else if ( $column == 'default_category' ) {
|
|
| 4373 | + } else if ($column == 'post_category' && $row[$c] != '') {
|
|
| 4374 | + $post_category_arr = explode(',', $row[$c]);
|
|
| 4375 | + } else if ($column == 'default_category') {
|
|
| 4376 | 4376 | $default_category = wp_kses_normalize_entities($row[$c]); |
| 4377 | - } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 4378 | - $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
| 4379 | - } else if ( $column == 'post_type' ) {
|
|
| 4377 | + } else if ($column == 'post_tags' && $row[$c] != '') {
|
|
| 4378 | + $post_tags = explode(',', sanitize_text_field($row[$c]));
|
|
| 4379 | + } else if ($column == 'post_type') {
|
|
| 4380 | 4380 | $post_type = $row[$c]; |
| 4381 | - } else if ( $column == 'post_status' ) {
|
|
| 4382 | - $post_status = sanitize_key( $row[$c] ); |
|
| 4383 | - } else if ( $column == 'is_featured' ) {
|
|
| 4384 | - $is_featured = (int)$row[$c]; |
|
| 4385 | - } else if ( $column == 'geodir_video' ) {
|
|
| 4381 | + } else if ($column == 'post_status') {
|
|
| 4382 | + $post_status = sanitize_key($row[$c]); |
|
| 4383 | + } else if ($column == 'is_featured') {
|
|
| 4384 | + $is_featured = (int) $row[$c]; |
|
| 4385 | + } else if ($column == 'geodir_video') {
|
|
| 4386 | 4386 | $geodir_video = $row[$c]; |
| 4387 | - } else if ( $column == 'post_address' ) {
|
|
| 4387 | + } else if ($column == 'post_address') {
|
|
| 4388 | 4388 | $post_address = sanitize_text_field($row[$c]); |
| 4389 | - } else if ( $column == 'post_city' ) {
|
|
| 4389 | + } else if ($column == 'post_city') {
|
|
| 4390 | 4390 | $post_city = sanitize_text_field($row[$c]); |
| 4391 | - } else if ( $column == 'post_region' ) {
|
|
| 4391 | + } else if ($column == 'post_region') {
|
|
| 4392 | 4392 | $post_region = sanitize_text_field($row[$c]); |
| 4393 | - } else if ( $column == 'post_country' ) {
|
|
| 4393 | + } else if ($column == 'post_country') {
|
|
| 4394 | 4394 | $post_country = sanitize_text_field($row[$c]); |
| 4395 | - } else if ( $column == 'post_zip' ) {
|
|
| 4395 | + } else if ($column == 'post_zip') {
|
|
| 4396 | 4396 | $post_zip = sanitize_text_field($row[$c]); |
| 4397 | - } else if ( $column == 'post_latitude' ) {
|
|
| 4397 | + } else if ($column == 'post_latitude') {
|
|
| 4398 | 4398 | $post_latitude = sanitize_text_field($row[$c]); |
| 4399 | - } else if ( $column == 'post_longitude' ) {
|
|
| 4399 | + } else if ($column == 'post_longitude') {
|
|
| 4400 | 4400 | $post_longitude = sanitize_text_field($row[$c]); |
| 4401 | - } else if ( $column == 'post_neighbourhood' ) {
|
|
| 4401 | + } else if ($column == 'post_neighbourhood') {
|
|
| 4402 | 4402 | $post_neighbourhood = sanitize_text_field($row[$c]); |
| 4403 | 4403 | unset($gd_post[$column]); |
| 4404 | - } else if ( $column == 'neighbourhood_latitude' ) {
|
|
| 4404 | + } else if ($column == 'neighbourhood_latitude') {
|
|
| 4405 | 4405 | $neighbourhood_latitude = sanitize_text_field($row[$c]); |
| 4406 | - } else if ( $column == 'neighbourhood_longitude' ) {
|
|
| 4406 | + } else if ($column == 'neighbourhood_longitude') {
|
|
| 4407 | 4407 | $neighbourhood_longitude = sanitize_text_field($row[$c]); |
| 4408 | - } else if ( $column == 'geodir_timing' ) {
|
|
| 4408 | + } else if ($column == 'geodir_timing') {
|
|
| 4409 | 4409 | $geodir_timing = sanitize_text_field($row[$c]); |
| 4410 | - } else if ( $column == 'geodir_contact' ) {
|
|
| 4410 | + } else if ($column == 'geodir_contact') {
|
|
| 4411 | 4411 | $geodir_contact = sanitize_text_field($row[$c]); |
| 4412 | - } else if ( $column == 'geodir_email' ) {
|
|
| 4412 | + } else if ($column == 'geodir_email') {
|
|
| 4413 | 4413 | $geodir_email = sanitize_email($row[$c]); |
| 4414 | - } else if ( $column == 'geodir_website' ) {
|
|
| 4414 | + } else if ($column == 'geodir_website') {
|
|
| 4415 | 4415 | $geodir_website = sanitize_text_field($row[$c]); |
| 4416 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 4416 | + } else if ($column == 'geodir_twitter') {
|
|
| 4417 | 4417 | $geodir_twitter = sanitize_text_field($row[$c]); |
| 4418 | - } else if ( $column == 'geodir_facebook' ) {
|
|
| 4418 | + } else if ($column == 'geodir_facebook') {
|
|
| 4419 | 4419 | $geodir_facebook = sanitize_text_field($row[$c]); |
| 4420 | - } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 4420 | + } else if ($column == 'IMAGE' && !empty($row[$c]) && $row[$c] != '') {
|
|
| 4421 | 4421 | $post_images[] = $row[$c]; |
| 4422 | - } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 4423 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 4424 | - } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 4422 | + } else if ($column == 'alive_days' && (int) $row[$c] > 0) {
|
|
| 4423 | + $expire_date = date_i18n('Y-m-d', strtotime($current_date.'+'.(int) $row[$c].' days'));
|
|
| 4424 | + } else if ($column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never') {
|
|
| 4425 | 4425 | $row[$c] = str_replace('/', '-', $row[$c]);
|
| 4426 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 4426 | + $expire_date = date_i18n('Y-m-d', strtotime($row[$c]));
|
|
| 4427 | 4427 | } |
| 4428 | 4428 | // WPML |
| 4429 | 4429 | if ($is_wpml) {
|
| 4430 | 4430 | if ($column == 'language') {
|
| 4431 | 4431 | $language = geodir_strtolower(trim($row[$c])); |
| 4432 | 4432 | } else if ($column == 'original_post_id') {
|
| 4433 | - $original_post_id = (int)$row[$c]; |
|
| 4433 | + $original_post_id = (int) $row[$c]; |
|
| 4434 | 4434 | } |
| 4435 | 4435 | } |
| 4436 | 4436 | // WPML |
@@ -4445,43 +4445,43 @@ discard block |
||
| 4445 | 4445 | |
| 4446 | 4446 | $gd_post['IMAGE'] = $post_images; |
| 4447 | 4447 | |
| 4448 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 4449 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 4448 | + $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status; |
|
| 4449 | + $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status; |
|
| 4450 | 4450 | |
| 4451 | 4451 | $valid = true; |
| 4452 | 4452 | |
| 4453 | - if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 4453 | + if ($post_title == '' || !in_array($post_type, $post_types)) {
|
|
| 4454 | 4454 | $invalid++; |
| 4455 | 4455 | $valid = false; |
| 4456 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4456 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank title/invalid post type', 'geodirectory'));
|
|
| 4457 | 4457 | } |
| 4458 | 4458 | |
| 4459 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 4460 | - if ( $location_allowed ) {
|
|
| 4459 | + $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
|
|
| 4460 | + if ($location_allowed) {
|
|
| 4461 | 4461 | $location_result = geodir_get_default_location(); |
| 4462 | - if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 4462 | + if ($post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '') {
|
|
| 4463 | 4463 | $invalid_addr++; |
| 4464 | 4464 | $valid = false; |
| 4465 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) ); |
|
| 4466 | - } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 4467 | - 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 ) ) ) {
|
|
| 4465 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory'));
|
|
| 4466 | + } else if (!empty($location_result) && $location_result->location_id == 0) {
|
|
| 4467 | + 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))) {
|
|
| 4468 | 4468 | $invalid_addr++; |
| 4469 | 4469 | $valid = false; |
| 4470 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) ); |
|
| 4470 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.__('Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory'));
|
|
| 4471 | 4471 | } else {
|
| 4472 | 4472 | if (!$location_manager) {
|
| 4473 | - $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. |
|
| 4473 | + $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. |
|
| 4474 | 4474 | } |
| 4475 | 4475 | } |
| 4476 | 4476 | } |
| 4477 | 4477 | } |
| 4478 | 4478 | |
| 4479 | - if ( !$valid ) {
|
|
| 4479 | + if (!$valid) {
|
|
| 4480 | 4480 | continue; |
| 4481 | 4481 | } |
| 4482 | 4482 | |
| 4483 | - $cat_taxonomy = $post_type . 'category'; |
|
| 4484 | - $tags_taxonomy = $post_type . '_tags'; |
|
| 4483 | + $cat_taxonomy = $post_type.'category'; |
|
| 4484 | + $tags_taxonomy = $post_type.'_tags'; |
|
| 4485 | 4485 | |
| 4486 | 4486 | if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
| 4487 | 4487 | $post_category_arr = array_merge(array($default_category), $post_category_arr); |
@@ -4489,29 +4489,29 @@ discard block |
||
| 4489 | 4489 | |
| 4490 | 4490 | $post_category = array(); |
| 4491 | 4491 | $default_category_id = NULL; |
| 4492 | - if ( !empty( $post_category_arr ) ) {
|
|
| 4493 | - foreach ( $post_category_arr as $value ) {
|
|
| 4494 | - $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 4492 | + if (!empty($post_category_arr)) {
|
|
| 4493 | + foreach ($post_category_arr as $value) {
|
|
| 4494 | + $category_name = wp_kses_normalize_entities(trim($value)); |
|
| 4495 | 4495 | |
| 4496 | - if ( $category_name != '' ) {
|
|
| 4496 | + if ($category_name != '') {
|
|
| 4497 | 4497 | $term_category = array(); |
| 4498 | 4498 | |
| 4499 | - if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 4499 | + if ($term = get_term_by('name', $category_name, $cat_taxonomy)) {
|
|
| 4500 | 4500 | $term_category = $term; |
| 4501 | - } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 4501 | + } else if ($term = get_term_by('slug', $category_name, $cat_taxonomy)) {
|
|
| 4502 | 4502 | $term_category = $term; |
| 4503 | 4503 | } else {
|
| 4504 | 4504 | $term_data = array(); |
| 4505 | 4505 | $term_data['name'] = $category_name; |
| 4506 | 4506 | $term_data['taxonomy'] = $cat_taxonomy; |
| 4507 | 4507 | |
| 4508 | - $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 4509 | - if ( $term_id ) {
|
|
| 4510 | - $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 4508 | + $term_id = geodir_imex_insert_term($cat_taxonomy, $term_data); |
|
| 4509 | + if ($term_id) {
|
|
| 4510 | + $term_category = get_term($term_id, $cat_taxonomy); |
|
| 4511 | 4511 | } |
| 4512 | 4512 | } |
| 4513 | 4513 | |
| 4514 | - if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 4514 | + if (!empty($term_category) && !is_wp_error($term_category)) {
|
|
| 4515 | 4515 | $post_category[] = intval($term_category->term_id); |
| 4516 | 4516 | |
| 4517 | 4517 | if ($category_name == $default_category) {
|
@@ -4532,15 +4532,15 @@ discard block |
||
| 4532 | 4532 | $save_post['post_tags'] = $post_tags; |
| 4533 | 4533 | |
| 4534 | 4534 | $saved_post_id = NULL; |
| 4535 | - if ( $import_choice == 'update' ) {
|
|
| 4536 | - $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
| 4535 | + if ($import_choice == 'update') {
|
|
| 4536 | + $gd_wp_error = __('Unable to add listing, please check the listing data.', 'geodirectory');
|
|
| 4537 | 4537 | |
| 4538 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4538 | + if ($post_id > 0 && get_post($post_id)) {
|
|
| 4539 | 4539 | $save_post['ID'] = $post_id; |
| 4540 | 4540 | |
| 4541 | - if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
|
|
| 4542 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4543 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4541 | + if ($saved_post_id = wp_update_post($save_post, true)) {
|
|
| 4542 | + if (is_wp_error($saved_post_id)) {
|
|
| 4543 | + $gd_wp_error = $saved_post_id->get_error_message().' '.$wp_chars_error; |
|
| 4544 | 4544 | $saved_post_id = 0; |
| 4545 | 4545 | } else {
|
| 4546 | 4546 | $saved_post_id = $post_id; |
@@ -4548,9 +4548,9 @@ discard block |
||
| 4548 | 4548 | } |
| 4549 | 4549 | } |
| 4550 | 4550 | } else {
|
| 4551 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4552 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4553 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4551 | + if ($saved_post_id = wp_insert_post($save_post, true)) {
|
|
| 4552 | + if (is_wp_error($saved_post_id)) {
|
|
| 4553 | + $gd_wp_error = $saved_post_id->get_error_message().' '.$wp_chars_error; |
|
| 4554 | 4554 | $saved_post_id = 0; |
| 4555 | 4555 | } else {
|
| 4556 | 4556 | $created++; |
@@ -4558,19 +4558,19 @@ discard block |
||
| 4558 | 4558 | } |
| 4559 | 4559 | } |
| 4560 | 4560 | |
| 4561 | - if ( !$saved_post_id > 0 ) {
|
|
| 4561 | + if (!$saved_post_id > 0) {
|
|
| 4562 | 4562 | $invalid++; |
| 4563 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
| 4563 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_wp_error); |
|
| 4564 | 4564 | } |
| 4565 | - } else if ( $import_choice == 'skip' ) {
|
|
| 4566 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4565 | + } else if ($import_choice == 'skip') {
|
|
| 4566 | + if ($post_id > 0 && get_post($post_id)) {
|
|
| 4567 | 4567 | $skipped++; |
| 4568 | 4568 | } else {
|
| 4569 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4570 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4569 | + if ($saved_post_id = wp_insert_post($save_post, true)) {
|
|
| 4570 | + if (is_wp_error($saved_post_id)) {
|
|
| 4571 | 4571 | $invalid++; |
| 4572 | 4572 | |
| 4573 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
| 4573 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$saved_post_id->get_error_message().' '.$wp_chars_error); |
|
| 4574 | 4574 | $saved_post_id = 0; |
| 4575 | 4575 | } else {
|
| 4576 | 4576 | $created++; |
@@ -4578,28 +4578,28 @@ discard block |
||
| 4578 | 4578 | } else {
|
| 4579 | 4579 | $invalid++; |
| 4580 | 4580 | |
| 4581 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4581 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$wp_chars_error); |
|
| 4582 | 4582 | } |
| 4583 | 4583 | } |
| 4584 | 4584 | } else {
|
| 4585 | 4585 | $invalid++; |
| 4586 | 4586 | |
| 4587 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4587 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$wp_chars_error); |
|
| 4588 | 4588 | } |
| 4589 | 4589 | |
| 4590 | - if ( (int)$saved_post_id > 0 ) {
|
|
| 4590 | + if ((int) $saved_post_id > 0) {
|
|
| 4591 | 4591 | // WPML |
| 4592 | 4592 | if ($is_wpml && $original_post_id > 0 && $language != '') {
|
| 4593 | - $wpml_post_type = 'post_' . $post_type; |
|
| 4594 | - $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 4593 | + $wpml_post_type = 'post_'.$post_type; |
|
| 4594 | + $source_language = geodir_get_language_for_element($original_post_id, $wpml_post_type); |
|
| 4595 | 4595 | $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
| 4596 | 4596 | |
| 4597 | - $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 4597 | + $trid = $sitepress->get_element_trid($original_post_id, $wpml_post_type); |
|
| 4598 | 4598 | |
| 4599 | - $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 4599 | + $sitepress->set_element_language_details($saved_post_id, $wpml_post_type, $trid, $language, $source_language); |
|
| 4600 | 4600 | } |
| 4601 | 4601 | // WPML |
| 4602 | - $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 4602 | + $gd_post_info = geodir_get_post_info($saved_post_id); |
|
| 4603 | 4603 | |
| 4604 | 4604 | $gd_post['post_id'] = $saved_post_id; |
| 4605 | 4605 | $gd_post['ID'] = $saved_post_id; |
@@ -4611,7 +4611,7 @@ discard block |
||
| 4611 | 4611 | |
| 4612 | 4612 | // post location |
| 4613 | 4613 | $post_location_id = 0; |
| 4614 | - if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 4614 | + if ($location_allowed && !empty($location_result) && $location_result->location_id > 0) {
|
|
| 4615 | 4615 | $gd_post['post_neighbourhood'] = ''; |
| 4616 | 4616 | |
| 4617 | 4617 | $post_location_info = array( |
@@ -4621,7 +4621,7 @@ discard block |
||
| 4621 | 4621 | 'geo_lat' => $post_latitude, |
| 4622 | 4622 | 'geo_lng' => $post_longitude |
| 4623 | 4623 | ); |
| 4624 | - if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 4624 | + if ($location_id = (int) geodir_add_new_location($post_location_info)) {
|
|
| 4625 | 4625 | $post_location_id = $location_id; |
| 4626 | 4626 | } |
| 4627 | 4627 | |
@@ -4659,14 +4659,14 @@ discard block |
||
| 4659 | 4659 | $gd_post['post_location_id'] = $post_location_id; |
| 4660 | 4660 | |
| 4661 | 4661 | // post package info |
| 4662 | - $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 4662 | + $package_id = isset($gd_post['package_id']) && !empty($gd_post['package_id']) ? (int) $gd_post['package_id'] : 0; |
|
| 4663 | 4663 | if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
| 4664 | 4664 | $package_id = $gd_post_info->package_id; |
| 4665 | 4665 | } |
| 4666 | 4666 | |
| 4667 | 4667 | $package_info = array(); |
| 4668 | 4668 | if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
| 4669 | - $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 4669 | + $package_info = (array) geodir_get_package_info_by_id($package_id); |
|
| 4670 | 4670 | |
| 4671 | 4671 | if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
| 4672 | 4672 | $package_info = array(); |
@@ -4674,18 +4674,18 @@ discard block |
||
| 4674 | 4674 | } |
| 4675 | 4675 | |
| 4676 | 4676 | if (empty($package_info)) {
|
| 4677 | - $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 4677 | + $package_info = (array) geodir_post_package_info(array(), '', $post_type); |
|
| 4678 | 4678 | } |
| 4679 | 4679 | |
| 4680 | - if (!empty($package_info)) {
|
|
| 4680 | + if (!empty($package_info)) {
|
|
| 4681 | 4681 | $package_id = $package_info['pid']; |
| 4682 | 4682 | |
| 4683 | 4683 | if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
| 4684 | 4684 | $gd_post['expire_date'] = $expire_date; |
| 4685 | 4685 | } else {
|
| 4686 | - if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 4687 | - $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 4688 | - $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 4686 | + if (isset($package_info['days']) && (int) $package_info['days'] > 0) {
|
|
| 4687 | + $gd_post['alive_days'] = (int) $package_info['days']; |
|
| 4688 | + $gd_post['expire_date'] = date_i18n('Y-m-d', strtotime($current_date.'+'.(int) $package_info['days'].' days'));
|
|
| 4689 | 4689 | } else {
|
| 4690 | 4690 | $gd_post['expire_date'] = 'Never'; |
| 4691 | 4691 | } |
@@ -4694,7 +4694,7 @@ discard block |
||
| 4694 | 4694 | $gd_post['package_id'] = $package_id; |
| 4695 | 4695 | } |
| 4696 | 4696 | |
| 4697 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 4697 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 4698 | 4698 | |
| 4699 | 4699 | if ($post_type == 'gd_event') {
|
| 4700 | 4700 | $gd_post = geodir_imex_process_event_data($gd_post); |
@@ -4705,28 +4705,28 @@ discard block |
||
| 4705 | 4705 | } |
| 4706 | 4706 | |
| 4707 | 4707 | // Export franchise fields |
| 4708 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 4708 | + $is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
|
|
| 4709 | 4709 | if ($is_franchise_active) {
|
| 4710 | - if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 4710 | + if (isset($gd_post['gd_is_franchise']) && (int) $gd_post['gd_is_franchise'] == 1) {
|
|
| 4711 | 4711 | $gd_franchise_lock = array(); |
| 4712 | 4712 | |
| 4713 | - if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 4714 | - $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 4715 | - $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 4716 | - $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 4713 | + if (isset($gd_post['gd_franchise_lock'])) {
|
|
| 4714 | + $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock']);
|
|
| 4715 | + $gd_franchise_lock = trim($gd_franchise_lock); |
|
| 4716 | + $gd_franchise_lock = explode(",", $gd_franchise_lock);
|
|
| 4717 | 4717 | } |
| 4718 | 4718 | |
| 4719 | - update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 4720 | - update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 4719 | + update_post_meta($saved_post_id, 'gd_is_franchise', 1); |
|
| 4720 | + update_post_meta($saved_post_id, 'gd_franchise_lock', $gd_franchise_lock); |
|
| 4721 | 4721 | } else {
|
| 4722 | - if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 4723 | - geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 4722 | + if (isset($gd_post['franchise']) && (int) $gd_post['franchise'] > 0 && geodir_franchise_check((int) $gd_post['franchise'])) {
|
|
| 4723 | + geodir_save_post_meta($saved_post_id, 'franchise', (int) $gd_post['franchise']); |
|
| 4724 | 4724 | } |
| 4725 | 4725 | } |
| 4726 | 4726 | } |
| 4727 | 4727 | |
| 4728 | 4728 | if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
| 4729 | - $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 4729 | + $save_post['post_category'] = array_unique(array_map('intval', $save_post['post_category']));
|
|
| 4730 | 4730 | if ($default_category_id) {
|
| 4731 | 4731 | $save_post['post_default_category'] = $default_category_id; |
| 4732 | 4732 | $gd_post['default_category'] = $default_category_id; |
@@ -4735,34 +4735,34 @@ discard block |
||
| 4735 | 4735 | } |
| 4736 | 4736 | |
| 4737 | 4737 | // Save post info |
| 4738 | - geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 4738 | + geodir_save_post_info($saved_post_id, $gd_post); |
|
| 4739 | 4739 | // post taxonomies |
| 4740 | - if ( !empty( $save_post['post_category'] ) ) {
|
|
| 4741 | - wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 4740 | + if (!empty($save_post['post_category'])) {
|
|
| 4741 | + wp_set_object_terms($saved_post_id, $save_post['post_category'], $cat_taxonomy); |
|
| 4742 | 4742 | |
| 4743 | - $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 4743 | + $post_default_category = isset($save_post['post_default_category']) ? $save_post['post_default_category'] : ''; |
|
| 4744 | 4744 | if ($default_category_id) {
|
| 4745 | 4745 | $post_default_category = $default_category_id; |
| 4746 | 4746 | } |
| 4747 | 4747 | $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
| 4748 | 4748 | $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
| 4749 | - $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 4749 | + $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']).',y:' : '';
|
|
| 4750 | 4750 | |
| 4751 | 4751 | if ($post_category_str != '' && $post_default_category) {
|
| 4752 | - $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 4752 | + $post_category_str = str_replace($post_default_category.',y:', $post_default_category.',y,d:', $post_category_str); |
|
| 4753 | 4753 | } |
| 4754 | 4754 | |
| 4755 | 4755 | $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
| 4756 | 4756 | |
| 4757 | - geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 4757 | + geodir_set_postcat_structure($saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str); |
|
| 4758 | 4758 | } |
| 4759 | 4759 | |
| 4760 | - if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 4761 | - wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 4760 | + if (!empty($save_post['post_tags'])) {
|
|
| 4761 | + wp_set_object_terms($saved_post_id, $save_post['post_tags'], $tags_taxonomy); |
|
| 4762 | 4762 | } |
| 4763 | 4763 | |
| 4764 | 4764 | // Post images |
| 4765 | - if ( !empty( $post_images ) ) {
|
|
| 4765 | + if (!empty($post_images)) {
|
|
| 4766 | 4766 | $post_images = array_unique($post_images); |
| 4767 | 4767 | |
| 4768 | 4768 | $old_post_images_arr = array(); |
@@ -4770,82 +4770,82 @@ discard block |
||
| 4770 | 4770 | |
| 4771 | 4771 | $order = 1; |
| 4772 | 4772 | |
| 4773 | - $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 4773 | + $old_post_images = geodir_get_images($saved_post_id); |
|
| 4774 | 4774 | if (!empty($old_post_images)) {
|
| 4775 | - foreach( $old_post_images as $old_post_image ) {
|
|
| 4775 | + foreach ($old_post_images as $old_post_image) {
|
|
| 4776 | 4776 | if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
| 4777 | 4777 | $old_post_images_arr[] = $old_post_image->file; |
| 4778 | 4778 | } |
| 4779 | 4779 | } |
| 4780 | 4780 | } |
| 4781 | 4781 | |
| 4782 | - foreach ( $post_images as $post_image ) {
|
|
| 4783 | - $image_name = basename( $post_image ); |
|
| 4782 | + foreach ($post_images as $post_image) {
|
|
| 4783 | + $image_name = basename($post_image); |
|
| 4784 | 4784 | $saved_post_images_arr[] = $image_name; |
| 4785 | 4785 | |
| 4786 | - if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 4786 | + if (!empty($old_post_images_arr) && in_array($image_name, $old_post_images_arr)) {
|
|
| 4787 | 4787 | continue; // Skip if image already exists. |
| 4788 | 4788 | } |
| 4789 | 4789 | |
| 4790 | - $image_name_parts = explode( '.', $image_name ); |
|
| 4791 | - array_pop( $image_name_parts ); |
|
| 4792 | - $proper_image_name = implode( '.', $image_name_parts ); |
|
| 4790 | + $image_name_parts = explode('.', $image_name);
|
|
| 4791 | + array_pop($image_name_parts); |
|
| 4792 | + $proper_image_name = implode('.', $image_name_parts);
|
|
| 4793 | 4793 | |
| 4794 | - $arr_file_type = wp_check_filetype( $image_name ); |
|
| 4794 | + $arr_file_type = wp_check_filetype($image_name); |
|
| 4795 | 4795 | |
| 4796 | - if ( !empty( $arr_file_type ) ) {
|
|
| 4796 | + if (!empty($arr_file_type)) {
|
|
| 4797 | 4797 | $uploaded_file_type = $arr_file_type['type']; |
| 4798 | 4798 | |
| 4799 | 4799 | $attachment = array(); |
| 4800 | 4800 | $attachment['post_id'] = $saved_post_id; |
| 4801 | 4801 | $attachment['title'] = $proper_image_name; |
| 4802 | 4802 | $attachment['content'] = ''; |
| 4803 | - $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 4803 | + $attachment['file'] = $uploads_subdir.'/'.$image_name; |
|
| 4804 | 4804 | $attachment['mime_type'] = $uploaded_file_type; |
| 4805 | 4805 | $attachment['menu_order'] = $order; |
| 4806 | 4806 | $attachment['is_featured'] = 0; |
| 4807 | 4807 | |
| 4808 | 4808 | $attachment_set = ''; |
| 4809 | - foreach ( $attachment as $key => $val ) {
|
|
| 4810 | - if ( $val != '' ) {
|
|
| 4811 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 4809 | + foreach ($attachment as $key => $val) {
|
|
| 4810 | + if ($val != '') {
|
|
| 4811 | + $attachment_set .= $key." = '".$val."', "; |
|
| 4812 | 4812 | } |
| 4813 | 4813 | } |
| 4814 | - $attachment_set = trim( $attachment_set, ", " ); |
|
| 4814 | + $attachment_set = trim($attachment_set, ", "); |
|
| 4815 | 4815 | |
| 4816 | 4816 | // Add new attachment |
| 4817 | - $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 4817 | + $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
|
|
| 4818 | 4818 | |
| 4819 | 4819 | $order++; |
| 4820 | 4820 | } |
| 4821 | 4821 | } |
| 4822 | 4822 | |
| 4823 | - $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 4823 | + $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/".implode("' AND file NOT LIKE '%/", $saved_post_images_arr)."' )" : '';
|
|
| 4824 | 4824 | // Remove previous attachment |
| 4825 | - $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 4825 | + $wpdb->query("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id = ".(int) $saved_post_id." ".$saved_post_images_sql);
|
|
| 4826 | 4826 | |
| 4827 | - if ( !empty( $saved_post_images_arr ) ) {
|
|
| 4827 | + if (!empty($saved_post_images_arr)) {
|
|
| 4828 | 4828 | $menu_order = 1; |
| 4829 | 4829 | |
| 4830 | - foreach ( $saved_post_images_arr as $img_name ) {
|
|
| 4831 | - $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 ) ) ); |
|
| 4830 | + foreach ($saved_post_images_arr as $img_name) {
|
|
| 4831 | + $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)));
|
|
| 4832 | 4832 | |
| 4833 | - if( $menu_order == 1 ) {
|
|
| 4834 | - 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 ) ) ) ) {
|
|
| 4835 | - $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) ); |
|
| 4833 | + if ($menu_order == 1) {
|
|
| 4834 | + 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)))) {
|
|
| 4835 | + $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s WHERE post_id =%d", array($featured_image, $saved_post_id)));
|
|
| 4836 | 4836 | } |
| 4837 | 4837 | } |
| 4838 | 4838 | $menu_order++; |
| 4839 | 4839 | } |
| 4840 | 4840 | } |
| 4841 | 4841 | |
| 4842 | - if ( $order > 1 ) {
|
|
| 4842 | + if ($order > 1) {
|
|
| 4843 | 4843 | $images++; |
| 4844 | 4844 | } |
| 4845 | 4845 | } |
| 4846 | 4846 | |
| 4847 | 4847 | /** This action is documented in geodirectory-functions/post-functions.php */ |
| 4848 | - do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 4848 | + do_action('geodir_after_save_listing', $saved_post_id, $gd_post);
|
|
| 4849 | 4849 | |
| 4850 | 4850 | if (isset($is_featured)) {
|
| 4851 | 4851 | geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
@@ -4865,10 +4865,10 @@ discard block |
||
| 4865 | 4865 | } |
| 4866 | 4866 | |
| 4867 | 4867 | //undo some stuff to make the import quicker |
| 4868 | - wp_defer_term_counting( false ); |
|
| 4869 | - wp_defer_comment_counting( false ); |
|
| 4870 | - $wpdb->query( 'COMMIT;' ); |
|
| 4871 | - $wpdb->query( 'SET autocommit = 1;' ); |
|
| 4868 | + wp_defer_term_counting(false); |
|
| 4869 | + wp_defer_comment_counting(false); |
|
| 4870 | + $wpdb->query('COMMIT;');
|
|
| 4871 | + $wpdb->query('SET autocommit = 1;');
|
|
| 4872 | 4872 | |
| 4873 | 4873 | $json = array(); |
| 4874 | 4874 | $json['processed'] = $processed_actual; |
@@ -4879,9 +4879,9 @@ discard block |
||
| 4879 | 4879 | $json['invalid_addr'] = $invalid_addr; |
| 4880 | 4880 | $json['images'] = $images; |
| 4881 | 4881 | |
| 4882 | - wp_send_json( $json ); |
|
| 4882 | + wp_send_json($json); |
|
| 4883 | 4883 | exit; |
| 4884 | - } else if ( $task == 'import_loc' ) {
|
|
| 4884 | + } else if ($task == 'import_loc') {
|
|
| 4885 | 4885 | global $gd_post_types; |
| 4886 | 4886 | $gd_post_types = $post_types; |
| 4887 | 4887 | |
@@ -4890,82 +4890,82 @@ discard block |
||
| 4890 | 4890 | |
| 4891 | 4891 | if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
| 4892 | 4892 | $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
| 4893 | - wp_send_json( $json ); |
|
| 4893 | + wp_send_json($json); |
|
| 4894 | 4894 | } |
| 4895 | 4895 | |
| 4896 | 4896 | $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
|
| 4897 | - $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
| 4897 | + $gd_error_location = __('Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory');
|
|
| 4898 | 4898 | for ($i = 1; $i <= $limit; $i++) {
|
| 4899 | 4899 | $index = $processed + $i; |
| 4900 | 4900 | |
| 4901 | 4901 | if (isset($file[$index])) {
|
| 4902 | 4902 | $row = $file[$index]; |
| 4903 | - $row = array_map( 'trim', $row ); |
|
| 4903 | + $row = array_map('trim', $row);
|
|
| 4904 | 4904 | $data = array(); |
| 4905 | 4905 | |
| 4906 | - foreach ($columns as $c => $column ) {
|
|
| 4906 | + foreach ($columns as $c => $column) {
|
|
| 4907 | 4907 | 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'))) {
|
| 4908 | 4908 | $data[$column] = $row[$c]; |
| 4909 | 4909 | } |
| 4910 | 4910 | } |
| 4911 | 4911 | |
| 4912 | - if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 4912 | + if (empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude'])) {
|
|
| 4913 | 4913 | $invalid++; |
| 4914 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4914 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location); |
|
| 4915 | 4915 | continue; |
| 4916 | 4916 | } |
| 4917 | 4917 | |
| 4918 | 4918 | $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
| 4919 | 4919 | |
| 4920 | - if ( $import_choice == 'update' ) {
|
|
| 4921 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4922 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4920 | + if ($import_choice == 'update') {
|
|
| 4921 | + if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
|
|
| 4922 | + if ($location_id = geodir_location_update_city($data, true, $location)) {
|
|
| 4923 | 4923 | $updated++; |
| 4924 | 4924 | } else {
|
| 4925 | 4925 | $invalid++; |
| 4926 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4926 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location); |
|
| 4927 | 4927 | } |
| 4928 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4929 | - $data['location_id'] = (int)$location->location_id; |
|
| 4928 | + } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
|
|
| 4929 | + $data['location_id'] = (int) $location->location_id; |
|
| 4930 | 4930 | |
| 4931 | - if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 4932 | - $data['location_id'] = (int)$location->location_id; |
|
| 4933 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 4934 | - $data['location_id'] = (int)$location->location_id; |
|
| 4935 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 4936 | - $data['location_id'] = (int)$location->location_id; |
|
| 4931 | + if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region']))) {
|
|
| 4932 | + $data['location_id'] = (int) $location->location_id; |
|
| 4933 | + } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'region' => $data['region']))) {
|
|
| 4934 | + $data['location_id'] = (int) $location->location_id; |
|
| 4935 | + } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country']))) {
|
|
| 4936 | + $data['location_id'] = (int) $location->location_id; |
|
| 4937 | 4937 | } |
| 4938 | 4938 | |
| 4939 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4939 | + if ($location_id = geodir_location_update_city($data, true, $location)) {
|
|
| 4940 | 4940 | $updated++; |
| 4941 | 4941 | } else {
|
| 4942 | 4942 | $invalid++; |
| 4943 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4943 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location); |
|
| 4944 | 4944 | } |
| 4945 | 4945 | } else {
|
| 4946 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4946 | + if ($location_id = geodir_location_insert_city($data, true)) {
|
|
| 4947 | 4947 | $created++; |
| 4948 | 4948 | } else {
|
| 4949 | 4949 | $invalid++; |
| 4950 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4950 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location); |
|
| 4951 | 4951 | } |
| 4952 | 4952 | } |
| 4953 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 4954 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4953 | + } elseif ($import_choice == 'skip') {
|
|
| 4954 | + if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
|
|
| 4955 | 4955 | $skipped++; |
| 4956 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4956 | + } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
|
|
| 4957 | 4957 | $skipped++; |
| 4958 | 4958 | } else {
|
| 4959 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4959 | + if ($location_id = geodir_location_insert_city($data, true)) {
|
|
| 4960 | 4960 | $created++; |
| 4961 | 4961 | } else {
|
| 4962 | 4962 | $invalid++; |
| 4963 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4963 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location); |
|
| 4964 | 4964 | } |
| 4965 | 4965 | } |
| 4966 | 4966 | } else {
|
| 4967 | 4967 | $invalid++; |
| 4968 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4968 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_location); |
|
| 4969 | 4969 | } |
| 4970 | 4970 | } |
| 4971 | 4971 | } |
@@ -4979,24 +4979,24 @@ discard block |
||
| 4979 | 4979 | $json['invalid'] = $invalid; |
| 4980 | 4980 | $json['images'] = $images; |
| 4981 | 4981 | |
| 4982 | - wp_send_json( $json ); |
|
| 4983 | - } else if ( $task == 'import_hood' ) {
|
|
| 4982 | + wp_send_json($json); |
|
| 4983 | + } else if ($task == 'import_hood') {
|
|
| 4984 | 4984 | if (!empty($file)) {
|
| 4985 | 4985 | $columns = isset($file[0]) ? $file[0] : NULL; |
| 4986 | 4986 | |
| 4987 | 4987 | if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
| 4988 | 4988 | $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
| 4989 | - wp_send_json( $json ); |
|
| 4989 | + wp_send_json($json); |
|
| 4990 | 4990 | } |
| 4991 | 4991 | |
| 4992 | 4992 | $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
|
| 4993 | - $gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' ); |
|
| 4993 | + $gd_error_hood = __('Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory');
|
|
| 4994 | 4994 | for ($i = 1; $i <= $limit; $i++) {
|
| 4995 | 4995 | $index = $processed + $i; |
| 4996 | 4996 | |
| 4997 | 4997 | if (isset($file[$index])) {
|
| 4998 | 4998 | $row = $file[$index]; |
| 4999 | - $row = array_map( 'trim', $row ); |
|
| 4999 | + $row = array_map('trim', $row);
|
|
| 5000 | 5000 | $data = array(); |
| 5001 | 5001 | |
| 5002 | 5002 | foreach ($columns as $c => $column) {
|
@@ -5007,20 +5007,20 @@ discard block |
||
| 5007 | 5007 | |
| 5008 | 5008 | if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
|
| 5009 | 5009 | $invalid++; |
| 5010 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5010 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood); |
|
| 5011 | 5011 | continue; |
| 5012 | 5012 | } |
| 5013 | 5013 | |
| 5014 | 5014 | $location_info = array(); |
| 5015 | - if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
|
|
| 5016 | - $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
|
|
| 5015 | + if (!empty($data['location_id']) && (int) $data['location_id'] > 0) {
|
|
| 5016 | + $location_info = geodir_get_location_by_id('', (int) $data['location_id']);
|
|
| 5017 | 5017 | } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
|
| 5018 | 5018 | $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
|
| 5019 | 5019 | } |
| 5020 | 5020 | |
| 5021 | 5021 | if (empty($location_info)) {
|
| 5022 | 5022 | $invalid++; |
| 5023 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5023 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood); |
|
| 5024 | 5024 | continue; |
| 5025 | 5025 | } |
| 5026 | 5026 | |
@@ -5035,35 +5035,35 @@ discard block |
||
| 5035 | 5035 | $hood_data['hood_longitude'] = $data['longitude']; |
| 5036 | 5036 | $hood_data['hood_location_id'] = $location_id; |
| 5037 | 5037 | |
| 5038 | - if ( $import_choice == 'update' ) {
|
|
| 5039 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 5040 | - $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
| 5038 | + if ($import_choice == 'update') {
|
|
| 5039 | + if ((int) $data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int) $data['neighbourhood_id']))) {
|
|
| 5040 | + $hood_data['hood_id'] = (int) $data['neighbourhood_id']; |
|
| 5041 | 5041 | |
| 5042 | 5042 | if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
| 5043 | 5043 | $updated++; |
| 5044 | 5044 | } else {
|
| 5045 | 5045 | $invalid++; |
| 5046 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5046 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood); |
|
| 5047 | 5047 | } |
| 5048 | 5048 | } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
| 5049 | - $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
| 5049 | + $hood_data['hood_id'] = (int) $neighbourhood->hood_id; |
|
| 5050 | 5050 | |
| 5051 | 5051 | if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
| 5052 | 5052 | $updated++; |
| 5053 | 5053 | } else {
|
| 5054 | 5054 | $invalid++; |
| 5055 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5055 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood); |
|
| 5056 | 5056 | } |
| 5057 | 5057 | } else {
|
| 5058 | 5058 | if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
| 5059 | 5059 | $created++; |
| 5060 | 5060 | } else {
|
| 5061 | 5061 | $invalid++; |
| 5062 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5062 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood); |
|
| 5063 | 5063 | } |
| 5064 | 5064 | } |
| 5065 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 5066 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 5065 | + } elseif ($import_choice == 'skip') {
|
|
| 5066 | + if ((int) $data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int) $data['neighbourhood_id']))) {
|
|
| 5067 | 5067 | $skipped++; |
| 5068 | 5068 | } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
| 5069 | 5069 | $skipped++; |
@@ -5073,12 +5073,12 @@ discard block |
||
| 5073 | 5073 | $created++; |
| 5074 | 5074 | } else {
|
| 5075 | 5075 | $invalid++; |
| 5076 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5076 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood); |
|
| 5077 | 5077 | } |
| 5078 | 5078 | } |
| 5079 | 5079 | } else {
|
| 5080 | 5080 | $invalid++; |
| 5081 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 5081 | + geodir_error_log(wp_sprintf($gd_error_log, ($index + 1)).' '.$gd_error_hood); |
|
| 5082 | 5082 | } |
| 5083 | 5083 | } |
| 5084 | 5084 | } |
@@ -5092,7 +5092,7 @@ discard block |
||
| 5092 | 5092 | $json['invalid'] = $invalid; |
| 5093 | 5093 | $json['images'] = $images; |
| 5094 | 5094 | |
| 5095 | - wp_send_json( $json ); |
|
| 5095 | + wp_send_json($json); |
|
| 5096 | 5096 | } |
| 5097 | 5097 | } |
| 5098 | 5098 | break; |
@@ -5136,29 +5136,29 @@ discard block |
||
| 5136 | 5136 | * } |
| 5137 | 5137 | * @return int|bool Term id when success, false when fail. |
| 5138 | 5138 | */ |
| 5139 | -function geodir_imex_insert_term( $taxonomy, $term_data ) {
|
|
| 5140 | - if ( empty( $taxonomy ) || empty( $term_data ) ) {
|
|
| 5139 | +function geodir_imex_insert_term($taxonomy, $term_data) {
|
|
| 5140 | + if (empty($taxonomy) || empty($term_data)) {
|
|
| 5141 | 5141 | return false; |
| 5142 | 5142 | } |
| 5143 | 5143 | |
| 5144 | - $term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : ''; |
|
| 5144 | + $term = isset($term_data['name']) && !empty($term_data['name']) ? $term_data['name'] : ''; |
|
| 5145 | 5145 | $args = array(); |
| 5146 | - $args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : ''; |
|
| 5147 | - $args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : ''; |
|
| 5148 | - $args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : ''; |
|
| 5146 | + $args['description'] = isset($term_data['description']) ? $term_data['description'] : ''; |
|
| 5147 | + $args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : ''; |
|
| 5148 | + $args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : ''; |
|
| 5149 | 5149 | |
| 5150 | - if ( ( !empty( $args['slug'] ) && term_exists( $args['slug'], $taxonomy ) ) || empty( $args['slug'] ) ) {
|
|
| 5151 | - $term_args = array_merge( $term_data, $args ); |
|
| 5152 | - $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => ''); |
|
| 5153 | - $term_args = wp_parse_args( $term_args, $defaults ); |
|
| 5154 | - $term_args = sanitize_term( $term_args, $taxonomy, 'db' ); |
|
| 5155 | - $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
|
| 5150 | + if ((!empty($args['slug']) && term_exists($args['slug'], $taxonomy)) || empty($args['slug'])) {
|
|
| 5151 | + $term_args = array_merge($term_data, $args); |
|
| 5152 | + $defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
|
|
| 5153 | + $term_args = wp_parse_args($term_args, $defaults); |
|
| 5154 | + $term_args = sanitize_term($term_args, $taxonomy, 'db'); |
|
| 5155 | + $args['slug'] = wp_unique_term_slug($args['slug'], (object) $term_args); |
|
| 5156 | 5156 | } |
| 5157 | 5157 | |
| 5158 | - if( !empty( $term ) ) {
|
|
| 5159 | - $result = wp_insert_term( $term, $taxonomy, $args ); |
|
| 5160 | - if( !is_wp_error( $result ) ) {
|
|
| 5161 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5158 | + if (!empty($term)) {
|
|
| 5159 | + $result = wp_insert_term($term, $taxonomy, $args); |
|
| 5160 | + if (!is_wp_error($result)) {
|
|
| 5161 | + return isset($result['term_id']) ? $result['term_id'] : 0; |
|
| 5162 | 5162 | } |
| 5163 | 5163 | } |
| 5164 | 5164 | |
@@ -5188,36 +5188,36 @@ discard block |
||
| 5188 | 5188 | * } |
| 5189 | 5189 | * @return int|bool Term id when success, false when fail. |
| 5190 | 5190 | */ |
| 5191 | -function geodir_imex_update_term( $taxonomy, $term_data ) {
|
|
| 5192 | - if ( empty( $taxonomy ) || empty( $term_data ) ) {
|
|
| 5191 | +function geodir_imex_update_term($taxonomy, $term_data) {
|
|
| 5192 | + if (empty($taxonomy) || empty($term_data)) {
|
|
| 5193 | 5193 | return false; |
| 5194 | 5194 | } |
| 5195 | 5195 | |
| 5196 | - $term_id = isset( $term_data['term_id'] ) && !empty( $term_data['term_id'] ) ? $term_data['term_id'] : 0; |
|
| 5196 | + $term_id = isset($term_data['term_id']) && !empty($term_data['term_id']) ? $term_data['term_id'] : 0; |
|
| 5197 | 5197 | |
| 5198 | 5198 | $args = array(); |
| 5199 | - $args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : ''; |
|
| 5200 | - $args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : ''; |
|
| 5201 | - $args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : ''; |
|
| 5199 | + $args['description'] = isset($term_data['description']) ? $term_data['description'] : ''; |
|
| 5200 | + $args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : ''; |
|
| 5201 | + $args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : ''; |
|
| 5202 | 5202 | |
| 5203 | - if ( $term_id > 0 && $term_info = (array)get_term( $term_id, $taxonomy ) ) {
|
|
| 5203 | + if ($term_id > 0 && $term_info = (array) get_term($term_id, $taxonomy)) {
|
|
| 5204 | 5204 | $term_data['term_id'] = $term_info['term_id']; |
| 5205 | 5205 | |
| 5206 | - $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
|
| 5206 | + $result = wp_update_term($term_data['term_id'], $taxonomy, $term_data); |
|
| 5207 | 5207 | |
| 5208 | - if( !is_wp_error( $result ) ) {
|
|
| 5209 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5208 | + if (!is_wp_error($result)) {
|
|
| 5209 | + return isset($result['term_id']) ? $result['term_id'] : 0; |
|
| 5210 | 5210 | } |
| 5211 | - } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5211 | + } else if ($term_data['slug'] != '' && $term_info = (array) term_exists($term_data['slug'], $taxonomy)) {
|
|
| 5212 | 5212 | $term_data['term_id'] = $term_info['term_id']; |
| 5213 | 5213 | |
| 5214 | - $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
|
| 5214 | + $result = wp_update_term($term_data['term_id'], $taxonomy, $term_data); |
|
| 5215 | 5215 | |
| 5216 | - if( !is_wp_error( $result ) ) {
|
|
| 5217 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5216 | + if (!is_wp_error($result)) {
|
|
| 5217 | + return isset($result['term_id']) ? $result['term_id'] : 0; |
|
| 5218 | 5218 | } |
| 5219 | 5219 | } else {
|
| 5220 | - return geodir_imex_insert_term( $taxonomy, $term_data ); |
|
| 5220 | + return geodir_imex_insert_term($taxonomy, $term_data); |
|
| 5221 | 5221 | } |
| 5222 | 5222 | |
| 5223 | 5223 | return false; |
@@ -5235,25 +5235,25 @@ discard block |
||
| 5235 | 5235 | * @param string $post_type Post type. |
| 5236 | 5236 | * @return int Posts count. |
| 5237 | 5237 | */ |
| 5238 | -function geodir_get_posts_count( $post_type ) {
|
|
| 5238 | +function geodir_get_posts_count($post_type) {
|
|
| 5239 | 5239 | global $wpdb, $plugin_prefix; |
| 5240 | 5240 | |
| 5241 | - if ( !post_type_exists( $post_type ) ) {
|
|
| 5241 | + if (!post_type_exists($post_type)) {
|
|
| 5242 | 5242 | return 0; |
| 5243 | 5243 | } |
| 5244 | 5244 | |
| 5245 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5245 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 5246 | 5246 | |
| 5247 | 5247 | // Skip listing with statuses trash, auto-draft etc... |
| 5248 | 5248 | $skip_statuses = geodir_imex_export_skip_statuses(); |
| 5249 | 5249 | $where_statuses = ''; |
| 5250 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5251 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5250 | + if (!empty($skip_statuses) && is_array($skip_statuses)) {
|
|
| 5251 | + $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
|
|
| 5252 | 5252 | } |
| 5253 | 5253 | |
| 5254 | - $query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
|
|
| 5254 | + $query = $wpdb->prepare("SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s ".$where_statuses, $post_type);
|
|
| 5255 | 5255 | |
| 5256 | - $posts_count = (int)$wpdb->get_var( $query ); |
|
| 5256 | + $posts_count = (int) $wpdb->get_var($query); |
|
| 5257 | 5257 | |
| 5258 | 5258 | /** |
| 5259 | 5259 | * Modify returned post counts for the current post type. |
@@ -5264,7 +5264,7 @@ discard block |
||
| 5264 | 5264 | * @param int $posts_count Post counts. |
| 5265 | 5265 | * @param string $post_type Post type. |
| 5266 | 5266 | */ |
| 5267 | - $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5267 | + $posts_count = apply_filters('geodir_imex_count_posts', $posts_count, $post_type);
|
|
| 5268 | 5268 | |
| 5269 | 5269 | return $posts_count; |
| 5270 | 5270 | } |
@@ -5285,17 +5285,17 @@ discard block |
||
| 5285 | 5285 | * @param int $page_no Page number. Default 0. |
| 5286 | 5286 | * @return array Array of posts data. |
| 5287 | 5287 | */ |
| 5288 | -function geodir_imex_get_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
|
| 5288 | +function geodir_imex_get_posts($post_type, $per_page = 0, $page_no = 0) {
|
|
| 5289 | 5289 | global $wp_filesystem; |
| 5290 | 5290 | |
| 5291 | - $posts = geodir_get_export_posts( $post_type, $per_page, $page_no ); |
|
| 5291 | + $posts = geodir_get_export_posts($post_type, $per_page, $page_no); |
|
| 5292 | 5292 | |
| 5293 | 5293 | $csv_rows = array(); |
| 5294 | 5294 | |
| 5295 | - if ( !empty( $posts ) ) {
|
|
| 5296 | - $is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' ); |
|
| 5295 | + if (!empty($posts)) {
|
|
| 5296 | + $is_payment_plugin = is_plugin_active('geodir_payment_manager/geodir_payment_manager.php');
|
|
| 5297 | 5297 | $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
| 5298 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5298 | + $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
|
|
| 5299 | 5299 | $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
|
| 5300 | 5300 | |
| 5301 | 5301 | $csv_row = array(); |
@@ -5307,7 +5307,7 @@ discard block |
||
| 5307 | 5307 | $csv_row[] = 'default_category'; |
| 5308 | 5308 | $csv_row[] = 'post_tags'; |
| 5309 | 5309 | $csv_row[] = 'post_type'; |
| 5310 | - if ( $post_type == 'gd_event' ) {
|
|
| 5310 | + if ($post_type == 'gd_event') {
|
|
| 5311 | 5311 | $csv_row[] = 'event_date'; |
| 5312 | 5312 | $csv_row[] = 'event_enddate'; |
| 5313 | 5313 | $csv_row[] = 'starttime'; |
@@ -5361,15 +5361,15 @@ discard block |
||
| 5361 | 5361 | } |
| 5362 | 5362 | // WPML |
| 5363 | 5363 | |
| 5364 | - $custom_fields = geodir_imex_get_custom_fields( $post_type ); |
|
| 5365 | - if ( !empty( $custom_fields ) ) {
|
|
| 5366 | - foreach ( $custom_fields as $custom_field ) {
|
|
| 5364 | + $custom_fields = geodir_imex_get_custom_fields($post_type); |
|
| 5365 | + if (!empty($custom_fields)) {
|
|
| 5366 | + foreach ($custom_fields as $custom_field) {
|
|
| 5367 | 5367 | $csv_row[] = $custom_field->htmlvar_name; |
| 5368 | 5368 | } |
| 5369 | 5369 | } |
| 5370 | 5370 | |
| 5371 | 5371 | // Export franchise fields |
| 5372 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 5372 | + $is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
|
|
| 5373 | 5373 | if ($is_franchise_active) {
|
| 5374 | 5374 | $csv_row[] = 'gd_is_franchise'; |
| 5375 | 5375 | $csv_row[] = 'gd_franchise_lock'; |
@@ -5379,28 +5379,28 @@ discard block |
||
| 5379 | 5379 | $csv_rows[] = $csv_row; |
| 5380 | 5380 | |
| 5381 | 5381 | $images_count = 5; |
| 5382 | - $xx=0; |
|
| 5383 | - foreach ( $posts as $post ) {$xx++;
|
|
| 5382 | + $xx = 0; |
|
| 5383 | + foreach ($posts as $post) {$xx++;
|
|
| 5384 | 5384 | $post_id = $post['ID']; |
| 5385 | 5385 | |
| 5386 | - $gd_post_info = geodir_get_post_info( $post_id ); |
|
| 5387 | - $post_info = (array)$gd_post_info; |
|
| 5386 | + $gd_post_info = geodir_get_post_info($post_id); |
|
| 5387 | + $post_info = (array) $gd_post_info; |
|
| 5388 | 5388 | |
| 5389 | - $taxonomy_category = $post_type . 'category'; |
|
| 5390 | - $taxonomy_tags = $post_type . '_tags'; |
|
| 5389 | + $taxonomy_category = $post_type.'category'; |
|
| 5390 | + $taxonomy_tags = $post_type.'_tags'; |
|
| 5391 | 5391 | |
| 5392 | 5392 | $post_category = ''; |
| 5393 | 5393 | $default_category_id = $gd_post_info->default_category; |
| 5394 | 5394 | $default_category = ''; |
| 5395 | 5395 | $post_tags = ''; |
| 5396 | - $terms = wp_get_post_terms( $post_id, array( $taxonomy_category, $taxonomy_tags ) ); |
|
| 5396 | + $terms = wp_get_post_terms($post_id, array($taxonomy_category, $taxonomy_tags)); |
|
| 5397 | 5397 | |
| 5398 | - if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
|
|
| 5398 | + if (!empty($terms) && !is_wp_error($terms)) {
|
|
| 5399 | 5399 | $post_category = array(); |
| 5400 | 5400 | $post_tags = array(); |
| 5401 | 5401 | |
| 5402 | - foreach ( $terms as $term ) {
|
|
| 5403 | - if ( $term->taxonomy == $taxonomy_category ) {
|
|
| 5402 | + foreach ($terms as $term) {
|
|
| 5403 | + if ($term->taxonomy == $taxonomy_category) {
|
|
| 5404 | 5404 | $post_category[] = $term->name; |
| 5405 | 5405 | |
| 5406 | 5406 | if ($default_category_id == $term->term_id) {
|
@@ -5408,7 +5408,7 @@ discard block |
||
| 5408 | 5408 | } |
| 5409 | 5409 | } |
| 5410 | 5410 | |
| 5411 | - if ( $term->taxonomy == $taxonomy_tags ) {
|
|
| 5411 | + if ($term->taxonomy == $taxonomy_tags) {
|
|
| 5412 | 5412 | $post_tags[] = $term->name; |
| 5413 | 5413 | } |
| 5414 | 5414 | } |
@@ -5416,47 +5416,47 @@ discard block |
||
| 5416 | 5416 | if (empty($default_category) && !empty($post_category)) {
|
| 5417 | 5417 | $default_category = $post_category[0]; // Set first one as default category. |
| 5418 | 5418 | } |
| 5419 | - $post_category = !empty( $post_category ) ? implode( ',', $post_category ) : ''; |
|
| 5420 | - $post_tags = !empty( $post_tags ) ? implode( ',', $post_tags ) : ''; |
|
| 5419 | + $post_category = !empty($post_category) ? implode(',', $post_category) : '';
|
|
| 5420 | + $post_tags = !empty($post_tags) ? implode(',', $post_tags) : '';
|
|
| 5421 | 5421 | } |
| 5422 | 5422 | |
| 5423 | 5423 | // Franchise data |
| 5424 | - if ($is_franchise_active && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 && geodir_franchise_check((int)$post_info['franchise'])) {
|
|
| 5424 | + if ($is_franchise_active && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 && geodir_franchise_check((int) $post_info['franchise'])) {
|
|
| 5425 | 5425 | $franchise_id = $post_info['franchise']; |
| 5426 | 5426 | $gd_franchise_info = geodir_get_post_info($franchise_id); |
| 5427 | 5427 | |
| 5428 | 5428 | if (geodir_franchise_pkg_is_active($gd_franchise_info)) {
|
| 5429 | - $franchise_info = (array)$gd_franchise_info; |
|
| 5429 | + $franchise_info = (array) $gd_franchise_info; |
|
| 5430 | 5430 | $locked_fields = geodir_franchise_get_locked_fields($franchise_id, true); |
| 5431 | 5431 | |
| 5432 | 5432 | if (!empty($locked_fields)) {
|
| 5433 | - foreach( $locked_fields as $locked_field) {
|
|
| 5433 | + foreach ($locked_fields as $locked_field) {
|
|
| 5434 | 5434 | if (isset($post_info[$locked_field]) && isset($franchise_info[$locked_field])) {
|
| 5435 | 5435 | $post_info[$locked_field] = $franchise_info[$locked_field]; |
| 5436 | 5436 | } |
| 5437 | 5437 | |
| 5438 | 5438 | if (in_array($taxonomy_category, $locked_fields) || in_array('post_tags', $locked_fields)) {
|
| 5439 | - $franchise_terms = wp_get_post_terms( $franchise_id, array( $taxonomy_category, $taxonomy_tags ) ); |
|
| 5439 | + $franchise_terms = wp_get_post_terms($franchise_id, array($taxonomy_category, $taxonomy_tags)); |
|
| 5440 | 5440 | |
| 5441 | - if ( !empty( $franchise_terms ) && !is_wp_error( $franchise_terms ) ) {
|
|
| 5441 | + if (!empty($franchise_terms) && !is_wp_error($franchise_terms)) {
|
|
| 5442 | 5442 | $franchise_post_category = array(); |
| 5443 | 5443 | $franchise_post_tags = array(); |
| 5444 | 5444 | |
| 5445 | - foreach ( $franchise_terms as $franchise_term ) {
|
|
| 5446 | - if ( $franchise_term->taxonomy == $taxonomy_category ) {
|
|
| 5445 | + foreach ($franchise_terms as $franchise_term) {
|
|
| 5446 | + if ($franchise_term->taxonomy == $taxonomy_category) {
|
|
| 5447 | 5447 | $franchise_post_category[] = $franchise_term->name; |
| 5448 | 5448 | } |
| 5449 | 5449 | |
| 5450 | - if ( $franchise_term->taxonomy == $taxonomy_tags ) {
|
|
| 5450 | + if ($franchise_term->taxonomy == $taxonomy_tags) {
|
|
| 5451 | 5451 | $franchise_post_tags[] = $franchise_term->name; |
| 5452 | 5452 | } |
| 5453 | 5453 | } |
| 5454 | 5454 | |
| 5455 | 5455 | if (in_array($taxonomy_category, $locked_fields)) {
|
| 5456 | - $post_category = !empty( $franchise_post_category ) ? implode( ',', $franchise_post_category ) : ''; |
|
| 5456 | + $post_category = !empty($franchise_post_category) ? implode(',', $franchise_post_category) : '';
|
|
| 5457 | 5457 | } |
| 5458 | 5458 | if (in_array('post_tags', $locked_fields)) {
|
| 5459 | - $post_tags = !empty( $franchise_post_tags ) ? implode( ',', $franchise_post_tags ) : ''; |
|
| 5459 | + $post_tags = !empty($franchise_post_tags) ? implode(',', $franchise_post_tags) : '';
|
|
| 5460 | 5460 | } |
| 5461 | 5461 | } |
| 5462 | 5462 | } |
@@ -5465,18 +5465,18 @@ discard block |
||
| 5465 | 5465 | } |
| 5466 | 5466 | } |
| 5467 | 5467 | |
| 5468 | - $post_images = geodir_get_images( $post_id ); |
|
| 5468 | + $post_images = geodir_get_images($post_id); |
|
| 5469 | 5469 | $current_images = array(); |
| 5470 | - if ( !empty( $post_images ) ) {
|
|
| 5471 | - foreach ( $post_images as $post_image ) {
|
|
| 5472 | - $post_image = (array)$post_image; |
|
| 5473 | - $image = !empty( $post_image ) && isset( $post_image['path'] ) && $wp_filesystem->is_file( $post_image['path'] ) && $wp_filesystem->exists( $post_image['path'] ) ? $post_image['src'] : ''; |
|
| 5474 | - if ( $image ) {
|
|
| 5470 | + if (!empty($post_images)) {
|
|
| 5471 | + foreach ($post_images as $post_image) {
|
|
| 5472 | + $post_image = (array) $post_image; |
|
| 5473 | + $image = !empty($post_image) && isset($post_image['path']) && $wp_filesystem->is_file($post_image['path']) && $wp_filesystem->exists($post_image['path']) ? $post_image['src'] : ''; |
|
| 5474 | + if ($image) {
|
|
| 5475 | 5475 | $current_images[] = $image; |
| 5476 | 5476 | } |
| 5477 | 5477 | } |
| 5478 | 5478 | |
| 5479 | - $images_count = max( $images_count, count( $current_images ) ); |
|
| 5479 | + $images_count = max($images_count, count($current_images)); |
|
| 5480 | 5480 | } |
| 5481 | 5481 | |
| 5482 | 5482 | $csv_row = array(); |
@@ -5488,7 +5488,7 @@ discard block |
||
| 5488 | 5488 | $csv_row[] = $default_category; // default_category |
| 5489 | 5489 | $csv_row[] = $post_tags; // post_tags |
| 5490 | 5490 | $csv_row[] = $post_type; // post_type |
| 5491 | - if ( $post_type == 'gd_event' ) {
|
|
| 5491 | + if ($post_type == 'gd_event') {
|
|
| 5492 | 5492 | $event_data = geodir_imex_get_event_data($post, $gd_post_info); |
| 5493 | 5493 | $csv_row[] = $event_data['event_date']; // event_date |
| 5494 | 5494 | $csv_row[] = $event_data['event_enddate']; // enddate |
@@ -5509,9 +5509,9 @@ discard block |
||
| 5509 | 5509 | $csv_row[] = $event_data['recurring_end_date']; // repeat_end |
| 5510 | 5510 | } |
| 5511 | 5511 | $csv_row[] = $post_info['post_status']; // post_status |
| 5512 | - $csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
|
| 5512 | + $csv_row[] = (int) $post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
|
| 5513 | 5513 | if ($is_payment_plugin) {
|
| 5514 | - $csv_row[] = (int)$post_info['package_id']; // package_id |
|
| 5514 | + $csv_row[] = (int) $post_info['package_id']; // package_id |
|
| 5515 | 5515 | $csv_row[] = $post_info['expire_date'] != '' && geodir_strtolower($post_info['expire_date']) != 'never' ? date_i18n('Y-m-d', strtotime($post_info['expire_date'])) : 'Never'; // expire_date
|
| 5516 | 5516 | } |
| 5517 | 5517 | $csv_row[] = $post_info['geodir_video']; // geodir_video |
@@ -5547,14 +5547,14 @@ discard block |
||
| 5547 | 5547 | $csv_row[] = $post_info['geodir_special_offers']; // geodir_special_offers |
| 5548 | 5548 | // WPML |
| 5549 | 5549 | if ($is_wpml) {
|
| 5550 | - $csv_row[] = geodir_get_language_for_element( $post_id, 'post_' . $post_type ); |
|
| 5551 | - $csv_row[] = geodir_imex_original_post_id( $post_id, 'post_' . $post_type ); |
|
| 5550 | + $csv_row[] = geodir_get_language_for_element($post_id, 'post_'.$post_type); |
|
| 5551 | + $csv_row[] = geodir_imex_original_post_id($post_id, 'post_'.$post_type); |
|
| 5552 | 5552 | } |
| 5553 | 5553 | // WPML |
| 5554 | 5554 | |
| 5555 | - if ( !empty( $custom_fields ) ) {
|
|
| 5556 | - foreach ( $custom_fields as $custom_field ) {
|
|
| 5557 | - $csv_row[] = isset( $post_info[$custom_field->htmlvar_name] ) ? $post_info[$custom_field->htmlvar_name] : ''; |
|
| 5555 | + if (!empty($custom_fields)) {
|
|
| 5556 | + foreach ($custom_fields as $custom_field) {
|
|
| 5557 | + $csv_row[] = isset($post_info[$custom_field->htmlvar_name]) ? $post_info[$custom_field->htmlvar_name] : ''; |
|
| 5558 | 5558 | } |
| 5559 | 5559 | } |
| 5560 | 5560 | |
@@ -5565,26 +5565,26 @@ discard block |
||
| 5565 | 5565 | $franchise = ''; |
| 5566 | 5566 | |
| 5567 | 5567 | if (geodir_franchise_pkg_is_active($gd_post_info)) {
|
| 5568 | - $gd_is_franchise = (int)get_post_meta( $post_id, 'gd_is_franchise', true ); |
|
| 5569 | - $locaked_fields = $gd_is_franchise ? get_post_meta( $post_id, 'gd_franchise_lock', true ) : ''; |
|
| 5568 | + $gd_is_franchise = (int) get_post_meta($post_id, 'gd_is_franchise', true); |
|
| 5569 | + $locaked_fields = $gd_is_franchise ? get_post_meta($post_id, 'gd_franchise_lock', true) : ''; |
|
| 5570 | 5570 | $locaked_fields = (is_array($locaked_fields) && !empty($locaked_fields) ? implode(",", $locaked_fields) : '');
|
| 5571 | - $franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 ? (int)$post_info['franchise'] : 0; // franchise id |
|
| 5571 | + $franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 ? (int) $post_info['franchise'] : 0; // franchise id |
|
| 5572 | 5572 | } |
| 5573 | 5573 | |
| 5574 | - $csv_row[] = (int)$gd_is_franchise; // gd_is_franchise |
|
| 5574 | + $csv_row[] = (int) $gd_is_franchise; // gd_is_franchise |
|
| 5575 | 5575 | $csv_row[] = $locaked_fields; // gd_franchise_lock fields |
| 5576 | - $csv_row[] = (int)$franchise; // franchise id |
|
| 5576 | + $csv_row[] = (int) $franchise; // franchise id |
|
| 5577 | 5577 | } |
| 5578 | 5578 | |
| 5579 | - for ( $c = 0; $c < $images_count; $c++ ) {
|
|
| 5580 | - $csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE |
|
| 5579 | + for ($c = 0; $c < $images_count; $c++) {
|
|
| 5580 | + $csv_row[] = isset($current_images[$c]) ? $current_images[$c] : ''; // IMAGE |
|
| 5581 | 5581 | } |
| 5582 | 5582 | |
| 5583 | 5583 | $csv_rows[] = $csv_row; |
| 5584 | 5584 | |
| 5585 | 5585 | } |
| 5586 | 5586 | |
| 5587 | - for ( $c = 0; $c < $images_count; $c++ ) {
|
|
| 5587 | + for ($c = 0; $c < $images_count; $c++) {
|
|
| 5588 | 5588 | $csv_rows[0][] = 'IMAGE'; |
| 5589 | 5589 | } |
| 5590 | 5590 | } |
@@ -5606,33 +5606,33 @@ discard block |
||
| 5606 | 5606 | * @param int $page_no Page number. Default 0. |
| 5607 | 5607 | * @return array Array of posts data. |
| 5608 | 5608 | */ |
| 5609 | -function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
|
| 5609 | +function geodir_get_export_posts($post_type, $per_page = 0, $page_no = 0) {
|
|
| 5610 | 5610 | global $wpdb, $plugin_prefix; |
| 5611 | 5611 | |
| 5612 | - if ( ! post_type_exists( $post_type ) ) |
|
| 5612 | + if (!post_type_exists($post_type)) |
|
| 5613 | 5613 | return new stdClass; |
| 5614 | 5614 | |
| 5615 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5615 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 5616 | 5616 | |
| 5617 | 5617 | $limit = ''; |
| 5618 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 5619 | - $offset = ( $page_no - 1 ) * $per_page; |
|
| 5618 | + if ($per_page > 0 && $page_no > 0) {
|
|
| 5619 | + $offset = ($page_no - 1) * $per_page; |
|
| 5620 | 5620 | |
| 5621 | - if ( $offset > 0 ) {
|
|
| 5622 | - $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 5621 | + if ($offset > 0) {
|
|
| 5622 | + $limit = " LIMIT ".$offset.",".$per_page; |
|
| 5623 | 5623 | } else {
|
| 5624 | - $limit = " LIMIT " . $per_page; |
|
| 5624 | + $limit = " LIMIT ".$per_page; |
|
| 5625 | 5625 | } |
| 5626 | 5626 | } |
| 5627 | 5627 | |
| 5628 | 5628 | // Skip listing with statuses trash, auto-draft etc... |
| 5629 | 5629 | $skip_statuses = geodir_imex_export_skip_statuses(); |
| 5630 | 5630 | $where_statuses = ''; |
| 5631 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5632 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5631 | + if (!empty($skip_statuses) && is_array($skip_statuses)) {
|
|
| 5632 | + $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
|
|
| 5633 | 5633 | } |
| 5634 | 5634 | |
| 5635 | - $query = "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit;
|
|
| 5635 | + $query = "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s ".$where_statuses." ORDER BY {$wpdb->posts}.ID ASC".$limit;
|
|
| 5636 | 5636 | /** |
| 5637 | 5637 | * Modify returned posts SQL query for the current post type. |
| 5638 | 5638 | * |
@@ -5642,9 +5642,9 @@ discard block |
||
| 5642 | 5642 | * @param int $query The SQL query. |
| 5643 | 5643 | * @param string $post_type Post type. |
| 5644 | 5644 | */ |
| 5645 | - $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 5645 | + $query = apply_filters('geodir_imex_export_posts_query', $query, $post_type);
|
|
| 5646 | 5646 | |
| 5647 | - $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 5647 | + $results = (array) $wpdb->get_results($wpdb->prepare($query, $post_type), ARRAY_A); |
|
| 5648 | 5648 | |
| 5649 | 5649 | /** |
| 5650 | 5650 | * Modify returned post results for the current post type. |
@@ -5655,7 +5655,7 @@ discard block |
||
| 5655 | 5655 | * @param object $results An object containing all post ids. |
| 5656 | 5656 | * @param string $post_type Post type. |
| 5657 | 5657 | */ |
| 5658 | - return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 5658 | + return apply_filters('geodir_export_posts', $results, $post_type);
|
|
| 5659 | 5659 | } |
| 5660 | 5660 | |
| 5661 | 5661 | /** |
@@ -5672,21 +5672,21 @@ discard block |
||
| 5672 | 5672 | * @param string $post_type Post type. |
| 5673 | 5673 | * @return string The SQL query. |
| 5674 | 5674 | */ |
| 5675 | -function geodir_imex_get_events_query( $query, $post_type ) {
|
|
| 5676 | - if ( $post_type == 'gd_event' ) {
|
|
| 5675 | +function geodir_imex_get_events_query($query, $post_type) {
|
|
| 5676 | + if ($post_type == 'gd_event') {
|
|
| 5677 | 5677 | global $wpdb, $plugin_prefix; |
| 5678 | 5678 | |
| 5679 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5679 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 5680 | 5680 | $schedule_table = EVENT_SCHEDULE; |
| 5681 | 5681 | |
| 5682 | 5682 | // Skip listing with statuses trash, auto-draft etc... |
| 5683 | 5683 | $skip_statuses = geodir_imex_export_skip_statuses(); |
| 5684 | 5684 | $where_statuses = ''; |
| 5685 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5686 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5685 | + if (!empty($skip_statuses) && is_array($skip_statuses)) {
|
|
| 5686 | + $where_statuses = "AND `".$wpdb->posts."`.`post_status` NOT IN('".implode("','", $skip_statuses)."')";
|
|
| 5687 | 5687 | } |
| 5688 | 5688 | |
| 5689 | - $query = "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC";
|
|
| 5689 | + $query = "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s ".$where_statuses." GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC";
|
|
| 5690 | 5690 | } |
| 5691 | 5691 | |
| 5692 | 5692 | return $query; |
@@ -5710,35 +5710,35 @@ discard block |
||
| 5710 | 5710 | * @param string $post_type Post type. |
| 5711 | 5711 | * @return int Total terms count. |
| 5712 | 5712 | */ |
| 5713 | -function geodir_get_terms_count( $post_type ) {
|
|
| 5714 | - $args = array( 'hide_empty' => 0 ); |
|
| 5713 | +function geodir_get_terms_count($post_type) {
|
|
| 5714 | + $args = array('hide_empty' => 0);
|
|
| 5715 | 5715 | |
| 5716 | - remove_all_filters( 'get_terms' ); |
|
| 5716 | + remove_all_filters('get_terms');
|
|
| 5717 | 5717 | |
| 5718 | - $taxonomy = $post_type . 'category'; |
|
| 5718 | + $taxonomy = $post_type.'category'; |
|
| 5719 | 5719 | |
| 5720 | 5720 | // WPML |
| 5721 | 5721 | $is_wpml = geodir_is_wpml(); |
| 5722 | 5722 | $active_lang = 'all'; |
| 5723 | - if ( $is_wpml ) {
|
|
| 5723 | + if ($is_wpml) {
|
|
| 5724 | 5724 | global $sitepress; |
| 5725 | 5725 | $active_lang = $sitepress->get_current_language(); |
| 5726 | 5726 | |
| 5727 | - if ( $active_lang != 'all' ) {
|
|
| 5728 | - $sitepress->switch_lang( 'all', true ); |
|
| 5727 | + if ($active_lang != 'all') {
|
|
| 5728 | + $sitepress->switch_lang('all', true);
|
|
| 5729 | 5729 | } |
| 5730 | 5730 | } |
| 5731 | 5731 | // WPML |
| 5732 | 5732 | |
| 5733 | - $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 5733 | + $count_terms = wp_count_terms($taxonomy, $args); |
|
| 5734 | 5734 | |
| 5735 | 5735 | // WPML |
| 5736 | - if ( $is_wpml && $active_lang !== 'all' ) {
|
|
| 5736 | + if ($is_wpml && $active_lang !== 'all') {
|
|
| 5737 | 5737 | global $sitepress; |
| 5738 | - $sitepress->switch_lang( $active_lang, true ); |
|
| 5738 | + $sitepress->switch_lang($active_lang, true); |
|
| 5739 | 5739 | } |
| 5740 | 5740 | // WPML |
| 5741 | - $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 5741 | + $count_terms = !is_wp_error($count_terms) ? $count_terms : 0; |
|
| 5742 | 5742 | |
| 5743 | 5743 | return $count_terms; |
| 5744 | 5744 | } |
@@ -5755,23 +5755,23 @@ discard block |
||
| 5755 | 5755 | * @param int $page_no Page number. Default 0. |
| 5756 | 5756 | * @return array Array of terms data. |
| 5757 | 5757 | */ |
| 5758 | -function geodir_imex_get_terms( $post_type, $per_page = 0, $page_no = 0 ) {
|
|
| 5759 | - $args = array( 'hide_empty' => 0, 'orderby' => 'id' ); |
|
| 5758 | +function geodir_imex_get_terms($post_type, $per_page = 0, $page_no = 0) {
|
|
| 5759 | + $args = array('hide_empty' => 0, 'orderby' => 'id');
|
|
| 5760 | 5760 | |
| 5761 | - remove_all_filters( 'get_terms' ); |
|
| 5761 | + remove_all_filters('get_terms');
|
|
| 5762 | 5762 | |
| 5763 | - $taxonomy = $post_type . 'category'; |
|
| 5763 | + $taxonomy = $post_type.'category'; |
|
| 5764 | 5764 | |
| 5765 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 5766 | - $args['offset'] = ( $page_no - 1 ) * $per_page; |
|
| 5765 | + if ($per_page > 0 && $page_no > 0) {
|
|
| 5766 | + $args['offset'] = ($page_no - 1) * $per_page; |
|
| 5767 | 5767 | $args['number'] = $per_page; |
| 5768 | 5768 | } |
| 5769 | 5769 | |
| 5770 | - $terms = get_terms( $taxonomy, $args ); |
|
| 5770 | + $terms = get_terms($taxonomy, $args); |
|
| 5771 | 5771 | |
| 5772 | 5772 | $csv_rows = array(); |
| 5773 | 5773 | |
| 5774 | - if ( !empty( $terms ) ) {
|
|
| 5774 | + if (!empty($terms)) {
|
|
| 5775 | 5775 | $csv_row = array(); |
| 5776 | 5776 | $csv_row[] = 'cat_id'; |
| 5777 | 5777 | $csv_row[] = 'cat_name'; |
@@ -5793,16 +5793,16 @@ discard block |
||
| 5793 | 5793 | |
| 5794 | 5794 | $csv_rows[] = $csv_row; |
| 5795 | 5795 | |
| 5796 | - foreach ( $terms as $term ) {
|
|
| 5797 | - $cat_icon = get_tax_meta( $term->term_id, 'ct_cat_icon', false, $post_type ); |
|
| 5798 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 5796 | + foreach ($terms as $term) {
|
|
| 5797 | + $cat_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $post_type); |
|
| 5798 | + $cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : ''; |
|
| 5799 | 5799 | |
| 5800 | - $cat_image = geodir_get_default_catimage( $term->term_id, $post_type ); |
|
| 5801 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 5800 | + $cat_image = geodir_get_default_catimage($term->term_id, $post_type); |
|
| 5801 | + $cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : ''; |
|
| 5802 | 5802 | |
| 5803 | 5803 | $cat_parent = ''; |
| 5804 | - if (isset($term->parent) && (int)$term->parent > 0 && term_exists((int)$term->parent, $taxonomy)) {
|
|
| 5805 | - $parent_term = (array)get_term_by( 'id', (int)$term->parent, $taxonomy ); |
|
| 5804 | + if (isset($term->parent) && (int) $term->parent > 0 && term_exists((int) $term->parent, $taxonomy)) {
|
|
| 5805 | + $parent_term = (array) get_term_by('id', (int) $term->parent, $taxonomy);
|
|
| 5806 | 5806 | $cat_parent = !empty($parent_term) && isset($parent_term['name']) ? $parent_term['name'] : ''; |
| 5807 | 5807 | } |
| 5808 | 5808 | |
@@ -5812,15 +5812,15 @@ discard block |
||
| 5812 | 5812 | $csv_row[] = $term->slug; |
| 5813 | 5813 | $csv_row[] = $post_type; |
| 5814 | 5814 | $csv_row[] = $cat_parent; |
| 5815 | - $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); |
|
| 5815 | + $csv_row[] = get_tax_meta($term->term_id, 'ct_cat_schema', false, $post_type); |
|
| 5816 | 5816 | // WPML |
| 5817 | 5817 | if ($is_wpml) {
|
| 5818 | - $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); |
|
| 5819 | - $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
| 5818 | + $csv_row[] = geodir_get_language_for_element($term->term_id, 'tax_'.$taxonomy); |
|
| 5819 | + $csv_row[] = geodir_imex_original_post_id($term->term_id, 'tax_'.$taxonomy); |
|
| 5820 | 5820 | } |
| 5821 | 5821 | // WPML |
| 5822 | 5822 | $csv_row[] = $term->description; |
| 5823 | - $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_top_desc', false, $post_type ); |
|
| 5823 | + $csv_row[] = get_tax_meta($term->term_id, 'ct_cat_top_desc', false, $post_type); |
|
| 5824 | 5824 | $csv_row[] = $cat_image; |
| 5825 | 5825 | $csv_row[] = $cat_icon; |
| 5826 | 5826 | |
@@ -5839,10 +5839,10 @@ discard block |
||
| 5839 | 5839 | * @param bool $relative True for relative path & False for absolute path. |
| 5840 | 5840 | * @return string Path to the cache directory. |
| 5841 | 5841 | */ |
| 5842 | -function geodir_path_import_export( $relative = true ) {
|
|
| 5842 | +function geodir_path_import_export($relative = true) {
|
|
| 5843 | 5843 | $upload_dir = wp_upload_dir(); |
| 5844 | 5844 | |
| 5845 | - return $relative ? $upload_dir['baseurl'] . '/cache' : $upload_dir['basedir'] . '/cache'; |
|
| 5845 | + return $relative ? $upload_dir['baseurl'].'/cache' : $upload_dir['basedir'].'/cache'; |
|
| 5846 | 5846 | } |
| 5847 | 5847 | |
| 5848 | 5848 | /** |
@@ -5858,8 +5858,8 @@ discard block |
||
| 5858 | 5858 | * @param bool $clear If true then it overwrite data otherwise add rows at the end of file. |
| 5859 | 5859 | * @return bool true if success otherwise false. |
| 5860 | 5860 | */ |
| 5861 | -function geodir_save_csv_data( $file_path, $csv_data = array(), $clear = true ) {
|
|
| 5862 | - if ( empty( $csv_data ) ) {
|
|
| 5861 | +function geodir_save_csv_data($file_path, $csv_data = array(), $clear = true) {
|
|
| 5862 | + if (empty($csv_data)) {
|
|
| 5863 | 5863 | return false; |
| 5864 | 5864 | } |
| 5865 | 5865 | |
@@ -5867,17 +5867,17 @@ discard block |
||
| 5867 | 5867 | |
| 5868 | 5868 | $mode = $clear ? 'w+' : 'a+'; |
| 5869 | 5869 | |
| 5870 | - if ( function_exists( 'fputcsv' ) ) {
|
|
| 5871 | - $file = fopen( $file_path, $mode ); |
|
| 5872 | - foreach( $csv_data as $csv_row ) {
|
|
| 5870 | + if (function_exists('fputcsv')) {
|
|
| 5871 | + $file = fopen($file_path, $mode); |
|
| 5872 | + foreach ($csv_data as $csv_row) {
|
|
| 5873 | 5873 | //$csv_row = array_map( 'utf8_decode', $csv_row ); |
| 5874 | - $write_successful = fputcsv( $file, $csv_row, ",", $enclosure = '"' ); |
|
| 5874 | + $write_successful = fputcsv($file, $csv_row, ",", $enclosure = '"'); |
|
| 5875 | 5875 | } |
| 5876 | - fclose( $file ); |
|
| 5876 | + fclose($file); |
|
| 5877 | 5877 | } else {
|
| 5878 | - foreach( $csv_data as $csv_row ) {
|
|
| 5878 | + foreach ($csv_data as $csv_row) {
|
|
| 5879 | 5879 | //$csv_row = array_map( 'utf8_decode', $csv_row ); |
| 5880 | - $wp_filesystem->put_contents( $file_path, $csv_row ); |
|
| 5880 | + $wp_filesystem->put_contents($file_path, $csv_row); |
|
| 5881 | 5881 | } |
| 5882 | 5882 | } |
| 5883 | 5883 | |
@@ -5895,14 +5895,14 @@ discard block |
||
| 5895 | 5895 | * @param string $file Full path to file. |
| 5896 | 5896 | * @return int No of file rows. |
| 5897 | 5897 | */ |
| 5898 | -function geodir_import_export_line_count( $file ) {
|
|
| 5898 | +function geodir_import_export_line_count($file) {
|
|
| 5899 | 5899 | global $wp_filesystem; |
| 5900 | 5900 | |
| 5901 | - if ( $wp_filesystem->is_file( $file ) && $wp_filesystem->exists( $file ) ) {
|
|
| 5902 | - $contents = $wp_filesystem->get_contents_array( $file ); |
|
| 5901 | + if ($wp_filesystem->is_file($file) && $wp_filesystem->exists($file)) {
|
|
| 5902 | + $contents = $wp_filesystem->get_contents_array($file); |
|
| 5903 | 5903 | |
| 5904 | - if ( !empty( $contents ) && is_array( $contents ) ) {
|
|
| 5905 | - return count( $contents ) - 1; |
|
| 5904 | + if (!empty($contents) && is_array($contents)) {
|
|
| 5905 | + return count($contents) - 1; |
|
| 5906 | 5906 | } |
| 5907 | 5907 | } |
| 5908 | 5908 | |
@@ -5919,11 +5919,11 @@ discard block |
||
| 5919 | 5919 | * @param string $post_type The post type. |
| 5920 | 5920 | * @return object Queried object. |
| 5921 | 5921 | */ |
| 5922 | -function geodir_imex_get_custom_fields( $post_type ) {
|
|
| 5922 | +function geodir_imex_get_custom_fields($post_type) {
|
|
| 5923 | 5923 | global $wpdb; |
| 5924 | 5924 | |
| 5925 | - $sql = $wpdb->prepare("SELECT htmlvar_name FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1' AND is_admin!='1' AND field_type != 'fieldset' AND htmlvar_name != '' ORDER BY id ASC", array( $post_type ) );
|
|
| 5926 | - $rows = $wpdb->get_results( $sql ); |
|
| 5925 | + $sql = $wpdb->prepare("SELECT htmlvar_name FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type=%s AND is_active='1' AND is_admin!='1' AND field_type != 'fieldset' AND htmlvar_name != '' ORDER BY id ASC", array($post_type));
|
|
| 5926 | + $rows = $wpdb->get_results($sql); |
|
| 5927 | 5927 | |
| 5928 | 5928 | return $rows; |
| 5929 | 5929 | } |
@@ -6002,14 +6002,14 @@ discard block |
||
| 6002 | 6002 | global $wpdb, $plugin_prefix; |
| 6003 | 6003 | |
| 6004 | 6004 | $post_type = get_post_type($master_post_id); |
| 6005 | - $post_table = $plugin_prefix . $post_type . '_detail'; |
|
| 6005 | + $post_table = $plugin_prefix.$post_type.'_detail'; |
|
| 6006 | 6006 | |
| 6007 | - $query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
|
|
| 6008 | - $data = (array)$wpdb->get_row($query); |
|
| 6007 | + $query = $wpdb->prepare("SELECT * FROM ".$post_table." WHERE post_id = %d", array($master_post_id));
|
|
| 6008 | + $data = (array) $wpdb->get_row($query); |
|
| 6009 | 6009 | |
| 6010 | - if ( !empty( $data ) ) {
|
|
| 6010 | + if (!empty($data)) {
|
|
| 6011 | 6011 | $data['post_id'] = $tr_post_id; |
| 6012 | - unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']); |
|
| 6012 | + unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type.'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']); |
|
| 6013 | 6013 | |
| 6014 | 6014 | $wpdb->update($post_table, $data, array('post_id' => $tr_post_id));
|
| 6015 | 6015 | return true; |
@@ -6035,7 +6035,7 @@ discard block |
||
| 6035 | 6035 | global $sitepress, $wpdb; |
| 6036 | 6036 | $post_type = get_post_type($master_post_id); |
| 6037 | 6037 | |
| 6038 | - remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
|
|
| 6038 | + remove_filter('get_term', array($sitepress, 'get_term_adjust_id')); // AVOID filtering to current language
|
|
| 6039 | 6039 | |
| 6040 | 6040 | $taxonomies = get_object_taxonomies($post_type); |
| 6041 | 6041 | foreach ($taxonomies as $taxonomy) {
|
@@ -6044,9 +6044,9 @@ discard block |
||
| 6044 | 6044 | |
| 6045 | 6045 | if ($terms) {
|
| 6046 | 6046 | foreach ($terms as $term) {
|
| 6047 | - $tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang); |
|
| 6047 | + $tr_id = apply_filters('translate_object_id', $term->term_id, $taxonomy, false, $lang);
|
|
| 6048 | 6048 | |
| 6049 | - if (!is_null($tr_id)){
|
|
| 6049 | + if (!is_null($tr_id)) {
|
|
| 6050 | 6050 | // not using get_term - unfiltered get_term |
| 6051 | 6051 | $translated_term = $wpdb->get_row($wpdb->prepare("
|
| 6052 | 6052 | SELECT * FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_id, $taxonomy));
|
@@ -6055,14 +6055,14 @@ discard block |
||
| 6055 | 6055 | } |
| 6056 | 6056 | } |
| 6057 | 6057 | |
| 6058 | - if (!is_taxonomy_hierarchical($taxonomy)){
|
|
| 6059 | - $terms_array = array_unique( array_map( 'intval', $terms_array ) ); |
|
| 6058 | + if (!is_taxonomy_hierarchical($taxonomy)) {
|
|
| 6059 | + $terms_array = array_unique(array_map('intval', $terms_array));
|
|
| 6060 | 6060 | } |
| 6061 | 6061 | |
| 6062 | 6062 | wp_set_post_terms($tr_post_id, $terms_array, $taxonomy); |
| 6063 | 6063 | |
| 6064 | - if ($taxonomy == $post_type . 'category') {
|
|
| 6065 | - geodir_set_postcat_structure($tr_post_id, $post_type . 'category'); |
|
| 6064 | + if ($taxonomy == $post_type.'category') {
|
|
| 6065 | + geodir_set_postcat_structure($tr_post_id, $post_type.'category'); |
|
| 6066 | 6066 | } |
| 6067 | 6067 | } |
| 6068 | 6068 | } |
@@ -6083,15 +6083,15 @@ discard block |
||
| 6083 | 6083 | function geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang) {
|
| 6084 | 6084 | global $wpdb; |
| 6085 | 6085 | |
| 6086 | - $query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
|
|
| 6086 | + $query = $wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
|
|
| 6087 | 6087 | $wpdb->query($query); |
| 6088 | 6088 | |
| 6089 | - $query = $wpdb->prepare("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
|
|
| 6089 | + $query = $wpdb->prepare("SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
|
|
| 6090 | 6090 | $post_images = $wpdb->get_results($query); |
| 6091 | 6091 | |
| 6092 | - if ( !empty( $post_images ) ) {
|
|
| 6093 | - foreach ( $post_images as $post_image) {
|
|
| 6094 | - $image_data = (array)$post_image; |
|
| 6092 | + if (!empty($post_images)) {
|
|
| 6093 | + foreach ($post_images as $post_image) {
|
|
| 6094 | + $image_data = (array) $post_image; |
|
| 6095 | 6095 | unset($image_data['ID']); |
| 6096 | 6096 | $image_data['post_id'] = $tr_post_id; |
| 6097 | 6097 | |
@@ -6117,10 +6117,10 @@ discard block |
||
| 6117 | 6117 | * @return array Event data array. |
| 6118 | 6118 | */ |
| 6119 | 6119 | function geodir_imex_get_event_data($post, $gd_post_info) {
|
| 6120 | - $event_date = isset( $post['event_date'] ) && $post['event_date'] != '' && $post['event_date'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $post['event_date'] ) ) : ''; |
|
| 6120 | + $event_date = isset($post['event_date']) && $post['event_date'] != '' && $post['event_date'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($post['event_date'])) : '';
|
|
| 6121 | 6121 | $event_enddate = $event_date; |
| 6122 | - $starttime = isset( $post['starttime'] ) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['starttime'] ) ) : ''; |
|
| 6123 | - $endtime = isset( $post['endtime'] ) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['endtime'] ) ) : ''; |
|
| 6122 | + $starttime = isset($post['starttime']) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['starttime'])) : '';
|
|
| 6123 | + $endtime = isset($post['endtime']) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['endtime'])) : '';
|
|
| 6124 | 6124 | |
| 6125 | 6125 | $is_recurring_event = ''; |
| 6126 | 6126 | $event_duration_days = ''; |
@@ -6137,15 +6137,15 @@ discard block |
||
| 6137 | 6137 | |
| 6138 | 6138 | $recurring_data = isset($gd_post_info->recurring_dates) ? maybe_unserialize($gd_post_info->recurring_dates) : array(); |
| 6139 | 6139 | if (!empty($recurring_data)) {
|
| 6140 | - $event_date = isset( $recurring_data['event_start'] ) && $recurring_data['event_start'] != '' && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_start'] ) ) : $event_date; |
|
| 6141 | - $event_enddate = isset( $recurring_data['event_end'] ) && $recurring_data['event_end'] != '' && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_end'] ) ) : $event_date; |
|
| 6142 | - $starttime = isset( $recurring_data['starttime'] ) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['starttime'] ) ) : $starttime; |
|
| 6143 | - $endtime = isset( $recurring_data['endtime'] ) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['endtime'] ) ) : $endtime; |
|
| 6140 | + $event_date = isset($recurring_data['event_start']) && $recurring_data['event_start'] != '' && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['event_start'])) : $event_date;
|
|
| 6141 | + $event_enddate = isset($recurring_data['event_end']) && $recurring_data['event_end'] != '' && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['event_end'])) : $event_date;
|
|
| 6142 | + $starttime = isset($recurring_data['starttime']) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['starttime'])) : $starttime;
|
|
| 6143 | + $endtime = isset($recurring_data['endtime']) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['endtime'])) : $endtime;
|
|
| 6144 | 6144 | $is_whole_day_event = !empty($recurring_data['all_day']) ? 1 : ''; |
| 6145 | 6145 | $different_times = !empty($recurring_data['different_times']) ? true : false; |
| 6146 | 6146 | |
| 6147 | - $recurring_pkg = geodir_event_recurring_pkg( $gd_post_info ); |
|
| 6148 | - $is_recurring = isset( $gd_post_info->is_recurring ) && (int)$gd_post_info->is_recurring == 0 ? false : true; |
|
| 6147 | + $recurring_pkg = geodir_event_recurring_pkg($gd_post_info); |
|
| 6148 | + $is_recurring = isset($gd_post_info->is_recurring) && (int) $gd_post_info->is_recurring == 0 ? false : true; |
|
| 6149 | 6149 | |
| 6150 | 6150 | if ($recurring_pkg && $is_recurring) {
|
| 6151 | 6151 | $recurring_dates = $event_date; |
@@ -6155,13 +6155,13 @@ discard block |
||
| 6155 | 6155 | $recurring_type = !empty($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'custom';
|
| 6156 | 6156 | |
| 6157 | 6157 | if (!empty($recurring_data['event_recurring_dates'])) {
|
| 6158 | - $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] ); |
|
| 6158 | + $event_recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
|
|
| 6159 | 6159 | |
| 6160 | 6160 | if (!empty($event_recurring_dates)) {
|
| 6161 | 6161 | $recurring_dates = array(); |
| 6162 | 6162 | |
| 6163 | 6163 | foreach ($event_recurring_dates as $date) {
|
| 6164 | - $recurring_dates[] = date_i18n( 'd/m/Y', strtotime( $date ) ); |
|
| 6164 | + $recurring_dates[] = date_i18n('d/m/Y', strtotime($date));
|
|
| 6165 | 6165 | } |
| 6166 | 6166 | |
| 6167 | 6167 | $recurring_dates = implode(",", $recurring_dates);
|
@@ -6177,7 +6177,7 @@ discard block |
||
| 6177 | 6177 | $times = array(); |
| 6178 | 6178 | |
| 6179 | 6179 | foreach ($recurring_data['starttimes'] as $time) {
|
| 6180 | - $times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00'; |
|
| 6180 | + $times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
|
|
| 6181 | 6181 | } |
| 6182 | 6182 | |
| 6183 | 6183 | $event_starttimes = implode(",", $times);
|
@@ -6187,7 +6187,7 @@ discard block |
||
| 6187 | 6187 | $times = array(); |
| 6188 | 6188 | |
| 6189 | 6189 | foreach ($recurring_data['endtimes'] as $time) {
|
| 6190 | - $times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00'; |
|
| 6190 | + $times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
|
|
| 6191 | 6191 | } |
| 6192 | 6192 | |
| 6193 | 6193 | $event_endtimes = implode(",", $times);
|
@@ -6199,8 +6199,8 @@ discard block |
||
| 6199 | 6199 | } |
| 6200 | 6200 | } |
| 6201 | 6201 | } else {
|
| 6202 | - $event_duration_days = isset($recurring_data['duration_x']) ? (int)$recurring_data['duration_x'] : 1; |
|
| 6203 | - $recurring_interval = !empty($recurring_data['repeat_x']) && (int)$recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1; |
|
| 6202 | + $event_duration_days = isset($recurring_data['duration_x']) ? (int) $recurring_data['duration_x'] : 1; |
|
| 6203 | + $recurring_interval = !empty($recurring_data['repeat_x']) && (int) $recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1; |
|
| 6204 | 6204 | |
| 6205 | 6205 | if (($recurring_type == 'week' || $recurring_type == 'month') && !empty($recurring_data['repeat_days'])) {
|
| 6206 | 6206 | $week_days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
|
@@ -6216,11 +6216,11 @@ discard block |
||
| 6216 | 6216 | } |
| 6217 | 6217 | |
| 6218 | 6218 | $recurring_week_nos = $recurring_type == 'month' && !empty($recurring_data['repeat_weeks']) ? implode(",", $recurring_data['repeat_weeks']) : $recurring_week_nos;
|
| 6219 | - if (!empty($recurring_data['repeat_end_type']) && (int)$recurring_data['repeat_end_type'] == 1) {
|
|
| 6220 | - $recurring_end_date = isset($recurring_data['repeat_end']) && $recurring_data['repeat_end'] != '' && $recurring_data['repeat_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['repeat_end'] ) ) : ''; |
|
| 6219 | + if (!empty($recurring_data['repeat_end_type']) && (int) $recurring_data['repeat_end_type'] == 1) {
|
|
| 6220 | + $recurring_end_date = isset($recurring_data['repeat_end']) && $recurring_data['repeat_end'] != '' && $recurring_data['repeat_end'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['repeat_end'])) : '';
|
|
| 6221 | 6221 | $max_recurring_count = empty($recurring_end_date) ? 1 : ''; |
| 6222 | 6222 | } else {
|
| 6223 | - $max_recurring_count = (!empty($recurring_data['max_repeat']) && (int)$recurring_data['max_repeat'] > 0 ? (int)$recurring_data['max_repeat'] : 1); |
|
| 6223 | + $max_recurring_count = (!empty($recurring_data['max_repeat']) && (int) $recurring_data['max_repeat'] > 0 ? (int) $recurring_data['max_repeat'] : 1); |
|
| 6224 | 6224 | } |
| 6225 | 6225 | } |
| 6226 | 6226 | } |
@@ -6284,9 +6284,9 @@ discard block |
||
| 6284 | 6284 | * @return array Event data array. |
| 6285 | 6285 | */ |
| 6286 | 6286 | function geodir_imex_process_event_data($gd_post) {
|
| 6287 | - $recurring_pkg = geodir_event_recurring_pkg( (object)$gd_post ); |
|
| 6287 | + $recurring_pkg = geodir_event_recurring_pkg((object) $gd_post); |
|
| 6288 | 6288 | |
| 6289 | - $is_recurring = isset( $gd_post['is_recurring_event'] ) && (int)$gd_post['is_recurring_event'] == 0 ? false : true; |
|
| 6289 | + $is_recurring = isset($gd_post['is_recurring_event']) && (int) $gd_post['is_recurring_event'] == 0 ? false : true; |
|
| 6290 | 6290 | $event_date = isset($gd_post['event_date']) && $gd_post['event_date'] != '' ? geodir_imex_get_date_ymd($gd_post['event_date']) : ''; |
| 6291 | 6291 | $event_enddate = isset($gd_post['event_enddate']) && $gd_post['event_enddate'] != '' ? geodir_imex_get_date_ymd($gd_post['event_enddate']) : $event_date; |
| 6292 | 6292 | $all_day = isset($gd_post['is_whole_day_event']) && !empty($gd_post['is_whole_day_event']) ? true : false; |
@@ -6333,17 +6333,17 @@ discard block |
||
| 6333 | 6333 | $event_recurring_dates = implode(",", $event_recurring_dates);
|
| 6334 | 6334 | } |
| 6335 | 6335 | } else {
|
| 6336 | - $duration_x = !empty( $gd_post['event_duration_days'] ) ? (int)$gd_post['event_duration_days'] : 1; |
|
| 6337 | - $repeat_x = !empty( $gd_post['recurring_interval'] ) ? (int)$gd_post['recurring_interval'] : 1; |
|
| 6338 | - $max_repeat = !empty( $gd_post['max_recurring_count'] ) ? (int)$gd_post['max_recurring_count'] : 1; |
|
| 6339 | - $repeat_end = !empty( $gd_post['recurring_end_date'] ) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : ''; |
|
| 6336 | + $duration_x = !empty($gd_post['event_duration_days']) ? (int) $gd_post['event_duration_days'] : 1; |
|
| 6337 | + $repeat_x = !empty($gd_post['recurring_interval']) ? (int) $gd_post['recurring_interval'] : 1; |
|
| 6338 | + $max_repeat = !empty($gd_post['max_recurring_count']) ? (int) $gd_post['max_recurring_count'] : 1; |
|
| 6339 | + $repeat_end = !empty($gd_post['recurring_end_date']) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : ''; |
|
| 6340 | 6340 | |
| 6341 | 6341 | $repeat_end_type = $repeat_end != '' ? 1 : 0; |
| 6342 | 6342 | $max_repeat = $repeat_end != '' ? '' : $max_repeat; |
| 6343 | 6343 | |
| 6344 | 6344 | $week_days = array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'));
|
| 6345 | 6345 | |
| 6346 | - $a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days'])!='' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
|
|
| 6346 | + $a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days']) != '' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
|
|
| 6347 | 6347 | $repeat_days = array(); |
| 6348 | 6348 | if (!empty($a_repeat_days)) {
|
| 6349 | 6349 | foreach ($a_repeat_days as $repeat_day) {
|
@@ -6361,7 +6361,7 @@ discard block |
||
| 6361 | 6361 | $repeat_weeks = array(); |
| 6362 | 6362 | if (!empty($a_repeat_weeks)) {
|
| 6363 | 6363 | foreach ($a_repeat_weeks as $repeat_week) {
|
| 6364 | - $repeat_weeks[] = (int)$repeat_week; |
|
| 6364 | + $repeat_weeks[] = (int) $repeat_week; |
|
| 6365 | 6365 | } |
| 6366 | 6366 | |
| 6367 | 6367 | $repeat_weeks = array_unique($repeat_weeks); |
@@ -6425,7 +6425,7 @@ discard block |
||
| 6425 | 6425 | |
| 6426 | 6426 | $page_found = $wpdb->get_var( |
| 6427 | 6427 | $wpdb->prepare( |
| 6428 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 6428 | + "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;", |
|
| 6429 | 6429 | array($slug) |
| 6430 | 6430 | ) |
| 6431 | 6431 | ); |
@@ -6480,7 +6480,7 @@ discard block |
||
| 6480 | 6480 | */ |
| 6481 | 6481 | function geodir_admin_upgrade_notice() {
|
| 6482 | 6482 | $class = "error"; |
| 6483 | - $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 6483 | + $message = __("Please update core GeoDirectory or some addons may not function correctly.", "geodirectory");
|
|
| 6484 | 6484 | echo"<div class=\"$class\"> <p>$message</p></div>"; |
| 6485 | 6485 | } |
| 6486 | 6486 | |
@@ -6492,7 +6492,7 @@ discard block |
||
| 6492 | 6492 | * @param (object) $r |
| 6493 | 6493 | * @return (string) $output |
| 6494 | 6494 | */ |
| 6495 | -function geodire_admin_upgrade_notice( $plugin_data, $r ) |
|
| 6495 | +function geodire_admin_upgrade_notice($plugin_data, $r) |
|
| 6496 | 6496 | {
|
| 6497 | 6497 | // readme contents |
| 6498 | 6498 | $args = array( |
@@ -6500,7 +6500,7 @@ discard block |
||
| 6500 | 6500 | 'redirection' => 5 |
| 6501 | 6501 | ); |
| 6502 | 6502 | $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
| 6503 | - $data = wp_remote_get( $url, $args ); |
|
| 6503 | + $data = wp_remote_get($url, $args); |
|
| 6504 | 6504 | |
| 6505 | 6505 | if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
| 6506 | 6506 | |
@@ -6515,20 +6515,20 @@ discard block |
||
| 6515 | 6515 | function geodir_in_plugin_update_message($content) {
|
| 6516 | 6516 | // Output Upgrade Notice |
| 6517 | 6517 | $matches = null; |
| 6518 | - $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 6518 | + $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*'.preg_quote(GEODIRECTORY_VERSION).'\s*=|$)~Uis'; |
|
| 6519 | 6519 | $upgrade_notice = ''; |
| 6520 | - if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 6521 | - if(empty($matches)){return;}
|
|
| 6520 | + if (preg_match($regexp, $content, $matches)) {
|
|
| 6521 | + if (empty($matches)) {return; }
|
|
| 6522 | 6522 | |
| 6523 | - $version = trim( $matches[1] ); |
|
| 6524 | - if($version && $version>GEODIRECTORY_VERSION){
|
|
| 6523 | + $version = trim($matches[1]); |
|
| 6524 | + if ($version && $version > GEODIRECTORY_VERSION) {
|
|
| 6525 | 6525 | |
| 6526 | 6526 | |
| 6527 | - $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 6528 | - if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
|
|
| 6527 | + $notices = (array) preg_split('~[\r\n]+~', trim($matches[2]));
|
|
| 6528 | + if (version_compare(GEODIRECTORY_VERSION, $version, '<')) {
|
|
| 6529 | 6529 | $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
| 6530 | - foreach ( $notices as $index => $line ) {
|
|
| 6531 | - $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 6530 | + foreach ($notices as $index => $line) {
|
|
| 6531 | + $upgrade_notice .= wp_kses_post(preg_replace('~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line));
|
|
| 6532 | 6532 | } |
| 6533 | 6533 | $upgrade_notice .= '</div> '; |
| 6534 | 6534 | } |
@@ -6552,7 +6552,7 @@ discard block |
||
| 6552 | 6552 | $default_language = $sitepress->get_default_language(); |
| 6553 | 6553 | if ($current_language != 'all' && $current_language != $default_language) {
|
| 6554 | 6554 | ?> |
| 6555 | - <div class="updated error notice-success" id="message"><p style="color:red"><strong><?php _e('Saving GeoDirectory pages settings on a different language breaks pages settings. Try to save after switching to default language.', 'geodirectory');?></strong></p></div>
|
|
| 6555 | + <div class="updated error notice-success" id="message"><p style="color:red"><strong><?php _e('Saving GeoDirectory pages settings on a different language breaks pages settings. Try to save after switching to default language.', 'geodirectory'); ?></strong></p></div>
|
|
| 6556 | 6556 | <?php |
| 6557 | 6557 | } |
| 6558 | 6558 | } |
@@ -6567,7 +6567,7 @@ discard block |
||
| 6567 | 6567 | * @param array Listing statuses to be skipped. |
| 6568 | 6568 | */ |
| 6569 | 6569 | function geodir_imex_export_skip_statuses() {
|
| 6570 | - $statuses = array( 'trash', 'auto-draft' ); |
|
| 6570 | + $statuses = array('trash', 'auto-draft');
|
|
| 6571 | 6571 | |
| 6572 | 6572 | /** |
| 6573 | 6573 | * Filter the statuses to skip during GD export listings. |
@@ -6577,7 +6577,7 @@ discard block |
||
| 6577 | 6577 | * |
| 6578 | 6578 | * @param array $statuses Listing statuses to be skipped. |
| 6579 | 6579 | */ |
| 6580 | - $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
| 6580 | + $statuses = apply_filters('geodir_imex_export_skip_statuses', $statuses);
|
|
| 6581 | 6581 | |
| 6582 | 6582 | return $statuses; |
| 6583 | 6583 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | function geodir_get_ajax_url() |
| 21 | 21 | {
|
| 22 | - return admin_url('admin-ajax.php?action=geodir_ajax_action');
|
|
| 22 | + return admin_url('admin-ajax.php?action=geodir_ajax_action');
|
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | ///////////////////// |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | add_filter('query_vars', 'geodir_add_geodir_page_var');
|
| 88 | 88 | add_action('wp', 'geodir_add_page_id_in_query_var'); // problem fix in wordpress 3.8
|
| 89 | 89 | if (get_option('permalink_structure') != '')
|
| 90 | - add_filter('parse_request', 'geodir_set_location_var_in_session_in_core');
|
|
| 90 | + add_filter('parse_request', 'geodir_set_location_var_in_session_in_core');
|
|
| 91 | 91 | |
| 92 | 92 | add_filter('parse_query', 'geodir_modified_query');
|
| 93 | 93 | |
@@ -154,14 +154,14 @@ discard block |
||
| 154 | 154 | /* POST AND LOOP ACTIONS */ |
| 155 | 155 | //////////////////////// |
| 156 | 156 | if (!is_admin()) {
|
| 157 | - add_action('pre_get_posts', 'geodir_exclude_page', 100); /// Will help to exclude virtural page from everywhere
|
|
| 158 | - add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages', 100);
|
|
| 159 | - /** Exclude Virtual Pages From Pages List **/ |
|
| 160 | - add_action('pre_get_posts', 'set_listing_request', 0);
|
|
| 161 | - add_action('pre_get_posts', 'geodir_listing_loop_filter', 1);
|
|
| 162 | - add_filter('excerpt_more', 'geodir_excerpt_more', 1000);
|
|
| 163 | - add_filter('excerpt_length', 'geodir_excerpt_length', 1000);
|
|
| 164 | - add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter
|
|
| 157 | + add_action('pre_get_posts', 'geodir_exclude_page', 100); /// Will help to exclude virtural page from everywhere
|
|
| 158 | + add_filter('wp_list_pages_excludes', 'exclude_from_wp_list_pages', 100);
|
|
| 159 | + /** Exclude Virtual Pages From Pages List **/ |
|
| 160 | + add_action('pre_get_posts', 'set_listing_request', 0);
|
|
| 161 | + add_action('pre_get_posts', 'geodir_listing_loop_filter', 1);
|
|
| 162 | + add_filter('excerpt_more', 'geodir_excerpt_more', 1000);
|
|
| 163 | + add_filter('excerpt_length', 'geodir_excerpt_length', 1000);
|
|
| 164 | + add_action('the_post', 'create_marker_jason_of_posts'); // Add marker in json array, Map related filter
|
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | |
@@ -222,12 +222,12 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | function geodir_unset_prev_theme_nav_location($newname) |
| 224 | 224 | {
|
| 225 | - $geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname);
|
|
| 226 | - if ($geodir_theme_location) {
|
|
| 227 | - update_option('geodir_theme_location_nav', $geodir_theme_location);
|
|
| 228 | - } else {
|
|
| 229 | - update_option('geodir_theme_location_nav', '');
|
|
| 230 | - } |
|
| 225 | + $geodir_theme_location = get_option('geodir_theme_location_nav_' . $newname);
|
|
| 226 | + if ($geodir_theme_location) {
|
|
| 227 | + update_option('geodir_theme_location_nav', $geodir_theme_location);
|
|
| 228 | + } else {
|
|
| 229 | + update_option('geodir_theme_location_nav', '');
|
|
| 230 | + } |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /// add action for theme switch to blank previous theme navigation location setting |
@@ -248,32 +248,32 @@ discard block |
||
| 248 | 248 | */ |
| 249 | 249 | function geodir_add_post_filters() |
| 250 | 250 | {
|
| 251 | - /** |
|
| 252 | - * Contains all function for filtering listing. |
|
| 253 | - * |
|
| 254 | - * @since 1.0.0 |
|
| 255 | - * @package GeoDirectory |
|
| 256 | - */ |
|
| 257 | - include_once('geodirectory-functions/listing_filters.php');
|
|
| 251 | + /** |
|
| 252 | + * Contains all function for filtering listing. |
|
| 253 | + * |
|
| 254 | + * @since 1.0.0 |
|
| 255 | + * @package GeoDirectory |
|
| 256 | + */ |
|
| 257 | + include_once('geodirectory-functions/listing_filters.php');
|
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | |
| 261 | 261 | if (!function_exists('geodir_init_defaults')) {
|
| 262 | - /** |
|
| 263 | - * Calls the function to register the GeoDirectory default CPT and taxonomies. |
|
| 264 | - * |
|
| 265 | - * @since 1.0.0 |
|
| 266 | - * @package GeoDirectory |
|
| 267 | - */ |
|
| 268 | - function geodir_init_defaults() |
|
| 269 | - {
|
|
| 270 | - if (function_exists('geodir_register_defaults')) {
|
|
| 262 | + /** |
|
| 263 | + * Calls the function to register the GeoDirectory default CPT and taxonomies. |
|
| 264 | + * |
|
| 265 | + * @since 1.0.0 |
|
| 266 | + * @package GeoDirectory |
|
| 267 | + */ |
|
| 268 | + function geodir_init_defaults() |
|
| 269 | + {
|
|
| 270 | + if (function_exists('geodir_register_defaults')) {
|
|
| 271 | 271 | |
| 272 | - geodir_register_defaults(); |
|
| 272 | + geodir_register_defaults(); |
|
| 273 | 273 | |
| 274 | - } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - } |
|
| 276 | + } |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | |
@@ -295,26 +295,26 @@ discard block |
||
| 295 | 295 | // CALLED ON 'sidebars_widgets' FILTER |
| 296 | 296 | |
| 297 | 297 | if (!function_exists('geodir_restrict_widget')) {
|
| 298 | - /** |
|
| 299 | - * Sets global values to be able to tell if the current page is a GeoDirectory listing page or a GeoDirectory details page. |
|
| 300 | - * |
|
| 301 | - * @global bool $is_listing Sets the global value to true if on a GD category page. False if not. |
|
| 302 | - * @global bool $is_single_place Sets the global value to true if on a GD details (post) page. False if not. |
|
| 303 | - * @since 1.0.0 |
|
| 304 | - * @package GeoDirectory |
|
| 305 | - */ |
|
| 306 | - function geodir_restrict_widget() |
|
| 307 | - {
|
|
| 308 | - global $is_listing, $is_single_place; |
|
| 298 | + /** |
|
| 299 | + * Sets global values to be able to tell if the current page is a GeoDirectory listing page or a GeoDirectory details page. |
|
| 300 | + * |
|
| 301 | + * @global bool $is_listing Sets the global value to true if on a GD category page. False if not. |
|
| 302 | + * @global bool $is_single_place Sets the global value to true if on a GD details (post) page. False if not. |
|
| 303 | + * @since 1.0.0 |
|
| 304 | + * @package GeoDirectory |
|
| 305 | + */ |
|
| 306 | + function geodir_restrict_widget() |
|
| 307 | + {
|
|
| 308 | + global $is_listing, $is_single_place; |
|
| 309 | 309 | |
| 310 | - // set is listing |
|
| 311 | - (geodir_is_page('listing')) ? $is_listing = true : $is_listing = false;
|
|
| 310 | + // set is listing |
|
| 311 | + (geodir_is_page('listing')) ? $is_listing = true : $is_listing = false;
|
|
| 312 | 312 | |
| 313 | - // set is single place |
|
| 314 | - (geodir_is_page('place')) ? $is_single_place = true : $is_single_place = false;
|
|
| 313 | + // set is single place |
|
| 314 | + (geodir_is_page('place')) ? $is_single_place = true : $is_single_place = false;
|
|
| 315 | 315 | |
| 316 | 316 | |
| 317 | - } |
|
| 317 | + } |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | |
@@ -335,32 +335,32 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | function geodir_detail_page_sidebar_content_sorting() |
| 337 | 337 | {
|
| 338 | - $arr_detail_page_sidebar_content = |
|
| 339 | - /** |
|
| 340 | - * An array of functions to be called to be displayed on the details (post) page sidebar. |
|
| 341 | - * |
|
| 342 | - * This filter can be used to remove sections of the details page sidebar, |
|
| 343 | - * add new sections or rearrange the order of the sections. |
|
| 344 | - * |
|
| 345 | - * @param array array('geodir_social_sharing_buttons','geodir_share_this_button','geodir_detail_page_google_analytics','geodir_edit_post_link','geodir_detail_page_review_rating','geodir_detail_page_more_info') The array of functions that will be called.
|
|
| 346 | - * @since 1.0.0 |
|
| 347 | - */ |
|
| 348 | - apply_filters('geodir_detail_page_sidebar_content',
|
|
| 349 | - array('geodir_social_sharing_buttons',
|
|
| 350 | - 'geodir_share_this_button', |
|
| 351 | - 'geodir_detail_page_google_analytics', |
|
| 352 | - 'geodir_edit_post_link', |
|
| 353 | - //'geodir_detail_page_review_rating', |
|
| 354 | - 'geodir_detail_page_more_info' |
|
| 355 | - ) // end of array |
|
| 356 | - ); // end of apply filter |
|
| 357 | - if (!empty($arr_detail_page_sidebar_content)) {
|
|
| 358 | - foreach ($arr_detail_page_sidebar_content as $content_function) {
|
|
| 359 | - if (function_exists($content_function)) {
|
|
| 360 | - add_action('geodir_detail_page_sidebar', $content_function);
|
|
| 361 | - } |
|
| 362 | - } |
|
| 363 | - } |
|
| 338 | + $arr_detail_page_sidebar_content = |
|
| 339 | + /** |
|
| 340 | + * An array of functions to be called to be displayed on the details (post) page sidebar. |
|
| 341 | + * |
|
| 342 | + * This filter can be used to remove sections of the details page sidebar, |
|
| 343 | + * add new sections or rearrange the order of the sections. |
|
| 344 | + * |
|
| 345 | + * @param array array('geodir_social_sharing_buttons','geodir_share_this_button','geodir_detail_page_google_analytics','geodir_edit_post_link','geodir_detail_page_review_rating','geodir_detail_page_more_info') The array of functions that will be called.
|
|
| 346 | + * @since 1.0.0 |
|
| 347 | + */ |
|
| 348 | + apply_filters('geodir_detail_page_sidebar_content',
|
|
| 349 | + array('geodir_social_sharing_buttons',
|
|
| 350 | + 'geodir_share_this_button', |
|
| 351 | + 'geodir_detail_page_google_analytics', |
|
| 352 | + 'geodir_edit_post_link', |
|
| 353 | + //'geodir_detail_page_review_rating', |
|
| 354 | + 'geodir_detail_page_more_info' |
|
| 355 | + ) // end of array |
|
| 356 | + ); // end of apply filter |
|
| 357 | + if (!empty($arr_detail_page_sidebar_content)) {
|
|
| 358 | + foreach ($arr_detail_page_sidebar_content as $content_function) {
|
|
| 359 | + if (function_exists($content_function)) {
|
|
| 360 | + add_action('geodir_detail_page_sidebar', $content_function);
|
|
| 361 | + } |
|
| 362 | + } |
|
| 363 | + } |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | add_action('geodir_after_edit_post_link', 'geodir_add_to_favourite_link', 1);
|
@@ -375,14 +375,14 @@ discard block |
||
| 375 | 375 | */ |
| 376 | 376 | function geodir_add_to_favourite_link() |
| 377 | 377 | {
|
| 378 | - global $post, $preview; |
|
| 379 | - if (!$preview && geodir_is_page('detail')) {
|
|
| 380 | - ?> |
|
| 378 | + global $post, $preview; |
|
| 379 | + if (!$preview && geodir_is_page('detail')) {
|
|
| 380 | + ?> |
|
| 381 | 381 | <p class="edit_link"> |
| 382 | 382 | <?php geodir_favourite_html($post->post_author, $post->ID); ?> |
| 383 | 383 | </p> |
| 384 | 384 | <?php |
| 385 | - } |
|
| 385 | + } |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -396,41 +396,41 @@ discard block |
||
| 396 | 396 | */ |
| 397 | 397 | function geodir_social_sharing_buttons() |
| 398 | 398 | {
|
| 399 | - global $preview; |
|
| 400 | - ob_start(); // Start buffering; |
|
| 401 | - /** |
|
| 402 | - * This action is called before the social buttons twitter,facebook and google plus are output in a containing div. |
|
| 403 | - * |
|
| 404 | - * @since 1.0.0 |
|
| 405 | - */ |
|
| 406 | - do_action('geodir_before_social_sharing_buttons');
|
|
| 407 | - if (!$preview) {
|
|
| 408 | - ?> |
|
| 399 | + global $preview; |
|
| 400 | + ob_start(); // Start buffering; |
|
| 401 | + /** |
|
| 402 | + * This action is called before the social buttons twitter,facebook and google plus are output in a containing div. |
|
| 403 | + * |
|
| 404 | + * @since 1.0.0 |
|
| 405 | + */ |
|
| 406 | + do_action('geodir_before_social_sharing_buttons');
|
|
| 407 | + if (!$preview) {
|
|
| 408 | + ?> |
|
| 409 | 409 | <div class="likethis"> |
| 410 | 410 | <?php geodir_twitter_tweet_button(); ?> |
| 411 | 411 | <?php geodir_fb_like_button(); ?> |
| 412 | 412 | <?php geodir_google_plus_button(); ?> |
| 413 | 413 | </div> |
| 414 | 414 | <?php |
| 415 | - }// end of if, if its a preview or not |
|
| 416 | - |
|
| 417 | - /** |
|
| 418 | - * This action is called after the social buttons twitter,facebook and google plus are output in a containing div. |
|
| 419 | - * |
|
| 420 | - * @since 1.0.0 |
|
| 421 | - */ |
|
| 422 | - do_action('geodir_after_social_sharing_buttons');
|
|
| 423 | - $content_html = ob_get_clean(); |
|
| 424 | - if (trim($content_html) != '') |
|
| 425 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>'; |
|
| 426 | - if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
|
|
| 427 | - /** |
|
| 428 | - * Filter the geodir_social_sharing_buttons() function content. |
|
| 429 | - * |
|
| 430 | - * @param string $content_html The output html of the geodir_social_sharing_buttons() function. |
|
| 431 | - */ |
|
| 432 | - echo $content_html = apply_filters('geodir_social_sharing_buttons_html', $content_html);
|
|
| 433 | - } |
|
| 415 | + }// end of if, if its a preview or not |
|
| 416 | + |
|
| 417 | + /** |
|
| 418 | + * This action is called after the social buttons twitter,facebook and google plus are output in a containing div. |
|
| 419 | + * |
|
| 420 | + * @since 1.0.0 |
|
| 421 | + */ |
|
| 422 | + do_action('geodir_after_social_sharing_buttons');
|
|
| 423 | + $content_html = ob_get_clean(); |
|
| 424 | + if (trim($content_html) != '') |
|
| 425 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-social-sharing">' . $content_html . '</div>'; |
|
| 426 | + if ((int)get_option('geodir_disable_tfg_buttons_section') != 1) {
|
|
| 427 | + /** |
|
| 428 | + * Filter the geodir_social_sharing_buttons() function content. |
|
| 429 | + * |
|
| 430 | + * @param string $content_html The output html of the geodir_social_sharing_buttons() function. |
|
| 431 | + */ |
|
| 432 | + echo $content_html = apply_filters('geodir_social_sharing_buttons_html', $content_html);
|
|
| 433 | + } |
|
| 434 | 434 | |
| 435 | 435 | |
| 436 | 436 | } |
@@ -446,39 +446,39 @@ discard block |
||
| 446 | 446 | */ |
| 447 | 447 | function geodir_share_this_button() |
| 448 | 448 | {
|
| 449 | - global $preview; |
|
| 450 | - ob_start(); // Start buffering; |
|
| 451 | - /** |
|
| 452 | - * This is called before the share this html in the function geodir_share_this_button() |
|
| 453 | - * |
|
| 454 | - * @since 1.0.0 |
|
| 455 | - */ |
|
| 456 | - do_action('geodir_before_share_this_button');
|
|
| 457 | - if (!$preview) {
|
|
| 458 | - ?> |
|
| 449 | + global $preview; |
|
| 450 | + ob_start(); // Start buffering; |
|
| 451 | + /** |
|
| 452 | + * This is called before the share this html in the function geodir_share_this_button() |
|
| 453 | + * |
|
| 454 | + * @since 1.0.0 |
|
| 455 | + */ |
|
| 456 | + do_action('geodir_before_share_this_button');
|
|
| 457 | + if (!$preview) {
|
|
| 458 | + ?> |
|
| 459 | 459 | <div class="share clearfix"> |
| 460 | 460 | <?php geodir_share_this_button_code(); ?> |
| 461 | 461 | </div> |
| 462 | 462 | <?php |
| 463 | - }// end of if, if its a preview or not |
|
| 464 | - /** |
|
| 465 | - * This is called after the share this html in the function geodir_share_this_button() |
|
| 466 | - * |
|
| 467 | - * @since 1.0.0 |
|
| 468 | - */ |
|
| 469 | - do_action('geodir_after_share_this_button');
|
|
| 470 | - $content_html = ob_get_clean(); |
|
| 471 | - if (trim($content_html) != '') |
|
| 472 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-sharethis">' . $content_html . '</div>'; |
|
| 473 | - if ((int)get_option('geodir_disable_sharethis_button_section') != 1) {
|
|
| 474 | - /** |
|
| 475 | - * Filter the geodir_share_this_button() function content. |
|
| 476 | - * |
|
| 477 | - * @param string $content_html The output html of the geodir_share_this_button() function. |
|
| 478 | - * @since 1.0.0 |
|
| 479 | - */ |
|
| 480 | - echo $content_html = apply_filters('geodir_share_this_button_html', $content_html);
|
|
| 481 | - } |
|
| 463 | + }// end of if, if its a preview or not |
|
| 464 | + /** |
|
| 465 | + * This is called after the share this html in the function geodir_share_this_button() |
|
| 466 | + * |
|
| 467 | + * @since 1.0.0 |
|
| 468 | + */ |
|
| 469 | + do_action('geodir_after_share_this_button');
|
|
| 470 | + $content_html = ob_get_clean(); |
|
| 471 | + if (trim($content_html) != '') |
|
| 472 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-sharethis">' . $content_html . '</div>'; |
|
| 473 | + if ((int)get_option('geodir_disable_sharethis_button_section') != 1) {
|
|
| 474 | + /** |
|
| 475 | + * Filter the geodir_share_this_button() function content. |
|
| 476 | + * |
|
| 477 | + * @param string $content_html The output html of the geodir_share_this_button() function. |
|
| 478 | + * @since 1.0.0 |
|
| 479 | + */ |
|
| 480 | + echo $content_html = apply_filters('geodir_share_this_button_html', $content_html);
|
|
| 481 | + } |
|
| 482 | 482 | |
| 483 | 483 | } |
| 484 | 484 | |
@@ -494,46 +494,46 @@ discard block |
||
| 494 | 494 | */ |
| 495 | 495 | function geodir_edit_post_link() |
| 496 | 496 | {
|
| 497 | - global $post, $preview; |
|
| 498 | - ob_start(); // Start buffering; |
|
| 499 | - /** |
|
| 500 | - * This is called before the edit post link html in the function geodir_edit_post_link() |
|
| 501 | - * |
|
| 502 | - * @since 1.0.0 |
|
| 503 | - */ |
|
| 504 | - do_action('geodir_before_edit_post_link');
|
|
| 505 | - if (!$preview) {
|
|
| 506 | - $is_current_user_owner = geodir_listing_belong_to_current_user(); |
|
| 497 | + global $post, $preview; |
|
| 498 | + ob_start(); // Start buffering; |
|
| 499 | + /** |
|
| 500 | + * This is called before the edit post link html in the function geodir_edit_post_link() |
|
| 501 | + * |
|
| 502 | + * @since 1.0.0 |
|
| 503 | + */ |
|
| 504 | + do_action('geodir_before_edit_post_link');
|
|
| 505 | + if (!$preview) {
|
|
| 506 | + $is_current_user_owner = geodir_listing_belong_to_current_user(); |
|
| 507 | 507 | |
| 508 | - if ($is_current_user_owner) {
|
|
| 509 | - $post_id = $post->ID; |
|
| 508 | + if ($is_current_user_owner) {
|
|
| 509 | + $post_id = $post->ID; |
|
| 510 | 510 | |
| 511 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 512 | - $post_id = (int)$_REQUEST['pid']; |
|
| 513 | - } |
|
| 511 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 512 | + $post_id = (int)$_REQUEST['pid']; |
|
| 513 | + } |
|
| 514 | 514 | |
| 515 | - $postlink = get_permalink(geodir_add_listing_page_id()); |
|
| 516 | - $editlink = geodir_getlink($postlink, array('pid' => $post_id), false);
|
|
| 517 | - echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>';
|
|
| 518 | - } |
|
| 519 | - }// end of if, if its a preview or not |
|
| 520 | - /** |
|
| 521 | - * This is called after the edit post link html in the function geodir_edit_post_link() |
|
| 522 | - * |
|
| 523 | - * @since 1.0.0 |
|
| 524 | - */ |
|
| 525 | - do_action('geodir_after_edit_post_link');
|
|
| 526 | - $content_html = ob_get_clean(); |
|
| 527 | - if (trim($content_html) != '') |
|
| 528 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>'; |
|
| 529 | - if ((int)get_option('geodir_disable_user_links_section') != 1) {
|
|
| 530 | - /** |
|
| 531 | - * Filter the geodir_edit_post_link() function content. |
|
| 532 | - * |
|
| 533 | - * @param string $content_html The output html of the geodir_edit_post_link() function. |
|
| 534 | - */ |
|
| 535 | - echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html);
|
|
| 536 | - } |
|
| 515 | + $postlink = get_permalink(geodir_add_listing_page_id()); |
|
| 516 | + $editlink = geodir_getlink($postlink, array('pid' => $post_id), false);
|
|
| 517 | + echo ' <p class="edit_link"><i class="fa fa-pencil"></i> <a href="' . esc_url($editlink) . '">' . __('Edit this Post', 'geodirectory') . '</a></p>';
|
|
| 518 | + } |
|
| 519 | + }// end of if, if its a preview or not |
|
| 520 | + /** |
|
| 521 | + * This is called after the edit post link html in the function geodir_edit_post_link() |
|
| 522 | + * |
|
| 523 | + * @since 1.0.0 |
|
| 524 | + */ |
|
| 525 | + do_action('geodir_after_edit_post_link');
|
|
| 526 | + $content_html = ob_get_clean(); |
|
| 527 | + if (trim($content_html) != '') |
|
| 528 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-user-links">' . $content_html . '</div>'; |
|
| 529 | + if ((int)get_option('geodir_disable_user_links_section') != 1) {
|
|
| 530 | + /** |
|
| 531 | + * Filter the geodir_edit_post_link() function content. |
|
| 532 | + * |
|
| 533 | + * @param string $content_html The output html of the geodir_edit_post_link() function. |
|
| 534 | + */ |
|
| 535 | + echo $content_html = apply_filters('geodir_edit_post_link_html', $content_html);
|
|
| 536 | + } |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | /** |
@@ -547,41 +547,41 @@ discard block |
||
| 547 | 547 | */ |
| 548 | 548 | function geodir_detail_page_google_analytics() |
| 549 | 549 | {
|
| 550 | - global $post; |
|
| 551 | - $package_info = array(); |
|
| 552 | - $package_info = geodir_post_package_info($package_info, $post); |
|
| 550 | + global $post; |
|
| 551 | + $package_info = array(); |
|
| 552 | + $package_info = geodir_post_package_info($package_info, $post); |
|
| 553 | 553 | |
| 554 | - $id = trim(get_option('geodir_ga_id'));
|
|
| 554 | + $id = trim(get_option('geodir_ga_id'));
|
|
| 555 | 555 | |
| 556 | - if (!$id) {
|
|
| 557 | - return; //if no Google Analytics ID then bail. |
|
| 558 | - } |
|
| 556 | + if (!$id) {
|
|
| 557 | + return; //if no Google Analytics ID then bail. |
|
| 558 | + } |
|
| 559 | 559 | |
| 560 | - ob_start(); // Start buffering; |
|
| 561 | - /** |
|
| 562 | - * This is called before the edit post link html in the function geodir_detail_page_google_analytics() |
|
| 563 | - * |
|
| 564 | - * @since 1.0.0 |
|
| 565 | - */ |
|
| 566 | - do_action('geodir_before_google_analytics');
|
|
| 560 | + ob_start(); // Start buffering; |
|
| 561 | + /** |
|
| 562 | + * This is called before the edit post link html in the function geodir_detail_page_google_analytics() |
|
| 563 | + * |
|
| 564 | + * @since 1.0.0 |
|
| 565 | + */ |
|
| 566 | + do_action('geodir_before_google_analytics');
|
|
| 567 | 567 | |
| 568 | - $refresh_time = get_option('geodir_ga_refresh_time', 5);
|
|
| 569 | - /** |
|
| 570 | - * Filter the time interval to check & refresh new users results. |
|
| 571 | - * |
|
| 572 | - * @since 1.5.9 |
|
| 573 | - * |
|
| 574 | - * @param int $refresh_time Time interval to check & refresh new users results. |
|
| 575 | - */ |
|
| 576 | - $refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time);
|
|
| 577 | - $refresh_time = absint($refresh_time * 1000); |
|
| 568 | + $refresh_time = get_option('geodir_ga_refresh_time', 5);
|
|
| 569 | + /** |
|
| 570 | + * Filter the time interval to check & refresh new users results. |
|
| 571 | + * |
|
| 572 | + * @since 1.5.9 |
|
| 573 | + * |
|
| 574 | + * @param int $refresh_time Time interval to check & refresh new users results. |
|
| 575 | + */ |
|
| 576 | + $refresh_time = apply_filters('geodir_google_analytics_refresh_time', $refresh_time);
|
|
| 577 | + $refresh_time = absint($refresh_time * 1000); |
|
| 578 | 578 | |
| 579 | - $hide_refresh = get_option('geodir_ga_auto_refresh');
|
|
| 579 | + $hide_refresh = get_option('geodir_ga_auto_refresh');
|
|
| 580 | 580 | |
| 581 | - $auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0; |
|
| 582 | - if (get_option('geodir_ga_stats') && is_user_logged_in() && (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) {
|
|
| 583 | - $page_url = urlencode($_SERVER['REQUEST_URI']); |
|
| 584 | - ?> |
|
| 581 | + $auto_refresh = $hide_refresh && $refresh_time && $refresh_time > 0 ? 1 : 0; |
|
| 582 | + if (get_option('geodir_ga_stats') && is_user_logged_in() && (isset($package_info->google_analytics) && $package_info->google_analytics == '1') && (get_current_user_id()==$post->post_author || current_user_can( 'manage_options' )) ) {
|
|
| 583 | + $page_url = urlencode($_SERVER['REQUEST_URI']); |
|
| 584 | + ?> |
|
| 585 | 585 | <script type="text/javascript"> |
| 586 | 586 | var gd_gaTimeOut; |
| 587 | 587 | var gd_gaTime = parseInt('<?php echo $refresh_time;?>');
|
@@ -833,15 +833,15 @@ discard block |
||
| 833 | 833 | var labels = results[1].rows.map(function(row) { return +row[0]; });
|
| 834 | 834 | |
| 835 | 835 | <?php |
| 836 | - // Here we list the shorthand days of the week so it can be used in translation. |
|
| 837 | - __("Mon",'geodirectory');
|
|
| 838 | - __("Tue",'geodirectory');
|
|
| 839 | - __("Wed",'geodirectory');
|
|
| 840 | - __("Thu",'geodirectory');
|
|
| 841 | - __("Fri",'geodirectory');
|
|
| 842 | - __("Sat",'geodirectory');
|
|
| 843 | - __("Sun",'geodirectory');
|
|
| 844 | - ?> |
|
| 836 | + // Here we list the shorthand days of the week so it can be used in translation. |
|
| 837 | + __("Mon",'geodirectory');
|
|
| 838 | + __("Tue",'geodirectory');
|
|
| 839 | + __("Wed",'geodirectory');
|
|
| 840 | + __("Thu",'geodirectory');
|
|
| 841 | + __("Fri",'geodirectory');
|
|
| 842 | + __("Sat",'geodirectory');
|
|
| 843 | + __("Sun",'geodirectory');
|
|
| 844 | + ?> |
|
| 845 | 845 | |
| 846 | 846 | labels = [ |
| 847 | 847 | "<?php _e(date('D', strtotime("+1 day")),'geodirectory'); ?>",
|
@@ -1090,24 +1090,24 @@ discard block |
||
| 1090 | 1090 | </span> |
| 1091 | 1091 | |
| 1092 | 1092 | <?php |
| 1093 | - } |
|
| 1094 | - /** |
|
| 1095 | - * This is called after the edit post link html in the function geodir_detail_page_google_analytics() |
|
| 1096 | - * |
|
| 1097 | - * @since 1.0.0 |
|
| 1098 | - */ |
|
| 1099 | - do_action('geodir_after_google_analytics');
|
|
| 1100 | - $content_html = ob_get_clean(); |
|
| 1101 | - if (trim($content_html) != '') |
|
| 1102 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>'; |
|
| 1103 | - if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
|
|
| 1104 | - /** |
|
| 1105 | - * Filter the geodir_edit_post_link() function content. |
|
| 1106 | - * |
|
| 1107 | - * @param string $content_html The output html of the geodir_edit_post_link() function. |
|
| 1108 | - */ |
|
| 1109 | - echo $content_html = apply_filters('geodir_google_analytic_html', $content_html);
|
|
| 1110 | - } |
|
| 1093 | + } |
|
| 1094 | + /** |
|
| 1095 | + * This is called after the edit post link html in the function geodir_detail_page_google_analytics() |
|
| 1096 | + * |
|
| 1097 | + * @since 1.0.0 |
|
| 1098 | + */ |
|
| 1099 | + do_action('geodir_after_google_analytics');
|
|
| 1100 | + $content_html = ob_get_clean(); |
|
| 1101 | + if (trim($content_html) != '') |
|
| 1102 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-google-analytics">' . $content_html . '</div>'; |
|
| 1103 | + if ((int)get_option('geodir_disable_google_analytics_section') != 1) {
|
|
| 1104 | + /** |
|
| 1105 | + * Filter the geodir_edit_post_link() function content. |
|
| 1106 | + * |
|
| 1107 | + * @param string $content_html The output html of the geodir_edit_post_link() function. |
|
| 1108 | + */ |
|
| 1109 | + echo $content_html = apply_filters('geodir_google_analytic_html', $content_html);
|
|
| 1110 | + } |
|
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | 1113 | /** |
@@ -1123,90 +1123,90 @@ discard block |
||
| 1123 | 1123 | */ |
| 1124 | 1124 | function geodir_detail_page_review_rating() |
| 1125 | 1125 | {
|
| 1126 | - global $post, $preview, $post_images; |
|
| 1127 | - ob_start(); // Start buffering; |
|
| 1128 | - /** |
|
| 1129 | - * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
| 1130 | - * |
|
| 1131 | - * This is called outside the check for an actual rating and the check for preview page. |
|
| 1132 | - * |
|
| 1133 | - * @since 1.0.0 |
|
| 1134 | - */ |
|
| 1135 | - do_action('geodir_before_detail_page_review_rating');
|
|
| 1136 | - |
|
| 1137 | - $comment_count = geodir_get_review_count_total($post->ID); |
|
| 1138 | - $post_avgratings = geodir_get_post_rating($post->ID); |
|
| 1139 | - |
|
| 1140 | - if ($post_avgratings != 0 && !$preview) {
|
|
| 1141 | - /** |
|
| 1142 | - * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
| 1143 | - * |
|
| 1144 | - * This is called inside the check for an actual rating and the check for preview page. |
|
| 1145 | - * |
|
| 1146 | - * @since 1.0.0 |
|
| 1147 | - * @param float $post_avgratings Average rating for the surrent post. |
|
| 1148 | - * @param int $post->ID Current post ID. |
|
| 1149 | - */ |
|
| 1150 | - do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID);
|
|
| 1151 | - |
|
| 1152 | - $html = '<p style=" float:left;">'; |
|
| 1153 | - $html .= geodir_get_rating_stars($post_avgratings, $post->ID); |
|
| 1154 | - $html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">'; |
|
| 1155 | - $post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings; |
|
| 1126 | + global $post, $preview, $post_images; |
|
| 1127 | + ob_start(); // Start buffering; |
|
| 1128 | + /** |
|
| 1129 | + * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
| 1130 | + * |
|
| 1131 | + * This is called outside the check for an actual rating and the check for preview page. |
|
| 1132 | + * |
|
| 1133 | + * @since 1.0.0 |
|
| 1134 | + */ |
|
| 1135 | + do_action('geodir_before_detail_page_review_rating');
|
|
| 1136 | + |
|
| 1137 | + $comment_count = geodir_get_review_count_total($post->ID); |
|
| 1138 | + $post_avgratings = geodir_get_post_rating($post->ID); |
|
| 1139 | + |
|
| 1140 | + if ($post_avgratings != 0 && !$preview) {
|
|
| 1141 | + /** |
|
| 1142 | + * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
| 1143 | + * |
|
| 1144 | + * This is called inside the check for an actual rating and the check for preview page. |
|
| 1145 | + * |
|
| 1146 | + * @since 1.0.0 |
|
| 1147 | + * @param float $post_avgratings Average rating for the surrent post. |
|
| 1148 | + * @param int $post->ID Current post ID. |
|
| 1149 | + */ |
|
| 1150 | + do_action('geodir_before_review_rating_stars_on_detail', $post_avgratings, $post->ID);
|
|
| 1151 | + |
|
| 1152 | + $html = '<p style=" float:left;">'; |
|
| 1153 | + $html .= geodir_get_rating_stars($post_avgratings, $post->ID); |
|
| 1154 | + $html .= '<div class="average-review" itemscope itemtype="http://data-vocabulary.org/Review-aggregate">'; |
|
| 1155 | + $post_avgratings = (is_float($post_avgratings) || (strpos($post_avgratings, ".", 1) == 1 && strlen($post_avgratings) > 3)) ? number_format($post_avgratings, 1, '.', '') : $post_avgratings; |
|
| 1156 | 1156 | |
| 1157 | 1157 | $reviews_text = $comment_count > 1 ? __("reviews", 'geodirectory') : __("review", 'geodirectory');
|
| 1158 | 1158 | |
| 1159 | 1159 | $html .= '<span itemprop="rating" itemscope itemtype="http://data-vocabulary.org/Rating"><span class="rating" itemprop="average" content="' . $post_avgratings . '">' . $post_avgratings . '</span> / <span itemprop="best" content="5">5</span> ' . __("based on", 'geodirectory') . ' </span><span class="count" itemprop="count" content="' . $comment_count . '">' . $comment_count . ' ' . $reviews_text . '</span><br />';
|
| 1160 | 1160 | |
| 1161 | - $html .= '<span class="item">'; |
|
| 1162 | - $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>'; |
|
| 1161 | + $html .= '<span class="item">'; |
|
| 1162 | + $html .= '<span class="fn" itemprop="itemreviewed">' . $post->post_title . '</span>'; |
|
| 1163 | 1163 | |
| 1164 | - if ($post_images) {
|
|
| 1165 | - foreach ($post_images as $img) {
|
|
| 1166 | - $post_img = $img->src; |
|
| 1167 | - break; |
|
| 1168 | - } |
|
| 1169 | - } |
|
| 1170 | - |
|
| 1171 | - if (isset($post_img) && $post_img) {
|
|
| 1172 | - $html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />'; |
|
| 1173 | - } |
|
| 1174 | - |
|
| 1175 | - $html .= '</span>'; |
|
| 1176 | - |
|
| 1177 | - echo $html .= '</div>'; |
|
| 1178 | - /** |
|
| 1179 | - * This is called after the rating html in the function geodir_detail_page_review_rating(). |
|
| 1180 | - * |
|
| 1181 | - * This is called inside the check for an actual rating and the check for preview page. |
|
| 1182 | - * |
|
| 1183 | - * @since 1.0.0 |
|
| 1184 | - * @param float $post_avgratings Average rating for the surrent post. |
|
| 1185 | - * @param int $post->ID Current post ID. |
|
| 1186 | - */ |
|
| 1187 | - do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID);
|
|
| 1188 | - } |
|
| 1189 | - /** |
|
| 1190 | - * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
| 1191 | - * |
|
| 1192 | - * This is called outside the check for an actual rating and the check for preview page. |
|
| 1193 | - * |
|
| 1194 | - * @since 1.0.0 |
|
| 1195 | - */ |
|
| 1196 | - do_action('geodir_after_detail_page_review_rating');
|
|
| 1197 | - $content_html = ob_get_clean(); |
|
| 1198 | - if (trim($content_html) != '') {
|
|
| 1199 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>'; |
|
| 1200 | - } |
|
| 1201 | - if ((int)get_option('geodir_disable_rating_info_section') != 1) {
|
|
| 1202 | - /** |
|
| 1203 | - * Filter the geodir_detail_page_review_rating() function content. |
|
| 1204 | - * |
|
| 1205 | - * @since 1.0.0 |
|
| 1206 | - * @param string $content_html The output html of the geodir_detail_page_review_rating() function. |
|
| 1207 | - */ |
|
| 1208 | - echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html);
|
|
| 1209 | - } |
|
| 1164 | + if ($post_images) {
|
|
| 1165 | + foreach ($post_images as $img) {
|
|
| 1166 | + $post_img = $img->src; |
|
| 1167 | + break; |
|
| 1168 | + } |
|
| 1169 | + } |
|
| 1170 | + |
|
| 1171 | + if (isset($post_img) && $post_img) {
|
|
| 1172 | + $html .= '<br /><img src="' . $post_img . '" class="photo" alt="' . esc_attr($post->post_title) . '" itemprop="photo" content="' . $post_img . '" class="photo" />'; |
|
| 1173 | + } |
|
| 1174 | + |
|
| 1175 | + $html .= '</span>'; |
|
| 1176 | + |
|
| 1177 | + echo $html .= '</div>'; |
|
| 1178 | + /** |
|
| 1179 | + * This is called after the rating html in the function geodir_detail_page_review_rating(). |
|
| 1180 | + * |
|
| 1181 | + * This is called inside the check for an actual rating and the check for preview page. |
|
| 1182 | + * |
|
| 1183 | + * @since 1.0.0 |
|
| 1184 | + * @param float $post_avgratings Average rating for the surrent post. |
|
| 1185 | + * @param int $post->ID Current post ID. |
|
| 1186 | + */ |
|
| 1187 | + do_action('geodir_after_review_rating_stars_on_detail', $post_avgratings, $post->ID);
|
|
| 1188 | + } |
|
| 1189 | + /** |
|
| 1190 | + * This is called before the rating html in the function geodir_detail_page_review_rating(). |
|
| 1191 | + * |
|
| 1192 | + * This is called outside the check for an actual rating and the check for preview page. |
|
| 1193 | + * |
|
| 1194 | + * @since 1.0.0 |
|
| 1195 | + */ |
|
| 1196 | + do_action('geodir_after_detail_page_review_rating');
|
|
| 1197 | + $content_html = ob_get_clean(); |
|
| 1198 | + if (trim($content_html) != '') {
|
|
| 1199 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-rating">' . $content_html . '</div>'; |
|
| 1200 | + } |
|
| 1201 | + if ((int)get_option('geodir_disable_rating_info_section') != 1) {
|
|
| 1202 | + /** |
|
| 1203 | + * Filter the geodir_detail_page_review_rating() function content. |
|
| 1204 | + * |
|
| 1205 | + * @since 1.0.0 |
|
| 1206 | + * @param string $content_html The output html of the geodir_detail_page_review_rating() function. |
|
| 1207 | + */ |
|
| 1208 | + echo $content_html = apply_filters('geodir_detail_page_review_rating_html', $content_html);
|
|
| 1209 | + } |
|
| 1210 | 1210 | } |
| 1211 | 1211 | |
| 1212 | 1212 | /** |
@@ -1218,35 +1218,35 @@ discard block |
||
| 1218 | 1218 | */ |
| 1219 | 1219 | function geodir_detail_page_more_info() |
| 1220 | 1220 | {
|
| 1221 | - ob_start(); // Start buffering; |
|
| 1222 | - /** |
|
| 1223 | - * This is called before the info section html. |
|
| 1224 | - * |
|
| 1225 | - * @since 1.0.0 |
|
| 1226 | - */ |
|
| 1227 | - do_action('geodir_before_detail_page_more_info');
|
|
| 1228 | - if ($geodir_post_detail_fields = geodir_show_listing_info()) {
|
|
| 1229 | - echo $geodir_post_detail_fields; |
|
| 1230 | - } |
|
| 1231 | - /** |
|
| 1232 | - * This is called after the info section html. |
|
| 1233 | - * |
|
| 1234 | - * @since 1.0.0 |
|
| 1235 | - */ |
|
| 1236 | - do_action('geodir_after_detail_page_more_info');
|
|
| 1237 | - |
|
| 1238 | - $content_html = ob_get_clean(); |
|
| 1239 | - if (trim($content_html) != '') |
|
| 1240 | - $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>'; |
|
| 1241 | - if ((int)get_option('geodir_disable_listing_info_section') != 1) {
|
|
| 1242 | - /** |
|
| 1243 | - * Filter the output html for function geodir_detail_page_more_info(). |
|
| 1244 | - * |
|
| 1245 | - * @since 1.0.0 |
|
| 1246 | - * @param string $content_html The output html of the geodir_detail_page_more_info() function. |
|
| 1247 | - */ |
|
| 1248 | - echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html);
|
|
| 1249 | - } |
|
| 1221 | + ob_start(); // Start buffering; |
|
| 1222 | + /** |
|
| 1223 | + * This is called before the info section html. |
|
| 1224 | + * |
|
| 1225 | + * @since 1.0.0 |
|
| 1226 | + */ |
|
| 1227 | + do_action('geodir_before_detail_page_more_info');
|
|
| 1228 | + if ($geodir_post_detail_fields = geodir_show_listing_info()) {
|
|
| 1229 | + echo $geodir_post_detail_fields; |
|
| 1230 | + } |
|
| 1231 | + /** |
|
| 1232 | + * This is called after the info section html. |
|
| 1233 | + * |
|
| 1234 | + * @since 1.0.0 |
|
| 1235 | + */ |
|
| 1236 | + do_action('geodir_after_detail_page_more_info');
|
|
| 1237 | + |
|
| 1238 | + $content_html = ob_get_clean(); |
|
| 1239 | + if (trim($content_html) != '') |
|
| 1240 | + $content_html = '<div class="geodir-company_info geodir-details-sidebar-listing-info">' . $content_html . '</div>'; |
|
| 1241 | + if ((int)get_option('geodir_disable_listing_info_section') != 1) {
|
|
| 1242 | + /** |
|
| 1243 | + * Filter the output html for function geodir_detail_page_more_info(). |
|
| 1244 | + * |
|
| 1245 | + * @since 1.0.0 |
|
| 1246 | + * @param string $content_html The output html of the geodir_detail_page_more_info() function. |
|
| 1247 | + */ |
|
| 1248 | + echo $content_html = apply_filters('geodir_detail_page_more_info_html', $content_html);
|
|
| 1249 | + } |
|
| 1250 | 1250 | } |
| 1251 | 1251 | |
| 1252 | 1252 | |
@@ -1260,15 +1260,15 @@ discard block |
||
| 1260 | 1260 | */ |
| 1261 | 1261 | function geodir_localize_all_js_msg() |
| 1262 | 1262 | {// check_ajax_referer function is used to make sure no files are uplaoded remotly but it will fail if used between https and non https so we do the check below of the urls
|
| 1263 | - if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
|
|
| 1264 | - $ajax_url = admin_url('admin-ajax.php');
|
|
| 1265 | - } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
|
|
| 1266 | - $ajax_url = admin_url('admin-ajax.php');
|
|
| 1267 | - } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
|
|
| 1268 | - $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
|
|
| 1269 | - } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
|
|
| 1270 | - $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
|
|
| 1271 | - } |
|
| 1263 | + if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
|
|
| 1264 | + $ajax_url = admin_url('admin-ajax.php');
|
|
| 1265 | + } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
|
|
| 1266 | + $ajax_url = admin_url('admin-ajax.php');
|
|
| 1267 | + } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
|
|
| 1268 | + $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
|
|
| 1269 | + } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
|
|
| 1270 | + $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
|
|
| 1271 | + } |
|
| 1272 | 1272 | |
| 1273 | 1273 | /** |
| 1274 | 1274 | * Filter the allowed image type extensions for post images. |
@@ -1278,59 +1278,59 @@ discard block |
||
| 1278 | 1278 | */ |
| 1279 | 1279 | $allowed_img_types = apply_filters('geodir_allowed_post_image_exts', array('jpg', 'jpeg', 'jpe', 'gif', 'png'));
|
| 1280 | 1280 | |
| 1281 | - $default_marker_icon = get_option('geodir_default_marker_icon');
|
|
| 1282 | - $default_marker_size = geodir_get_marker_size($default_marker_icon, array('w' => 20, 'h' => 34));
|
|
| 1283 | - $default_marker_width = $default_marker_size['w']; |
|
| 1284 | - $default_marker_height = $default_marker_size['h']; |
|
| 1281 | + $default_marker_icon = get_option('geodir_default_marker_icon');
|
|
| 1282 | + $default_marker_size = geodir_get_marker_size($default_marker_icon, array('w' => 20, 'h' => 34));
|
|
| 1283 | + $default_marker_width = $default_marker_size['w']; |
|
| 1284 | + $default_marker_height = $default_marker_size['h']; |
|
| 1285 | 1285 | |
| 1286 | - $arr_alert_msg = array( |
|
| 1287 | - 'geodir_plugin_url' => geodir_plugin_url(), |
|
| 1288 | - 'geodir_admin_ajax_url' => $ajax_url, |
|
| 1289 | - 'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'geodirectory'),
|
|
| 1290 | - 'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'geodirectory'),
|
|
| 1291 | - 'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'geodirectory'),
|
|
| 1292 | - 'custom_field_delete' => __('Are you wish to delete this field?', 'geodirectory'),
|
|
| 1293 | - //start not show alert msg |
|
| 1294 | - 'tax_meta_class_succ_del_msg' => __('File has been successfully deleted.', 'geodirectory'),
|
|
| 1295 | - 'tax_meta_class_not_permission_to_del_msg' => __('You do NOT have permission to delete this file.', 'geodirectory'),
|
|
| 1296 | - 'tax_meta_class_order_save_msg' => __('Order saved!', 'geodirectory'),
|
|
| 1297 | - 'tax_meta_class_not_permission_record_img_msg' => __('You do not have permission to reorder images.', 'geodirectory'),
|
|
| 1298 | - 'address_not_found_on_map_msg' => __('Address not found for:', 'geodirectory'),
|
|
| 1299 | - // end not show alert msg |
|
| 1300 | - 'my_place_listing_del' => __('Are you wish to delete this listing?', 'geodirectory'),
|
|
| 1301 | - //start not show alert msg |
|
| 1302 | - 'rating_error_msg' => __('Error : please retry', 'geodirectory'),
|
|
| 1303 | - 'listing_url_prefix_msg' => __('Please enter listing url prefix', 'geodirectory'),
|
|
| 1304 | - 'invalid_listing_prefix_msg' => __('Invalid character in listing url prefix', 'geodirectory'),
|
|
| 1305 | - 'location_url_prefix_msg' => __('Please enter location url prefix', 'geodirectory'),
|
|
| 1306 | - 'invalid_location_prefix_msg' => __('Invalid character in location url prefix', 'geodirectory'),
|
|
| 1307 | - 'location_and_cat_url_separator_msg' => __('Please enter location and category url separator', 'geodirectory'),
|
|
| 1308 | - 'invalid_char_and_cat_url_separator_msg' => __('Invalid character in location and category url separator', 'geodirectory'),
|
|
| 1309 | - 'listing_det_url_separator_msg' => __('Please enter listing detail url separator', 'geodirectory'),
|
|
| 1310 | - 'invalid_char_listing_det_url_separator_msg' => __('Invalid character in listing detail url separator', 'geodirectory'),
|
|
| 1311 | - 'loading_listing_error_favorite' => __('Error loading listing.', 'geodirectory'),
|
|
| 1312 | - 'geodir_field_id_required' => __('This field is required.', 'geodirectory'),
|
|
| 1313 | - 'geodir_valid_email_address_msg' => __('Please enter valid email address.', 'geodirectory'),
|
|
| 1314 | - 'geodir_default_marker_icon' => $default_marker_icon, |
|
| 1315 | - 'geodir_default_marker_w' => $default_marker_width, |
|
| 1316 | - 'geodir_default_marker_h' => $default_marker_height, |
|
| 1317 | - 'geodir_latitude_error_msg' => GEODIR_LATITUDE_ERROR_MSG, |
|
| 1318 | - 'geodir_longgitude_error_msg' => GEODIR_LOGNGITUDE_ERROR_MSG, |
|
| 1319 | - 'geodir_default_rating_star_icon' => get_option('geodir_default_rating_star_icon'),
|
|
| 1320 | - 'gd_cmt_btn_post_reply' => __('Post Reply', 'geodirectory'),
|
|
| 1321 | - 'gd_cmt_btn_reply_text' => __('Reply text', 'geodirectory'),
|
|
| 1322 | - 'gd_cmt_btn_post_review' => __('Post Review', 'geodirectory'),
|
|
| 1323 | - 'gd_cmt_btn_review_text' => __('Review text', 'geodirectory'),
|
|
| 1324 | - 'gd_cmt_err_no_rating' => __("Please select star rating, you can't leave a review without stars.", 'geodirectory'),
|
|
| 1325 | - /* on/off dragging for phone devices */ |
|
| 1326 | - 'geodir_onoff_dragging' => get_option('geodir_map_onoff_dragging') ? true : false,
|
|
| 1327 | - 'geodir_is_mobile' => wp_is_mobile() ? true : false, |
|
| 1328 | - 'geodir_on_dragging_text' => __('Enable Dragging', 'geodirectory'),
|
|
| 1329 | - 'geodir_off_dragging_text' => __('Disable Dragging', 'geodirectory'),
|
|
| 1330 | - 'geodir_err_max_file_size' => __('File size error : You tried to upload a file over %s', 'geodirectory'),
|
|
| 1331 | - 'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'),
|
|
| 1332 | - 'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'),
|
|
| 1333 | - 'geodir_action_remove' => __('Remove', 'geodirectory'),
|
|
| 1286 | + $arr_alert_msg = array( |
|
| 1287 | + 'geodir_plugin_url' => geodir_plugin_url(), |
|
| 1288 | + 'geodir_admin_ajax_url' => $ajax_url, |
|
| 1289 | + 'custom_field_not_blank_var' => __('HTML Variable Name must not be blank', 'geodirectory'),
|
|
| 1290 | + 'custom_field_not_special_char' => __('Please do not use special character and spaces in HTML Variable Name.', 'geodirectory'),
|
|
| 1291 | + 'custom_field_unique_name' => __('HTML Variable Name should be a unique name.', 'geodirectory'),
|
|
| 1292 | + 'custom_field_delete' => __('Are you wish to delete this field?', 'geodirectory'),
|
|
| 1293 | + //start not show alert msg |
|
| 1294 | + 'tax_meta_class_succ_del_msg' => __('File has been successfully deleted.', 'geodirectory'),
|
|
| 1295 | + 'tax_meta_class_not_permission_to_del_msg' => __('You do NOT have permission to delete this file.', 'geodirectory'),
|
|
| 1296 | + 'tax_meta_class_order_save_msg' => __('Order saved!', 'geodirectory'),
|
|
| 1297 | + 'tax_meta_class_not_permission_record_img_msg' => __('You do not have permission to reorder images.', 'geodirectory'),
|
|
| 1298 | + 'address_not_found_on_map_msg' => __('Address not found for:', 'geodirectory'),
|
|
| 1299 | + // end not show alert msg |
|
| 1300 | + 'my_place_listing_del' => __('Are you wish to delete this listing?', 'geodirectory'),
|
|
| 1301 | + //start not show alert msg |
|
| 1302 | + 'rating_error_msg' => __('Error : please retry', 'geodirectory'),
|
|
| 1303 | + 'listing_url_prefix_msg' => __('Please enter listing url prefix', 'geodirectory'),
|
|
| 1304 | + 'invalid_listing_prefix_msg' => __('Invalid character in listing url prefix', 'geodirectory'),
|
|
| 1305 | + 'location_url_prefix_msg' => __('Please enter location url prefix', 'geodirectory'),
|
|
| 1306 | + 'invalid_location_prefix_msg' => __('Invalid character in location url prefix', 'geodirectory'),
|
|
| 1307 | + 'location_and_cat_url_separator_msg' => __('Please enter location and category url separator', 'geodirectory'),
|
|
| 1308 | + 'invalid_char_and_cat_url_separator_msg' => __('Invalid character in location and category url separator', 'geodirectory'),
|
|
| 1309 | + 'listing_det_url_separator_msg' => __('Please enter listing detail url separator', 'geodirectory'),
|
|
| 1310 | + 'invalid_char_listing_det_url_separator_msg' => __('Invalid character in listing detail url separator', 'geodirectory'),
|
|
| 1311 | + 'loading_listing_error_favorite' => __('Error loading listing.', 'geodirectory'),
|
|
| 1312 | + 'geodir_field_id_required' => __('This field is required.', 'geodirectory'),
|
|
| 1313 | + 'geodir_valid_email_address_msg' => __('Please enter valid email address.', 'geodirectory'),
|
|
| 1314 | + 'geodir_default_marker_icon' => $default_marker_icon, |
|
| 1315 | + 'geodir_default_marker_w' => $default_marker_width, |
|
| 1316 | + 'geodir_default_marker_h' => $default_marker_height, |
|
| 1317 | + 'geodir_latitude_error_msg' => GEODIR_LATITUDE_ERROR_MSG, |
|
| 1318 | + 'geodir_longgitude_error_msg' => GEODIR_LOGNGITUDE_ERROR_MSG, |
|
| 1319 | + 'geodir_default_rating_star_icon' => get_option('geodir_default_rating_star_icon'),
|
|
| 1320 | + 'gd_cmt_btn_post_reply' => __('Post Reply', 'geodirectory'),
|
|
| 1321 | + 'gd_cmt_btn_reply_text' => __('Reply text', 'geodirectory'),
|
|
| 1322 | + 'gd_cmt_btn_post_review' => __('Post Review', 'geodirectory'),
|
|
| 1323 | + 'gd_cmt_btn_review_text' => __('Review text', 'geodirectory'),
|
|
| 1324 | + 'gd_cmt_err_no_rating' => __("Please select star rating, you can't leave a review without stars.", 'geodirectory'),
|
|
| 1325 | + /* on/off dragging for phone devices */ |
|
| 1326 | + 'geodir_onoff_dragging' => get_option('geodir_map_onoff_dragging') ? true : false,
|
|
| 1327 | + 'geodir_is_mobile' => wp_is_mobile() ? true : false, |
|
| 1328 | + 'geodir_on_dragging_text' => __('Enable Dragging', 'geodirectory'),
|
|
| 1329 | + 'geodir_off_dragging_text' => __('Disable Dragging', 'geodirectory'),
|
|
| 1330 | + 'geodir_err_max_file_size' => __('File size error : You tried to upload a file over %s', 'geodirectory'),
|
|
| 1331 | + 'geodir_err_file_upload_limit' => __('You have reached your upload limit of %s files.', 'geodirectory'),
|
|
| 1332 | + 'geodir_err_pkg_upload_limit' => __('You may only upload %s files with this package, please try again.', 'geodirectory'),
|
|
| 1333 | + 'geodir_action_remove' => __('Remove', 'geodirectory'),
|
|
| 1334 | 1334 | 'geodir_txt_all_files' => __('Allowed files', 'geodirectory'),
|
| 1335 | 1335 | 'geodir_err_file_type' => __('File type error. Allowed file types: %s', 'geodirectory'),
|
| 1336 | 1336 | 'gd_allowed_img_types' => !empty($allowed_img_types) ? implode(',', $allowed_img_types) : '',
|
@@ -1338,29 +1338,29 @@ discard block |
||
| 1338 | 1338 | 'geodir_txt_form_searching' => __('Searching...', 'geodirectory'),
|
| 1339 | 1339 | 'fa_rating' => (int)get_option('geodir_reviewrating_enable_font_awesome') == 1 ? 1 : '',
|
| 1340 | 1340 | 'reviewrating' => defined('GEODIRREVIEWRATING_VERSION') ? 1 : '',
|
| 1341 | - 'geodir_map_name' => geodir_map_name(), |
|
| 1342 | - ); |
|
| 1343 | - |
|
| 1344 | - /** |
|
| 1345 | - * Filters the translated JS strings from function geodir_localize_all_js_msg(). |
|
| 1346 | - * |
|
| 1347 | - * With this filter you can add, remove or change translated JS strings. |
|
| 1348 | - * You should add your own translations to this if you are building an addon rather than adding another script block. |
|
| 1349 | - * |
|
| 1350 | - * @since 1.0.0 |
|
| 1351 | - */ |
|
| 1352 | - $arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg);
|
|
| 1353 | - |
|
| 1354 | - foreach ($arr_alert_msg as $key => $value) {
|
|
| 1355 | - if (!is_scalar($value)) |
|
| 1356 | - continue; |
|
| 1357 | - $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8'); |
|
| 1358 | - } |
|
| 1341 | + 'geodir_map_name' => geodir_map_name(), |
|
| 1342 | + ); |
|
| 1343 | + |
|
| 1344 | + /** |
|
| 1345 | + * Filters the translated JS strings from function geodir_localize_all_js_msg(). |
|
| 1346 | + * |
|
| 1347 | + * With this filter you can add, remove or change translated JS strings. |
|
| 1348 | + * You should add your own translations to this if you are building an addon rather than adding another script block. |
|
| 1349 | + * |
|
| 1350 | + * @since 1.0.0 |
|
| 1351 | + */ |
|
| 1352 | + $arr_alert_msg = apply_filters('geodir_all_js_msg', $arr_alert_msg);
|
|
| 1359 | 1353 | |
| 1360 | - $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';'; |
|
| 1361 | - echo '<script>'; |
|
| 1362 | - echo $script; |
|
| 1363 | - echo '</script>'; |
|
| 1354 | + foreach ($arr_alert_msg as $key => $value) {
|
|
| 1355 | + if (!is_scalar($value)) |
|
| 1356 | + continue; |
|
| 1357 | + $arr_alert_msg[$key] = html_entity_decode((string)$value, ENT_QUOTES, 'UTF-8'); |
|
| 1358 | + } |
|
| 1359 | + |
|
| 1360 | + $script = "var geodir_all_js_msg = " . json_encode($arr_alert_msg) . ';'; |
|
| 1361 | + echo '<script>'; |
|
| 1362 | + echo $script; |
|
| 1363 | + echo '</script>'; |
|
| 1364 | 1364 | } |
| 1365 | 1365 | |
| 1366 | 1366 | add_action('admin_bar_menu', 'geodir_admin_bar_site_menu', 31);
|
@@ -1376,9 +1376,9 @@ discard block |
||
| 1376 | 1376 | */ |
| 1377 | 1377 | function geodir_admin_bar_site_menu($wp_admin_bar) |
| 1378 | 1378 | {
|
| 1379 | - if (get_option("geodir_installed")) {
|
|
| 1380 | - $wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'geodirectory', 'title' => __('GeoDirectory', 'geodirectory'), 'href' => admin_url('?page=geodirectory')));
|
|
| 1381 | - } |
|
| 1379 | + if (get_option("geodir_installed")) {
|
|
| 1380 | + $wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'geodirectory', 'title' => __('GeoDirectory', 'geodirectory'), 'href' => admin_url('?page=geodirectory')));
|
|
| 1381 | + } |
|
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | 1384 | add_action('geodir_before_listing', 'geodir_display_sort_options'); /*function in custom_functions.php*/
|
@@ -1404,25 +1404,25 @@ discard block |
||
| 1404 | 1404 | */ |
| 1405 | 1405 | function geodir_store_sidebars() |
| 1406 | 1406 | {
|
| 1407 | - global $geodir_sidebars; |
|
| 1408 | - global $sidebars_widgets; |
|
| 1409 | - |
|
| 1410 | - if (!is_array($sidebars_widgets)) |
|
| 1411 | - $sidebars_widgets = wp_get_sidebars_widgets(); |
|
| 1412 | - $geodir_old_sidebars = array(); |
|
| 1413 | - |
|
| 1414 | - if (is_array($geodir_sidebars)) {
|
|
| 1415 | - foreach ($geodir_sidebars as $val) {
|
|
| 1416 | - if (is_array($sidebars_widgets)) {
|
|
| 1417 | - if (array_key_exists($val, $sidebars_widgets)) |
|
| 1418 | - $geodir_old_sidebars[$val] = $sidebars_widgets[$val]; |
|
| 1419 | - else |
|
| 1420 | - $geodir_old_sidebars[$val] = array(); |
|
| 1421 | - } |
|
| 1422 | - } |
|
| 1423 | - } |
|
| 1424 | - update_option('geodir_sidebars', $geodir_old_sidebars);
|
|
| 1425 | - geodir_option_version_backup('geodir_sidebars');
|
|
| 1407 | + global $geodir_sidebars; |
|
| 1408 | + global $sidebars_widgets; |
|
| 1409 | + |
|
| 1410 | + if (!is_array($sidebars_widgets)) |
|
| 1411 | + $sidebars_widgets = wp_get_sidebars_widgets(); |
|
| 1412 | + $geodir_old_sidebars = array(); |
|
| 1413 | + |
|
| 1414 | + if (is_array($geodir_sidebars)) {
|
|
| 1415 | + foreach ($geodir_sidebars as $val) {
|
|
| 1416 | + if (is_array($sidebars_widgets)) {
|
|
| 1417 | + if (array_key_exists($val, $sidebars_widgets)) |
|
| 1418 | + $geodir_old_sidebars[$val] = $sidebars_widgets[$val]; |
|
| 1419 | + else |
|
| 1420 | + $geodir_old_sidebars[$val] = array(); |
|
| 1421 | + } |
|
| 1422 | + } |
|
| 1423 | + } |
|
| 1424 | + update_option('geodir_sidebars', $geodir_old_sidebars);
|
|
| 1425 | + geodir_option_version_backup('geodir_sidebars');
|
|
| 1426 | 1426 | |
| 1427 | 1427 | } |
| 1428 | 1428 | |
@@ -1436,34 +1436,34 @@ discard block |
||
| 1436 | 1436 | */ |
| 1437 | 1437 | function geodir_restore_sidebars() |
| 1438 | 1438 | {
|
| 1439 | - global $sidebars_widgets; |
|
| 1440 | - |
|
| 1441 | - if (!is_array($sidebars_widgets)) |
|
| 1442 | - $sidebars_widgets = wp_get_sidebars_widgets(); |
|
| 1443 | - |
|
| 1444 | - if (is_array($sidebars_widgets)) {
|
|
| 1445 | - $geodir_old_sidebars = get_option('geodir_sidebars');
|
|
| 1446 | - if (is_array($geodir_old_sidebars)) {
|
|
| 1447 | - foreach ($geodir_old_sidebars as $key => $val) {
|
|
| 1448 | - //if(array_key_exists($key, $sidebars_widgets)) |
|
| 1449 | - {
|
|
| 1450 | - $sidebars_widgets[$key] = $geodir_old_sidebars[$key]; |
|
| 1451 | - } |
|
| 1439 | + global $sidebars_widgets; |
|
| 1452 | 1440 | |
| 1441 | + if (!is_array($sidebars_widgets)) |
|
| 1442 | + $sidebars_widgets = wp_get_sidebars_widgets(); |
|
| 1453 | 1443 | |
| 1454 | - } |
|
| 1455 | - } |
|
| 1444 | + if (is_array($sidebars_widgets)) {
|
|
| 1445 | + $geodir_old_sidebars = get_option('geodir_sidebars');
|
|
| 1446 | + if (is_array($geodir_old_sidebars)) {
|
|
| 1447 | + foreach ($geodir_old_sidebars as $key => $val) {
|
|
| 1448 | + //if(array_key_exists($key, $sidebars_widgets)) |
|
| 1449 | + {
|
|
| 1450 | + $sidebars_widgets[$key] = $geodir_old_sidebars[$key]; |
|
| 1451 | + } |
|
| 1456 | 1452 | |
| 1457 | - // now clear all non geodiretory sidebars |
|
| 1458 | - foreach ($sidebars_widgets as $key => $val) {
|
|
| 1459 | - if (!array_key_exists($key, $geodir_old_sidebars)) {
|
|
| 1460 | - $sidebars_widgets[$key] = array(); |
|
| 1461 | - } |
|
| 1462 | - } |
|
| 1463 | - } |
|
| 1464 | 1453 | |
| 1465 | - update_option('sidebars_widgets', $sidebars_widgets);
|
|
| 1466 | - update_option('geodir_sidebars', '');
|
|
| 1454 | + } |
|
| 1455 | + } |
|
| 1456 | + |
|
| 1457 | + // now clear all non geodiretory sidebars |
|
| 1458 | + foreach ($sidebars_widgets as $key => $val) {
|
|
| 1459 | + if (!array_key_exists($key, $geodir_old_sidebars)) {
|
|
| 1460 | + $sidebars_widgets[$key] = array(); |
|
| 1461 | + } |
|
| 1462 | + } |
|
| 1463 | + } |
|
| 1464 | + |
|
| 1465 | + update_option('sidebars_widgets', $sidebars_widgets);
|
|
| 1466 | + update_option('geodir_sidebars', '');
|
|
| 1467 | 1467 | } |
| 1468 | 1468 | |
| 1469 | 1469 | add_action('geodir_after_listing_post_gridview', 'geodir_after_listing_post_gridview');
|
@@ -1476,9 +1476,9 @@ discard block |
||
| 1476 | 1476 | */ |
| 1477 | 1477 | function geodir_after_listing_post_gridview() |
| 1478 | 1478 | {
|
| 1479 | - global $gridview_columns; |
|
| 1479 | + global $gridview_columns; |
|
| 1480 | 1480 | |
| 1481 | - $gridview_columns = ''; |
|
| 1481 | + $gridview_columns = ''; |
|
| 1482 | 1482 | |
| 1483 | 1483 | } |
| 1484 | 1484 | |
@@ -1506,11 +1506,11 @@ discard block |
||
| 1506 | 1506 | */ |
| 1507 | 1507 | function so_handle_038($url, $original_url, $_context) |
| 1508 | 1508 | {
|
| 1509 | - if (strstr($url, "maps.google.com/maps/api/js") !== false) {
|
|
| 1510 | - $url = str_replace("&", "&", $url); // or $url = $original_url
|
|
| 1511 | - } |
|
| 1509 | + if (strstr($url, "maps.google.com/maps/api/js") !== false) {
|
|
| 1510 | + $url = str_replace("&", "&", $url); // or $url = $original_url
|
|
| 1511 | + } |
|
| 1512 | 1512 | |
| 1513 | - return $url; |
|
| 1513 | + return $url; |
|
| 1514 | 1514 | } |
| 1515 | 1515 | |
| 1516 | 1516 | |
@@ -1526,34 +1526,34 @@ discard block |
||
| 1526 | 1526 | function geodir_after_main_form_fields() {
|
| 1527 | 1527 | global $gd_session; |
| 1528 | 1528 | |
| 1529 | - if (get_option('geodir_accept_term_condition')) {
|
|
| 1530 | - global $post; |
|
| 1531 | - $term_condition = ''; |
|
| 1532 | - if (isset($_REQUEST['backandedit'])) {
|
|
| 1533 | - $post = (object)$gd_session->get('listing');
|
|
| 1534 | - $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : ''; |
|
| 1535 | - } |
|
| 1536 | - |
|
| 1537 | - ?> |
|
| 1529 | + if (get_option('geodir_accept_term_condition')) {
|
|
| 1530 | + global $post; |
|
| 1531 | + $term_condition = ''; |
|
| 1532 | + if (isset($_REQUEST['backandedit'])) {
|
|
| 1533 | + $post = (object)$gd_session->get('listing');
|
|
| 1534 | + $term_condition = isset($post->geodir_accept_term_condition) ? $post->geodir_accept_term_condition : ''; |
|
| 1535 | + } |
|
| 1536 | + |
|
| 1537 | + ?> |
|
| 1538 | 1538 | <div id="geodir_accept_term_condition_row" class="required_field geodir_form_row clearfix"> |
| 1539 | 1539 | <label> </label> |
| 1540 | 1540 | |
| 1541 | 1541 | <div class="geodir_taxonomy_field" style="float:left; width:70%;"> |
| 1542 | 1542 | <span style="display:block"> |
| 1543 | 1543 | <input class="main_list_selecter" type="checkbox" <?php if ($term_condition == '1') {
|
| 1544 | - echo 'checked="checked"'; |
|
| 1545 | - } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition" |
|
| 1544 | + echo 'checked="checked"'; |
|
| 1545 | + } ?> field_type="checkbox" name="geodir_accept_term_condition" id="geodir_accept_term_condition" |
|
| 1546 | 1546 | class="geodir_textfield" value="1" |
| 1547 | 1547 | style="display:inline-block"/><a href="<?php $terms_page = get_option('geodir_term_condition_page'); if($terms_page){ echo get_permalink($terms_page);}?>" target="_blank"><?php _e('Please accept our terms and conditions', 'geodirectory'); ?></a>
|
| 1548 | 1548 | </span> |
| 1549 | 1549 | </div> |
| 1550 | 1550 | <span class="geodir_message_error"><?php if (isset($required_msg)) {
|
| 1551 | - _e($required_msg, 'geodirectory'); |
|
| 1552 | - } ?></span> |
|
| 1551 | + _e($required_msg, 'geodirectory'); |
|
| 1552 | + } ?></span> |
|
| 1553 | 1553 | </div> |
| 1554 | 1554 | <?php |
| 1555 | 1555 | |
| 1556 | - } |
|
| 1556 | + } |
|
| 1557 | 1557 | } |
| 1558 | 1558 | |
| 1559 | 1559 | |
@@ -1578,42 +1578,42 @@ discard block |
||
| 1578 | 1578 | */ |
| 1579 | 1579 | function geodir_detail_page_tab_is_display($is_display, $tab) |
| 1580 | 1580 | {
|
| 1581 | - global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields; |
|
| 1581 | + global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields; |
|
| 1582 | 1582 | |
| 1583 | - if ($tab == 'post_profile') {
|
|
| 1584 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 1585 | - $desc_limit = apply_filters('geodir_description_field_desc_limit', '');
|
|
| 1583 | + if ($tab == 'post_profile') {
|
|
| 1584 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 1585 | + $desc_limit = apply_filters('geodir_description_field_desc_limit', '');
|
|
| 1586 | 1586 | |
| 1587 | - if (!($desc_limit === '' || (int)$desc_limit > 0)) {
|
|
| 1588 | - $is_display = false; |
|
| 1589 | - } |
|
| 1590 | - } |
|
| 1587 | + if (!($desc_limit === '' || (int)$desc_limit > 0)) {
|
|
| 1588 | + $is_display = false; |
|
| 1589 | + } |
|
| 1590 | + } |
|
| 1591 | 1591 | |
| 1592 | - if ($tab == 'post_info') |
|
| 1593 | - $is_display = (!empty($geodir_post_detail_fields)) ? true : false; |
|
| 1592 | + if ($tab == 'post_info') |
|
| 1593 | + $is_display = (!empty($geodir_post_detail_fields)) ? true : false; |
|
| 1594 | 1594 | |
| 1595 | - if ($tab == 'post_images') |
|
| 1596 | - $is_display = (!empty($post_images)) ? true : false; |
|
| 1595 | + if ($tab == 'post_images') |
|
| 1596 | + $is_display = (!empty($post_images)) ? true : false; |
|
| 1597 | 1597 | |
| 1598 | - if ($tab == 'post_video') |
|
| 1599 | - $is_display = (!empty($video)) ? true : false; |
|
| 1598 | + if ($tab == 'post_video') |
|
| 1599 | + $is_display = (!empty($video)) ? true : false; |
|
| 1600 | 1600 | |
| 1601 | - if ($tab == 'special_offers') |
|
| 1602 | - $is_display = (!empty($special_offers)) ? true : false; |
|
| 1601 | + if ($tab == 'special_offers') |
|
| 1602 | + $is_display = (!empty($special_offers)) ? true : false; |
|
| 1603 | 1603 | |
| 1604 | - if ($tab == 'reviews') |
|
| 1605 | - $is_display = (geodir_is_page('detail')) ? true : false;
|
|
| 1604 | + if ($tab == 'reviews') |
|
| 1605 | + $is_display = (geodir_is_page('detail')) ? true : false;
|
|
| 1606 | 1606 | |
| 1607 | - if ($tab == 'related_listing') {
|
|
| 1608 | - $message = __('No listings found which match your selection.', 'geodirectory');
|
|
| 1607 | + if ($tab == 'related_listing') {
|
|
| 1608 | + $message = __('No listings found which match your selection.', 'geodirectory');
|
|
| 1609 | 1609 | |
| 1610 | - /** This action is documented in geodirectory-functions/template_functions.php */ |
|
| 1611 | - $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false);
|
|
| 1610 | + /** This action is documented in geodirectory-functions/template_functions.php */ |
|
| 1611 | + $message = apply_filters('geodir_message_listing_not_found', $message, 'listing-listview', false);
|
|
| 1612 | 1612 | |
| 1613 | - $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true;
|
|
| 1614 | - } |
|
| 1613 | + $is_display = ((strpos($related_listing, $message) !== false || $related_listing == '' || !geodir_is_page('detail'))) ? false : true;
|
|
| 1614 | + } |
|
| 1615 | 1615 | |
| 1616 | - return $is_display; |
|
| 1616 | + return $is_display; |
|
| 1617 | 1617 | } |
| 1618 | 1618 | |
| 1619 | 1619 | |
@@ -1629,69 +1629,69 @@ discard block |
||
| 1629 | 1629 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
| 1630 | 1630 | */ |
| 1631 | 1631 | function geodir_changes_in_custom_fields_table() {
|
| 1632 | - global $wpdb, $plugin_prefix; |
|
| 1632 | + global $wpdb, $plugin_prefix; |
|
| 1633 | 1633 | |
| 1634 | 1634 | // Remove unused virtual page |
| 1635 | 1635 | $listings_page_id = (int)get_option('geodir_listing_page');
|
| 1636 | 1636 | if ($listings_page_id) {
|
| 1637 | 1637 | $wpdb->query($wpdb->prepare("DELETE FROM " . $wpdb->posts . " WHERE ID=%d AND post_name = %s AND post_type=%s", array($listings_page_id, 'listings', 'page')));
|
| 1638 | - delete_option('geodir_listing_page');
|
|
| 1638 | + delete_option('geodir_listing_page');
|
|
| 1639 | 1639 | } |
| 1640 | 1640 | |
| 1641 | - if (!get_option('geodir_changes_in_custom_fields_table')) {
|
|
| 1642 | - $wpdb->query( |
|
| 1643 | - $wpdb->prepare( |
|
| 1644 | - "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s", |
|
| 1645 | - array('1', '1', 'admin')
|
|
| 1646 | - ) |
|
| 1647 | - ); |
|
| 1641 | + if (!get_option('geodir_changes_in_custom_fields_table')) {
|
|
| 1642 | + $wpdb->query( |
|
| 1643 | + $wpdb->prepare( |
|
| 1644 | + "UPDATE " . GEODIR_CUSTOM_FIELDS_TABLE . " SET is_default=%s, is_admin=%s WHERE is_default=%s", |
|
| 1645 | + array('1', '1', 'admin')
|
|
| 1646 | + ) |
|
| 1647 | + ); |
|
| 1648 | 1648 | |
| 1649 | 1649 | |
| 1650 | - /* --- terms meta value set --- */ |
|
| 1650 | + /* --- terms meta value set --- */ |
|
| 1651 | 1651 | |
| 1652 | - update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png');
|
|
| 1652 | + update_option('geodir_default_marker_icon', geodir_plugin_url() . '/geodirectory-functions/map-functions/icons/pin.png');
|
|
| 1653 | 1653 | |
| 1654 | - $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%')));
|
|
| 1654 | + $options_data = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . "options WHERE option_name LIKE %s", array('%tax_meta_%')));
|
|
| 1655 | 1655 | |
| 1656 | - if (!empty($options_data)) {
|
|
| 1656 | + if (!empty($options_data)) {
|
|
| 1657 | 1657 | |
| 1658 | - foreach ($options_data as $optobj) {
|
|
| 1658 | + foreach ($options_data as $optobj) {
|
|
| 1659 | 1659 | |
| 1660 | - $option_val = str_replace('tax_meta_', '', $optobj->option_name);
|
|
| 1660 | + $option_val = str_replace('tax_meta_', '', $optobj->option_name);
|
|
| 1661 | 1661 | |
| 1662 | - $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val)));
|
|
| 1662 | + $taxonomies_data = $wpdb->get_results($wpdb->prepare("SELECT taxonomy FROM " . $wpdb->prefix . "term_taxonomy WHERE taxonomy LIKE %s AND term_id=%d", array('%category%', $option_val)));
|
|
| 1663 | 1663 | |
| 1664 | - if (!empty($taxonomies_data)) {
|
|
| 1664 | + if (!empty($taxonomies_data)) {
|
|
| 1665 | 1665 | |
| 1666 | - foreach ($taxonomies_data as $taxobj) {
|
|
| 1666 | + foreach ($taxonomies_data as $taxobj) {
|
|
| 1667 | 1667 | |
| 1668 | - $taxObject = get_taxonomy($taxobj->taxonomy); |
|
| 1669 | - $post_type = $taxObject->object_type[0]; |
|
| 1668 | + $taxObject = get_taxonomy($taxobj->taxonomy); |
|
| 1669 | + $post_type = $taxObject->object_type[0]; |
|
| 1670 | 1670 | |
| 1671 | - $opt_value = 'tax_meta_' . $post_type . '_' . $option_val; |
|
| 1671 | + $opt_value = 'tax_meta_' . $post_type . '_' . $option_val; |
|
| 1672 | 1672 | |
| 1673 | - $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val)));
|
|
| 1673 | + $duplicate_data = $wpdb->get_var($wpdb->prepare("SELECT option_id FROM " . $wpdb->prefix . "options WHERE option_name=%s", array('tax_meta_' . $option_val)));
|
|
| 1674 | 1674 | |
| 1675 | - if ($duplicate_data) {
|
|
| 1675 | + if ($duplicate_data) {
|
|
| 1676 | 1676 | |
| 1677 | - $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id)));
|
|
| 1677 | + $wpdb->query($wpdb->prepare("UPDATE " . $wpdb->prefix . "options SET option_name=%s WHERE option_id=%d", array($opt_value, $optobj->option_id)));
|
|
| 1678 | 1678 | |
| 1679 | - } else {
|
|
| 1679 | + } else {
|
|
| 1680 | 1680 | |
| 1681 | - $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload)));
|
|
| 1681 | + $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "options (option_name,option_value,autoload) VALUES (%s, %s, %s)", array($opt_value, $optobj->option_value, $optobj->autoload)));
|
|
| 1682 | 1682 | |
| 1683 | - } |
|
| 1683 | + } |
|
| 1684 | 1684 | |
| 1685 | - } |
|
| 1685 | + } |
|
| 1686 | 1686 | |
| 1687 | - } |
|
| 1687 | + } |
|
| 1688 | 1688 | |
| 1689 | - } |
|
| 1690 | - } |
|
| 1689 | + } |
|
| 1690 | + } |
|
| 1691 | 1691 | |
| 1692 | - update_option('geodir_changes_in_custom_fields_table', '1');
|
|
| 1692 | + update_option('geodir_changes_in_custom_fields_table', '1');
|
|
| 1693 | 1693 | |
| 1694 | - } |
|
| 1694 | + } |
|
| 1695 | 1695 | |
| 1696 | 1696 | } |
| 1697 | 1697 | |
@@ -1710,24 +1710,24 @@ discard block |
||
| 1710 | 1710 | function geodir_location_slug_check($slug) |
| 1711 | 1711 | {
|
| 1712 | 1712 | |
| 1713 | - global $wpdb, $table_prefix; |
|
| 1713 | + global $wpdb, $table_prefix; |
|
| 1714 | 1714 | |
| 1715 | - $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug)));
|
|
| 1715 | + $slug_exists = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($slug)));
|
|
| 1716 | 1716 | |
| 1717 | - if ($slug_exists) {
|
|
| 1717 | + if ($slug_exists) {
|
|
| 1718 | 1718 | |
| 1719 | - $suffix = 1; |
|
| 1720 | - do {
|
|
| 1721 | - $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix"; |
|
| 1722 | - $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name)));
|
|
| 1723 | - $suffix++; |
|
| 1724 | - } while ($location_slug_check && $suffix < 100); |
|
| 1719 | + $suffix = 1; |
|
| 1720 | + do {
|
|
| 1721 | + $alt_location_name = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix"; |
|
| 1722 | + $location_slug_check = $wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s", array($alt_location_name)));
|
|
| 1723 | + $suffix++; |
|
| 1724 | + } while ($location_slug_check && $suffix < 100); |
|
| 1725 | 1725 | |
| 1726 | - $slug = $alt_location_name; |
|
| 1726 | + $slug = $alt_location_name; |
|
| 1727 | 1727 | |
| 1728 | - } |
|
| 1728 | + } |
|
| 1729 | 1729 | |
| 1730 | - return $slug; |
|
| 1730 | + return $slug; |
|
| 1731 | 1731 | |
| 1732 | 1732 | } |
| 1733 | 1733 | |
@@ -1752,42 +1752,42 @@ discard block |
||
| 1752 | 1752 | function geodir_update_term_slug($term_id, $tt_id, $taxonomy) |
| 1753 | 1753 | {
|
| 1754 | 1754 | |
| 1755 | - global $wpdb, $plugin_prefix, $table_prefix; |
|
| 1755 | + global $wpdb, $plugin_prefix, $table_prefix; |
|
| 1756 | 1756 | |
| 1757 | - $tern_data = get_term_by('id', $term_id, $taxonomy);
|
|
| 1757 | + $tern_data = get_term_by('id', $term_id, $taxonomy);
|
|
| 1758 | 1758 | |
| 1759 | - $slug = $tern_data->slug; |
|
| 1759 | + $slug = $tern_data->slug; |
|
| 1760 | 1760 | |
| 1761 | - /** |
|
| 1762 | - * Filter if a term slug exists. |
|
| 1763 | - * |
|
| 1764 | - * @since 1.0.0 |
|
| 1765 | - * @package GeoDirectory |
|
| 1766 | - * @param bool $bool Default: false. |
|
| 1767 | - * @param string $slug The term slug. |
|
| 1768 | - * @param int $term_id The term ID. |
|
| 1769 | - */ |
|
| 1770 | - $slug_exists = apply_filters('geodir_term_slug_is_exists', false, $slug, $term_id);
|
|
| 1761 | + /** |
|
| 1762 | + * Filter if a term slug exists. |
|
| 1763 | + * |
|
| 1764 | + * @since 1.0.0 |
|
| 1765 | + * @package GeoDirectory |
|
| 1766 | + * @param bool $bool Default: false. |
|
| 1767 | + * @param string $slug The term slug. |
|
| 1768 | + * @param int $term_id The term ID. |
|
| 1769 | + */ |
|
| 1770 | + $slug_exists = apply_filters('geodir_term_slug_is_exists', false, $slug, $term_id);
|
|
| 1771 | 1771 | |
| 1772 | - if ($slug_exists) {
|
|
| 1772 | + if ($slug_exists) {
|
|
| 1773 | 1773 | |
| 1774 | - $suffix = 1; |
|
| 1775 | - do {
|
|
| 1776 | - $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix"; |
|
| 1774 | + $suffix = 1; |
|
| 1775 | + do {
|
|
| 1776 | + $new_slug = _truncate_post_slug($slug, 200 - (strlen($suffix) + 1)) . "-$suffix"; |
|
| 1777 | 1777 | |
| 1778 | - /** This action is documented in geodirectory_hooks_actions.php */ |
|
| 1779 | - $term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id);
|
|
| 1778 | + /** This action is documented in geodirectory_hooks_actions.php */ |
|
| 1779 | + $term_slug_check = apply_filters('geodir_term_slug_is_exists', false, $new_slug, $term_id);
|
|
| 1780 | 1780 | |
| 1781 | - $suffix++; |
|
| 1782 | - } while ($term_slug_check && $suffix < 100); |
|
| 1781 | + $suffix++; |
|
| 1782 | + } while ($term_slug_check && $suffix < 100); |
|
| 1783 | 1783 | |
| 1784 | - $slug = $new_slug; |
|
| 1784 | + $slug = $new_slug; |
|
| 1785 | 1785 | |
| 1786 | - //wp_update_term( $term_id, $taxonomy, array('slug' => $slug) );
|
|
| 1786 | + //wp_update_term( $term_id, $taxonomy, array('slug' => $slug) );
|
|
| 1787 | 1787 | |
| 1788 | - $wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id)));
|
|
| 1788 | + $wpdb->query($wpdb->prepare("UPDATE " . $table_prefix . "terms SET slug=%s WHERE term_id=%d", array($slug, $term_id)));
|
|
| 1789 | 1789 | |
| 1790 | - } |
|
| 1790 | + } |
|
| 1791 | 1791 | |
| 1792 | 1792 | // Update tag in detail table. |
| 1793 | 1793 | $taxonomy_obj = get_taxonomy($taxonomy); |
@@ -1828,21 +1828,21 @@ discard block |
||
| 1828 | 1828 | function geodir_term_slug_is_exists($slug_exists, $slug, $term_id) |
| 1829 | 1829 | {
|
| 1830 | 1830 | |
| 1831 | - global $wpdb, $table_prefix; |
|
| 1831 | + global $wpdb, $table_prefix; |
|
| 1832 | 1832 | |
| 1833 | - $default_location = geodir_get_default_location(); |
|
| 1833 | + $default_location = geodir_get_default_location(); |
|
| 1834 | 1834 | |
| 1835 | - $country_slug = $default_location->country_slug; |
|
| 1836 | - $region_slug = $default_location->region_slug; |
|
| 1837 | - $city_slug = $default_location->city_slug; |
|
| 1835 | + $country_slug = $default_location->country_slug; |
|
| 1836 | + $region_slug = $default_location->region_slug; |
|
| 1837 | + $city_slug = $default_location->city_slug; |
|
| 1838 | 1838 | |
| 1839 | - if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug) |
|
| 1840 | - return $slug_exists = true; |
|
| 1839 | + if ($country_slug == $slug || $region_slug == $slug || $city_slug == $slug) |
|
| 1840 | + return $slug_exists = true; |
|
| 1841 | 1841 | |
| 1842 | - if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
|
|
| 1843 | - return $slug_exists = true; |
|
| 1842 | + if ($wpdb->get_var($wpdb->prepare("SELECT slug FROM " . $table_prefix . "terms WHERE slug=%s AND term_id != %d", array($slug, $term_id))))
|
|
| 1843 | + return $slug_exists = true; |
|
| 1844 | 1844 | |
| 1845 | - return $slug_exists; |
|
| 1845 | + return $slug_exists; |
|
| 1846 | 1846 | } |
| 1847 | 1847 | |
| 1848 | 1848 | |
@@ -1861,75 +1861,75 @@ discard block |
||
| 1861 | 1861 | */ |
| 1862 | 1862 | function geodir_custom_page_title($title = '', $sep = '') |
| 1863 | 1863 | {
|
| 1864 | - global $wp; |
|
| 1865 | - if (class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) {
|
|
| 1866 | - return $title; |
|
| 1867 | - } |
|
| 1864 | + global $wp; |
|
| 1865 | + if (class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) {
|
|
| 1866 | + return $title; |
|
| 1867 | + } |
|
| 1868 | 1868 | |
| 1869 | - if ($sep == '') {
|
|
| 1870 | - /** |
|
| 1871 | - * Filter the page title separator. |
|
| 1872 | - * |
|
| 1873 | - * @since 1.0.0 |
|
| 1874 | - * @package GeoDirectory |
|
| 1875 | - * @param string $sep The separator, default: `|`. |
|
| 1876 | - */ |
|
| 1877 | - $sep = apply_filters('geodir_page_title_separator', '|');
|
|
| 1878 | - } |
|
| 1869 | + if ($sep == '') {
|
|
| 1870 | + /** |
|
| 1871 | + * Filter the page title separator. |
|
| 1872 | + * |
|
| 1873 | + * @since 1.0.0 |
|
| 1874 | + * @package GeoDirectory |
|
| 1875 | + * @param string $sep The separator, default: `|`. |
|
| 1876 | + */ |
|
| 1877 | + $sep = apply_filters('geodir_page_title_separator', '|');
|
|
| 1878 | + } |
|
| 1879 | 1879 | |
| 1880 | 1880 | |
| 1881 | - $gd_page = ''; |
|
| 1882 | - if(geodir_is_page('home')){
|
|
| 1883 | - $gd_page = 'home'; |
|
| 1884 | - $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
|
|
| 1885 | - } |
|
| 1886 | - elseif(geodir_is_page('detail')){
|
|
| 1887 | - $gd_page = 'detail'; |
|
| 1888 | - $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
|
|
| 1889 | - } |
|
| 1890 | - elseif(geodir_is_page('pt')){
|
|
| 1891 | - $gd_page = 'pt'; |
|
| 1892 | - $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
|
|
| 1893 | - } |
|
| 1894 | - elseif(geodir_is_page('listing')){
|
|
| 1895 | - $gd_page = 'listing'; |
|
| 1896 | - $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
|
|
| 1897 | - } |
|
| 1898 | - elseif(geodir_is_page('location')){
|
|
| 1899 | - $gd_page = 'location'; |
|
| 1900 | - $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
|
|
| 1901 | - } |
|
| 1902 | - elseif(geodir_is_page('search')){
|
|
| 1903 | - $gd_page = 'search'; |
|
| 1904 | - $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
|
|
| 1905 | - } |
|
| 1906 | - elseif(geodir_is_page('add-listing')){
|
|
| 1907 | - $gd_page = 'add-listing'; |
|
| 1908 | - $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
|
|
| 1909 | - } |
|
| 1910 | - elseif(geodir_is_page('author')){
|
|
| 1911 | - $gd_page = 'author'; |
|
| 1912 | - $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
|
|
| 1913 | - } |
|
| 1914 | - elseif(geodir_is_page('login')){
|
|
| 1915 | - $gd_page = 'login'; |
|
| 1916 | - $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
|
|
| 1917 | - } |
|
| 1918 | - elseif(geodir_is_page('listing-success')){
|
|
| 1919 | - $gd_page = 'listing-success'; |
|
| 1920 | - $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
|
|
| 1921 | - } |
|
| 1881 | + $gd_page = ''; |
|
| 1882 | + if(geodir_is_page('home')){
|
|
| 1883 | + $gd_page = 'home'; |
|
| 1884 | + $title = (get_option('geodir_meta_title_homepage')) ? get_option('geodir_meta_title_homepage') : $title;
|
|
| 1885 | + } |
|
| 1886 | + elseif(geodir_is_page('detail')){
|
|
| 1887 | + $gd_page = 'detail'; |
|
| 1888 | + $title = (get_option('geodir_meta_title_detail')) ? get_option('geodir_meta_title_detail') : $title;
|
|
| 1889 | + } |
|
| 1890 | + elseif(geodir_is_page('pt')){
|
|
| 1891 | + $gd_page = 'pt'; |
|
| 1892 | + $title = (get_option('geodir_meta_title_pt')) ? get_option('geodir_meta_title_pt') : $title;
|
|
| 1893 | + } |
|
| 1894 | + elseif(geodir_is_page('listing')){
|
|
| 1895 | + $gd_page = 'listing'; |
|
| 1896 | + $title = (get_option('geodir_meta_title_listing')) ? get_option('geodir_meta_title_listing') : $title;
|
|
| 1897 | + } |
|
| 1898 | + elseif(geodir_is_page('location')){
|
|
| 1899 | + $gd_page = 'location'; |
|
| 1900 | + $title = (get_option('geodir_meta_title_location')) ? get_option('geodir_meta_title_location') : $title;
|
|
| 1901 | + } |
|
| 1902 | + elseif(geodir_is_page('search')){
|
|
| 1903 | + $gd_page = 'search'; |
|
| 1904 | + $title = (get_option('geodir_meta_title_search')) ? get_option('geodir_meta_title_search') : $title;
|
|
| 1905 | + } |
|
| 1906 | + elseif(geodir_is_page('add-listing')){
|
|
| 1907 | + $gd_page = 'add-listing'; |
|
| 1908 | + $title = (get_option('geodir_meta_title_add-listing')) ? get_option('geodir_meta_title_add-listing') : $title;
|
|
| 1909 | + } |
|
| 1910 | + elseif(geodir_is_page('author')){
|
|
| 1911 | + $gd_page = 'author'; |
|
| 1912 | + $title = (get_option('geodir_meta_title_author')) ? get_option('geodir_meta_title_author') : $title;
|
|
| 1913 | + } |
|
| 1914 | + elseif(geodir_is_page('login')){
|
|
| 1915 | + $gd_page = 'login'; |
|
| 1916 | + $title = (get_option('geodir_meta_title_login')) ? get_option('geodir_meta_title_login') : $title;
|
|
| 1917 | + } |
|
| 1918 | + elseif(geodir_is_page('listing-success')){
|
|
| 1919 | + $gd_page = 'listing-success'; |
|
| 1920 | + $title = (get_option('geodir_meta_title_listing-success')) ? get_option('geodir_meta_title_listing-success') : $title;
|
|
| 1921 | + } |
|
| 1922 | 1922 | |
| 1923 | 1923 | |
| 1924 | - /** |
|
| 1925 | - * Filter page meta title to replace variables. |
|
| 1926 | - * |
|
| 1927 | - * @since 1.5.4 |
|
| 1928 | - * @param string $title The page title including variables. |
|
| 1929 | - * @param string $gd_page The GeoDirectory page type if any. |
|
| 1930 | - * @param string $sep The title separator symbol. |
|
| 1931 | - */ |
|
| 1932 | - return apply_filters('geodir_seo_meta_title', __($title, 'geodirectory'), $gd_page, $sep);
|
|
| 1924 | + /** |
|
| 1925 | + * Filter page meta title to replace variables. |
|
| 1926 | + * |
|
| 1927 | + * @since 1.5.4 |
|
| 1928 | + * @param string $title The page title including variables. |
|
| 1929 | + * @param string $gd_page The GeoDirectory page type if any. |
|
| 1930 | + * @param string $sep The title separator symbol. |
|
| 1931 | + */ |
|
| 1932 | + return apply_filters('geodir_seo_meta_title', __($title, 'geodirectory'), $gd_page, $sep);
|
|
| 1933 | 1933 | |
| 1934 | 1934 | } |
| 1935 | 1935 | |
@@ -1945,33 +1945,33 @@ discard block |
||
| 1945 | 1945 | function geodir_set_post_attachment() |
| 1946 | 1946 | {
|
| 1947 | 1947 | |
| 1948 | - if (!get_option('geodir_set_post_attachments')) {
|
|
| 1948 | + if (!get_option('geodir_set_post_attachments')) {
|
|
| 1949 | 1949 | |
| 1950 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 1951 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 1950 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 1951 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 1952 | 1952 | |
| 1953 | - $all_postypes = geodir_get_posttypes(); |
|
| 1953 | + $all_postypes = geodir_get_posttypes(); |
|
| 1954 | 1954 | |
| 1955 | - $args = array( |
|
| 1956 | - 'posts_per_page' => -1, |
|
| 1957 | - 'post_type' => $all_postypes, |
|
| 1958 | - 'post_status' => 'publish'); |
|
| 1955 | + $args = array( |
|
| 1956 | + 'posts_per_page' => -1, |
|
| 1957 | + 'post_type' => $all_postypes, |
|
| 1958 | + 'post_status' => 'publish'); |
|
| 1959 | 1959 | |
| 1960 | - $posts_array = get_posts($args); |
|
| 1960 | + $posts_array = get_posts($args); |
|
| 1961 | 1961 | |
| 1962 | - if (!empty($posts_array)) {
|
|
| 1962 | + if (!empty($posts_array)) {
|
|
| 1963 | 1963 | |
| 1964 | - foreach ($posts_array as $post) {
|
|
| 1964 | + foreach ($posts_array as $post) {
|
|
| 1965 | 1965 | |
| 1966 | - geodir_set_wp_featured_image($post->ID); |
|
| 1966 | + geodir_set_wp_featured_image($post->ID); |
|
| 1967 | 1967 | |
| 1968 | - } |
|
| 1968 | + } |
|
| 1969 | 1969 | |
| 1970 | - } |
|
| 1970 | + } |
|
| 1971 | 1971 | |
| 1972 | - update_option('geodir_set_post_attachments', '1');
|
|
| 1972 | + update_option('geodir_set_post_attachments', '1');
|
|
| 1973 | 1973 | |
| 1974 | - } |
|
| 1974 | + } |
|
| 1975 | 1975 | |
| 1976 | 1976 | } |
| 1977 | 1977 | |
@@ -1988,19 +1988,19 @@ discard block |
||
| 1988 | 1988 | function geodir_remove_url_seperator() |
| 1989 | 1989 | {
|
| 1990 | 1990 | |
| 1991 | - if (!get_option('geodir_remove_url_seperator')) {
|
|
| 1991 | + if (!get_option('geodir_remove_url_seperator')) {
|
|
| 1992 | 1992 | |
| 1993 | - if (get_option('geodir_listingurl_separator'))
|
|
| 1994 | - delete_option('geodir_listingurl_separator');
|
|
| 1993 | + if (get_option('geodir_listingurl_separator'))
|
|
| 1994 | + delete_option('geodir_listingurl_separator');
|
|
| 1995 | 1995 | |
| 1996 | - if (get_option('geodir_detailurl_separator'))
|
|
| 1997 | - delete_option('geodir_detailurl_separator');
|
|
| 1996 | + if (get_option('geodir_detailurl_separator'))
|
|
| 1997 | + delete_option('geodir_detailurl_separator');
|
|
| 1998 | 1998 | |
| 1999 | - flush_rewrite_rules(false); |
|
| 1999 | + flush_rewrite_rules(false); |
|
| 2000 | 2000 | |
| 2001 | - update_option('geodir_remove_url_seperator', '1');
|
|
| 2001 | + update_option('geodir_remove_url_seperator', '1');
|
|
| 2002 | 2002 | |
| 2003 | - } |
|
| 2003 | + } |
|
| 2004 | 2004 | |
| 2005 | 2005 | } |
| 2006 | 2006 | |
@@ -2016,19 +2016,19 @@ discard block |
||
| 2016 | 2016 | */ |
| 2017 | 2017 | function geodir_remove_url_seperator_form_permalink_settings($permalink_arr) |
| 2018 | 2018 | {
|
| 2019 | - foreach ($permalink_arr as $key => $value) {
|
|
| 2019 | + foreach ($permalink_arr as $key => $value) {
|
|
| 2020 | 2020 | |
| 2021 | - if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator') |
|
| 2022 | - unset($permalink_arr[$key]); |
|
| 2021 | + if ($value['id'] == 'geodir_listingurl_separator' || $value['id'] == 'geodir_detailurl_separator') |
|
| 2022 | + unset($permalink_arr[$key]); |
|
| 2023 | 2023 | |
| 2024 | - } |
|
| 2024 | + } |
|
| 2025 | 2025 | |
| 2026 | - return $permalink_arr; |
|
| 2026 | + return $permalink_arr; |
|
| 2027 | 2027 | |
| 2028 | 2028 | } |
| 2029 | 2029 | |
| 2030 | 2030 | if (!is_admin()) {
|
| 2031 | - add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post');
|
|
| 2031 | + add_filter('posts_results', 'geodir_set_status_draft_to_publish_for_own_post');
|
|
| 2032 | 2032 | } |
| 2033 | 2033 | /** |
| 2034 | 2034 | * Set status from draft to publish. |
@@ -2041,13 +2041,13 @@ discard block |
||
| 2041 | 2041 | */ |
| 2042 | 2042 | function geodir_set_status_draft_to_publish_for_own_post($post) |
| 2043 | 2043 | {
|
| 2044 | - global $wp; |
|
| 2045 | - $user_id = get_current_user_id(); |
|
| 2044 | + global $wp; |
|
| 2045 | + $user_id = get_current_user_id(); |
|
| 2046 | 2046 | |
| 2047 | - if (!empty($post) && $post[0]->post_author == $user_id) {
|
|
| 2048 | - $post[0]->post_status = 'publish'; |
|
| 2049 | - } |
|
| 2050 | - return $post; |
|
| 2047 | + if (!empty($post) && $post[0]->post_author == $user_id) {
|
|
| 2048 | + $post[0]->post_status = 'publish'; |
|
| 2049 | + } |
|
| 2050 | + return $post; |
|
| 2051 | 2051 | } |
| 2052 | 2052 | |
| 2053 | 2053 | |
@@ -2139,33 +2139,33 @@ discard block |
||
| 2139 | 2139 | */ |
| 2140 | 2140 | function geodir_detail_page_tab_headings_change($tabs_arr) |
| 2141 | 2141 | {
|
| 2142 | - global $wpdb; |
|
| 2142 | + global $wpdb; |
|
| 2143 | 2143 | |
| 2144 | - $post_type = geodir_get_current_posttype(); |
|
| 2144 | + $post_type = geodir_get_current_posttype(); |
|
| 2145 | 2145 | |
| 2146 | - $all_postypes = geodir_get_posttypes(); |
|
| 2146 | + $all_postypes = geodir_get_posttypes(); |
|
| 2147 | 2147 | |
| 2148 | - if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) {
|
|
| 2148 | + if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes)) {
|
|
| 2149 | 2149 | |
| 2150 | - if (array_key_exists('post_video', $tabs_arr)) {
|
|
| 2150 | + if (array_key_exists('post_video', $tabs_arr)) {
|
|
| 2151 | 2151 | |
| 2152 | - $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
|
|
| 2152 | + $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_video', $post_type)));
|
|
| 2153 | 2153 | |
| 2154 | - if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '') |
|
| 2155 | - $tabs_arr['post_video']['heading_text'] = $field_title; |
|
| 2156 | - } |
|
| 2154 | + if (isset($tabs_arr['post_video']['heading_text']) && $field_title != '') |
|
| 2155 | + $tabs_arr['post_video']['heading_text'] = $field_title; |
|
| 2156 | + } |
|
| 2157 | 2157 | |
| 2158 | - if (array_key_exists('special_offers', $tabs_arr)) {
|
|
| 2158 | + if (array_key_exists('special_offers', $tabs_arr)) {
|
|
| 2159 | 2159 | |
| 2160 | - $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
|
|
| 2160 | + $field_title = $wpdb->get_var($wpdb->prepare("select site_title from " . GEODIR_CUSTOM_FIELDS_TABLE . " where htmlvar_name = %s and post_type = %s ", array('geodir_special_offers', $post_type)));
|
|
| 2161 | 2161 | |
| 2162 | - if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '') |
|
| 2163 | - $tabs_arr['special_offers']['heading_text'] = $field_title; |
|
| 2164 | - } |
|
| 2162 | + if (isset($tabs_arr['special_offers']['heading_text']) && $field_title != '') |
|
| 2163 | + $tabs_arr['special_offers']['heading_text'] = $field_title; |
|
| 2164 | + } |
|
| 2165 | 2165 | |
| 2166 | - } |
|
| 2166 | + } |
|
| 2167 | 2167 | |
| 2168 | - return $tabs_arr; |
|
| 2168 | + return $tabs_arr; |
|
| 2169 | 2169 | |
| 2170 | 2170 | } |
| 2171 | 2171 | |
@@ -2178,10 +2178,10 @@ discard block |
||
| 2178 | 2178 | */ |
| 2179 | 2179 | function geodir_remove_template_redirect_actions() |
| 2180 | 2180 | {
|
| 2181 | - if (geodir_is_page('login')){
|
|
| 2182 | - remove_all_actions('template_redirect');
|
|
| 2183 | - remove_action('init', 'avia_modify_front', 10);
|
|
| 2184 | - } |
|
| 2181 | + if (geodir_is_page('login')){
|
|
| 2182 | + remove_all_actions('template_redirect');
|
|
| 2183 | + remove_action('init', 'avia_modify_front', 10);
|
|
| 2184 | + } |
|
| 2185 | 2185 | } |
| 2186 | 2186 | |
| 2187 | 2187 | |
@@ -2203,51 +2203,51 @@ discard block |
||
| 2203 | 2203 | function geodirectory_before_featured_image_delete($attachment_id) |
| 2204 | 2204 | {
|
| 2205 | 2205 | |
| 2206 | - global $wpdb, $plugin_prefix; |
|
| 2206 | + global $wpdb, $plugin_prefix; |
|
| 2207 | 2207 | |
| 2208 | - $post_id = get_post_field('post_parent', $attachment_id);
|
|
| 2208 | + $post_id = get_post_field('post_parent', $attachment_id);
|
|
| 2209 | 2209 | |
| 2210 | - $attachment_url = wp_get_attachment_url($attachment_id); |
|
| 2210 | + $attachment_url = wp_get_attachment_url($attachment_id); |
|
| 2211 | 2211 | |
| 2212 | - if ($post_id > 0 && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete')) {
|
|
| 2212 | + if ($post_id > 0 && (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete')) {
|
|
| 2213 | 2213 | |
| 2214 | - $post_type = get_post_type($post_id); |
|
| 2214 | + $post_type = get_post_type($post_id); |
|
| 2215 | 2215 | |
| 2216 | - $all_postypes = geodir_get_posttypes(); |
|
| 2216 | + $all_postypes = geodir_get_posttypes(); |
|
| 2217 | 2217 | |
| 2218 | - if (!in_array($post_type, $all_postypes) || !is_admin()) |
|
| 2219 | - return false; |
|
| 2218 | + if (!in_array($post_type, $all_postypes) || !is_admin()) |
|
| 2219 | + return false; |
|
| 2220 | 2220 | |
| 2221 | - $uploads = wp_upload_dir(); |
|
| 2221 | + $uploads = wp_upload_dir(); |
|
| 2222 | 2222 | |
| 2223 | - $split_img_path = explode($uploads['baseurl'], $attachment_url); |
|
| 2223 | + $split_img_path = explode($uploads['baseurl'], $attachment_url); |
|
| 2224 | 2224 | |
| 2225 | - $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
|
| 2225 | + $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
|
| 2226 | 2226 | |
| 2227 | - $wpdb->query( |
|
| 2228 | - $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ",
|
|
| 2229 | - array($post_id, $split_img_file_path) |
|
| 2230 | - ) |
|
| 2231 | - ); |
|
| 2227 | + $wpdb->query( |
|
| 2228 | + $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d AND file=%s ",
|
|
| 2229 | + array($post_id, $split_img_file_path) |
|
| 2230 | + ) |
|
| 2231 | + ); |
|
| 2232 | 2232 | |
| 2233 | - $attachment_data = $wpdb->get_row( |
|
| 2234 | - $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d",
|
|
| 2235 | - array($post_id) |
|
| 2236 | - ) |
|
| 2237 | - ); |
|
| 2233 | + $attachment_data = $wpdb->get_row( |
|
| 2234 | + $wpdb->prepare("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=%d",
|
|
| 2235 | + array($post_id) |
|
| 2236 | + ) |
|
| 2237 | + ); |
|
| 2238 | 2238 | |
| 2239 | - if (!empty($attachment_data)) {
|
|
| 2240 | - $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
|
|
| 2241 | - } |
|
| 2239 | + if (!empty($attachment_data)) {
|
|
| 2240 | + $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
|
|
| 2241 | + } |
|
| 2242 | 2242 | |
| 2243 | 2243 | |
| 2244 | - $table_name = $plugin_prefix . $post_type . '_detail'; |
|
| 2244 | + $table_name = $plugin_prefix . $post_type . '_detail'; |
|
| 2245 | 2245 | |
| 2246 | - $wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id);
|
|
| 2246 | + $wpdb->query("UPDATE " . $table_name . " SET featured_image='' WHERE post_id =" . $post_id);
|
|
| 2247 | 2247 | |
| 2248 | - geodir_set_wp_featured_image($post_id); |
|
| 2248 | + geodir_set_wp_featured_image($post_id); |
|
| 2249 | 2249 | |
| 2250 | - } |
|
| 2250 | + } |
|
| 2251 | 2251 | |
| 2252 | 2252 | } |
| 2253 | 2253 | |
@@ -2265,79 +2265,79 @@ discard block |
||
| 2265 | 2265 | function geodir_temp_set_post_attachment() |
| 2266 | 2266 | {
|
| 2267 | 2267 | |
| 2268 | - global $wpdb, $plugin_prefix; |
|
| 2268 | + global $wpdb, $plugin_prefix; |
|
| 2269 | 2269 | |
| 2270 | - $all_postypes = geodir_get_posttypes(); |
|
| 2270 | + $all_postypes = geodir_get_posttypes(); |
|
| 2271 | 2271 | |
| 2272 | - foreach ($all_postypes as $posttype) {
|
|
| 2272 | + foreach ($all_postypes as $posttype) {
|
|
| 2273 | 2273 | |
| 2274 | - $tablename = $plugin_prefix . $posttype . '_detail'; |
|
| 2274 | + $tablename = $plugin_prefix . $posttype . '_detail'; |
|
| 2275 | 2275 | |
| 2276 | - $get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename);
|
|
| 2276 | + $get_post_data = $wpdb->get_results("SELECT post_id FROM " . $tablename);
|
|
| 2277 | 2277 | |
| 2278 | - if (!empty($get_post_data)) {
|
|
| 2278 | + if (!empty($get_post_data)) {
|
|
| 2279 | 2279 | |
| 2280 | - foreach ($get_post_data as $data) {
|
|
| 2280 | + foreach ($get_post_data as $data) {
|
|
| 2281 | 2281 | |
| 2282 | - $post_id = $data->post_id; |
|
| 2282 | + $post_id = $data->post_id; |
|
| 2283 | 2283 | |
| 2284 | - $attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''");
|
|
| 2284 | + $attachment_data = $wpdb->get_results("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =" . $post_id . " AND file!=''");
|
|
| 2285 | 2285 | |
| 2286 | - if (!empty($attachment_data)) {
|
|
| 2286 | + if (!empty($attachment_data)) {
|
|
| 2287 | 2287 | |
| 2288 | - foreach ($attachment_data as $attach) {
|
|
| 2288 | + foreach ($attachment_data as $attach) {
|
|
| 2289 | 2289 | |
| 2290 | - $file_info = pathinfo($attach->file); |
|
| 2290 | + $file_info = pathinfo($attach->file); |
|
| 2291 | 2291 | |
| 2292 | - $sub_dir = ''; |
|
| 2293 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 2294 | - $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 2292 | + $sub_dir = ''; |
|
| 2293 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 2294 | + $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 2295 | 2295 | |
| 2296 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 2297 | - $uploads_path = $uploads['basedir']; |
|
| 2296 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 2297 | + $uploads_path = $uploads['basedir']; |
|
| 2298 | 2298 | |
| 2299 | - $file_name = $file_info['basename']; |
|
| 2299 | + $file_name = $file_info['basename']; |
|
| 2300 | 2300 | |
| 2301 | - $img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name; |
|
| 2301 | + $img_arr['path'] = $uploads_path . $sub_dir . '/' . $file_name; |
|
| 2302 | 2302 | |
| 2303 | - if (!file_exists($img_arr['path'])) {
|
|
| 2303 | + if (!file_exists($img_arr['path'])) {
|
|
| 2304 | 2304 | |
| 2305 | - $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID);
|
|
| 2305 | + $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE ID=" . $attach->ID);
|
|
| 2306 | 2306 | |
| 2307 | - } |
|
| 2307 | + } |
|
| 2308 | 2308 | |
| 2309 | - } |
|
| 2309 | + } |
|
| 2310 | 2310 | |
| 2311 | - $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id");
|
|
| 2311 | + $attachment_data = $wpdb->get_row("SELECT ID, MIN(`menu_order`) FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id=" . $post_id . " GROUP BY post_id");
|
|
| 2312 | 2312 | |
| 2313 | - if (!empty($attachment_data)) {
|
|
| 2313 | + if (!empty($attachment_data)) {
|
|
| 2314 | 2314 | |
| 2315 | - if ($attachment_data->ID) |
|
| 2316 | - $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
|
|
| 2315 | + if ($attachment_data->ID) |
|
| 2316 | + $wpdb->query("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order=1 WHERE ID=" . $attachment_data->ID);
|
|
| 2317 | 2317 | |
| 2318 | - } else {
|
|
| 2318 | + } else {
|
|
| 2319 | 2319 | |
| 2320 | - if (has_post_thumbnail($post_id)) {
|
|
| 2320 | + if (has_post_thumbnail($post_id)) {
|
|
| 2321 | 2321 | |
| 2322 | - $post_thumbnail_id = get_post_thumbnail_id($post_id); |
|
| 2322 | + $post_thumbnail_id = get_post_thumbnail_id($post_id); |
|
| 2323 | 2323 | |
| 2324 | - wp_delete_attachment($post_thumbnail_id); |
|
| 2324 | + wp_delete_attachment($post_thumbnail_id); |
|
| 2325 | 2325 | |
| 2326 | - } |
|
| 2326 | + } |
|
| 2327 | 2327 | |
| 2328 | - } |
|
| 2328 | + } |
|
| 2329 | 2329 | |
| 2330 | - $wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id);
|
|
| 2330 | + $wpdb->query("UPDATE " . $tablename . " SET featured_image='' WHERE post_id =" . $post_id);
|
|
| 2331 | 2331 | |
| 2332 | - geodir_set_wp_featured_image($post_id); |
|
| 2332 | + geodir_set_wp_featured_image($post_id); |
|
| 2333 | 2333 | |
| 2334 | - } |
|
| 2334 | + } |
|
| 2335 | 2335 | |
| 2336 | - } |
|
| 2336 | + } |
|
| 2337 | 2337 | |
| 2338 | - } |
|
| 2338 | + } |
|
| 2339 | 2339 | |
| 2340 | - } |
|
| 2340 | + } |
|
| 2341 | 2341 | |
| 2342 | 2342 | } |
| 2343 | 2343 | |
@@ -2355,9 +2355,9 @@ discard block |
||
| 2355 | 2355 | function geodir_default_rating_star_icon() |
| 2356 | 2356 | {
|
| 2357 | 2357 | |
| 2358 | - if (!get_option('geodir_default_rating_star_icon')) {
|
|
| 2359 | - update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png');
|
|
| 2360 | - } |
|
| 2358 | + if (!get_option('geodir_default_rating_star_icon')) {
|
|
| 2359 | + update_option('geodir_default_rating_star_icon', geodir_plugin_url() . '/geodirectory-assets/images/stars.png');
|
|
| 2360 | + } |
|
| 2361 | 2361 | |
| 2362 | 2362 | } |
| 2363 | 2363 | |
@@ -2375,27 +2375,27 @@ discard block |
||
| 2375 | 2375 | */ |
| 2376 | 2376 | function geodir_user_post_listing_count($user_id=null) |
| 2377 | 2377 | {
|
| 2378 | - global $wpdb, $plugin_prefix, $current_user; |
|
| 2379 | - if(!$user_id){
|
|
| 2380 | - $user_id = $current_user->ID; |
|
| 2381 | - } |
|
| 2378 | + global $wpdb, $plugin_prefix, $current_user; |
|
| 2379 | + if(!$user_id){
|
|
| 2380 | + $user_id = $current_user->ID; |
|
| 2381 | + } |
|
| 2382 | 2382 | |
| 2383 | - $user_id = $current_user->ID; |
|
| 2384 | - $all_postypes = geodir_get_posttypes(); |
|
| 2385 | - $all_posts = get_option('geodir_listing_link_user_dashboard');
|
|
| 2383 | + $user_id = $current_user->ID; |
|
| 2384 | + $all_postypes = geodir_get_posttypes(); |
|
| 2385 | + $all_posts = get_option('geodir_listing_link_user_dashboard');
|
|
| 2386 | 2386 | |
| 2387 | - $user_listing = array(); |
|
| 2388 | - if (is_array($all_posts) && !empty($all_posts)) {
|
|
| 2389 | - foreach ($all_posts as $ptype) {
|
|
| 2390 | - $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' )");
|
|
| 2387 | + $user_listing = array(); |
|
| 2388 | + if (is_array($all_posts) && !empty($all_posts)) {
|
|
| 2389 | + foreach ($all_posts as $ptype) {
|
|
| 2390 | + $total_posts = $wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . $user_id . " AND post_type='" . $ptype . "' AND ( post_status = 'publish' OR post_status = 'draft' OR post_status = 'private' )");
|
|
| 2391 | 2391 | |
| 2392 | - if ($total_posts > 0) {
|
|
| 2393 | - $user_listing[$ptype] = $total_posts; |
|
| 2394 | - } |
|
| 2395 | - } |
|
| 2396 | - } |
|
| 2392 | + if ($total_posts > 0) {
|
|
| 2393 | + $user_listing[$ptype] = $total_posts; |
|
| 2394 | + } |
|
| 2395 | + } |
|
| 2396 | + } |
|
| 2397 | 2397 | |
| 2398 | - return $user_listing; |
|
| 2398 | + return $user_listing; |
|
| 2399 | 2399 | } |
| 2400 | 2400 | |
| 2401 | 2401 | |
@@ -2415,579 +2415,579 @@ discard block |
||
| 2415 | 2415 | */ |
| 2416 | 2416 | function geodir_detail_page_custom_field_tab($tabs_arr) |
| 2417 | 2417 | {
|
| 2418 | - global $post; |
|
| 2419 | - |
|
| 2420 | - $post_type = geodir_get_current_posttype(); |
|
| 2421 | - $all_postypes = geodir_get_posttypes(); |
|
| 2422 | - |
|
| 2423 | - if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) {
|
|
| 2424 | - $package_info = array(); |
|
| 2425 | - $package_info = geodir_post_package_info($package_info, $post); |
|
| 2426 | - $post_package_id = $package_info->pid; |
|
| 2427 | - $fields_location = 'detail'; |
|
| 2428 | - |
|
| 2429 | - $custom_fields = geodir_post_custom_fields($post_package_id, 'default', $post_type, $fields_location); |
|
| 2430 | - if (!empty($custom_fields)) {
|
|
| 2431 | - $parse_custom_fields = array(); |
|
| 2432 | - foreach ($custom_fields as $field) {
|
|
| 2433 | - $field = stripslashes_deep($field); // strip slashes |
|
| 2418 | + global $post; |
|
| 2419 | + |
|
| 2420 | + $post_type = geodir_get_current_posttype(); |
|
| 2421 | + $all_postypes = geodir_get_posttypes(); |
|
| 2422 | + |
|
| 2423 | + if (!empty($tabs_arr) && $post_type != '' && in_array($post_type, $all_postypes) && (geodir_is_page('detail') || geodir_is_page('preview'))) {
|
|
| 2424 | + $package_info = array(); |
|
| 2425 | + $package_info = geodir_post_package_info($package_info, $post); |
|
| 2426 | + $post_package_id = $package_info->pid; |
|
| 2427 | + $fields_location = 'detail'; |
|
| 2428 | + |
|
| 2429 | + $custom_fields = geodir_post_custom_fields($post_package_id, 'default', $post_type, $fields_location); |
|
| 2430 | + if (!empty($custom_fields)) {
|
|
| 2431 | + $parse_custom_fields = array(); |
|
| 2432 | + foreach ($custom_fields as $field) {
|
|
| 2433 | + $field = stripslashes_deep($field); // strip slashes |
|
| 2434 | 2434 | |
| 2435 | - $type = $field; |
|
| 2436 | - $field_name = $field['htmlvar_name']; |
|
| 2437 | - if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
|
|
| 2438 | - $post->{$field_name} = $_REQUEST[$field_name];
|
|
| 2439 | - } |
|
| 2440 | - |
|
| 2441 | - if (isset($field['show_as_tab']) && $field['show_as_tab'] == 1 && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
|
|
| 2442 | - if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
|
|
| 2443 | - continue; |
|
| 2444 | - } |
|
| 2445 | - |
|
| 2446 | - $parse_custom_fields[] = $field; |
|
| 2447 | - } |
|
| 2448 | - } |
|
| 2449 | - $custom_fields = $parse_custom_fields; |
|
| 2450 | - } |
|
| 2451 | - |
|
| 2452 | - if (!empty($custom_fields)) {
|
|
| 2453 | - $field_set_start = 0; |
|
| 2454 | - $fieldset_count = 0; |
|
| 2455 | - $fieldset = ''; |
|
| 2456 | - $total_fields = count($custom_fields); |
|
| 2457 | - $count_field = 0; |
|
| 2458 | - $fieldset_arr = array(); |
|
| 2459 | - $i = 0; |
|
| 2460 | - $geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL; |
|
| 2461 | - |
|
| 2462 | - foreach ($custom_fields as $field) {
|
|
| 2463 | - $count_field++; |
|
| 2464 | - $field_name = $field['htmlvar_name']; |
|
| 2465 | - if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
|
|
| 2466 | - $post->{$field_name} = $_REQUEST[$field_name];
|
|
| 2467 | - } |
|
| 2468 | - |
|
| 2469 | - if (isset($field['show_as_tab']) && $field['show_as_tab'] == 1 && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
|
|
| 2470 | - $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title']; |
|
| 2471 | - $site_title = trim($field['site_title']); |
|
| 2472 | - $type = $field; |
|
| 2473 | - $html = ''; |
|
| 2474 | - $html_var = $field_name; |
|
| 2475 | - $field_icon = ''; |
|
| 2476 | - $variables_array = array(); |
|
| 2477 | - |
|
| 2478 | - if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
|
|
| 2479 | - continue; |
|
| 2480 | - } |
|
| 2481 | - |
|
| 2482 | - if ($type['type'] != 'fieldset') {
|
|
| 2483 | - $i++; |
|
| 2484 | - $variables_array['post_id'] = $post->ID; |
|
| 2485 | - $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
|
| 2486 | - $variables_array['value'] = ''; |
|
| 2487 | - $variables_array['value'] = $post->{$type['htmlvar_name']};
|
|
| 2488 | - } |
|
| 2489 | - |
|
| 2490 | - if (strpos($type['field_icon'], 'http') !== false) {
|
|
| 2491 | - $field_icon = ' background: url(' . $type['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
|
|
| 2492 | - } elseif (strpos($type['field_icon'], 'fa fa-') !== false) {
|
|
| 2493 | - $field_icon = '<i class="' . $type['field_icon'] . '"></i>'; |
|
| 2494 | - } |
|
| 2435 | + $type = $field; |
|
| 2436 | + $field_name = $field['htmlvar_name']; |
|
| 2437 | + if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
|
|
| 2438 | + $post->{$field_name} = $_REQUEST[$field_name];
|
|
| 2439 | + } |
|
| 2440 | + |
|
| 2441 | + if (isset($field['show_as_tab']) && $field['show_as_tab'] == 1 && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
|
|
| 2442 | + if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
|
|
| 2443 | + continue; |
|
| 2444 | + } |
|
| 2445 | + |
|
| 2446 | + $parse_custom_fields[] = $field; |
|
| 2447 | + } |
|
| 2448 | + } |
|
| 2449 | + $custom_fields = $parse_custom_fields; |
|
| 2450 | + } |
|
| 2495 | 2451 | |
| 2496 | - switch ($type['type']) {
|
|
| 2497 | - case 'fieldset': {
|
|
| 2498 | - $i = 0; |
|
| 2499 | - $fieldset_count++; |
|
| 2500 | - $field_set_start = 1; |
|
| 2501 | - $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count; |
|
| 2502 | - $fieldset_arr[$fieldset_count]['label'] = $label; |
|
| 2503 | - } |
|
| 2504 | - break; |
|
| 2505 | - case 'url': {
|
|
| 2506 | - if (strpos($field_icon, 'http') !== false) {
|
|
| 2507 | - $field_icon_af = ''; |
|
| 2508 | - } elseif ($field_icon == '') {
|
|
| 2509 | - |
|
| 2510 | - if ($type['name'] == 'geodir_facebook') {
|
|
| 2511 | - $field_icon_af = '<i class="fa fa-facebook-square"></i>'; |
|
| 2512 | - } elseif ($type['name'] == 'geodir_twitter') {
|
|
| 2513 | - $field_icon_af = '<i class="fa fa-twitter-square"></i>'; |
|
| 2514 | - } else {
|
|
| 2515 | - $field_icon_af = '<i class="fa fa-link"></i>'; |
|
| 2516 | - } |
|
| 2517 | - |
|
| 2518 | - } else {
|
|
| 2519 | - $field_icon_af = $field_icon; |
|
| 2520 | - $field_icon = ''; |
|
| 2521 | - } |
|
| 2452 | + if (!empty($custom_fields)) {
|
|
| 2453 | + $field_set_start = 0; |
|
| 2454 | + $fieldset_count = 0; |
|
| 2455 | + $fieldset = ''; |
|
| 2456 | + $total_fields = count($custom_fields); |
|
| 2457 | + $count_field = 0; |
|
| 2458 | + $fieldset_arr = array(); |
|
| 2459 | + $i = 0; |
|
| 2460 | + $geodir_post_info = isset($post->ID) && !empty($post->ID) ? geodir_get_post_info($post->ID) : NULL; |
|
| 2461 | + |
|
| 2462 | + foreach ($custom_fields as $field) {
|
|
| 2463 | + $count_field++; |
|
| 2464 | + $field_name = $field['htmlvar_name']; |
|
| 2465 | + if (empty($geodir_post_info) && geodir_is_page('preview') && $field_name != '' && !isset($post->{$field_name}) && isset($_REQUEST[$field_name])) {
|
|
| 2466 | + $post->{$field_name} = $_REQUEST[$field_name];
|
|
| 2467 | + } |
|
| 2468 | + |
|
| 2469 | + if (isset($field['show_as_tab']) && $field['show_as_tab'] == 1 && ((isset($post->{$field_name}) && $post->{$field_name} != '') || $field['type'] == 'fieldset') && in_array($field['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
|
|
| 2470 | + $label = $field['site_title'] != '' ? $field['site_title'] : $field['admin_title']; |
|
| 2471 | + $site_title = trim($field['site_title']); |
|
| 2472 | + $type = $field; |
|
| 2473 | + $html = ''; |
|
| 2474 | + $html_var = $field_name; |
|
| 2475 | + $field_icon = ''; |
|
| 2476 | + $variables_array = array(); |
|
| 2477 | + |
|
| 2478 | + if ($type['type'] == 'datepicker' && ($post->{$type['htmlvar_name']} == '' || $post->{$type['htmlvar_name']} == '0000-00-00')) {
|
|
| 2479 | + continue; |
|
| 2480 | + } |
|
| 2481 | + |
|
| 2482 | + if ($type['type'] != 'fieldset') {
|
|
| 2483 | + $i++; |
|
| 2484 | + $variables_array['post_id'] = $post->ID; |
|
| 2485 | + $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
|
| 2486 | + $variables_array['value'] = ''; |
|
| 2487 | + $variables_array['value'] = $post->{$type['htmlvar_name']};
|
|
| 2488 | + } |
|
| 2489 | + |
|
| 2490 | + if (strpos($type['field_icon'], 'http') !== false) {
|
|
| 2491 | + $field_icon = ' background: url(' . $type['field_icon'] . ') no-repeat left center;background-size:18px 18px;padding-left: 21px;';
|
|
| 2492 | + } elseif (strpos($type['field_icon'], 'fa fa-') !== false) {
|
|
| 2493 | + $field_icon = '<i class="' . $type['field_icon'] . '"></i>'; |
|
| 2494 | + } |
|
| 2495 | + |
|
| 2496 | + switch ($type['type']) {
|
|
| 2497 | + case 'fieldset': {
|
|
| 2498 | + $i = 0; |
|
| 2499 | + $fieldset_count++; |
|
| 2500 | + $field_set_start = 1; |
|
| 2501 | + $fieldset_arr[$fieldset_count]['htmlvar_name'] = 'gd_tab_' . $fieldset_count; |
|
| 2502 | + $fieldset_arr[$fieldset_count]['label'] = $label; |
|
| 2503 | + } |
|
| 2504 | + break; |
|
| 2505 | + case 'url': {
|
|
| 2506 | + if (strpos($field_icon, 'http') !== false) {
|
|
| 2507 | + $field_icon_af = ''; |
|
| 2508 | + } elseif ($field_icon == '') {
|
|
| 2509 | + |
|
| 2510 | + if ($type['name'] == 'geodir_facebook') {
|
|
| 2511 | + $field_icon_af = '<i class="fa fa-facebook-square"></i>'; |
|
| 2512 | + } elseif ($type['name'] == 'geodir_twitter') {
|
|
| 2513 | + $field_icon_af = '<i class="fa fa-twitter-square"></i>'; |
|
| 2514 | + } else {
|
|
| 2515 | + $field_icon_af = '<i class="fa fa-link"></i>'; |
|
| 2516 | + } |
|
| 2517 | + |
|
| 2518 | + } else {
|
|
| 2519 | + $field_icon_af = $field_icon; |
|
| 2520 | + $field_icon = ''; |
|
| 2521 | + } |
|
| 2522 | 2522 | |
| 2523 | - $a_url = geodir_parse_custom_field_url($post->{$type['htmlvar_name']});
|
|
| 2524 | - |
|
| 2525 | - $website = !empty($a_url['url']) ? $a_url['url'] : ''; |
|
| 2526 | - $title = !empty($a_url['label']) ? $a_url['label'] : $type['site_title']; |
|
| 2527 | - $title = $title != '' ? __(stripslashes($title), 'geodirectory') : ''; |
|
| 2528 | - |
|
| 2529 | - $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2530 | - |
|
| 2531 | - // all search engines that use the nofollow value exclude links that use it from their ranking calculation |
|
| 2532 | - $rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"'; |
|
| 2533 | - |
|
| 2534 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-website" style="' . $field_icon . '">' . $field_icon_af . ' <a href="' . $website . '" target="_blank" ' . $rel . ' ><strong>' . |
|
| 2535 | - /** |
|
| 2536 | - * Filer the custom field website name. |
|
| 2537 | - * |
|
| 2538 | - * @since 1.0.0 |
|
| 2539 | - * @param string $title The field name default: "Website". |
|
| 2540 | - * @param string $website The website address. |
|
| 2541 | - * @param int $post->ID The post ID. |
|
| 2542 | - */ |
|
| 2543 | - apply_filters('geodir_custom_field_website_name', $title, $website, $post->ID) . '</strong></a></span></div>';
|
|
| 2544 | - } |
|
| 2545 | - break; |
|
| 2546 | - case 'phone': {
|
|
| 2547 | - if (strpos($field_icon, 'http') !== false) {
|
|
| 2548 | - $field_icon_af = ''; |
|
| 2549 | - } elseif ($field_icon == '') {
|
|
| 2550 | - $field_icon_af = '<i class="fa fa-phone"></i>'; |
|
| 2551 | - } else {
|
|
| 2552 | - $field_icon_af = $field_icon; |
|
| 2553 | - $field_icon = ''; |
|
| 2554 | - } |
|
| 2555 | - |
|
| 2556 | - $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2557 | - |
|
| 2558 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2559 | - if ($field_set_start == 1 && $site_title != '') {
|
|
| 2560 | - $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2561 | - } |
|
| 2562 | - $html .= ' </span>' . stripslashes($post->{$type['htmlvar_name']}) . '</div>';
|
|
| 2563 | - } |
|
| 2564 | - break; |
|
| 2565 | - case 'time': {
|
|
| 2566 | - $value = ''; |
|
| 2567 | - if ($post->{$type['htmlvar_name']} != '')
|
|
| 2568 | - $value = date_i18n(get_option('time_format'), strtotime($post->{$type['htmlvar_name']}));
|
|
| 2569 | - |
|
| 2570 | - if (strpos($field_icon, 'http') !== false) {
|
|
| 2571 | - $field_icon_af = ''; |
|
| 2572 | - } elseif ($field_icon == '') {
|
|
| 2573 | - $field_icon_af = '<i class="fa fa-clock-o"></i>'; |
|
| 2574 | - } else {
|
|
| 2575 | - $field_icon_af = $field_icon; |
|
| 2576 | - $field_icon = ''; |
|
| 2577 | - } |
|
| 2578 | - |
|
| 2579 | - $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2580 | - |
|
| 2581 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2582 | - if ($field_set_start == 1 && $site_title != '') {
|
|
| 2583 | - $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2584 | - } |
|
| 2585 | - $html .= ' </span>' . stripslashes($value) . '</div>'; |
|
| 2586 | - } |
|
| 2587 | - break; |
|
| 2588 | - case 'datepicker': {
|
|
| 2589 | - $date_format = geodir_default_date_format(); |
|
| 2590 | - if ($type['extra_fields'] != '') {
|
|
| 2591 | - $date_format = unserialize($type['extra_fields']); |
|
| 2592 | - $date_format = $date_format['date_format']; |
|
| 2593 | - } |
|
| 2594 | - |
|
| 2595 | - $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
|
|
| 2596 | - $replace = array('d','j','l','m','n','F','Y');//PHP date format
|
|
| 2597 | - |
|
| 2598 | - $date_format = str_replace($search, $replace, $date_format); |
|
| 2599 | - |
|
| 2600 | - $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $post->{$type['htmlvar_name']}) : $post->{$type['htmlvar_name']}; // PHP doesn't work well with dd/mm/yyyy format
|
|
| 2601 | - |
|
| 2602 | - $value = ''; |
|
| 2603 | - if ($post->{$type['htmlvar_name']} != '')
|
|
| 2604 | - $value = date($date_format, strtotime($post_htmlvar_value)); |
|
| 2605 | - |
|
| 2606 | - if (strpos($field_icon, 'http') !== false) {
|
|
| 2607 | - $field_icon_af = ''; |
|
| 2608 | - } elseif ($field_icon == '') {
|
|
| 2609 | - $field_icon_af = '<i class="fa fa-calendar"></i>'; |
|
| 2610 | - } else {
|
|
| 2611 | - $field_icon_af = $field_icon; |
|
| 2612 | - $field_icon = ''; |
|
| 2613 | - } |
|
| 2614 | - |
|
| 2615 | - $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2616 | - |
|
| 2617 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2618 | - if ($field_set_start == 1 && $site_title != '') {
|
|
| 2619 | - $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2620 | - } |
|
| 2621 | - $html .= ' </span>' . $value . '</div>'; |
|
| 2622 | - } |
|
| 2623 | - break; |
|
| 2624 | - case 'text': {
|
|
| 2625 | - if (strpos($field_icon, 'http') !== false) {
|
|
| 2626 | - $field_icon_af = ''; |
|
| 2627 | - } elseif ($field_icon == '') {
|
|
| 2628 | - $field_icon_af = ''; |
|
| 2629 | - } else {
|
|
| 2630 | - $field_icon_af = $field_icon; |
|
| 2631 | - $field_icon = ''; |
|
| 2632 | - } |
|
| 2633 | - |
|
| 2634 | - $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2635 | - |
|
| 2636 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2637 | - if ($field_set_start == 1 && $site_title != '') {
|
|
| 2638 | - $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2639 | - } |
|
| 2640 | - $html .= ' </span>' . stripslashes($post->{$type['htmlvar_name']}) . '</div>';
|
|
| 2641 | - } |
|
| 2642 | - break; |
|
| 2643 | - case 'radio': {
|
|
| 2644 | - |
|
| 2645 | - if ($post->{$type['htmlvar_name']} != '') {
|
|
| 2646 | - if ($post->{$type['htmlvar_name']} == 'f' || $post->{$type['htmlvar_name']} == '0') {
|
|
| 2647 | - $html_val = __('No', 'geodirectory');
|
|
| 2648 | - } else if ($post->{$type['htmlvar_name']} == 't' || $post->{$type['htmlvar_name']} == '1') {
|
|
| 2649 | - $html_val = __('Yes', 'geodirectory');
|
|
| 2650 | - } else {
|
|
| 2651 | - $html_val = __($post->{$type['htmlvar_name']}, 'geodirectory');
|
|
| 2523 | + $a_url = geodir_parse_custom_field_url($post->{$type['htmlvar_name']});
|
|
| 2524 | + |
|
| 2525 | + $website = !empty($a_url['url']) ? $a_url['url'] : ''; |
|
| 2526 | + $title = !empty($a_url['label']) ? $a_url['label'] : $type['site_title']; |
|
| 2527 | + $title = $title != '' ? __(stripslashes($title), 'geodirectory') : ''; |
|
| 2528 | + |
|
| 2529 | + $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2530 | + |
|
| 2531 | + // all search engines that use the nofollow value exclude links that use it from their ranking calculation |
|
| 2532 | + $rel = strpos($website, get_site_url()) !== false ? '' : 'rel="nofollow"'; |
|
| 2533 | + |
|
| 2534 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '"><span class="geodir-i-website" style="' . $field_icon . '">' . $field_icon_af . ' <a href="' . $website . '" target="_blank" ' . $rel . ' ><strong>' . |
|
| 2535 | + /** |
|
| 2536 | + * Filer the custom field website name. |
|
| 2537 | + * |
|
| 2538 | + * @since 1.0.0 |
|
| 2539 | + * @param string $title The field name default: "Website". |
|
| 2540 | + * @param string $website The website address. |
|
| 2541 | + * @param int $post->ID The post ID. |
|
| 2542 | + */ |
|
| 2543 | + apply_filters('geodir_custom_field_website_name', $title, $website, $post->ID) . '</strong></a></span></div>';
|
|
| 2544 | + } |
|
| 2545 | + break; |
|
| 2546 | + case 'phone': {
|
|
| 2547 | + if (strpos($field_icon, 'http') !== false) {
|
|
| 2548 | + $field_icon_af = ''; |
|
| 2549 | + } elseif ($field_icon == '') {
|
|
| 2550 | + $field_icon_af = '<i class="fa fa-phone"></i>'; |
|
| 2551 | + } else {
|
|
| 2552 | + $field_icon_af = $field_icon; |
|
| 2553 | + $field_icon = ''; |
|
| 2554 | + } |
|
| 2555 | + |
|
| 2556 | + $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2557 | + |
|
| 2558 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-contact" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2559 | + if ($field_set_start == 1 && $site_title != '') {
|
|
| 2560 | + $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2561 | + } |
|
| 2562 | + $html .= ' </span>' . stripslashes($post->{$type['htmlvar_name']}) . '</div>';
|
|
| 2563 | + } |
|
| 2564 | + break; |
|
| 2565 | + case 'time': {
|
|
| 2566 | + $value = ''; |
|
| 2567 | + if ($post->{$type['htmlvar_name']} != '')
|
|
| 2568 | + $value = date_i18n(get_option('time_format'), strtotime($post->{$type['htmlvar_name']}));
|
|
| 2569 | + |
|
| 2570 | + if (strpos($field_icon, 'http') !== false) {
|
|
| 2571 | + $field_icon_af = ''; |
|
| 2572 | + } elseif ($field_icon == '') {
|
|
| 2573 | + $field_icon_af = '<i class="fa fa-clock-o"></i>'; |
|
| 2574 | + } else {
|
|
| 2575 | + $field_icon_af = $field_icon; |
|
| 2576 | + $field_icon = ''; |
|
| 2577 | + } |
|
| 2578 | + |
|
| 2579 | + $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2580 | + |
|
| 2581 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-time" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2582 | + if ($field_set_start == 1 && $site_title != '') {
|
|
| 2583 | + $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2584 | + } |
|
| 2585 | + $html .= ' </span>' . stripslashes($value) . '</div>'; |
|
| 2586 | + } |
|
| 2587 | + break; |
|
| 2588 | + case 'datepicker': {
|
|
| 2589 | + $date_format = geodir_default_date_format(); |
|
| 2590 | + if ($type['extra_fields'] != '') {
|
|
| 2591 | + $date_format = unserialize($type['extra_fields']); |
|
| 2592 | + $date_format = $date_format['date_format']; |
|
| 2593 | + } |
|
| 2594 | + |
|
| 2595 | + $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
|
|
| 2596 | + $replace = array('d','j','l','m','n','F','Y');//PHP date format
|
|
| 2597 | + |
|
| 2598 | + $date_format = str_replace($search, $replace, $date_format); |
|
| 2599 | + |
|
| 2600 | + $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $post->{$type['htmlvar_name']}) : $post->{$type['htmlvar_name']}; // PHP doesn't work well with dd/mm/yyyy format
|
|
| 2601 | + |
|
| 2602 | + $value = ''; |
|
| 2603 | + if ($post->{$type['htmlvar_name']} != '')
|
|
| 2604 | + $value = date($date_format, strtotime($post_htmlvar_value)); |
|
| 2605 | + |
|
| 2606 | + if (strpos($field_icon, 'http') !== false) {
|
|
| 2607 | + $field_icon_af = ''; |
|
| 2608 | + } elseif ($field_icon == '') {
|
|
| 2609 | + $field_icon_af = '<i class="fa fa-calendar"></i>'; |
|
| 2610 | + } else {
|
|
| 2611 | + $field_icon_af = $field_icon; |
|
| 2612 | + $field_icon = ''; |
|
| 2613 | + } |
|
| 2614 | + |
|
| 2615 | + $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2616 | + |
|
| 2617 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-datepicker" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2618 | + if ($field_set_start == 1 && $site_title != '') {
|
|
| 2619 | + $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2620 | + } |
|
| 2621 | + $html .= ' </span>' . $value . '</div>'; |
|
| 2622 | + } |
|
| 2623 | + break; |
|
| 2624 | + case 'text': {
|
|
| 2625 | + if (strpos($field_icon, 'http') !== false) {
|
|
| 2626 | + $field_icon_af = ''; |
|
| 2627 | + } elseif ($field_icon == '') {
|
|
| 2628 | + $field_icon_af = ''; |
|
| 2629 | + } else {
|
|
| 2630 | + $field_icon_af = $field_icon; |
|
| 2631 | + $field_icon = ''; |
|
| 2632 | + } |
|
| 2633 | + |
|
| 2634 | + $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2635 | + |
|
| 2636 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2637 | + if ($field_set_start == 1 && $site_title != '') {
|
|
| 2638 | + $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2639 | + } |
|
| 2640 | + $html .= ' </span>' . stripslashes($post->{$type['htmlvar_name']}) . '</div>';
|
|
| 2641 | + } |
|
| 2642 | + break; |
|
| 2643 | + case 'radio': {
|
|
| 2644 | + |
|
| 2645 | + if ($post->{$type['htmlvar_name']} != '') {
|
|
| 2646 | + if ($post->{$type['htmlvar_name']} == 'f' || $post->{$type['htmlvar_name']} == '0') {
|
|
| 2647 | + $html_val = __('No', 'geodirectory');
|
|
| 2648 | + } else if ($post->{$type['htmlvar_name']} == 't' || $post->{$type['htmlvar_name']} == '1') {
|
|
| 2649 | + $html_val = __('Yes', 'geodirectory');
|
|
| 2650 | + } else {
|
|
| 2651 | + $html_val = __($post->{$type['htmlvar_name']}, 'geodirectory');
|
|
| 2652 | 2652 | |
| 2653 | - if (!empty($type['option_values'])) {
|
|
| 2654 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2653 | + if (!empty($type['option_values'])) {
|
|
| 2654 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2655 | 2655 | |
| 2656 | - if (!empty($cf_option_values)) {
|
|
| 2657 | - foreach ($cf_option_values as $cf_option_value) {
|
|
| 2658 | - if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$type['htmlvar_name']}) {
|
|
| 2659 | - $html_val = $cf_option_value['label']; |
|
| 2660 | - } |
|
| 2661 | - } |
|
| 2662 | - } |
|
| 2663 | - } |
|
| 2664 | - } |
|
| 2665 | - |
|
| 2666 | - if (strpos($field_icon, 'http') !== false) {
|
|
| 2667 | - $field_icon_af = ''; |
|
| 2668 | - } else if ($field_icon == '') {
|
|
| 2669 | - $field_icon_af = ''; |
|
| 2670 | - } else {
|
|
| 2671 | - $field_icon_af = $field_icon; |
|
| 2672 | - $field_icon = ''; |
|
| 2673 | - } |
|
| 2674 | - |
|
| 2675 | - $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2676 | - |
|
| 2677 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2678 | - |
|
| 2679 | - if ($field_set_start == 1 && $site_title != '') {
|
|
| 2680 | - $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2681 | - } |
|
| 2682 | - |
|
| 2683 | - $html .= ' </span>' . $html_val . '</div>'; |
|
| 2684 | - } |
|
| 2685 | - } |
|
| 2686 | - break; |
|
| 2687 | - case 'checkbox': {
|
|
| 2688 | - $html_var = $type['htmlvar_name']; |
|
| 2689 | - $html_val = $type['htmlvar_name']; |
|
| 2690 | - |
|
| 2691 | - if ((int)$post->{$html_var} == 1) {
|
|
| 2692 | - |
|
| 2693 | - if ($post->{$type['htmlvar_name']} == '1') {
|
|
| 2694 | - $html_val = __('Yes', 'geodirectory');
|
|
| 2695 | - } else {
|
|
| 2696 | - $html_val = __('No', 'geodirectory');
|
|
| 2697 | - } |
|
| 2698 | - |
|
| 2699 | - if (strpos($field_icon, 'http') !== false) {
|
|
| 2700 | - $field_icon_af = ''; |
|
| 2701 | - } else if ($field_icon == '') {
|
|
| 2702 | - $field_icon_af = ''; |
|
| 2703 | - } else {
|
|
| 2704 | - $field_icon_af = $field_icon; |
|
| 2705 | - $field_icon = ''; |
|
| 2706 | - } |
|
| 2707 | - |
|
| 2708 | - $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2709 | - |
|
| 2710 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2711 | - |
|
| 2712 | - if ($field_set_start == 1 && $site_title != '') {
|
|
| 2713 | - $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2714 | - } |
|
| 2715 | - |
|
| 2716 | - $html .= ' </span>' . $html_val . '</div>'; |
|
| 2717 | - } |
|
| 2718 | - } |
|
| 2719 | - break; |
|
| 2720 | - case 'select': {
|
|
| 2721 | - if (strpos($field_icon, 'http') !== false) {
|
|
| 2722 | - $field_icon_af = ''; |
|
| 2723 | - } elseif ($field_icon == '') {
|
|
| 2724 | - $field_icon_af = ''; |
|
| 2725 | - } else {
|
|
| 2726 | - $field_icon_af = $field_icon; |
|
| 2727 | - $field_icon = ''; |
|
| 2728 | - } |
|
| 2656 | + if (!empty($cf_option_values)) {
|
|
| 2657 | + foreach ($cf_option_values as $cf_option_value) {
|
|
| 2658 | + if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$type['htmlvar_name']}) {
|
|
| 2659 | + $html_val = $cf_option_value['label']; |
|
| 2660 | + } |
|
| 2661 | + } |
|
| 2662 | + } |
|
| 2663 | + } |
|
| 2664 | + } |
|
| 2665 | + |
|
| 2666 | + if (strpos($field_icon, 'http') !== false) {
|
|
| 2667 | + $field_icon_af = ''; |
|
| 2668 | + } else if ($field_icon == '') {
|
|
| 2669 | + $field_icon_af = ''; |
|
| 2670 | + } else {
|
|
| 2671 | + $field_icon_af = $field_icon; |
|
| 2672 | + $field_icon = ''; |
|
| 2673 | + } |
|
| 2674 | + |
|
| 2675 | + $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2676 | + |
|
| 2677 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-radio" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2678 | + |
|
| 2679 | + if ($field_set_start == 1 && $site_title != '') {
|
|
| 2680 | + $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2681 | + } |
|
| 2682 | + |
|
| 2683 | + $html .= ' </span>' . $html_val . '</div>'; |
|
| 2684 | + } |
|
| 2685 | + } |
|
| 2686 | + break; |
|
| 2687 | + case 'checkbox': {
|
|
| 2688 | + $html_var = $type['htmlvar_name']; |
|
| 2689 | + $html_val = $type['htmlvar_name']; |
|
| 2690 | + |
|
| 2691 | + if ((int)$post->{$html_var} == 1) {
|
|
| 2692 | + |
|
| 2693 | + if ($post->{$type['htmlvar_name']} == '1') {
|
|
| 2694 | + $html_val = __('Yes', 'geodirectory');
|
|
| 2695 | + } else {
|
|
| 2696 | + $html_val = __('No', 'geodirectory');
|
|
| 2697 | + } |
|
| 2698 | + |
|
| 2699 | + if (strpos($field_icon, 'http') !== false) {
|
|
| 2700 | + $field_icon_af = ''; |
|
| 2701 | + } else if ($field_icon == '') {
|
|
| 2702 | + $field_icon_af = ''; |
|
| 2703 | + } else {
|
|
| 2704 | + $field_icon_af = $field_icon; |
|
| 2705 | + $field_icon = ''; |
|
| 2706 | + } |
|
| 2707 | + |
|
| 2708 | + $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2709 | + |
|
| 2710 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2711 | + |
|
| 2712 | + if ($field_set_start == 1 && $site_title != '') {
|
|
| 2713 | + $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2714 | + } |
|
| 2715 | + |
|
| 2716 | + $html .= ' </span>' . $html_val . '</div>'; |
|
| 2717 | + } |
|
| 2718 | + } |
|
| 2719 | + break; |
|
| 2720 | + case 'select': {
|
|
| 2721 | + if (strpos($field_icon, 'http') !== false) {
|
|
| 2722 | + $field_icon_af = ''; |
|
| 2723 | + } elseif ($field_icon == '') {
|
|
| 2724 | + $field_icon_af = ''; |
|
| 2725 | + } else {
|
|
| 2726 | + $field_icon_af = $field_icon; |
|
| 2727 | + $field_icon = ''; |
|
| 2728 | + } |
|
| 2729 | 2729 | |
| 2730 | - $field_value = __($post->{$type['htmlvar_name']}, 'geodirectory');
|
|
| 2730 | + $field_value = __($post->{$type['htmlvar_name']}, 'geodirectory');
|
|
| 2731 | 2731 | |
| 2732 | - if (!empty($type['option_values'])) {
|
|
| 2733 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2732 | + if (!empty($type['option_values'])) {
|
|
| 2733 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2734 | 2734 | |
| 2735 | - if (!empty($cf_option_values)) {
|
|
| 2736 | - foreach ($cf_option_values as $cf_option_value) {
|
|
| 2737 | - if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$type['htmlvar_name']}) {
|
|
| 2738 | - $field_value = $cf_option_value['label']; |
|
| 2739 | - } |
|
| 2740 | - } |
|
| 2741 | - } |
|
| 2742 | - } |
|
| 2743 | - |
|
| 2744 | - $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2745 | - |
|
| 2746 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2747 | - if ($field_set_start == 1 && $site_title != '') {
|
|
| 2748 | - $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2749 | - } |
|
| 2750 | - $html .= ' </span>' . $field_value . '</div>'; |
|
| 2751 | - } |
|
| 2752 | - break; |
|
| 2753 | - case 'multiselect': {
|
|
| 2754 | - if (is_array($post->{$type['htmlvar_name']})) {
|
|
| 2755 | - $post->{$type['htmlvar_name']} = implode(', ', $post->{$type['htmlvar_name']});
|
|
| 2756 | - } |
|
| 2757 | - |
|
| 2758 | - if (strpos($field_icon, 'http') !== false) {
|
|
| 2759 | - $field_icon_af = ''; |
|
| 2760 | - } elseif ($field_icon == '') {
|
|
| 2761 | - $field_icon_af = ''; |
|
| 2762 | - } else {
|
|
| 2763 | - $field_icon_af = $field_icon; |
|
| 2764 | - $field_icon = ''; |
|
| 2765 | - } |
|
| 2766 | - |
|
| 2767 | - $field_values = explode(',', trim($post->{$type['htmlvar_name']}, ","));
|
|
| 2768 | - |
|
| 2769 | - $option_values = array(); |
|
| 2770 | - if (!empty($type['option_values'])) {
|
|
| 2771 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2735 | + if (!empty($cf_option_values)) {
|
|
| 2736 | + foreach ($cf_option_values as $cf_option_value) {
|
|
| 2737 | + if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$type['htmlvar_name']}) {
|
|
| 2738 | + $field_value = $cf_option_value['label']; |
|
| 2739 | + } |
|
| 2740 | + } |
|
| 2741 | + } |
|
| 2742 | + } |
|
| 2743 | + |
|
| 2744 | + $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2745 | + |
|
| 2746 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2747 | + if ($field_set_start == 1 && $site_title != '') {
|
|
| 2748 | + $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2749 | + } |
|
| 2750 | + $html .= ' </span>' . $field_value . '</div>'; |
|
| 2751 | + } |
|
| 2752 | + break; |
|
| 2753 | + case 'multiselect': {
|
|
| 2754 | + if (is_array($post->{$type['htmlvar_name']})) {
|
|
| 2755 | + $post->{$type['htmlvar_name']} = implode(', ', $post->{$type['htmlvar_name']});
|
|
| 2756 | + } |
|
| 2757 | + |
|
| 2758 | + if (strpos($field_icon, 'http') !== false) {
|
|
| 2759 | + $field_icon_af = ''; |
|
| 2760 | + } elseif ($field_icon == '') {
|
|
| 2761 | + $field_icon_af = ''; |
|
| 2762 | + } else {
|
|
| 2763 | + $field_icon_af = $field_icon; |
|
| 2764 | + $field_icon = ''; |
|
| 2765 | + } |
|
| 2766 | + |
|
| 2767 | + $field_values = explode(',', trim($post->{$type['htmlvar_name']}, ","));
|
|
| 2768 | + |
|
| 2769 | + $option_values = array(); |
|
| 2770 | + if (!empty($type['option_values'])) {
|
|
| 2771 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2772 | 2772 | |
| 2773 | - if (!empty($cf_option_values)) {
|
|
| 2774 | - foreach ($cf_option_values as $cf_option_value) {
|
|
| 2775 | - if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
|
|
| 2776 | - $option_values[] = $cf_option_value['label']; |
|
| 2777 | - } |
|
| 2778 | - } |
|
| 2779 | - } |
|
| 2780 | - } |
|
| 2781 | - |
|
| 2782 | - $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2783 | - |
|
| 2784 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2785 | - if ($field_set_start == 1 && $site_title != '') {
|
|
| 2786 | - $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2787 | - } |
|
| 2788 | - $html .= ' </span>'; |
|
| 2789 | - |
|
| 2790 | - if (count($option_values) > 1) {
|
|
| 2791 | - $html .= '<ul>'; |
|
| 2792 | - foreach ($option_values as $val) {
|
|
| 2793 | - $html .= '<li>' . $val . '</li>'; |
|
| 2794 | - } |
|
| 2795 | - $html .= '</ul>'; |
|
| 2796 | - } else {
|
|
| 2797 | - $html .= $post->{$type['htmlvar_name']};
|
|
| 2798 | - } |
|
| 2799 | - $html .= '</div>'; |
|
| 2800 | - } |
|
| 2801 | - break; |
|
| 2802 | - case 'email': {
|
|
| 2803 | - if (strpos($field_icon, 'http') !== false) {
|
|
| 2804 | - $field_icon_af = ''; |
|
| 2805 | - } elseif ($field_icon == '') {
|
|
| 2806 | - $field_icon_af = '<i class="fa fa-envelope"></i>'; |
|
| 2807 | - } else {
|
|
| 2808 | - $field_icon_af = $field_icon; |
|
| 2809 | - $field_icon = ''; |
|
| 2810 | - } |
|
| 2811 | - |
|
| 2812 | - $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2813 | - |
|
| 2814 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2815 | - if ($field_set_start == 1 && $site_title != '') {
|
|
| 2816 | - $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2817 | - } |
|
| 2818 | - $html .= ' </span>' . stripslashes($post->{$type['htmlvar_name']}) . '</div>';
|
|
| 2819 | - } |
|
| 2820 | - break; |
|
| 2821 | - case 'textarea': {
|
|
| 2822 | - if (strpos($field_icon, 'http') !== false) {
|
|
| 2823 | - $field_icon_af = ''; |
|
| 2824 | - } elseif ($field_icon == '') {
|
|
| 2825 | - $field_icon_af = ''; |
|
| 2826 | - } else {
|
|
| 2827 | - $field_icon_af = $field_icon; |
|
| 2828 | - $field_icon = ''; |
|
| 2829 | - } |
|
| 2830 | - |
|
| 2831 | - $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2832 | - |
|
| 2833 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2834 | - if ($field_set_start == 1 && $site_title != '') {
|
|
| 2835 | - $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2836 | - } |
|
| 2837 | - $html .= '</span>' . wpautop(stripslashes($post->{$type['htmlvar_name']})) . '</div>';
|
|
| 2838 | - } |
|
| 2839 | - break; |
|
| 2840 | - case 'html': {
|
|
| 2841 | - if (strpos($field_icon, 'http') !== false) {
|
|
| 2842 | - $field_icon_af = ''; |
|
| 2843 | - } elseif ($field_icon == '') {
|
|
| 2844 | - $field_icon_af = ''; |
|
| 2845 | - } else {
|
|
| 2846 | - $field_icon_af = $field_icon; |
|
| 2847 | - $field_icon = ''; |
|
| 2848 | - } |
|
| 2849 | - |
|
| 2850 | - $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2851 | - |
|
| 2852 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2853 | - if ($field_set_start == 1 && $site_title != '') {
|
|
| 2854 | - $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2855 | - } |
|
| 2856 | - $html .= ' </span>' . wpautop(stripslashes($post->{$type['htmlvar_name']})) . '</div>';
|
|
| 2857 | - } |
|
| 2858 | - break; |
|
| 2859 | - case 'file': {
|
|
| 2860 | - $html_var = $type['htmlvar_name']; |
|
| 2861 | - |
|
| 2862 | - if (!empty($post->{$type['htmlvar_name']})) {
|
|
| 2863 | - $files = explode(",", $post->{$type['htmlvar_name']});
|
|
| 2864 | - |
|
| 2865 | - if (!empty($files)) {
|
|
| 2866 | - $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL; |
|
| 2867 | - $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
|
|
| 2773 | + if (!empty($cf_option_values)) {
|
|
| 2774 | + foreach ($cf_option_values as $cf_option_value) {
|
|
| 2775 | + if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
|
|
| 2776 | + $option_values[] = $cf_option_value['label']; |
|
| 2777 | + } |
|
| 2778 | + } |
|
| 2779 | + } |
|
| 2780 | + } |
|
| 2781 | + |
|
| 2782 | + $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2783 | + |
|
| 2784 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-select" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2785 | + if ($field_set_start == 1 && $site_title != '') {
|
|
| 2786 | + $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2787 | + } |
|
| 2788 | + $html .= ' </span>'; |
|
| 2789 | + |
|
| 2790 | + if (count($option_values) > 1) {
|
|
| 2791 | + $html .= '<ul>'; |
|
| 2792 | + foreach ($option_values as $val) {
|
|
| 2793 | + $html .= '<li>' . $val . '</li>'; |
|
| 2794 | + } |
|
| 2795 | + $html .= '</ul>'; |
|
| 2796 | + } else {
|
|
| 2797 | + $html .= $post->{$type['htmlvar_name']};
|
|
| 2798 | + } |
|
| 2799 | + $html .= '</div>'; |
|
| 2800 | + } |
|
| 2801 | + break; |
|
| 2802 | + case 'email': {
|
|
| 2803 | + if (strpos($field_icon, 'http') !== false) {
|
|
| 2804 | + $field_icon_af = ''; |
|
| 2805 | + } elseif ($field_icon == '') {
|
|
| 2806 | + $field_icon_af = '<i class="fa fa-envelope"></i>'; |
|
| 2807 | + } else {
|
|
| 2808 | + $field_icon_af = $field_icon; |
|
| 2809 | + $field_icon = ''; |
|
| 2810 | + } |
|
| 2811 | + |
|
| 2812 | + $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2813 | + |
|
| 2814 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2815 | + if ($field_set_start == 1 && $site_title != '') {
|
|
| 2816 | + $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2817 | + } |
|
| 2818 | + $html .= ' </span>' . stripslashes($post->{$type['htmlvar_name']}) . '</div>';
|
|
| 2819 | + } |
|
| 2820 | + break; |
|
| 2821 | + case 'textarea': {
|
|
| 2822 | + if (strpos($field_icon, 'http') !== false) {
|
|
| 2823 | + $field_icon_af = ''; |
|
| 2824 | + } elseif ($field_icon == '') {
|
|
| 2825 | + $field_icon_af = ''; |
|
| 2826 | + } else {
|
|
| 2827 | + $field_icon_af = $field_icon; |
|
| 2828 | + $field_icon = ''; |
|
| 2829 | + } |
|
| 2830 | + |
|
| 2831 | + $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2832 | + |
|
| 2833 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2834 | + if ($field_set_start == 1 && $site_title != '') {
|
|
| 2835 | + $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2836 | + } |
|
| 2837 | + $html .= '</span>' . wpautop(stripslashes($post->{$type['htmlvar_name']})) . '</div>';
|
|
| 2838 | + } |
|
| 2839 | + break; |
|
| 2840 | + case 'html': {
|
|
| 2841 | + if (strpos($field_icon, 'http') !== false) {
|
|
| 2842 | + $field_icon_af = ''; |
|
| 2843 | + } elseif ($field_icon == '') {
|
|
| 2844 | + $field_icon_af = ''; |
|
| 2845 | + } else {
|
|
| 2846 | + $field_icon_af = $field_icon; |
|
| 2847 | + $field_icon = ''; |
|
| 2848 | + } |
|
| 2849 | + |
|
| 2850 | + $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2851 | + |
|
| 2852 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-text" style="' . $field_icon . '">' . $field_icon_af; |
|
| 2853 | + if ($field_set_start == 1 && $site_title != '') {
|
|
| 2854 | + $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2855 | + } |
|
| 2856 | + $html .= ' </span>' . wpautop(stripslashes($post->{$type['htmlvar_name']})) . '</div>';
|
|
| 2857 | + } |
|
| 2858 | + break; |
|
| 2859 | + case 'file': {
|
|
| 2860 | + $html_var = $type['htmlvar_name']; |
|
| 2861 | + |
|
| 2862 | + if (!empty($post->{$type['htmlvar_name']})) {
|
|
| 2863 | + $files = explode(",", $post->{$type['htmlvar_name']});
|
|
| 2864 | + |
|
| 2865 | + if (!empty($files)) {
|
|
| 2866 | + $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL; |
|
| 2867 | + $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
|
|
| 2868 | 2868 | |
| 2869 | - $file_paths = ''; |
|
| 2870 | - foreach ($files as $file) {
|
|
| 2871 | - if (!empty($file)) {
|
|
| 2872 | - $image_name_arr = explode('/', $file);
|
|
| 2873 | - $filename = end($image_name_arr); |
|
| 2874 | - |
|
| 2875 | - $arr_file_type = wp_check_filetype($filename); |
|
| 2876 | - if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
|
|
| 2877 | - continue; |
|
| 2878 | - } |
|
| 2879 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 2880 | - $uploaded_file_ext = $arr_file_type['ext']; |
|
| 2869 | + $file_paths = ''; |
|
| 2870 | + foreach ($files as $file) {
|
|
| 2871 | + if (!empty($file)) {
|
|
| 2872 | + $image_name_arr = explode('/', $file);
|
|
| 2873 | + $filename = end($image_name_arr); |
|
| 2874 | + |
|
| 2875 | + $arr_file_type = wp_check_filetype($filename); |
|
| 2876 | + if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
|
|
| 2877 | + continue; |
|
| 2878 | + } |
|
| 2879 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 2880 | + $uploaded_file_ext = $arr_file_type['ext']; |
|
| 2881 | 2881 | |
| 2882 | - if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
|
|
| 2883 | - continue; // Invalid file type. |
|
| 2884 | - } |
|
| 2885 | - |
|
| 2886 | - $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon');
|
|
| 2887 | - |
|
| 2888 | - // If the uploaded file is image |
|
| 2889 | - if (in_array($uploaded_file_type, $image_file_types)) {
|
|
| 2890 | - $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">'; |
|
| 2891 | - $file_paths .= '<a href="'.$file.'">'; |
|
| 2892 | - $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
|
|
| 2893 | - $file_paths .= '</a>'; |
|
| 2894 | - $file_paths .= '</div>'; |
|
| 2895 | - } else {
|
|
| 2896 | - $ext_path = '_' . $html_var . '_'; |
|
| 2897 | - $filename = explode($ext_path, $filename); |
|
| 2898 | - $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>'; |
|
| 2899 | - } |
|
| 2900 | - } |
|
| 2901 | - } |
|
| 2902 | - |
|
| 2903 | - if (strpos($field_icon, 'http') !== false) {
|
|
| 2904 | - $field_icon_af = ''; |
|
| 2905 | - } else if ($field_icon == '') {
|
|
| 2906 | - $field_icon_af = ''; |
|
| 2907 | - } else {
|
|
| 2908 | - $field_icon_af = $field_icon; |
|
| 2909 | - $field_icon = ''; |
|
| 2910 | - } |
|
| 2911 | - |
|
| 2912 | - $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2913 | - |
|
| 2914 | - |
|
| 2915 | - $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . ' geodir-custom-file-box" style="clear:both;"><span class="geodir-i-file" style="display:inline-block;vertical-align:top;padding-right:14px;' . $field_icon . '">' . $field_icon_af; |
|
| 2916 | - |
|
| 2917 | - if ($field_set_start == 1 && $site_title != '') {
|
|
| 2918 | - $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2919 | - } |
|
| 2920 | - |
|
| 2921 | - $html .= ' </span>' . $file_paths . '</div>'; |
|
| 2922 | - } |
|
| 2923 | - } |
|
| 2924 | - } |
|
| 2925 | - break; |
|
| 2926 | - } |
|
| 2927 | - |
|
| 2928 | - |
|
| 2929 | - /** |
|
| 2930 | - * Filter custom field output in tab. |
|
| 2931 | - * |
|
| 2932 | - * @since 1.5.6 |
|
| 2933 | - * |
|
| 2934 | - * @param string $html_var The HTML variable name for the field. |
|
| 2935 | - * @param string $html Custom field unfiltered HTML. |
|
| 2936 | - * @param array $variables_array Custom field variables array. |
|
| 2937 | - */ |
|
| 2938 | - $html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array);
|
|
| 2939 | - |
|
| 2940 | - $fieldset_html = ''; |
|
| 2941 | - if ($field_set_start == 1) {
|
|
| 2942 | - $add_html = false; |
|
| 2943 | - if ($type['type'] == 'fieldset' && $fieldset_count > 1) {
|
|
| 2944 | - if ($fieldset != '') {
|
|
| 2945 | - $add_html = true; |
|
| 2946 | - $label = $fieldset_arr[$fieldset_count - 1]['label']; |
|
| 2947 | - $htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name']; |
|
| 2948 | - } |
|
| 2949 | - $fieldset_html = $fieldset; |
|
| 2950 | - $fieldset = ''; |
|
| 2951 | - } else {
|
|
| 2952 | - $fieldset .= $html; |
|
| 2953 | - if ($total_fields == $count_field && $fieldset != '') {
|
|
| 2954 | - $add_html = true; |
|
| 2955 | - $label = $fieldset_arr[$fieldset_count]['label']; |
|
| 2956 | - $htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name']; |
|
| 2957 | - $fieldset_html = $fieldset; |
|
| 2958 | - } |
|
| 2959 | - } |
|
| 2960 | - |
|
| 2961 | - if ($add_html) {
|
|
| 2962 | - $tabs_arr[$htmlvar_name] = array( |
|
| 2963 | - 'heading_text' => __($label, 'geodirectory'), |
|
| 2964 | - 'is_active_tab' => false, |
|
| 2965 | - /** |
|
| 2966 | - * Filter if a custom field should be displayed on the details page tab. |
|
| 2967 | - * |
|
| 2968 | - * @since 1.0.0 |
|
| 2969 | - * @param string $htmlvar_name The field HTML var name. |
|
| 2970 | - */ |
|
| 2971 | - 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name),
|
|
| 2972 | - 'tab_content' => '<div class="geodir-company_info field-group">' . $fieldset_html . '</html>' |
|
| 2973 | - ); |
|
| 2974 | - } |
|
| 2975 | - } else {
|
|
| 2976 | - if ($html != '') {
|
|
| 2977 | - $tabs_arr[$field['htmlvar_name']] = array( |
|
| 2978 | - 'heading_text' => __($label, 'geodirectory'), |
|
| 2979 | - 'is_active_tab' => false, |
|
| 2980 | - /** This action is documented in geodirectory_hooks_actions.php */ |
|
| 2981 | - 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']),
|
|
| 2982 | - 'tab_content' => $html |
|
| 2983 | - ); |
|
| 2984 | - } |
|
| 2985 | - } |
|
| 2986 | - } |
|
| 2987 | - } |
|
| 2988 | - } |
|
| 2989 | - } |
|
| 2990 | - return $tabs_arr; |
|
| 2882 | + if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
|
|
| 2883 | + continue; // Invalid file type. |
|
| 2884 | + } |
|
| 2885 | + |
|
| 2886 | + $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon');
|
|
| 2887 | + |
|
| 2888 | + // If the uploaded file is image |
|
| 2889 | + if (in_array($uploaded_file_type, $image_file_types)) {
|
|
| 2890 | + $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">'; |
|
| 2891 | + $file_paths .= '<a href="'.$file.'">'; |
|
| 2892 | + $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
|
|
| 2893 | + $file_paths .= '</a>'; |
|
| 2894 | + $file_paths .= '</div>'; |
|
| 2895 | + } else {
|
|
| 2896 | + $ext_path = '_' . $html_var . '_'; |
|
| 2897 | + $filename = explode($ext_path, $filename); |
|
| 2898 | + $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>'; |
|
| 2899 | + } |
|
| 2900 | + } |
|
| 2901 | + } |
|
| 2902 | + |
|
| 2903 | + if (strpos($field_icon, 'http') !== false) {
|
|
| 2904 | + $field_icon_af = ''; |
|
| 2905 | + } else if ($field_icon == '') {
|
|
| 2906 | + $field_icon_af = ''; |
|
| 2907 | + } else {
|
|
| 2908 | + $field_icon_af = $field_icon; |
|
| 2909 | + $field_icon = ''; |
|
| 2910 | + } |
|
| 2911 | + |
|
| 2912 | + $geodir_odd_even = $field_set_start == 1 && $i % 2 == 0 ? 'geodir_more_info_even' : 'geodir_more_info_odd'; |
|
| 2913 | + |
|
| 2914 | + |
|
| 2915 | + $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . ' geodir-custom-file-box" style="clear:both;"><span class="geodir-i-file" style="display:inline-block;vertical-align:top;padding-right:14px;' . $field_icon . '">' . $field_icon_af; |
|
| 2916 | + |
|
| 2917 | + if ($field_set_start == 1 && $site_title != '') {
|
|
| 2918 | + $html .= ' ' . __($site_title, 'geodirectory') . ': '; |
|
| 2919 | + } |
|
| 2920 | + |
|
| 2921 | + $html .= ' </span>' . $file_paths . '</div>'; |
|
| 2922 | + } |
|
| 2923 | + } |
|
| 2924 | + } |
|
| 2925 | + break; |
|
| 2926 | + } |
|
| 2927 | + |
|
| 2928 | + |
|
| 2929 | + /** |
|
| 2930 | + * Filter custom field output in tab. |
|
| 2931 | + * |
|
| 2932 | + * @since 1.5.6 |
|
| 2933 | + * |
|
| 2934 | + * @param string $html_var The HTML variable name for the field. |
|
| 2935 | + * @param string $html Custom field unfiltered HTML. |
|
| 2936 | + * @param array $variables_array Custom field variables array. |
|
| 2937 | + */ |
|
| 2938 | + $html = apply_filters("geodir_tab_show_{$html_var}", $html, $variables_array);
|
|
| 2939 | + |
|
| 2940 | + $fieldset_html = ''; |
|
| 2941 | + if ($field_set_start == 1) {
|
|
| 2942 | + $add_html = false; |
|
| 2943 | + if ($type['type'] == 'fieldset' && $fieldset_count > 1) {
|
|
| 2944 | + if ($fieldset != '') {
|
|
| 2945 | + $add_html = true; |
|
| 2946 | + $label = $fieldset_arr[$fieldset_count - 1]['label']; |
|
| 2947 | + $htmlvar_name = $fieldset_arr[$fieldset_count - 1]['htmlvar_name']; |
|
| 2948 | + } |
|
| 2949 | + $fieldset_html = $fieldset; |
|
| 2950 | + $fieldset = ''; |
|
| 2951 | + } else {
|
|
| 2952 | + $fieldset .= $html; |
|
| 2953 | + if ($total_fields == $count_field && $fieldset != '') {
|
|
| 2954 | + $add_html = true; |
|
| 2955 | + $label = $fieldset_arr[$fieldset_count]['label']; |
|
| 2956 | + $htmlvar_name = $fieldset_arr[$fieldset_count]['htmlvar_name']; |
|
| 2957 | + $fieldset_html = $fieldset; |
|
| 2958 | + } |
|
| 2959 | + } |
|
| 2960 | + |
|
| 2961 | + if ($add_html) {
|
|
| 2962 | + $tabs_arr[$htmlvar_name] = array( |
|
| 2963 | + 'heading_text' => __($label, 'geodirectory'), |
|
| 2964 | + 'is_active_tab' => false, |
|
| 2965 | + /** |
|
| 2966 | + * Filter if a custom field should be displayed on the details page tab. |
|
| 2967 | + * |
|
| 2968 | + * @since 1.0.0 |
|
| 2969 | + * @param string $htmlvar_name The field HTML var name. |
|
| 2970 | + */ |
|
| 2971 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $htmlvar_name),
|
|
| 2972 | + 'tab_content' => '<div class="geodir-company_info field-group">' . $fieldset_html . '</html>' |
|
| 2973 | + ); |
|
| 2974 | + } |
|
| 2975 | + } else {
|
|
| 2976 | + if ($html != '') {
|
|
| 2977 | + $tabs_arr[$field['htmlvar_name']] = array( |
|
| 2978 | + 'heading_text' => __($label, 'geodirectory'), |
|
| 2979 | + 'is_active_tab' => false, |
|
| 2980 | + /** This action is documented in geodirectory_hooks_actions.php */ |
|
| 2981 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, $field['htmlvar_name']),
|
|
| 2982 | + 'tab_content' => $html |
|
| 2983 | + ); |
|
| 2984 | + } |
|
| 2985 | + } |
|
| 2986 | + } |
|
| 2987 | + } |
|
| 2988 | + } |
|
| 2989 | + } |
|
| 2990 | + return $tabs_arr; |
|
| 2991 | 2991 | } |
| 2992 | 2992 | |
| 2993 | 2993 | /* display add listing page for wpml */ |
@@ -3011,37 +3011,37 @@ discard block |
||
| 3011 | 3011 | */ |
| 3012 | 3012 | function geodir_add_post_status_author_page() |
| 3013 | 3013 | {
|
| 3014 | - global $wpdb, $post; |
|
| 3015 | - |
|
| 3016 | - $html = ''; |
|
| 3017 | - if (get_current_user_id()) {
|
|
| 3018 | - if (geodir_is_page('author') && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) {
|
|
| 3019 | - |
|
| 3020 | - // we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them. |
|
| 3021 | - $real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID");
|
|
| 3022 | - $status = "<strong>(";
|
|
| 3023 | - $status_icon = '<i class="fa fa-play"></i>'; |
|
| 3024 | - if ($real_status == 'publish') {
|
|
| 3025 | - $status .= __('Published', 'geodirectory');
|
|
| 3026 | - } else {
|
|
| 3027 | - $status .= __('Not published', 'geodirectory');
|
|
| 3028 | - $status_icon = '<i class="fa fa-pause"></i>'; |
|
| 3029 | - } |
|
| 3030 | - $status .= ")</strong>"; |
|
| 3014 | + global $wpdb, $post; |
|
| 3015 | + |
|
| 3016 | + $html = ''; |
|
| 3017 | + if (get_current_user_id()) {
|
|
| 3018 | + if (geodir_is_page('author') && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) {
|
|
| 3019 | + |
|
| 3020 | + // we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them. |
|
| 3021 | + $real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID");
|
|
| 3022 | + $status = "<strong>(";
|
|
| 3023 | + $status_icon = '<i class="fa fa-play"></i>'; |
|
| 3024 | + if ($real_status == 'publish') {
|
|
| 3025 | + $status .= __('Published', 'geodirectory');
|
|
| 3026 | + } else {
|
|
| 3027 | + $status .= __('Not published', 'geodirectory');
|
|
| 3028 | + $status_icon = '<i class="fa fa-pause"></i>'; |
|
| 3029 | + } |
|
| 3030 | + $status .= ")</strong>"; |
|
| 3031 | 3031 | |
| 3032 | - $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>';
|
|
| 3033 | - } |
|
| 3034 | - } |
|
| 3032 | + $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'geodirectory') . '</font>' . $status . '</span>';
|
|
| 3033 | + } |
|
| 3034 | + } |
|
| 3035 | 3035 | |
| 3036 | - if ($html != '') {
|
|
| 3037 | - /** |
|
| 3038 | - * Filter the post status text on the author page. |
|
| 3039 | - * |
|
| 3040 | - * @since 1.0.0 |
|
| 3041 | - * @param string $html The HTML of the status. |
|
| 3042 | - */ |
|
| 3043 | - echo apply_filters('geodir_filter_status_text_on_author_page', $html);
|
|
| 3044 | - } |
|
| 3036 | + if ($html != '') {
|
|
| 3037 | + /** |
|
| 3038 | + * Filter the post status text on the author page. |
|
| 3039 | + * |
|
| 3040 | + * @since 1.0.0 |
|
| 3041 | + * @param string $html The HTML of the status. |
|
| 3042 | + */ |
|
| 3043 | + echo apply_filters('geodir_filter_status_text_on_author_page', $html);
|
|
| 3044 | + } |
|
| 3045 | 3045 | |
| 3046 | 3046 | |
| 3047 | 3047 | } |
@@ -3055,21 +3055,21 @@ discard block |
||
| 3055 | 3055 | */ |
| 3056 | 3056 | function geodir_init_no_rating() |
| 3057 | 3057 | {
|
| 3058 | - if (get_option('geodir_disable_rating')) {
|
|
| 3059 | - remove_action('comment_form_logged_in_after', 'geodir_comment_rating_fields');
|
|
| 3060 | - remove_action('comment_form_before_fields', 'geodir_comment_rating_fields');
|
|
| 3061 | - remove_action('comment_form_logged_in_after', 'geodir_reviewrating_comment_rating_fields');
|
|
| 3062 | - remove_action('comment_form_before_fields', 'geodir_reviewrating_comment_rating_fields');
|
|
| 3063 | - remove_action('add_meta_boxes_comment', 'geodir_comment_add_meta_box');
|
|
| 3064 | - remove_action('add_meta_boxes', 'geodir_reviewrating_comment_metabox', 13);
|
|
| 3065 | - remove_filter('comment_text', 'geodir_wrap_comment_text', 40);
|
|
| 3066 | - |
|
| 3067 | - add_action('comment_form_logged_in_after', 'geodir_no_rating_rating_fields');
|
|
| 3068 | - add_action('comment_form_before_fields', 'geodir_no_rating_rating_fields');
|
|
| 3069 | - add_filter('comment_text', 'geodir_no_rating_comment_text', 100, 2);
|
|
| 3070 | - add_filter('geodir_detail_page_review_rating_html', 'geodir_no_rating_review_rating_html', 100);
|
|
| 3071 | - add_filter('geodir_get_sort_options', 'geodir_no_rating_get_sort_options', 100, 2);
|
|
| 3072 | - } |
|
| 3058 | + if (get_option('geodir_disable_rating')) {
|
|
| 3059 | + remove_action('comment_form_logged_in_after', 'geodir_comment_rating_fields');
|
|
| 3060 | + remove_action('comment_form_before_fields', 'geodir_comment_rating_fields');
|
|
| 3061 | + remove_action('comment_form_logged_in_after', 'geodir_reviewrating_comment_rating_fields');
|
|
| 3062 | + remove_action('comment_form_before_fields', 'geodir_reviewrating_comment_rating_fields');
|
|
| 3063 | + remove_action('add_meta_boxes_comment', 'geodir_comment_add_meta_box');
|
|
| 3064 | + remove_action('add_meta_boxes', 'geodir_reviewrating_comment_metabox', 13);
|
|
| 3065 | + remove_filter('comment_text', 'geodir_wrap_comment_text', 40);
|
|
| 3066 | + |
|
| 3067 | + add_action('comment_form_logged_in_after', 'geodir_no_rating_rating_fields');
|
|
| 3068 | + add_action('comment_form_before_fields', 'geodir_no_rating_rating_fields');
|
|
| 3069 | + add_filter('comment_text', 'geodir_no_rating_comment_text', 100, 2);
|
|
| 3070 | + add_filter('geodir_detail_page_review_rating_html', 'geodir_no_rating_review_rating_html', 100);
|
|
| 3071 | + add_filter('geodir_get_sort_options', 'geodir_no_rating_get_sort_options', 100, 2);
|
|
| 3072 | + } |
|
| 3073 | 3073 | } |
| 3074 | 3074 | |
| 3075 | 3075 | /** |
@@ -3081,20 +3081,20 @@ discard block |
||
| 3081 | 3081 | */ |
| 3082 | 3082 | function geodir_no_rating_rating_fields() |
| 3083 | 3083 | {
|
| 3084 | - global $post; |
|
| 3084 | + global $post; |
|
| 3085 | 3085 | |
| 3086 | - $post_types = geodir_get_posttypes(); |
|
| 3086 | + $post_types = geodir_get_posttypes(); |
|
| 3087 | 3087 | |
| 3088 | - if (!empty($post) && isset($post->post_type) && in_array($post->post_type, $post_types)) {
|
|
| 3089 | - if (is_plugin_active('geodir_review_rating_manager/geodir_review_rating_manager.php')) {
|
|
| 3090 | - echo '<input type="hidden" value="1" name="geodir_rating[overall]" />'; |
|
| 3091 | - if (get_option('geodir_reviewrating_enable_images')) {
|
|
| 3092 | - geodir_reviewrating_rating_img_html(); |
|
| 3093 | - } |
|
| 3094 | - } else {
|
|
| 3095 | - echo '<input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="1" />'; |
|
| 3096 | - } |
|
| 3097 | - } |
|
| 3088 | + if (!empty($post) && isset($post->post_type) && in_array($post->post_type, $post_types)) {
|
|
| 3089 | + if (is_plugin_active('geodir_review_rating_manager/geodir_review_rating_manager.php')) {
|
|
| 3090 | + echo '<input type="hidden" value="1" name="geodir_rating[overall]" />'; |
|
| 3091 | + if (get_option('geodir_reviewrating_enable_images')) {
|
|
| 3092 | + geodir_reviewrating_rating_img_html(); |
|
| 3093 | + } |
|
| 3094 | + } else {
|
|
| 3095 | + echo '<input type="hidden" id="geodir_overallrating" name="geodir_overallrating" value="1" />'; |
|
| 3096 | + } |
|
| 3097 | + } |
|
| 3098 | 3098 | } |
| 3099 | 3099 | |
| 3100 | 3100 | /** |
@@ -3108,11 +3108,11 @@ discard block |
||
| 3108 | 3108 | */ |
| 3109 | 3109 | function geodir_no_rating_comment_text($content, $comment = '') |
| 3110 | 3110 | {
|
| 3111 | - if (!is_admin()) {
|
|
| 3112 | - return '<div class="description">' . $content . '</div>'; |
|
| 3113 | - } else {
|
|
| 3114 | - return $content; |
|
| 3115 | - } |
|
| 3111 | + if (!is_admin()) {
|
|
| 3112 | + return '<div class="description">' . $content . '</div>'; |
|
| 3113 | + } else {
|
|
| 3114 | + return $content; |
|
| 3115 | + } |
|
| 3116 | 3116 | } |
| 3117 | 3117 | |
| 3118 | 3118 | /** |
@@ -3125,7 +3125,7 @@ discard block |
||
| 3125 | 3125 | */ |
| 3126 | 3126 | function geodir_no_rating_review_rating_html($content = '') |
| 3127 | 3127 | {
|
| 3128 | - return NULL; |
|
| 3128 | + return NULL; |
|
| 3129 | 3129 | } |
| 3130 | 3130 | |
| 3131 | 3131 | /** |
@@ -3139,19 +3139,19 @@ discard block |
||
| 3139 | 3139 | */ |
| 3140 | 3140 | function geodir_no_rating_get_sort_options($options, $post_type = '') |
| 3141 | 3141 | {
|
| 3142 | - $new_options = array(); |
|
| 3143 | - if (!empty($options)) {
|
|
| 3144 | - foreach ($options as $option) {
|
|
| 3145 | - if (is_object($option) && isset($option->htmlvar_name) && $option->htmlvar_name == 'overall_rating') {
|
|
| 3146 | - continue; |
|
| 3147 | - } |
|
| 3148 | - $new_options[] = $option; |
|
| 3149 | - } |
|
| 3142 | + $new_options = array(); |
|
| 3143 | + if (!empty($options)) {
|
|
| 3144 | + foreach ($options as $option) {
|
|
| 3145 | + if (is_object($option) && isset($option->htmlvar_name) && $option->htmlvar_name == 'overall_rating') {
|
|
| 3146 | + continue; |
|
| 3147 | + } |
|
| 3148 | + $new_options[] = $option; |
|
| 3149 | + } |
|
| 3150 | 3150 | |
| 3151 | - $options = $new_options; |
|
| 3152 | - } |
|
| 3151 | + $options = $new_options; |
|
| 3152 | + } |
|
| 3153 | 3153 | |
| 3154 | - return $options; |
|
| 3154 | + return $options; |
|
| 3155 | 3155 | } |
| 3156 | 3156 | |
| 3157 | 3157 | add_filter('geodir_all_js_msg', 'geodir_all_js_msg_no_rating', 100);
|
@@ -3165,11 +3165,11 @@ discard block |
||
| 3165 | 3165 | */ |
| 3166 | 3166 | function geodir_all_js_msg_no_rating($msg = array()) |
| 3167 | 3167 | {
|
| 3168 | - if (get_option('geodir_disable_rating')) {
|
|
| 3169 | - $msg['gd_cmt_no_rating'] = true; |
|
| 3170 | - } |
|
| 3168 | + if (get_option('geodir_disable_rating')) {
|
|
| 3169 | + $msg['gd_cmt_no_rating'] = true; |
|
| 3170 | + } |
|
| 3171 | 3171 | |
| 3172 | - return $msg; |
|
| 3172 | + return $msg; |
|
| 3173 | 3173 | } |
| 3174 | 3174 | |
| 3175 | 3175 | add_filter('body_class', 'geodir_body_class_no_rating', 100);
|
@@ -3183,13 +3183,13 @@ discard block |
||
| 3183 | 3183 | */ |
| 3184 | 3184 | function geodir_body_class_no_rating($classes = array()) |
| 3185 | 3185 | {
|
| 3186 | - if (get_option('geodir_disable_rating')) {
|
|
| 3187 | - $classes[] = 'gd-no-rating'; |
|
| 3188 | - } |
|
| 3186 | + if (get_option('geodir_disable_rating')) {
|
|
| 3187 | + $classes[] = 'gd-no-rating'; |
|
| 3188 | + } |
|
| 3189 | 3189 | |
| 3190 | - $classes[] = 'gd-map-' . geodir_map_name(); |
|
| 3190 | + $classes[] = 'gd-map-' . geodir_map_name(); |
|
| 3191 | 3191 | |
| 3192 | - return $classes; |
|
| 3192 | + return $classes; |
|
| 3193 | 3193 | } |
| 3194 | 3194 | |
| 3195 | 3195 | add_filter('admin_body_class', 'geodir_admin_body_class_no_rating', 100);
|
@@ -3203,13 +3203,13 @@ discard block |
||
| 3203 | 3203 | */ |
| 3204 | 3204 | function geodir_admin_body_class_no_rating($class = '') |
| 3205 | 3205 | {
|
| 3206 | - if (get_option('geodir_disable_rating')) {
|
|
| 3207 | - $class .= ' gd-no-rating'; |
|
| 3208 | - } |
|
| 3206 | + if (get_option('geodir_disable_rating')) {
|
|
| 3207 | + $class .= ' gd-no-rating'; |
|
| 3208 | + } |
|
| 3209 | 3209 | |
| 3210 | - $class .= ' gd-map-' . geodir_map_name(); |
|
| 3210 | + $class .= ' gd-map-' . geodir_map_name(); |
|
| 3211 | 3211 | |
| 3212 | - return $class; |
|
| 3212 | + return $class; |
|
| 3213 | 3213 | } |
| 3214 | 3214 | |
| 3215 | 3215 | add_action('wp_head', 'geodir_wp_head_no_rating');
|
@@ -3222,10 +3222,10 @@ discard block |
||
| 3222 | 3222 | */ |
| 3223 | 3223 | function geodir_wp_head_no_rating() |
| 3224 | 3224 | {
|
| 3225 | - if (get_option('geodir_disable_rating')) {
|
|
| 3226 | - echo '<style>body .geodir-rating, body .geodir-bubble-rating, body .gd_ratings_module_box{display:none!important;}</style>';
|
|
| 3227 | - echo '<script type="text/javascript">jQuery(function(){jQuery(".gd_rating_show").parent(".geodir-rating").remove();});</script>';
|
|
| 3228 | - } |
|
| 3225 | + if (get_option('geodir_disable_rating')) {
|
|
| 3226 | + echo '<style>body .geodir-rating, body .geodir-bubble-rating, body .gd_ratings_module_box{display:none!important;}</style>';
|
|
| 3227 | + echo '<script type="text/javascript">jQuery(function(){jQuery(".gd_rating_show").parent(".geodir-rating").remove();});</script>';
|
|
| 3228 | + } |
|
| 3229 | 3229 | } |
| 3230 | 3230 | |
| 3231 | 3231 | add_filter('geodir_load_db_language', 'geodir_load_custom_field_translation');
|
@@ -3242,36 +3242,36 @@ discard block |
||
| 3242 | 3242 | * @return array Translation texts. |
| 3243 | 3243 | */ |
| 3244 | 3244 | function geodir_load_gd_options_text_translation($translation_texts = array()) {
|
| 3245 | - $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array(); |
|
| 3246 | - |
|
| 3247 | - $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin');
|
|
| 3248 | - |
|
| 3249 | - /** |
|
| 3250 | - * Filters the geodirectory option names that requires to add for translation. |
|
| 3251 | - * |
|
| 3252 | - * @since 1.5.7 |
|
| 3253 | - * @package GeoDirectory |
|
| 3254 | - * |
|
| 3255 | - * @param array $gd_options Array of option names. |
|
| 3256 | - */ |
|
| 3257 | - $gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options);
|
|
| 3258 | - $gd_options = array_unique($gd_options); |
|
| 3259 | - |
|
| 3260 | - if (!empty($gd_options)) {
|
|
| 3261 | - foreach ($gd_options as $gd_option) {
|
|
| 3262 | - if ($gd_option != '' && $option_value = get_option($gd_option)) {
|
|
| 3263 | - $option_value = is_string($option_value) ? stripslashes_deep($option_value) : ''; |
|
| 3245 | + $translation_texts = !empty( $translation_texts ) && is_array( $translation_texts ) ? $translation_texts : array(); |
|
| 3246 | + |
|
| 3247 | + $gd_options = array('geodir_post_submited_success_email_subject_admin', 'geodir_post_submited_success_email_content_admin', 'geodir_post_submited_success_email_subject', 'geodir_post_submited_success_email_content', 'geodir_forgot_password_subject', 'geodir_forgot_password_content', 'geodir_registration_success_email_subject', 'geodir_registration_success_email_content', 'geodir_post_published_email_subject', 'geodir_post_published_email_content', 'geodir_email_friend_subject', 'geodir_email_friend_content', 'geodir_email_enquiry_subject', 'geodir_email_enquiry_content', 'geodir_post_added_success_msg_content', 'geodir_post_edited_email_subject_admin', 'geodir_post_edited_email_content_admin');
|
|
| 3248 | + |
|
| 3249 | + /** |
|
| 3250 | + * Filters the geodirectory option names that requires to add for translation. |
|
| 3251 | + * |
|
| 3252 | + * @since 1.5.7 |
|
| 3253 | + * @package GeoDirectory |
|
| 3254 | + * |
|
| 3255 | + * @param array $gd_options Array of option names. |
|
| 3256 | + */ |
|
| 3257 | + $gd_options = apply_filters('geodir_gd_options_for_translation', $gd_options);
|
|
| 3258 | + $gd_options = array_unique($gd_options); |
|
| 3259 | + |
|
| 3260 | + if (!empty($gd_options)) {
|
|
| 3261 | + foreach ($gd_options as $gd_option) {
|
|
| 3262 | + if ($gd_option != '' && $option_value = get_option($gd_option)) {
|
|
| 3263 | + $option_value = is_string($option_value) ? stripslashes_deep($option_value) : ''; |
|
| 3264 | 3264 | |
| 3265 | - if ($option_value != '' && !in_array($option_value, $translation_texts)) {
|
|
| 3266 | - $translation_texts[] = stripslashes_deep($option_value); |
|
| 3267 | - } |
|
| 3268 | - } |
|
| 3269 | - } |
|
| 3270 | - } |
|
| 3265 | + if ($option_value != '' && !in_array($option_value, $translation_texts)) {
|
|
| 3266 | + $translation_texts[] = stripslashes_deep($option_value); |
|
| 3267 | + } |
|
| 3268 | + } |
|
| 3269 | + } |
|
| 3270 | + } |
|
| 3271 | 3271 | |
| 3272 | - $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
| 3272 | + $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
| 3273 | 3273 | |
| 3274 | - return $translation_texts; |
|
| 3274 | + return $translation_texts; |
|
| 3275 | 3275 | } |
| 3276 | 3276 | |
| 3277 | 3277 | add_filter('geodir_load_db_language', 'geodir_load_gd_options_text_translation');
|
@@ -3285,13 +3285,13 @@ discard block |
||
| 3285 | 3285 | |
| 3286 | 3286 | add_filter('get_comments_link', 'gd_get_comments_link', 10, 2);
|
| 3287 | 3287 | function gd_get_comments_link($comments_link, $post_id) {
|
| 3288 | - $post_type = get_post_type($post_id); |
|
| 3288 | + $post_type = get_post_type($post_id); |
|
| 3289 | 3289 | |
| 3290 | - $all_postypes = geodir_get_posttypes(); |
|
| 3291 | - if (in_array($post_type, $all_postypes)) {
|
|
| 3292 | - $comments_link = str_replace('#comments', '#reviews', $comments_link);
|
|
| 3293 | - $comments_link = str_replace('#respond', '#reviews', $comments_link);
|
|
| 3294 | - } |
|
| 3290 | + $all_postypes = geodir_get_posttypes(); |
|
| 3291 | + if (in_array($post_type, $all_postypes)) {
|
|
| 3292 | + $comments_link = str_replace('#comments', '#reviews', $comments_link);
|
|
| 3293 | + $comments_link = str_replace('#respond', '#reviews', $comments_link);
|
|
| 3294 | + } |
|
| 3295 | 3295 | |
| 3296 | - return $comments_link; |
|
| 3296 | + return $comments_link; |
|
| 3297 | 3297 | } |
| 3298 | 3298 | \ No newline at end of file |
@@ -20,468 +20,468 @@ discard block |
||
| 20 | 20 | function geodir_set_postcat_structure($post_id, $taxonomy, $default_cat = '', $category_str = '') |
| 21 | 21 | {
|
| 22 | 22 | |
| 23 | - $post_cat_ids = geodir_get_post_meta($post_id, $taxonomy); |
|
| 24 | - if (!empty($post_cat_ids)) |
|
| 25 | - $post_cat_array = explode(",", trim($post_cat_ids, ","));
|
|
| 26 | - |
|
| 27 | - if (!isset($default_cat) || empty($default_cat)) {
|
|
| 28 | - $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : ''; |
|
| 29 | - }else{
|
|
| 30 | - if(!is_int($default_cat)){
|
|
| 31 | - $category = get_term_by('name', $default_cat, $taxonomy);
|
|
| 32 | - if(isset($category->term_id)){
|
|
| 33 | - $default_cat = $category->term_id; |
|
| 34 | - } |
|
| 35 | - } |
|
| 23 | + $post_cat_ids = geodir_get_post_meta($post_id, $taxonomy); |
|
| 24 | + if (!empty($post_cat_ids)) |
|
| 25 | + $post_cat_array = explode(",", trim($post_cat_ids, ","));
|
|
| 26 | + |
|
| 27 | + if (!isset($default_cat) || empty($default_cat)) {
|
|
| 28 | + $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : ''; |
|
| 29 | + }else{
|
|
| 30 | + if(!is_int($default_cat)){
|
|
| 31 | + $category = get_term_by('name', $default_cat, $taxonomy);
|
|
| 32 | + if(isset($category->term_id)){
|
|
| 33 | + $default_cat = $category->term_id; |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | - geodir_save_post_meta($post_id, 'default_category', $default_cat); |
|
| 40 | + geodir_save_post_meta($post_id, 'default_category', $default_cat); |
|
| 41 | 41 | |
| 42 | - if (isset($category_str) && empty($category_str)) {
|
|
| 42 | + if (isset($category_str) && empty($category_str)) {
|
|
| 43 | 43 | |
| 44 | - $post_cat_str = ''; |
|
| 45 | - $post_categories = array(); |
|
| 46 | - if (isset($post_cat_array) && is_array($post_cat_array) && !empty($post_cat_array)) {
|
|
| 47 | - $post_cat_str = implode(",y:#", $post_cat_array);
|
|
| 48 | - $post_cat_str .= ",y:"; |
|
| 49 | - $post_cat_str = substr_replace($post_cat_str, ',y,d:', strpos($post_cat_str, ',y:'), strlen(',y:'));
|
|
| 50 | - } |
|
| 51 | - $post_categories[$taxonomy] = $post_cat_str; |
|
| 52 | - $category_str = $post_categories; |
|
| 53 | - } |
|
| 44 | + $post_cat_str = ''; |
|
| 45 | + $post_categories = array(); |
|
| 46 | + if (isset($post_cat_array) && is_array($post_cat_array) && !empty($post_cat_array)) {
|
|
| 47 | + $post_cat_str = implode(",y:#", $post_cat_array);
|
|
| 48 | + $post_cat_str .= ",y:"; |
|
| 49 | + $post_cat_str = substr_replace($post_cat_str, ',y,d:', strpos($post_cat_str, ',y:'), strlen(',y:'));
|
|
| 50 | + } |
|
| 51 | + $post_categories[$taxonomy] = $post_cat_str; |
|
| 52 | + $category_str = $post_categories; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - $change_cat_str = $category_str[$taxonomy]; |
|
| 55 | + $change_cat_str = $category_str[$taxonomy]; |
|
| 56 | 56 | |
| 57 | - $default_pos = strpos($change_cat_str, 'd:'); |
|
| 57 | + $default_pos = strpos($change_cat_str, 'd:'); |
|
| 58 | 58 | |
| 59 | - if ($default_pos === false) {
|
|
| 59 | + if ($default_pos === false) {
|
|
| 60 | 60 | |
| 61 | - $change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str); |
|
| 61 | + $change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str); |
|
| 62 | 62 | |
| 63 | - } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - $category_str[$taxonomy] = $change_cat_str; |
|
| 65 | + $category_str[$taxonomy] = $change_cat_str; |
|
| 66 | 66 | |
| 67 | - update_post_meta($post_id, 'post_categories', $category_str); |
|
| 67 | + update_post_meta($post_id, 'post_categories', $category_str); |
|
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | if (!function_exists('geodir_save_listing')) {
|
| 73 | - /** |
|
| 74 | - * Saves listing in the database using given information. |
|
| 75 | - * |
|
| 76 | - * @since 1.0.0 |
|
| 77 | - * @since 1.5.4 New parameter $wp_error added. |
|
| 78 | - * @package GeoDirectory |
|
| 79 | - * @global object $wpdb WordPress Database object. |
|
| 80 | - * @global object $post The current post object. |
|
| 81 | - * @global object $current_user Current user object. |
|
| 73 | + /** |
|
| 74 | + * Saves listing in the database using given information. |
|
| 75 | + * |
|
| 76 | + * @since 1.0.0 |
|
| 77 | + * @since 1.5.4 New parameter $wp_error added. |
|
| 78 | + * @package GeoDirectory |
|
| 79 | + * @global object $wpdb WordPress Database object. |
|
| 80 | + * @global object $post The current post object. |
|
| 81 | + * @global object $current_user Current user object. |
|
| 82 | 82 | * @global object $gd_session GeoDirectory Session object. |
| 83 | - * @param array $request_info {
|
|
| 84 | - * Array of request info arguments. |
|
| 85 | - * |
|
| 86 | - * @type string $action Ajax action name. |
|
| 87 | - * @type string $geodir_ajax Ajax type. |
|
| 88 | - * @type string $ajax_action Ajax action. |
|
| 89 | - * @type string $listing_type Listing type. |
|
| 90 | - * @type string $pid Default Post ID. |
|
| 91 | - * @type string $preview Todo Desc needed. |
|
| 92 | - * @type string $add_listing_page_id Add listing page ID. |
|
| 93 | - * @type string $post_title Listing title. |
|
| 94 | - * @type string $post_desc Listing Description. |
|
| 95 | - * @type string $post_tags Listing tags. |
|
| 96 | - * @type array $cat_limit Category limit. |
|
| 97 | - * @type array $post_category Category IDs. |
|
| 98 | - * @type array $post_category_str Category string. |
|
| 99 | - * @type string $post_default_category Default category ID. |
|
| 100 | - * @type string $post_address Listing address. |
|
| 101 | - * @type string $geodir_location_add_listing_country_val Add listing country value. |
|
| 102 | - * @type string $post_country Listing country. |
|
| 103 | - * @type string $geodir_location_add_listing_region_val Add listing region value. |
|
| 104 | - * @type string $post_region Listing region. |
|
| 105 | - * @type string $geodir_location_add_listing_city_val Add listing city value. |
|
| 106 | - * @type string $post_city Listing city. |
|
| 107 | - * @type string $post_zip Listing zip. |
|
| 108 | - * @type string $post_latitude Listing latitude. |
|
| 109 | - * @type string $post_longitude Listing longitude. |
|
| 110 | - * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
| 111 | - * @type string $post_mapzoom Listing mapzoom Default "9". |
|
| 112 | - * @type string $geodir_timing Business timing info. |
|
| 113 | - * @type string $geodir_contact Contact number. |
|
| 114 | - * @type string $geodir_email Business contact email. |
|
| 115 | - * @type string $geodir_website Business website. |
|
| 116 | - * @type string $geodir_twitter Twitter link. |
|
| 117 | - * @type string $geodir_facebook Facebook link. |
|
| 118 | - * @type string $geodir_video Video link. |
|
| 119 | - * @type string $geodir_special_offers Speacial offers. |
|
| 120 | - * @type string $post_images Post image urls. |
|
| 121 | - * @type string $post_imagesimage_limit Post images limit. |
|
| 122 | - * @type string $post_imagestotImg Todo Desc needed. |
|
| 123 | - * @type string $geodir_accept_term_condition Has accepted terms and conditions?. |
|
| 124 | - * @type string $geodir_spamblocker Todo Desc needed. |
|
| 125 | - * @type string $geodir_filled_by_spam_bot Todo Desc needed. |
|
| 126 | - * |
|
| 127 | - * } |
|
| 128 | - * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
| 129 | - * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false. |
|
| 130 | - * @return int|string|WP_Error Created post id or WP_Error on failure. |
|
| 131 | - */ |
|
| 132 | - function geodir_save_listing($request_info = array(), $dummy = false, $wp_error = false) |
|
| 133 | - {
|
|
| 134 | - global $wpdb, $current_user, $gd_session; |
|
| 135 | - |
|
| 136 | - $last_post_id = ''; |
|
| 137 | - |
|
| 138 | - if ($gd_session->get('listing') && !$dummy) {
|
|
| 139 | - $request_info = array(); |
|
| 140 | - $request_session = $gd_session->get('listing');
|
|
| 141 | - $request_info = array_merge($_REQUEST, $request_session); |
|
| 142 | - } else if (!$gd_session->get('listing') && !$dummy) {
|
|
| 143 | - global $post; |
|
| 144 | - $request_info['pid'] = !empty($post->ID) ? $post->ID : (!empty($request_info['post_id']) ? $request_info['post_id'] : NULL); |
|
| 145 | - $request_info['post_title'] = $request_info['post_title']; |
|
| 146 | - $request_info['listing_type'] = $post->post_type; |
|
| 147 | - $request_info['post_desc'] = $request_info['content']; |
|
| 148 | - } else if (!$dummy) {
|
|
| 149 | - return false; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - /** |
|
| 153 | - * Filter the request_info array. |
|
| 154 | - * |
|
| 155 | - * You can use this filter to modify request_info array. |
|
| 156 | - * |
|
| 157 | - * @since 1.0.0 |
|
| 158 | - * @package GeoDirectory |
|
| 159 | - * @param array $request_info See {@see geodir_save_listing()} for accepted args.
|
|
| 160 | - */ |
|
| 161 | - $request_info = apply_filters('geodir_action_get_request_info', $request_info);
|
|
| 162 | - |
|
| 163 | - // Check if we need to save post location as new location |
|
| 164 | - $location_result = geodir_get_default_location(); |
|
| 165 | - |
|
| 166 | - if ($location_result->location_id > 0) {
|
|
| 167 | - if (isset($request_info['post_city']) && isset($request_info['post_region'])) {
|
|
| 168 | - $request_info['post_location'] = array( |
|
| 169 | - 'city' => $request_info['post_city'], |
|
| 170 | - 'region' => isset($request_info['post_region']) ? $request_info['post_region'] : '', |
|
| 171 | - 'country' => isset($request_info['post_country']) ? $request_info['post_country'] : '', |
|
| 172 | - 'geo_lat' => isset($request_info['post_latitude']) ? $request_info['post_latitude'] : '', |
|
| 173 | - 'geo_lng' => isset($request_info['post_longitude']) ? $request_info['post_longitude'] : '' |
|
| 174 | - ); |
|
| 175 | - |
|
| 176 | - $post_location_info = $request_info['post_location']; |
|
| 177 | - |
|
| 178 | - if ($location_id = geodir_add_new_location($post_location_info)) {
|
|
| 179 | - $post_location_id = $location_id; |
|
| 180 | - } |
|
| 181 | - } else {
|
|
| 182 | - $post_location_id = $location_result->location_id; |
|
| 183 | - } |
|
| 184 | - } else {
|
|
| 185 | - $post_location_id = $location_result->location_id; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - if ($dummy) {
|
|
| 189 | - $post_status = 'publish'; |
|
| 190 | - } else {
|
|
| 191 | - $post_status = geodir_new_post_default_status(); |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - if (isset($request_info['pid']) && $request_info['pid'] != '') {
|
|
| 195 | - $post_status = get_post_status($request_info['pid']); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - /* fix change of slug on every title edit */ |
|
| 199 | - if (!isset($request_info['post_name'])) {
|
|
| 200 | - $request_info['post_name'] = $request_info['post_title']; |
|
| 201 | - |
|
| 202 | - if (!empty($request_info['pid'])) {
|
|
| 203 | - $post_info = get_post($request_info['pid']); |
|
| 204 | - |
|
| 205 | - if (!empty($post_info) && isset($post_info->post_name)) {
|
|
| 206 | - $request_info['post_name'] = $post_info->post_name; |
|
| 207 | - } |
|
| 208 | - } |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - $post = array( |
|
| 212 | - 'post_content' => $request_info['post_desc'], |
|
| 213 | - 'post_status' => $post_status, |
|
| 214 | - 'post_title' => $request_info['post_title'], |
|
| 215 | - 'post_name' => $request_info['post_name'], |
|
| 216 | - 'post_type' => $request_info['listing_type'] |
|
| 217 | - ); |
|
| 218 | - |
|
| 219 | - /** |
|
| 220 | - * Called before a listing is saved to the database. |
|
| 221 | - * |
|
| 222 | - * @since 1.0.0 |
|
| 223 | - * @param object $post The post object. |
|
| 224 | - */ |
|
| 225 | - do_action_ref_array('geodir_before_save_listing', $post);
|
|
| 83 | + * @param array $request_info {
|
|
| 84 | + * Array of request info arguments. |
|
| 85 | + * |
|
| 86 | + * @type string $action Ajax action name. |
|
| 87 | + * @type string $geodir_ajax Ajax type. |
|
| 88 | + * @type string $ajax_action Ajax action. |
|
| 89 | + * @type string $listing_type Listing type. |
|
| 90 | + * @type string $pid Default Post ID. |
|
| 91 | + * @type string $preview Todo Desc needed. |
|
| 92 | + * @type string $add_listing_page_id Add listing page ID. |
|
| 93 | + * @type string $post_title Listing title. |
|
| 94 | + * @type string $post_desc Listing Description. |
|
| 95 | + * @type string $post_tags Listing tags. |
|
| 96 | + * @type array $cat_limit Category limit. |
|
| 97 | + * @type array $post_category Category IDs. |
|
| 98 | + * @type array $post_category_str Category string. |
|
| 99 | + * @type string $post_default_category Default category ID. |
|
| 100 | + * @type string $post_address Listing address. |
|
| 101 | + * @type string $geodir_location_add_listing_country_val Add listing country value. |
|
| 102 | + * @type string $post_country Listing country. |
|
| 103 | + * @type string $geodir_location_add_listing_region_val Add listing region value. |
|
| 104 | + * @type string $post_region Listing region. |
|
| 105 | + * @type string $geodir_location_add_listing_city_val Add listing city value. |
|
| 106 | + * @type string $post_city Listing city. |
|
| 107 | + * @type string $post_zip Listing zip. |
|
| 108 | + * @type string $post_latitude Listing latitude. |
|
| 109 | + * @type string $post_longitude Listing longitude. |
|
| 110 | + * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
| 111 | + * @type string $post_mapzoom Listing mapzoom Default "9". |
|
| 112 | + * @type string $geodir_timing Business timing info. |
|
| 113 | + * @type string $geodir_contact Contact number. |
|
| 114 | + * @type string $geodir_email Business contact email. |
|
| 115 | + * @type string $geodir_website Business website. |
|
| 116 | + * @type string $geodir_twitter Twitter link. |
|
| 117 | + * @type string $geodir_facebook Facebook link. |
|
| 118 | + * @type string $geodir_video Video link. |
|
| 119 | + * @type string $geodir_special_offers Speacial offers. |
|
| 120 | + * @type string $post_images Post image urls. |
|
| 121 | + * @type string $post_imagesimage_limit Post images limit. |
|
| 122 | + * @type string $post_imagestotImg Todo Desc needed. |
|
| 123 | + * @type string $geodir_accept_term_condition Has accepted terms and conditions?. |
|
| 124 | + * @type string $geodir_spamblocker Todo Desc needed. |
|
| 125 | + * @type string $geodir_filled_by_spam_bot Todo Desc needed. |
|
| 126 | + * |
|
| 127 | + * } |
|
| 128 | + * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
| 129 | + * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false. |
|
| 130 | + * @return int|string|WP_Error Created post id or WP_Error on failure. |
|
| 131 | + */ |
|
| 132 | + function geodir_save_listing($request_info = array(), $dummy = false, $wp_error = false) |
|
| 133 | + {
|
|
| 134 | + global $wpdb, $current_user, $gd_session; |
|
| 135 | + |
|
| 136 | + $last_post_id = ''; |
|
| 137 | + |
|
| 138 | + if ($gd_session->get('listing') && !$dummy) {
|
|
| 139 | + $request_info = array(); |
|
| 140 | + $request_session = $gd_session->get('listing');
|
|
| 141 | + $request_info = array_merge($_REQUEST, $request_session); |
|
| 142 | + } else if (!$gd_session->get('listing') && !$dummy) {
|
|
| 143 | + global $post; |
|
| 144 | + $request_info['pid'] = !empty($post->ID) ? $post->ID : (!empty($request_info['post_id']) ? $request_info['post_id'] : NULL); |
|
| 145 | + $request_info['post_title'] = $request_info['post_title']; |
|
| 146 | + $request_info['listing_type'] = $post->post_type; |
|
| 147 | + $request_info['post_desc'] = $request_info['content']; |
|
| 148 | + } else if (!$dummy) {
|
|
| 149 | + return false; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + /** |
|
| 153 | + * Filter the request_info array. |
|
| 154 | + * |
|
| 155 | + * You can use this filter to modify request_info array. |
|
| 156 | + * |
|
| 157 | + * @since 1.0.0 |
|
| 158 | + * @package GeoDirectory |
|
| 159 | + * @param array $request_info See {@see geodir_save_listing()} for accepted args.
|
|
| 160 | + */ |
|
| 161 | + $request_info = apply_filters('geodir_action_get_request_info', $request_info);
|
|
| 162 | + |
|
| 163 | + // Check if we need to save post location as new location |
|
| 164 | + $location_result = geodir_get_default_location(); |
|
| 165 | + |
|
| 166 | + if ($location_result->location_id > 0) {
|
|
| 167 | + if (isset($request_info['post_city']) && isset($request_info['post_region'])) {
|
|
| 168 | + $request_info['post_location'] = array( |
|
| 169 | + 'city' => $request_info['post_city'], |
|
| 170 | + 'region' => isset($request_info['post_region']) ? $request_info['post_region'] : '', |
|
| 171 | + 'country' => isset($request_info['post_country']) ? $request_info['post_country'] : '', |
|
| 172 | + 'geo_lat' => isset($request_info['post_latitude']) ? $request_info['post_latitude'] : '', |
|
| 173 | + 'geo_lng' => isset($request_info['post_longitude']) ? $request_info['post_longitude'] : '' |
|
| 174 | + ); |
|
| 175 | + |
|
| 176 | + $post_location_info = $request_info['post_location']; |
|
| 177 | + |
|
| 178 | + if ($location_id = geodir_add_new_location($post_location_info)) {
|
|
| 179 | + $post_location_id = $location_id; |
|
| 180 | + } |
|
| 181 | + } else {
|
|
| 182 | + $post_location_id = $location_result->location_id; |
|
| 183 | + } |
|
| 184 | + } else {
|
|
| 185 | + $post_location_id = $location_result->location_id; |
|
| 186 | + } |
|
| 226 | 187 | |
| 227 | - $send_post_submit_mail = false; |
|
| 188 | + if ($dummy) {
|
|
| 189 | + $post_status = 'publish'; |
|
| 190 | + } else {
|
|
| 191 | + $post_status = geodir_new_post_default_status(); |
|
| 192 | + } |
|
| 228 | 193 | |
| 229 | - // unhook this function so it doesn't loop infinitely |
|
| 230 | - remove_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 194 | + if (isset($request_info['pid']) && $request_info['pid'] != '') {
|
|
| 195 | + $post_status = get_post_status($request_info['pid']); |
|
| 196 | + } |
|
| 231 | 197 | |
| 232 | - if (isset($request_info['pid']) && $request_info['pid'] != '') {
|
|
| 233 | - $post['ID'] = $request_info['pid']; |
|
| 198 | + /* fix change of slug on every title edit */ |
|
| 199 | + if (!isset($request_info['post_name'])) {
|
|
| 200 | + $request_info['post_name'] = $request_info['post_title']; |
|
| 234 | 201 | |
| 235 | - $last_post_id = wp_update_post($post, $wp_error); |
|
| 236 | - } else {
|
|
| 237 | - $last_post_id = wp_insert_post($post, $wp_error); |
|
| 202 | + if (!empty($request_info['pid'])) {
|
|
| 203 | + $post_info = get_post($request_info['pid']); |
|
| 238 | 204 | |
| 239 | - if (!$dummy && $last_post_id) {
|
|
| 240 | - $send_post_submit_mail = true; // we move post_submit email from here so the rest of the variables are added to the db first(was breaking permalink in email) |
|
| 241 | - //geodir_sendEmail('','',$current_user->user_email,$current_user->display_name,'','',$request_info,'post_submit',$last_post_id,$current_user->ID);
|
|
| 242 | - } |
|
| 243 | - } |
|
| 205 | + if (!empty($post_info) && isset($post_info->post_name)) {
|
|
| 206 | + $request_info['post_name'] = $post_info->post_name; |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + $post = array( |
|
| 212 | + 'post_content' => $request_info['post_desc'], |
|
| 213 | + 'post_status' => $post_status, |
|
| 214 | + 'post_title' => $request_info['post_title'], |
|
| 215 | + 'post_name' => $request_info['post_name'], |
|
| 216 | + 'post_type' => $request_info['listing_type'] |
|
| 217 | + ); |
|
| 218 | + |
|
| 219 | + /** |
|
| 220 | + * Called before a listing is saved to the database. |
|
| 221 | + * |
|
| 222 | + * @since 1.0.0 |
|
| 223 | + * @param object $post The post object. |
|
| 224 | + */ |
|
| 225 | + do_action_ref_array('geodir_before_save_listing', $post);
|
|
| 226 | + |
|
| 227 | + $send_post_submit_mail = false; |
|
| 228 | + |
|
| 229 | + // unhook this function so it doesn't loop infinitely |
|
| 230 | + remove_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 231 | + |
|
| 232 | + if (isset($request_info['pid']) && $request_info['pid'] != '') {
|
|
| 233 | + $post['ID'] = $request_info['pid']; |
|
| 234 | + |
|
| 235 | + $last_post_id = wp_update_post($post, $wp_error); |
|
| 236 | + } else {
|
|
| 237 | + $last_post_id = wp_insert_post($post, $wp_error); |
|
| 238 | + |
|
| 239 | + if (!$dummy && $last_post_id) {
|
|
| 240 | + $send_post_submit_mail = true; // we move post_submit email from here so the rest of the variables are added to the db first(was breaking permalink in email) |
|
| 241 | + //geodir_sendEmail('','',$current_user->user_email,$current_user->display_name,'','',$request_info,'post_submit',$last_post_id,$current_user->ID);
|
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - if ($wp_error && is_wp_error($last_post_id)) {
|
|
| 246 | - return $last_post_id; // Return WP_Error on save failure. |
|
| 247 | - } |
|
| 245 | + if ($wp_error && is_wp_error($last_post_id)) {
|
|
| 246 | + return $last_post_id; // Return WP_Error on save failure. |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - if (!$last_post_id) {
|
|
| 250 | - return false; // Save failure. |
|
| 251 | - } |
|
| 249 | + if (!$last_post_id) {
|
|
| 250 | + return false; // Save failure. |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - // re-hook this function |
|
| 254 | - add_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 253 | + // re-hook this function |
|
| 254 | + add_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 255 | 255 | |
| 256 | - $post_tags = ''; |
|
| 257 | - if (!isset($request_info['post_tags'])) {
|
|
| 256 | + $post_tags = ''; |
|
| 257 | + if (!isset($request_info['post_tags'])) {
|
|
| 258 | 258 | |
| 259 | - $post_type = $request_info['listing_type']; |
|
| 260 | - $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
|
|
| 259 | + $post_type = $request_info['listing_type']; |
|
| 260 | + $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
|
|
| 261 | 261 | |
| 262 | - } |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | - $gd_post_info = array( |
|
| 265 | - "post_title" => $request_info['post_title'], |
|
| 266 | - "post_tags" => isset($request_info['post_tags']) ? $request_info['post_tags'] : $post_tags, |
|
| 267 | - "post_status" => $post_status, |
|
| 268 | - "post_location_id" => $post_location_id, |
|
| 269 | - "claimed" => isset($request_info['claimed']) ? $request_info['claimed'] : '', |
|
| 270 | - "businesses" => isset($request_info['a_businesses']) ? $request_info['a_businesses'] : '', |
|
| 271 | - "submit_time" => time(), |
|
| 272 | - "submit_ip" => $_SERVER['REMOTE_ADDR'], |
|
| 273 | - ); |
|
| 264 | + $gd_post_info = array( |
|
| 265 | + "post_title" => $request_info['post_title'], |
|
| 266 | + "post_tags" => isset($request_info['post_tags']) ? $request_info['post_tags'] : $post_tags, |
|
| 267 | + "post_status" => $post_status, |
|
| 268 | + "post_location_id" => $post_location_id, |
|
| 269 | + "claimed" => isset($request_info['claimed']) ? $request_info['claimed'] : '', |
|
| 270 | + "businesses" => isset($request_info['a_businesses']) ? $request_info['a_businesses'] : '', |
|
| 271 | + "submit_time" => time(), |
|
| 272 | + "submit_ip" => $_SERVER['REMOTE_ADDR'], |
|
| 273 | + ); |
|
| 274 | 274 | |
| 275 | - $payment_info = array(); |
|
| 276 | - $package_info = array(); |
|
| 275 | + $payment_info = array(); |
|
| 276 | + $package_info = array(); |
|
| 277 | 277 | |
| 278 | - $package_info = (array)geodir_post_package_info($package_info, $post); |
|
| 278 | + $package_info = (array)geodir_post_package_info($package_info, $post); |
|
| 279 | 279 | |
| 280 | - $post_package_id = geodir_get_post_meta($last_post_id, 'package_id'); |
|
| 280 | + $post_package_id = geodir_get_post_meta($last_post_id, 'package_id'); |
|
| 281 | 281 | |
| 282 | - if (!empty($package_info) && !$post_package_id) {
|
|
| 283 | - if (isset($package_info['days']) && $package_info['days'] != 0) {
|
|
| 284 | - $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
|
|
| 285 | - } else {
|
|
| 286 | - $payment_info['expire_date'] = 'Never'; |
|
| 287 | - } |
|
| 282 | + if (!empty($package_info) && !$post_package_id) {
|
|
| 283 | + if (isset($package_info['days']) && $package_info['days'] != 0) {
|
|
| 284 | + $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
|
|
| 285 | + } else {
|
|
| 286 | + $payment_info['expire_date'] = 'Never'; |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - $payment_info['package_id'] = $package_info['pid']; |
|
| 290 | - $payment_info['alive_days'] = $package_info['days']; |
|
| 291 | - $payment_info['is_featured'] = $package_info['is_featured']; |
|
| 289 | + $payment_info['package_id'] = $package_info['pid']; |
|
| 290 | + $payment_info['alive_days'] = $package_info['days']; |
|
| 291 | + $payment_info['is_featured'] = $package_info['is_featured']; |
|
| 292 | 292 | |
| 293 | - $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
| 294 | - } |
|
| 293 | + $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
| 294 | + } |
|
| 295 | 295 | |
| 296 | - $custom_metaboxes = geodir_post_custom_fields('', 'all', $request_info['listing_type']);
|
|
| 296 | + $custom_metaboxes = geodir_post_custom_fields('', 'all', $request_info['listing_type']);
|
|
| 297 | 297 | |
| 298 | - foreach ($custom_metaboxes as $key => $val): |
|
| 298 | + foreach ($custom_metaboxes as $key => $val): |
|
| 299 | 299 | |
| 300 | - $name = $val['name']; |
|
| 301 | - $type = $val['type']; |
|
| 302 | - $extrafields = $val['extra_fields']; |
|
| 300 | + $name = $val['name']; |
|
| 301 | + $type = $val['type']; |
|
| 302 | + $extrafields = $val['extra_fields']; |
|
| 303 | 303 | |
| 304 | - if (trim($type) == 'address') {
|
|
| 305 | - $prefix = $name . '_'; |
|
| 306 | - $address = $prefix . 'address'; |
|
| 304 | + if (trim($type) == 'address') {
|
|
| 305 | + $prefix = $name . '_'; |
|
| 306 | + $address = $prefix . 'address'; |
|
| 307 | 307 | |
| 308 | - if (isset($request_info[$address]) && $request_info[$address] != '') {
|
|
| 309 | - $gd_post_info[$address] = wp_slash($request_info[$address]); |
|
| 310 | - } |
|
| 308 | + if (isset($request_info[$address]) && $request_info[$address] != '') {
|
|
| 309 | + $gd_post_info[$address] = wp_slash($request_info[$address]); |
|
| 310 | + } |
|
| 311 | 311 | |
| 312 | - if ($extrafields != '') {
|
|
| 313 | - $extrafields = unserialize($extrafields); |
|
| 312 | + if ($extrafields != '') {
|
|
| 313 | + $extrafields = unserialize($extrafields); |
|
| 314 | 314 | |
| 315 | 315 | |
| 316 | - if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
|
|
| 316 | + if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
|
|
| 317 | 317 | |
| 318 | - $location_result = geodir_get_default_location(); |
|
| 318 | + $location_result = geodir_get_default_location(); |
|
| 319 | 319 | |
| 320 | - $gd_post_info[$prefix . 'city'] = $location_result->city; |
|
| 321 | - $gd_post_info[$prefix . 'region'] = $location_result->region; |
|
| 322 | - $gd_post_info[$prefix . 'country'] = $location_result->country; |
|
| 320 | + $gd_post_info[$prefix . 'city'] = $location_result->city; |
|
| 321 | + $gd_post_info[$prefix . 'region'] = $location_result->region; |
|
| 322 | + $gd_post_info[$prefix . 'country'] = $location_result->country; |
|
| 323 | 323 | |
| 324 | - $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 324 | + $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 325 | 325 | |
| 326 | - } else {
|
|
| 326 | + } else {
|
|
| 327 | 327 | |
| 328 | - $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city']; |
|
| 329 | - $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region']; |
|
| 330 | - $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country']; |
|
| 328 | + $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city']; |
|
| 329 | + $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region']; |
|
| 330 | + $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country']; |
|
| 331 | 331 | |
| 332 | - //----------set post locations when import dummy data------- |
|
| 333 | - $location_result = geodir_get_default_location(); |
|
| 332 | + //----------set post locations when import dummy data------- |
|
| 333 | + $location_result = geodir_get_default_location(); |
|
| 334 | 334 | |
| 335 | - $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 336 | - //----------------------------------------------------------------- |
|
| 335 | + $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 336 | + //----------------------------------------------------------------- |
|
| 337 | 337 | |
| 338 | - } |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | 340 | |
| 341 | - if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
|
|
| 342 | - $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip']; |
|
| 343 | - } |
|
| 341 | + if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
|
|
| 342 | + $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip']; |
|
| 343 | + } |
|
| 344 | 344 | |
| 345 | 345 | |
| 346 | - if (isset($extrafields['show_map']) && $extrafields['show_map']) {
|
|
| 346 | + if (isset($extrafields['show_map']) && $extrafields['show_map']) {
|
|
| 347 | 347 | |
| 348 | - if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
|
|
| 349 | - $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude']; |
|
| 350 | - } |
|
| 348 | + if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
|
|
| 349 | + $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude']; |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | - if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
|
|
| 353 | - $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude']; |
|
| 354 | - } |
|
| 352 | + if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
|
|
| 353 | + $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude']; |
|
| 354 | + } |
|
| 355 | 355 | |
| 356 | - if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
|
|
| 357 | - $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview']; |
|
| 358 | - } |
|
| 356 | + if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
|
|
| 357 | + $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview']; |
|
| 358 | + } |
|
| 359 | 359 | |
| 360 | - if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
|
|
| 361 | - $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom']; |
|
| 362 | - } |
|
| 360 | + if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
|
|
| 361 | + $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom']; |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - } |
|
| 364 | + } |
|
| 365 | 365 | |
| 366 | - // show lat lng |
|
| 367 | - if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
|
|
| 368 | - $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng']; |
|
| 369 | - } |
|
| 370 | - } |
|
| 366 | + // show lat lng |
|
| 367 | + if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
|
|
| 368 | + $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng']; |
|
| 369 | + } |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | - } elseif (trim($type) == 'file') {
|
|
| 373 | - if (isset($request_info[$name])) {
|
|
| 374 | - $request_files = array(); |
|
| 375 | - if ($request_info[$name] != '') |
|
| 376 | - $request_files = explode(",", $request_info[$name]);
|
|
| 372 | + } elseif (trim($type) == 'file') {
|
|
| 373 | + if (isset($request_info[$name])) {
|
|
| 374 | + $request_files = array(); |
|
| 375 | + if ($request_info[$name] != '') |
|
| 376 | + $request_files = explode(",", $request_info[$name]);
|
|
| 377 | 377 | |
| 378 | - $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL; |
|
| 379 | - geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields); |
|
| 378 | + $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL; |
|
| 379 | + geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields); |
|
| 380 | 380 | |
| 381 | - } |
|
| 382 | - } elseif (trim($type) == 'datepicker') {
|
|
| 383 | - $datetime = ''; |
|
| 384 | - if (isset($request_info[$name]) && $request_info[$name] != '') {
|
|
| 385 | - $date_format = geodir_default_date_format(); |
|
| 386 | - if (isset($val['extra_fields']) && $val['extra_fields'] != '') {
|
|
| 387 | - $extra_fields = unserialize($val['extra_fields']); |
|
| 388 | - $date_format = isset($extra_fields['date_format']) && $extra_fields['date_format'] != '' ? $extra_fields['date_format'] : $date_format; |
|
| 389 | - } |
|
| 381 | + } |
|
| 382 | + } elseif (trim($type) == 'datepicker') {
|
|
| 383 | + $datetime = ''; |
|
| 384 | + if (isset($request_info[$name]) && $request_info[$name] != '') {
|
|
| 385 | + $date_format = geodir_default_date_format(); |
|
| 386 | + if (isset($val['extra_fields']) && $val['extra_fields'] != '') {
|
|
| 387 | + $extra_fields = unserialize($val['extra_fields']); |
|
| 388 | + $date_format = isset($extra_fields['date_format']) && $extra_fields['date_format'] != '' ? $extra_fields['date_format'] : $date_format; |
|
| 389 | + } |
|
| 390 | 390 | |
| 391 | - $search = array('dd', 'mm', 'yy');
|
|
| 392 | - $replace = array('d', 'm', 'Y');
|
|
| 391 | + $search = array('dd', 'mm', 'yy');
|
|
| 392 | + $replace = array('d', 'm', 'Y');
|
|
| 393 | 393 | |
| 394 | - $date_format = str_replace($search, $replace, $date_format); |
|
| 394 | + $date_format = str_replace($search, $replace, $date_format); |
|
| 395 | 395 | |
| 396 | - $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name]; // PHP doesn't work well with dd/mm/yyyy format
|
|
| 396 | + $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name]; // PHP doesn't work well with dd/mm/yyyy format
|
|
| 397 | 397 | |
| 398 | - $datetime = date("Y-m-d", strtotime($post_htmlvar_value));
|
|
| 399 | - } |
|
| 400 | - $gd_post_info[$name] = $datetime; |
|
| 401 | - } else if ($type == 'multiselect') {
|
|
| 402 | - if (isset($request_info[$name])) {
|
|
| 403 | - $gd_post_info[$name] = $request_info[$name]; |
|
| 404 | - } else {
|
|
| 405 | - if (isset($request_info['gd_field_' . $name])) {
|
|
| 406 | - $gd_post_info[$name] = ''; /* fix de-select for multiselect */ |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - } else if (isset($request_info[$name])) {
|
|
| 410 | - $gd_post_info[$name] = $request_info[$name]; |
|
| 411 | - } |
|
| 398 | + $datetime = date("Y-m-d", strtotime($post_htmlvar_value));
|
|
| 399 | + } |
|
| 400 | + $gd_post_info[$name] = $datetime; |
|
| 401 | + } else if ($type == 'multiselect') {
|
|
| 402 | + if (isset($request_info[$name])) {
|
|
| 403 | + $gd_post_info[$name] = $request_info[$name]; |
|
| 404 | + } else {
|
|
| 405 | + if (isset($request_info['gd_field_' . $name])) {
|
|
| 406 | + $gd_post_info[$name] = ''; /* fix de-select for multiselect */ |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + } else if (isset($request_info[$name])) {
|
|
| 410 | + $gd_post_info[$name] = $request_info[$name]; |
|
| 411 | + } |
|
| 412 | 412 | |
| 413 | - endforeach; |
|
| 413 | + endforeach; |
|
| 414 | 414 | |
| 415 | - if (isset($request_info['post_dummy']) && $request_info['post_dummy'] != '') {
|
|
| 416 | - $gd_post_info['post_dummy'] = $request_info['post_dummy']; |
|
| 417 | - } |
|
| 415 | + if (isset($request_info['post_dummy']) && $request_info['post_dummy'] != '') {
|
|
| 416 | + $gd_post_info['post_dummy'] = $request_info['post_dummy']; |
|
| 417 | + } |
|
| 418 | 418 | |
| 419 | - // Save post detail info in detail table |
|
| 420 | - if (!empty($gd_post_info)) {
|
|
| 421 | - geodir_save_post_info($last_post_id, $gd_post_info); |
|
| 422 | - } |
|
| 419 | + // Save post detail info in detail table |
|
| 420 | + if (!empty($gd_post_info)) {
|
|
| 421 | + geodir_save_post_info($last_post_id, $gd_post_info); |
|
| 422 | + } |
|
| 423 | 423 | |
| 424 | 424 | |
| 425 | - // Set categories to the listing |
|
| 426 | - if (isset($request_info['post_category']) && !empty($request_info['post_category'])) {
|
|
| 427 | - $post_category = array(); |
|
| 425 | + // Set categories to the listing |
|
| 426 | + if (isset($request_info['post_category']) && !empty($request_info['post_category'])) {
|
|
| 427 | + $post_category = array(); |
|
| 428 | 428 | |
| 429 | - foreach ($request_info['post_category'] as $taxonomy => $cat) {
|
|
| 429 | + foreach ($request_info['post_category'] as $taxonomy => $cat) {
|
|
| 430 | 430 | |
| 431 | - if ($dummy) |
|
| 432 | - $post_category = $cat; |
|
| 433 | - else {
|
|
| 431 | + if ($dummy) |
|
| 432 | + $post_category = $cat; |
|
| 433 | + else {
|
|
| 434 | 434 | |
| 435 | - if (!is_array($cat) && strstr($cat, ',')) |
|
| 436 | - $cat = explode(',', $cat);
|
|
| 435 | + if (!is_array($cat) && strstr($cat, ',')) |
|
| 436 | + $cat = explode(',', $cat);
|
|
| 437 | 437 | |
| 438 | - if (!empty($cat) && is_array($cat)) |
|
| 439 | - $post_category = array_map('intval', $cat);
|
|
| 440 | - } |
|
| 438 | + if (!empty($cat) && is_array($cat)) |
|
| 439 | + $post_category = array_map('intval', $cat);
|
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | - wp_set_object_terms($last_post_id, $post_category, $taxonomy); |
|
| 443 | - } |
|
| 442 | + wp_set_object_terms($last_post_id, $post_category, $taxonomy); |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + $post_default_category = isset($request_info['post_default_category']) ? $request_info['post_default_category'] : ''; |
|
| 446 | + |
|
| 447 | + $post_category_str = isset($request_info['post_category_str']) ? $request_info['post_category_str'] : ''; |
|
| 448 | + geodir_set_postcat_structure($last_post_id, $taxonomy, $post_default_category, $post_category_str); |
|
| 444 | 449 | |
| 445 | - $post_default_category = isset($request_info['post_default_category']) ? $request_info['post_default_category'] : ''; |
|
| 450 | + } |
|
| 446 | 451 | |
| 447 | - $post_category_str = isset($request_info['post_category_str']) ? $request_info['post_category_str'] : ''; |
|
| 448 | - geodir_set_postcat_structure($last_post_id, $taxonomy, $post_default_category, $post_category_str); |
|
| 449 | - |
|
| 450 | - } |
|
| 452 | + $post_tags = ''; |
|
| 453 | + // Set tags to the listing |
|
| 454 | + if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
|
|
| 455 | + $post_tags = explode(",", $request_info['post_tags']);
|
|
| 456 | + } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
|
|
| 457 | + if ($dummy) |
|
| 458 | + $post_tags = $request_info['post_tags']; |
|
| 459 | + } else {
|
|
| 460 | + if ($dummy) |
|
| 461 | + $post_tags = array($request_info['post_title']); |
|
| 462 | + } |
|
| 451 | 463 | |
| 452 | - $post_tags = ''; |
|
| 453 | - // Set tags to the listing |
|
| 454 | - if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
|
|
| 455 | - $post_tags = explode(",", $request_info['post_tags']);
|
|
| 456 | - } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
|
|
| 457 | - if ($dummy) |
|
| 458 | - $post_tags = $request_info['post_tags']; |
|
| 459 | - } else {
|
|
| 460 | - if ($dummy) |
|
| 461 | - $post_tags = array($request_info['post_title']); |
|
| 462 | - } |
|
| 464 | + if (is_array($post_tags)) {
|
|
| 465 | + $taxonomy = $request_info['listing_type'] . '_tags'; |
|
| 466 | + wp_set_object_terms($last_post_id, $post_tags, $taxonomy); |
|
| 467 | + } |
|
| 463 | 468 | |
| 464 | - if (is_array($post_tags)) {
|
|
| 465 | - $taxonomy = $request_info['listing_type'] . '_tags'; |
|
| 466 | - wp_set_object_terms($last_post_id, $post_tags, $taxonomy); |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - |
|
| 470 | - // Insert attechment |
|
| 471 | 469 | |
| 472 | - if (isset($request_info['post_images']) && !is_wp_error($last_post_id)) {
|
|
| 473 | - if (!$dummy) {
|
|
| 474 | - $tmpimgArr = trim($request_info['post_images'], ","); |
|
| 475 | - $tmpimgArr = explode(",", $tmpimgArr);
|
|
| 476 | - geodir_save_post_images($last_post_id, $tmpimgArr, $dummy); |
|
| 477 | - } else{
|
|
| 478 | - geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy); |
|
| 479 | - } |
|
| 470 | + // Insert attechment |
|
| 471 | + |
|
| 472 | + if (isset($request_info['post_images']) && !is_wp_error($last_post_id)) {
|
|
| 473 | + if (!$dummy) {
|
|
| 474 | + $tmpimgArr = trim($request_info['post_images'], ","); |
|
| 475 | + $tmpimgArr = explode(",", $tmpimgArr);
|
|
| 476 | + geodir_save_post_images($last_post_id, $tmpimgArr, $dummy); |
|
| 477 | + } else{
|
|
| 478 | + geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy); |
|
| 479 | + } |
|
| 480 | + |
|
| 480 | 481 | |
| 482 | + } elseif (!isset($request_info['post_images']) || $request_info['post_images'] == '') {
|
|
| 481 | 483 | |
| 482 | - } elseif (!isset($request_info['post_images']) || $request_info['post_images'] == '') {
|
|
| 483 | - |
|
| 484 | - /* Delete Attachments |
|
| 484 | + /* Delete Attachments |
|
| 485 | 485 | $postcurr_images = geodir_get_images($last_post_id); |
| 486 | 486 | |
| 487 | 487 | $wpdb->query( |
@@ -497,34 +497,34 @@ discard block |
||
| 497 | 497 | geodir_save_post_info($last_post_id, $gd_post_featured_img); |
| 498 | 498 | */ |
| 499 | 499 | |
| 500 | - } |
|
| 500 | + } |
|
| 501 | 501 | |
| 502 | - geodir_remove_temp_images(); |
|
| 503 | - geodir_set_wp_featured_image($last_post_id); |
|
| 502 | + geodir_remove_temp_images(); |
|
| 503 | + geodir_set_wp_featured_image($last_post_id); |
|
| 504 | 504 | |
| 505 | - /** |
|
| 506 | - * Called after a listing is saved to the database and before any email have been sent. |
|
| 507 | - * |
|
| 508 | - * @since 1.0.0 |
|
| 509 | - * @param int $last_post_id The saved post ID. |
|
| 510 | - * @param array $request_info The post details in an array. |
|
| 511 | - * @see 'geodir_after_save_listinginfo' |
|
| 512 | - */ |
|
| 513 | - do_action('geodir_after_save_listing', $last_post_id, $request_info);
|
|
| 505 | + /** |
|
| 506 | + * Called after a listing is saved to the database and before any email have been sent. |
|
| 507 | + * |
|
| 508 | + * @since 1.0.0 |
|
| 509 | + * @param int $last_post_id The saved post ID. |
|
| 510 | + * @param array $request_info The post details in an array. |
|
| 511 | + * @see 'geodir_after_save_listinginfo' |
|
| 512 | + */ |
|
| 513 | + do_action('geodir_after_save_listing', $last_post_id, $request_info);
|
|
| 514 | 514 | |
| 515 | - //die; |
|
| 515 | + //die; |
|
| 516 | 516 | |
| 517 | - if ($send_post_submit_mail) { // if new post send out email
|
|
| 518 | - $to_name = geodir_get_client_name($current_user->ID); |
|
| 519 | - geodir_sendEmail('', '', $current_user->user_email, $to_name, '', '', $request_info, 'post_submit', $last_post_id, $current_user->ID);
|
|
| 520 | - } |
|
| 521 | - /* |
|
| 517 | + if ($send_post_submit_mail) { // if new post send out email
|
|
| 518 | + $to_name = geodir_get_client_name($current_user->ID); |
|
| 519 | + geodir_sendEmail('', '', $current_user->user_email, $to_name, '', '', $request_info, 'post_submit', $last_post_id, $current_user->ID);
|
|
| 520 | + } |
|
| 521 | + /* |
|
| 522 | 522 | * Unset the session so we don't loop. |
| 523 | 523 | */ |
| 524 | - $gd_session->un_set('listing');
|
|
| 525 | - return $last_post_id; |
|
| 524 | + $gd_session->un_set('listing');
|
|
| 525 | + return $last_post_id; |
|
| 526 | 526 | |
| 527 | - } |
|
| 527 | + } |
|
| 528 | 528 | |
| 529 | 529 | } |
| 530 | 530 | |
@@ -543,586 +543,586 @@ discard block |
||
| 543 | 543 | function geodir_get_post_info($post_id = '') |
| 544 | 544 | {
|
| 545 | 545 | |
| 546 | - global $wpdb, $plugin_prefix, $post, $post_info; |
|
| 546 | + global $wpdb, $plugin_prefix, $post, $post_info; |
|
| 547 | 547 | |
| 548 | - if ($post_id == '' && !empty($post)) |
|
| 549 | - $post_id = $post->ID; |
|
| 548 | + if ($post_id == '' && !empty($post)) |
|
| 549 | + $post_id = $post->ID; |
|
| 550 | 550 | |
| 551 | - $post_type = get_post_type($post_id); |
|
| 551 | + $post_type = get_post_type($post_id); |
|
| 552 | 552 | |
| 553 | - $all_postypes = geodir_get_posttypes(); |
|
| 553 | + $all_postypes = geodir_get_posttypes(); |
|
| 554 | 554 | |
| 555 | - if (!in_array($post_type, $all_postypes)) |
|
| 556 | - return false; |
|
| 555 | + if (!in_array($post_type, $all_postypes)) |
|
| 556 | + return false; |
|
| 557 | 557 | |
| 558 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 558 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 559 | 559 | |
| 560 | - /** |
|
| 561 | - * Apply Filter to change Post info |
|
| 562 | - * |
|
| 563 | - * You can use this filter to change Post info. |
|
| 564 | - * |
|
| 565 | - * @since 1.0.0 |
|
| 566 | - * @package GeoDirectory |
|
| 567 | - */ |
|
| 568 | - $query = apply_filters('geodir_post_info_query', "SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
|
|
| 560 | + /** |
|
| 561 | + * Apply Filter to change Post info |
|
| 562 | + * |
|
| 563 | + * You can use this filter to change Post info. |
|
| 564 | + * |
|
| 565 | + * @since 1.0.0 |
|
| 566 | + * @package GeoDirectory |
|
| 567 | + */ |
|
| 568 | + $query = apply_filters('geodir_post_info_query', "SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
|
|
| 569 | 569 | WHERE p.ID = pd.post_id |
| 570 | 570 | AND post_id = " . $post_id); |
| 571 | 571 | |
| 572 | - $post_detail = $wpdb->get_row($query); |
|
| 572 | + $post_detail = $wpdb->get_row($query); |
|
| 573 | 573 | |
| 574 | - return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false; |
|
| 574 | + return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false; |
|
| 575 | 575 | |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | 578 | |
| 579 | 579 | if (!function_exists('geodir_save_post_info')) {
|
| 580 | - /** |
|
| 581 | - * Saves post detail info in detail table. |
|
| 582 | - * |
|
| 583 | - * @since 1.0.0 |
|
| 584 | - * @package GeoDirectory |
|
| 585 | - * @global object $wpdb WordPress Database object. |
|
| 586 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 587 | - * @param int $post_id The post ID. |
|
| 588 | - * @param array $postinfo_array {
|
|
| 589 | - * Post info that needs to be saved in detail table. |
|
| 590 | - * |
|
| 591 | - * @type string $post_title Listing title. |
|
| 592 | - * @type string $post_tags Listing tags. |
|
| 593 | - * @type string $post_status Listing post status. |
|
| 594 | - * @type string $post_location_id Listing location ID. |
|
| 595 | - * @type string $claimed Todo Desc needed. |
|
| 596 | - * @type string $businesses Todo Desc needed. |
|
| 597 | - * @type int $submit_time Submitted time in unix timestamp. |
|
| 598 | - * @type string $submit_ip Submitted IP. |
|
| 599 | - * @type string $expire_date Listing expiration date. |
|
| 600 | - * @type int $package_id Listing package ID. |
|
| 601 | - * @type int $alive_days Todo Desc needed. |
|
| 602 | - * @type int $is_featured Is this a featured listing?. |
|
| 603 | - * @type string $post_address Listing address. |
|
| 604 | - * @type string $post_city Listing city. |
|
| 605 | - * @type string $post_region Listing region. |
|
| 606 | - * @type string $post_country Listing country. |
|
| 607 | - * @type string $post_locations Listing locations. |
|
| 608 | - * @type string $post_zip Listing zip. |
|
| 609 | - * @type string $post_latitude Listing latitude. |
|
| 610 | - * @type string $post_longitude Listing longitude. |
|
| 611 | - * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
| 612 | - * @type string $post_mapzoom Listing mapzoom Default "9". |
|
| 613 | - * @type string $geodir_timing Business timing info. |
|
| 614 | - * @type string $geodir_contact Contact number. |
|
| 615 | - * @type string $geodir_email Business contact email. |
|
| 616 | - * @type string $geodir_website Business website. |
|
| 617 | - * @type string $geodir_twitter Twitter link. |
|
| 618 | - * @type string $geodir_facebook Facebook link. |
|
| 619 | - * @type string $geodir_video Video link. |
|
| 620 | - * @type string $geodir_special_offers Speacial offers. |
|
| 621 | - * |
|
| 622 | - * } |
|
| 623 | - * @return bool |
|
| 624 | - */ |
|
| 625 | - function geodir_save_post_info($post_id, $postinfo_array = array()) |
|
| 626 | - {
|
|
| 627 | - global $wpdb, $plugin_prefix; |
|
| 628 | - |
|
| 629 | - $post_type = get_post_type($post_id); |
|
| 630 | - |
|
| 631 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 632 | - |
|
| 633 | - /** |
|
| 634 | - * Filter to change Post info |
|
| 635 | - * |
|
| 636 | - * You can use this filter to change Post info. |
|
| 637 | - * |
|
| 638 | - * @since 1.0.0 |
|
| 639 | - * @package GeoDirectory |
|
| 640 | - * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
|
|
| 641 | - * @param int $post_id The post ID. |
|
| 642 | - */ |
|
| 580 | + /** |
|
| 581 | + * Saves post detail info in detail table. |
|
| 582 | + * |
|
| 583 | + * @since 1.0.0 |
|
| 584 | + * @package GeoDirectory |
|
| 585 | + * @global object $wpdb WordPress Database object. |
|
| 586 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 587 | + * @param int $post_id The post ID. |
|
| 588 | + * @param array $postinfo_array {
|
|
| 589 | + * Post info that needs to be saved in detail table. |
|
| 590 | + * |
|
| 591 | + * @type string $post_title Listing title. |
|
| 592 | + * @type string $post_tags Listing tags. |
|
| 593 | + * @type string $post_status Listing post status. |
|
| 594 | + * @type string $post_location_id Listing location ID. |
|
| 595 | + * @type string $claimed Todo Desc needed. |
|
| 596 | + * @type string $businesses Todo Desc needed. |
|
| 597 | + * @type int $submit_time Submitted time in unix timestamp. |
|
| 598 | + * @type string $submit_ip Submitted IP. |
|
| 599 | + * @type string $expire_date Listing expiration date. |
|
| 600 | + * @type int $package_id Listing package ID. |
|
| 601 | + * @type int $alive_days Todo Desc needed. |
|
| 602 | + * @type int $is_featured Is this a featured listing?. |
|
| 603 | + * @type string $post_address Listing address. |
|
| 604 | + * @type string $post_city Listing city. |
|
| 605 | + * @type string $post_region Listing region. |
|
| 606 | + * @type string $post_country Listing country. |
|
| 607 | + * @type string $post_locations Listing locations. |
|
| 608 | + * @type string $post_zip Listing zip. |
|
| 609 | + * @type string $post_latitude Listing latitude. |
|
| 610 | + * @type string $post_longitude Listing longitude. |
|
| 611 | + * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
| 612 | + * @type string $post_mapzoom Listing mapzoom Default "9". |
|
| 613 | + * @type string $geodir_timing Business timing info. |
|
| 614 | + * @type string $geodir_contact Contact number. |
|
| 615 | + * @type string $geodir_email Business contact email. |
|
| 616 | + * @type string $geodir_website Business website. |
|
| 617 | + * @type string $geodir_twitter Twitter link. |
|
| 618 | + * @type string $geodir_facebook Facebook link. |
|
| 619 | + * @type string $geodir_video Video link. |
|
| 620 | + * @type string $geodir_special_offers Speacial offers. |
|
| 621 | + * |
|
| 622 | + * } |
|
| 623 | + * @return bool |
|
| 624 | + */ |
|
| 625 | + function geodir_save_post_info($post_id, $postinfo_array = array()) |
|
| 626 | + {
|
|
| 627 | + global $wpdb, $plugin_prefix; |
|
| 628 | + |
|
| 629 | + $post_type = get_post_type($post_id); |
|
| 630 | + |
|
| 631 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 632 | + |
|
| 633 | + /** |
|
| 634 | + * Filter to change Post info |
|
| 635 | + * |
|
| 636 | + * You can use this filter to change Post info. |
|
| 637 | + * |
|
| 638 | + * @since 1.0.0 |
|
| 639 | + * @package GeoDirectory |
|
| 640 | + * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
|
|
| 641 | + * @param int $post_id The post ID. |
|
| 642 | + */ |
|
| 643 | + |
|
| 644 | + $postmeta = apply_filters('geodir_listinginfo_request', $postinfo_array, $post_id);
|
|
| 645 | + |
|
| 646 | + if (!empty($postmeta) && $post_id) {
|
|
| 647 | + $post_meta_set_query = ''; |
|
| 648 | + |
|
| 649 | + foreach ($postmeta as $mkey => $mval) {
|
|
| 650 | + if (geodir_column_exist($table, $mkey)) {
|
|
| 651 | + if (is_array($mval)) {
|
|
| 652 | + $mval = implode(",", $mval);
|
|
| 653 | + } |
|
| 654 | + |
|
| 655 | + $post_meta_set_query .= $mkey . " = '" . $mval . "', "; |
|
| 656 | + } |
|
| 657 | + } |
|
| 643 | 658 | |
| 644 | - $postmeta = apply_filters('geodir_listinginfo_request', $postinfo_array, $post_id);
|
|
| 659 | + $post_meta_set_query = trim($post_meta_set_query, ", "); |
|
| 645 | 660 | |
| 646 | - if (!empty($postmeta) && $post_id) {
|
|
| 647 | - $post_meta_set_query = ''; |
|
| 661 | + $post_meta_set_query = str_replace('%', '%%', $post_meta_set_query);// escape %
|
|
| 648 | 662 | |
| 649 | - foreach ($postmeta as $mkey => $mval) {
|
|
| 650 | - if (geodir_column_exist($table, $mkey)) {
|
|
| 651 | - if (is_array($mval)) {
|
|
| 652 | - $mval = implode(",", $mval);
|
|
| 653 | - } |
|
| 663 | + /** |
|
| 664 | + * Called before saving the listing info. |
|
| 665 | + * |
|
| 666 | + * @since 1.0.0 |
|
| 667 | + * @package GeoDirectory |
|
| 668 | + * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
|
|
| 669 | + * @param int $post_id The post ID. |
|
| 670 | + */ |
|
| 671 | + do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
|
|
| 654 | 672 | |
| 655 | - $post_meta_set_query .= $mkey . " = '" . $mval . "', "; |
|
| 656 | - } |
|
| 657 | - } |
|
| 673 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 658 | 674 | |
| 659 | - $post_meta_set_query = trim($post_meta_set_query, ", "); |
|
| 675 | + $wpdb->query( |
|
| 676 | + $wpdb->prepare( |
|
| 677 | + "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id =%d", |
|
| 678 | + array($post_id) |
|
| 679 | + ) |
|
| 680 | + ); |
|
| 660 | 681 | |
| 661 | - $post_meta_set_query = str_replace('%', '%%', $post_meta_set_query);// escape %
|
|
| 662 | 682 | |
| 663 | - /** |
|
| 664 | - * Called before saving the listing info. |
|
| 665 | - * |
|
| 666 | - * @since 1.0.0 |
|
| 667 | - * @package GeoDirectory |
|
| 668 | - * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
|
|
| 669 | - * @param int $post_id The post ID. |
|
| 670 | - */ |
|
| 671 | - do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
|
|
| 683 | + } else {
|
|
| 672 | 684 | |
| 673 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 685 | + $wpdb->query( |
|
| 686 | + $wpdb->prepare( |
|
| 687 | + "INSERT INTO " . $table . " SET post_id = %d," . $post_meta_set_query, |
|
| 688 | + array($post_id) |
|
| 689 | + ) |
|
| 690 | + ); |
|
| 674 | 691 | |
| 675 | - $wpdb->query( |
|
| 676 | - $wpdb->prepare( |
|
| 677 | - "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id =%d", |
|
| 678 | - array($post_id) |
|
| 679 | - ) |
|
| 680 | - ); |
|
| 692 | + } |
|
| 681 | 693 | |
| 694 | + /** |
|
| 695 | + * Called after saving the listing info. |
|
| 696 | + * |
|
| 697 | + * @since 1.0.0 |
|
| 698 | + * @package GeoDirectory |
|
| 699 | + * @param array $postinfo_array Post info that needs to be saved in detail table. |
|
| 700 | + * @param int $post_id The post ID. |
|
| 701 | + * @see 'geodir_after_save_listing' |
|
| 702 | + */ |
|
| 703 | + do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
|
|
| 704 | + |
|
| 705 | + return true; |
|
| 706 | + } else |
|
| 707 | + return false; |
|
| 682 | 708 | |
| 683 | - } else {
|
|
| 709 | + } |
|
| 710 | +} |
|
| 684 | 711 | |
| 685 | - $wpdb->query( |
|
| 686 | - $wpdb->prepare( |
|
| 687 | - "INSERT INTO " . $table . " SET post_id = %d," . $post_meta_set_query, |
|
| 688 | - array($post_id) |
|
| 689 | - ) |
|
| 690 | - ); |
|
| 691 | 712 | |
| 692 | - } |
|
| 713 | +if (!function_exists('geodir_save_post_meta')) {
|
|
| 714 | + /** |
|
| 715 | + * Save or update post custom fields. |
|
| 716 | + * |
|
| 717 | + * @since 1.0.0 |
|
| 718 | + * @package GeoDirectory |
|
| 719 | + * @global object $wpdb WordPress Database object. |
|
| 720 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 721 | + * @param int $post_id The post ID. |
|
| 722 | + * @param string $postmeta Detail table column name. |
|
| 723 | + * @param string $meta_value Detail table column value. |
|
| 724 | + * @return void|bool |
|
| 725 | + */ |
|
| 726 | + function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '') |
|
| 727 | + {
|
|
| 728 | + |
|
| 729 | + global $wpdb, $plugin_prefix; |
|
| 730 | + |
|
| 731 | + $post_type = get_post_type($post_id); |
|
| 732 | + |
|
| 733 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 734 | + |
|
| 735 | + if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
|
|
| 736 | + |
|
| 737 | + if (is_array($meta_value)) {
|
|
| 738 | + $meta_value = implode(",", $meta_value);
|
|
| 739 | + } |
|
| 693 | 740 | |
| 694 | - /** |
|
| 695 | - * Called after saving the listing info. |
|
| 696 | - * |
|
| 697 | - * @since 1.0.0 |
|
| 698 | - * @package GeoDirectory |
|
| 699 | - * @param array $postinfo_array Post info that needs to be saved in detail table. |
|
| 700 | - * @param int $post_id The post ID. |
|
| 701 | - * @see 'geodir_after_save_listing' |
|
| 702 | - */ |
|
| 703 | - do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
|
|
| 741 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 704 | 742 | |
| 705 | - return true; |
|
| 706 | - } else |
|
| 707 | - return false; |
|
| 743 | + $wpdb->query( |
|
| 744 | + $wpdb->prepare( |
|
| 745 | + "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d", |
|
| 746 | + array($post_id) |
|
| 747 | + ) |
|
| 748 | + ); |
|
| 708 | 749 | |
| 709 | - } |
|
| 710 | -} |
|
| 750 | + } else {
|
|
| 751 | + |
|
| 752 | + $wpdb->query( |
|
| 753 | + $wpdb->prepare( |
|
| 754 | + "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'", |
|
| 755 | + array($post_id) |
|
| 756 | + ) |
|
| 757 | + ); |
|
| 758 | + } |
|
| 711 | 759 | |
| 712 | 760 | |
| 713 | -if (!function_exists('geodir_save_post_meta')) {
|
|
| 714 | - /** |
|
| 715 | - * Save or update post custom fields. |
|
| 716 | - * |
|
| 717 | - * @since 1.0.0 |
|
| 718 | - * @package GeoDirectory |
|
| 719 | - * @global object $wpdb WordPress Database object. |
|
| 720 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 721 | - * @param int $post_id The post ID. |
|
| 722 | - * @param string $postmeta Detail table column name. |
|
| 723 | - * @param string $meta_value Detail table column value. |
|
| 724 | - * @return void|bool |
|
| 725 | - */ |
|
| 726 | - function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '') |
|
| 727 | - {
|
|
| 728 | - |
|
| 729 | - global $wpdb, $plugin_prefix; |
|
| 730 | - |
|
| 731 | - $post_type = get_post_type($post_id); |
|
| 732 | - |
|
| 733 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 734 | - |
|
| 735 | - if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
|
|
| 736 | - |
|
| 737 | - if (is_array($meta_value)) {
|
|
| 738 | - $meta_value = implode(",", $meta_value);
|
|
| 739 | - } |
|
| 740 | - |
|
| 741 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 742 | - |
|
| 743 | - $wpdb->query( |
|
| 744 | - $wpdb->prepare( |
|
| 745 | - "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d", |
|
| 746 | - array($post_id) |
|
| 747 | - ) |
|
| 748 | - ); |
|
| 749 | - |
|
| 750 | - } else {
|
|
| 751 | - |
|
| 752 | - $wpdb->query( |
|
| 753 | - $wpdb->prepare( |
|
| 754 | - "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'", |
|
| 755 | - array($post_id) |
|
| 756 | - ) |
|
| 757 | - ); |
|
| 758 | - } |
|
| 759 | - |
|
| 760 | - |
|
| 761 | - } else |
|
| 762 | - return false; |
|
| 763 | - } |
|
| 761 | + } else |
|
| 762 | + return false; |
|
| 763 | + } |
|
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | if (!function_exists('geodir_delete_post_meta')) {
|
| 767 | - /** |
|
| 768 | - * Delete post custom fields. |
|
| 769 | - * |
|
| 770 | - * @since 1.0.0 |
|
| 771 | - * @package GeoDirectory |
|
| 772 | - * @global object $wpdb WordPress Database object. |
|
| 773 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 774 | - * @param int $post_id The post ID. |
|
| 775 | - * @param string $postmeta Detail table column name. |
|
| 776 | - * @todo check if this is depreciated |
|
| 777 | - * @todo Fix unknown variable mval |
|
| 778 | - * @return bool |
|
| 779 | - */ |
|
| 780 | - function geodir_delete_post_meta($post_id, $postmeta) |
|
| 781 | - {
|
|
| 782 | - |
|
| 783 | - global $wpdb, $plugin_prefix; |
|
| 784 | - |
|
| 785 | - $post_type = get_post_type($post_id); |
|
| 786 | - |
|
| 787 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 788 | - |
|
| 789 | - if (is_array($postmeta) && !empty($postmeta) && $post_id) {
|
|
| 790 | - $post_meta_set_query = ''; |
|
| 791 | - |
|
| 792 | - foreach ($postmeta as $mkey) {
|
|
| 793 | - if ($mval != '') |
|
| 794 | - $post_meta_set_query .= $mkey . " = '', "; |
|
| 795 | - } |
|
| 796 | - |
|
| 797 | - $post_meta_set_query = trim($post_meta_set_query, ", "); |
|
| 798 | - |
|
| 799 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 800 | - |
|
| 801 | - $wpdb->query( |
|
| 802 | - $wpdb->prepare( |
|
| 803 | - "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d", |
|
| 804 | - array($post_id) |
|
| 805 | - ) |
|
| 806 | - ); |
|
| 807 | - |
|
| 808 | - return true; |
|
| 809 | - } |
|
| 810 | - |
|
| 811 | - } elseif ($postmeta != '' && $post_id) {
|
|
| 812 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 813 | - |
|
| 814 | - $wpdb->query( |
|
| 815 | - $wpdb->prepare( |
|
| 816 | - "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d", |
|
| 817 | - array($post_id) |
|
| 818 | - ) |
|
| 819 | - ); |
|
| 820 | - |
|
| 821 | - return true; |
|
| 822 | - } |
|
| 823 | - |
|
| 824 | - } else |
|
| 825 | - return false; |
|
| 826 | - } |
|
| 767 | + /** |
|
| 768 | + * Delete post custom fields. |
|
| 769 | + * |
|
| 770 | + * @since 1.0.0 |
|
| 771 | + * @package GeoDirectory |
|
| 772 | + * @global object $wpdb WordPress Database object. |
|
| 773 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 774 | + * @param int $post_id The post ID. |
|
| 775 | + * @param string $postmeta Detail table column name. |
|
| 776 | + * @todo check if this is depreciated |
|
| 777 | + * @todo Fix unknown variable mval |
|
| 778 | + * @return bool |
|
| 779 | + */ |
|
| 780 | + function geodir_delete_post_meta($post_id, $postmeta) |
|
| 781 | + {
|
|
| 782 | + |
|
| 783 | + global $wpdb, $plugin_prefix; |
|
| 784 | + |
|
| 785 | + $post_type = get_post_type($post_id); |
|
| 786 | + |
|
| 787 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 788 | + |
|
| 789 | + if (is_array($postmeta) && !empty($postmeta) && $post_id) {
|
|
| 790 | + $post_meta_set_query = ''; |
|
| 791 | + |
|
| 792 | + foreach ($postmeta as $mkey) {
|
|
| 793 | + if ($mval != '') |
|
| 794 | + $post_meta_set_query .= $mkey . " = '', "; |
|
| 795 | + } |
|
| 796 | + |
|
| 797 | + $post_meta_set_query = trim($post_meta_set_query, ", "); |
|
| 798 | + |
|
| 799 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 800 | + |
|
| 801 | + $wpdb->query( |
|
| 802 | + $wpdb->prepare( |
|
| 803 | + "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d", |
|
| 804 | + array($post_id) |
|
| 805 | + ) |
|
| 806 | + ); |
|
| 807 | + |
|
| 808 | + return true; |
|
| 809 | + } |
|
| 810 | + |
|
| 811 | + } elseif ($postmeta != '' && $post_id) {
|
|
| 812 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 813 | + |
|
| 814 | + $wpdb->query( |
|
| 815 | + $wpdb->prepare( |
|
| 816 | + "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d", |
|
| 817 | + array($post_id) |
|
| 818 | + ) |
|
| 819 | + ); |
|
| 820 | + |
|
| 821 | + return true; |
|
| 822 | + } |
|
| 823 | + |
|
| 824 | + } else |
|
| 825 | + return false; |
|
| 826 | + } |
|
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | |
| 830 | 830 | if (!function_exists('geodir_get_post_meta')) {
|
| 831 | - /** |
|
| 832 | - * Get post custom meta. |
|
| 833 | - * |
|
| 834 | - * @since 1.0.0 |
|
| 835 | - * @package GeoDirectory |
|
| 836 | - * @global object $wpdb WordPress Database object. |
|
| 837 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 838 | - * @param int $post_id The post ID. |
|
| 839 | - * @param string $meta_key The meta key to retrieve. |
|
| 840 | - * @param bool $single Optional. Whether to return a single value. Default false. |
|
| 841 | - * @todo single variable not yet implemented. |
|
| 842 | - * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true. |
|
| 843 | - */ |
|
| 844 | - function geodir_get_post_meta($post_id, $meta_key, $single = false) |
|
| 845 | - {
|
|
| 846 | - if (!$post_id) {
|
|
| 847 | - return false; |
|
| 848 | - } |
|
| 849 | - global $wpdb, $plugin_prefix; |
|
| 850 | - |
|
| 851 | - $all_postypes = geodir_get_posttypes(); |
|
| 852 | - |
|
| 853 | - $post_type = get_post_type($post_id); |
|
| 854 | - |
|
| 855 | - if (!in_array($post_type, $all_postypes)) |
|
| 856 | - return false; |
|
| 857 | - |
|
| 858 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 859 | - |
|
| 860 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
|
|
| 861 | - $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
|
|
| 831 | + /** |
|
| 832 | + * Get post custom meta. |
|
| 833 | + * |
|
| 834 | + * @since 1.0.0 |
|
| 835 | + * @package GeoDirectory |
|
| 836 | + * @global object $wpdb WordPress Database object. |
|
| 837 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 838 | + * @param int $post_id The post ID. |
|
| 839 | + * @param string $meta_key The meta key to retrieve. |
|
| 840 | + * @param bool $single Optional. Whether to return a single value. Default false. |
|
| 841 | + * @todo single variable not yet implemented. |
|
| 842 | + * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true. |
|
| 843 | + */ |
|
| 844 | + function geodir_get_post_meta($post_id, $meta_key, $single = false) |
|
| 845 | + {
|
|
| 846 | + if (!$post_id) {
|
|
| 847 | + return false; |
|
| 848 | + } |
|
| 849 | + global $wpdb, $plugin_prefix; |
|
| 850 | + |
|
| 851 | + $all_postypes = geodir_get_posttypes(); |
|
| 852 | + |
|
| 853 | + $post_type = get_post_type($post_id); |
|
| 854 | + |
|
| 855 | + if (!in_array($post_type, $all_postypes)) |
|
| 856 | + return false; |
|
| 857 | + |
|
| 858 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 859 | + |
|
| 860 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
|
|
| 861 | + $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
|
|
| 862 | 862 | |
| 863 | - if ($meta_value && $meta_value !== '') {
|
|
| 864 | - return maybe_serialize($meta_value); |
|
| 865 | - } else |
|
| 866 | - return $meta_value; |
|
| 867 | - } else {
|
|
| 868 | - return false; |
|
| 869 | - } |
|
| 870 | - } |
|
| 863 | + if ($meta_value && $meta_value !== '') {
|
|
| 864 | + return maybe_serialize($meta_value); |
|
| 865 | + } else |
|
| 866 | + return $meta_value; |
|
| 867 | + } else {
|
|
| 868 | + return false; |
|
| 869 | + } |
|
| 870 | + } |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | |
| 874 | 874 | if (!function_exists('geodir_save_post_images')) {
|
| 875 | - /** |
|
| 876 | - * Save post attachments. |
|
| 877 | - * |
|
| 878 | - * @since 1.0.0 |
|
| 879 | - * @package GeoDirectory |
|
| 880 | - * @global object $wpdb WordPress Database object. |
|
| 881 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 882 | - * @global object $current_user Current user object. |
|
| 883 | - * @param int $post_id The post ID. |
|
| 884 | - * @param array $post_image Post image urls as an array. |
|
| 885 | - * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
| 886 | - */ |
|
| 887 | - function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false) |
|
| 888 | - {
|
|
| 889 | - |
|
| 875 | + /** |
|
| 876 | + * Save post attachments. |
|
| 877 | + * |
|
| 878 | + * @since 1.0.0 |
|
| 879 | + * @package GeoDirectory |
|
| 880 | + * @global object $wpdb WordPress Database object. |
|
| 881 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 882 | + * @global object $current_user Current user object. |
|
| 883 | + * @param int $post_id The post ID. |
|
| 884 | + * @param array $post_image Post image urls as an array. |
|
| 885 | + * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
| 886 | + */ |
|
| 887 | + function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false) |
|
| 888 | + {
|
|
| 890 | 889 | |
| 891 | - global $wpdb, $plugin_prefix, $current_user; |
|
| 892 | 890 | |
| 893 | - $post_type = get_post_type($post_id); |
|
| 891 | + global $wpdb, $plugin_prefix, $current_user; |
|
| 894 | 892 | |
| 895 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 893 | + $post_type = get_post_type($post_id); |
|
| 896 | 894 | |
| 897 | - $post_images = geodir_get_images($post_id); |
|
| 895 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 898 | 896 | |
| 899 | - $wpdb->query( |
|
| 900 | - $wpdb->prepare( |
|
| 901 | - "UPDATE " . $table . " SET featured_image = '' where post_id =%d", |
|
| 902 | - array($post_id) |
|
| 903 | - ) |
|
| 904 | - ); |
|
| 897 | + $post_images = geodir_get_images($post_id); |
|
| 905 | 898 | |
| 906 | - $invalid_files = $post_images; |
|
| 907 | - $valid_file_ids = array(); |
|
| 908 | - $valid_files_condition = ''; |
|
| 909 | - $geodir_uploaddir = ''; |
|
| 899 | + $wpdb->query( |
|
| 900 | + $wpdb->prepare( |
|
| 901 | + "UPDATE " . $table . " SET featured_image = '' where post_id =%d", |
|
| 902 | + array($post_id) |
|
| 903 | + ) |
|
| 904 | + ); |
|
| 910 | 905 | |
| 911 | - $remove_files = array(); |
|
| 906 | + $invalid_files = $post_images; |
|
| 907 | + $valid_file_ids = array(); |
|
| 908 | + $valid_files_condition = ''; |
|
| 909 | + $geodir_uploaddir = ''; |
|
| 912 | 910 | |
| 913 | - if (!empty($post_image)) {
|
|
| 911 | + $remove_files = array(); |
|
| 914 | 912 | |
| 915 | - $uploads = wp_upload_dir(); |
|
| 916 | - $uploads_dir = $uploads['path']; |
|
| 913 | + if (!empty($post_image)) {
|
|
| 917 | 914 | |
| 918 | - $geodir_uploadpath = $uploads['path']; |
|
| 919 | - $geodir_uploadurl = $uploads['url']; |
|
| 920 | - $sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : ''; |
|
| 915 | + $uploads = wp_upload_dir(); |
|
| 916 | + $uploads_dir = $uploads['path']; |
|
| 921 | 917 | |
| 922 | - $invalid_files = array(); |
|
| 923 | - $postcurr_images = array(); |
|
| 918 | + $geodir_uploadpath = $uploads['path']; |
|
| 919 | + $geodir_uploadurl = $uploads['url']; |
|
| 920 | + $sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : ''; |
|
| 924 | 921 | |
| 925 | - for ($m = 0; $m < count($post_image); $m++) {
|
|
| 926 | - $menu_order = $m + 1; |
|
| 922 | + $invalid_files = array(); |
|
| 923 | + $postcurr_images = array(); |
|
| 927 | 924 | |
| 928 | - $file_path = ''; |
|
| 929 | - /* --------- start ------- */ |
|
| 925 | + for ($m = 0; $m < count($post_image); $m++) {
|
|
| 926 | + $menu_order = $m + 1; |
|
| 930 | 927 | |
| 931 | - $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
|
|
| 928 | + $file_path = ''; |
|
| 929 | + /* --------- start ------- */ |
|
| 932 | 930 | |
| 933 | - $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
|
| 931 | + $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
|
|
| 934 | 932 | |
| 933 | + $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
|
| 935 | 934 | |
| 936 | - if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
|
|
| 937 | 935 | |
| 938 | - /* --------- end ------- */ |
|
| 939 | - $curr_img_url = $post_image[$m]; |
|
| 936 | + if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
|
|
| 940 | 937 | |
| 941 | - $image_name_arr = explode('/', $curr_img_url);
|
|
| 938 | + /* --------- end ------- */ |
|
| 939 | + $curr_img_url = $post_image[$m]; |
|
| 942 | 940 | |
| 943 | - $count_image_name_arr = count($image_name_arr) - 2; |
|
| 941 | + $image_name_arr = explode('/', $curr_img_url);
|
|
| 944 | 942 | |
| 945 | - $count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0; |
|
| 943 | + $count_image_name_arr = count($image_name_arr) - 2; |
|
| 946 | 944 | |
| 947 | - $curr_img_dir = $image_name_arr[$count_image_name_arr]; |
|
| 945 | + $count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0; |
|
| 948 | 946 | |
| 949 | - $filename = end($image_name_arr); |
|
| 950 | - if (strpos($filename, '?') !== false) {
|
|
| 951 | - list($filename) = explode('?', $filename);
|
|
| 952 | - } |
|
| 947 | + $curr_img_dir = $image_name_arr[$count_image_name_arr]; |
|
| 953 | 948 | |
| 954 | - $curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url); |
|
| 955 | - $curr_img_dir = str_replace($filename, "", $curr_img_dir); |
|
| 949 | + $filename = end($image_name_arr); |
|
| 950 | + if (strpos($filename, '?') !== false) {
|
|
| 951 | + list($filename) = explode('?', $filename);
|
|
| 952 | + } |
|
| 956 | 953 | |
| 957 | - $img_name_arr = explode('.', $filename);
|
|
| 954 | + $curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url); |
|
| 955 | + $curr_img_dir = str_replace($filename, "", $curr_img_dir); |
|
| 958 | 956 | |
| 959 | - $file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename; |
|
| 960 | - if (!empty($img_name_arr) && count($img_name_arr) > 2) {
|
|
| 961 | - $new_img_name_arr = $img_name_arr; |
|
| 962 | - if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
|
|
| 963 | - unset($new_img_name_arr[count($img_name_arr) - 1]); |
|
| 964 | - $file_title = implode('.', $new_img_name_arr);
|
|
| 965 | - } |
|
| 966 | - } |
|
| 967 | - $file_title = sanitize_file_name($file_title); |
|
| 968 | - $file_name = sanitize_file_name($filename); |
|
| 957 | + $img_name_arr = explode('.', $filename);
|
|
| 969 | 958 | |
| 970 | - $arr_file_type = wp_check_filetype($filename); |
|
| 959 | + $file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename; |
|
| 960 | + if (!empty($img_name_arr) && count($img_name_arr) > 2) {
|
|
| 961 | + $new_img_name_arr = $img_name_arr; |
|
| 962 | + if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
|
|
| 963 | + unset($new_img_name_arr[count($img_name_arr) - 1]); |
|
| 964 | + $file_title = implode('.', $new_img_name_arr);
|
|
| 965 | + } |
|
| 966 | + } |
|
| 967 | + $file_title = sanitize_file_name($file_title); |
|
| 968 | + $file_name = sanitize_file_name($filename); |
|
| 971 | 969 | |
| 972 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 970 | + $arr_file_type = wp_check_filetype($filename); |
|
| 973 | 971 | |
| 974 | - // Set an array containing a list of acceptable formats |
|
| 975 | - $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
|
|
| 972 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 976 | 973 | |
| 977 | - // If the uploaded file is the right format |
|
| 978 | - if (in_array($uploaded_file_type, $allowed_file_types)) {
|
|
| 979 | - if (!function_exists('wp_handle_upload')) {
|
|
| 980 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 981 | - } |
|
| 974 | + // Set an array containing a list of acceptable formats |
|
| 975 | + $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
|
|
| 982 | 976 | |
| 983 | - if (!is_dir($geodir_uploadpath)) {
|
|
| 984 | - mkdir($geodir_uploadpath); |
|
| 985 | - } |
|
| 977 | + // If the uploaded file is the right format |
|
| 978 | + if (in_array($uploaded_file_type, $allowed_file_types)) {
|
|
| 979 | + if (!function_exists('wp_handle_upload')) {
|
|
| 980 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 981 | + } |
|
| 986 | 982 | |
| 987 | - $external_img = false; |
|
| 988 | - if (strpos(str_replace(array('http://','https://'),'',$curr_img_url), str_replace(array('http://','https://'),'',$uploads['baseurl'])) !== false) {
|
|
| 989 | - } else {
|
|
| 990 | - $external_img = true; |
|
| 991 | - } |
|
| 983 | + if (!is_dir($geodir_uploadpath)) {
|
|
| 984 | + mkdir($geodir_uploadpath); |
|
| 985 | + } |
|
| 992 | 986 | |
| 993 | - if ($dummy || $external_img) {
|
|
| 994 | - $uploaded_file = array(); |
|
| 995 | - $uploaded = (array)fetch_remote_file($curr_img_url); |
|
| 987 | + $external_img = false; |
|
| 988 | + if (strpos(str_replace(array('http://','https://'),'',$curr_img_url), str_replace(array('http://','https://'),'',$uploads['baseurl'])) !== false) {
|
|
| 989 | + } else {
|
|
| 990 | + $external_img = true; |
|
| 991 | + } |
|
| 996 | 992 | |
| 997 | - if (isset($uploaded['error']) && empty($uploaded['error'])) {
|
|
| 998 | - $new_name = basename($uploaded['file']); |
|
| 999 | - $uploaded_file = $uploaded; |
|
| 1000 | - }else{
|
|
| 1001 | - print_r($uploaded);exit; |
|
| 1002 | - } |
|
| 1003 | - $external_img = false; |
|
| 1004 | - } else {
|
|
| 1005 | - $new_name = $post_id . '_' . $file_name; |
|
| 993 | + if ($dummy || $external_img) {
|
|
| 994 | + $uploaded_file = array(); |
|
| 995 | + $uploaded = (array)fetch_remote_file($curr_img_url); |
|
| 1006 | 996 | |
| 1007 | - if ($curr_img_dir == $sub_dir) {
|
|
| 1008 | - $img_path = $geodir_uploadpath . '/' . $filename; |
|
| 1009 | - $img_url = $geodir_uploadurl . '/' . $filename; |
|
| 1010 | - } else {
|
|
| 1011 | - $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1012 | - $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1013 | - } |
|
| 997 | + if (isset($uploaded['error']) && empty($uploaded['error'])) {
|
|
| 998 | + $new_name = basename($uploaded['file']); |
|
| 999 | + $uploaded_file = $uploaded; |
|
| 1000 | + }else{
|
|
| 1001 | + print_r($uploaded);exit; |
|
| 1002 | + } |
|
| 1003 | + $external_img = false; |
|
| 1004 | + } else {
|
|
| 1005 | + $new_name = $post_id . '_' . $file_name; |
|
| 1014 | 1006 | |
| 1015 | - $uploaded_file = ''; |
|
| 1007 | + if ($curr_img_dir == $sub_dir) {
|
|
| 1008 | + $img_path = $geodir_uploadpath . '/' . $filename; |
|
| 1009 | + $img_url = $geodir_uploadurl . '/' . $filename; |
|
| 1010 | + } else {
|
|
| 1011 | + $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1012 | + $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1013 | + } |
|
| 1016 | 1014 | |
| 1017 | - if (file_exists($img_path)) {
|
|
| 1018 | - $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
| 1019 | - $file_path = ''; |
|
| 1020 | - } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
|
|
| 1021 | - $uploaded_file = true; |
|
| 1022 | - $file_path = $curr_img_dir . '/' . $filename; |
|
| 1023 | - } |
|
| 1015 | + $uploaded_file = ''; |
|
| 1024 | 1016 | |
| 1025 | - if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) |
|
| 1026 | - unlink($img_path); |
|
| 1027 | - } |
|
| 1017 | + if (file_exists($img_path)) {
|
|
| 1018 | + $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
| 1019 | + $file_path = ''; |
|
| 1020 | + } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
|
|
| 1021 | + $uploaded_file = true; |
|
| 1022 | + $file_path = $curr_img_dir . '/' . $filename; |
|
| 1023 | + } |
|
| 1028 | 1024 | |
| 1029 | - if (!empty($uploaded_file)) {
|
|
| 1030 | - if (!isset($file_path) || !$file_path) {
|
|
| 1031 | - $file_path = $sub_dir . '/' . $new_name; |
|
| 1032 | - } |
|
| 1025 | + if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) |
|
| 1026 | + unlink($img_path); |
|
| 1027 | + } |
|
| 1033 | 1028 | |
| 1034 | - $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
|
|
| 1029 | + if (!empty($uploaded_file)) {
|
|
| 1030 | + if (!isset($file_path) || !$file_path) {
|
|
| 1031 | + $file_path = $sub_dir . '/' . $new_name; |
|
| 1032 | + } |
|
| 1035 | 1033 | |
| 1036 | - if ($menu_order == 1) {
|
|
| 1034 | + $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
|
|
| 1037 | 1035 | |
| 1038 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
|
|
| 1036 | + if ($menu_order == 1) {
|
|
| 1039 | 1037 | |
| 1040 | - } |
|
| 1038 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
|
|
| 1041 | 1039 | |
| 1042 | - // Set up options array to add this file as an attachment |
|
| 1043 | - $attachment = array(); |
|
| 1044 | - $attachment['post_id'] = $post_id; |
|
| 1045 | - $attachment['title'] = $file_title; |
|
| 1046 | - $attachment['content'] = ''; |
|
| 1047 | - $attachment['file'] = $file_path; |
|
| 1048 | - $attachment['mime_type'] = $uploaded_file_type; |
|
| 1049 | - $attachment['menu_order'] = $menu_order; |
|
| 1050 | - $attachment['is_featured'] = 0; |
|
| 1040 | + } |
|
| 1051 | 1041 | |
| 1052 | - $attachment_set = ''; |
|
| 1042 | + // Set up options array to add this file as an attachment |
|
| 1043 | + $attachment = array(); |
|
| 1044 | + $attachment['post_id'] = $post_id; |
|
| 1045 | + $attachment['title'] = $file_title; |
|
| 1046 | + $attachment['content'] = ''; |
|
| 1047 | + $attachment['file'] = $file_path; |
|
| 1048 | + $attachment['mime_type'] = $uploaded_file_type; |
|
| 1049 | + $attachment['menu_order'] = $menu_order; |
|
| 1050 | + $attachment['is_featured'] = 0; |
|
| 1053 | 1051 | |
| 1054 | - foreach ($attachment as $key => $val) {
|
|
| 1055 | - if ($val != '') |
|
| 1056 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 1057 | - } |
|
| 1052 | + $attachment_set = ''; |
|
| 1058 | 1053 | |
| 1059 | - $attachment_set = trim($attachment_set, ", "); |
|
| 1054 | + foreach ($attachment as $key => $val) {
|
|
| 1055 | + if ($val != '') |
|
| 1056 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 1057 | + } |
|
| 1060 | 1058 | |
| 1061 | - $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 1059 | + $attachment_set = trim($attachment_set, ", "); |
|
| 1060 | + |
|
| 1061 | + $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 1062 | 1062 | |
| 1063 | - $valid_file_ids[] = $wpdb->insert_id; |
|
| 1064 | - } |
|
| 1063 | + $valid_file_ids[] = $wpdb->insert_id; |
|
| 1064 | + } |
|
| 1065 | 1065 | |
| 1066 | - } |
|
| 1066 | + } |
|
| 1067 | 1067 | |
| 1068 | 1068 | |
| 1069 | - } else {
|
|
| 1070 | - $valid_file_ids[] = $find_image; |
|
| 1069 | + } else {
|
|
| 1070 | + $valid_file_ids[] = $find_image; |
|
| 1071 | 1071 | |
| 1072 | - $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
|
|
| 1072 | + $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
|
|
| 1073 | 1073 | |
| 1074 | - $wpdb->query( |
|
| 1075 | - $wpdb->prepare( |
|
| 1076 | - "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d", |
|
| 1077 | - array($menu_order, $split_img_path[1], $post_id) |
|
| 1078 | - ) |
|
| 1079 | - ); |
|
| 1074 | + $wpdb->query( |
|
| 1075 | + $wpdb->prepare( |
|
| 1076 | + "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d", |
|
| 1077 | + array($menu_order, $split_img_path[1], $post_id) |
|
| 1078 | + ) |
|
| 1079 | + ); |
|
| 1080 | 1080 | |
| 1081 | - if ($menu_order == 1) |
|
| 1082 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
|
|
| 1081 | + if ($menu_order == 1) |
|
| 1082 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
|
|
| 1083 | 1083 | |
| 1084 | - } |
|
| 1084 | + } |
|
| 1085 | 1085 | |
| 1086 | 1086 | |
| 1087 | - } |
|
| 1087 | + } |
|
| 1088 | 1088 | |
| 1089 | - if (!empty($valid_file_ids)) {
|
|
| 1089 | + if (!empty($valid_file_ids)) {
|
|
| 1090 | 1090 | |
| 1091 | - $remove_files = $valid_file_ids; |
|
| 1091 | + $remove_files = $valid_file_ids; |
|
| 1092 | 1092 | |
| 1093 | - $remove_files_length = count($remove_files); |
|
| 1094 | - $remove_files_format = array_fill(0, $remove_files_length, '%d'); |
|
| 1095 | - $format = implode(',', $remove_files_format);
|
|
| 1096 | - $valid_files_condition = " ID NOT IN ($format) AND "; |
|
| 1093 | + $remove_files_length = count($remove_files); |
|
| 1094 | + $remove_files_format = array_fill(0, $remove_files_length, '%d'); |
|
| 1095 | + $format = implode(',', $remove_files_format);
|
|
| 1096 | + $valid_files_condition = " ID NOT IN ($format) AND "; |
|
| 1097 | 1097 | |
| 1098 | - } |
|
| 1098 | + } |
|
| 1099 | 1099 | |
| 1100 | - //Get and remove all old images of post from database to set by new order |
|
| 1100 | + //Get and remove all old images of post from database to set by new order |
|
| 1101 | 1101 | |
| 1102 | - if (!empty($post_images)) {
|
|
| 1102 | + if (!empty($post_images)) {
|
|
| 1103 | 1103 | |
| 1104 | - foreach ($post_images as $img) {
|
|
| 1104 | + foreach ($post_images as $img) {
|
|
| 1105 | 1105 | |
| 1106 | - if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
|
|
| 1106 | + if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
|
|
| 1107 | 1107 | |
| 1108 | - $invalid_files[] = (object)array('src' => $img->src);
|
|
| 1108 | + $invalid_files[] = (object)array('src' => $img->src);
|
|
| 1109 | 1109 | |
| 1110 | - } |
|
| 1110 | + } |
|
| 1111 | 1111 | |
| 1112 | - } |
|
| 1112 | + } |
|
| 1113 | 1113 | |
| 1114 | - } |
|
| 1114 | + } |
|
| 1115 | 1115 | |
| 1116 | - $invalid_files = (object)$invalid_files; |
|
| 1117 | - } |
|
| 1116 | + $invalid_files = (object)$invalid_files; |
|
| 1117 | + } |
|
| 1118 | 1118 | |
| 1119 | - $remove_files[] = $post_id; |
|
| 1119 | + $remove_files[] = $post_id; |
|
| 1120 | 1120 | |
| 1121 | - $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
|
|
| 1121 | + $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
|
|
| 1122 | 1122 | |
| 1123 | - if (!empty($invalid_files)) |
|
| 1124 | - geodir_remove_attachments($invalid_files); |
|
| 1125 | - } |
|
| 1123 | + if (!empty($invalid_files)) |
|
| 1124 | + geodir_remove_attachments($invalid_files); |
|
| 1125 | + } |
|
| 1126 | 1126 | |
| 1127 | 1127 | } |
| 1128 | 1128 | |
@@ -1136,12 +1136,12 @@ discard block |
||
| 1136 | 1136 | function geodir_remove_temp_images() |
| 1137 | 1137 | {
|
| 1138 | 1138 | |
| 1139 | - global $current_user; |
|
| 1139 | + global $current_user; |
|
| 1140 | 1140 | |
| 1141 | - $uploads = wp_upload_dir(); |
|
| 1142 | - $uploads_dir = $uploads['path']; |
|
| 1141 | + $uploads = wp_upload_dir(); |
|
| 1142 | + $uploads_dir = $uploads['path']; |
|
| 1143 | 1143 | |
| 1144 | - /* if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
|
|
| 1144 | + /* if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
|
|
| 1145 | 1145 | |
| 1146 | 1146 | $dirPath = $uploads_dir.'/temp_'.$current_user->data->ID; |
| 1147 | 1147 | if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
|
@@ -1158,8 +1158,8 @@ discard block |
||
| 1158 | 1158 | rmdir($dirPath); |
| 1159 | 1159 | } */ |
| 1160 | 1160 | |
| 1161 | - $dirname = $uploads_dir . '/temp_' . $current_user->ID; |
|
| 1162 | - geodir_delete_directory($dirname); |
|
| 1161 | + $dirname = $uploads_dir . '/temp_' . $current_user->ID; |
|
| 1162 | + geodir_delete_directory($dirname); |
|
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | 1165 | |
@@ -1173,116 +1173,116 @@ discard block |
||
| 1173 | 1173 | */ |
| 1174 | 1174 | function geodir_delete_directory($dirname) |
| 1175 | 1175 | {
|
| 1176 | - $dir_handle = ''; |
|
| 1177 | - if (is_dir($dirname)) |
|
| 1178 | - $dir_handle = opendir($dirname); |
|
| 1179 | - if (!$dir_handle) |
|
| 1180 | - return false; |
|
| 1181 | - while ($file = readdir($dir_handle)) {
|
|
| 1182 | - if ($file != "." && $file != "..") {
|
|
| 1183 | - if (!is_dir($dirname . "/" . $file)) |
|
| 1184 | - unlink($dirname . "/" . $file); |
|
| 1185 | - else |
|
| 1186 | - geodir_delete_directory($dirname . '/' . $file); |
|
| 1187 | - } |
|
| 1188 | - } |
|
| 1189 | - closedir($dir_handle); |
|
| 1190 | - rmdir($dirname); |
|
| 1191 | - return true; |
|
| 1176 | + $dir_handle = ''; |
|
| 1177 | + if (is_dir($dirname)) |
|
| 1178 | + $dir_handle = opendir($dirname); |
|
| 1179 | + if (!$dir_handle) |
|
| 1180 | + return false; |
|
| 1181 | + while ($file = readdir($dir_handle)) {
|
|
| 1182 | + if ($file != "." && $file != "..") {
|
|
| 1183 | + if (!is_dir($dirname . "/" . $file)) |
|
| 1184 | + unlink($dirname . "/" . $file); |
|
| 1185 | + else |
|
| 1186 | + geodir_delete_directory($dirname . '/' . $file); |
|
| 1187 | + } |
|
| 1188 | + } |
|
| 1189 | + closedir($dir_handle); |
|
| 1190 | + rmdir($dirname); |
|
| 1191 | + return true; |
|
| 1192 | 1192 | |
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | 1195 | |
| 1196 | 1196 | if (!function_exists('geodir_remove_attachments')) {
|
| 1197 | - /** |
|
| 1198 | - * Remove post attachments. |
|
| 1199 | - * |
|
| 1200 | - * @since 1.0.0 |
|
| 1201 | - * @package GeoDirectory |
|
| 1202 | - * @param array $postcurr_images Array of image objects. |
|
| 1203 | - */ |
|
| 1204 | - function geodir_remove_attachments($postcurr_images = array()) |
|
| 1205 | - {
|
|
| 1206 | - // Unlink all past images of post |
|
| 1207 | - if (!empty($postcurr_images)) {
|
|
| 1208 | - |
|
| 1209 | - $uploads = wp_upload_dir(); |
|
| 1210 | - $uploads_dir = $uploads['path']; |
|
| 1211 | - |
|
| 1212 | - foreach ($postcurr_images as $postimg) {
|
|
| 1213 | - $image_name_arr = explode('/', $postimg->src);
|
|
| 1214 | - $filename = end($image_name_arr); |
|
| 1215 | - if (file_exists($uploads_dir . '/' . $filename)) |
|
| 1216 | - unlink($uploads_dir . '/' . $filename); |
|
| 1217 | - } |
|
| 1218 | - |
|
| 1219 | - } // endif |
|
| 1220 | - // Unlink all past images of post end |
|
| 1221 | - } |
|
| 1197 | + /** |
|
| 1198 | + * Remove post attachments. |
|
| 1199 | + * |
|
| 1200 | + * @since 1.0.0 |
|
| 1201 | + * @package GeoDirectory |
|
| 1202 | + * @param array $postcurr_images Array of image objects. |
|
| 1203 | + */ |
|
| 1204 | + function geodir_remove_attachments($postcurr_images = array()) |
|
| 1205 | + {
|
|
| 1206 | + // Unlink all past images of post |
|
| 1207 | + if (!empty($postcurr_images)) {
|
|
| 1208 | + |
|
| 1209 | + $uploads = wp_upload_dir(); |
|
| 1210 | + $uploads_dir = $uploads['path']; |
|
| 1211 | + |
|
| 1212 | + foreach ($postcurr_images as $postimg) {
|
|
| 1213 | + $image_name_arr = explode('/', $postimg->src);
|
|
| 1214 | + $filename = end($image_name_arr); |
|
| 1215 | + if (file_exists($uploads_dir . '/' . $filename)) |
|
| 1216 | + unlink($uploads_dir . '/' . $filename); |
|
| 1217 | + } |
|
| 1218 | + |
|
| 1219 | + } // endif |
|
| 1220 | + // Unlink all past images of post end |
|
| 1221 | + } |
|
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | 1224 | if (!function_exists('geodir_get_featured_image')) {
|
| 1225 | - /** |
|
| 1226 | - * Gets the post featured image. |
|
| 1227 | - * |
|
| 1228 | - * @since 1.0.0 |
|
| 1229 | - * @package GeoDirectory |
|
| 1230 | - * @global object $wpdb WordPress Database object. |
|
| 1231 | - * @global object $post The current post object. |
|
| 1232 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1233 | - * @param int|string $post_id The post ID. |
|
| 1234 | - * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1235 | - * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1236 | - * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false. |
|
| 1237 | - * @return bool|object Image details as an object. |
|
| 1238 | - */ |
|
| 1239 | - function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false) |
|
| 1240 | - {
|
|
| 1241 | - |
|
| 1242 | - /*$img_arr['src'] = get_the_post_thumbnail_url( $post_id, 'medium');//medium/thumbnail |
|
| 1225 | + /** |
|
| 1226 | + * Gets the post featured image. |
|
| 1227 | + * |
|
| 1228 | + * @since 1.0.0 |
|
| 1229 | + * @package GeoDirectory |
|
| 1230 | + * @global object $wpdb WordPress Database object. |
|
| 1231 | + * @global object $post The current post object. |
|
| 1232 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1233 | + * @param int|string $post_id The post ID. |
|
| 1234 | + * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1235 | + * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1236 | + * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false. |
|
| 1237 | + * @return bool|object Image details as an object. |
|
| 1238 | + */ |
|
| 1239 | + function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false) |
|
| 1240 | + {
|
|
| 1241 | + |
|
| 1242 | + /*$img_arr['src'] = get_the_post_thumbnail_url( $post_id, 'medium');//medium/thumbnail |
|
| 1243 | 1243 | $img_arr['path'] = ''; |
| 1244 | 1244 | $img_arr['width'] = ''; |
| 1245 | 1245 | $img_arr['height'] = ''; |
| 1246 | 1246 | $img_arr['title'] = ''; |
| 1247 | 1247 | return (object)$img_arr;*/ |
| 1248 | - global $wpdb, $plugin_prefix, $post; |
|
| 1248 | + global $wpdb, $plugin_prefix, $post; |
|
| 1249 | 1249 | |
| 1250 | - if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
|
|
| 1251 | - $post_type = $post->post_type; |
|
| 1252 | - } else {
|
|
| 1253 | - $post_type = get_post_type($post_id); |
|
| 1254 | - } |
|
| 1250 | + if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
|
|
| 1251 | + $post_type = $post->post_type; |
|
| 1252 | + } else {
|
|
| 1253 | + $post_type = get_post_type($post_id); |
|
| 1254 | + } |
|
| 1255 | 1255 | |
| 1256 | - if (!in_array($post_type, geodir_get_posttypes())) {
|
|
| 1257 | - return false;// if not a GD CPT return; |
|
| 1258 | - } |
|
| 1256 | + if (!in_array($post_type, geodir_get_posttypes())) {
|
|
| 1257 | + return false;// if not a GD CPT return; |
|
| 1258 | + } |
|
| 1259 | 1259 | |
| 1260 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1260 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1261 | 1261 | |
| 1262 | - if (!$file) {
|
|
| 1263 | - if (isset($post->featured_image)) {
|
|
| 1264 | - $file = $post->featured_image; |
|
| 1265 | - } else {
|
|
| 1266 | - $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
|
|
| 1267 | - } |
|
| 1268 | - } |
|
| 1262 | + if (!$file) {
|
|
| 1263 | + if (isset($post->featured_image)) {
|
|
| 1264 | + $file = $post->featured_image; |
|
| 1265 | + } else {
|
|
| 1266 | + $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
|
|
| 1267 | + } |
|
| 1268 | + } |
|
| 1269 | 1269 | |
| 1270 | - if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
|
|
| 1271 | - $img_arr = array(); |
|
| 1270 | + if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
|
|
| 1271 | + $img_arr = array(); |
|
| 1272 | 1272 | |
| 1273 | - $file_info = pathinfo($file); |
|
| 1274 | - $sub_dir = ''; |
|
| 1275 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 1276 | - $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1273 | + $file_info = pathinfo($file); |
|
| 1274 | + $sub_dir = ''; |
|
| 1275 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 1276 | + $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1277 | 1277 | |
| 1278 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 1279 | - $uploads_baseurl = $uploads['baseurl']; |
|
| 1280 | - $uploads_path = $uploads['path']; |
|
| 1278 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 1279 | + $uploads_baseurl = $uploads['baseurl']; |
|
| 1280 | + $uploads_path = $uploads['path']; |
|
| 1281 | 1281 | |
| 1282 | - $file_name = $file_info['basename']; |
|
| 1282 | + $file_name = $file_info['basename']; |
|
| 1283 | 1283 | |
| 1284 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1285 | - /* |
|
| 1284 | + $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1285 | + /* |
|
| 1286 | 1286 | * Allows the filter of image src for such things as CDN change. |
| 1287 | 1287 | * |
| 1288 | 1288 | * @since 1.5.7 |
@@ -1291,158 +1291,158 @@ discard block |
||
| 1291 | 1291 | * @param string $uploads_url The server upload directory url. |
| 1292 | 1292 | * @param string $uploads_baseurl The uploads dir base url. |
| 1293 | 1293 | */ |
| 1294 | - $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1295 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1296 | - $width = 0; |
|
| 1297 | - $height = 0; |
|
| 1298 | - if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1299 | - $imagesize = getimagesize($img_arr['path']); |
|
| 1300 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1301 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1302 | - } |
|
| 1303 | - $img_arr['width'] = $width; |
|
| 1304 | - $img_arr['height'] = $height; |
|
| 1305 | - $img_arr['title'] = ''; |
|
| 1306 | - } elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
|
|
| 1307 | - foreach ($post_images as $image) {
|
|
| 1308 | - return $image; |
|
| 1309 | - } |
|
| 1310 | - } else if ($no_image) {
|
|
| 1311 | - $img_arr = array(); |
|
| 1312 | - |
|
| 1313 | - $default_img = ''; |
|
| 1314 | - if (isset($post->default_category) && $post->default_category) {
|
|
| 1315 | - $default_cat = $post->default_category; |
|
| 1316 | - } else {
|
|
| 1317 | - $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1318 | - } |
|
| 1319 | - |
|
| 1320 | - if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
| 1321 | - $default_img = $default_catimg['src']; |
|
| 1322 | - elseif ($no_image) {
|
|
| 1323 | - $default_img = get_option('geodir_listing_no_img');
|
|
| 1324 | - } |
|
| 1325 | - |
|
| 1326 | - if (!empty($default_img)) {
|
|
| 1327 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 1328 | - $uploads_baseurl = $uploads['baseurl']; |
|
| 1329 | - $uploads_path = $uploads['path']; |
|
| 1330 | - |
|
| 1331 | - $img_arr = array(); |
|
| 1332 | - |
|
| 1333 | - $file_info = pathinfo($default_img); |
|
| 1334 | - |
|
| 1335 | - $file_name = $file_info['basename']; |
|
| 1336 | - |
|
| 1337 | - $img_arr['src'] = $default_img; |
|
| 1338 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1339 | - |
|
| 1340 | - $width = 0; |
|
| 1341 | - $height = 0; |
|
| 1342 | - if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1343 | - $imagesize = getimagesize($img_arr['path']); |
|
| 1344 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1345 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1346 | - } |
|
| 1347 | - $img_arr['width'] = $width; |
|
| 1348 | - $img_arr['height'] = $height; |
|
| 1349 | - |
|
| 1350 | - $img_arr['title'] = ''; // add the title to the array |
|
| 1351 | - } |
|
| 1352 | - } |
|
| 1353 | - |
|
| 1354 | - if (!empty($img_arr)) |
|
| 1355 | - return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path ); |
|
| 1356 | - else |
|
| 1357 | - return false; |
|
| 1358 | - } |
|
| 1294 | + $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1295 | + $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1296 | + $width = 0; |
|
| 1297 | + $height = 0; |
|
| 1298 | + if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1299 | + $imagesize = getimagesize($img_arr['path']); |
|
| 1300 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1301 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1302 | + } |
|
| 1303 | + $img_arr['width'] = $width; |
|
| 1304 | + $img_arr['height'] = $height; |
|
| 1305 | + $img_arr['title'] = ''; |
|
| 1306 | + } elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
|
|
| 1307 | + foreach ($post_images as $image) {
|
|
| 1308 | + return $image; |
|
| 1309 | + } |
|
| 1310 | + } else if ($no_image) {
|
|
| 1311 | + $img_arr = array(); |
|
| 1312 | + |
|
| 1313 | + $default_img = ''; |
|
| 1314 | + if (isset($post->default_category) && $post->default_category) {
|
|
| 1315 | + $default_cat = $post->default_category; |
|
| 1316 | + } else {
|
|
| 1317 | + $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1318 | + } |
|
| 1319 | + |
|
| 1320 | + if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
| 1321 | + $default_img = $default_catimg['src']; |
|
| 1322 | + elseif ($no_image) {
|
|
| 1323 | + $default_img = get_option('geodir_listing_no_img');
|
|
| 1324 | + } |
|
| 1325 | + |
|
| 1326 | + if (!empty($default_img)) {
|
|
| 1327 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 1328 | + $uploads_baseurl = $uploads['baseurl']; |
|
| 1329 | + $uploads_path = $uploads['path']; |
|
| 1330 | + |
|
| 1331 | + $img_arr = array(); |
|
| 1332 | + |
|
| 1333 | + $file_info = pathinfo($default_img); |
|
| 1334 | + |
|
| 1335 | + $file_name = $file_info['basename']; |
|
| 1336 | + |
|
| 1337 | + $img_arr['src'] = $default_img; |
|
| 1338 | + $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1339 | + |
|
| 1340 | + $width = 0; |
|
| 1341 | + $height = 0; |
|
| 1342 | + if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1343 | + $imagesize = getimagesize($img_arr['path']); |
|
| 1344 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1345 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1346 | + } |
|
| 1347 | + $img_arr['width'] = $width; |
|
| 1348 | + $img_arr['height'] = $height; |
|
| 1349 | + |
|
| 1350 | + $img_arr['title'] = ''; // add the title to the array |
|
| 1351 | + } |
|
| 1352 | + } |
|
| 1353 | + |
|
| 1354 | + if (!empty($img_arr)) |
|
| 1355 | + return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path ); |
|
| 1356 | + else |
|
| 1357 | + return false; |
|
| 1358 | + } |
|
| 1359 | 1359 | } |
| 1360 | 1360 | |
| 1361 | 1361 | if (!function_exists('geodir_show_featured_image')) {
|
| 1362 | - /** |
|
| 1363 | - * Gets the post featured image. |
|
| 1364 | - * |
|
| 1365 | - * @since 1.0.0 |
|
| 1366 | - * @package GeoDirectory |
|
| 1367 | - * @param int|string $post_id The post ID. |
|
| 1368 | - * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1369 | - * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1370 | - * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
| 1371 | - * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false. |
|
| 1372 | - * @return bool|string Returns image html. |
|
| 1373 | - */ |
|
| 1374 | - function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false) |
|
| 1375 | - {
|
|
| 1376 | - $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage); |
|
| 1377 | - |
|
| 1378 | - $html = geodir_show_image($image, $size, $no_image, false); |
|
| 1379 | - |
|
| 1380 | - if (!empty($html) && $echo) {
|
|
| 1381 | - echo $html; |
|
| 1382 | - } elseif (!empty($html)) {
|
|
| 1383 | - return $html; |
|
| 1384 | - } else |
|
| 1385 | - return false; |
|
| 1386 | - } |
|
| 1362 | + /** |
|
| 1363 | + * Gets the post featured image. |
|
| 1364 | + * |
|
| 1365 | + * @since 1.0.0 |
|
| 1366 | + * @package GeoDirectory |
|
| 1367 | + * @param int|string $post_id The post ID. |
|
| 1368 | + * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1369 | + * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1370 | + * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
| 1371 | + * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false. |
|
| 1372 | + * @return bool|string Returns image html. |
|
| 1373 | + */ |
|
| 1374 | + function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false) |
|
| 1375 | + {
|
|
| 1376 | + $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage); |
|
| 1377 | + |
|
| 1378 | + $html = geodir_show_image($image, $size, $no_image, false); |
|
| 1379 | + |
|
| 1380 | + if (!empty($html) && $echo) {
|
|
| 1381 | + echo $html; |
|
| 1382 | + } elseif (!empty($html)) {
|
|
| 1383 | + return $html; |
|
| 1384 | + } else |
|
| 1385 | + return false; |
|
| 1386 | + } |
|
| 1387 | 1387 | } |
| 1388 | 1388 | |
| 1389 | 1389 | if (!function_exists('geodir_get_images')) {
|
| 1390 | - /** |
|
| 1391 | - * Gets the post images. |
|
| 1392 | - * |
|
| 1393 | - * @since 1.0.0 |
|
| 1394 | - * @package GeoDirectory |
|
| 1395 | - * @global object $wpdb WordPress Database object. |
|
| 1396 | - * @param int $post_id The post ID. |
|
| 1397 | - * @param string $img_size Optional. Thumbnail size. |
|
| 1398 | - * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1399 | - * @param bool $add_featured Optional. Do you want to include featured images too? Default: true. |
|
| 1400 | - * @param int|string $limit Optional. Number of images. |
|
| 1401 | - * @return array|bool Returns images as an array. Each item is an object. |
|
| 1402 | - */ |
|
| 1403 | - function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '') |
|
| 1404 | - {
|
|
| 1405 | - global $wpdb; |
|
| 1406 | - if ($limit) {
|
|
| 1407 | - $limit_q = " LIMIT $limit "; |
|
| 1408 | - } else {
|
|
| 1409 | - $limit_q = ''; |
|
| 1410 | - } |
|
| 1411 | - $not_featured = ''; |
|
| 1412 | - $sub_dir = ''; |
|
| 1413 | - if (!$add_featured) |
|
| 1414 | - $not_featured = " AND is_featured = 0 "; |
|
| 1415 | - |
|
| 1416 | - $arrImages = $wpdb->get_results( |
|
| 1417 | - $wpdb->prepare( |
|
| 1418 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ", |
|
| 1419 | - array('%image%', $post_id)
|
|
| 1420 | - ) |
|
| 1421 | - ); |
|
| 1422 | - |
|
| 1423 | - $counter = 0; |
|
| 1424 | - $return_arr = array(); |
|
| 1425 | - |
|
| 1426 | - if (!empty($arrImages)) {
|
|
| 1427 | - foreach ($arrImages as $attechment) {
|
|
| 1428 | - |
|
| 1429 | - $img_arr = array(); |
|
| 1430 | - $img_arr['id'] = $attechment->ID; |
|
| 1431 | - $img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0; |
|
| 1432 | - |
|
| 1433 | - $file_info = pathinfo($attechment->file); |
|
| 1434 | - |
|
| 1435 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 1436 | - $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1437 | - |
|
| 1438 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 1439 | - $uploads_baseurl = $uploads['baseurl']; |
|
| 1440 | - $uploads_path = $uploads['path']; |
|
| 1441 | - |
|
| 1442 | - $file_name = $file_info['basename']; |
|
| 1443 | - |
|
| 1444 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1445 | - /* |
|
| 1390 | + /** |
|
| 1391 | + * Gets the post images. |
|
| 1392 | + * |
|
| 1393 | + * @since 1.0.0 |
|
| 1394 | + * @package GeoDirectory |
|
| 1395 | + * @global object $wpdb WordPress Database object. |
|
| 1396 | + * @param int $post_id The post ID. |
|
| 1397 | + * @param string $img_size Optional. Thumbnail size. |
|
| 1398 | + * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1399 | + * @param bool $add_featured Optional. Do you want to include featured images too? Default: true. |
|
| 1400 | + * @param int|string $limit Optional. Number of images. |
|
| 1401 | + * @return array|bool Returns images as an array. Each item is an object. |
|
| 1402 | + */ |
|
| 1403 | + function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '') |
|
| 1404 | + {
|
|
| 1405 | + global $wpdb; |
|
| 1406 | + if ($limit) {
|
|
| 1407 | + $limit_q = " LIMIT $limit "; |
|
| 1408 | + } else {
|
|
| 1409 | + $limit_q = ''; |
|
| 1410 | + } |
|
| 1411 | + $not_featured = ''; |
|
| 1412 | + $sub_dir = ''; |
|
| 1413 | + if (!$add_featured) |
|
| 1414 | + $not_featured = " AND is_featured = 0 "; |
|
| 1415 | + |
|
| 1416 | + $arrImages = $wpdb->get_results( |
|
| 1417 | + $wpdb->prepare( |
|
| 1418 | + "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ", |
|
| 1419 | + array('%image%', $post_id)
|
|
| 1420 | + ) |
|
| 1421 | + ); |
|
| 1422 | + |
|
| 1423 | + $counter = 0; |
|
| 1424 | + $return_arr = array(); |
|
| 1425 | + |
|
| 1426 | + if (!empty($arrImages)) {
|
|
| 1427 | + foreach ($arrImages as $attechment) {
|
|
| 1428 | + |
|
| 1429 | + $img_arr = array(); |
|
| 1430 | + $img_arr['id'] = $attechment->ID; |
|
| 1431 | + $img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0; |
|
| 1432 | + |
|
| 1433 | + $file_info = pathinfo($attechment->file); |
|
| 1434 | + |
|
| 1435 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 1436 | + $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1437 | + |
|
| 1438 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 1439 | + $uploads_baseurl = $uploads['baseurl']; |
|
| 1440 | + $uploads_path = $uploads['path']; |
|
| 1441 | + |
|
| 1442 | + $file_name = $file_info['basename']; |
|
| 1443 | + |
|
| 1444 | + $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1445 | + /* |
|
| 1446 | 1446 | * Allows the filter of image src for such things as CDN change. |
| 1447 | 1447 | * |
| 1448 | 1448 | * @since 1.5.7 |
@@ -1451,534 +1451,534 @@ discard block |
||
| 1451 | 1451 | * @param string $uploads_url The server upload directory url. |
| 1452 | 1452 | * @param string $uploads_baseurl The uploads dir base url. |
| 1453 | 1453 | */ |
| 1454 | - $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1455 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1456 | - $width = 0; |
|
| 1457 | - $height = 0; |
|
| 1458 | - if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1459 | - $imagesize = getimagesize($img_arr['path']); |
|
| 1460 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1461 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1462 | - } |
|
| 1463 | - $img_arr['width'] = $width; |
|
| 1464 | - $img_arr['height'] = $height; |
|
| 1465 | - |
|
| 1466 | - $img_arr['file'] = $file_name; // add the title to the array |
|
| 1467 | - $img_arr['title'] = $attechment->title; // add the title to the array |
|
| 1468 | - $img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array |
|
| 1469 | - $img_arr['content'] = $attechment->content; // add the description to the array |
|
| 1470 | - $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1. |
|
| 1471 | - |
|
| 1472 | - $return_arr[] = (object)$img_arr; |
|
| 1473 | - |
|
| 1474 | - $counter++; |
|
| 1475 | - } |
|
| 1476 | - return (object)$return_arr; |
|
| 1477 | - } else if ($no_images) {
|
|
| 1478 | - $default_img = ''; |
|
| 1479 | - $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1480 | - $post_type = get_post_type($post_id); |
|
| 1481 | - if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
| 1482 | - $default_img = $default_catimg['src']; |
|
| 1483 | - elseif ($no_images) {
|
|
| 1484 | - $default_img = get_option('geodir_listing_no_img');
|
|
| 1485 | - } |
|
| 1486 | - |
|
| 1487 | - if (!empty($default_img)) {
|
|
| 1488 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 1454 | + $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1455 | + $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1456 | + $width = 0; |
|
| 1457 | + $height = 0; |
|
| 1458 | + if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1459 | + $imagesize = getimagesize($img_arr['path']); |
|
| 1460 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1461 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1462 | + } |
|
| 1463 | + $img_arr['width'] = $width; |
|
| 1464 | + $img_arr['height'] = $height; |
|
| 1465 | + |
|
| 1466 | + $img_arr['file'] = $file_name; // add the title to the array |
|
| 1467 | + $img_arr['title'] = $attechment->title; // add the title to the array |
|
| 1468 | + $img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array |
|
| 1469 | + $img_arr['content'] = $attechment->content; // add the description to the array |
|
| 1470 | + $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1. |
|
| 1471 | + |
|
| 1472 | + $return_arr[] = (object)$img_arr; |
|
| 1473 | + |
|
| 1474 | + $counter++; |
|
| 1475 | + } |
|
| 1476 | + return (object)$return_arr; |
|
| 1477 | + } else if ($no_images) {
|
|
| 1478 | + $default_img = ''; |
|
| 1479 | + $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1480 | + $post_type = get_post_type($post_id); |
|
| 1481 | + if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
| 1482 | + $default_img = $default_catimg['src']; |
|
| 1483 | + elseif ($no_images) {
|
|
| 1484 | + $default_img = get_option('geodir_listing_no_img');
|
|
| 1485 | + } |
|
| 1486 | + |
|
| 1487 | + if (!empty($default_img)) {
|
|
| 1488 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 1489 | 1489 | |
| 1490 | - $image_path = $default_img; |
|
| 1491 | - if (!path_is_absolute($image_path)) {
|
|
| 1492 | - $image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path); |
|
| 1493 | - } |
|
| 1494 | - |
|
| 1495 | - $file_info = pathinfo($default_img); |
|
| 1496 | - $file_name = $file_info['basename']; |
|
| 1497 | - |
|
| 1498 | - $width = ''; |
|
| 1499 | - $height = ''; |
|
| 1500 | - if (is_file($image_path) && file_exists($image_path)) {
|
|
| 1501 | - $imagesize = getimagesize($image_path); |
|
| 1502 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1503 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1504 | - } |
|
| 1490 | + $image_path = $default_img; |
|
| 1491 | + if (!path_is_absolute($image_path)) {
|
|
| 1492 | + $image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path); |
|
| 1493 | + } |
|
| 1494 | + |
|
| 1495 | + $file_info = pathinfo($default_img); |
|
| 1496 | + $file_name = $file_info['basename']; |
|
| 1497 | + |
|
| 1498 | + $width = ''; |
|
| 1499 | + $height = ''; |
|
| 1500 | + if (is_file($image_path) && file_exists($image_path)) {
|
|
| 1501 | + $imagesize = getimagesize($image_path); |
|
| 1502 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1503 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1504 | + } |
|
| 1505 | 1505 | |
| 1506 | - $img_arr = array(); |
|
| 1507 | - $img_arr['src'] = $default_img; |
|
| 1508 | - $img_arr['path'] = $image_path; |
|
| 1509 | - $img_arr['width'] = $width; |
|
| 1510 | - $img_arr['height'] = $height; |
|
| 1511 | - $img_arr['file'] = $file_name; // add the title to the array |
|
| 1512 | - $img_arr['title'] = $file_info['filename']; // add the title to the array |
|
| 1513 | - $img_arr['content'] = $file_info['filename']; // add the description to the array |
|
| 1514 | - |
|
| 1515 | - $return_arr[] = (object)$img_arr; |
|
| 1516 | - |
|
| 1517 | - return $return_arr; |
|
| 1518 | - } else |
|
| 1519 | - return false; |
|
| 1520 | - } |
|
| 1521 | - } |
|
| 1506 | + $img_arr = array(); |
|
| 1507 | + $img_arr['src'] = $default_img; |
|
| 1508 | + $img_arr['path'] = $image_path; |
|
| 1509 | + $img_arr['width'] = $width; |
|
| 1510 | + $img_arr['height'] = $height; |
|
| 1511 | + $img_arr['file'] = $file_name; // add the title to the array |
|
| 1512 | + $img_arr['title'] = $file_info['filename']; // add the title to the array |
|
| 1513 | + $img_arr['content'] = $file_info['filename']; // add the description to the array |
|
| 1514 | + |
|
| 1515 | + $return_arr[] = (object)$img_arr; |
|
| 1516 | + |
|
| 1517 | + return $return_arr; |
|
| 1518 | + } else |
|
| 1519 | + return false; |
|
| 1520 | + } |
|
| 1521 | + } |
|
| 1522 | 1522 | } |
| 1523 | 1523 | |
| 1524 | 1524 | if (!function_exists('geodir_show_image')) {
|
| 1525 | - /** |
|
| 1526 | - * Show image using image details. |
|
| 1527 | - * |
|
| 1528 | - * @since 1.0.0 |
|
| 1529 | - * @package GeoDirectory |
|
| 1530 | - * @param array|object $request Image info either as an array or object. |
|
| 1531 | - * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1532 | - * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1533 | - * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
| 1534 | - * @return bool|string Returns image html. |
|
| 1535 | - */ |
|
| 1536 | - function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true) |
|
| 1537 | - {
|
|
| 1538 | - $image = new stdClass(); |
|
| 1539 | - |
|
| 1540 | - $html = ''; |
|
| 1541 | - if (!empty($request)) {
|
|
| 1542 | - if (!is_object($request)){
|
|
| 1543 | - $request = (object)$request; |
|
| 1544 | - } |
|
| 1545 | - |
|
| 1546 | - if (isset($request->src) && !isset($request->path)) {
|
|
| 1547 | - $request->path = $request->src; |
|
| 1548 | - } |
|
| 1549 | - |
|
| 1550 | - /* |
|
| 1525 | + /** |
|
| 1526 | + * Show image using image details. |
|
| 1527 | + * |
|
| 1528 | + * @since 1.0.0 |
|
| 1529 | + * @package GeoDirectory |
|
| 1530 | + * @param array|object $request Image info either as an array or object. |
|
| 1531 | + * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1532 | + * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1533 | + * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
| 1534 | + * @return bool|string Returns image html. |
|
| 1535 | + */ |
|
| 1536 | + function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true) |
|
| 1537 | + {
|
|
| 1538 | + $image = new stdClass(); |
|
| 1539 | + |
|
| 1540 | + $html = ''; |
|
| 1541 | + if (!empty($request)) {
|
|
| 1542 | + if (!is_object($request)){
|
|
| 1543 | + $request = (object)$request; |
|
| 1544 | + } |
|
| 1545 | + |
|
| 1546 | + if (isset($request->src) && !isset($request->path)) {
|
|
| 1547 | + $request->path = $request->src; |
|
| 1548 | + } |
|
| 1549 | + |
|
| 1550 | + /* |
|
| 1551 | 1551 | * getimagesize() works faster from path than url so we try and get path if we can. |
| 1552 | 1552 | */ |
| 1553 | - $upload_dir = wp_upload_dir(); |
|
| 1554 | - $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
|
|
| 1555 | - $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
|
|
| 1556 | - if (strpos($img_no_http, $upload_no_http) !== false) {
|
|
| 1557 | - $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path); |
|
| 1558 | - } |
|
| 1553 | + $upload_dir = wp_upload_dir(); |
|
| 1554 | + $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
|
|
| 1555 | + $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
|
|
| 1556 | + if (strpos($img_no_http, $upload_no_http) !== false) {
|
|
| 1557 | + $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path); |
|
| 1558 | + } |
|
| 1559 | 1559 | |
| 1560 | - $width = 0; |
|
| 1561 | - $height = 0; |
|
| 1562 | - if (is_file($request->path) && file_exists($request->path)) {
|
|
| 1563 | - $imagesize = getimagesize($request->path); |
|
| 1564 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1565 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1566 | - } |
|
| 1567 | - |
|
| 1568 | - $image->src = $request->src; |
|
| 1569 | - $image->width = $width; |
|
| 1570 | - $image->height = $height; |
|
| 1571 | - |
|
| 1572 | - $max_size = (object)geodir_get_imagesize($size); |
|
| 1573 | - |
|
| 1574 | - if (!is_wp_error($max_size)) {
|
|
| 1575 | - if ($image->width) {
|
|
| 1576 | - if ($image->height >= $image->width) {
|
|
| 1577 | - $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2); |
|
| 1578 | - } else if ($image->width < ($max_size->h)) {
|
|
| 1579 | - $width_per = round((($image->width / $max_size->w) * 100), 2); |
|
| 1580 | - } else |
|
| 1581 | - $width_per = 100; |
|
| 1582 | - } |
|
| 1583 | - |
|
| 1584 | - if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
|
|
| 1585 | - $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '" /></div>'; |
|
| 1586 | - } else {
|
|
| 1587 | - if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
|
|
| 1588 | - $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
|
| 1589 | - }else{
|
|
| 1590 | - //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
|
| 1591 | - //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>'; |
|
| 1592 | - $html = '<div data-src="'.$image->src.'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>'; |
|
| 1593 | - |
|
| 1594 | - } |
|
| 1595 | - |
|
| 1596 | - } |
|
| 1597 | - } |
|
| 1598 | - } |
|
| 1599 | - |
|
| 1600 | - if (!empty($html) && $echo) {
|
|
| 1601 | - echo $html; |
|
| 1602 | - } elseif (!empty($html)) {
|
|
| 1603 | - return $html; |
|
| 1604 | - } else |
|
| 1605 | - return false; |
|
| 1606 | - } |
|
| 1607 | -} |
|
| 1560 | + $width = 0; |
|
| 1561 | + $height = 0; |
|
| 1562 | + if (is_file($request->path) && file_exists($request->path)) {
|
|
| 1563 | + $imagesize = getimagesize($request->path); |
|
| 1564 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1565 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1566 | + } |
|
| 1608 | 1567 | |
| 1609 | -if (!function_exists('geodir_set_post_terms')) {
|
|
| 1610 | - /** |
|
| 1611 | - * Set post Categories. |
|
| 1612 | - * |
|
| 1613 | - * @since 1.0.0 |
|
| 1614 | - * @package GeoDirectory |
|
| 1615 | - * @global object $wpdb WordPress Database object. |
|
| 1616 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1617 | - * @param int $post_id The post ID. |
|
| 1618 | - * @param array $terms An array of term objects. |
|
| 1619 | - * @param array $tt_ids An array of term taxonomy IDs. |
|
| 1620 | - * @param string $taxonomy Taxonomy slug. |
|
| 1621 | - */ |
|
| 1622 | - function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy) |
|
| 1623 | - {
|
|
| 1624 | - global $wpdb, $plugin_prefix; |
|
| 1568 | + $image->src = $request->src; |
|
| 1569 | + $image->width = $width; |
|
| 1570 | + $image->height = $height; |
|
| 1625 | 1571 | |
| 1626 | - $post_type = get_post_type($post_id); |
|
| 1572 | + $max_size = (object)geodir_get_imagesize($size); |
|
| 1627 | 1573 | |
| 1628 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1574 | + if (!is_wp_error($max_size)) {
|
|
| 1575 | + if ($image->width) {
|
|
| 1576 | + if ($image->height >= $image->width) {
|
|
| 1577 | + $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2); |
|
| 1578 | + } else if ($image->width < ($max_size->h)) {
|
|
| 1579 | + $width_per = round((($image->width / $max_size->w) * 100), 2); |
|
| 1580 | + } else |
|
| 1581 | + $width_per = 100; |
|
| 1582 | + } |
|
| 1629 | 1583 | |
| 1630 | - if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
|
|
| 1584 | + if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
|
|
| 1585 | + $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '" /></div>'; |
|
| 1586 | + } else {
|
|
| 1587 | + if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
|
|
| 1588 | + $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
|
| 1589 | + }else{
|
|
| 1590 | + //$html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');"></div>'; |
|
| 1591 | + //$html = '<div data-src="'.$image->src.'" class="geodir_thumbnail" ></div>'; |
|
| 1592 | + $html = '<div data-src="'.$image->src.'" class="geodir_thumbnail geodir_lazy_load_thumbnail" ></div>'; |
|
| 1593 | + |
|
| 1594 | + } |
|
| 1595 | + |
|
| 1596 | + } |
|
| 1597 | + } |
|
| 1598 | + } |
|
| 1599 | + |
|
| 1600 | + if (!empty($html) && $echo) {
|
|
| 1601 | + echo $html; |
|
| 1602 | + } elseif (!empty($html)) {
|
|
| 1603 | + return $html; |
|
| 1604 | + } else |
|
| 1605 | + return false; |
|
| 1606 | + } |
|
| 1607 | +} |
|
| 1631 | 1608 | |
| 1632 | - if ($taxonomy == $post_type . '_tags') {
|
|
| 1633 | - if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 1634 | - geodir_save_post_meta($post_id, 'post_tags', $terms); |
|
| 1635 | - } |
|
| 1636 | - } elseif ($taxonomy == $post_type . 'category') {
|
|
| 1637 | - $srcharr = array('"', '\\');
|
|
| 1638 | - $replarr = array(""", '');
|
|
| 1609 | +if (!function_exists('geodir_set_post_terms')) {
|
|
| 1610 | + /** |
|
| 1611 | + * Set post Categories. |
|
| 1612 | + * |
|
| 1613 | + * @since 1.0.0 |
|
| 1614 | + * @package GeoDirectory |
|
| 1615 | + * @global object $wpdb WordPress Database object. |
|
| 1616 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1617 | + * @param int $post_id The post ID. |
|
| 1618 | + * @param array $terms An array of term objects. |
|
| 1619 | + * @param array $tt_ids An array of term taxonomy IDs. |
|
| 1620 | + * @param string $taxonomy Taxonomy slug. |
|
| 1621 | + */ |
|
| 1622 | + function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy) |
|
| 1623 | + {
|
|
| 1624 | + global $wpdb, $plugin_prefix; |
|
| 1625 | + |
|
| 1626 | + $post_type = get_post_type($post_id); |
|
| 1627 | + |
|
| 1628 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1629 | + |
|
| 1630 | + if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
|
|
| 1631 | + |
|
| 1632 | + if ($taxonomy == $post_type . '_tags') {
|
|
| 1633 | + if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 1634 | + geodir_save_post_meta($post_id, 'post_tags', $terms); |
|
| 1635 | + } |
|
| 1636 | + } elseif ($taxonomy == $post_type . 'category') {
|
|
| 1637 | + $srcharr = array('"', '\\');
|
|
| 1638 | + $replarr = array(""", '');
|
|
| 1639 | 1639 | |
| 1640 | - $post_obj = get_post($post_id); |
|
| 1640 | + $post_obj = get_post($post_id); |
|
| 1641 | 1641 | |
| 1642 | - $cat_ids = array('0');
|
|
| 1643 | - if (is_array($tt_ids)) |
|
| 1644 | - $cat_ids = $tt_ids; |
|
| 1642 | + $cat_ids = array('0');
|
|
| 1643 | + if (is_array($tt_ids)) |
|
| 1644 | + $cat_ids = $tt_ids; |
|
| 1645 | 1645 | |
| 1646 | 1646 | |
| 1647 | - if (!empty($cat_ids)) {
|
|
| 1648 | - $cat_ids_array = $cat_ids; |
|
| 1649 | - $cat_ids_length = count($cat_ids_array); |
|
| 1650 | - $cat_ids_format = array_fill(0, $cat_ids_length, '%d'); |
|
| 1651 | - $format = implode(',', $cat_ids_format);
|
|
| 1647 | + if (!empty($cat_ids)) {
|
|
| 1648 | + $cat_ids_array = $cat_ids; |
|
| 1649 | + $cat_ids_length = count($cat_ids_array); |
|
| 1650 | + $cat_ids_format = array_fill(0, $cat_ids_length, '%d'); |
|
| 1651 | + $format = implode(',', $cat_ids_format);
|
|
| 1652 | 1652 | |
| 1653 | - $cat_ids_array_del = $cat_ids_array; |
|
| 1654 | - $cat_ids_array_del[] = $post_id; |
|
| 1653 | + $cat_ids_array_del = $cat_ids_array; |
|
| 1654 | + $cat_ids_array_del[] = $post_id; |
|
| 1655 | 1655 | |
| 1656 | - $wpdb->get_var( |
|
| 1657 | - $wpdb->prepare( |
|
| 1658 | - "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ", |
|
| 1659 | - $cat_ids_array_del |
|
| 1660 | - ) |
|
| 1661 | - ); |
|
| 1656 | + $wpdb->get_var( |
|
| 1657 | + $wpdb->prepare( |
|
| 1658 | + "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ", |
|
| 1659 | + $cat_ids_array_del |
|
| 1660 | + ) |
|
| 1661 | + ); |
|
| 1662 | 1662 | |
| 1663 | 1663 | |
| 1664 | - $post_term = $wpdb->get_col( |
|
| 1665 | - $wpdb->prepare( |
|
| 1666 | - "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id", |
|
| 1667 | - $cat_ids_array |
|
| 1668 | - ) |
|
| 1669 | - ); |
|
| 1664 | + $post_term = $wpdb->get_col( |
|
| 1665 | + $wpdb->prepare( |
|
| 1666 | + "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id", |
|
| 1667 | + $cat_ids_array |
|
| 1668 | + ) |
|
| 1669 | + ); |
|
| 1670 | 1670 | |
| 1671 | - } |
|
| 1671 | + } |
|
| 1672 | 1672 | |
| 1673 | - $post_marker_json = ''; |
|
| 1673 | + $post_marker_json = ''; |
|
| 1674 | 1674 | |
| 1675 | - if (!empty($post_term)): |
|
| 1675 | + if (!empty($post_term)): |
|
| 1676 | 1676 | |
| 1677 | - foreach ($post_term as $cat_id): |
|
| 1677 | + foreach ($post_term as $cat_id): |
|
| 1678 | 1678 | |
| 1679 | - $term_icon_url = get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type); |
|
| 1680 | - $term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : ''; |
|
| 1679 | + $term_icon_url = get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type); |
|
| 1680 | + $term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : ''; |
|
| 1681 | 1681 | |
| 1682 | - $post_title = $post_obj->title; |
|
| 1683 | - $title = str_replace($srcharr, $replarr, $post_title); |
|
| 1682 | + $post_title = $post_obj->title; |
|
| 1683 | + $title = str_replace($srcharr, $replarr, $post_title); |
|
| 1684 | 1684 | |
| 1685 | - $lat = geodir_get_post_meta($post_id, 'post_latitude', true); |
|
| 1686 | - $lng = geodir_get_post_meta($post_id, 'post_longitude', true); |
|
| 1685 | + $lat = geodir_get_post_meta($post_id, 'post_latitude', true); |
|
| 1686 | + $lng = geodir_get_post_meta($post_id, 'post_longitude', true); |
|
| 1687 | 1687 | |
| 1688 | - $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
|
|
| 1689 | - $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true); |
|
| 1688 | + $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
|
|
| 1689 | + $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true); |
|
| 1690 | 1690 | |
| 1691 | - $json = '{';
|
|
| 1692 | - $json .= '"id":"' . $post_id . '",'; |
|
| 1693 | - $json .= '"lat_pos": "' . $lat . '",'; |
|
| 1694 | - $json .= '"long_pos": "' . $lng . '",'; |
|
| 1695 | - $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",'; |
|
| 1696 | - $json .= '"icon":"' . $term_icon . '",'; |
|
| 1697 | - $json .= '"group":"catgroup' . $cat_id . '"'; |
|
| 1698 | - $json .= '}'; |
|
| 1691 | + $json = '{';
|
|
| 1692 | + $json .= '"id":"' . $post_id . '",'; |
|
| 1693 | + $json .= '"lat_pos": "' . $lat . '",'; |
|
| 1694 | + $json .= '"long_pos": "' . $lng . '",'; |
|
| 1695 | + $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",'; |
|
| 1696 | + $json .= '"icon":"' . $term_icon . '",'; |
|
| 1697 | + $json .= '"group":"catgroup' . $cat_id . '"'; |
|
| 1698 | + $json .= '}'; |
|
| 1699 | 1699 | |
| 1700 | 1700 | |
| 1701 | - if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) |
|
| 1702 | - $post_marker_json = $json; |
|
| 1701 | + if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) |
|
| 1702 | + $post_marker_json = $json; |
|
| 1703 | 1703 | |
| 1704 | 1704 | |
| 1705 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
|
|
| 1705 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
|
|
| 1706 | 1706 | |
| 1707 | - $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
|
|
| 1707 | + $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
|
|
| 1708 | 1708 | post_title = %s, |
| 1709 | 1709 | json = %s |
| 1710 | 1710 | WHERE post_id = %d AND cat_id = %d ", |
| 1711 | - array($post_title, $json, $post_id, $cat_id)); |
|
| 1711 | + array($post_title, $json, $post_id, $cat_id)); |
|
| 1712 | 1712 | |
| 1713 | - } else {
|
|
| 1713 | + } else {
|
|
| 1714 | 1714 | |
| 1715 | - $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
|
|
| 1715 | + $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
|
|
| 1716 | 1716 | post_id = %d, |
| 1717 | 1717 | post_title = %s, |
| 1718 | 1718 | cat_id = %d, |
| 1719 | 1719 | json = %s", |
| 1720 | - array($post_id, $post_title, $cat_id, $json)); |
|
| 1720 | + array($post_id, $post_title, $cat_id, $json)); |
|
| 1721 | 1721 | |
| 1722 | - } |
|
| 1722 | + } |
|
| 1723 | 1723 | |
| 1724 | - $wpdb->query($json_query); |
|
| 1724 | + $wpdb->query($json_query); |
|
| 1725 | 1725 | |
| 1726 | - endforeach; |
|
| 1726 | + endforeach; |
|
| 1727 | 1727 | |
| 1728 | - endif; |
|
| 1728 | + endif; |
|
| 1729 | 1729 | |
| 1730 | - if (!empty($post_term) && is_array($post_term)) {
|
|
| 1731 | - $categories = implode(',', $post_term);
|
|
| 1730 | + if (!empty($post_term) && is_array($post_term)) {
|
|
| 1731 | + $categories = implode(',', $post_term);
|
|
| 1732 | 1732 | |
| 1733 | - if ($categories != '' && $categories != 0) $categories = ',' . $categories . ','; |
|
| 1733 | + if ($categories != '' && $categories != 0) $categories = ',' . $categories . ','; |
|
| 1734 | 1734 | |
| 1735 | - if (empty($post_marker_json)) |
|
| 1736 | - $post_marker_json = isset($json) ? $json : ''; |
|
| 1735 | + if (empty($post_marker_json)) |
|
| 1736 | + $post_marker_json = isset($json) ? $json : ''; |
|
| 1737 | 1737 | |
| 1738 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 1738 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 1739 | 1739 | |
| 1740 | - $wpdb->query( |
|
| 1741 | - $wpdb->prepare( |
|
| 1742 | - "UPDATE " . $table . " SET |
|
| 1740 | + $wpdb->query( |
|
| 1741 | + $wpdb->prepare( |
|
| 1742 | + "UPDATE " . $table . " SET |
|
| 1743 | 1743 | " . $taxonomy . " = %s, |
| 1744 | 1744 | marker_json = %s |
| 1745 | 1745 | where post_id = %d", |
| 1746 | - array($categories, $post_marker_json, $post_id) |
|
| 1747 | - ) |
|
| 1748 | - ); |
|
| 1746 | + array($categories, $post_marker_json, $post_id) |
|
| 1747 | + ) |
|
| 1748 | + ); |
|
| 1749 | 1749 | |
| 1750 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
|
|
| 1750 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
|
|
| 1751 | 1751 | |
| 1752 | - $categories = trim($categories, ','); |
|
| 1752 | + $categories = trim($categories, ','); |
|
| 1753 | 1753 | |
| 1754 | - if ($categories) {
|
|
| 1754 | + if ($categories) {
|
|
| 1755 | 1755 | |
| 1756 | - $categories = explode(',', $categories);
|
|
| 1756 | + $categories = explode(',', $categories);
|
|
| 1757 | 1757 | |
| 1758 | - $default_category = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1758 | + $default_category = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1759 | 1759 | |
| 1760 | - if (!in_array($default_category, $categories)) {
|
|
| 1760 | + if (!in_array($default_category, $categories)) {
|
|
| 1761 | 1761 | |
| 1762 | - $wpdb->query( |
|
| 1763 | - $wpdb->prepare( |
|
| 1764 | - "UPDATE " . $table . " SET |
|
| 1762 | + $wpdb->query( |
|
| 1763 | + $wpdb->prepare( |
|
| 1764 | + "UPDATE " . $table . " SET |
|
| 1765 | 1765 | default_category = %s |
| 1766 | 1766 | where post_id = %d", |
| 1767 | - array($categories[0], $post_id) |
|
| 1768 | - ) |
|
| 1769 | - ); |
|
| 1767 | + array($categories[0], $post_id) |
|
| 1768 | + ) |
|
| 1769 | + ); |
|
| 1770 | 1770 | |
| 1771 | - $default_category = $categories[0]; |
|
| 1771 | + $default_category = $categories[0]; |
|
| 1772 | 1772 | |
| 1773 | - } |
|
| 1773 | + } |
|
| 1774 | 1774 | |
| 1775 | - if ($default_category == '') |
|
| 1776 | - $default_category = $categories[0]; |
|
| 1775 | + if ($default_category == '') |
|
| 1776 | + $default_category = $categories[0]; |
|
| 1777 | 1777 | |
| 1778 | - geodir_set_postcat_structure($post_id, $taxonomy, $default_category, ''); |
|
| 1778 | + geodir_set_postcat_structure($post_id, $taxonomy, $default_category, ''); |
|
| 1779 | 1779 | |
| 1780 | - } |
|
| 1780 | + } |
|
| 1781 | 1781 | |
| 1782 | - } |
|
| 1782 | + } |
|
| 1783 | 1783 | |
| 1784 | 1784 | |
| 1785 | - } else {
|
|
| 1785 | + } else {
|
|
| 1786 | 1786 | |
| 1787 | - $wpdb->query( |
|
| 1788 | - $wpdb->prepare( |
|
| 1789 | - "INSERT INTO " . $table . " SET |
|
| 1787 | + $wpdb->query( |
|
| 1788 | + $wpdb->prepare( |
|
| 1789 | + "INSERT INTO " . $table . " SET |
|
| 1790 | 1790 | post_id = %d, |
| 1791 | 1791 | " . $taxonomy . " = %s, |
| 1792 | 1792 | marker_json = %s ", |
| 1793 | 1793 | |
| 1794 | - array($post_id, $categories, $post_marker_json) |
|
| 1795 | - ) |
|
| 1796 | - ); |
|
| 1797 | - } |
|
| 1798 | - } |
|
| 1799 | - } |
|
| 1800 | - } |
|
| 1801 | - } |
|
| 1794 | + array($post_id, $categories, $post_marker_json) |
|
| 1795 | + ) |
|
| 1796 | + ); |
|
| 1797 | + } |
|
| 1798 | + } |
|
| 1799 | + } |
|
| 1800 | + } |
|
| 1801 | + } |
|
| 1802 | 1802 | } |
| 1803 | 1803 | |
| 1804 | 1804 | if (!function_exists('geodir_get_infowindow_html')) {
|
| 1805 | - /** |
|
| 1806 | - * Set post Map Marker info html. |
|
| 1807 | - * |
|
| 1808 | - * @since 1.0.0 |
|
| 1809 | - * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before". |
|
| 1810 | - * @package GeoDirectory |
|
| 1811 | - * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
| 1812 | - * @global object $gd_session GeoDirectory Session object. |
|
| 1813 | - * @param object $postinfo_obj The post details object. |
|
| 1814 | - * @param string $post_preview Is this a post preview?. |
|
| 1815 | - * @return mixed|string|void |
|
| 1816 | - */ |
|
| 1817 | - function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') |
|
| 1818 | - {
|
|
| 1819 | - global $preview, $gd_session; |
|
| 1820 | - $srcharr = array("'", "/", "-", '"', '\\');
|
|
| 1821 | - $replarr = array("′", "⁄", "–", "“", '');
|
|
| 1822 | - |
|
| 1823 | - if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
|
|
| 1824 | - $ID = ''; |
|
| 1825 | - $plink = ''; |
|
| 1826 | - |
|
| 1827 | - if (isset($postinfo_obj->pid)) {
|
|
| 1828 | - $ID = $postinfo_obj->pid; |
|
| 1829 | - $plink = get_permalink($ID); |
|
| 1830 | - } |
|
| 1831 | - |
|
| 1832 | - $title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title)); |
|
| 1833 | - $lat = $postinfo_obj->post_latitude; |
|
| 1834 | - $lng = $postinfo_obj->post_longitude; |
|
| 1835 | - $address = str_replace($srcharr, $replarr, ($postinfo_obj->post_address)); |
|
| 1836 | - $contact = str_replace($srcharr, $replarr, ($postinfo_obj->geodir_contact)); |
|
| 1837 | - $timing = str_replace($srcharr, $replarr, ($postinfo_obj->geodir_timing)); |
|
| 1838 | - } else {
|
|
| 1839 | - $ID = $postinfo_obj->post_id; |
|
| 1840 | - $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan |
|
| 1841 | - $plink = get_permalink($ID); |
|
| 1842 | - $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true)); |
|
| 1843 | - $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true)); |
|
| 1844 | - $address = str_replace($srcharr, $replarr, htmlentities(geodir_get_post_meta($ID, 'post_address', true), ENT_COMPAT, 'UTF-8')); // fix by Stiofan |
|
| 1845 | - $contact = str_replace($srcharr, $replarr, htmlentities(geodir_get_post_meta($ID, 'geodir_contact', true), ENT_COMPAT, 'UTF-8')); |
|
| 1846 | - $timing = str_replace($srcharr, $replarr, (geodir_get_post_meta($ID, 'geodir_timing', true))); |
|
| 1847 | - } |
|
| 1848 | - |
|
| 1849 | - // filter field as per price package |
|
| 1850 | - global $geodir_addon_list; |
|
| 1851 | - if (isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes') {
|
|
| 1852 | - $post_type = get_post_type($ID); |
|
| 1853 | - $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL; |
|
| 1854 | - $field_name = 'geodir_contact'; |
|
| 1855 | - if (!check_field_visibility($package_id, $field_name, $post_type)) {
|
|
| 1856 | - $contact = ''; |
|
| 1857 | - } |
|
| 1858 | - |
|
| 1859 | - $field_name = 'geodir_timing'; |
|
| 1860 | - if (!check_field_visibility($package_id, $field_name, $post_type)) {
|
|
| 1861 | - $timing = ''; |
|
| 1862 | - } |
|
| 1863 | - } |
|
| 1864 | - |
|
| 1865 | - if ($lat && $lng) {
|
|
| 1866 | - ob_start(); ?> |
|
| 1805 | + /** |
|
| 1806 | + * Set post Map Marker info html. |
|
| 1807 | + * |
|
| 1808 | + * @since 1.0.0 |
|
| 1809 | + * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before". |
|
| 1810 | + * @package GeoDirectory |
|
| 1811 | + * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
| 1812 | + * @global object $gd_session GeoDirectory Session object. |
|
| 1813 | + * @param object $postinfo_obj The post details object. |
|
| 1814 | + * @param string $post_preview Is this a post preview?. |
|
| 1815 | + * @return mixed|string|void |
|
| 1816 | + */ |
|
| 1817 | + function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') |
|
| 1818 | + {
|
|
| 1819 | + global $preview, $gd_session; |
|
| 1820 | + $srcharr = array("'", "/", "-", '"', '\\');
|
|
| 1821 | + $replarr = array("′", "⁄", "–", "“", '');
|
|
| 1822 | + |
|
| 1823 | + if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
|
|
| 1824 | + $ID = ''; |
|
| 1825 | + $plink = ''; |
|
| 1826 | + |
|
| 1827 | + if (isset($postinfo_obj->pid)) {
|
|
| 1828 | + $ID = $postinfo_obj->pid; |
|
| 1829 | + $plink = get_permalink($ID); |
|
| 1830 | + } |
|
| 1831 | + |
|
| 1832 | + $title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title)); |
|
| 1833 | + $lat = $postinfo_obj->post_latitude; |
|
| 1834 | + $lng = $postinfo_obj->post_longitude; |
|
| 1835 | + $address = str_replace($srcharr, $replarr, ($postinfo_obj->post_address)); |
|
| 1836 | + $contact = str_replace($srcharr, $replarr, ($postinfo_obj->geodir_contact)); |
|
| 1837 | + $timing = str_replace($srcharr, $replarr, ($postinfo_obj->geodir_timing)); |
|
| 1838 | + } else {
|
|
| 1839 | + $ID = $postinfo_obj->post_id; |
|
| 1840 | + $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan |
|
| 1841 | + $plink = get_permalink($ID); |
|
| 1842 | + $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true)); |
|
| 1843 | + $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true)); |
|
| 1844 | + $address = str_replace($srcharr, $replarr, htmlentities(geodir_get_post_meta($ID, 'post_address', true), ENT_COMPAT, 'UTF-8')); // fix by Stiofan |
|
| 1845 | + $contact = str_replace($srcharr, $replarr, htmlentities(geodir_get_post_meta($ID, 'geodir_contact', true), ENT_COMPAT, 'UTF-8')); |
|
| 1846 | + $timing = str_replace($srcharr, $replarr, (geodir_get_post_meta($ID, 'geodir_timing', true))); |
|
| 1847 | + } |
|
| 1848 | + |
|
| 1849 | + // filter field as per price package |
|
| 1850 | + global $geodir_addon_list; |
|
| 1851 | + if (isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes') {
|
|
| 1852 | + $post_type = get_post_type($ID); |
|
| 1853 | + $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL; |
|
| 1854 | + $field_name = 'geodir_contact'; |
|
| 1855 | + if (!check_field_visibility($package_id, $field_name, $post_type)) {
|
|
| 1856 | + $contact = ''; |
|
| 1857 | + } |
|
| 1858 | + |
|
| 1859 | + $field_name = 'geodir_timing'; |
|
| 1860 | + if (!check_field_visibility($package_id, $field_name, $post_type)) {
|
|
| 1861 | + $timing = ''; |
|
| 1862 | + } |
|
| 1863 | + } |
|
| 1864 | + |
|
| 1865 | + if ($lat && $lng) {
|
|
| 1866 | + ob_start(); ?> |
|
| 1867 | 1867 | <div class="gd-bubble" style=""> |
| 1868 | 1868 | <div class="gd-bubble-inside"> |
| 1869 | 1869 | <?php |
| 1870 | - $comment_count = ''; |
|
| 1871 | - $rating_star = ''; |
|
| 1872 | - if ($ID != '') {
|
|
| 1873 | - $rating_star = ''; |
|
| 1874 | - $comment_count = geodir_get_review_count_total($ID); |
|
| 1875 | - |
|
| 1876 | - if (!$preview) {
|
|
| 1877 | - $post_avgratings = geodir_get_post_rating($ID); |
|
| 1878 | - |
|
| 1879 | - $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false); |
|
| 1880 | - |
|
| 1881 | - /** |
|
| 1882 | - * Filter to change rating stars |
|
| 1883 | - * |
|
| 1884 | - * You can use this filter to change Rating stars. |
|
| 1885 | - * |
|
| 1886 | - * @since 1.0.0 |
|
| 1887 | - * @package GeoDirectory |
|
| 1888 | - * @param string $rating_star Rating stars. |
|
| 1889 | - * @param float $post_avgratings Average ratings of the post. |
|
| 1890 | - * @param int $ID The post ID. |
|
| 1891 | - */ |
|
| 1892 | - $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
|
|
| 1893 | - } |
|
| 1894 | - } |
|
| 1895 | - ?> |
|
| 1870 | + $comment_count = ''; |
|
| 1871 | + $rating_star = ''; |
|
| 1872 | + if ($ID != '') {
|
|
| 1873 | + $rating_star = ''; |
|
| 1874 | + $comment_count = geodir_get_review_count_total($ID); |
|
| 1875 | + |
|
| 1876 | + if (!$preview) {
|
|
| 1877 | + $post_avgratings = geodir_get_post_rating($ID); |
|
| 1878 | + |
|
| 1879 | + $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false); |
|
| 1880 | + |
|
| 1881 | + /** |
|
| 1882 | + * Filter to change rating stars |
|
| 1883 | + * |
|
| 1884 | + * You can use this filter to change Rating stars. |
|
| 1885 | + * |
|
| 1886 | + * @since 1.0.0 |
|
| 1887 | + * @package GeoDirectory |
|
| 1888 | + * @param string $rating_star Rating stars. |
|
| 1889 | + * @param float $post_avgratings Average ratings of the post. |
|
| 1890 | + * @param int $ID The post ID. |
|
| 1891 | + */ |
|
| 1892 | + $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
|
|
| 1893 | + } |
|
| 1894 | + } |
|
| 1895 | + ?> |
|
| 1896 | 1896 | <div class="geodir-bubble_desc"> |
| 1897 | 1897 | <h4> |
| 1898 | 1898 | <a href="<?php if ($plink != '') {
|
| 1899 | - echo $plink; |
|
| 1900 | - } else {
|
|
| 1901 | - echo 'javascript:void(0);'; |
|
| 1902 | - } ?>"><?php echo $title; ?></a> |
|
| 1899 | + echo $plink; |
|
| 1900 | + } else {
|
|
| 1901 | + echo 'javascript:void(0);'; |
|
| 1902 | + } ?>"><?php echo $title; ?></a> |
|
| 1903 | 1903 | </h4> |
| 1904 | 1904 | <?php |
| 1905 | - if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
|
|
| 1906 | - $post_images = array(); |
|
| 1907 | - if (!empty($postinfo_obj->post_images)) {
|
|
| 1908 | - $post_images = explode(",", $postinfo_obj->post_images);
|
|
| 1909 | - } |
|
| 1910 | - |
|
| 1911 | - if (!empty($post_images)) {
|
|
| 1912 | - ?> |
|
| 1905 | + if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
|
|
| 1906 | + $post_images = array(); |
|
| 1907 | + if (!empty($postinfo_obj->post_images)) {
|
|
| 1908 | + $post_images = explode(",", $postinfo_obj->post_images);
|
|
| 1909 | + } |
|
| 1910 | + |
|
| 1911 | + if (!empty($post_images)) {
|
|
| 1912 | + ?> |
|
| 1913 | 1913 | <div class="geodir-bubble_image"><a href="<?php if ($plink != '') {
|
| 1914 | - echo $plink; |
|
| 1915 | - } else {
|
|
| 1916 | - echo 'javascript:void(0);'; |
|
| 1917 | - } ?>"><img alt="bubble image" style="max-height:50px;" |
|
| 1914 | + echo $plink; |
|
| 1915 | + } else {
|
|
| 1916 | + echo 'javascript:void(0);'; |
|
| 1917 | + } ?>"><img alt="bubble image" style="max-height:50px;" |
|
| 1918 | 1918 | src="<?php echo $post_images[0]; ?>"/></a></div> |
| 1919 | 1919 | <?php |
| 1920 | - }else{
|
|
| 1921 | - echo '<div class="geodir-bubble_image"></div>'; |
|
| 1922 | - } |
|
| 1923 | - } else {
|
|
| 1924 | - if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
|
|
| 1925 | - ?> |
|
| 1920 | + }else{
|
|
| 1921 | + echo '<div class="geodir-bubble_image"></div>'; |
|
| 1922 | + } |
|
| 1923 | + } else {
|
|
| 1924 | + if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
|
|
| 1925 | + ?> |
|
| 1926 | 1926 | <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div> |
| 1927 | 1927 | <?php |
| 1928 | - }else{
|
|
| 1929 | - echo '<div class="geodir-bubble_image"></div>'; |
|
| 1930 | - } |
|
| 1931 | - } |
|
| 1932 | - ?> |
|
| 1928 | + }else{
|
|
| 1929 | + echo '<div class="geodir-bubble_image"></div>'; |
|
| 1930 | + } |
|
| 1931 | + } |
|
| 1932 | + ?> |
|
| 1933 | 1933 | <div class="geodir-bubble-meta-side"> |
| 1934 | 1934 | <?php |
| 1935 | - /** |
|
| 1936 | - * Fires before the meta info in the map info window. |
|
| 1937 | - * |
|
| 1938 | - * This can be used to add more info to the map info window before the normal meta info. |
|
| 1939 | - * |
|
| 1940 | - * @since 1.5.4 |
|
| 1941 | - * @param int $ID The post id. |
|
| 1942 | - * @param object $postinfo_obj The posts info as an object. |
|
| 1943 | - * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
| 1944 | - */ |
|
| 1945 | - do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
|
|
| 1946 | - ?> |
|
| 1935 | + /** |
|
| 1936 | + * Fires before the meta info in the map info window. |
|
| 1937 | + * |
|
| 1938 | + * This can be used to add more info to the map info window before the normal meta info. |
|
| 1939 | + * |
|
| 1940 | + * @since 1.5.4 |
|
| 1941 | + * @param int $ID The post id. |
|
| 1942 | + * @param object $postinfo_obj The posts info as an object. |
|
| 1943 | + * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
| 1944 | + */ |
|
| 1945 | + do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
|
|
| 1946 | + ?> |
|
| 1947 | 1947 | <span class="geodir_address"><i class="fa fa-home"></i> <?php echo $address; ?></span> |
| 1948 | 1948 | <?php if ($contact) { ?><span class="geodir_contact"><i
|
| 1949 | 1949 | class="fa fa-phone"></i> |
| 1950 | 1950 | <?php |
| 1951 | - $tel_link = apply_filters('geodir_map_bubble_tel_linkable', false);
|
|
| 1952 | - if ($tel_link) {
|
|
| 1953 | - ?> |
|
| 1951 | + $tel_link = apply_filters('geodir_map_bubble_tel_linkable', false);
|
|
| 1952 | + if ($tel_link) {
|
|
| 1953 | + ?> |
|
| 1954 | 1954 | <a href="tel:<?php echo preg_replace('/[^0-9+]/', '', $contact); ?>"><?php echo stripslashes($contact); ?></a>
|
| 1955 | 1955 | <?php |
| 1956 | - } else {
|
|
| 1957 | - echo $contact; |
|
| 1958 | - } |
|
| 1959 | - ?> |
|
| 1956 | + } else {
|
|
| 1957 | + echo $contact; |
|
| 1958 | + } |
|
| 1959 | + ?> |
|
| 1960 | 1960 | </span><?php } ?> |
| 1961 | 1961 | <?php if ($timing) { ?><span class="geodir_timing"><i
|
| 1962 | 1962 | class="fa fa-clock-o"></i> <?php echo $timing; ?></span><?php } |
| 1963 | 1963 | |
| 1964 | - /** |
|
| 1965 | - * Fires after the meta info in the map info window. |
|
| 1966 | - * |
|
| 1967 | - * This can be used to add more info to the map info window after the normal meta info. |
|
| 1968 | - * |
|
| 1969 | - * @since 1.4.2 |
|
| 1970 | - * @param object $postinfo_obj The posts info as an object. |
|
| 1971 | - * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
| 1972 | - */ |
|
| 1973 | - do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
|
|
| 1974 | - ?> |
|
| 1964 | + /** |
|
| 1965 | + * Fires after the meta info in the map info window. |
|
| 1966 | + * |
|
| 1967 | + * This can be used to add more info to the map info window after the normal meta info. |
|
| 1968 | + * |
|
| 1969 | + * @since 1.4.2 |
|
| 1970 | + * @param object $postinfo_obj The posts info as an object. |
|
| 1971 | + * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
| 1972 | + */ |
|
| 1973 | + do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
|
|
| 1974 | + ?> |
|
| 1975 | 1975 | </div> |
| 1976 | 1976 | <?php |
| 1977 | 1977 | |
| 1978 | - if ($ID) {
|
|
| 1978 | + if ($ID) {
|
|
| 1979 | 1979 | |
| 1980 | - $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
|
|
| 1981 | - ?> |
|
| 1980 | + $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
|
|
| 1981 | + ?> |
|
| 1982 | 1982 | <div class="geodir-bubble-meta-fade"></div> |
| 1983 | 1983 | |
| 1984 | 1984 | <div class="geodir-bubble-meta-bottom"> |
@@ -1998,69 +1998,69 @@ discard block |
||
| 1998 | 1998 | </div> |
| 1999 | 1999 | </div> |
| 2000 | 2000 | <?php |
| 2001 | - $html = ob_get_clean(); |
|
| 2002 | - /** |
|
| 2003 | - * Filter to change infowindow html |
|
| 2004 | - * |
|
| 2005 | - * You can use this filter to change infowindow html. |
|
| 2006 | - * |
|
| 2007 | - * @since 1.0.0 |
|
| 2008 | - * @package GeoDirectory |
|
| 2009 | - * @param string $html Infowindow html. |
|
| 2010 | - * @param object $postinfo_obj The Post object. |
|
| 2011 | - * @param bool|string $post_preview Is this a post preview? |
|
| 2012 | - */ |
|
| 2013 | - $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
|
|
| 2014 | - return $html; |
|
| 2015 | - } |
|
| 2016 | - } |
|
| 2001 | + $html = ob_get_clean(); |
|
| 2002 | + /** |
|
| 2003 | + * Filter to change infowindow html |
|
| 2004 | + * |
|
| 2005 | + * You can use this filter to change infowindow html. |
|
| 2006 | + * |
|
| 2007 | + * @since 1.0.0 |
|
| 2008 | + * @package GeoDirectory |
|
| 2009 | + * @param string $html Infowindow html. |
|
| 2010 | + * @param object $postinfo_obj The Post object. |
|
| 2011 | + * @param bool|string $post_preview Is this a post preview? |
|
| 2012 | + */ |
|
| 2013 | + $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
|
|
| 2014 | + return $html; |
|
| 2015 | + } |
|
| 2016 | + } |
|
| 2017 | 2017 | } |
| 2018 | 2018 | |
| 2019 | 2019 | |
| 2020 | 2020 | if (!function_exists('geodir_new_post_default_status')) {
|
| 2021 | - /** |
|
| 2022 | - * Default post status for new posts. |
|
| 2023 | - * |
|
| 2024 | - * @since 1.0.0 |
|
| 2025 | - * @package GeoDirectory |
|
| 2026 | - * @return string Returns the default post status for new posts. Ex: draft, publish etc. |
|
| 2027 | - */ |
|
| 2028 | - function geodir_new_post_default_status() |
|
| 2029 | - {
|
|
| 2030 | - if (get_option('geodir_new_post_default_status'))
|
|
| 2031 | - return get_option('geodir_new_post_default_status');
|
|
| 2032 | - else |
|
| 2033 | - return 'publish'; |
|
| 2034 | - |
|
| 2035 | - } |
|
| 2021 | + /** |
|
| 2022 | + * Default post status for new posts. |
|
| 2023 | + * |
|
| 2024 | + * @since 1.0.0 |
|
| 2025 | + * @package GeoDirectory |
|
| 2026 | + * @return string Returns the default post status for new posts. Ex: draft, publish etc. |
|
| 2027 | + */ |
|
| 2028 | + function geodir_new_post_default_status() |
|
| 2029 | + {
|
|
| 2030 | + if (get_option('geodir_new_post_default_status'))
|
|
| 2031 | + return get_option('geodir_new_post_default_status');
|
|
| 2032 | + else |
|
| 2033 | + return 'publish'; |
|
| 2034 | + |
|
| 2035 | + } |
|
| 2036 | 2036 | } |
| 2037 | 2037 | |
| 2038 | 2038 | if (!function_exists('geodir_change_post_status')) {
|
| 2039 | - /** |
|
| 2040 | - * Change post status of a post. |
|
| 2041 | - * |
|
| 2042 | - * @global object $wpdb WordPress Database object. |
|
| 2043 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2044 | - * @param int|string $post_id The post ID. |
|
| 2045 | - * @param string $status New post status. Ex: draft, publish etc. |
|
| 2046 | - */ |
|
| 2047 | - function geodir_change_post_status($post_id = '', $status = '') |
|
| 2048 | - {
|
|
| 2049 | - global $wpdb, $plugin_prefix; |
|
| 2050 | - |
|
| 2051 | - $post_type = get_post_type($post_id); |
|
| 2052 | - |
|
| 2053 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2054 | - |
|
| 2055 | - $wpdb->query( |
|
| 2056 | - $wpdb->prepare( |
|
| 2057 | - "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d", |
|
| 2058 | - array($status, $post_id) |
|
| 2059 | - ) |
|
| 2060 | - ); |
|
| 2061 | - |
|
| 2062 | - |
|
| 2063 | - } |
|
| 2039 | + /** |
|
| 2040 | + * Change post status of a post. |
|
| 2041 | + * |
|
| 2042 | + * @global object $wpdb WordPress Database object. |
|
| 2043 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2044 | + * @param int|string $post_id The post ID. |
|
| 2045 | + * @param string $status New post status. Ex: draft, publish etc. |
|
| 2046 | + */ |
|
| 2047 | + function geodir_change_post_status($post_id = '', $status = '') |
|
| 2048 | + {
|
|
| 2049 | + global $wpdb, $plugin_prefix; |
|
| 2050 | + |
|
| 2051 | + $post_type = get_post_type($post_id); |
|
| 2052 | + |
|
| 2053 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2054 | + |
|
| 2055 | + $wpdb->query( |
|
| 2056 | + $wpdb->prepare( |
|
| 2057 | + "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d", |
|
| 2058 | + array($status, $post_id) |
|
| 2059 | + ) |
|
| 2060 | + ); |
|
| 2061 | + |
|
| 2062 | + |
|
| 2063 | + } |
|
| 2064 | 2064 | } |
| 2065 | 2065 | |
| 2066 | 2066 | /** |
@@ -2074,13 +2074,13 @@ discard block |
||
| 2074 | 2074 | */ |
| 2075 | 2075 | function geodir_set_post_status($pid, $status) |
| 2076 | 2076 | {
|
| 2077 | - if ($pid) {
|
|
| 2078 | - global $wpdb; |
|
| 2079 | - $my_post = array(); |
|
| 2080 | - $my_post['post_status'] = $status; |
|
| 2081 | - $my_post['ID'] = $pid; |
|
| 2082 | - $last_postid = wp_update_post($my_post); |
|
| 2083 | - } |
|
| 2077 | + if ($pid) {
|
|
| 2078 | + global $wpdb; |
|
| 2079 | + $my_post = array(); |
|
| 2080 | + $my_post['post_status'] = $status; |
|
| 2081 | + $my_post['ID'] = $pid; |
|
| 2082 | + $last_postid = wp_update_post($my_post); |
|
| 2083 | + } |
|
| 2084 | 2084 | } |
| 2085 | 2085 | |
| 2086 | 2086 | |
@@ -2096,384 +2096,384 @@ discard block |
||
| 2096 | 2096 | */ |
| 2097 | 2097 | function geodir_update_poststatus($new_status, $old_status, $post) |
| 2098 | 2098 | {
|
| 2099 | - global $wpdb; |
|
| 2099 | + global $wpdb; |
|
| 2100 | 2100 | |
| 2101 | - $geodir_posttypes = geodir_get_posttypes(); |
|
| 2101 | + $geodir_posttypes = geodir_get_posttypes(); |
|
| 2102 | 2102 | |
| 2103 | - if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 2103 | + if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 2104 | 2104 | |
| 2105 | - geodir_change_post_status($post->ID, $new_status); |
|
| 2106 | - } |
|
| 2105 | + geodir_change_post_status($post->ID, $new_status); |
|
| 2106 | + } |
|
| 2107 | 2107 | } |
| 2108 | 2108 | |
| 2109 | 2109 | |
| 2110 | 2110 | if (!function_exists('geodir_update_listing_info')) {
|
| 2111 | - /** |
|
| 2112 | - * Update post info. |
|
| 2113 | - * |
|
| 2114 | - * @since 1.0.0 |
|
| 2115 | - * @package GeoDirectory |
|
| 2116 | - * @global object $wpdb WordPress Database object. |
|
| 2117 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2118 | - * @param int $updatingpost The updating post ID. |
|
| 2119 | - * @param int $temppost The temporary post ID. |
|
| 2120 | - * @todo fix post_id variable |
|
| 2121 | - */ |
|
| 2122 | - function geodir_update_listing_info($updatingpost, $temppost) |
|
| 2123 | - {
|
|
| 2124 | - |
|
| 2125 | - global $wpdb, $plugin_prefix; |
|
| 2126 | - |
|
| 2127 | - $post_type = get_post_type($post_id); |
|
| 2128 | - |
|
| 2129 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2130 | - |
|
| 2131 | - $wpdb->query( |
|
| 2132 | - $wpdb->prepare( |
|
| 2133 | - "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2134 | - array($updatingpost, $temppost) |
|
| 2135 | - ) |
|
| 2136 | - ); |
|
| 2137 | - |
|
| 2138 | - $wpdb->query( |
|
| 2139 | - $wpdb->prepare( |
|
| 2140 | - "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2141 | - array($updatingpost, $temppost) |
|
| 2142 | - ) |
|
| 2143 | - ); |
|
| 2144 | - |
|
| 2145 | - /* Update Attachments*/ |
|
| 2146 | - |
|
| 2147 | - $wpdb->query( |
|
| 2148 | - $wpdb->prepare( |
|
| 2149 | - "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2150 | - array($updatingpost, $temppost) |
|
| 2151 | - ) |
|
| 2152 | - ); |
|
| 2153 | - |
|
| 2154 | - } |
|
| 2111 | + /** |
|
| 2112 | + * Update post info. |
|
| 2113 | + * |
|
| 2114 | + * @since 1.0.0 |
|
| 2115 | + * @package GeoDirectory |
|
| 2116 | + * @global object $wpdb WordPress Database object. |
|
| 2117 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2118 | + * @param int $updatingpost The updating post ID. |
|
| 2119 | + * @param int $temppost The temporary post ID. |
|
| 2120 | + * @todo fix post_id variable |
|
| 2121 | + */ |
|
| 2122 | + function geodir_update_listing_info($updatingpost, $temppost) |
|
| 2123 | + {
|
|
| 2124 | + |
|
| 2125 | + global $wpdb, $plugin_prefix; |
|
| 2126 | + |
|
| 2127 | + $post_type = get_post_type($post_id); |
|
| 2128 | + |
|
| 2129 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2130 | + |
|
| 2131 | + $wpdb->query( |
|
| 2132 | + $wpdb->prepare( |
|
| 2133 | + "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2134 | + array($updatingpost, $temppost) |
|
| 2135 | + ) |
|
| 2136 | + ); |
|
| 2137 | + |
|
| 2138 | + $wpdb->query( |
|
| 2139 | + $wpdb->prepare( |
|
| 2140 | + "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2141 | + array($updatingpost, $temppost) |
|
| 2142 | + ) |
|
| 2143 | + ); |
|
| 2144 | + |
|
| 2145 | + /* Update Attachments*/ |
|
| 2146 | + |
|
| 2147 | + $wpdb->query( |
|
| 2148 | + $wpdb->prepare( |
|
| 2149 | + "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2150 | + array($updatingpost, $temppost) |
|
| 2151 | + ) |
|
| 2152 | + ); |
|
| 2153 | + |
|
| 2154 | + } |
|
| 2155 | 2155 | } |
| 2156 | 2156 | |
| 2157 | 2157 | |
| 2158 | 2158 | if (!function_exists('geodir_delete_listing_info')) {
|
| 2159 | - /** |
|
| 2160 | - * Delete Listing info from details table for the given post id. |
|
| 2161 | - * |
|
| 2162 | - * @since 1.0.0 |
|
| 2163 | - * @package GeoDirectory |
|
| 2164 | - * @global object $wpdb WordPress Database object. |
|
| 2165 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2166 | - * @param int $deleted_postid The post ID. |
|
| 2167 | - * @param bool $force Optional. Do you want to force delete it? Default: false. |
|
| 2168 | - * @return bool|void |
|
| 2169 | - */ |
|
| 2170 | - function geodir_delete_listing_info($deleted_postid, $force = false) |
|
| 2171 | - {
|
|
| 2172 | - global $wpdb, $plugin_prefix; |
|
| 2173 | - |
|
| 2174 | - // check for multisite deletions |
|
| 2175 | - if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
|
|
| 2176 | - } else {
|
|
| 2177 | - return; |
|
| 2178 | - } |
|
| 2179 | - |
|
| 2180 | - $post_type = get_post_type($deleted_postid); |
|
| 2181 | - |
|
| 2182 | - $all_postypes = geodir_get_posttypes(); |
|
| 2183 | - |
|
| 2184 | - if (!in_array($post_type, $all_postypes)) |
|
| 2185 | - return false; |
|
| 2186 | - |
|
| 2187 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2188 | - |
|
| 2189 | - /* Delete custom post meta*/ |
|
| 2190 | - $wpdb->query( |
|
| 2191 | - $wpdb->prepare( |
|
| 2192 | - "DELETE FROM " . $table . " WHERE `post_id` = %d", |
|
| 2193 | - array($deleted_postid) |
|
| 2194 | - ) |
|
| 2195 | - ); |
|
| 2196 | - |
|
| 2197 | - /* Delete post map icons*/ |
|
| 2198 | - |
|
| 2199 | - $wpdb->query( |
|
| 2200 | - $wpdb->prepare( |
|
| 2201 | - "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d", |
|
| 2202 | - array($deleted_postid) |
|
| 2203 | - ) |
|
| 2204 | - ); |
|
| 2205 | - |
|
| 2206 | - /* Delete Attachments*/ |
|
| 2207 | - $postcurr_images = geodir_get_images($deleted_postid); |
|
| 2208 | - |
|
| 2209 | - $wpdb->query( |
|
| 2210 | - $wpdb->prepare( |
|
| 2211 | - "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d", |
|
| 2212 | - array($deleted_postid) |
|
| 2213 | - ) |
|
| 2214 | - ); |
|
| 2215 | - geodir_remove_attachments($postcurr_images); |
|
| 2216 | - |
|
| 2217 | - } |
|
| 2159 | + /** |
|
| 2160 | + * Delete Listing info from details table for the given post id. |
|
| 2161 | + * |
|
| 2162 | + * @since 1.0.0 |
|
| 2163 | + * @package GeoDirectory |
|
| 2164 | + * @global object $wpdb WordPress Database object. |
|
| 2165 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2166 | + * @param int $deleted_postid The post ID. |
|
| 2167 | + * @param bool $force Optional. Do you want to force delete it? Default: false. |
|
| 2168 | + * @return bool|void |
|
| 2169 | + */ |
|
| 2170 | + function geodir_delete_listing_info($deleted_postid, $force = false) |
|
| 2171 | + {
|
|
| 2172 | + global $wpdb, $plugin_prefix; |
|
| 2173 | + |
|
| 2174 | + // check for multisite deletions |
|
| 2175 | + if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
|
|
| 2176 | + } else {
|
|
| 2177 | + return; |
|
| 2178 | + } |
|
| 2179 | + |
|
| 2180 | + $post_type = get_post_type($deleted_postid); |
|
| 2181 | + |
|
| 2182 | + $all_postypes = geodir_get_posttypes(); |
|
| 2183 | + |
|
| 2184 | + if (!in_array($post_type, $all_postypes)) |
|
| 2185 | + return false; |
|
| 2186 | + |
|
| 2187 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2188 | + |
|
| 2189 | + /* Delete custom post meta*/ |
|
| 2190 | + $wpdb->query( |
|
| 2191 | + $wpdb->prepare( |
|
| 2192 | + "DELETE FROM " . $table . " WHERE `post_id` = %d", |
|
| 2193 | + array($deleted_postid) |
|
| 2194 | + ) |
|
| 2195 | + ); |
|
| 2196 | + |
|
| 2197 | + /* Delete post map icons*/ |
|
| 2198 | + |
|
| 2199 | + $wpdb->query( |
|
| 2200 | + $wpdb->prepare( |
|
| 2201 | + "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d", |
|
| 2202 | + array($deleted_postid) |
|
| 2203 | + ) |
|
| 2204 | + ); |
|
| 2205 | + |
|
| 2206 | + /* Delete Attachments*/ |
|
| 2207 | + $postcurr_images = geodir_get_images($deleted_postid); |
|
| 2208 | + |
|
| 2209 | + $wpdb->query( |
|
| 2210 | + $wpdb->prepare( |
|
| 2211 | + "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d", |
|
| 2212 | + array($deleted_postid) |
|
| 2213 | + ) |
|
| 2214 | + ); |
|
| 2215 | + geodir_remove_attachments($postcurr_images); |
|
| 2216 | + |
|
| 2217 | + } |
|
| 2218 | 2218 | } |
| 2219 | 2219 | |
| 2220 | 2220 | |
| 2221 | 2221 | if (!function_exists('geodir_add_to_favorite')) {
|
| 2222 | - /** |
|
| 2223 | - * This function would add listing to favorite listing. |
|
| 2224 | - * |
|
| 2225 | - * @since 1.0.0 |
|
| 2226 | - * @package GeoDirectory |
|
| 2227 | - * @global object $current_user Current user object. |
|
| 2228 | - * @param int $post_id The post ID. |
|
| 2229 | - */ |
|
| 2230 | - function geodir_add_to_favorite($post_id) |
|
| 2231 | - {
|
|
| 2232 | - |
|
| 2233 | - global $current_user; |
|
| 2234 | - |
|
| 2235 | - /** |
|
| 2236 | - * Filter to modify "Unfavorite" text |
|
| 2237 | - * |
|
| 2238 | - * You can use this filter to rename "Unfavorite" text to something else. |
|
| 2239 | - * |
|
| 2240 | - * @since 1.0.0 |
|
| 2241 | - * @package GeoDirectory |
|
| 2242 | - */ |
|
| 2243 | - $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
|
|
| 2244 | - |
|
| 2245 | - /** |
|
| 2246 | - * Filter to modify "Remove from Favorites" text |
|
| 2247 | - * |
|
| 2248 | - * You can use this filter to rename "Remove from Favorites" text to something else. |
|
| 2249 | - * |
|
| 2250 | - * @since 1.0.0 |
|
| 2251 | - * @package GeoDirectory |
|
| 2252 | - */ |
|
| 2253 | - $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
|
|
| 2254 | - |
|
| 2255 | - /** |
|
| 2256 | - * Filter to modify "fa fa-heart" icon |
|
| 2257 | - * |
|
| 2258 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2259 | - * |
|
| 2260 | - * @since 1.0.0 |
|
| 2261 | - * @package GeoDirectory |
|
| 2262 | - */ |
|
| 2263 | - $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2222 | + /** |
|
| 2223 | + * This function would add listing to favorite listing. |
|
| 2224 | + * |
|
| 2225 | + * @since 1.0.0 |
|
| 2226 | + * @package GeoDirectory |
|
| 2227 | + * @global object $current_user Current user object. |
|
| 2228 | + * @param int $post_id The post ID. |
|
| 2229 | + */ |
|
| 2230 | + function geodir_add_to_favorite($post_id) |
|
| 2231 | + {
|
|
| 2232 | + |
|
| 2233 | + global $current_user; |
|
| 2234 | + |
|
| 2235 | + /** |
|
| 2236 | + * Filter to modify "Unfavorite" text |
|
| 2237 | + * |
|
| 2238 | + * You can use this filter to rename "Unfavorite" text to something else. |
|
| 2239 | + * |
|
| 2240 | + * @since 1.0.0 |
|
| 2241 | + * @package GeoDirectory |
|
| 2242 | + */ |
|
| 2243 | + $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
|
|
| 2244 | + |
|
| 2245 | + /** |
|
| 2246 | + * Filter to modify "Remove from Favorites" text |
|
| 2247 | + * |
|
| 2248 | + * You can use this filter to rename "Remove from Favorites" text to something else. |
|
| 2249 | + * |
|
| 2250 | + * @since 1.0.0 |
|
| 2251 | + * @package GeoDirectory |
|
| 2252 | + */ |
|
| 2253 | + $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
|
|
| 2254 | + |
|
| 2255 | + /** |
|
| 2256 | + * Filter to modify "fa fa-heart" icon |
|
| 2257 | + * |
|
| 2258 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2259 | + * |
|
| 2260 | + * @since 1.0.0 |
|
| 2261 | + * @package GeoDirectory |
|
| 2262 | + */ |
|
| 2263 | + $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2264 | + |
|
| 2265 | + $user_meta_data = array(); |
|
| 2266 | + $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
| 2267 | + |
|
| 2268 | + if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
|
|
| 2269 | + $user_meta_data[] = $post_id; |
|
| 2270 | + } |
|
| 2271 | + |
|
| 2272 | + update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data); |
|
| 2273 | + |
|
| 2274 | + /** |
|
| 2275 | + * Called before adding the post from favourites. |
|
| 2276 | + * |
|
| 2277 | + * @since 1.0.0 |
|
| 2278 | + * @package GeoDirectory |
|
| 2279 | + * @param int $post_id The post ID. |
|
| 2280 | + */ |
|
| 2281 | + do_action('geodir_before_add_from_favorite', $post_id);
|
|
| 2282 | + |
|
| 2283 | + echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-addtofav geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>'; |
|
| 2284 | + |
|
| 2285 | + /** |
|
| 2286 | + * Called after adding the post from favourites. |
|
| 2287 | + * |
|
| 2288 | + * @since 1.0.0 |
|
| 2289 | + * @package GeoDirectory |
|
| 2290 | + * @param int $post_id The post ID. |
|
| 2291 | + */ |
|
| 2292 | + do_action('geodir_after_add_from_favorite', $post_id);
|
|
| 2264 | 2293 | |
| 2265 | - $user_meta_data = array(); |
|
| 2266 | - $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
| 2267 | - |
|
| 2268 | - if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
|
|
| 2269 | - $user_meta_data[] = $post_id; |
|
| 2270 | - } |
|
| 2271 | - |
|
| 2272 | - update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data); |
|
| 2273 | - |
|
| 2274 | - /** |
|
| 2275 | - * Called before adding the post from favourites. |
|
| 2276 | - * |
|
| 2277 | - * @since 1.0.0 |
|
| 2278 | - * @package GeoDirectory |
|
| 2279 | - * @param int $post_id The post ID. |
|
| 2280 | - */ |
|
| 2281 | - do_action('geodir_before_add_from_favorite', $post_id);
|
|
| 2282 | - |
|
| 2283 | - echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-addtofav geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>'; |
|
| 2284 | - |
|
| 2285 | - /** |
|
| 2286 | - * Called after adding the post from favourites. |
|
| 2287 | - * |
|
| 2288 | - * @since 1.0.0 |
|
| 2289 | - * @package GeoDirectory |
|
| 2290 | - * @param int $post_id The post ID. |
|
| 2291 | - */ |
|
| 2292 | - do_action('geodir_after_add_from_favorite', $post_id);
|
|
| 2293 | - |
|
| 2294 | - } |
|
| 2294 | + } |
|
| 2295 | 2295 | } |
| 2296 | 2296 | |
| 2297 | 2297 | if (!function_exists('geodir_remove_from_favorite')) {
|
| 2298 | - /** |
|
| 2299 | - * This function would remove the favourited property earlier. |
|
| 2300 | - * |
|
| 2301 | - * @since 1.0.0 |
|
| 2302 | - * @package GeoDirectory |
|
| 2303 | - * @global object $current_user Current user object. |
|
| 2304 | - * @param int $post_id The post ID. |
|
| 2305 | - */ |
|
| 2306 | - function geodir_remove_from_favorite($post_id) |
|
| 2307 | - {
|
|
| 2308 | - global $current_user; |
|
| 2309 | - |
|
| 2310 | - /** |
|
| 2311 | - * Filter to modify "Add to Favorites" text |
|
| 2312 | - * |
|
| 2313 | - * You can use this filter to rename "Add to Favorites" text to something else. |
|
| 2314 | - * |
|
| 2315 | - * @since 1.0.0 |
|
| 2316 | - * @package GeoDirectory |
|
| 2317 | - */ |
|
| 2318 | - $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
|
|
| 2319 | - |
|
| 2320 | - /** |
|
| 2321 | - * Filter to modify "Favourite" text |
|
| 2322 | - * |
|
| 2323 | - * You can use this filter to rename "Favourite" text to something else. |
|
| 2324 | - * |
|
| 2325 | - * @since 1.0.0 |
|
| 2326 | - * @package GeoDirectory |
|
| 2327 | - */ |
|
| 2328 | - $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
|
|
| 2329 | - |
|
| 2330 | - /** |
|
| 2331 | - * Filter to modify "fa fa-heart" icon |
|
| 2332 | - * |
|
| 2333 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2334 | - * |
|
| 2335 | - * @since 1.0.0 |
|
| 2336 | - * @package GeoDirectory |
|
| 2337 | - */ |
|
| 2338 | - $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2339 | - |
|
| 2340 | - $user_meta_data = array(); |
|
| 2341 | - $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
| 2342 | - |
|
| 2343 | - if (!empty($user_meta_data)) {
|
|
| 2298 | + /** |
|
| 2299 | + * This function would remove the favourited property earlier. |
|
| 2300 | + * |
|
| 2301 | + * @since 1.0.0 |
|
| 2302 | + * @package GeoDirectory |
|
| 2303 | + * @global object $current_user Current user object. |
|
| 2304 | + * @param int $post_id The post ID. |
|
| 2305 | + */ |
|
| 2306 | + function geodir_remove_from_favorite($post_id) |
|
| 2307 | + {
|
|
| 2308 | + global $current_user; |
|
| 2309 | + |
|
| 2310 | + /** |
|
| 2311 | + * Filter to modify "Add to Favorites" text |
|
| 2312 | + * |
|
| 2313 | + * You can use this filter to rename "Add to Favorites" text to something else. |
|
| 2314 | + * |
|
| 2315 | + * @since 1.0.0 |
|
| 2316 | + * @package GeoDirectory |
|
| 2317 | + */ |
|
| 2318 | + $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
|
|
| 2319 | + |
|
| 2320 | + /** |
|
| 2321 | + * Filter to modify "Favourite" text |
|
| 2322 | + * |
|
| 2323 | + * You can use this filter to rename "Favourite" text to something else. |
|
| 2324 | + * |
|
| 2325 | + * @since 1.0.0 |
|
| 2326 | + * @package GeoDirectory |
|
| 2327 | + */ |
|
| 2328 | + $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
|
|
| 2329 | + |
|
| 2330 | + /** |
|
| 2331 | + * Filter to modify "fa fa-heart" icon |
|
| 2332 | + * |
|
| 2333 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2334 | + * |
|
| 2335 | + * @since 1.0.0 |
|
| 2336 | + * @package GeoDirectory |
|
| 2337 | + */ |
|
| 2338 | + $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2339 | + |
|
| 2340 | + $user_meta_data = array(); |
|
| 2341 | + $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
| 2342 | + |
|
| 2343 | + if (!empty($user_meta_data)) {
|
|
| 2344 | + |
|
| 2345 | + if (($key = array_search($post_id, $user_meta_data)) !== false) {
|
|
| 2346 | + unset($user_meta_data[$key]); |
|
| 2347 | + } |
|
| 2344 | 2348 | |
| 2345 | - if (($key = array_search($post_id, $user_meta_data)) !== false) {
|
|
| 2346 | - unset($user_meta_data[$key]); |
|
| 2347 | - } |
|
| 2349 | + } |
|
| 2348 | 2350 | |
| 2349 | - } |
|
| 2351 | + update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data); |
|
| 2350 | 2352 | |
| 2351 | - update_user_meta($current_user->data->ID, 'gd_user_favourite_post', $user_meta_data); |
|
| 2353 | + /** |
|
| 2354 | + * Called before removing the post from favourites. |
|
| 2355 | + * |
|
| 2356 | + * @since 1.0.0 |
|
| 2357 | + * @package GeoDirectory |
|
| 2358 | + * @param int $post_id The post ID. |
|
| 2359 | + */ |
|
| 2360 | + do_action('geodir_before_remove_from_favorite', $post_id);
|
|
| 2352 | 2361 | |
| 2353 | - /** |
|
| 2354 | - * Called before removing the post from favourites. |
|
| 2355 | - * |
|
| 2356 | - * @since 1.0.0 |
|
| 2357 | - * @package GeoDirectory |
|
| 2358 | - * @param int $post_id The post ID. |
|
| 2359 | - */ |
|
| 2360 | - do_action('geodir_before_remove_from_favorite', $post_id);
|
|
| 2362 | + echo '<a href="javascript:void(0);" title="' . $add_favourite_text . '" class="geodir-addtofav geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>'; |
|
| 2361 | 2363 | |
| 2362 | - echo '<a href="javascript:void(0);" title="' . $add_favourite_text . '" class="geodir-addtofav geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>'; |
|
| 2364 | + /** |
|
| 2365 | + * Called after removing the post from favourites. |
|
| 2366 | + * |
|
| 2367 | + * @since 1.0.0 |
|
| 2368 | + * @package GeoDirectory |
|
| 2369 | + * @param int $post_id The post ID. |
|
| 2370 | + */ |
|
| 2371 | + do_action('geodir_after_remove_from_favorite', $post_id);
|
|
| 2363 | 2372 | |
| 2364 | - /** |
|
| 2365 | - * Called after removing the post from favourites. |
|
| 2366 | - * |
|
| 2367 | - * @since 1.0.0 |
|
| 2368 | - * @package GeoDirectory |
|
| 2369 | - * @param int $post_id The post ID. |
|
| 2370 | - */ |
|
| 2371 | - do_action('geodir_after_remove_from_favorite', $post_id);
|
|
| 2372 | - |
|
| 2373 | - } |
|
| 2373 | + } |
|
| 2374 | 2374 | } |
| 2375 | 2375 | |
| 2376 | 2376 | if (!function_exists('geodir_favourite_html')) {
|
| 2377 | - /** |
|
| 2378 | - * This function would display the html content for add to favorite or remove from favorite. |
|
| 2379 | - * |
|
| 2380 | - * @since 1.0.0 |
|
| 2381 | - * @package GeoDirectory |
|
| 2382 | - * @global object $current_user Current user object. |
|
| 2383 | - * @global object $post The current post object. |
|
| 2384 | - * @param int $user_id The user ID. |
|
| 2385 | - * @param int $post_id The post ID. |
|
| 2386 | - */ |
|
| 2387 | - function geodir_favourite_html($user_id, $post_id) |
|
| 2388 | - {
|
|
| 2389 | - |
|
| 2390 | - global $current_user, $post; |
|
| 2391 | - |
|
| 2392 | - /** |
|
| 2393 | - * Filter to modify "Add to Favorites" text |
|
| 2394 | - * |
|
| 2395 | - * You can use this filter to rename "Add to Favorites" text to something else. |
|
| 2396 | - * |
|
| 2397 | - * @since 1.0.0 |
|
| 2398 | - * @package GeoDirectory |
|
| 2399 | - */ |
|
| 2400 | - $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
|
|
| 2401 | - |
|
| 2402 | - /** |
|
| 2403 | - * Filter to modify "Favourite" text |
|
| 2404 | - * |
|
| 2405 | - * You can use this filter to rename "Favourite" text to something else. |
|
| 2406 | - * |
|
| 2407 | - * @since 1.0.0 |
|
| 2408 | - * @package GeoDirectory |
|
| 2409 | - */ |
|
| 2410 | - $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
|
|
| 2411 | - |
|
| 2412 | - /** |
|
| 2413 | - * Filter to modify "Unfavorite" text |
|
| 2414 | - * |
|
| 2415 | - * You can use this filter to rename "Unfavorite" text to something else. |
|
| 2416 | - * |
|
| 2417 | - * @since 1.0.0 |
|
| 2418 | - * @package GeoDirectory |
|
| 2419 | - */ |
|
| 2420 | - $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
|
|
| 2421 | - |
|
| 2422 | - /** |
|
| 2423 | - * Filter to modify "Remove from Favorites" text |
|
| 2424 | - * |
|
| 2425 | - * You can use this filter to rename "Remove from Favorites" text to something else. |
|
| 2426 | - * |
|
| 2427 | - * @since 1.0.0 |
|
| 2428 | - * @package GeoDirectory |
|
| 2429 | - */ |
|
| 2430 | - $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
|
|
| 2431 | - |
|
| 2432 | - /** |
|
| 2433 | - * Filter to modify "fa fa-heart" icon |
|
| 2434 | - * |
|
| 2435 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2436 | - * |
|
| 2437 | - * @since 1.0.0 |
|
| 2438 | - * @package GeoDirectory |
|
| 2439 | - */ |
|
| 2440 | - $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2441 | - |
|
| 2442 | - /** |
|
| 2443 | - * Filter to modify "fa fa-heart" icon for "remove from favorites" link |
|
| 2444 | - * |
|
| 2445 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2446 | - * |
|
| 2447 | - * @since 1.0.0 |
|
| 2448 | - * @package GeoDirectory |
|
| 2449 | - */ |
|
| 2450 | - $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
|
|
| 2451 | - |
|
| 2452 | - $user_meta_data = ''; |
|
| 2453 | - if (isset($current_user->data->ID)) |
|
| 2454 | - $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
| 2455 | - |
|
| 2456 | - if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
|
|
| 2457 | - ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>" ><a |
|
| 2377 | + /** |
|
| 2378 | + * This function would display the html content for add to favorite or remove from favorite. |
|
| 2379 | + * |
|
| 2380 | + * @since 1.0.0 |
|
| 2381 | + * @package GeoDirectory |
|
| 2382 | + * @global object $current_user Current user object. |
|
| 2383 | + * @global object $post The current post object. |
|
| 2384 | + * @param int $user_id The user ID. |
|
| 2385 | + * @param int $post_id The post ID. |
|
| 2386 | + */ |
|
| 2387 | + function geodir_favourite_html($user_id, $post_id) |
|
| 2388 | + {
|
|
| 2389 | + |
|
| 2390 | + global $current_user, $post; |
|
| 2391 | + |
|
| 2392 | + /** |
|
| 2393 | + * Filter to modify "Add to Favorites" text |
|
| 2394 | + * |
|
| 2395 | + * You can use this filter to rename "Add to Favorites" text to something else. |
|
| 2396 | + * |
|
| 2397 | + * @since 1.0.0 |
|
| 2398 | + * @package GeoDirectory |
|
| 2399 | + */ |
|
| 2400 | + $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
|
|
| 2401 | + |
|
| 2402 | + /** |
|
| 2403 | + * Filter to modify "Favourite" text |
|
| 2404 | + * |
|
| 2405 | + * You can use this filter to rename "Favourite" text to something else. |
|
| 2406 | + * |
|
| 2407 | + * @since 1.0.0 |
|
| 2408 | + * @package GeoDirectory |
|
| 2409 | + */ |
|
| 2410 | + $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
|
|
| 2411 | + |
|
| 2412 | + /** |
|
| 2413 | + * Filter to modify "Unfavorite" text |
|
| 2414 | + * |
|
| 2415 | + * You can use this filter to rename "Unfavorite" text to something else. |
|
| 2416 | + * |
|
| 2417 | + * @since 1.0.0 |
|
| 2418 | + * @package GeoDirectory |
|
| 2419 | + */ |
|
| 2420 | + $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
|
|
| 2421 | + |
|
| 2422 | + /** |
|
| 2423 | + * Filter to modify "Remove from Favorites" text |
|
| 2424 | + * |
|
| 2425 | + * You can use this filter to rename "Remove from Favorites" text to something else. |
|
| 2426 | + * |
|
| 2427 | + * @since 1.0.0 |
|
| 2428 | + * @package GeoDirectory |
|
| 2429 | + */ |
|
| 2430 | + $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
|
|
| 2431 | + |
|
| 2432 | + /** |
|
| 2433 | + * Filter to modify "fa fa-heart" icon |
|
| 2434 | + * |
|
| 2435 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2436 | + * |
|
| 2437 | + * @since 1.0.0 |
|
| 2438 | + * @package GeoDirectory |
|
| 2439 | + */ |
|
| 2440 | + $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2441 | + |
|
| 2442 | + /** |
|
| 2443 | + * Filter to modify "fa fa-heart" icon for "remove from favorites" link |
|
| 2444 | + * |
|
| 2445 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2446 | + * |
|
| 2447 | + * @since 1.0.0 |
|
| 2448 | + * @package GeoDirectory |
|
| 2449 | + */ |
|
| 2450 | + $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
|
|
| 2451 | + |
|
| 2452 | + $user_meta_data = ''; |
|
| 2453 | + if (isset($current_user->data->ID)) |
|
| 2454 | + $user_meta_data = get_user_meta($current_user->data->ID, 'gd_user_favourite_post', true); |
|
| 2455 | + |
|
| 2456 | + if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
|
|
| 2457 | + ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>" ><a |
|
| 2458 | 2458 | class="geodir-removetofav-icon" href="javascript:void(0);" |
| 2459 | 2459 | onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');" |
| 2460 | 2460 | title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?> |
| 2461 | 2461 | </a> </span><?php |
| 2462 | 2462 | |
| 2463 | - } else {
|
|
| 2463 | + } else {
|
|
| 2464 | 2464 | |
| 2465 | - if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
|
|
| 2466 | - $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\''; |
|
| 2467 | - } else |
|
| 2468 | - $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
|
|
| 2465 | + if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
|
|
| 2466 | + $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\''; |
|
| 2467 | + } else |
|
| 2468 | + $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
|
|
| 2469 | 2469 | |
| 2470 | - ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon" |
|
| 2470 | + ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon" |
|
| 2471 | 2471 | href="javascript:void(0);" |
| 2472 | 2472 | onclick="<?php echo $script_text;?>" |
| 2473 | 2473 | title="<?php echo $add_favourite_text;?>"><i |
| 2474 | 2474 | class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span> |
| 2475 | 2475 | <?php } |
| 2476 | - } |
|
| 2476 | + } |
|
| 2477 | 2477 | } |
| 2478 | 2478 | |
| 2479 | 2479 | |
@@ -2490,54 +2490,54 @@ discard block |
||
| 2490 | 2490 | function geodir_get_cat_postcount($term = array()) |
| 2491 | 2491 | {
|
| 2492 | 2492 | |
| 2493 | - if (!empty($term)) {
|
|
| 2493 | + if (!empty($term)) {
|
|
| 2494 | 2494 | |
| 2495 | - global $wpdb, $plugin_prefix; |
|
| 2495 | + global $wpdb, $plugin_prefix; |
|
| 2496 | 2496 | |
| 2497 | - $where = ''; |
|
| 2498 | - $join = ''; |
|
| 2499 | - if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
|
|
| 2500 | - $taxonomy_obj = get_taxonomy($term->taxonomy); |
|
| 2497 | + $where = ''; |
|
| 2498 | + $join = ''; |
|
| 2499 | + if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
|
|
| 2500 | + $taxonomy_obj = get_taxonomy($term->taxonomy); |
|
| 2501 | 2501 | |
| 2502 | - $post_type = $taxonomy_obj->object_type[0]; |
|
| 2502 | + $post_type = $taxonomy_obj->object_type[0]; |
|
| 2503 | 2503 | |
| 2504 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2504 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2505 | 2505 | |
| 2506 | - /** |
|
| 2507 | - * Filter to modify the 'join' query |
|
| 2508 | - * |
|
| 2509 | - * @since 1.0.0 |
|
| 2510 | - * @package GeoDirectory |
|
| 2511 | - * @param object|array $term category / term object that need to be processed. |
|
| 2512 | - * @param string $join The join query. |
|
| 2513 | - */ |
|
| 2514 | - $join = apply_filters('geodir_cat_post_count_join', $join, $term);
|
|
| 2506 | + /** |
|
| 2507 | + * Filter to modify the 'join' query |
|
| 2508 | + * |
|
| 2509 | + * @since 1.0.0 |
|
| 2510 | + * @package GeoDirectory |
|
| 2511 | + * @param object|array $term category / term object that need to be processed. |
|
| 2512 | + * @param string $join The join query. |
|
| 2513 | + */ |
|
| 2514 | + $join = apply_filters('geodir_cat_post_count_join', $join, $term);
|
|
| 2515 | 2515 | |
| 2516 | - /** |
|
| 2517 | - * Filter to modify the 'where' query |
|
| 2518 | - * |
|
| 2519 | - * @since 1.0.0 |
|
| 2520 | - * @package GeoDirectory |
|
| 2521 | - * @param object|array $term category / term object that need to be processed. |
|
| 2522 | - * @param string $where The where query. |
|
| 2523 | - */ |
|
| 2524 | - $where = apply_filters('geodir_cat_post_count_where', $where, $term);
|
|
| 2516 | + /** |
|
| 2517 | + * Filter to modify the 'where' query |
|
| 2518 | + * |
|
| 2519 | + * @since 1.0.0 |
|
| 2520 | + * @package GeoDirectory |
|
| 2521 | + * @param object|array $term category / term object that need to be processed. |
|
| 2522 | + * @param string $where The where query. |
|
| 2523 | + */ |
|
| 2524 | + $where = apply_filters('geodir_cat_post_count_where', $where, $term);
|
|
| 2525 | 2525 | |
| 2526 | - $count_query = "SELECT count(post_id) FROM |
|
| 2526 | + $count_query = "SELECT count(post_id) FROM |
|
| 2527 | 2527 | " . $table . " as pd " . $join . " |
| 2528 | 2528 | WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
|
| 2529 | 2529 | |
| 2530 | - $cat_post_count = $wpdb->get_var($count_query); |
|
| 2531 | - if (empty($cat_post_count) || is_wp_error($cat_post_count)) |
|
| 2532 | - $cat_post_count = 0; |
|
| 2530 | + $cat_post_count = $wpdb->get_var($count_query); |
|
| 2531 | + if (empty($cat_post_count) || is_wp_error($cat_post_count)) |
|
| 2532 | + $cat_post_count = 0; |
|
| 2533 | 2533 | |
| 2534 | - return $cat_post_count; |
|
| 2534 | + return $cat_post_count; |
|
| 2535 | 2535 | |
| 2536 | - } else |
|
| 2536 | + } else |
|
| 2537 | 2537 | |
| 2538 | - return $term->count; |
|
| 2539 | - } |
|
| 2540 | - return false; |
|
| 2538 | + return $term->count; |
|
| 2539 | + } |
|
| 2540 | + return false; |
|
| 2541 | 2541 | |
| 2542 | 2542 | } |
| 2543 | 2543 | |
@@ -2550,17 +2550,17 @@ discard block |
||
| 2550 | 2550 | */ |
| 2551 | 2551 | function geodir_allow_post_type_frontend() |
| 2552 | 2552 | {
|
| 2553 | - $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 2553 | + $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 2554 | 2554 | |
| 2555 | - if (!is_admin() && isset($_REQUEST['listing_type']) |
|
| 2556 | - && !empty($geodir_allow_posttype_frontend) |
|
| 2557 | - && !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend) |
|
| 2558 | - ) {
|
|
| 2555 | + if (!is_admin() && isset($_REQUEST['listing_type']) |
|
| 2556 | + && !empty($geodir_allow_posttype_frontend) |
|
| 2557 | + && !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend) |
|
| 2558 | + ) {
|
|
| 2559 | 2559 | |
| 2560 | - wp_redirect(home_url()); |
|
| 2561 | - exit; |
|
| 2560 | + wp_redirect(home_url()); |
|
| 2561 | + exit; |
|
| 2562 | 2562 | |
| 2563 | - } |
|
| 2563 | + } |
|
| 2564 | 2564 | |
| 2565 | 2565 | } |
| 2566 | 2566 | |
@@ -2577,20 +2577,20 @@ discard block |
||
| 2577 | 2577 | */ |
| 2578 | 2578 | function geodir_excerpt_length($length) |
| 2579 | 2579 | {
|
| 2580 | - global $wp_query, $geodir_is_widget_listing; |
|
| 2580 | + global $wp_query, $geodir_is_widget_listing; |
|
| 2581 | 2581 | if ($geodir_is_widget_listing) {
|
| 2582 | 2582 | return $length; |
| 2583 | 2583 | } |
| 2584 | 2584 | |
| 2585 | - if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
|
|
| 2586 | - $length = get_option('geodir_desc_word_limit');
|
|
| 2587 | - elseif (get_query_var('excerpt_length'))
|
|
| 2588 | - $length = get_query_var('excerpt_length');
|
|
| 2585 | + if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
|
|
| 2586 | + $length = get_option('geodir_desc_word_limit');
|
|
| 2587 | + elseif (get_query_var('excerpt_length'))
|
|
| 2588 | + $length = get_query_var('excerpt_length');
|
|
| 2589 | 2589 | |
| 2590 | - if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
|
|
| 2591 | - $length = get_option('geodir_author_desc_word_limit');
|
|
| 2590 | + if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
|
|
| 2591 | + $length = get_option('geodir_author_desc_word_limit');
|
|
| 2592 | 2592 | |
| 2593 | - return $length; |
|
| 2593 | + return $length; |
|
| 2594 | 2594 | } |
| 2595 | 2595 | |
| 2596 | 2596 | /** |
@@ -2605,13 +2605,13 @@ discard block |
||
| 2605 | 2605 | */ |
| 2606 | 2606 | function geodir_excerpt_more($more) |
| 2607 | 2607 | {
|
| 2608 | - global $post; |
|
| 2609 | - $all_postypes = geodir_get_posttypes(); |
|
| 2610 | - if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
|
|
| 2611 | - return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>'; |
|
| 2612 | - } |
|
| 2608 | + global $post; |
|
| 2609 | + $all_postypes = geodir_get_posttypes(); |
|
| 2610 | + if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
|
|
| 2611 | + return ' <a href="' . get_permalink($post->ID) . '">' . READ_MORE_TXT . '</a>'; |
|
| 2612 | + } |
|
| 2613 | 2613 | |
| 2614 | - return $more; |
|
| 2614 | + return $more; |
|
| 2615 | 2615 | } |
| 2616 | 2616 | |
| 2617 | 2617 | |
@@ -2628,63 +2628,63 @@ discard block |
||
| 2628 | 2628 | */ |
| 2629 | 2629 | function geodir_update_markers_oncatedit($term_id, $tt_id, $taxonomy) |
| 2630 | 2630 | {
|
| 2631 | - global $plugin_prefix, $wpdb; |
|
| 2631 | + global $plugin_prefix, $wpdb; |
|
| 2632 | 2632 | |
| 2633 | - $gd_taxonomies = geodir_get_taxonomies(); |
|
| 2633 | + $gd_taxonomies = geodir_get_taxonomies(); |
|
| 2634 | 2634 | |
| 2635 | - if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
|
|
| 2635 | + if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
|
|
| 2636 | 2636 | |
| 2637 | - $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy); |
|
| 2638 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 2637 | + $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy); |
|
| 2638 | + $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 2639 | 2639 | |
| 2640 | - $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']); |
|
| 2641 | - $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png'; |
|
| 2640 | + $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']); |
|
| 2641 | + $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png'; |
|
| 2642 | 2642 | |
| 2643 | - $posts = $wpdb->get_results( |
|
| 2644 | - $wpdb->prepare( |
|
| 2645 | - "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ", |
|
| 2646 | - array($term_id, $taxonomy) |
|
| 2647 | - ) |
|
| 2648 | - ); |
|
| 2643 | + $posts = $wpdb->get_results( |
|
| 2644 | + $wpdb->prepare( |
|
| 2645 | + "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ", |
|
| 2646 | + array($term_id, $taxonomy) |
|
| 2647 | + ) |
|
| 2648 | + ); |
|
| 2649 | 2649 | |
| 2650 | - if (!empty($posts)): |
|
| 2651 | - foreach ($posts as $post_obj) {
|
|
| 2650 | + if (!empty($posts)): |
|
| 2651 | + foreach ($posts as $post_obj) {
|
|
| 2652 | 2652 | |
| 2653 | - $lat = $post_obj->post_latitude; |
|
| 2654 | - $lng = $post_obj->post_longitude; |
|
| 2653 | + $lat = $post_obj->post_latitude; |
|
| 2654 | + $lng = $post_obj->post_longitude; |
|
| 2655 | 2655 | |
| 2656 | - $json = '{';
|
|
| 2657 | - $json .= '"id":"' . $post_obj->post_id . '",'; |
|
| 2658 | - $json .= '"lat_pos": "' . $lat . '",'; |
|
| 2659 | - $json .= '"long_pos": "' . $lng . '",'; |
|
| 2660 | - $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",'; |
|
| 2661 | - $json .= '"icon":"' . $term_icon . '",'; |
|
| 2662 | - $json .= '"group":"catgroup' . $term_id . '"'; |
|
| 2663 | - $json .= '}'; |
|
| 2656 | + $json = '{';
|
|
| 2657 | + $json .= '"id":"' . $post_obj->post_id . '",'; |
|
| 2658 | + $json .= '"lat_pos": "' . $lat . '",'; |
|
| 2659 | + $json .= '"long_pos": "' . $lng . '",'; |
|
| 2660 | + $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",'; |
|
| 2661 | + $json .= '"icon":"' . $term_icon . '",'; |
|
| 2662 | + $json .= '"group":"catgroup' . $term_id . '"'; |
|
| 2663 | + $json .= '}'; |
|
| 2664 | 2664 | |
| 2665 | - if ($post_obj->default_category == $term_id) {
|
|
| 2665 | + if ($post_obj->default_category == $term_id) {
|
|
| 2666 | 2666 | |
| 2667 | - $wpdb->query( |
|
| 2668 | - $wpdb->prepare( |
|
| 2669 | - "UPDATE " . $table . " SET marker_json = %s where post_id = %d", |
|
| 2670 | - array($json, $post_obj->post_id) |
|
| 2671 | - ) |
|
| 2672 | - ); |
|
| 2673 | - } |
|
| 2667 | + $wpdb->query( |
|
| 2668 | + $wpdb->prepare( |
|
| 2669 | + "UPDATE " . $table . " SET marker_json = %s where post_id = %d", |
|
| 2670 | + array($json, $post_obj->post_id) |
|
| 2671 | + ) |
|
| 2672 | + ); |
|
| 2673 | + } |
|
| 2674 | 2674 | |
| 2675 | - $wpdb->query( |
|
| 2676 | - $wpdb->prepare( |
|
| 2677 | - "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d", |
|
| 2678 | - array($json, $post_obj->post_id, $term_id) |
|
| 2679 | - ) |
|
| 2680 | - ); |
|
| 2675 | + $wpdb->query( |
|
| 2676 | + $wpdb->prepare( |
|
| 2677 | + "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d", |
|
| 2678 | + array($json, $post_obj->post_id, $term_id) |
|
| 2679 | + ) |
|
| 2680 | + ); |
|
| 2681 | 2681 | |
| 2682 | - } |
|
| 2682 | + } |
|
| 2683 | 2683 | |
| 2684 | 2684 | |
| 2685 | - endif; |
|
| 2685 | + endif; |
|
| 2686 | 2686 | |
| 2687 | - } |
|
| 2687 | + } |
|
| 2688 | 2688 | |
| 2689 | 2689 | } |
| 2690 | 2690 | |
@@ -2698,14 +2698,14 @@ discard block |
||
| 2698 | 2698 | */ |
| 2699 | 2699 | function geodir_get_listing_author($listing_id = '') |
| 2700 | 2700 | {
|
| 2701 | - if ($listing_id == '') {
|
|
| 2702 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 2703 | - $listing_id = $_REQUEST['pid']; |
|
| 2704 | - } |
|
| 2705 | - } |
|
| 2706 | - $listing = get_post(strip_tags($listing_id)); |
|
| 2707 | - $listing_author_id = $listing->post_author; |
|
| 2708 | - return $listing_author_id; |
|
| 2701 | + if ($listing_id == '') {
|
|
| 2702 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 2703 | + $listing_id = $_REQUEST['pid']; |
|
| 2704 | + } |
|
| 2705 | + } |
|
| 2706 | + $listing = get_post(strip_tags($listing_id)); |
|
| 2707 | + $listing_author_id = $listing->post_author; |
|
| 2708 | + return $listing_author_id; |
|
| 2709 | 2709 | } |
| 2710 | 2710 | |
| 2711 | 2711 | |
@@ -2720,11 +2720,11 @@ discard block |
||
| 2720 | 2720 | */ |
| 2721 | 2721 | function geodir_lisiting_belong_to_user($listing_id, $user_id) |
| 2722 | 2722 | {
|
| 2723 | - $listing_author_id = geodir_get_listing_author($listing_id); |
|
| 2724 | - if ($listing_author_id == $user_id) |
|
| 2725 | - return true; |
|
| 2726 | - else |
|
| 2727 | - return false; |
|
| 2723 | + $listing_author_id = geodir_get_listing_author($listing_id); |
|
| 2724 | + if ($listing_author_id == $user_id) |
|
| 2725 | + return true; |
|
| 2726 | + else |
|
| 2727 | + return false; |
|
| 2728 | 2728 | |
| 2729 | 2729 | } |
| 2730 | 2730 | |
@@ -2740,17 +2740,17 @@ discard block |
||
| 2740 | 2740 | */ |
| 2741 | 2741 | function geodir_listing_belong_to_current_user($listing_id = '', $exclude_admin = true) |
| 2742 | 2742 | {
|
| 2743 | - global $current_user; |
|
| 2744 | - if ($exclude_admin) {
|
|
| 2745 | - foreach ($current_user->caps as $key => $caps) {
|
|
| 2746 | - if (geodir_strtolower($key) == 'administrator') {
|
|
| 2747 | - return true; |
|
| 2748 | - break; |
|
| 2749 | - } |
|
| 2750 | - } |
|
| 2751 | - } |
|
| 2752 | - |
|
| 2753 | - return geodir_lisiting_belong_to_user($listing_id, $current_user->ID); |
|
| 2743 | + global $current_user; |
|
| 2744 | + if ($exclude_admin) {
|
|
| 2745 | + foreach ($current_user->caps as $key => $caps) {
|
|
| 2746 | + if (geodir_strtolower($key) == 'administrator') {
|
|
| 2747 | + return true; |
|
| 2748 | + break; |
|
| 2749 | + } |
|
| 2750 | + } |
|
| 2751 | + } |
|
| 2752 | + |
|
| 2753 | + return geodir_lisiting_belong_to_user($listing_id, $current_user->ID); |
|
| 2754 | 2754 | } |
| 2755 | 2755 | |
| 2756 | 2756 | |
@@ -2766,17 +2766,17 @@ discard block |
||
| 2766 | 2766 | function geodir_only_supportable_attachments_remove($file) |
| 2767 | 2767 | {
|
| 2768 | 2768 | |
| 2769 | - global $wpdb; |
|
| 2769 | + global $wpdb; |
|
| 2770 | 2770 | |
| 2771 | - $matches = array(); |
|
| 2771 | + $matches = array(); |
|
| 2772 | 2772 | |
| 2773 | - $pattern = '/-\d+x\d+\./'; |
|
| 2774 | - preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE); |
|
| 2773 | + $pattern = '/-\d+x\d+\./'; |
|
| 2774 | + preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE); |
|
| 2775 | 2775 | |
| 2776 | - if (empty($matches)) |
|
| 2777 | - return ''; |
|
| 2778 | - else |
|
| 2779 | - return $file; |
|
| 2776 | + if (empty($matches)) |
|
| 2777 | + return ''; |
|
| 2778 | + else |
|
| 2779 | + return $file; |
|
| 2780 | 2780 | |
| 2781 | 2781 | } |
| 2782 | 2782 | |
@@ -2793,78 +2793,78 @@ discard block |
||
| 2793 | 2793 | function geodir_set_wp_featured_image($post_id) |
| 2794 | 2794 | {
|
| 2795 | 2795 | |
| 2796 | - global $wpdb, $plugin_prefix; |
|
| 2797 | - $uploads = wp_upload_dir(); |
|
| 2796 | + global $wpdb, $plugin_prefix; |
|
| 2797 | + $uploads = wp_upload_dir(); |
|
| 2798 | 2798 | // print_r($uploads ) ; |
| 2799 | - $post_first_image = $wpdb->get_results( |
|
| 2800 | - $wpdb->prepare( |
|
| 2801 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1 ", array($post_id) |
|
| 2802 | - ) |
|
| 2803 | - ); |
|
| 2799 | + $post_first_image = $wpdb->get_results( |
|
| 2800 | + $wpdb->prepare( |
|
| 2801 | + "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1 ", array($post_id) |
|
| 2802 | + ) |
|
| 2803 | + ); |
|
| 2804 | 2804 | |
| 2805 | - $old_attachment_name = ''; |
|
| 2806 | - $post_thumbnail_id = ''; |
|
| 2807 | - if (has_post_thumbnail($post_id)) {
|
|
| 2805 | + $old_attachment_name = ''; |
|
| 2806 | + $post_thumbnail_id = ''; |
|
| 2807 | + if (has_post_thumbnail($post_id)) {
|
|
| 2808 | 2808 | |
| 2809 | - if (has_post_thumbnail($post_id)) {
|
|
| 2809 | + if (has_post_thumbnail($post_id)) {
|
|
| 2810 | 2810 | |
| 2811 | - $post_thumbnail_id = get_post_thumbnail_id($post_id); |
|
| 2811 | + $post_thumbnail_id = get_post_thumbnail_id($post_id); |
|
| 2812 | 2812 | |
| 2813 | - $old_attachment_name = basename(get_attached_file($post_thumbnail_id)); |
|
| 2813 | + $old_attachment_name = basename(get_attached_file($post_thumbnail_id)); |
|
| 2814 | 2814 | |
| 2815 | - } |
|
| 2816 | - } |
|
| 2817 | - |
|
| 2818 | - if (!empty($post_first_image)) {
|
|
| 2815 | + } |
|
| 2816 | + } |
|
| 2819 | 2817 | |
| 2820 | - $post_type = get_post_type($post_id); |
|
| 2818 | + if (!empty($post_first_image)) {
|
|
| 2821 | 2819 | |
| 2822 | - $table_name = $plugin_prefix . $post_type . '_detail'; |
|
| 2820 | + $post_type = get_post_type($post_id); |
|
| 2823 | 2821 | |
| 2824 | - $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
|
|
| 2822 | + $table_name = $plugin_prefix . $post_type . '_detail'; |
|
| 2825 | 2823 | |
| 2826 | - $new_attachment_name = basename($post_first_image[0]->file); |
|
| 2824 | + $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
|
|
| 2827 | 2825 | |
| 2828 | - if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
|
|
| 2826 | + $new_attachment_name = basename($post_first_image[0]->file); |
|
| 2829 | 2827 | |
| 2830 | - if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
|
|
| 2828 | + if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
|
|
| 2831 | 2829 | |
| 2832 | - add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
|
|
| 2830 | + if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
|
|
| 2833 | 2831 | |
| 2834 | - wp_delete_attachment($post_thumbnail_id); |
|
| 2832 | + add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
|
|
| 2835 | 2833 | |
| 2836 | - } |
|
| 2837 | - $filename = $uploads['basedir'] . $post_first_image[0]->file; |
|
| 2834 | + wp_delete_attachment($post_thumbnail_id); |
|
| 2838 | 2835 | |
| 2839 | - $attachment = array( |
|
| 2840 | - 'post_mime_type' => $post_first_image[0]->mime_type, |
|
| 2841 | - 'guid' => $uploads['baseurl'] . $post_first_image[0]->file, |
|
| 2842 | - 'post_parent' => $post_id, |
|
| 2843 | - 'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
|
|
| 2844 | - 'post_content' => '' |
|
| 2845 | - ); |
|
| 2836 | + } |
|
| 2837 | + $filename = $uploads['basedir'] . $post_first_image[0]->file; |
|
| 2838 | + |
|
| 2839 | + $attachment = array( |
|
| 2840 | + 'post_mime_type' => $post_first_image[0]->mime_type, |
|
| 2841 | + 'guid' => $uploads['baseurl'] . $post_first_image[0]->file, |
|
| 2842 | + 'post_parent' => $post_id, |
|
| 2843 | + 'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
|
|
| 2844 | + 'post_content' => '' |
|
| 2845 | + ); |
|
| 2846 | 2846 | |
| 2847 | 2847 | |
| 2848 | - $id = wp_insert_attachment($attachment, $filename, $post_id); |
|
| 2848 | + $id = wp_insert_attachment($attachment, $filename, $post_id); |
|
| 2849 | 2849 | |
| 2850 | - if (!is_wp_error($id)) {
|
|
| 2850 | + if (!is_wp_error($id)) {
|
|
| 2851 | 2851 | |
| 2852 | - set_post_thumbnail($post_id, $id); |
|
| 2852 | + set_post_thumbnail($post_id, $id); |
|
| 2853 | 2853 | |
| 2854 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 2855 | - wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
|
| 2854 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 2855 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
|
| 2856 | 2856 | |
| 2857 | - } |
|
| 2857 | + } |
|
| 2858 | 2858 | |
| 2859 | - } |
|
| 2859 | + } |
|
| 2860 | 2860 | |
| 2861 | - } else {
|
|
| 2862 | - //set_post_thumbnail($post_id,-1); |
|
| 2861 | + } else {
|
|
| 2862 | + //set_post_thumbnail($post_id,-1); |
|
| 2863 | 2863 | |
| 2864 | - if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) |
|
| 2865 | - wp_delete_attachment($post_thumbnail_id); |
|
| 2864 | + if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) |
|
| 2865 | + wp_delete_attachment($post_thumbnail_id); |
|
| 2866 | 2866 | |
| 2867 | - } |
|
| 2867 | + } |
|
| 2868 | 2868 | } |
| 2869 | 2869 | |
| 2870 | 2870 | |
@@ -2879,53 +2879,53 @@ discard block |
||
| 2879 | 2879 | */ |
| 2880 | 2880 | function gd_copy_original_translation() |
| 2881 | 2881 | {
|
| 2882 | - if (function_exists('icl_object_id')) {
|
|
| 2883 | - global $wpdb, $table_prefix, $plugin_prefix; |
|
| 2884 | - $post_id = absint($_POST['post_id']); |
|
| 2885 | - $upload_dir = wp_upload_dir(); |
|
| 2886 | - $post_type = get_post_type($_POST['post_id']); |
|
| 2887 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2888 | - |
|
| 2889 | - $post_arr = $wpdb->get_results($wpdb->prepare( |
|
| 2890 | - "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1", |
|
| 2891 | - array($post_id) |
|
| 2892 | - ) |
|
| 2893 | - , ARRAY_A); |
|
| 2894 | - |
|
| 2895 | - $arrImages = $wpdb->get_results( |
|
| 2896 | - $wpdb->prepare( |
|
| 2897 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ", |
|
| 2898 | - array('%image%', $post_id)
|
|
| 2899 | - ) |
|
| 2900 | - ); |
|
| 2901 | - if ($arrImages) {
|
|
| 2902 | - $image_arr = array(); |
|
| 2903 | - foreach ($arrImages as $img) {
|
|
| 2904 | - $image_arr[] = $upload_dir['baseurl'] . $img->file; |
|
| 2905 | - } |
|
| 2906 | - $comma_separated = implode(",", $image_arr);
|
|
| 2907 | - $post_arr[0]['post_images'] = $comma_separated; |
|
| 2908 | - } |
|
| 2909 | - |
|
| 2910 | - |
|
| 2911 | - $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category']; |
|
| 2912 | - $cat_arr = array_filter(explode(",", $cats));
|
|
| 2913 | - $trans_cat = array(); |
|
| 2914 | - foreach ($cat_arr as $cat) {
|
|
| 2915 | - $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false); |
|
| 2916 | - } |
|
| 2917 | - |
|
| 2918 | - |
|
| 2919 | - $post_arr[0]['categories'] = array_filter($trans_cat); |
|
| 2882 | + if (function_exists('icl_object_id')) {
|
|
| 2883 | + global $wpdb, $table_prefix, $plugin_prefix; |
|
| 2884 | + $post_id = absint($_POST['post_id']); |
|
| 2885 | + $upload_dir = wp_upload_dir(); |
|
| 2886 | + $post_type = get_post_type($_POST['post_id']); |
|
| 2887 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2888 | + |
|
| 2889 | + $post_arr = $wpdb->get_results($wpdb->prepare( |
|
| 2890 | + "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1", |
|
| 2891 | + array($post_id) |
|
| 2892 | + ) |
|
| 2893 | + , ARRAY_A); |
|
| 2894 | + |
|
| 2895 | + $arrImages = $wpdb->get_results( |
|
| 2896 | + $wpdb->prepare( |
|
| 2897 | + "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ", |
|
| 2898 | + array('%image%', $post_id)
|
|
| 2899 | + ) |
|
| 2900 | + ); |
|
| 2901 | + if ($arrImages) {
|
|
| 2902 | + $image_arr = array(); |
|
| 2903 | + foreach ($arrImages as $img) {
|
|
| 2904 | + $image_arr[] = $upload_dir['baseurl'] . $img->file; |
|
| 2905 | + } |
|
| 2906 | + $comma_separated = implode(",", $image_arr);
|
|
| 2907 | + $post_arr[0]['post_images'] = $comma_separated; |
|
| 2908 | + } |
|
| 2909 | + |
|
| 2910 | + |
|
| 2911 | + $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category']; |
|
| 2912 | + $cat_arr = array_filter(explode(",", $cats));
|
|
| 2913 | + $trans_cat = array(); |
|
| 2914 | + foreach ($cat_arr as $cat) {
|
|
| 2915 | + $trans_cat[] = icl_object_id($cat, $post_arr[0]['post_type'] . 'category', false); |
|
| 2916 | + } |
|
| 2917 | + |
|
| 2918 | + |
|
| 2919 | + $post_arr[0]['categories'] = array_filter($trans_cat); |
|
| 2920 | 2920 | //print_r($image_arr); |
| 2921 | - //print_r($arrImages); |
|
| 2922 | - //echo $_REQUEST['lang']; |
|
| 2921 | + //print_r($arrImages); |
|
| 2922 | + //echo $_REQUEST['lang']; |
|
| 2923 | 2923 | //print_r($post_arr); |
| 2924 | 2924 | //print_r($trans_cat); |
| 2925 | - echo json_encode($post_arr[0]); |
|
| 2925 | + echo json_encode($post_arr[0]); |
|
| 2926 | 2926 | |
| 2927 | - } |
|
| 2928 | - die(); |
|
| 2927 | + } |
|
| 2928 | + die(); |
|
| 2929 | 2929 | } |
| 2930 | 2930 | |
| 2931 | 2931 | |
@@ -2945,54 +2945,54 @@ discard block |
||
| 2945 | 2945 | function geodir_get_custom_fields_type($listing_type = '') |
| 2946 | 2946 | {
|
| 2947 | 2947 | |
| 2948 | - global $wpdb; |
|
| 2948 | + global $wpdb; |
|
| 2949 | 2949 | |
| 2950 | - if ($listing_type == '') |
|
| 2951 | - $listing_type = 'gd_place'; |
|
| 2950 | + if ($listing_type == '') |
|
| 2951 | + $listing_type = 'gd_place'; |
|
| 2952 | 2952 | |
| 2953 | - $fields_info = array(); |
|
| 2953 | + $fields_info = array(); |
|
| 2954 | 2954 | |
| 2955 | - $get_data = $wpdb->get_results( |
|
| 2956 | - $wpdb->prepare( |
|
| 2957 | - "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'", |
|
| 2958 | - array($listing_type) |
|
| 2959 | - ) |
|
| 2960 | - ); |
|
| 2955 | + $get_data = $wpdb->get_results( |
|
| 2956 | + $wpdb->prepare( |
|
| 2957 | + "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'", |
|
| 2958 | + array($listing_type) |
|
| 2959 | + ) |
|
| 2960 | + ); |
|
| 2961 | 2961 | |
| 2962 | - if (!empty($get_data)) {
|
|
| 2962 | + if (!empty($get_data)) {
|
|
| 2963 | 2963 | |
| 2964 | - foreach ($get_data as $data) {
|
|
| 2964 | + foreach ($get_data as $data) {
|
|
| 2965 | 2965 | |
| 2966 | - if ($data->field_type == 'address') {
|
|
| 2966 | + if ($data->field_type == 'address') {
|
|
| 2967 | 2967 | |
| 2968 | - $extra_fields = unserialize($data->extra_fields); |
|
| 2968 | + $extra_fields = unserialize($data->extra_fields); |
|
| 2969 | 2969 | |
| 2970 | - $prefix = $data->htmlvar_name . '_'; |
|
| 2970 | + $prefix = $data->htmlvar_name . '_'; |
|
| 2971 | 2971 | |
| 2972 | - $fields_info[$prefix . 'address'] = $data->field_type; |
|
| 2972 | + $fields_info[$prefix . 'address'] = $data->field_type; |
|
| 2973 | 2973 | |
| 2974 | - if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) |
|
| 2975 | - $fields_info[$prefix . 'zip'] = $data->field_type; |
|
| 2974 | + if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) |
|
| 2975 | + $fields_info[$prefix . 'zip'] = $data->field_type; |
|
| 2976 | 2976 | |
| 2977 | - } else {
|
|
| 2977 | + } else {
|
|
| 2978 | 2978 | |
| 2979 | - $fields_info[$data->htmlvar_name] = $data->field_type; |
|
| 2979 | + $fields_info[$data->htmlvar_name] = $data->field_type; |
|
| 2980 | 2980 | |
| 2981 | - } |
|
| 2981 | + } |
|
| 2982 | 2982 | |
| 2983 | - } |
|
| 2983 | + } |
|
| 2984 | 2984 | |
| 2985 | - } |
|
| 2985 | + } |
|
| 2986 | 2986 | |
| 2987 | - /** |
|
| 2988 | - * Filter to modify custom fields info using listing post type. |
|
| 2989 | - * |
|
| 2990 | - * @since 1.0.0 |
|
| 2991 | - * @package GeoDirectory |
|
| 2992 | - * @return array $fields_info Custom fields info. |
|
| 2993 | - * @param string $listing_type The listing post type. |
|
| 2994 | - */ |
|
| 2995 | - return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
|
|
| 2987 | + /** |
|
| 2988 | + * Filter to modify custom fields info using listing post type. |
|
| 2989 | + * |
|
| 2990 | + * @since 1.0.0 |
|
| 2991 | + * @package GeoDirectory |
|
| 2992 | + * @return array $fields_info Custom fields info. |
|
| 2993 | + * @param string $listing_type The listing post type. |
|
| 2994 | + */ |
|
| 2995 | + return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
|
|
| 2996 | 2996 | } |
| 2997 | 2997 | |
| 2998 | 2998 | |
@@ -3007,58 +3007,58 @@ discard block |
||
| 3007 | 3007 | */ |
| 3008 | 3008 | function geodir_function_post_updated($post_ID, $post_after, $post_before) |
| 3009 | 3009 | {
|
| 3010 | - $post_type = get_post_type($post_ID); |
|
| 3010 | + $post_type = get_post_type($post_ID); |
|
| 3011 | 3011 | |
| 3012 | - if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
|
|
| 3013 | - // send notification to client when post moves from draft to publish |
|
| 3014 | - if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft')) {
|
|
| 3015 | - $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL; |
|
| 3016 | - $post_author_data = get_userdata($post_author_id); |
|
| 3012 | + if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
|
|
| 3013 | + // send notification to client when post moves from draft to publish |
|
| 3014 | + if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft')) {
|
|
| 3015 | + $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL; |
|
| 3016 | + $post_author_data = get_userdata($post_author_id); |
|
| 3017 | 3017 | |
| 3018 | - $to_name = geodir_get_client_name($post_author_id); |
|
| 3018 | + $to_name = geodir_get_client_name($post_author_id); |
|
| 3019 | 3019 | |
| 3020 | - $from_email = geodir_get_site_email_id(); |
|
| 3021 | - $from_name = get_site_emailName(); |
|
| 3022 | - $to_email = $post_author_data->user_email; |
|
| 3020 | + $from_email = geodir_get_site_email_id(); |
|
| 3021 | + $from_name = get_site_emailName(); |
|
| 3022 | + $to_email = $post_author_data->user_email; |
|
| 3023 | 3023 | |
| 3024 | - if (!is_email($to_email) && !empty($post_author_data->user_email)) {
|
|
| 3025 | - $to_email = $post_author_data->user_email; |
|
| 3026 | - } |
|
| 3024 | + if (!is_email($to_email) && !empty($post_author_data->user_email)) {
|
|
| 3025 | + $to_email = $post_author_data->user_email; |
|
| 3026 | + } |
|
| 3027 | 3027 | |
| 3028 | - $message_type = 'listing_published'; |
|
| 3028 | + $message_type = 'listing_published'; |
|
| 3029 | 3029 | |
| 3030 | - if (get_option('geodir_post_published_email_subject') == '') {
|
|
| 3031 | - update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
|
|
| 3032 | - } |
|
| 3030 | + if (get_option('geodir_post_published_email_subject') == '') {
|
|
| 3031 | + update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
|
|
| 3032 | + } |
|
| 3033 | 3033 | |
| 3034 | - if (get_option('geodir_post_published_email_content') == '') {
|
|
| 3035 | - update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", 'geodirectory'));
|
|
| 3036 | - } |
|
| 3034 | + if (get_option('geodir_post_published_email_content') == '') {
|
|
| 3035 | + update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", 'geodirectory'));
|
|
| 3036 | + } |
|
| 3037 | 3037 | |
| 3038 | - /** |
|
| 3039 | - * Called before sending the email when listing gets published. |
|
| 3040 | - * |
|
| 3041 | - * @since 1.0.0 |
|
| 3042 | - * @package GeoDirectory |
|
| 3043 | - * @param object $post_after The post object after update. |
|
| 3044 | - * @param object $post_before The post object before update. |
|
| 3045 | - */ |
|
| 3046 | - do_action('geodir_before_listing_published_email', $post_after, $post_before);
|
|
| 3047 | - if (is_email($to_email)) {
|
|
| 3048 | - geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID); |
|
| 3049 | - } |
|
| 3038 | + /** |
|
| 3039 | + * Called before sending the email when listing gets published. |
|
| 3040 | + * |
|
| 3041 | + * @since 1.0.0 |
|
| 3042 | + * @package GeoDirectory |
|
| 3043 | + * @param object $post_after The post object after update. |
|
| 3044 | + * @param object $post_before The post object before update. |
|
| 3045 | + */ |
|
| 3046 | + do_action('geodir_before_listing_published_email', $post_after, $post_before);
|
|
| 3047 | + if (is_email($to_email)) {
|
|
| 3048 | + geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID); |
|
| 3049 | + } |
|
| 3050 | 3050 | |
| 3051 | - /** |
|
| 3052 | - * Called after sending the email when listing gets published. |
|
| 3053 | - * |
|
| 3054 | - * @since 1.0.0 |
|
| 3055 | - * @package GeoDirectory |
|
| 3056 | - * @param object $post_after The post object after update. |
|
| 3057 | - * @param object $post_before The post object before update. |
|
| 3058 | - */ |
|
| 3059 | - do_action('geodir_after_listing_published_email', $post_after, $post_before);
|
|
| 3060 | - } |
|
| 3061 | - } |
|
| 3051 | + /** |
|
| 3052 | + * Called after sending the email when listing gets published. |
|
| 3053 | + * |
|
| 3054 | + * @since 1.0.0 |
|
| 3055 | + * @package GeoDirectory |
|
| 3056 | + * @param object $post_after The post object after update. |
|
| 3057 | + * @param object $post_before The post object before update. |
|
| 3058 | + */ |
|
| 3059 | + do_action('geodir_after_listing_published_email', $post_after, $post_before);
|
|
| 3060 | + } |
|
| 3061 | + } |
|
| 3062 | 3062 | } |
| 3063 | 3063 | |
| 3064 | 3064 | add_action('wp_head', 'geodir_fb_like_thumbnail');
|
@@ -3072,14 +3072,14 @@ discard block |
||
| 3072 | 3072 | */ |
| 3073 | 3073 | function geodir_fb_like_thumbnail(){
|
| 3074 | 3074 | |
| 3075 | - // return if not a single post |
|
| 3076 | - if(!is_single()){return;}
|
|
| 3075 | + // return if not a single post |
|
| 3076 | + if(!is_single()){return;}
|
|
| 3077 | 3077 | |
| 3078 | - global $post; |
|
| 3079 | - if(isset($post->featured_image) && $post->featured_image){
|
|
| 3080 | - $upload_dir = wp_upload_dir(); |
|
| 3081 | - $thumb = $upload_dir['baseurl'].$post->featured_image; |
|
| 3082 | - echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n"; |
|
| 3078 | + global $post; |
|
| 3079 | + if(isset($post->featured_image) && $post->featured_image){
|
|
| 3080 | + $upload_dir = wp_upload_dir(); |
|
| 3081 | + $thumb = $upload_dir['baseurl'].$post->featured_image; |
|
| 3082 | + echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$thumb\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n"; |
|
| 3083 | 3083 | |
| 3084 | - } |
|
| 3084 | + } |
|
| 3085 | 3085 | } |
| 3086 | 3086 | \ No newline at end of file |
@@ -28,11 +28,11 @@ discard block |
||
| 28 | 28 | function geodir_plugin_url() |
| 29 | 29 | {
|
| 30 | 30 | |
| 31 | - if (is_ssl()) : |
|
| 32 | - return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename(dirname(dirname(__FILE__)));
|
|
| 33 | - else : |
|
| 34 | - return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__))); |
|
| 35 | - endif; |
|
| 31 | + if (is_ssl()) : |
|
| 32 | + return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename(dirname(dirname(__FILE__)));
|
|
| 33 | + else : |
|
| 34 | + return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__))); |
|
| 35 | + endif; |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | function geodir_plugin_path() |
| 49 | 49 | {
|
| 50 | - if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
|
|
| 51 | - return dirname(dirname(__FILE__)); |
|
| 52 | - } else {
|
|
| 53 | - return WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__))); |
|
| 54 | - } |
|
| 50 | + if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
|
|
| 51 | + return dirname(dirname(__FILE__)); |
|
| 52 | + } else {
|
|
| 53 | + return WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__))); |
|
| 54 | + } |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | */ |
| 66 | 66 | function geodir_is_plugin_active($plugin) |
| 67 | 67 | {
|
| 68 | - $active_plugins = get_option('active_plugins');
|
|
| 69 | - foreach ($active_plugins as $key => $active_plugin) {
|
|
| 70 | - if (strstr($active_plugin, $plugin)) return true; |
|
| 71 | - } |
|
| 72 | - return false; |
|
| 68 | + $active_plugins = get_option('active_plugins');
|
|
| 69 | + foreach ($active_plugins as $key => $active_plugin) {
|
|
| 70 | + if (strstr($active_plugin, $plugin)) return true; |
|
| 71 | + } |
|
| 72 | + return false; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | function geodir_get_formated_date($date) |
| 87 | 87 | {
|
| 88 | - return mysql2date(get_option('date_format'), $date);
|
|
| 88 | + return mysql2date(get_option('date_format'), $date);
|
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | */ |
| 101 | 101 | function geodir_get_formated_time($time) |
| 102 | 102 | {
|
| 103 | - return mysql2date(get_option('time_format'), $time, $translate = true);
|
|
| 103 | + return mysql2date(get_option('time_format'), $time, $translate = true);
|
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | |
@@ -118,26 +118,26 @@ discard block |
||
| 118 | 118 | */ |
| 119 | 119 | function geodir_getlink($url, $params = array(), $use_existing_arguments = false) |
| 120 | 120 | {
|
| 121 | - if ($use_existing_arguments) $params = $params + $_GET; |
|
| 122 | - if (!$params) return $url; |
|
| 123 | - $link = $url; |
|
| 124 | - if (strpos($link, '?') === false) $link .= '?'; //If there is no '?' add one at the end |
|
| 125 | - elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) $link .= '&'; //If there is no '&' at the END, add one. |
|
| 126 | - elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) $link .= '&'; //If there is no '&' at the END, add one.
|
|
| 127 | - |
|
| 128 | - $params_arr = array(); |
|
| 129 | - foreach ($params as $key => $value) {
|
|
| 130 | - if (gettype($value) == 'array') { //Handle array data properly
|
|
| 131 | - foreach ($value as $val) {
|
|
| 132 | - $params_arr[] = $key . '[]=' . urlencode($val); |
|
| 133 | - } |
|
| 134 | - } else {
|
|
| 135 | - $params_arr[] = $key . '=' . urlencode($value); |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - $link .= implode('&', $params_arr);
|
|
| 139 | - |
|
| 140 | - return $link; |
|
| 121 | + if ($use_existing_arguments) $params = $params + $_GET; |
|
| 122 | + if (!$params) return $url; |
|
| 123 | + $link = $url; |
|
| 124 | + if (strpos($link, '?') === false) $link .= '?'; //If there is no '?' add one at the end |
|
| 125 | + elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) $link .= '&'; //If there is no '&' at the END, add one. |
|
| 126 | + elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) $link .= '&'; //If there is no '&' at the END, add one.
|
|
| 127 | + |
|
| 128 | + $params_arr = array(); |
|
| 129 | + foreach ($params as $key => $value) {
|
|
| 130 | + if (gettype($value) == 'array') { //Handle array data properly
|
|
| 131 | + foreach ($value as $val) {
|
|
| 132 | + $params_arr[] = $key . '[]=' . urlencode($val); |
|
| 133 | + } |
|
| 134 | + } else {
|
|
| 135 | + $params_arr[] = $key . '=' . urlencode($value); |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + $link .= implode('&', $params_arr);
|
|
| 139 | + |
|
| 140 | + return $link; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | |
@@ -152,17 +152,17 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | function geodir_get_addlisting_link($post_type = '') |
| 154 | 154 | {
|
| 155 | - global $wpdb; |
|
| 155 | + global $wpdb; |
|
| 156 | 156 | |
| 157 | - //$check_pkg = $wpdb->get_var("SELECT pid FROM ".GEODIR_PRICE_TABLE." WHERE post_type='".$post_type."' and status != '0'");
|
|
| 158 | - $check_pkg = 1; |
|
| 159 | - if (post_type_exists($post_type) && $check_pkg) {
|
|
| 157 | + //$check_pkg = $wpdb->get_var("SELECT pid FROM ".GEODIR_PRICE_TABLE." WHERE post_type='".$post_type."' and status != '0'");
|
|
| 158 | + $check_pkg = 1; |
|
| 159 | + if (post_type_exists($post_type) && $check_pkg) {
|
|
| 160 | 160 | |
| 161 | - $add_listing_link = get_page_link(geodir_add_listing_page_id()); |
|
| 161 | + $add_listing_link = get_page_link(geodir_add_listing_page_id()); |
|
| 162 | 162 | |
| 163 | - return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
|
|
| 164 | - } else |
|
| 165 | - return get_bloginfo('url');
|
|
| 163 | + return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
|
|
| 164 | + } else |
|
| 165 | + return get_bloginfo('url');
|
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -175,19 +175,19 @@ discard block |
||
| 175 | 175 | */ |
| 176 | 176 | function geodir_curPageURL() |
| 177 | 177 | {
|
| 178 | - $pageURL = 'http'; |
|
| 179 | - if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
|
|
| 180 | - $pageURL .= "s"; |
|
| 181 | - } |
|
| 182 | - $pageURL .= "://"; |
|
| 183 | - $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; |
|
| 184 | - /** |
|
| 185 | - * Filter the current page URL returned by function geodir_curPageURL(). |
|
| 186 | - * |
|
| 187 | - * @since 1.4.1 |
|
| 188 | - * @param string $pageURL The URL of the current page. |
|
| 189 | - */ |
|
| 190 | - return apply_filters('geodir_curPageURL', $pageURL);
|
|
| 178 | + $pageURL = 'http'; |
|
| 179 | + if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on") {
|
|
| 180 | + $pageURL .= "s"; |
|
| 181 | + } |
|
| 182 | + $pageURL .= "://"; |
|
| 183 | + $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; |
|
| 184 | + /** |
|
| 185 | + * Filter the current page URL returned by function geodir_curPageURL(). |
|
| 186 | + * |
|
| 187 | + * @since 1.4.1 |
|
| 188 | + * @param string $pageURL The URL of the current page. |
|
| 189 | + */ |
|
| 190 | + return apply_filters('geodir_curPageURL', $pageURL);
|
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
@@ -204,12 +204,12 @@ discard block |
||
| 204 | 204 | function geodir_clean($string) |
| 205 | 205 | {
|
| 206 | 206 | |
| 207 | - $string = trim(strip_tags(stripslashes($string))); |
|
| 208 | - $string = str_replace(" ", "-", $string); // Replaces all spaces with hyphens.
|
|
| 209 | - $string = preg_replace('/[^A-Za-z0-9\-\_]/', '', $string); // Removes special chars.
|
|
| 210 | - $string = preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
|
|
| 207 | + $string = trim(strip_tags(stripslashes($string))); |
|
| 208 | + $string = str_replace(" ", "-", $string); // Replaces all spaces with hyphens.
|
|
| 209 | + $string = preg_replace('/[^A-Za-z0-9\-\_]/', '', $string); // Removes special chars.
|
|
| 210 | + $string = preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
|
|
| 211 | 211 | |
| 212 | - return $string; |
|
| 212 | + return $string; |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | */ |
| 222 | 222 | function geodir_get_weekday() |
| 223 | 223 | {
|
| 224 | - return array(__('Sunday', 'geodirectory'), __('Monday', 'geodirectory'), __('Tuesday', 'geodirectory'), __('Wednesday', 'geodirectory'), __('Thursday', 'geodirectory'), __('Friday', 'geodirectory'), __('Saturday', 'geodirectory'));
|
|
| 224 | + return array(__('Sunday', 'geodirectory'), __('Monday', 'geodirectory'), __('Tuesday', 'geodirectory'), __('Wednesday', 'geodirectory'), __('Thursday', 'geodirectory'), __('Friday', 'geodirectory'), __('Saturday', 'geodirectory'));
|
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | */ |
| 234 | 234 | function geodir_get_weeks() |
| 235 | 235 | {
|
| 236 | - return array(__('First', 'geodirectory'), __('Second', 'geodirectory'), __('Third', 'geodirectory'), __('Fourth', 'geodirectory'), __('Last', 'geodirectory'));
|
|
| 236 | + return array(__('First', 'geodirectory'), __('Second', 'geodirectory'), __('Third', 'geodirectory'), __('Fourth', 'geodirectory'), __('Last', 'geodirectory'));
|
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | |
@@ -252,103 +252,103 @@ discard block |
||
| 252 | 252 | function geodir_is_page($gdpage = '') |
| 253 | 253 | {
|
| 254 | 254 | |
| 255 | - global $wp_query, $post,$wp; |
|
| 256 | - //if(!is_admin()): |
|
| 257 | - |
|
| 258 | - switch ($gdpage): |
|
| 259 | - case 'add-listing': |
|
| 260 | - |
|
| 261 | - if (is_page() && get_query_var('page_id') == geodir_add_listing_page_id()) {
|
|
| 262 | - return true; |
|
| 263 | - } elseif (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
|
|
| 264 | - return true; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - break; |
|
| 268 | - case 'preview': |
|
| 269 | - if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
|
|
| 270 | - && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) |
|
| 271 | - ) |
|
| 272 | - return true; |
|
| 273 | - break; |
|
| 274 | - case 'listing-success': |
|
| 275 | - if (is_page() && get_query_var('page_id') == geodir_success_page_id())
|
|
| 276 | - return true; |
|
| 277 | - break; |
|
| 278 | - case 'detail': |
|
| 279 | - $post_type = get_query_var('post_type');
|
|
| 280 | - if(is_array($post_type)){$post_type = reset($post_type);}
|
|
| 281 | - if (is_single() && in_array($post_type, geodir_get_posttypes())) |
|
| 282 | - return true; |
|
| 283 | - break; |
|
| 284 | - case 'pt': |
|
| 285 | - $post_type = get_query_var('post_type');
|
|
| 286 | - if(is_array($post_type)){$post_type = reset($post_type);}
|
|
| 287 | - if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax()) |
|
| 288 | - return true; |
|
| 289 | - |
|
| 290 | - break; |
|
| 291 | - case 'listing': |
|
| 292 | - if (is_tax() && geodir_get_taxonomy_posttype()) {
|
|
| 293 | - global $current_term, $taxonomy, $term; |
|
| 294 | - |
|
| 295 | - return true; |
|
| 296 | - } |
|
| 297 | - $post_type = get_query_var('post_type');
|
|
| 298 | - if(is_array($post_type)){$post_type = reset($post_type);}
|
|
| 299 | - if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes())) |
|
| 300 | - return true; |
|
| 301 | - |
|
| 302 | - break; |
|
| 303 | - case 'home': |
|
| 304 | - |
|
| 305 | - if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
|
|
| 306 | - return true; |
|
| 307 | - |
|
| 308 | - break; |
|
| 309 | - case 'location': |
|
| 310 | - if (is_page() && get_query_var('page_id') == geodir_location_page_id())
|
|
| 311 | - return true; |
|
| 312 | - break; |
|
| 313 | - case 'author': |
|
| 314 | - if (is_author() && isset($_REQUEST['geodir_dashbord'])) |
|
| 315 | - return true; |
|
| 255 | + global $wp_query, $post,$wp; |
|
| 256 | + //if(!is_admin()): |
|
| 257 | + |
|
| 258 | + switch ($gdpage): |
|
| 259 | + case 'add-listing': |
|
| 260 | + |
|
| 261 | + if (is_page() && get_query_var('page_id') == geodir_add_listing_page_id()) {
|
|
| 262 | + return true; |
|
| 263 | + } elseif (is_page() && isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
|
|
| 264 | + return true; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + break; |
|
| 268 | + case 'preview': |
|
| 269 | + if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
|
|
| 270 | + && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) |
|
| 271 | + ) |
|
| 272 | + return true; |
|
| 273 | + break; |
|
| 274 | + case 'listing-success': |
|
| 275 | + if (is_page() && get_query_var('page_id') == geodir_success_page_id())
|
|
| 276 | + return true; |
|
| 277 | + break; |
|
| 278 | + case 'detail': |
|
| 279 | + $post_type = get_query_var('post_type');
|
|
| 280 | + if(is_array($post_type)){$post_type = reset($post_type);}
|
|
| 281 | + if (is_single() && in_array($post_type, geodir_get_posttypes())) |
|
| 282 | + return true; |
|
| 283 | + break; |
|
| 284 | + case 'pt': |
|
| 285 | + $post_type = get_query_var('post_type');
|
|
| 286 | + if(is_array($post_type)){$post_type = reset($post_type);}
|
|
| 287 | + if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax()) |
|
| 288 | + return true; |
|
| 289 | + |
|
| 290 | + break; |
|
| 291 | + case 'listing': |
|
| 292 | + if (is_tax() && geodir_get_taxonomy_posttype()) {
|
|
| 293 | + global $current_term, $taxonomy, $term; |
|
| 294 | + |
|
| 295 | + return true; |
|
| 296 | + } |
|
| 297 | + $post_type = get_query_var('post_type');
|
|
| 298 | + if(is_array($post_type)){$post_type = reset($post_type);}
|
|
| 299 | + if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes())) |
|
| 300 | + return true; |
|
| 301 | + |
|
| 302 | + break; |
|
| 303 | + case 'home': |
|
| 304 | + |
|
| 305 | + if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
|
|
| 306 | + return true; |
|
| 307 | + |
|
| 308 | + break; |
|
| 309 | + case 'location': |
|
| 310 | + if (is_page() && get_query_var('page_id') == geodir_location_page_id())
|
|
| 311 | + return true; |
|
| 312 | + break; |
|
| 313 | + case 'author': |
|
| 314 | + if (is_author() && isset($_REQUEST['geodir_dashbord'])) |
|
| 315 | + return true; |
|
| 316 | 316 | |
| 317 | 317 | if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
|
| 318 | 318 | if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
|
| 319 | 319 | return true; |
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | - break; |
|
| 323 | - case 'search': |
|
| 324 | - if (is_search() && isset($_REQUEST['geodir_search'])) |
|
| 325 | - return true; |
|
| 326 | - break; |
|
| 327 | - case 'info': |
|
| 328 | - if (is_page() && get_query_var('page_id') == geodir_info_page_id())
|
|
| 329 | - return true; |
|
| 330 | - break; |
|
| 331 | - case 'login': |
|
| 332 | - if (is_page() && get_query_var('page_id') == geodir_login_page_id())
|
|
| 333 | - return true; |
|
| 334 | - break; |
|
| 335 | - case 'checkout': |
|
| 336 | - if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
|
|
| 337 | - return true; |
|
| 338 | - break; |
|
| 339 | - case 'invoices': |
|
| 340 | - if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
|
|
| 341 | - return true; |
|
| 342 | - break; |
|
| 343 | - default: |
|
| 344 | - return false; |
|
| 345 | - break; |
|
| 346 | - |
|
| 347 | - endswitch; |
|
| 348 | - |
|
| 349 | - //endif; |
|
| 350 | - |
|
| 351 | - return false; |
|
| 322 | + break; |
|
| 323 | + case 'search': |
|
| 324 | + if (is_search() && isset($_REQUEST['geodir_search'])) |
|
| 325 | + return true; |
|
| 326 | + break; |
|
| 327 | + case 'info': |
|
| 328 | + if (is_page() && get_query_var('page_id') == geodir_info_page_id())
|
|
| 329 | + return true; |
|
| 330 | + break; |
|
| 331 | + case 'login': |
|
| 332 | + if (is_page() && get_query_var('page_id') == geodir_login_page_id())
|
|
| 333 | + return true; |
|
| 334 | + break; |
|
| 335 | + case 'checkout': |
|
| 336 | + if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
|
|
| 337 | + return true; |
|
| 338 | + break; |
|
| 339 | + case 'invoices': |
|
| 340 | + if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
|
|
| 341 | + return true; |
|
| 342 | + break; |
|
| 343 | + default: |
|
| 344 | + return false; |
|
| 345 | + break; |
|
| 346 | + |
|
| 347 | + endswitch; |
|
| 348 | + |
|
| 349 | + //endif; |
|
| 350 | + |
|
| 351 | + return false; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /** |
@@ -362,97 +362,97 @@ discard block |
||
| 362 | 362 | */ |
| 363 | 363 | function geodir_set_is_geodir_page($wp) |
| 364 | 364 | {
|
| 365 | - if (!is_admin()) {
|
|
| 366 | - //$wp->query_vars['gd_is_geodir_page'] = false; |
|
| 367 | - //print_r() |
|
| 368 | - if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
|
|
| 369 | - if (get_option('geodir_set_as_home'))
|
|
| 370 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 371 | - if(geodir_is_page('home')){
|
|
| 372 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['page_id'])) {
|
|
| 379 | - if ( |
|
| 380 | - $wp->query_vars['page_id'] == geodir_add_listing_page_id() |
|
| 381 | - || $wp->query_vars['page_id'] == geodir_preview_page_id() |
|
| 382 | - || $wp->query_vars['page_id'] == geodir_success_page_id() |
|
| 383 | - || $wp->query_vars['page_id'] == geodir_location_page_id() |
|
| 384 | - || $wp->query_vars['page_id'] == geodir_home_page_id() |
|
| 385 | - || $wp->query_vars['page_id'] == geodir_info_page_id() |
|
| 386 | - || $wp->query_vars['page_id'] == geodir_login_page_id() |
|
| 387 | - || (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
|
|
| 388 | - || (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
|
|
| 389 | - ) |
|
| 390 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
|
|
| 394 | - $page = get_page_by_path($wp->query_vars['pagename']); |
|
| 395 | - |
|
| 396 | - if (!empty($page) && ( |
|
| 397 | - $page->ID == geodir_add_listing_page_id() |
|
| 398 | - || $page->ID == geodir_preview_page_id() |
|
| 399 | - || $page->ID == geodir_success_page_id() |
|
| 400 | - || $page->ID == geodir_location_page_id() |
|
| 401 | - || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_home_page_id()) |
|
| 402 | - || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_info_page_id()) |
|
| 403 | - || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_login_page_id()) |
|
| 404 | - || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
|
|
| 405 | - || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
|
|
| 406 | - ) |
|
| 407 | - ) |
|
| 408 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - |
|
| 412 | - if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
|
|
| 413 | - $requested_post_type = $wp->query_vars['post_type']; |
|
| 414 | - // check if this post type is geodirectory post types |
|
| 415 | - $post_type_array = geodir_get_posttypes(); |
|
| 416 | - if (in_array($requested_post_type, $post_type_array)) {
|
|
| 417 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 418 | - } |
|
| 419 | - } |
|
| 420 | - |
|
| 421 | - if (!isset($wp->query_vars['gd_is_geodir_page'])) {
|
|
| 422 | - $geodir_taxonomis = geodir_get_taxonomies('', true);
|
|
| 423 | - if(!empty($geodir_taxonomis)){
|
|
| 424 | - foreach ($geodir_taxonomis as $taxonomy) {
|
|
| 425 | - if (array_key_exists($taxonomy, $wp->query_vars)) {
|
|
| 426 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 427 | - break; |
|
| 428 | - } |
|
| 429 | - } |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - } |
|
| 433 | - |
|
| 434 | - if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord'])) |
|
| 435 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 436 | - |
|
| 437 | - |
|
| 438 | - if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) |
|
| 439 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 365 | + if (!is_admin()) {
|
|
| 366 | + //$wp->query_vars['gd_is_geodir_page'] = false; |
|
| 367 | + //print_r() |
|
| 368 | + if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
|
|
| 369 | + if (get_option('geodir_set_as_home'))
|
|
| 370 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 371 | + if(geodir_is_page('home')){
|
|
| 372 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['page_id'])) {
|
|
| 379 | + if ( |
|
| 380 | + $wp->query_vars['page_id'] == geodir_add_listing_page_id() |
|
| 381 | + || $wp->query_vars['page_id'] == geodir_preview_page_id() |
|
| 382 | + || $wp->query_vars['page_id'] == geodir_success_page_id() |
|
| 383 | + || $wp->query_vars['page_id'] == geodir_location_page_id() |
|
| 384 | + || $wp->query_vars['page_id'] == geodir_home_page_id() |
|
| 385 | + || $wp->query_vars['page_id'] == geodir_info_page_id() |
|
| 386 | + || $wp->query_vars['page_id'] == geodir_login_page_id() |
|
| 387 | + || (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
|
|
| 388 | + || (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
|
|
| 389 | + ) |
|
| 390 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
|
|
| 394 | + $page = get_page_by_path($wp->query_vars['pagename']); |
|
| 395 | + |
|
| 396 | + if (!empty($page) && ( |
|
| 397 | + $page->ID == geodir_add_listing_page_id() |
|
| 398 | + || $page->ID == geodir_preview_page_id() |
|
| 399 | + || $page->ID == geodir_success_page_id() |
|
| 400 | + || $page->ID == geodir_location_page_id() |
|
| 401 | + || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_home_page_id()) |
|
| 402 | + || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_info_page_id()) |
|
| 403 | + || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_login_page_id()) |
|
| 404 | + || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
|
|
| 405 | + || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
|
|
| 406 | + ) |
|
| 407 | + ) |
|
| 408 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + |
|
| 412 | + if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['post_type']) && $wp->query_vars['post_type'] != '') {
|
|
| 413 | + $requested_post_type = $wp->query_vars['post_type']; |
|
| 414 | + // check if this post type is geodirectory post types |
|
| 415 | + $post_type_array = geodir_get_posttypes(); |
|
| 416 | + if (in_array($requested_post_type, $post_type_array)) {
|
|
| 417 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 418 | + } |
|
| 419 | + } |
|
| 420 | + |
|
| 421 | + if (!isset($wp->query_vars['gd_is_geodir_page'])) {
|
|
| 422 | + $geodir_taxonomis = geodir_get_taxonomies('', true);
|
|
| 423 | + if(!empty($geodir_taxonomis)){
|
|
| 424 | + foreach ($geodir_taxonomis as $taxonomy) {
|
|
| 425 | + if (array_key_exists($taxonomy, $wp->query_vars)) {
|
|
| 426 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 427 | + break; |
|
| 428 | + } |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + } |
|
| 433 | + |
|
| 434 | + if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord'])) |
|
| 435 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 436 | + |
|
| 437 | + |
|
| 438 | + if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) |
|
| 439 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 440 | 440 | |
| 441 | 441 | |
| 442 | 442 | //check if homepage |
| 443 | - if(!isset($wp->query_vars['gd_is_geodir_page']) |
|
| 444 | - && !isset($wp->query_vars['page_id']) |
|
| 445 | - && !isset($wp->query_vars['pagename']) |
|
| 446 | - && is_page_geodir_home()){
|
|
| 447 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 448 | - } |
|
| 449 | - //echo $wp->query_vars['gd_is_geodir_page'] ; |
|
| 450 | - /*echo "<pre>" ; |
|
| 443 | + if(!isset($wp->query_vars['gd_is_geodir_page']) |
|
| 444 | + && !isset($wp->query_vars['page_id']) |
|
| 445 | + && !isset($wp->query_vars['pagename']) |
|
| 446 | + && is_page_geodir_home()){
|
|
| 447 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 448 | + } |
|
| 449 | + //echo $wp->query_vars['gd_is_geodir_page'] ; |
|
| 450 | + /*echo "<pre>" ; |
|
| 451 | 451 | print_r($wp) ; |
| 452 | 452 | echo "</pre>" ; |
| 453 | 453 | // exit(); |
| 454 | 454 | */ |
| 455 | - } // end of is admin |
|
| 455 | + } // end of is admin |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
@@ -465,56 +465,56 @@ discard block |
||
| 465 | 465 | */ |
| 466 | 466 | function geodir_is_geodir_page() |
| 467 | 467 | {
|
| 468 | - global $wp; |
|
| 469 | - if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page']) |
|
| 470 | - return true; |
|
| 471 | - else |
|
| 472 | - return false; |
|
| 468 | + global $wp; |
|
| 469 | + if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page']) |
|
| 470 | + return true; |
|
| 471 | + else |
|
| 472 | + return false; |
|
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | if (!function_exists('geodir_get_imagesize')) {
|
| 476 | - /** |
|
| 477 | - * Get image size using the size key . |
|
| 478 | - * |
|
| 479 | - * @since 1.0.0 |
|
| 480 | - * @package GeoDirectory |
|
| 481 | - * @param string $size The image size key. |
|
| 482 | - * @return array|mixed|void|WP_Error If valid returns image size. Else returns error. |
|
| 483 | - */ |
|
| 484 | - function geodir_get_imagesize($size = '') |
|
| 485 | - {
|
|
| 486 | - |
|
| 487 | - $imagesizes = array('list-thumb' => array('w' => 283, 'h' => 188),
|
|
| 488 | - 'thumbnail' => array('w' => 125, 'h' => 125),
|
|
| 489 | - 'widget-thumb' => array('w' => 50, 'h' => 50),
|
|
| 490 | - 'slider-thumb' => array('w' => 100, 'h' => 100)
|
|
| 491 | - ); |
|
| 492 | - |
|
| 493 | - /** |
|
| 494 | - * Filter the image sizes array. |
|
| 495 | - * |
|
| 496 | - * @since 1.0.0 |
|
| 497 | - * @param array $imagesizes Image size array. |
|
| 498 | - */ |
|
| 499 | - $imagesizes = apply_filters('geodir_imagesizes', $imagesizes);
|
|
| 500 | - |
|
| 501 | - if (!empty($size) && array_key_exists($size, $imagesizes)) {
|
|
| 502 | - /** |
|
| 503 | - * Filters image size of the passed key. |
|
| 504 | - * |
|
| 505 | - * @since 1.0.0 |
|
| 506 | - * @param array $imagesizes[$size] Image size array of the passed key. |
|
| 507 | - */ |
|
| 508 | - return apply_filters('geodir_get_imagesize_' . $size, $imagesizes[$size]);
|
|
| 509 | - |
|
| 510 | - } elseif (!empty($size)) {
|
|
| 511 | - |
|
| 512 | - return new WP_Error('geodir_no_imagesize', __("Given image size is not valid", 'geodirectory'));
|
|
| 513 | - |
|
| 514 | - } |
|
| 515 | - |
|
| 516 | - return $imagesizes; |
|
| 517 | - } |
|
| 476 | + /** |
|
| 477 | + * Get image size using the size key . |
|
| 478 | + * |
|
| 479 | + * @since 1.0.0 |
|
| 480 | + * @package GeoDirectory |
|
| 481 | + * @param string $size The image size key. |
|
| 482 | + * @return array|mixed|void|WP_Error If valid returns image size. Else returns error. |
|
| 483 | + */ |
|
| 484 | + function geodir_get_imagesize($size = '') |
|
| 485 | + {
|
|
| 486 | + |
|
| 487 | + $imagesizes = array('list-thumb' => array('w' => 283, 'h' => 188),
|
|
| 488 | + 'thumbnail' => array('w' => 125, 'h' => 125),
|
|
| 489 | + 'widget-thumb' => array('w' => 50, 'h' => 50),
|
|
| 490 | + 'slider-thumb' => array('w' => 100, 'h' => 100)
|
|
| 491 | + ); |
|
| 492 | + |
|
| 493 | + /** |
|
| 494 | + * Filter the image sizes array. |
|
| 495 | + * |
|
| 496 | + * @since 1.0.0 |
|
| 497 | + * @param array $imagesizes Image size array. |
|
| 498 | + */ |
|
| 499 | + $imagesizes = apply_filters('geodir_imagesizes', $imagesizes);
|
|
| 500 | + |
|
| 501 | + if (!empty($size) && array_key_exists($size, $imagesizes)) {
|
|
| 502 | + /** |
|
| 503 | + * Filters image size of the passed key. |
|
| 504 | + * |
|
| 505 | + * @since 1.0.0 |
|
| 506 | + * @param array $imagesizes[$size] Image size array of the passed key. |
|
| 507 | + */ |
|
| 508 | + return apply_filters('geodir_get_imagesize_' . $size, $imagesizes[$size]);
|
|
| 509 | + |
|
| 510 | + } elseif (!empty($size)) {
|
|
| 511 | + |
|
| 512 | + return new WP_Error('geodir_no_imagesize', __("Given image size is not valid", 'geodirectory'));
|
|
| 513 | + |
|
| 514 | + } |
|
| 515 | + |
|
| 516 | + return $imagesizes; |
|
| 517 | + } |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | /** |
@@ -534,151 +534,151 @@ discard block |
||
| 534 | 534 | |
| 535 | 535 | |
| 536 | 536 | if (!function_exists('createRandomString')) {
|
| 537 | - /** |
|
| 538 | - * Creates random string. |
|
| 539 | - * |
|
| 540 | - * @since 1.0.0 |
|
| 541 | - * @package GeoDirectory |
|
| 542 | - * @return string Random string. |
|
| 543 | - */ |
|
| 544 | - function createRandomString() |
|
| 545 | - {
|
|
| 546 | - $chars = "abcdefghijkmlnopqrstuvwxyz1023456789"; |
|
| 547 | - srand((double)microtime() * 1000000); |
|
| 548 | - $i = 0; |
|
| 549 | - $rstring = ''; |
|
| 550 | - while ($i <= 25) {
|
|
| 551 | - $num = rand() % 33; |
|
| 552 | - $tmp = substr($chars, $num, 1); |
|
| 553 | - $rstring = $rstring . $tmp; |
|
| 554 | - $i++; |
|
| 555 | - } |
|
| 556 | - return $rstring; |
|
| 557 | - } |
|
| 537 | + /** |
|
| 538 | + * Creates random string. |
|
| 539 | + * |
|
| 540 | + * @since 1.0.0 |
|
| 541 | + * @package GeoDirectory |
|
| 542 | + * @return string Random string. |
|
| 543 | + */ |
|
| 544 | + function createRandomString() |
|
| 545 | + {
|
|
| 546 | + $chars = "abcdefghijkmlnopqrstuvwxyz1023456789"; |
|
| 547 | + srand((double)microtime() * 1000000); |
|
| 548 | + $i = 0; |
|
| 549 | + $rstring = ''; |
|
| 550 | + while ($i <= 25) {
|
|
| 551 | + $num = rand() % 33; |
|
| 552 | + $tmp = substr($chars, $num, 1); |
|
| 553 | + $rstring = $rstring . $tmp; |
|
| 554 | + $i++; |
|
| 555 | + } |
|
| 556 | + return $rstring; |
|
| 557 | + } |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | if (!function_exists('geodir_getDistanceRadius')) {
|
| 561 | - /** |
|
| 562 | - * Calculates the distance radius. |
|
| 563 | - * |
|
| 564 | - * @since 1.0.0 |
|
| 565 | - * @package GeoDirectory |
|
| 566 | - * @param string $uom Measurement unit type. |
|
| 567 | - * @return float The mean radius. |
|
| 568 | - */ |
|
| 569 | - function geodir_getDistanceRadius($uom = 'km') |
|
| 570 | - {
|
|
| 561 | + /** |
|
| 562 | + * Calculates the distance radius. |
|
| 563 | + * |
|
| 564 | + * @since 1.0.0 |
|
| 565 | + * @package GeoDirectory |
|
| 566 | + * @param string $uom Measurement unit type. |
|
| 567 | + * @return float The mean radius. |
|
| 568 | + */ |
|
| 569 | + function geodir_getDistanceRadius($uom = 'km') |
|
| 570 | + {
|
|
| 571 | 571 | // Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude |
| 572 | - switch (geodir_strtolower($uom)): |
|
| 573 | - case 'km' : |
|
| 574 | - $earthMeanRadius = 6371.009; // km |
|
| 575 | - break; |
|
| 576 | - case 'm' : |
|
| 577 | - case 'meters' : |
|
| 578 | - $earthMeanRadius = 6371.009 * 1000; // km |
|
| 579 | - break; |
|
| 580 | - case 'miles' : |
|
| 581 | - $earthMeanRadius = 3958.761; // miles |
|
| 582 | - break; |
|
| 583 | - case 'yards' : |
|
| 584 | - case 'yds' : |
|
| 585 | - $earthMeanRadius = 3958.761 * 1760; // yards |
|
| 586 | - break; |
|
| 587 | - case 'feet' : |
|
| 588 | - case 'ft' : |
|
| 589 | - $earthMeanRadius = 3958.761 * 1760 * 3; // feet |
|
| 590 | - break; |
|
| 591 | - case 'nm' : |
|
| 592 | - $earthMeanRadius = 3440.069; // miles |
|
| 593 | - break; |
|
| 594 | - default: |
|
| 595 | - $earthMeanRadius = 3958.761; // miles |
|
| 596 | - break; |
|
| 597 | - endswitch; |
|
| 598 | - return $earthMeanRadius; |
|
| 599 | - } |
|
| 572 | + switch (geodir_strtolower($uom)): |
|
| 573 | + case 'km' : |
|
| 574 | + $earthMeanRadius = 6371.009; // km |
|
| 575 | + break; |
|
| 576 | + case 'm' : |
|
| 577 | + case 'meters' : |
|
| 578 | + $earthMeanRadius = 6371.009 * 1000; // km |
|
| 579 | + break; |
|
| 580 | + case 'miles' : |
|
| 581 | + $earthMeanRadius = 3958.761; // miles |
|
| 582 | + break; |
|
| 583 | + case 'yards' : |
|
| 584 | + case 'yds' : |
|
| 585 | + $earthMeanRadius = 3958.761 * 1760; // yards |
|
| 586 | + break; |
|
| 587 | + case 'feet' : |
|
| 588 | + case 'ft' : |
|
| 589 | + $earthMeanRadius = 3958.761 * 1760 * 3; // feet |
|
| 590 | + break; |
|
| 591 | + case 'nm' : |
|
| 592 | + $earthMeanRadius = 3440.069; // miles |
|
| 593 | + break; |
|
| 594 | + default: |
|
| 595 | + $earthMeanRadius = 3958.761; // miles |
|
| 596 | + break; |
|
| 597 | + endswitch; |
|
| 598 | + return $earthMeanRadius; |
|
| 599 | + } |
|
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | |
| 603 | 603 | if (!function_exists('geodir_calculateDistanceFromLatLong')) {
|
| 604 | - /** |
|
| 605 | - * Calculate the great circle distance between two points identified by longitude and latitude. |
|
| 606 | - * |
|
| 607 | - * @since 1.0.0 |
|
| 608 | - * @package GeoDirectory |
|
| 609 | - * @param array $point1 Latitude and Longitude of point 1. |
|
| 610 | - * @param array $point2 Latitude and Longitude of point 2. |
|
| 611 | - * @param string $uom Unit of measurement. |
|
| 612 | - * @return float The distance. |
|
| 613 | - */ |
|
| 614 | - function geodir_calculateDistanceFromLatLong($point1, $point2, $uom = 'km') |
|
| 615 | - {
|
|
| 604 | + /** |
|
| 605 | + * Calculate the great circle distance between two points identified by longitude and latitude. |
|
| 606 | + * |
|
| 607 | + * @since 1.0.0 |
|
| 608 | + * @package GeoDirectory |
|
| 609 | + * @param array $point1 Latitude and Longitude of point 1. |
|
| 610 | + * @param array $point2 Latitude and Longitude of point 2. |
|
| 611 | + * @param string $uom Unit of measurement. |
|
| 612 | + * @return float The distance. |
|
| 613 | + */ |
|
| 614 | + function geodir_calculateDistanceFromLatLong($point1, $point2, $uom = 'km') |
|
| 615 | + {
|
|
| 616 | 616 | // Use Haversine formula to calculate the great circle distance between two points identified by longitude and latitude |
| 617 | 617 | |
| 618 | - $earthMeanRadius = geodir_getDistanceRadius($uom); |
|
| 618 | + $earthMeanRadius = geodir_getDistanceRadius($uom); |
|
| 619 | 619 | |
| 620 | - $deltaLatitude = deg2rad((float) $point2['latitude'] - (float) $point1['latitude']); |
|
| 621 | - $deltaLongitude = deg2rad((float) $point2['longitude'] - (float) $point1['longitude']); |
|
| 622 | - $a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) + |
|
| 623 | - cos(deg2rad((float) $point1['latitude'])) * cos(deg2rad((float) $point2['latitude'])) * |
|
| 624 | - sin($deltaLongitude / 2) * sin($deltaLongitude / 2); |
|
| 625 | - $c = 2 * atan2(sqrt($a), sqrt(1 - $a)); |
|
| 626 | - $distance = $earthMeanRadius * $c; |
|
| 627 | - return $distance; |
|
| 620 | + $deltaLatitude = deg2rad((float) $point2['latitude'] - (float) $point1['latitude']); |
|
| 621 | + $deltaLongitude = deg2rad((float) $point2['longitude'] - (float) $point1['longitude']); |
|
| 622 | + $a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) + |
|
| 623 | + cos(deg2rad((float) $point1['latitude'])) * cos(deg2rad((float) $point2['latitude'])) * |
|
| 624 | + sin($deltaLongitude / 2) * sin($deltaLongitude / 2); |
|
| 625 | + $c = 2 * atan2(sqrt($a), sqrt(1 - $a)); |
|
| 626 | + $distance = $earthMeanRadius * $c; |
|
| 627 | + return $distance; |
|
| 628 | 628 | |
| 629 | - } |
|
| 629 | + } |
|
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | |
| 633 | 633 | if (!function_exists('geodir_sendEmail')) {
|
| 634 | - /** |
|
| 635 | - * The main function that send transactional emails using the args provided. |
|
| 636 | - * |
|
| 637 | - * @since 1.0.0 |
|
| 638 | - * @since 1.5.7 Added db translations for notifications subject and content. |
|
| 639 | - * @package GeoDirectory |
|
| 640 | - * @param string $fromEmail Sender email address. |
|
| 641 | - * @param string $fromEmailName Sender name. |
|
| 642 | - * @param string $toEmail Receiver email address. |
|
| 643 | - * @param string $toEmailName Receiver name. |
|
| 644 | - * @param string $to_subject Email subject. |
|
| 645 | - * @param string $to_message Email content. |
|
| 646 | - * @param string $extra Not being used. |
|
| 647 | - * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published. |
|
| 648 | - * @param string $post_id The post ID. |
|
| 649 | - * @param string $user_id The user ID. |
|
| 650 | - */ |
|
| 651 | - function geodir_sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') {
|
|
| 652 | - $login_details = ''; |
|
| 653 | - |
|
| 654 | - // strip slashes from subject & message text |
|
| 655 | - $to_subject = stripslashes_deep($to_subject); |
|
| 656 | - $to_message = stripslashes_deep($to_message); |
|
| 657 | - |
|
| 658 | - if ($message_type == 'send_friend') {
|
|
| 659 | - $subject = get_option('geodir_email_friend_subject');
|
|
| 660 | - $message = get_option('geodir_email_friend_content');
|
|
| 661 | - } elseif ($message_type == 'send_enquiry') {
|
|
| 662 | - $subject = get_option('geodir_email_enquiry_subject');
|
|
| 663 | - $message = get_option('geodir_email_enquiry_content');
|
|
| 664 | - } elseif ($message_type == 'forgot_password') {
|
|
| 665 | - $subject = get_option('geodir_forgot_password_subject');
|
|
| 666 | - $message = get_option('geodir_forgot_password_content');
|
|
| 667 | - $login_details = $to_message; |
|
| 668 | - } elseif ($message_type == 'registration') {
|
|
| 669 | - $subject = get_option('geodir_registration_success_email_subject');
|
|
| 670 | - $message = get_option('geodir_registration_success_email_content');
|
|
| 671 | - $login_details = $to_message; |
|
| 672 | - } elseif ($message_type == 'post_submit') {
|
|
| 673 | - $subject = get_option('geodir_post_submited_success_email_subject');
|
|
| 674 | - $message = get_option('geodir_post_submited_success_email_content');
|
|
| 675 | - } elseif ($message_type == 'listing_published') {
|
|
| 676 | - $subject = get_option('geodir_post_published_email_subject');
|
|
| 677 | - $message = get_option('geodir_post_published_email_content');
|
|
| 678 | - } elseif ($message_type == 'listing_edited') {
|
|
| 679 | - $subject = get_option('geodir_post_edited_email_subject_admin');
|
|
| 680 | - $message = get_option('geodir_post_edited_email_content_admin');
|
|
| 681 | - } |
|
| 634 | + /** |
|
| 635 | + * The main function that send transactional emails using the args provided. |
|
| 636 | + * |
|
| 637 | + * @since 1.0.0 |
|
| 638 | + * @since 1.5.7 Added db translations for notifications subject and content. |
|
| 639 | + * @package GeoDirectory |
|
| 640 | + * @param string $fromEmail Sender email address. |
|
| 641 | + * @param string $fromEmailName Sender name. |
|
| 642 | + * @param string $toEmail Receiver email address. |
|
| 643 | + * @param string $toEmailName Receiver name. |
|
| 644 | + * @param string $to_subject Email subject. |
|
| 645 | + * @param string $to_message Email content. |
|
| 646 | + * @param string $extra Not being used. |
|
| 647 | + * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published. |
|
| 648 | + * @param string $post_id The post ID. |
|
| 649 | + * @param string $user_id The user ID. |
|
| 650 | + */ |
|
| 651 | + function geodir_sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') {
|
|
| 652 | + $login_details = ''; |
|
| 653 | + |
|
| 654 | + // strip slashes from subject & message text |
|
| 655 | + $to_subject = stripslashes_deep($to_subject); |
|
| 656 | + $to_message = stripslashes_deep($to_message); |
|
| 657 | + |
|
| 658 | + if ($message_type == 'send_friend') {
|
|
| 659 | + $subject = get_option('geodir_email_friend_subject');
|
|
| 660 | + $message = get_option('geodir_email_friend_content');
|
|
| 661 | + } elseif ($message_type == 'send_enquiry') {
|
|
| 662 | + $subject = get_option('geodir_email_enquiry_subject');
|
|
| 663 | + $message = get_option('geodir_email_enquiry_content');
|
|
| 664 | + } elseif ($message_type == 'forgot_password') {
|
|
| 665 | + $subject = get_option('geodir_forgot_password_subject');
|
|
| 666 | + $message = get_option('geodir_forgot_password_content');
|
|
| 667 | + $login_details = $to_message; |
|
| 668 | + } elseif ($message_type == 'registration') {
|
|
| 669 | + $subject = get_option('geodir_registration_success_email_subject');
|
|
| 670 | + $message = get_option('geodir_registration_success_email_content');
|
|
| 671 | + $login_details = $to_message; |
|
| 672 | + } elseif ($message_type == 'post_submit') {
|
|
| 673 | + $subject = get_option('geodir_post_submited_success_email_subject');
|
|
| 674 | + $message = get_option('geodir_post_submited_success_email_content');
|
|
| 675 | + } elseif ($message_type == 'listing_published') {
|
|
| 676 | + $subject = get_option('geodir_post_published_email_subject');
|
|
| 677 | + $message = get_option('geodir_post_published_email_content');
|
|
| 678 | + } elseif ($message_type == 'listing_edited') {
|
|
| 679 | + $subject = get_option('geodir_post_edited_email_subject_admin');
|
|
| 680 | + $message = get_option('geodir_post_edited_email_content_admin');
|
|
| 681 | + } |
|
| 682 | 682 | |
| 683 | 683 | if (!empty($subject)) {
|
| 684 | 684 | $subject = __(stripslashes_deep($subject),'geodirectory'); |
@@ -688,203 +688,203 @@ discard block |
||
| 688 | 688 | $message = __(stripslashes_deep($message),'geodirectory'); |
| 689 | 689 | } |
| 690 | 690 | |
| 691 | - $to_message = nl2br($to_message); |
|
| 692 | - $sitefromEmail = get_option('site_email');
|
|
| 693 | - $sitefromEmailName = get_site_emailName(); |
|
| 694 | - $productlink = get_permalink($post_id); |
|
| 695 | - |
|
| 696 | - $user_login = ''; |
|
| 697 | - if ($user_id > 0 && $user_info = get_userdata($user_id)) {
|
|
| 698 | - $user_login = $user_info->user_login; |
|
| 699 | - } |
|
| 700 | - |
|
| 701 | - $posted_date = ''; |
|
| 702 | - $listingLink = ''; |
|
| 703 | - |
|
| 704 | - $post_info = get_post($post_id); |
|
| 705 | - |
|
| 706 | - if ($post_info) {
|
|
| 707 | - $posted_date = $post_info->post_date; |
|
| 708 | - $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 709 | - } |
|
| 710 | - $siteurl = home_url(); |
|
| 711 | - $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; |
|
| 712 | - $loginurl = geodir_login_url(); |
|
| 713 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 691 | + $to_message = nl2br($to_message); |
|
| 692 | + $sitefromEmail = get_option('site_email');
|
|
| 693 | + $sitefromEmailName = get_site_emailName(); |
|
| 694 | + $productlink = get_permalink($post_id); |
|
| 695 | + |
|
| 696 | + $user_login = ''; |
|
| 697 | + if ($user_id > 0 && $user_info = get_userdata($user_id)) {
|
|
| 698 | + $user_login = $user_info->user_login; |
|
| 699 | + } |
|
| 700 | + |
|
| 701 | + $posted_date = ''; |
|
| 702 | + $listingLink = ''; |
|
| 703 | + |
|
| 704 | + $post_info = get_post($post_id); |
|
| 705 | + |
|
| 706 | + if ($post_info) {
|
|
| 707 | + $posted_date = $post_info->post_date; |
|
| 708 | + $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 709 | + } |
|
| 710 | + $siteurl = home_url(); |
|
| 711 | + $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; |
|
| 712 | + $loginurl = geodir_login_url(); |
|
| 713 | + $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 714 | 714 | |
| 715 | - $post_author_id = !empty($post_info) ? $post_info->post_author : 0; |
|
| 716 | - $post_author_name = geodir_get_client_name($post_author_id); |
|
| 717 | - $current_date = date_i18n('Y-m-d H:i:s', current_time('timestamp'));
|
|
| 718 | - |
|
| 719 | - if ($fromEmail == '') {
|
|
| 720 | - $fromEmail = get_option('site_email');
|
|
| 721 | - } |
|
| 722 | - |
|
| 723 | - if ($fromEmailName == '') {
|
|
| 724 | - $fromEmailName = get_option('site_email_name');
|
|
| 725 | - } |
|
| 726 | - |
|
| 727 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
|
|
| 728 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date); |
|
| 729 | - $message = str_replace($search_array, $replace_array, $message); |
|
| 730 | - |
|
| 731 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
|
|
| 732 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date); |
|
| 733 | - $subject = str_replace($search_array, $replace_array, $subject); |
|
| 734 | - |
|
| 735 | - $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 736 | - $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 737 | - $headers .= "Reply-To: " . $fromEmail . "\r\n"; |
|
| 738 | - $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n"; |
|
| 739 | - |
|
| 740 | - $to = $toEmail; |
|
| 741 | - |
|
| 742 | - /** |
|
| 743 | - * Filter the client email to address. |
|
| 744 | - * |
|
| 745 | - * @since 1.6.1 |
|
| 746 | - * @package GeoDirectory |
|
| 747 | - * @param string $to The email address the email is being sent to. |
|
| 748 | - * @param string $fromEmail Sender email address. |
|
| 749 | - * @param string $fromEmailName Sender name. |
|
| 750 | - * @param string $toEmail Receiver email address. |
|
| 751 | - * @param string $toEmailName Receiver name. |
|
| 752 | - * @param string $to_subject Email subject. |
|
| 753 | - * @param string $to_message Email content. |
|
| 754 | - * @param string $extra Not being used. |
|
| 755 | - * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published. |
|
| 756 | - * @param string $post_id The post ID. |
|
| 757 | - * @param string $user_id The user ID. |
|
| 758 | - */ |
|
| 759 | - $to = apply_filters('geodir_sendEmail_to',$to,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
|
| 760 | - /** |
|
| 761 | - * Filter the client email subject. |
|
| 762 | - * |
|
| 763 | - * @since 1.6.1 |
|
| 764 | - * @package GeoDirectory_Payment_Manager |
|
| 765 | - * @param string $subject The email subject. |
|
| 766 | - * @param string $fromEmail Sender email address. |
|
| 767 | - * @param string $fromEmailName Sender name. |
|
| 768 | - * @param string $toEmail Receiver email address. |
|
| 769 | - * @param string $toEmailName Receiver name. |
|
| 770 | - * @param string $to_subject Email subject. |
|
| 771 | - * @param string $to_message Email content. |
|
| 772 | - * @param string $extra Not being used. |
|
| 773 | - * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published. |
|
| 774 | - * @param string $post_id The post ID. |
|
| 775 | - * @param string $user_id The user ID. |
|
| 776 | - */ |
|
| 777 | - $subject = apply_filters('geodir_sendEmail_subject',$subject,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
|
| 778 | - /** |
|
| 779 | - * Filter the client email message. |
|
| 780 | - * |
|
| 781 | - * @since 1.6.1 |
|
| 782 | - * @package GeoDirectory_Payment_Manager |
|
| 783 | - * @param string $message The email message text. |
|
| 784 | - * @param string $fromEmail Sender email address. |
|
| 785 | - * @param string $fromEmailName Sender name. |
|
| 786 | - * @param string $toEmail Receiver email address. |
|
| 787 | - * @param string $toEmailName Receiver name. |
|
| 788 | - * @param string $to_subject Email subject. |
|
| 789 | - * @param string $to_message Email content. |
|
| 790 | - * @param string $extra Not being used. |
|
| 791 | - * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published. |
|
| 792 | - * @param string $post_id The post ID. |
|
| 793 | - * @param string $user_id The user ID. |
|
| 794 | - */ |
|
| 795 | - $message = apply_filters('geodir_sendEmail_message',$message,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
|
| 796 | - /** |
|
| 797 | - * Filter the client email headers. |
|
| 798 | - * |
|
| 799 | - * @since 1.6.1 |
|
| 800 | - * @package GeoDirectory_Payment_Manager |
|
| 801 | - * @param string $headers The email headers. |
|
| 802 | - * @param string $fromEmail Sender email address. |
|
| 803 | - * @param string $fromEmailName Sender name. |
|
| 804 | - * @param string $toEmail Receiver email address. |
|
| 805 | - * @param string $toEmailName Receiver name. |
|
| 806 | - * @param string $to_subject Email subject. |
|
| 807 | - * @param string $to_message Email content. |
|
| 808 | - * @param string $extra Not being used. |
|
| 809 | - * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published. |
|
| 810 | - * @param string $post_id The post ID. |
|
| 811 | - * @param string $user_id The user ID. |
|
| 812 | - */ |
|
| 813 | - $headers = apply_filters('geodir_sendEmail_headers',$headers,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
|
| 814 | - |
|
| 815 | - $sent = wp_mail($to, $subject, $message, $headers); |
|
| 816 | - |
|
| 817 | - if( ! $sent ) {
|
|
| 818 | - if ( is_array( $to ) ) {
|
|
| 819 | - $to = implode( ',', $to ); |
|
| 820 | - } |
|
| 821 | - $log_message = sprintf( |
|
| 822 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 823 | - $message_type, |
|
| 824 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 825 | - $to, |
|
| 826 | - $subject |
|
| 827 | - ); |
|
| 828 | - geodir_error_log( $log_message ); |
|
| 829 | - } |
|
| 830 | - |
|
| 831 | - ///////// ADMIN BCC EMIALS |
|
| 832 | - $adminEmail = get_bloginfo('admin_email');
|
|
| 833 | - $to = $adminEmail; |
|
| 834 | - |
|
| 835 | - $admin_bcc = false; |
|
| 836 | - if ($message_type == 'post_submit') {
|
|
| 837 | - $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
|
|
| 838 | - $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
|
|
| 839 | - |
|
| 840 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
|
|
| 841 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date, $user_login, $user_login); |
|
| 842 | - $message = str_replace($search_array, $replace_array, $message); |
|
| 843 | - |
|
| 844 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
|
|
| 845 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login); |
|
| 846 | - $subject = str_replace($search_array, $replace_array, $subject); |
|
| 847 | - |
|
| 848 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 849 | - $admin_bcc = true; |
|
| 850 | - |
|
| 851 | - } |
|
| 852 | - elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
|
|
| 853 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 854 | - $admin_bcc = true; |
|
| 855 | - } |
|
| 856 | - elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
|
|
| 857 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 858 | - $admin_bcc = true; |
|
| 859 | - } |
|
| 860 | - elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
|
|
| 861 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 862 | - $admin_bcc = true; |
|
| 863 | - } |
|
| 864 | - elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
|
|
| 865 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 866 | - $admin_bcc = true; |
|
| 867 | - } |
|
| 868 | - |
|
| 869 | - if($admin_bcc===true){
|
|
| 870 | - $sent = wp_mail($to, $subject, $message, $headers); |
|
| 871 | - |
|
| 872 | - if( ! $sent ) {
|
|
| 873 | - if ( is_array( $to ) ) {
|
|
| 874 | - $to = implode( ',', $to ); |
|
| 875 | - } |
|
| 876 | - $log_message = sprintf( |
|
| 877 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 878 | - $message_type, |
|
| 879 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 880 | - $to, |
|
| 881 | - $subject |
|
| 882 | - ); |
|
| 883 | - geodir_error_log( $log_message ); |
|
| 884 | - } |
|
| 885 | - } |
|
| 886 | - |
|
| 887 | - } |
|
| 715 | + $post_author_id = !empty($post_info) ? $post_info->post_author : 0; |
|
| 716 | + $post_author_name = geodir_get_client_name($post_author_id); |
|
| 717 | + $current_date = date_i18n('Y-m-d H:i:s', current_time('timestamp'));
|
|
| 718 | + |
|
| 719 | + if ($fromEmail == '') {
|
|
| 720 | + $fromEmail = get_option('site_email');
|
|
| 721 | + } |
|
| 722 | + |
|
| 723 | + if ($fromEmailName == '') {
|
|
| 724 | + $fromEmailName = get_option('site_email_name');
|
|
| 725 | + } |
|
| 726 | + |
|
| 727 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
|
|
| 728 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date); |
|
| 729 | + $message = str_replace($search_array, $replace_array, $message); |
|
| 730 | + |
|
| 731 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
|
|
| 732 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date); |
|
| 733 | + $subject = str_replace($search_array, $replace_array, $subject); |
|
| 734 | + |
|
| 735 | + $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 736 | + $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 737 | + $headers .= "Reply-To: " . $fromEmail . "\r\n"; |
|
| 738 | + $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n"; |
|
| 739 | + |
|
| 740 | + $to = $toEmail; |
|
| 741 | + |
|
| 742 | + /** |
|
| 743 | + * Filter the client email to address. |
|
| 744 | + * |
|
| 745 | + * @since 1.6.1 |
|
| 746 | + * @package GeoDirectory |
|
| 747 | + * @param string $to The email address the email is being sent to. |
|
| 748 | + * @param string $fromEmail Sender email address. |
|
| 749 | + * @param string $fromEmailName Sender name. |
|
| 750 | + * @param string $toEmail Receiver email address. |
|
| 751 | + * @param string $toEmailName Receiver name. |
|
| 752 | + * @param string $to_subject Email subject. |
|
| 753 | + * @param string $to_message Email content. |
|
| 754 | + * @param string $extra Not being used. |
|
| 755 | + * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published. |
|
| 756 | + * @param string $post_id The post ID. |
|
| 757 | + * @param string $user_id The user ID. |
|
| 758 | + */ |
|
| 759 | + $to = apply_filters('geodir_sendEmail_to',$to,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
|
| 760 | + /** |
|
| 761 | + * Filter the client email subject. |
|
| 762 | + * |
|
| 763 | + * @since 1.6.1 |
|
| 764 | + * @package GeoDirectory_Payment_Manager |
|
| 765 | + * @param string $subject The email subject. |
|
| 766 | + * @param string $fromEmail Sender email address. |
|
| 767 | + * @param string $fromEmailName Sender name. |
|
| 768 | + * @param string $toEmail Receiver email address. |
|
| 769 | + * @param string $toEmailName Receiver name. |
|
| 770 | + * @param string $to_subject Email subject. |
|
| 771 | + * @param string $to_message Email content. |
|
| 772 | + * @param string $extra Not being used. |
|
| 773 | + * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published. |
|
| 774 | + * @param string $post_id The post ID. |
|
| 775 | + * @param string $user_id The user ID. |
|
| 776 | + */ |
|
| 777 | + $subject = apply_filters('geodir_sendEmail_subject',$subject,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
|
| 778 | + /** |
|
| 779 | + * Filter the client email message. |
|
| 780 | + * |
|
| 781 | + * @since 1.6.1 |
|
| 782 | + * @package GeoDirectory_Payment_Manager |
|
| 783 | + * @param string $message The email message text. |
|
| 784 | + * @param string $fromEmail Sender email address. |
|
| 785 | + * @param string $fromEmailName Sender name. |
|
| 786 | + * @param string $toEmail Receiver email address. |
|
| 787 | + * @param string $toEmailName Receiver name. |
|
| 788 | + * @param string $to_subject Email subject. |
|
| 789 | + * @param string $to_message Email content. |
|
| 790 | + * @param string $extra Not being used. |
|
| 791 | + * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published. |
|
| 792 | + * @param string $post_id The post ID. |
|
| 793 | + * @param string $user_id The user ID. |
|
| 794 | + */ |
|
| 795 | + $message = apply_filters('geodir_sendEmail_message',$message,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
|
| 796 | + /** |
|
| 797 | + * Filter the client email headers. |
|
| 798 | + * |
|
| 799 | + * @since 1.6.1 |
|
| 800 | + * @package GeoDirectory_Payment_Manager |
|
| 801 | + * @param string $headers The email headers. |
|
| 802 | + * @param string $fromEmail Sender email address. |
|
| 803 | + * @param string $fromEmailName Sender name. |
|
| 804 | + * @param string $toEmail Receiver email address. |
|
| 805 | + * @param string $toEmailName Receiver name. |
|
| 806 | + * @param string $to_subject Email subject. |
|
| 807 | + * @param string $to_message Email content. |
|
| 808 | + * @param string $extra Not being used. |
|
| 809 | + * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration, post_submit, listing_published. |
|
| 810 | + * @param string $post_id The post ID. |
|
| 811 | + * @param string $user_id The user ID. |
|
| 812 | + */ |
|
| 813 | + $headers = apply_filters('geodir_sendEmail_headers',$headers,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
|
| 814 | + |
|
| 815 | + $sent = wp_mail($to, $subject, $message, $headers); |
|
| 816 | + |
|
| 817 | + if( ! $sent ) {
|
|
| 818 | + if ( is_array( $to ) ) {
|
|
| 819 | + $to = implode( ',', $to ); |
|
| 820 | + } |
|
| 821 | + $log_message = sprintf( |
|
| 822 | + __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 823 | + $message_type, |
|
| 824 | + date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 825 | + $to, |
|
| 826 | + $subject |
|
| 827 | + ); |
|
| 828 | + geodir_error_log( $log_message ); |
|
| 829 | + } |
|
| 830 | + |
|
| 831 | + ///////// ADMIN BCC EMIALS |
|
| 832 | + $adminEmail = get_bloginfo('admin_email');
|
|
| 833 | + $to = $adminEmail; |
|
| 834 | + |
|
| 835 | + $admin_bcc = false; |
|
| 836 | + if ($message_type == 'post_submit') {
|
|
| 837 | + $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
|
|
| 838 | + $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
|
|
| 839 | + |
|
| 840 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
|
|
| 841 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date, $user_login, $user_login); |
|
| 842 | + $message = str_replace($search_array, $replace_array, $message); |
|
| 843 | + |
|
| 844 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
|
|
| 845 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login); |
|
| 846 | + $subject = str_replace($search_array, $replace_array, $subject); |
|
| 847 | + |
|
| 848 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 849 | + $admin_bcc = true; |
|
| 850 | + |
|
| 851 | + } |
|
| 852 | + elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
|
|
| 853 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 854 | + $admin_bcc = true; |
|
| 855 | + } |
|
| 856 | + elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
|
|
| 857 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 858 | + $admin_bcc = true; |
|
| 859 | + } |
|
| 860 | + elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
|
|
| 861 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 862 | + $admin_bcc = true; |
|
| 863 | + } |
|
| 864 | + elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
|
|
| 865 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 866 | + $admin_bcc = true; |
|
| 867 | + } |
|
| 868 | + |
|
| 869 | + if($admin_bcc===true){
|
|
| 870 | + $sent = wp_mail($to, $subject, $message, $headers); |
|
| 871 | + |
|
| 872 | + if( ! $sent ) {
|
|
| 873 | + if ( is_array( $to ) ) {
|
|
| 874 | + $to = implode( ',', $to ); |
|
| 875 | + } |
|
| 876 | + $log_message = sprintf( |
|
| 877 | + __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 878 | + $message_type, |
|
| 879 | + date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 880 | + $to, |
|
| 881 | + $subject |
|
| 882 | + ); |
|
| 883 | + geodir_error_log( $log_message ); |
|
| 884 | + } |
|
| 885 | + } |
|
| 886 | + |
|
| 887 | + } |
|
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | |
@@ -897,27 +897,27 @@ discard block |
||
| 897 | 897 | function geodir_taxonomy_breadcrumb() |
| 898 | 898 | {
|
| 899 | 899 | |
| 900 | - $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
|
|
| 901 | - $parent = $term->parent; |
|
| 900 | + $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
|
|
| 901 | + $parent = $term->parent; |
|
| 902 | 902 | |
| 903 | - while ($parent): |
|
| 904 | - $parents[] = $parent; |
|
| 905 | - $new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
|
|
| 906 | - $parent = $new_parent->parent; |
|
| 907 | - endwhile; |
|
| 903 | + while ($parent): |
|
| 904 | + $parents[] = $parent; |
|
| 905 | + $new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
|
|
| 906 | + $parent = $new_parent->parent; |
|
| 907 | + endwhile; |
|
| 908 | 908 | |
| 909 | - if (!empty($parents)): |
|
| 910 | - $parents = array_reverse($parents); |
|
| 909 | + if (!empty($parents)): |
|
| 910 | + $parents = array_reverse($parents); |
|
| 911 | 911 | |
| 912 | - foreach ($parents as $parent): |
|
| 913 | - $item = get_term_by('id', $parent, get_query_var('taxonomy'));
|
|
| 914 | - $url = get_term_link($item, get_query_var('taxonomy'));
|
|
| 915 | - echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>'; |
|
| 916 | - endforeach; |
|
| 912 | + foreach ($parents as $parent): |
|
| 913 | + $item = get_term_by('id', $parent, get_query_var('taxonomy'));
|
|
| 914 | + $url = get_term_link($item, get_query_var('taxonomy'));
|
|
| 915 | + echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>'; |
|
| 916 | + endforeach; |
|
| 917 | 917 | |
| 918 | - endif; |
|
| 918 | + endif; |
|
| 919 | 919 | |
| 920 | - echo '<li> > ' . $term->name . '</li>'; |
|
| 920 | + echo '<li> > ' . $term->name . '</li>'; |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | |
@@ -933,365 +933,365 @@ discard block |
||
| 933 | 933 | */ |
| 934 | 934 | function geodir_breadcrumb() |
| 935 | 935 | {
|
| 936 | - global $wp_query, $geodir_add_location_url; |
|
| 937 | - |
|
| 938 | - /** |
|
| 939 | - * Filter breadcrumb separator. |
|
| 940 | - * |
|
| 941 | - * @since 1.0.0 |
|
| 942 | - */ |
|
| 943 | - $separator = apply_filters('geodir_breadcrumb_separator', ' > ');
|
|
| 944 | - |
|
| 945 | - if (!geodir_is_page('home')) {
|
|
| 946 | - $breadcrumb = ''; |
|
| 947 | - $url_categoris = ''; |
|
| 948 | - $breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">'; |
|
| 949 | - /** |
|
| 950 | - * Filter breadcrumb's first link. |
|
| 951 | - * |
|
| 952 | - * @since 1.0.0 |
|
| 953 | - */ |
|
| 954 | - $breadcrumb .= '<li>' . apply_filters('geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __('Home', 'geodirectory') . '</a>') . '</li>';
|
|
| 955 | - |
|
| 956 | - $gd_post_type = geodir_get_current_posttype(); |
|
| 957 | - $post_type_info = get_post_type_object($gd_post_type); |
|
| 958 | - |
|
| 959 | - remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
|
|
| 960 | - |
|
| 961 | - $listing_link = get_post_type_archive_link($gd_post_type); |
|
| 962 | - |
|
| 963 | - add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
|
|
| 964 | - $listing_link = rtrim($listing_link, '/'); |
|
| 965 | - $listing_link .= '/'; |
|
| 966 | - |
|
| 967 | - $post_type_for_location_link = $listing_link; |
|
| 968 | - $location_terms = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 969 | - |
|
| 970 | - global $wp, $gd_session; |
|
| 971 | - $location_link = $post_type_for_location_link; |
|
| 972 | - |
|
| 973 | - if (geodir_is_page('detail') || geodir_is_page('listing')) {
|
|
| 974 | - global $post; |
|
| 975 | - $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 936 | + global $wp_query, $geodir_add_location_url; |
|
| 937 | + |
|
| 938 | + /** |
|
| 939 | + * Filter breadcrumb separator. |
|
| 940 | + * |
|
| 941 | + * @since 1.0.0 |
|
| 942 | + */ |
|
| 943 | + $separator = apply_filters('geodir_breadcrumb_separator', ' > ');
|
|
| 944 | + |
|
| 945 | + if (!geodir_is_page('home')) {
|
|
| 946 | + $breadcrumb = ''; |
|
| 947 | + $url_categoris = ''; |
|
| 948 | + $breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">'; |
|
| 949 | + /** |
|
| 950 | + * Filter breadcrumb's first link. |
|
| 951 | + * |
|
| 952 | + * @since 1.0.0 |
|
| 953 | + */ |
|
| 954 | + $breadcrumb .= '<li>' . apply_filters('geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __('Home', 'geodirectory') . '</a>') . '</li>';
|
|
| 955 | + |
|
| 956 | + $gd_post_type = geodir_get_current_posttype(); |
|
| 957 | + $post_type_info = get_post_type_object($gd_post_type); |
|
| 958 | + |
|
| 959 | + remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
|
|
| 960 | + |
|
| 961 | + $listing_link = get_post_type_archive_link($gd_post_type); |
|
| 962 | + |
|
| 963 | + add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
|
|
| 964 | + $listing_link = rtrim($listing_link, '/'); |
|
| 965 | + $listing_link .= '/'; |
|
| 966 | + |
|
| 967 | + $post_type_for_location_link = $listing_link; |
|
| 968 | + $location_terms = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 969 | + |
|
| 970 | + global $wp, $gd_session; |
|
| 971 | + $location_link = $post_type_for_location_link; |
|
| 972 | + |
|
| 973 | + if (geodir_is_page('detail') || geodir_is_page('listing')) {
|
|
| 974 | + global $post; |
|
| 975 | + $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 976 | 976 | $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
| 977 | 977 | |
| 978 | 978 | if(geodir_is_page('detail') && isset($post->country_slug)){
|
| 979 | - $location_terms = array( |
|
| 980 | - 'gd_country' => $post->country_slug, |
|
| 981 | - 'gd_region' => $post->region_slug, |
|
| 982 | - 'gd_city' => $post->city_slug |
|
| 983 | - ); |
|
| 979 | + $location_terms = array( |
|
| 980 | + 'gd_country' => $post->country_slug, |
|
| 981 | + 'gd_region' => $post->region_slug, |
|
| 982 | + 'gd_city' => $post->city_slug |
|
| 983 | + ); |
|
| 984 | 984 | |
| 985 | 985 | if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
|
| 986 | 986 | $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
| 987 | 987 | } |
| 988 | - } |
|
| 989 | - |
|
| 990 | - $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 991 | - |
|
| 992 | - $hide_url_part = array(); |
|
| 993 | - if ($location_manager) {
|
|
| 994 | - $hide_country_part = get_option('geodir_location_hide_country_part');
|
|
| 995 | - $hide_region_part = get_option('geodir_location_hide_region_part');
|
|
| 996 | - |
|
| 997 | - if ($hide_region_part && $hide_country_part) {
|
|
| 998 | - $hide_url_part = array('gd_country', 'gd_region');
|
|
| 999 | - } else if ($hide_region_part && !$hide_country_part) {
|
|
| 1000 | - $hide_url_part = array('gd_region');
|
|
| 1001 | - } else if (!$hide_region_part && $hide_country_part) {
|
|
| 1002 | - $hide_url_part = array('gd_country');
|
|
| 1003 | - } |
|
| 1004 | - } |
|
| 1005 | - |
|
| 1006 | - $hide_text_part = array(); |
|
| 1007 | - if ($geodir_show_location_url == 'country_city') {
|
|
| 1008 | - $hide_text_part = array('gd_region');
|
|
| 1009 | - |
|
| 1010 | - if (isset($location_terms['gd_region']) && !$location_manager) {
|
|
| 1011 | - unset($location_terms['gd_region']); |
|
| 1012 | - } |
|
| 1013 | - } else if ($geodir_show_location_url == 'region_city') {
|
|
| 1014 | - $hide_text_part = array('gd_country');
|
|
| 1015 | - |
|
| 1016 | - if (isset($location_terms['gd_country']) && !$location_manager) {
|
|
| 1017 | - unset($location_terms['gd_country']); |
|
| 1018 | - } |
|
| 1019 | - } else if ($geodir_show_location_url == 'city') {
|
|
| 1020 | - $hide_text_part = array('gd_country', 'gd_region');
|
|
| 1021 | - |
|
| 1022 | - if (isset($location_terms['gd_country']) && !$location_manager) {
|
|
| 1023 | - unset($location_terms['gd_country']); |
|
| 1024 | - } |
|
| 1025 | - if (isset($location_terms['gd_region']) && !$location_manager) {
|
|
| 1026 | - unset($location_terms['gd_region']); |
|
| 1027 | - } |
|
| 1028 | - } |
|
| 1029 | - |
|
| 1030 | - $is_location_last = ''; |
|
| 1031 | - $is_taxonomy_last = ''; |
|
| 1032 | - $breadcrumb .= '<li>'; |
|
| 1033 | - if (get_query_var($gd_post_type . 'category')) |
|
| 1034 | - $gd_taxonomy = $gd_post_type . 'category'; |
|
| 1035 | - elseif (get_query_var($gd_post_type . '_tags')) |
|
| 1036 | - $gd_taxonomy = $gd_post_type . '_tags'; |
|
| 1037 | - |
|
| 1038 | - $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>'; |
|
| 1039 | - if (!empty($gd_taxonomy) || geodir_is_page('detail'))
|
|
| 1040 | - $is_location_last = false; |
|
| 1041 | - else |
|
| 1042 | - $is_location_last = true; |
|
| 1043 | - |
|
| 1044 | - if (!empty($gd_taxonomy) && geodir_is_page('listing'))
|
|
| 1045 | - $is_taxonomy_last = true; |
|
| 1046 | - else |
|
| 1047 | - $is_taxonomy_last = false; |
|
| 1048 | - |
|
| 1049 | - if (!empty($location_terms)) {
|
|
| 1050 | - $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
|
|
| 1051 | - |
|
| 1052 | - foreach ($location_terms as $key => $location_term) {
|
|
| 1053 | - if ($location_term != '') {
|
|
| 1054 | - if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
|
|
| 1055 | - continue; |
|
| 1056 | - } |
|
| 988 | + } |
|
| 1057 | 989 | |
| 1058 | - $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
|
|
| 1059 | - $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
|
|
| 1060 | - $gd_location_link_text = ucfirst($gd_location_link_text); |
|
| 1061 | - |
|
| 1062 | - $location_term_actual_country = ''; |
|
| 1063 | - $location_term_actual_region = ''; |
|
| 1064 | - $location_term_actual_city = ''; |
|
| 1065 | - if ($geodir_get_locations) {
|
|
| 1066 | - if ($key == 'gd_country') {
|
|
| 1067 | - $location_term_actual_country = get_actual_location_name('country', $location_term, true);
|
|
| 1068 | - } else if ($key == 'gd_region') {
|
|
| 1069 | - $location_term_actual_region = get_actual_location_name('region', $location_term, true);
|
|
| 1070 | - } else if ($key == 'gd_city') {
|
|
| 1071 | - $location_term_actual_city = get_actual_location_name('city', $location_term, true);
|
|
| 1072 | - } |
|
| 1073 | - } else {
|
|
| 1074 | - $location_info = geodir_get_location(); |
|
| 1075 | - |
|
| 1076 | - if (!empty($location_info) && isset($location_info->location_id)) {
|
|
| 1077 | - if ($key == 'gd_country') {
|
|
| 1078 | - $location_term_actual_country = __($location_info->country, 'geodirectory'); |
|
| 1079 | - } else if ($key == 'gd_region') {
|
|
| 1080 | - $location_term_actual_region = __($location_info->region, 'geodirectory'); |
|
| 1081 | - } else if ($key == 'gd_city') {
|
|
| 1082 | - $location_term_actual_city = __($location_info->city, 'geodirectory'); |
|
| 1083 | - } |
|
| 1084 | - } |
|
| 1085 | - } |
|
| 990 | + $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 1086 | 991 | |
| 1087 | - if ($is_location_last && $key == 'gd_country' && !(isset($location_terms['gd_region']) && $location_terms['gd_region'] != '') && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
|
|
| 1088 | - $breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text; |
|
| 1089 | - } else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
|
|
| 1090 | - $breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text; |
|
| 1091 | - } else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
|
|
| 1092 | - $breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text; |
|
| 1093 | - } else if ($is_location_last && $key == 'gd_neighbourhood') {
|
|
| 1094 | - $breadcrumb .= $separator . $gd_location_link_text; |
|
| 1095 | - } else {
|
|
| 1096 | - if (get_option('permalink_structure') != '') {
|
|
| 1097 | - $location_link .= $location_term . '/'; |
|
| 1098 | - } else {
|
|
| 1099 | - $location_link .= "&$key=" . $location_term; |
|
| 1100 | - } |
|
| 992 | + $hide_url_part = array(); |
|
| 993 | + if ($location_manager) {
|
|
| 994 | + $hide_country_part = get_option('geodir_location_hide_country_part');
|
|
| 995 | + $hide_region_part = get_option('geodir_location_hide_region_part');
|
|
| 1101 | 996 | |
| 1102 | - if ($key == 'gd_country' && $location_term_actual_country != '') {
|
|
| 1103 | - $gd_location_link_text = $location_term_actual_country; |
|
| 1104 | - } else if ($key == 'gd_region' && $location_term_actual_region != '') {
|
|
| 1105 | - $gd_location_link_text = $location_term_actual_region; |
|
| 1106 | - } else if ($key == 'gd_city' && $location_term_actual_city != '') {
|
|
| 1107 | - $gd_location_link_text = $location_term_actual_city; |
|
| 1108 | - } |
|
| 997 | + if ($hide_region_part && $hide_country_part) {
|
|
| 998 | + $hide_url_part = array('gd_country', 'gd_region');
|
|
| 999 | + } else if ($hide_region_part && !$hide_country_part) {
|
|
| 1000 | + $hide_url_part = array('gd_region');
|
|
| 1001 | + } else if (!$hide_region_part && $hide_country_part) {
|
|
| 1002 | + $hide_url_part = array('gd_country');
|
|
| 1003 | + } |
|
| 1004 | + } |
|
| 1005 | + |
|
| 1006 | + $hide_text_part = array(); |
|
| 1007 | + if ($geodir_show_location_url == 'country_city') {
|
|
| 1008 | + $hide_text_part = array('gd_region');
|
|
| 1009 | + |
|
| 1010 | + if (isset($location_terms['gd_region']) && !$location_manager) {
|
|
| 1011 | + unset($location_terms['gd_region']); |
|
| 1012 | + } |
|
| 1013 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 1014 | + $hide_text_part = array('gd_country');
|
|
| 1015 | + |
|
| 1016 | + if (isset($location_terms['gd_country']) && !$location_manager) {
|
|
| 1017 | + unset($location_terms['gd_country']); |
|
| 1018 | + } |
|
| 1019 | + } else if ($geodir_show_location_url == 'city') {
|
|
| 1020 | + $hide_text_part = array('gd_country', 'gd_region');
|
|
| 1021 | + |
|
| 1022 | + if (isset($location_terms['gd_country']) && !$location_manager) {
|
|
| 1023 | + unset($location_terms['gd_country']); |
|
| 1024 | + } |
|
| 1025 | + if (isset($location_terms['gd_region']) && !$location_manager) {
|
|
| 1026 | + unset($location_terms['gd_region']); |
|
| 1027 | + } |
|
| 1028 | + } |
|
| 1109 | 1029 | |
| 1110 | - /* |
|
| 1030 | + $is_location_last = ''; |
|
| 1031 | + $is_taxonomy_last = ''; |
|
| 1032 | + $breadcrumb .= '<li>'; |
|
| 1033 | + if (get_query_var($gd_post_type . 'category')) |
|
| 1034 | + $gd_taxonomy = $gd_post_type . 'category'; |
|
| 1035 | + elseif (get_query_var($gd_post_type . '_tags')) |
|
| 1036 | + $gd_taxonomy = $gd_post_type . '_tags'; |
|
| 1037 | + |
|
| 1038 | + $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>'; |
|
| 1039 | + if (!empty($gd_taxonomy) || geodir_is_page('detail'))
|
|
| 1040 | + $is_location_last = false; |
|
| 1041 | + else |
|
| 1042 | + $is_location_last = true; |
|
| 1043 | + |
|
| 1044 | + if (!empty($gd_taxonomy) && geodir_is_page('listing'))
|
|
| 1045 | + $is_taxonomy_last = true; |
|
| 1046 | + else |
|
| 1047 | + $is_taxonomy_last = false; |
|
| 1048 | + |
|
| 1049 | + if (!empty($location_terms)) {
|
|
| 1050 | + $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
|
|
| 1051 | + |
|
| 1052 | + foreach ($location_terms as $key => $location_term) {
|
|
| 1053 | + if ($location_term != '') {
|
|
| 1054 | + if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
|
|
| 1055 | + continue; |
|
| 1056 | + } |
|
| 1057 | + |
|
| 1058 | + $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
|
|
| 1059 | + $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
|
|
| 1060 | + $gd_location_link_text = ucfirst($gd_location_link_text); |
|
| 1061 | + |
|
| 1062 | + $location_term_actual_country = ''; |
|
| 1063 | + $location_term_actual_region = ''; |
|
| 1064 | + $location_term_actual_city = ''; |
|
| 1065 | + if ($geodir_get_locations) {
|
|
| 1066 | + if ($key == 'gd_country') {
|
|
| 1067 | + $location_term_actual_country = get_actual_location_name('country', $location_term, true);
|
|
| 1068 | + } else if ($key == 'gd_region') {
|
|
| 1069 | + $location_term_actual_region = get_actual_location_name('region', $location_term, true);
|
|
| 1070 | + } else if ($key == 'gd_city') {
|
|
| 1071 | + $location_term_actual_city = get_actual_location_name('city', $location_term, true);
|
|
| 1072 | + } |
|
| 1073 | + } else {
|
|
| 1074 | + $location_info = geodir_get_location(); |
|
| 1075 | + |
|
| 1076 | + if (!empty($location_info) && isset($location_info->location_id)) {
|
|
| 1077 | + if ($key == 'gd_country') {
|
|
| 1078 | + $location_term_actual_country = __($location_info->country, 'geodirectory'); |
|
| 1079 | + } else if ($key == 'gd_region') {
|
|
| 1080 | + $location_term_actual_region = __($location_info->region, 'geodirectory'); |
|
| 1081 | + } else if ($key == 'gd_city') {
|
|
| 1082 | + $location_term_actual_city = __($location_info->city, 'geodirectory'); |
|
| 1083 | + } |
|
| 1084 | + } |
|
| 1085 | + } |
|
| 1086 | + |
|
| 1087 | + if ($is_location_last && $key == 'gd_country' && !(isset($location_terms['gd_region']) && $location_terms['gd_region'] != '') && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
|
|
| 1088 | + $breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text; |
|
| 1089 | + } else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
|
|
| 1090 | + $breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text; |
|
| 1091 | + } else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
|
|
| 1092 | + $breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text; |
|
| 1093 | + } else if ($is_location_last && $key == 'gd_neighbourhood') {
|
|
| 1094 | + $breadcrumb .= $separator . $gd_location_link_text; |
|
| 1095 | + } else {
|
|
| 1096 | + if (get_option('permalink_structure') != '') {
|
|
| 1097 | + $location_link .= $location_term . '/'; |
|
| 1098 | + } else {
|
|
| 1099 | + $location_link .= "&$key=" . $location_term; |
|
| 1100 | + } |
|
| 1101 | + |
|
| 1102 | + if ($key == 'gd_country' && $location_term_actual_country != '') {
|
|
| 1103 | + $gd_location_link_text = $location_term_actual_country; |
|
| 1104 | + } else if ($key == 'gd_region' && $location_term_actual_region != '') {
|
|
| 1105 | + $gd_location_link_text = $location_term_actual_region; |
|
| 1106 | + } else if ($key == 'gd_city' && $location_term_actual_city != '') {
|
|
| 1107 | + $gd_location_link_text = $location_term_actual_city; |
|
| 1108 | + } |
|
| 1109 | + |
|
| 1110 | + /* |
|
| 1111 | 1111 | if (geodir_is_page('detail') && !empty($hide_text_part) && in_array($key, $hide_text_part)) {
|
| 1112 | 1112 | continue; |
| 1113 | 1113 | } |
| 1114 | 1114 | */ |
| 1115 | 1115 | |
| 1116 | - $breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>'; |
|
| 1117 | - } |
|
| 1118 | - } |
|
| 1119 | - } |
|
| 1120 | - } |
|
| 1121 | - |
|
| 1122 | - if (!empty($gd_taxonomy)) {
|
|
| 1123 | - $term_index = 1; |
|
| 1124 | - |
|
| 1125 | - //if(get_option('geodir_add_categories_url'))
|
|
| 1126 | - {
|
|
| 1127 | - if (get_query_var($gd_post_type . '_tags')) {
|
|
| 1128 | - $cat_link = $listing_link . 'tags/'; |
|
| 1129 | - } else |
|
| 1130 | - $cat_link = $listing_link; |
|
| 1131 | - |
|
| 1132 | - foreach ($location_terms as $key => $location_term) {
|
|
| 1133 | - if ($location_manager && in_array($key, $hide_url_part)) {
|
|
| 1134 | - continue; |
|
| 1135 | - } |
|
| 1116 | + $breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>'; |
|
| 1117 | + } |
|
| 1118 | + } |
|
| 1119 | + } |
|
| 1120 | + } |
|
| 1136 | 1121 | |
| 1137 | - if ($location_term != '') {
|
|
| 1138 | - if (get_option('permalink_structure') != '') {
|
|
| 1139 | - $cat_link .= $location_term . '/'; |
|
| 1140 | - } |
|
| 1141 | - } |
|
| 1142 | - } |
|
| 1143 | - |
|
| 1144 | - $term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
|
|
| 1145 | - foreach ($term_array as $term) {
|
|
| 1146 | - $term_link_text = preg_replace('/-(\d+)$/', '', $term);
|
|
| 1147 | - $term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
|
|
| 1148 | - |
|
| 1149 | - // get term actual name |
|
| 1150 | - $term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
|
|
| 1151 | - if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
|
|
| 1152 | - $term_link_text = urldecode($term_info['name']); |
|
| 1153 | - } else {
|
|
| 1154 | - $term_link_text = geodir_ucwords(urldecode($term_link_text)); |
|
| 1155 | - } |
|
| 1122 | + if (!empty($gd_taxonomy)) {
|
|
| 1123 | + $term_index = 1; |
|
| 1156 | 1124 | |
| 1157 | - if ($term_index == count($term_array) && $is_taxonomy_last) |
|
| 1158 | - $breadcrumb .= $separator . $term_link_text; |
|
| 1159 | - else {
|
|
| 1160 | - $cat_link .= $term . '/'; |
|
| 1161 | - $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>'; |
|
| 1162 | - } |
|
| 1163 | - $term_index++; |
|
| 1164 | - } |
|
| 1165 | - } |
|
| 1166 | - |
|
| 1167 | - |
|
| 1168 | - } |
|
| 1169 | - |
|
| 1170 | - if (geodir_is_page('detail'))
|
|
| 1171 | - $breadcrumb .= $separator . get_the_title(); |
|
| 1172 | - |
|
| 1173 | - $breadcrumb .= '</li>'; |
|
| 1174 | - |
|
| 1175 | - |
|
| 1176 | - } elseif (geodir_is_page('author')) {
|
|
| 1177 | - $user_id = get_current_user_id(); |
|
| 1178 | - $author_link = get_author_posts_url($user_id); |
|
| 1179 | - $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
|
|
| 1180 | - |
|
| 1181 | - /** |
|
| 1182 | - * Filter author page link. |
|
| 1183 | - * |
|
| 1184 | - * @since 1.0.0 |
|
| 1185 | - * @param string $default_author_link Default author link. |
|
| 1186 | - * @param int $user_id Author ID. |
|
| 1187 | - */ |
|
| 1188 | - $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
|
|
| 1189 | - |
|
| 1190 | - $breadcrumb .= '<li>'; |
|
| 1191 | - $breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __('My Dashboard', 'geodirectory') . '</a>';
|
|
| 1192 | - |
|
| 1193 | - if (isset($_REQUEST['list'])) {
|
|
| 1194 | - $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $_REQUEST['stype']), false);
|
|
| 1195 | - |
|
| 1196 | - /** |
|
| 1197 | - * Filter author page link. |
|
| 1198 | - * |
|
| 1199 | - * @since 1.0.0 |
|
| 1200 | - * @param string $author_link Author page link. |
|
| 1201 | - * @param int $user_id Author ID. |
|
| 1202 | - * @param string $_REQUEST['stype'] Post type. |
|
| 1203 | - */ |
|
| 1204 | - $author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
|
|
| 1205 | - |
|
| 1206 | - $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>'; |
|
| 1207 | - $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
|
|
| 1208 | - } else |
|
| 1209 | - $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory'); |
|
| 1210 | - |
|
| 1211 | - $breadcrumb .= '</li>'; |
|
| 1212 | - } elseif (is_category() || is_single()) {
|
|
| 1213 | - $category = get_the_category(); |
|
| 1214 | - if (is_category()) {
|
|
| 1215 | - $breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>'; |
|
| 1216 | - } |
|
| 1217 | - if (is_single()) {
|
|
| 1218 | - $breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a></li>'; |
|
| 1219 | - $breadcrumb .= '<li>' . $separator . get_the_title() . '</li>'; |
|
| 1220 | - } |
|
| 1221 | - /* End of my version ##################################################### */ |
|
| 1222 | - } else if (is_page()) {
|
|
| 1223 | - $page_title = get_the_title(); |
|
| 1224 | - |
|
| 1225 | - if (geodir_is_page('location')) {
|
|
| 1226 | - $page_title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
|
|
| 1227 | - } |
|
| 1228 | - |
|
| 1229 | - $breadcrumb .= '<li>' . $separator; |
|
| 1230 | - $breadcrumb .= stripslashes_deep($page_title); |
|
| 1231 | - $breadcrumb .= '</li>'; |
|
| 1232 | - } else if (is_tag()) {
|
|
| 1233 | - $breadcrumb .= "<li> " . $separator . single_tag_title('',false) . '</li>';
|
|
| 1234 | - } else if (is_day()) {
|
|
| 1235 | - $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1236 | - the_time('F jS, Y');
|
|
| 1237 | - $breadcrumb .= '</li>'; |
|
| 1238 | - } else if (is_month()) {
|
|
| 1239 | - $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1240 | - the_time('F, Y');
|
|
| 1241 | - $breadcrumb .= '</li>'; |
|
| 1242 | - } else if (is_year()) {
|
|
| 1243 | - $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1244 | - the_time('Y');
|
|
| 1245 | - $breadcrumb .= '</li>'; |
|
| 1246 | - } else if (is_author()) {
|
|
| 1247 | - $breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
|
|
| 1248 | - $breadcrumb .= '</li>'; |
|
| 1249 | - } else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
|
|
| 1250 | - $breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
|
|
| 1251 | - $breadcrumb .= '</li>'; |
|
| 1252 | - } else if (is_search()) {
|
|
| 1253 | - $breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
|
|
| 1254 | - $breadcrumb .= '</li>'; |
|
| 1255 | - } |
|
| 1256 | - $breadcrumb .= '</ul></div>'; |
|
| 1257 | - |
|
| 1258 | - /** |
|
| 1259 | - * Filter breadcrumb html output. |
|
| 1260 | - * |
|
| 1261 | - * @since 1.0.0 |
|
| 1262 | - * @param string $breadcrumb Breadcrumb HTML. |
|
| 1263 | - * @param string $separator Breadcrumb separator. |
|
| 1264 | - */ |
|
| 1265 | - echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
|
|
| 1266 | - } |
|
| 1125 | + //if(get_option('geodir_add_categories_url'))
|
|
| 1126 | + {
|
|
| 1127 | + if (get_query_var($gd_post_type . '_tags')) {
|
|
| 1128 | + $cat_link = $listing_link . 'tags/'; |
|
| 1129 | + } else |
|
| 1130 | + $cat_link = $listing_link; |
|
| 1131 | + |
|
| 1132 | + foreach ($location_terms as $key => $location_term) {
|
|
| 1133 | + if ($location_manager && in_array($key, $hide_url_part)) {
|
|
| 1134 | + continue; |
|
| 1135 | + } |
|
| 1136 | + |
|
| 1137 | + if ($location_term != '') {
|
|
| 1138 | + if (get_option('permalink_structure') != '') {
|
|
| 1139 | + $cat_link .= $location_term . '/'; |
|
| 1140 | + } |
|
| 1141 | + } |
|
| 1142 | + } |
|
| 1143 | + |
|
| 1144 | + $term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
|
|
| 1145 | + foreach ($term_array as $term) {
|
|
| 1146 | + $term_link_text = preg_replace('/-(\d+)$/', '', $term);
|
|
| 1147 | + $term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
|
|
| 1148 | + |
|
| 1149 | + // get term actual name |
|
| 1150 | + $term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
|
|
| 1151 | + if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
|
|
| 1152 | + $term_link_text = urldecode($term_info['name']); |
|
| 1153 | + } else {
|
|
| 1154 | + $term_link_text = geodir_ucwords(urldecode($term_link_text)); |
|
| 1155 | + } |
|
| 1156 | + |
|
| 1157 | + if ($term_index == count($term_array) && $is_taxonomy_last) |
|
| 1158 | + $breadcrumb .= $separator . $term_link_text; |
|
| 1159 | + else {
|
|
| 1160 | + $cat_link .= $term . '/'; |
|
| 1161 | + $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>'; |
|
| 1162 | + } |
|
| 1163 | + $term_index++; |
|
| 1164 | + } |
|
| 1165 | + } |
|
| 1166 | + |
|
| 1167 | + |
|
| 1168 | + } |
|
| 1169 | + |
|
| 1170 | + if (geodir_is_page('detail'))
|
|
| 1171 | + $breadcrumb .= $separator . get_the_title(); |
|
| 1172 | + |
|
| 1173 | + $breadcrumb .= '</li>'; |
|
| 1174 | + |
|
| 1175 | + |
|
| 1176 | + } elseif (geodir_is_page('author')) {
|
|
| 1177 | + $user_id = get_current_user_id(); |
|
| 1178 | + $author_link = get_author_posts_url($user_id); |
|
| 1179 | + $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
|
|
| 1180 | + |
|
| 1181 | + /** |
|
| 1182 | + * Filter author page link. |
|
| 1183 | + * |
|
| 1184 | + * @since 1.0.0 |
|
| 1185 | + * @param string $default_author_link Default author link. |
|
| 1186 | + * @param int $user_id Author ID. |
|
| 1187 | + */ |
|
| 1188 | + $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
|
|
| 1189 | + |
|
| 1190 | + $breadcrumb .= '<li>'; |
|
| 1191 | + $breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __('My Dashboard', 'geodirectory') . '</a>';
|
|
| 1192 | + |
|
| 1193 | + if (isset($_REQUEST['list'])) {
|
|
| 1194 | + $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $_REQUEST['stype']), false);
|
|
| 1195 | + |
|
| 1196 | + /** |
|
| 1197 | + * Filter author page link. |
|
| 1198 | + * |
|
| 1199 | + * @since 1.0.0 |
|
| 1200 | + * @param string $author_link Author page link. |
|
| 1201 | + * @param int $user_id Author ID. |
|
| 1202 | + * @param string $_REQUEST['stype'] Post type. |
|
| 1203 | + */ |
|
| 1204 | + $author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
|
|
| 1205 | + |
|
| 1206 | + $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>'; |
|
| 1207 | + $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
|
|
| 1208 | + } else |
|
| 1209 | + $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory'); |
|
| 1210 | + |
|
| 1211 | + $breadcrumb .= '</li>'; |
|
| 1212 | + } elseif (is_category() || is_single()) {
|
|
| 1213 | + $category = get_the_category(); |
|
| 1214 | + if (is_category()) {
|
|
| 1215 | + $breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>'; |
|
| 1216 | + } |
|
| 1217 | + if (is_single()) {
|
|
| 1218 | + $breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a></li>'; |
|
| 1219 | + $breadcrumb .= '<li>' . $separator . get_the_title() . '</li>'; |
|
| 1220 | + } |
|
| 1221 | + /* End of my version ##################################################### */ |
|
| 1222 | + } else if (is_page()) {
|
|
| 1223 | + $page_title = get_the_title(); |
|
| 1224 | + |
|
| 1225 | + if (geodir_is_page('location')) {
|
|
| 1226 | + $page_title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
|
|
| 1227 | + } |
|
| 1228 | + |
|
| 1229 | + $breadcrumb .= '<li>' . $separator; |
|
| 1230 | + $breadcrumb .= stripslashes_deep($page_title); |
|
| 1231 | + $breadcrumb .= '</li>'; |
|
| 1232 | + } else if (is_tag()) {
|
|
| 1233 | + $breadcrumb .= "<li> " . $separator . single_tag_title('',false) . '</li>';
|
|
| 1234 | + } else if (is_day()) {
|
|
| 1235 | + $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1236 | + the_time('F jS, Y');
|
|
| 1237 | + $breadcrumb .= '</li>'; |
|
| 1238 | + } else if (is_month()) {
|
|
| 1239 | + $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1240 | + the_time('F, Y');
|
|
| 1241 | + $breadcrumb .= '</li>'; |
|
| 1242 | + } else if (is_year()) {
|
|
| 1243 | + $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1244 | + the_time('Y');
|
|
| 1245 | + $breadcrumb .= '</li>'; |
|
| 1246 | + } else if (is_author()) {
|
|
| 1247 | + $breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
|
|
| 1248 | + $breadcrumb .= '</li>'; |
|
| 1249 | + } else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
|
|
| 1250 | + $breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
|
|
| 1251 | + $breadcrumb .= '</li>'; |
|
| 1252 | + } else if (is_search()) {
|
|
| 1253 | + $breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
|
|
| 1254 | + $breadcrumb .= '</li>'; |
|
| 1255 | + } |
|
| 1256 | + $breadcrumb .= '</ul></div>'; |
|
| 1257 | + |
|
| 1258 | + /** |
|
| 1259 | + * Filter breadcrumb html output. |
|
| 1260 | + * |
|
| 1261 | + * @since 1.0.0 |
|
| 1262 | + * @param string $breadcrumb Breadcrumb HTML. |
|
| 1263 | + * @param string $separator Breadcrumb separator. |
|
| 1264 | + */ |
|
| 1265 | + echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
|
|
| 1266 | + } |
|
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | 1269 | |
| 1270 | 1270 | add_action("admin_init", "geodir_allow_wpadmin"); // check user is admin
|
| 1271 | 1271 | if (!function_exists('geodir_allow_wpadmin')) {
|
| 1272 | - /** |
|
| 1273 | - * Allow only admins to access wp-admin. |
|
| 1274 | - * |
|
| 1275 | - * Normal users will be redirected to home page. |
|
| 1276 | - * |
|
| 1277 | - * @since 1.0.0 |
|
| 1278 | - * @package GeoDirectory |
|
| 1279 | - * @global object $wpdb WordPress Database object. |
|
| 1280 | - */ |
|
| 1281 | - function geodir_allow_wpadmin() |
|
| 1282 | - {
|
|
| 1283 | - global $wpdb; |
|
| 1284 | - if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
|
|
| 1285 | - {
|
|
| 1286 | - if (current_user_can('manage_options')) {
|
|
| 1287 | - } else {
|
|
| 1288 | - |
|
| 1289 | - wp_redirect(home_url()); |
|
| 1290 | - exit; |
|
| 1291 | - } |
|
| 1292 | - |
|
| 1293 | - } |
|
| 1294 | - } |
|
| 1272 | + /** |
|
| 1273 | + * Allow only admins to access wp-admin. |
|
| 1274 | + * |
|
| 1275 | + * Normal users will be redirected to home page. |
|
| 1276 | + * |
|
| 1277 | + * @since 1.0.0 |
|
| 1278 | + * @package GeoDirectory |
|
| 1279 | + * @global object $wpdb WordPress Database object. |
|
| 1280 | + */ |
|
| 1281 | + function geodir_allow_wpadmin() |
|
| 1282 | + {
|
|
| 1283 | + global $wpdb; |
|
| 1284 | + if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
|
|
| 1285 | + {
|
|
| 1286 | + if (current_user_can('manage_options')) {
|
|
| 1287 | + } else {
|
|
| 1288 | + |
|
| 1289 | + wp_redirect(home_url()); |
|
| 1290 | + exit; |
|
| 1291 | + } |
|
| 1292 | + |
|
| 1293 | + } |
|
| 1294 | + } |
|
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | 1297 | |
@@ -1305,76 +1305,76 @@ discard block |
||
| 1305 | 1305 | */ |
| 1306 | 1306 | function fetch_remote_file($url) |
| 1307 | 1307 | {
|
| 1308 | - // extract the file name and extension from the url |
|
| 1309 | - require_once(ABSPATH . 'wp-includes/pluggable.php'); |
|
| 1310 | - $file_name = basename($url); |
|
| 1311 | - if (strpos($file_name, '?') !== false) {
|
|
| 1312 | - list($file_name) = explode('?', $file_name);
|
|
| 1313 | - } |
|
| 1314 | - $dummy = false; |
|
| 1315 | - $add_to_cache = false; |
|
| 1316 | - $key = null; |
|
| 1317 | - if (strpos($url, '/dummy/') !== false) {
|
|
| 1318 | - $dummy = true; |
|
| 1319 | - $key = "dummy_".str_replace('.', '_', $file_name);
|
|
| 1320 | - $value = get_transient('cached_dummy_images');
|
|
| 1321 | - if ($value) {
|
|
| 1322 | - if (isset($value[$key])) {
|
|
| 1323 | - return $value[$key]; |
|
| 1324 | - } else {
|
|
| 1325 | - $add_to_cache = true; |
|
| 1326 | - } |
|
| 1327 | - } else {
|
|
| 1328 | - $add_to_cache = true; |
|
| 1329 | - } |
|
| 1330 | - } |
|
| 1331 | - |
|
| 1332 | - // get placeholder file in the upload dir with a unique, sanitized filename |
|
| 1333 | - |
|
| 1334 | - $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : ''; |
|
| 1335 | - |
|
| 1336 | - $upload = wp_upload_bits($file_name, 0, '', $post_upload_date); |
|
| 1337 | - if ($upload['error']) |
|
| 1338 | - return new WP_Error('upload_dir_error', $upload['error']);
|
|
| 1339 | - |
|
| 1340 | - // fetch the remote url and write it to the placeholder file |
|
| 1341 | - $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
|
|
| 1342 | - |
|
| 1343 | - $log_message = ''; |
|
| 1344 | - $filesize = filesize($upload['file']); |
|
| 1345 | - // request failed |
|
| 1346 | - if (!$headers) {
|
|
| 1347 | - $log_message = __('Remote server did not respond', 'geodirectory');
|
|
| 1348 | - } |
|
| 1349 | - // make sure the fetch was successful |
|
| 1350 | - elseif ($headers['response']['code'] != '200') {
|
|
| 1351 | - $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
|
|
| 1352 | - } |
|
| 1353 | - elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
|
|
| 1354 | - $log_message = __('Remote file is incorrect size', 'geodirectory');
|
|
| 1355 | - } |
|
| 1356 | - elseif (0 == $filesize) {
|
|
| 1357 | - $log_message = __('Zero size file downloaded', 'geodirectory');
|
|
| 1358 | - } |
|
| 1359 | - |
|
| 1360 | - if($log_message){
|
|
| 1361 | - $del = unlink($upload['file']); |
|
| 1362 | - if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
|
|
| 1363 | - return new WP_Error('import_file_error',$log_message );
|
|
| 1364 | - } |
|
| 1365 | - |
|
| 1366 | - if ($dummy && $add_to_cache && is_array($upload)) {
|
|
| 1367 | - $images = get_transient('cached_dummy_images');
|
|
| 1368 | - if(is_array($images)) |
|
| 1369 | - $images[$key] = $upload; |
|
| 1370 | - else |
|
| 1371 | - $images = array($key => $upload); |
|
| 1372 | - |
|
| 1373 | - //setting the cache using the WP Transient API |
|
| 1374 | - set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
|
|
| 1375 | - } |
|
| 1376 | - |
|
| 1377 | - return $upload; |
|
| 1308 | + // extract the file name and extension from the url |
|
| 1309 | + require_once(ABSPATH . 'wp-includes/pluggable.php'); |
|
| 1310 | + $file_name = basename($url); |
|
| 1311 | + if (strpos($file_name, '?') !== false) {
|
|
| 1312 | + list($file_name) = explode('?', $file_name);
|
|
| 1313 | + } |
|
| 1314 | + $dummy = false; |
|
| 1315 | + $add_to_cache = false; |
|
| 1316 | + $key = null; |
|
| 1317 | + if (strpos($url, '/dummy/') !== false) {
|
|
| 1318 | + $dummy = true; |
|
| 1319 | + $key = "dummy_".str_replace('.', '_', $file_name);
|
|
| 1320 | + $value = get_transient('cached_dummy_images');
|
|
| 1321 | + if ($value) {
|
|
| 1322 | + if (isset($value[$key])) {
|
|
| 1323 | + return $value[$key]; |
|
| 1324 | + } else {
|
|
| 1325 | + $add_to_cache = true; |
|
| 1326 | + } |
|
| 1327 | + } else {
|
|
| 1328 | + $add_to_cache = true; |
|
| 1329 | + } |
|
| 1330 | + } |
|
| 1331 | + |
|
| 1332 | + // get placeholder file in the upload dir with a unique, sanitized filename |
|
| 1333 | + |
|
| 1334 | + $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : ''; |
|
| 1335 | + |
|
| 1336 | + $upload = wp_upload_bits($file_name, 0, '', $post_upload_date); |
|
| 1337 | + if ($upload['error']) |
|
| 1338 | + return new WP_Error('upload_dir_error', $upload['error']);
|
|
| 1339 | + |
|
| 1340 | + // fetch the remote url and write it to the placeholder file |
|
| 1341 | + $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
|
|
| 1342 | + |
|
| 1343 | + $log_message = ''; |
|
| 1344 | + $filesize = filesize($upload['file']); |
|
| 1345 | + // request failed |
|
| 1346 | + if (!$headers) {
|
|
| 1347 | + $log_message = __('Remote server did not respond', 'geodirectory');
|
|
| 1348 | + } |
|
| 1349 | + // make sure the fetch was successful |
|
| 1350 | + elseif ($headers['response']['code'] != '200') {
|
|
| 1351 | + $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
|
|
| 1352 | + } |
|
| 1353 | + elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
|
|
| 1354 | + $log_message = __('Remote file is incorrect size', 'geodirectory');
|
|
| 1355 | + } |
|
| 1356 | + elseif (0 == $filesize) {
|
|
| 1357 | + $log_message = __('Zero size file downloaded', 'geodirectory');
|
|
| 1358 | + } |
|
| 1359 | + |
|
| 1360 | + if($log_message){
|
|
| 1361 | + $del = unlink($upload['file']); |
|
| 1362 | + if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
|
|
| 1363 | + return new WP_Error('import_file_error',$log_message );
|
|
| 1364 | + } |
|
| 1365 | + |
|
| 1366 | + if ($dummy && $add_to_cache && is_array($upload)) {
|
|
| 1367 | + $images = get_transient('cached_dummy_images');
|
|
| 1368 | + if(is_array($images)) |
|
| 1369 | + $images[$key] = $upload; |
|
| 1370 | + else |
|
| 1371 | + $images = array($key => $upload); |
|
| 1372 | + |
|
| 1373 | + //setting the cache using the WP Transient API |
|
| 1374 | + set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
|
|
| 1375 | + } |
|
| 1376 | + |
|
| 1377 | + return $upload; |
|
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | 1380 | /** |
@@ -1386,21 +1386,21 @@ discard block |
||
| 1386 | 1386 | */ |
| 1387 | 1387 | function geodir_max_upload_size() |
| 1388 | 1388 | {
|
| 1389 | - $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
|
|
| 1390 | - |
|
| 1391 | - if ($max_filesize > 0 && $max_filesize < 1) {
|
|
| 1392 | - $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
| 1393 | - } else {
|
|
| 1394 | - $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
|
| 1395 | - } |
|
| 1396 | - |
|
| 1397 | - /** |
|
| 1398 | - * Filter default image upload size limit. |
|
| 1399 | - * |
|
| 1400 | - * @since 1.0.0 |
|
| 1401 | - * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb. |
|
| 1402 | - */ |
|
| 1403 | - return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
|
|
| 1389 | + $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
|
|
| 1390 | + |
|
| 1391 | + if ($max_filesize > 0 && $max_filesize < 1) {
|
|
| 1392 | + $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
| 1393 | + } else {
|
|
| 1394 | + $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
|
| 1395 | + } |
|
| 1396 | + |
|
| 1397 | + /** |
|
| 1398 | + * Filter default image upload size limit. |
|
| 1399 | + * |
|
| 1400 | + * @since 1.0.0 |
|
| 1401 | + * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb. |
|
| 1402 | + */ |
|
| 1403 | + return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
|
|
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | 1406 | /** |
@@ -1414,11 +1414,11 @@ discard block |
||
| 1414 | 1414 | */ |
| 1415 | 1415 | function geodir_dummy_folder_exists() |
| 1416 | 1416 | {
|
| 1417 | - $path = geodir_plugin_path() . '/geodirectory-admin/dummy/'; |
|
| 1418 | - if (!is_dir($path)) |
|
| 1419 | - return false; |
|
| 1420 | - else |
|
| 1421 | - return true; |
|
| 1417 | + $path = geodir_plugin_path() . '/geodirectory-admin/dummy/'; |
|
| 1418 | + if (!is_dir($path)) |
|
| 1419 | + return false; |
|
| 1420 | + else |
|
| 1421 | + return true; |
|
| 1422 | 1422 | |
| 1423 | 1423 | } |
| 1424 | 1424 | |
@@ -1433,290 +1433,290 @@ discard block |
||
| 1433 | 1433 | */ |
| 1434 | 1434 | function geodir_get_author_info($aid) |
| 1435 | 1435 | {
|
| 1436 | - global $wpdb; |
|
| 1437 | - /*$infosql = "select * from $wpdb->users where ID=$aid";*/ |
|
| 1438 | - $infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
|
|
| 1439 | - $info = $wpdb->get_results($infosql); |
|
| 1440 | - if ($info) {
|
|
| 1441 | - return $info[0]; |
|
| 1442 | - } |
|
| 1436 | + global $wpdb; |
|
| 1437 | + /*$infosql = "select * from $wpdb->users where ID=$aid";*/ |
|
| 1438 | + $infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
|
|
| 1439 | + $info = $wpdb->get_results($infosql); |
|
| 1440 | + if ($info) {
|
|
| 1441 | + return $info[0]; |
|
| 1442 | + } |
|
| 1443 | 1443 | } |
| 1444 | 1444 | |
| 1445 | 1445 | if (!function_exists('adminEmail')) {
|
| 1446 | - /** |
|
| 1447 | - * Send emails to client on post submission, renew etc. |
|
| 1448 | - * |
|
| 1449 | - * @since 1.0.0 |
|
| 1450 | - * @package GeoDirectory |
|
| 1451 | - * @global object $wpdb WordPress Database object. |
|
| 1452 | - * @param int|string $page_id Page ID. |
|
| 1453 | - * @param int|string $user_id User ID. |
|
| 1454 | - * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
|
| 1455 | - * @param string $custom_1 Custom data to be sent. |
|
| 1456 | - */ |
|
| 1457 | - function adminEmail($page_id, $user_id, $message_type, $custom_1 = '') |
|
| 1458 | - {
|
|
| 1459 | - global $wpdb; |
|
| 1460 | - if ($message_type == 'expiration') {
|
|
| 1461 | - $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
|
|
| 1462 | - $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
|
|
| 1463 | - } elseif ($message_type == 'post_submited') {
|
|
| 1464 | - $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
|
|
| 1465 | - $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
|
|
| 1466 | - } elseif ($message_type == 'renew') {
|
|
| 1467 | - $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
|
|
| 1468 | - $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
|
|
| 1469 | - } elseif ($message_type == 'upgrade') {
|
|
| 1470 | - $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
|
|
| 1471 | - $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
|
|
| 1472 | - } elseif ($message_type == 'claim_approved') {
|
|
| 1473 | - $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
|
|
| 1474 | - $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
|
|
| 1475 | - } elseif ($message_type == 'claim_rejected') {
|
|
| 1476 | - $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
|
|
| 1477 | - $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
|
|
| 1478 | - } elseif ($message_type == 'claim_requested') {
|
|
| 1479 | - $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
|
|
| 1480 | - $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
|
|
| 1481 | - } elseif ($message_type == 'auto_claim') {
|
|
| 1482 | - $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
|
|
| 1483 | - $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
|
|
| 1484 | - } elseif ($message_type == 'payment_success') {
|
|
| 1485 | - $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
|
|
| 1486 | - $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
|
|
| 1487 | - } elseif ($message_type == 'payment_fail') {
|
|
| 1488 | - $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
|
|
| 1489 | - $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
|
|
| 1490 | - } |
|
| 1491 | - $transaction_details = $custom_1; |
|
| 1492 | - $fromEmail = get_option('site_email');
|
|
| 1493 | - $fromEmailName = get_site_emailName(); |
|
| 1446 | + /** |
|
| 1447 | + * Send emails to client on post submission, renew etc. |
|
| 1448 | + * |
|
| 1449 | + * @since 1.0.0 |
|
| 1450 | + * @package GeoDirectory |
|
| 1451 | + * @global object $wpdb WordPress Database object. |
|
| 1452 | + * @param int|string $page_id Page ID. |
|
| 1453 | + * @param int|string $user_id User ID. |
|
| 1454 | + * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
|
| 1455 | + * @param string $custom_1 Custom data to be sent. |
|
| 1456 | + */ |
|
| 1457 | + function adminEmail($page_id, $user_id, $message_type, $custom_1 = '') |
|
| 1458 | + {
|
|
| 1459 | + global $wpdb; |
|
| 1460 | + if ($message_type == 'expiration') {
|
|
| 1461 | + $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
|
|
| 1462 | + $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
|
|
| 1463 | + } elseif ($message_type == 'post_submited') {
|
|
| 1464 | + $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
|
|
| 1465 | + $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
|
|
| 1466 | + } elseif ($message_type == 'renew') {
|
|
| 1467 | + $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
|
|
| 1468 | + $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
|
|
| 1469 | + } elseif ($message_type == 'upgrade') {
|
|
| 1470 | + $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
|
|
| 1471 | + $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
|
|
| 1472 | + } elseif ($message_type == 'claim_approved') {
|
|
| 1473 | + $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
|
|
| 1474 | + $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
|
|
| 1475 | + } elseif ($message_type == 'claim_rejected') {
|
|
| 1476 | + $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
|
|
| 1477 | + $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
|
|
| 1478 | + } elseif ($message_type == 'claim_requested') {
|
|
| 1479 | + $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
|
|
| 1480 | + $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
|
|
| 1481 | + } elseif ($message_type == 'auto_claim') {
|
|
| 1482 | + $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
|
|
| 1483 | + $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
|
|
| 1484 | + } elseif ($message_type == 'payment_success') {
|
|
| 1485 | + $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
|
|
| 1486 | + $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
|
|
| 1487 | + } elseif ($message_type == 'payment_fail') {
|
|
| 1488 | + $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
|
|
| 1489 | + $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
|
|
| 1490 | + } |
|
| 1491 | + $transaction_details = $custom_1; |
|
| 1492 | + $fromEmail = get_option('site_email');
|
|
| 1493 | + $fromEmailName = get_site_emailName(); |
|
| 1494 | 1494 | //$alivedays = get_post_meta($page_id,'alive_days',true); |
| 1495 | - $pkg_limit = get_property_price_info_listing($page_id); |
|
| 1496 | - $alivedays = $pkg_limit['days']; |
|
| 1497 | - $productlink = get_permalink($page_id); |
|
| 1498 | - $post_info = get_post($page_id); |
|
| 1499 | - $post_date = date('dS F,Y', strtotime($post_info->post_date));
|
|
| 1500 | - $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 1501 | - $loginurl = geodir_login_url(); |
|
| 1502 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 1503 | - $siteurl = home_url(); |
|
| 1504 | - $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>'; |
|
| 1505 | - $user_info = get_userdata($user_id); |
|
| 1506 | - $user_email = $user_info->user_email; |
|
| 1507 | - $display_name = geodir_get_client_name($user_id); |
|
| 1508 | - $user_login = $user_info->user_login; |
|
| 1509 | - $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
|
|
| 1510 | - if ($number_of_grace_days == '') {
|
|
| 1511 | - $number_of_grace_days = 1; |
|
| 1512 | - } |
|
| 1513 | - if ($post_info->post_type == 'event') {
|
|
| 1514 | - $post_type = 'event'; |
|
| 1515 | - } else {
|
|
| 1516 | - $post_type = 'listing'; |
|
| 1517 | - } |
|
| 1518 | - $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>'; |
|
| 1519 | - $search_array = array('[#client_name#]', '[#listing_link#]', '[#posted_date#]', '[#number_of_days#]', '[#number_of_grace_days#]', '[#login_url#]', '[#username#]', '[#user_email#]', '[#site_name_url#]', '[#renew_link#]', '[#post_id#]', '[#site_name#]', '[#transaction_details#]');
|
|
| 1520 | - $replace_array = array($display_name, $listingLink, $post_date, $alivedays, $number_of_grace_days, $loginurl_link, $user_login, $user_email, $siteurl_link, $renew_link, $page_id, $fromEmailName, $transaction_details); |
|
| 1521 | - $client_message = str_replace($search_array, $replace_array, $client_message); |
|
| 1522 | - $subject = str_replace($search_array, $replace_array, $subject); |
|
| 1523 | - $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 1524 | - $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 1525 | - $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n"; |
|
| 1526 | - |
|
| 1527 | - $to = $fromEmail; |
|
| 1528 | - $message = $client_message; |
|
| 1529 | - |
|
| 1530 | - |
|
| 1531 | - /** |
|
| 1532 | - * Filter the admin email to address. |
|
| 1533 | - * |
|
| 1534 | - * @since 1.6.1 |
|
| 1535 | - * @package GeoDirectory |
|
| 1536 | - * @param string $to The email address the email is being sent to. |
|
| 1537 | - * @param int|string $page_id Page ID. |
|
| 1538 | - * @param int|string $user_id User ID. |
|
| 1539 | - * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
|
| 1540 | - * @param string $custom_1 Custom data to be sent. |
|
| 1541 | - */ |
|
| 1542 | - $to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
|
|
| 1543 | - /** |
|
| 1544 | - * Filter the admin email subject. |
|
| 1545 | - * |
|
| 1546 | - * @since 1.6.1 |
|
| 1547 | - * @package GeoDirectory_Payment_Manager |
|
| 1548 | - * @param string $subject The email subject. |
|
| 1549 | - * @param int|string $page_id Page ID. |
|
| 1550 | - * @param int|string $user_id User ID. |
|
| 1551 | - * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
|
| 1552 | - * @param string $custom_1 Custom data to be sent. |
|
| 1553 | - */ |
|
| 1554 | - $subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
|
|
| 1555 | - /** |
|
| 1556 | - * Filter the admin email message. |
|
| 1557 | - * |
|
| 1558 | - * @since 1.6.1 |
|
| 1559 | - * @package GeoDirectory_Payment_Manager |
|
| 1560 | - * @param string $message The email message text. |
|
| 1561 | - * @param int|string $page_id Page ID. |
|
| 1562 | - * @param int|string $user_id User ID. |
|
| 1563 | - * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
|
| 1564 | - * @param string $custom_1 Custom data to be sent. |
|
| 1565 | - */ |
|
| 1566 | - $message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
|
|
| 1567 | - /** |
|
| 1568 | - * Filter the admin email headers. |
|
| 1569 | - * |
|
| 1570 | - * @since 1.6.1 |
|
| 1571 | - * @package GeoDirectory_Payment_Manager |
|
| 1572 | - * @param string $headers The email headers. |
|
| 1573 | - * @param int|string $page_id Page ID. |
|
| 1574 | - * @param int|string $user_id User ID. |
|
| 1575 | - * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
|
| 1576 | - * @param string $custom_1 Custom data to be sent. |
|
| 1577 | - */ |
|
| 1578 | - $headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
|
|
| 1579 | - |
|
| 1580 | - |
|
| 1581 | - |
|
| 1582 | - $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1583 | - if( ! $sent ) {
|
|
| 1584 | - if ( is_array( $to ) ) {
|
|
| 1585 | - $to = implode( ',', $to ); |
|
| 1586 | - } |
|
| 1587 | - $log_message = sprintf( |
|
| 1588 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1589 | - $message_type, |
|
| 1590 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1591 | - $to, |
|
| 1592 | - $subject |
|
| 1593 | - ); |
|
| 1594 | - geodir_error_log( $log_message ); |
|
| 1595 | - } |
|
| 1596 | - } |
|
| 1495 | + $pkg_limit = get_property_price_info_listing($page_id); |
|
| 1496 | + $alivedays = $pkg_limit['days']; |
|
| 1497 | + $productlink = get_permalink($page_id); |
|
| 1498 | + $post_info = get_post($page_id); |
|
| 1499 | + $post_date = date('dS F,Y', strtotime($post_info->post_date));
|
|
| 1500 | + $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 1501 | + $loginurl = geodir_login_url(); |
|
| 1502 | + $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 1503 | + $siteurl = home_url(); |
|
| 1504 | + $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>'; |
|
| 1505 | + $user_info = get_userdata($user_id); |
|
| 1506 | + $user_email = $user_info->user_email; |
|
| 1507 | + $display_name = geodir_get_client_name($user_id); |
|
| 1508 | + $user_login = $user_info->user_login; |
|
| 1509 | + $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
|
|
| 1510 | + if ($number_of_grace_days == '') {
|
|
| 1511 | + $number_of_grace_days = 1; |
|
| 1512 | + } |
|
| 1513 | + if ($post_info->post_type == 'event') {
|
|
| 1514 | + $post_type = 'event'; |
|
| 1515 | + } else {
|
|
| 1516 | + $post_type = 'listing'; |
|
| 1517 | + } |
|
| 1518 | + $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>'; |
|
| 1519 | + $search_array = array('[#client_name#]', '[#listing_link#]', '[#posted_date#]', '[#number_of_days#]', '[#number_of_grace_days#]', '[#login_url#]', '[#username#]', '[#user_email#]', '[#site_name_url#]', '[#renew_link#]', '[#post_id#]', '[#site_name#]', '[#transaction_details#]');
|
|
| 1520 | + $replace_array = array($display_name, $listingLink, $post_date, $alivedays, $number_of_grace_days, $loginurl_link, $user_login, $user_email, $siteurl_link, $renew_link, $page_id, $fromEmailName, $transaction_details); |
|
| 1521 | + $client_message = str_replace($search_array, $replace_array, $client_message); |
|
| 1522 | + $subject = str_replace($search_array, $replace_array, $subject); |
|
| 1523 | + $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 1524 | + $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 1525 | + $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n"; |
|
| 1526 | + |
|
| 1527 | + $to = $fromEmail; |
|
| 1528 | + $message = $client_message; |
|
| 1529 | + |
|
| 1530 | + |
|
| 1531 | + /** |
|
| 1532 | + * Filter the admin email to address. |
|
| 1533 | + * |
|
| 1534 | + * @since 1.6.1 |
|
| 1535 | + * @package GeoDirectory |
|
| 1536 | + * @param string $to The email address the email is being sent to. |
|
| 1537 | + * @param int|string $page_id Page ID. |
|
| 1538 | + * @param int|string $user_id User ID. |
|
| 1539 | + * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
|
| 1540 | + * @param string $custom_1 Custom data to be sent. |
|
| 1541 | + */ |
|
| 1542 | + $to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
|
|
| 1543 | + /** |
|
| 1544 | + * Filter the admin email subject. |
|
| 1545 | + * |
|
| 1546 | + * @since 1.6.1 |
|
| 1547 | + * @package GeoDirectory_Payment_Manager |
|
| 1548 | + * @param string $subject The email subject. |
|
| 1549 | + * @param int|string $page_id Page ID. |
|
| 1550 | + * @param int|string $user_id User ID. |
|
| 1551 | + * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
|
| 1552 | + * @param string $custom_1 Custom data to be sent. |
|
| 1553 | + */ |
|
| 1554 | + $subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
|
|
| 1555 | + /** |
|
| 1556 | + * Filter the admin email message. |
|
| 1557 | + * |
|
| 1558 | + * @since 1.6.1 |
|
| 1559 | + * @package GeoDirectory_Payment_Manager |
|
| 1560 | + * @param string $message The email message text. |
|
| 1561 | + * @param int|string $page_id Page ID. |
|
| 1562 | + * @param int|string $user_id User ID. |
|
| 1563 | + * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
|
| 1564 | + * @param string $custom_1 Custom data to be sent. |
|
| 1565 | + */ |
|
| 1566 | + $message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
|
|
| 1567 | + /** |
|
| 1568 | + * Filter the admin email headers. |
|
| 1569 | + * |
|
| 1570 | + * @since 1.6.1 |
|
| 1571 | + * @package GeoDirectory_Payment_Manager |
|
| 1572 | + * @param string $headers The email headers. |
|
| 1573 | + * @param int|string $page_id Page ID. |
|
| 1574 | + * @param int|string $user_id User ID. |
|
| 1575 | + * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
|
| 1576 | + * @param string $custom_1 Custom data to be sent. |
|
| 1577 | + */ |
|
| 1578 | + $headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
|
|
| 1579 | + |
|
| 1580 | + |
|
| 1581 | + |
|
| 1582 | + $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1583 | + if( ! $sent ) {
|
|
| 1584 | + if ( is_array( $to ) ) {
|
|
| 1585 | + $to = implode( ',', $to ); |
|
| 1586 | + } |
|
| 1587 | + $log_message = sprintf( |
|
| 1588 | + __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1589 | + $message_type, |
|
| 1590 | + date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1591 | + $to, |
|
| 1592 | + $subject |
|
| 1593 | + ); |
|
| 1594 | + geodir_error_log( $log_message ); |
|
| 1595 | + } |
|
| 1596 | + } |
|
| 1597 | 1597 | } |
| 1598 | 1598 | |
| 1599 | 1599 | if (!function_exists('sendEmail')) {
|
| 1600 | - /** |
|
| 1601 | - * @todo could be a duplicate of geodir_sendEmail. |
|
| 1602 | - * |
|
| 1603 | - * @since 1.0.0 |
|
| 1604 | - * @package GeoDirectory |
|
| 1605 | - * @param string $fromEmail Sender email address. |
|
| 1606 | - * @param string $fromEmailName Sender name. |
|
| 1607 | - * @param string $toEmail Receiver email address. |
|
| 1608 | - * @param string $toEmailName Receiver name. |
|
| 1609 | - * @param string $to_subject Email subject. |
|
| 1610 | - * @param string $to_message Email content. |
|
| 1611 | - * @param string $extra Not being used. |
|
| 1612 | - * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration. |
|
| 1613 | - * @param string $post_id The post ID. |
|
| 1614 | - * @param string $user_id The user ID. |
|
| 1615 | - */ |
|
| 1616 | - function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') |
|
| 1617 | - {
|
|
| 1618 | - $login_details = ''; |
|
| 1619 | - if ($message_type == 'send_friend') {
|
|
| 1620 | - $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
|
|
| 1621 | - $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
|
|
| 1622 | - } elseif ($message_type == 'send_enquiry') {
|
|
| 1623 | - $subject = __(get_option('email_enquiry_subject'),'geodirectory');
|
|
| 1624 | - $message = __(get_option('email_enquiry_content'),'geodirectory');
|
|
| 1625 | - } elseif ($message_type == 'forgot_password') {
|
|
| 1626 | - $subject = __(get_option('forgot_password_subject'),'geodirectory');
|
|
| 1627 | - $message = __(get_option('forgot_password_content'),'geodirectory');
|
|
| 1628 | - $login_details = $to_message; |
|
| 1629 | - } elseif ($message_type == 'registration') {
|
|
| 1630 | - $subject = __(get_option('registration_success_email_subject'),'geodirectory');
|
|
| 1631 | - $message = __(get_option('registration_success_email_content'),'geodirectory');
|
|
| 1632 | - $login_details = $to_message; |
|
| 1633 | - } |
|
| 1634 | - $to_message = nl2br($to_message); |
|
| 1635 | - $sitefromEmail = get_option('site_email');
|
|
| 1636 | - $sitefromEmailName = get_site_emailName(); |
|
| 1637 | - $productlink = get_permalink($post_id); |
|
| 1638 | - $post_info = get_post($post_id); |
|
| 1639 | - $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 1640 | - $siteurl = home_url(); |
|
| 1641 | - $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; |
|
| 1642 | - $loginurl = geodir_login_url(); |
|
| 1643 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 1644 | - if ($fromEmail == '') {
|
|
| 1645 | - $fromEmail = get_option('site_email');
|
|
| 1646 | - } |
|
| 1647 | - if ($fromEmailName == '') {
|
|
| 1648 | - $fromEmailName = get_option('site_email_name');
|
|
| 1649 | - } |
|
| 1650 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
|
|
| 1651 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName); |
|
| 1652 | - $message = str_replace($search_array, $replace_array, $message); |
|
| 1653 | - |
|
| 1654 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
|
|
| 1655 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName); |
|
| 1656 | - $subject = str_replace($search_array, $replace_array, $subject); |
|
| 1657 | - $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 1658 | - $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 1659 | - $headers .= "Reply-To: " . $fromEmail . "\r\n"; |
|
| 1660 | - $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n"; |
|
| 1661 | - |
|
| 1662 | - $to = $toEmail; |
|
| 1663 | - |
|
| 1664 | - $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1665 | - if( ! $sent ) {
|
|
| 1666 | - if ( is_array( $to ) ) {
|
|
| 1667 | - $to = implode( ',', $to ); |
|
| 1668 | - } |
|
| 1669 | - $log_message = sprintf( |
|
| 1670 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1671 | - $message_type, |
|
| 1672 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1673 | - $to, |
|
| 1674 | - $subject |
|
| 1675 | - ); |
|
| 1676 | - geodir_error_log( $log_message ); |
|
| 1677 | - } |
|
| 1678 | - |
|
| 1679 | - ///////// ADMIN BCC EMIALS |
|
| 1680 | - $admin_bcc = false; |
|
| 1681 | - if ($message_type == 'registration') {
|
|
| 1682 | - $message_raw = explode(__("Password:", 'geodirectory'), $message);
|
|
| 1683 | - $message_raw2 = explode("</p>", $message_raw[1], 2);
|
|
| 1684 | - $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
|
|
| 1685 | - } |
|
| 1686 | - $adminEmail = get_bloginfo('admin_email');
|
|
| 1687 | - $to = $adminEmail; |
|
| 1688 | - |
|
| 1689 | - if ($message_type == 'registration' && get_option('bcc_new_user')) {
|
|
| 1690 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 1691 | - $admin_bcc = true; |
|
| 1692 | - } |
|
| 1693 | - elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
|
|
| 1694 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 1695 | - $admin_bcc = true; |
|
| 1696 | - } |
|
| 1697 | - elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
|
|
| 1698 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 1699 | - $admin_bcc = true; |
|
| 1700 | - } |
|
| 1701 | - |
|
| 1702 | - if($admin_bcc === true){
|
|
| 1703 | - $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1704 | - if( ! $sent ) {
|
|
| 1705 | - if ( is_array( $to ) ) {
|
|
| 1706 | - $to = implode( ',', $to ); |
|
| 1707 | - } |
|
| 1708 | - $log_message = sprintf( |
|
| 1709 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1710 | - $message_type, |
|
| 1711 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1712 | - $to, |
|
| 1713 | - $subject |
|
| 1714 | - ); |
|
| 1715 | - geodir_error_log( $log_message ); |
|
| 1716 | - } |
|
| 1717 | - } |
|
| 1718 | - |
|
| 1719 | - } |
|
| 1600 | + /** |
|
| 1601 | + * @todo could be a duplicate of geodir_sendEmail. |
|
| 1602 | + * |
|
| 1603 | + * @since 1.0.0 |
|
| 1604 | + * @package GeoDirectory |
|
| 1605 | + * @param string $fromEmail Sender email address. |
|
| 1606 | + * @param string $fromEmailName Sender name. |
|
| 1607 | + * @param string $toEmail Receiver email address. |
|
| 1608 | + * @param string $toEmailName Receiver name. |
|
| 1609 | + * @param string $to_subject Email subject. |
|
| 1610 | + * @param string $to_message Email content. |
|
| 1611 | + * @param string $extra Not being used. |
|
| 1612 | + * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration. |
|
| 1613 | + * @param string $post_id The post ID. |
|
| 1614 | + * @param string $user_id The user ID. |
|
| 1615 | + */ |
|
| 1616 | + function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') |
|
| 1617 | + {
|
|
| 1618 | + $login_details = ''; |
|
| 1619 | + if ($message_type == 'send_friend') {
|
|
| 1620 | + $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
|
|
| 1621 | + $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
|
|
| 1622 | + } elseif ($message_type == 'send_enquiry') {
|
|
| 1623 | + $subject = __(get_option('email_enquiry_subject'),'geodirectory');
|
|
| 1624 | + $message = __(get_option('email_enquiry_content'),'geodirectory');
|
|
| 1625 | + } elseif ($message_type == 'forgot_password') {
|
|
| 1626 | + $subject = __(get_option('forgot_password_subject'),'geodirectory');
|
|
| 1627 | + $message = __(get_option('forgot_password_content'),'geodirectory');
|
|
| 1628 | + $login_details = $to_message; |
|
| 1629 | + } elseif ($message_type == 'registration') {
|
|
| 1630 | + $subject = __(get_option('registration_success_email_subject'),'geodirectory');
|
|
| 1631 | + $message = __(get_option('registration_success_email_content'),'geodirectory');
|
|
| 1632 | + $login_details = $to_message; |
|
| 1633 | + } |
|
| 1634 | + $to_message = nl2br($to_message); |
|
| 1635 | + $sitefromEmail = get_option('site_email');
|
|
| 1636 | + $sitefromEmailName = get_site_emailName(); |
|
| 1637 | + $productlink = get_permalink($post_id); |
|
| 1638 | + $post_info = get_post($post_id); |
|
| 1639 | + $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 1640 | + $siteurl = home_url(); |
|
| 1641 | + $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; |
|
| 1642 | + $loginurl = geodir_login_url(); |
|
| 1643 | + $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 1644 | + if ($fromEmail == '') {
|
|
| 1645 | + $fromEmail = get_option('site_email');
|
|
| 1646 | + } |
|
| 1647 | + if ($fromEmailName == '') {
|
|
| 1648 | + $fromEmailName = get_option('site_email_name');
|
|
| 1649 | + } |
|
| 1650 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
|
|
| 1651 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName); |
|
| 1652 | + $message = str_replace($search_array, $replace_array, $message); |
|
| 1653 | + |
|
| 1654 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
|
|
| 1655 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName); |
|
| 1656 | + $subject = str_replace($search_array, $replace_array, $subject); |
|
| 1657 | + $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 1658 | + $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 1659 | + $headers .= "Reply-To: " . $fromEmail . "\r\n"; |
|
| 1660 | + $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n"; |
|
| 1661 | + |
|
| 1662 | + $to = $toEmail; |
|
| 1663 | + |
|
| 1664 | + $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1665 | + if( ! $sent ) {
|
|
| 1666 | + if ( is_array( $to ) ) {
|
|
| 1667 | + $to = implode( ',', $to ); |
|
| 1668 | + } |
|
| 1669 | + $log_message = sprintf( |
|
| 1670 | + __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1671 | + $message_type, |
|
| 1672 | + date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1673 | + $to, |
|
| 1674 | + $subject |
|
| 1675 | + ); |
|
| 1676 | + geodir_error_log( $log_message ); |
|
| 1677 | + } |
|
| 1678 | + |
|
| 1679 | + ///////// ADMIN BCC EMIALS |
|
| 1680 | + $admin_bcc = false; |
|
| 1681 | + if ($message_type == 'registration') {
|
|
| 1682 | + $message_raw = explode(__("Password:", 'geodirectory'), $message);
|
|
| 1683 | + $message_raw2 = explode("</p>", $message_raw[1], 2);
|
|
| 1684 | + $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
|
|
| 1685 | + } |
|
| 1686 | + $adminEmail = get_bloginfo('admin_email');
|
|
| 1687 | + $to = $adminEmail; |
|
| 1688 | + |
|
| 1689 | + if ($message_type == 'registration' && get_option('bcc_new_user')) {
|
|
| 1690 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 1691 | + $admin_bcc = true; |
|
| 1692 | + } |
|
| 1693 | + elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
|
|
| 1694 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 1695 | + $admin_bcc = true; |
|
| 1696 | + } |
|
| 1697 | + elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
|
|
| 1698 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 1699 | + $admin_bcc = true; |
|
| 1700 | + } |
|
| 1701 | + |
|
| 1702 | + if($admin_bcc === true){
|
|
| 1703 | + $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1704 | + if( ! $sent ) {
|
|
| 1705 | + if ( is_array( $to ) ) {
|
|
| 1706 | + $to = implode( ',', $to ); |
|
| 1707 | + } |
|
| 1708 | + $log_message = sprintf( |
|
| 1709 | + __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1710 | + $message_type, |
|
| 1711 | + date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1712 | + $to, |
|
| 1713 | + $subject |
|
| 1714 | + ); |
|
| 1715 | + geodir_error_log( $log_message ); |
|
| 1716 | + } |
|
| 1717 | + } |
|
| 1718 | + |
|
| 1719 | + } |
|
| 1720 | 1720 | } |
| 1721 | 1721 | |
| 1722 | 1722 | /* |
@@ -1734,16 +1734,16 @@ discard block |
||
| 1734 | 1734 | */ |
| 1735 | 1735 | function gd_lang_object_ids($ids_array, $type) |
| 1736 | 1736 | {
|
| 1737 | - if (function_exists('icl_object_id')) {
|
|
| 1738 | - $res = array(); |
|
| 1739 | - foreach ($ids_array as $id) {
|
|
| 1740 | - $xlat = icl_object_id($id, $type, false); |
|
| 1741 | - if (!is_null($xlat)) $res[] = $xlat; |
|
| 1742 | - } |
|
| 1743 | - return $res; |
|
| 1744 | - } else {
|
|
| 1745 | - return $ids_array; |
|
| 1746 | - } |
|
| 1737 | + if (function_exists('icl_object_id')) {
|
|
| 1738 | + $res = array(); |
|
| 1739 | + foreach ($ids_array as $id) {
|
|
| 1740 | + $xlat = icl_object_id($id, $type, false); |
|
| 1741 | + if (!is_null($xlat)) $res[] = $xlat; |
|
| 1742 | + } |
|
| 1743 | + return $res; |
|
| 1744 | + } else {
|
|
| 1745 | + return $ids_array; |
|
| 1746 | + } |
|
| 1747 | 1747 | } |
| 1748 | 1748 | |
| 1749 | 1749 | |
@@ -1758,31 +1758,31 @@ discard block |
||
| 1758 | 1758 | * @return array Modified Body CSS classes. |
| 1759 | 1759 | */ |
| 1760 | 1760 | function geodir_custom_posts_body_class($classes) {
|
| 1761 | - global $wpdb, $wp; |
|
| 1762 | - $post_types = geodir_get_posttypes('object');
|
|
| 1763 | - if (!empty($post_types) && count((array)$post_types) > 1) {
|
|
| 1764 | - $classes[] = 'geodir_custom_posts'; |
|
| 1765 | - } |
|
| 1766 | - |
|
| 1767 | - // fix body class for signup page |
|
| 1768 | - if (geodir_is_page('login')) {
|
|
| 1769 | - $new_classes = array(); |
|
| 1770 | - $new_classes[] = 'signup page-geodir-signup'; |
|
| 1771 | - if (!empty($classes)) {
|
|
| 1772 | - foreach ($classes as $class) {
|
|
| 1773 | - if ($class && $class != 'home' && $class != 'blog') {
|
|
| 1774 | - $new_classes[] = $class; |
|
| 1775 | - } |
|
| 1776 | - } |
|
| 1777 | - } |
|
| 1778 | - $classes = $new_classes; |
|
| 1779 | - } |
|
| 1780 | - |
|
| 1781 | - if (geodir_is_geodir_page()) {
|
|
| 1782 | - $classes[] = 'geodir-page'; |
|
| 1783 | - } |
|
| 1784 | - |
|
| 1785 | - return $classes; |
|
| 1761 | + global $wpdb, $wp; |
|
| 1762 | + $post_types = geodir_get_posttypes('object');
|
|
| 1763 | + if (!empty($post_types) && count((array)$post_types) > 1) {
|
|
| 1764 | + $classes[] = 'geodir_custom_posts'; |
|
| 1765 | + } |
|
| 1766 | + |
|
| 1767 | + // fix body class for signup page |
|
| 1768 | + if (geodir_is_page('login')) {
|
|
| 1769 | + $new_classes = array(); |
|
| 1770 | + $new_classes[] = 'signup page-geodir-signup'; |
|
| 1771 | + if (!empty($classes)) {
|
|
| 1772 | + foreach ($classes as $class) {
|
|
| 1773 | + if ($class && $class != 'home' && $class != 'blog') {
|
|
| 1774 | + $new_classes[] = $class; |
|
| 1775 | + } |
|
| 1776 | + } |
|
| 1777 | + } |
|
| 1778 | + $classes = $new_classes; |
|
| 1779 | + } |
|
| 1780 | + |
|
| 1781 | + if (geodir_is_geodir_page()) {
|
|
| 1782 | + $classes[] = 'geodir-page'; |
|
| 1783 | + } |
|
| 1784 | + |
|
| 1785 | + return $classes; |
|
| 1786 | 1786 | } |
| 1787 | 1787 | |
| 1788 | 1788 | add_filter('body_class', 'geodir_custom_posts_body_class'); // let's add a class to the body so we can style the new addition to the search
|
@@ -1797,12 +1797,12 @@ discard block |
||
| 1797 | 1797 | */ |
| 1798 | 1798 | function geodir_map_zoom_level() |
| 1799 | 1799 | {
|
| 1800 | - /** |
|
| 1801 | - * Filter GD map zoom level. |
|
| 1802 | - * |
|
| 1803 | - * @since 1.0.0 |
|
| 1804 | - */ |
|
| 1805 | - return apply_filters('geodir_map_zoom_level', array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19));
|
|
| 1800 | + /** |
|
| 1801 | + * Filter GD map zoom level. |
|
| 1802 | + * |
|
| 1803 | + * @since 1.0.0 |
|
| 1804 | + */ |
|
| 1805 | + return apply_filters('geodir_map_zoom_level', array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19));
|
|
| 1806 | 1806 | |
| 1807 | 1807 | } |
| 1808 | 1808 | |
@@ -1816,12 +1816,12 @@ discard block |
||
| 1816 | 1816 | */ |
| 1817 | 1817 | function geodir_option_version_backup($geodir_option_name) |
| 1818 | 1818 | {
|
| 1819 | - $version_date = time(); |
|
| 1820 | - $geodir_option = get_option($geodir_option_name); |
|
| 1819 | + $version_date = time(); |
|
| 1820 | + $geodir_option = get_option($geodir_option_name); |
|
| 1821 | 1821 | |
| 1822 | - if (!empty($geodir_option)) {
|
|
| 1823 | - add_option($geodir_option_name . '_' . $version_date, $geodir_option); |
|
| 1824 | - } |
|
| 1822 | + if (!empty($geodir_option)) {
|
|
| 1823 | + add_option($geodir_option_name . '_' . $version_date, $geodir_option); |
|
| 1824 | + } |
|
| 1825 | 1825 | } |
| 1826 | 1826 | |
| 1827 | 1827 | /** |
@@ -1834,11 +1834,11 @@ discard block |
||
| 1834 | 1834 | */ |
| 1835 | 1835 | function get_page_id_geodir_add_listing_page($page_id) |
| 1836 | 1836 | {
|
| 1837 | - if (geodir_wpml_multilingual_status()) {
|
|
| 1838 | - $post_type = 'post_page'; |
|
| 1839 | - $page_id = geodir_get_wpml_element_id($page_id, $post_type); |
|
| 1840 | - } |
|
| 1841 | - return $page_id; |
|
| 1837 | + if (geodir_wpml_multilingual_status()) {
|
|
| 1838 | + $post_type = 'post_page'; |
|
| 1839 | + $page_id = geodir_get_wpml_element_id($page_id, $post_type); |
|
| 1840 | + } |
|
| 1841 | + return $page_id; |
|
| 1842 | 1842 | } |
| 1843 | 1843 | |
| 1844 | 1844 | /** |
@@ -1850,10 +1850,10 @@ discard block |
||
| 1850 | 1850 | */ |
| 1851 | 1851 | function geodir_wpml_multilingual_status() |
| 1852 | 1852 | {
|
| 1853 | - if (function_exists('icl_object_id')) {
|
|
| 1854 | - return true; |
|
| 1855 | - } |
|
| 1856 | - return false; |
|
| 1853 | + if (function_exists('icl_object_id')) {
|
|
| 1854 | + return true; |
|
| 1855 | + } |
|
| 1856 | + return false; |
|
| 1857 | 1857 | } |
| 1858 | 1858 | |
| 1859 | 1859 | /** |
@@ -1867,22 +1867,22 @@ discard block |
||
| 1867 | 1867 | */ |
| 1868 | 1868 | function geodir_get_wpml_element_id($page_id, $post_type) |
| 1869 | 1869 | {
|
| 1870 | - global $sitepress; |
|
| 1871 | - if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
|
|
| 1872 | - $trid = $sitepress->get_element_trid($page_id, $post_type); |
|
| 1873 | - |
|
| 1874 | - if ($trid > 0) {
|
|
| 1875 | - $translations = $sitepress->get_element_translations($trid, $post_type); |
|
| 1876 | - |
|
| 1877 | - $lang = $sitepress->get_current_language(); |
|
| 1878 | - $lang = $lang ? $lang : $sitepress->get_default_language(); |
|
| 1879 | - |
|
| 1880 | - if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
|
|
| 1881 | - $page_id = $translations[$lang]->element_id; |
|
| 1882 | - } |
|
| 1883 | - } |
|
| 1884 | - } |
|
| 1885 | - return $page_id; |
|
| 1870 | + global $sitepress; |
|
| 1871 | + if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
|
|
| 1872 | + $trid = $sitepress->get_element_trid($page_id, $post_type); |
|
| 1873 | + |
|
| 1874 | + if ($trid > 0) {
|
|
| 1875 | + $translations = $sitepress->get_element_translations($trid, $post_type); |
|
| 1876 | + |
|
| 1877 | + $lang = $sitepress->get_current_language(); |
|
| 1878 | + $lang = $lang ? $lang : $sitepress->get_default_language(); |
|
| 1879 | + |
|
| 1880 | + if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
|
|
| 1881 | + $page_id = $translations[$lang]->element_id; |
|
| 1882 | + } |
|
| 1883 | + } |
|
| 1884 | + } |
|
| 1885 | + return $page_id; |
|
| 1886 | 1886 | } |
| 1887 | 1887 | |
| 1888 | 1888 | /** |
@@ -1894,20 +1894,20 @@ discard block |
||
| 1894 | 1894 | */ |
| 1895 | 1895 | function geodir_wpml_check_element_id() |
| 1896 | 1896 | {
|
| 1897 | - global $sitepress; |
|
| 1898 | - if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
|
|
| 1899 | - $el_type = 'post_page'; |
|
| 1900 | - $el_id = get_option('geodir_add_listing_page');
|
|
| 1901 | - $default_lang = $sitepress->get_default_language(); |
|
| 1902 | - $el_details = $sitepress->get_element_language_details($el_id, $el_type); |
|
| 1903 | - |
|
| 1904 | - if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
|
|
| 1905 | - if (!$el_details->source_language_code) {
|
|
| 1906 | - $sitepress->set_element_language_details($el_id, $el_type, '', $default_lang); |
|
| 1907 | - $sitepress->icl_translations_cache->clear(); |
|
| 1908 | - } |
|
| 1909 | - } |
|
| 1910 | - } |
|
| 1897 | + global $sitepress; |
|
| 1898 | + if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
|
|
| 1899 | + $el_type = 'post_page'; |
|
| 1900 | + $el_id = get_option('geodir_add_listing_page');
|
|
| 1901 | + $default_lang = $sitepress->get_default_language(); |
|
| 1902 | + $el_details = $sitepress->get_element_language_details($el_id, $el_type); |
|
| 1903 | + |
|
| 1904 | + if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
|
|
| 1905 | + if (!$el_details->source_language_code) {
|
|
| 1906 | + $sitepress->set_element_language_details($el_id, $el_type, '', $default_lang); |
|
| 1907 | + $sitepress->icl_translations_cache->clear(); |
|
| 1908 | + } |
|
| 1909 | + } |
|
| 1910 | + } |
|
| 1911 | 1911 | } |
| 1912 | 1912 | |
| 1913 | 1913 | /** |
@@ -1922,44 +1922,44 @@ discard block |
||
| 1922 | 1922 | */ |
| 1923 | 1923 | function geodir_widget_listings_get_order($query_args) |
| 1924 | 1924 | {
|
| 1925 | - global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 1926 | - |
|
| 1927 | - $query_args = $gd_query_args_widgets; |
|
| 1928 | - if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 1929 | - return $wpdb->posts . ".post_date DESC, "; |
|
| 1930 | - } |
|
| 1931 | - |
|
| 1932 | - $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 1933 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1934 | - |
|
| 1935 | - $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : ''; |
|
| 1936 | - |
|
| 1937 | - switch ($sort_by) {
|
|
| 1938 | - case 'latest': |
|
| 1939 | - case 'newest': |
|
| 1940 | - $orderby = $wpdb->posts . ".post_date DESC, "; |
|
| 1941 | - break; |
|
| 1942 | - case 'featured': |
|
| 1943 | - $orderby = $table . ".is_featured ASC, "; |
|
| 1944 | - break; |
|
| 1945 | - case 'az': |
|
| 1946 | - $orderby = $wpdb->posts . ".post_title ASC, "; |
|
| 1947 | - break; |
|
| 1948 | - case 'high_review': |
|
| 1949 | - $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, "; |
|
| 1950 | - break; |
|
| 1951 | - case 'high_rating': |
|
| 1952 | - $orderby = "( " . $table . ".overall_rating ) DESC, "; |
|
| 1953 | - break; |
|
| 1954 | - case 'random': |
|
| 1955 | - $orderby = "RAND(), "; |
|
| 1956 | - break; |
|
| 1957 | - default: |
|
| 1958 | - $orderby = $wpdb->posts . ".post_title ASC, "; |
|
| 1959 | - break; |
|
| 1960 | - } |
|
| 1961 | - |
|
| 1962 | - return $orderby; |
|
| 1925 | + global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 1926 | + |
|
| 1927 | + $query_args = $gd_query_args_widgets; |
|
| 1928 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 1929 | + return $wpdb->posts . ".post_date DESC, "; |
|
| 1930 | + } |
|
| 1931 | + |
|
| 1932 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 1933 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1934 | + |
|
| 1935 | + $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : ''; |
|
| 1936 | + |
|
| 1937 | + switch ($sort_by) {
|
|
| 1938 | + case 'latest': |
|
| 1939 | + case 'newest': |
|
| 1940 | + $orderby = $wpdb->posts . ".post_date DESC, "; |
|
| 1941 | + break; |
|
| 1942 | + case 'featured': |
|
| 1943 | + $orderby = $table . ".is_featured ASC, "; |
|
| 1944 | + break; |
|
| 1945 | + case 'az': |
|
| 1946 | + $orderby = $wpdb->posts . ".post_title ASC, "; |
|
| 1947 | + break; |
|
| 1948 | + case 'high_review': |
|
| 1949 | + $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, "; |
|
| 1950 | + break; |
|
| 1951 | + case 'high_rating': |
|
| 1952 | + $orderby = "( " . $table . ".overall_rating ) DESC, "; |
|
| 1953 | + break; |
|
| 1954 | + case 'random': |
|
| 1955 | + $orderby = "RAND(), "; |
|
| 1956 | + break; |
|
| 1957 | + default: |
|
| 1958 | + $orderby = $wpdb->posts . ".post_title ASC, "; |
|
| 1959 | + break; |
|
| 1960 | + } |
|
| 1961 | + |
|
| 1962 | + return $orderby; |
|
| 1963 | 1963 | } |
| 1964 | 1964 | |
| 1965 | 1965 | /** |
@@ -1977,126 +1977,126 @@ discard block |
||
| 1977 | 1977 | */ |
| 1978 | 1978 | function geodir_get_widget_listings($query_args = array(), $count_only = false) |
| 1979 | 1979 | {
|
| 1980 | - global $wpdb, $plugin_prefix, $table_prefix; |
|
| 1981 | - $GLOBALS['gd_query_args_widgets'] = $query_args; |
|
| 1982 | - $gd_query_args_widgets = $query_args; |
|
| 1983 | - |
|
| 1984 | - $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 1985 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1986 | - |
|
| 1987 | - $fields = $wpdb->posts . ".*, " . $table . ".*"; |
|
| 1988 | - /** |
|
| 1989 | - * Filter widget listing fields string part that is being used for query. |
|
| 1990 | - * |
|
| 1991 | - * @since 1.0.0 |
|
| 1992 | - * @param string $fields Fields string. |
|
| 1993 | - * @param string $table Table name. |
|
| 1994 | - * @param string $post_type Post type. |
|
| 1995 | - */ |
|
| 1996 | - $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
|
|
| 1997 | - |
|
| 1998 | - $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
|
|
| 1980 | + global $wpdb, $plugin_prefix, $table_prefix; |
|
| 1981 | + $GLOBALS['gd_query_args_widgets'] = $query_args; |
|
| 1982 | + $gd_query_args_widgets = $query_args; |
|
| 1983 | + |
|
| 1984 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 1985 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1986 | + |
|
| 1987 | + $fields = $wpdb->posts . ".*, " . $table . ".*"; |
|
| 1988 | + /** |
|
| 1989 | + * Filter widget listing fields string part that is being used for query. |
|
| 1990 | + * |
|
| 1991 | + * @since 1.0.0 |
|
| 1992 | + * @param string $fields Fields string. |
|
| 1993 | + * @param string $table Table name. |
|
| 1994 | + * @param string $post_type Post type. |
|
| 1995 | + */ |
|
| 1996 | + $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
|
|
| 1997 | + |
|
| 1998 | + $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
|
|
| 1999 | + |
|
| 2000 | + ########### WPML ########### |
|
| 2001 | + |
|
| 2002 | + if (function_exists('icl_object_id')) {
|
|
| 2003 | + global $sitepress; |
|
| 2004 | + $lang_code = ICL_LANGUAGE_CODE; |
|
| 2005 | + if ($lang_code) {
|
|
| 2006 | + $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID"; |
|
| 2007 | + } |
|
| 2008 | + } |
|
| 1999 | 2009 | |
| 2000 | - ########### WPML ########### |
|
| 2010 | + ########### WPML ########### |
|
| 2001 | 2011 | |
| 2002 | - if (function_exists('icl_object_id')) {
|
|
| 2003 | - global $sitepress; |
|
| 2004 | - $lang_code = ICL_LANGUAGE_CODE; |
|
| 2005 | - if ($lang_code) {
|
|
| 2006 | - $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID"; |
|
| 2007 | - } |
|
| 2008 | - } |
|
| 2012 | + /** |
|
| 2013 | + * Filter widget listing join clause string part that is being used for query. |
|
| 2014 | + * |
|
| 2015 | + * @since 1.0.0 |
|
| 2016 | + * @param string $join Join clause string. |
|
| 2017 | + * @param string $post_type Post type. |
|
| 2018 | + */ |
|
| 2019 | + $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
|
|
| 2009 | 2020 | |
| 2010 | - ########### WPML ########### |
|
| 2021 | + $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : ''; |
|
| 2011 | 2022 | |
| 2012 | - /** |
|
| 2013 | - * Filter widget listing join clause string part that is being used for query. |
|
| 2014 | - * |
|
| 2015 | - * @since 1.0.0 |
|
| 2016 | - * @param string $join Join clause string. |
|
| 2017 | - * @param string $post_type Post type. |
|
| 2018 | - */ |
|
| 2019 | - $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
|
|
| 2020 | - |
|
| 2021 | - $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : ''; |
|
| 2022 | - |
|
| 2023 | - $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'"; |
|
| 2024 | - |
|
| 2025 | - ########### WPML ########### |
|
| 2026 | - if (function_exists('icl_object_id')) {
|
|
| 2027 | - if ($lang_code) {
|
|
| 2028 | - $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' "; |
|
| 2029 | - } |
|
| 2030 | - } |
|
| 2031 | - ########### WPML ########### |
|
| 2032 | - /** |
|
| 2033 | - * Filter widget listing where clause string part that is being used for query. |
|
| 2034 | - * |
|
| 2035 | - * @since 1.0.0 |
|
| 2036 | - * @param string $where Where clause string. |
|
| 2037 | - * @param string $post_type Post type. |
|
| 2038 | - */ |
|
| 2039 | - $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
|
|
| 2040 | - $where = $where != '' ? " WHERE 1=1 " . $where : ''; |
|
| 2041 | - |
|
| 2042 | - $groupby = " GROUP BY $wpdb->posts.ID "; |
|
| 2043 | - /** |
|
| 2044 | - * Filter widget listing groupby clause string part that is being used for query. |
|
| 2045 | - * |
|
| 2046 | - * @since 1.0.0 |
|
| 2047 | - * @param string $groupby Group by clause string. |
|
| 2048 | - * @param string $post_type Post type. |
|
| 2049 | - */ |
|
| 2050 | - $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
|
|
| 2023 | + $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'"; |
|
| 2051 | 2024 | |
| 2052 | - if ($count_only) {
|
|
| 2053 | - $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
|
|
| 2025 | + ########### WPML ########### |
|
| 2026 | + if (function_exists('icl_object_id')) {
|
|
| 2027 | + if ($lang_code) {
|
|
| 2028 | + $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' "; |
|
| 2029 | + } |
|
| 2030 | + } |
|
| 2031 | + ########### WPML ########### |
|
| 2032 | + /** |
|
| 2033 | + * Filter widget listing where clause string part that is being used for query. |
|
| 2034 | + * |
|
| 2035 | + * @since 1.0.0 |
|
| 2036 | + * @param string $where Where clause string. |
|
| 2037 | + * @param string $post_type Post type. |
|
| 2038 | + */ |
|
| 2039 | + $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
|
|
| 2040 | + $where = $where != '' ? " WHERE 1=1 " . $where : ''; |
|
| 2041 | + |
|
| 2042 | + $groupby = " GROUP BY $wpdb->posts.ID "; |
|
| 2043 | + /** |
|
| 2044 | + * Filter widget listing groupby clause string part that is being used for query. |
|
| 2045 | + * |
|
| 2046 | + * @since 1.0.0 |
|
| 2047 | + * @param string $groupby Group by clause string. |
|
| 2048 | + * @param string $post_type Post type. |
|
| 2049 | + */ |
|
| 2050 | + $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
|
|
| 2051 | + |
|
| 2052 | + if ($count_only) {
|
|
| 2053 | + $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
|
|
| 2054 | 2054 | " . $join . " |
| 2055 | 2055 | " . $where; |
| 2056 | - $rows = (int)$wpdb->get_var($sql); |
|
| 2057 | - } else {
|
|
| 2058 | - $orderby = geodir_widget_listings_get_order($query_args); |
|
| 2059 | - /** |
|
| 2060 | - * Filter widget listing orderby clause string part that is being used for query. |
|
| 2061 | - * |
|
| 2062 | - * @since 1.0.0 |
|
| 2063 | - * @param string $orderby Order by clause string. |
|
| 2064 | - * @param string $table Table name. |
|
| 2065 | - * @param string $post_type Post type. |
|
| 2066 | - */ |
|
| 2067 | - $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
|
|
| 2068 | - $orderby .= $wpdb->posts . ".post_title ASC"; |
|
| 2069 | - $orderby = $orderby != '' ? " ORDER BY " . $orderby : ''; |
|
| 2070 | - |
|
| 2071 | - $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5; |
|
| 2072 | - /** |
|
| 2073 | - * Filter widget listing limit that is being used for query. |
|
| 2074 | - * |
|
| 2075 | - * @since 1.0.0 |
|
| 2076 | - * @param int $limit Query results limit. |
|
| 2077 | - * @param string $post_type Post type. |
|
| 2078 | - */ |
|
| 2079 | - $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
|
|
| 2080 | - |
|
| 2081 | - $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1; |
|
| 2082 | - if ( !$page ) |
|
| 2083 | - $page = 1; |
|
| 2084 | - |
|
| 2085 | - $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : ""; |
|
| 2086 | - |
|
| 2087 | - $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . " |
|
| 2056 | + $rows = (int)$wpdb->get_var($sql); |
|
| 2057 | + } else {
|
|
| 2058 | + $orderby = geodir_widget_listings_get_order($query_args); |
|
| 2059 | + /** |
|
| 2060 | + * Filter widget listing orderby clause string part that is being used for query. |
|
| 2061 | + * |
|
| 2062 | + * @since 1.0.0 |
|
| 2063 | + * @param string $orderby Order by clause string. |
|
| 2064 | + * @param string $table Table name. |
|
| 2065 | + * @param string $post_type Post type. |
|
| 2066 | + */ |
|
| 2067 | + $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
|
|
| 2068 | + $orderby .= $wpdb->posts . ".post_title ASC"; |
|
| 2069 | + $orderby = $orderby != '' ? " ORDER BY " . $orderby : ''; |
|
| 2070 | + |
|
| 2071 | + $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5; |
|
| 2072 | + /** |
|
| 2073 | + * Filter widget listing limit that is being used for query. |
|
| 2074 | + * |
|
| 2075 | + * @since 1.0.0 |
|
| 2076 | + * @param int $limit Query results limit. |
|
| 2077 | + * @param string $post_type Post type. |
|
| 2078 | + */ |
|
| 2079 | + $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
|
|
| 2080 | + |
|
| 2081 | + $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1; |
|
| 2082 | + if ( !$page ) |
|
| 2083 | + $page = 1; |
|
| 2084 | + |
|
| 2085 | + $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : ""; |
|
| 2086 | + |
|
| 2087 | + $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . " |
|
| 2088 | 2088 | " . $join . " |
| 2089 | 2089 | " . $where . " |
| 2090 | 2090 | " . $groupby . " |
| 2091 | 2091 | " . $orderby . " |
| 2092 | 2092 | " . $limit; |
| 2093 | - $rows = $wpdb->get_results($sql); |
|
| 2094 | - } |
|
| 2093 | + $rows = $wpdb->get_results($sql); |
|
| 2094 | + } |
|
| 2095 | 2095 | |
| 2096 | - unset($GLOBALS['gd_query_args_widgets']); |
|
| 2097 | - unset($gd_query_args_widgets); |
|
| 2096 | + unset($GLOBALS['gd_query_args_widgets']); |
|
| 2097 | + unset($gd_query_args_widgets); |
|
| 2098 | 2098 | |
| 2099 | - return $rows; |
|
| 2099 | + return $rows; |
|
| 2100 | 2100 | } |
| 2101 | 2101 | |
| 2102 | 2102 | /** |
@@ -2111,14 +2111,14 @@ discard block |
||
| 2111 | 2111 | */ |
| 2112 | 2112 | function geodir_function_widget_listings_fields($fields) |
| 2113 | 2113 | {
|
| 2114 | - global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2114 | + global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2115 | 2115 | |
| 2116 | - $query_args = $gd_query_args_widgets; |
|
| 2117 | - if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2118 | - return $fields; |
|
| 2119 | - } |
|
| 2116 | + $query_args = $gd_query_args_widgets; |
|
| 2117 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2118 | + return $fields; |
|
| 2119 | + } |
|
| 2120 | 2120 | |
| 2121 | - return $fields; |
|
| 2121 | + return $fields; |
|
| 2122 | 2122 | } |
| 2123 | 2123 | |
| 2124 | 2124 | /** |
@@ -2133,28 +2133,28 @@ discard block |
||
| 2133 | 2133 | */ |
| 2134 | 2134 | function geodir_function_widget_listings_join($join) |
| 2135 | 2135 | {
|
| 2136 | - global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2136 | + global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2137 | 2137 | |
| 2138 | - $query_args = $gd_query_args_widgets; |
|
| 2139 | - if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2140 | - return $join; |
|
| 2141 | - } |
|
| 2138 | + $query_args = $gd_query_args_widgets; |
|
| 2139 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2140 | + return $join; |
|
| 2141 | + } |
|
| 2142 | 2142 | |
| 2143 | - $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 2144 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2143 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 2144 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2145 | 2145 | |
| 2146 | - if (!empty($query_args['with_pics_only'])) {
|
|
| 2147 | - $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )"; |
|
| 2148 | - } |
|
| 2146 | + if (!empty($query_args['with_pics_only'])) {
|
|
| 2147 | + $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )"; |
|
| 2148 | + } |
|
| 2149 | 2149 | |
| 2150 | - if (!empty($query_args['tax_query'])) {
|
|
| 2151 | - $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID'); |
|
| 2152 | - if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
|
|
| 2153 | - $join .= $tax_queries['join']; |
|
| 2154 | - } |
|
| 2155 | - } |
|
| 2150 | + if (!empty($query_args['tax_query'])) {
|
|
| 2151 | + $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID'); |
|
| 2152 | + if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
|
|
| 2153 | + $join .= $tax_queries['join']; |
|
| 2154 | + } |
|
| 2155 | + } |
|
| 2156 | 2156 | |
| 2157 | - return $join; |
|
| 2157 | + return $join; |
|
| 2158 | 2158 | } |
| 2159 | 2159 | |
| 2160 | 2160 | /** |
@@ -2169,54 +2169,54 @@ discard block |
||
| 2169 | 2169 | */ |
| 2170 | 2170 | function geodir_function_widget_listings_where($where) |
| 2171 | 2171 | {
|
| 2172 | - global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2173 | - |
|
| 2174 | - $query_args = $gd_query_args_widgets; |
|
| 2175 | - if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2176 | - return $where; |
|
| 2177 | - } |
|
| 2178 | - $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 2179 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2180 | - |
|
| 2181 | - if (!empty($query_args)) {
|
|
| 2182 | - if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
|
|
| 2183 | - $where = geodir_default_location_where($where, $table); |
|
| 2184 | - } |
|
| 2185 | - |
|
| 2186 | - if (!empty($query_args['post_author'])) {
|
|
| 2187 | - $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author']; |
|
| 2188 | - } |
|
| 2189 | - |
|
| 2190 | - if (!empty($query_args['show_featured_only'])) {
|
|
| 2191 | - $where .= " AND " . $table . ".is_featured = '1'"; |
|
| 2192 | - } |
|
| 2172 | + global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2193 | 2173 | |
| 2194 | - if (!empty($query_args['show_special_only'])) {
|
|
| 2195 | - $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )"; |
|
| 2196 | - } |
|
| 2174 | + $query_args = $gd_query_args_widgets; |
|
| 2175 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2176 | + return $where; |
|
| 2177 | + } |
|
| 2178 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 2179 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2197 | 2180 | |
| 2198 | - if (!empty($query_args['with_pics_only'])) {
|
|
| 2199 | - $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL "; |
|
| 2200 | - } |
|
| 2181 | + if (!empty($query_args)) {
|
|
| 2182 | + if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
|
|
| 2183 | + $where = geodir_default_location_where($where, $table); |
|
| 2184 | + } |
|
| 2201 | 2185 | |
| 2202 | - if (!empty($query_args['featured_image_only'])) {
|
|
| 2203 | - $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' "; |
|
| 2204 | - } |
|
| 2186 | + if (!empty($query_args['post_author'])) {
|
|
| 2187 | + $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author']; |
|
| 2188 | + } |
|
| 2189 | + |
|
| 2190 | + if (!empty($query_args['show_featured_only'])) {
|
|
| 2191 | + $where .= " AND " . $table . ".is_featured = '1'"; |
|
| 2192 | + } |
|
| 2205 | 2193 | |
| 2206 | - if (!empty($query_args['with_videos_only'])) {
|
|
| 2207 | - $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )"; |
|
| 2208 | - } |
|
| 2194 | + if (!empty($query_args['show_special_only'])) {
|
|
| 2195 | + $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )"; |
|
| 2196 | + } |
|
| 2209 | 2197 | |
| 2210 | - if (!empty($query_args['tax_query'])) {
|
|
| 2211 | - $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID'); |
|
| 2198 | + if (!empty($query_args['with_pics_only'])) {
|
|
| 2199 | + $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL "; |
|
| 2200 | + } |
|
| 2212 | 2201 | |
| 2213 | - if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
|
|
| 2214 | - $where .= $tax_queries['where']; |
|
| 2215 | - } |
|
| 2216 | - } |
|
| 2217 | - } |
|
| 2202 | + if (!empty($query_args['featured_image_only'])) {
|
|
| 2203 | + $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' "; |
|
| 2204 | + } |
|
| 2218 | 2205 | |
| 2219 | - return $where; |
|
| 2206 | + if (!empty($query_args['with_videos_only'])) {
|
|
| 2207 | + $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )"; |
|
| 2208 | + } |
|
| 2209 | + |
|
| 2210 | + if (!empty($query_args['tax_query'])) {
|
|
| 2211 | + $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID'); |
|
| 2212 | + |
|
| 2213 | + if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
|
|
| 2214 | + $where .= $tax_queries['where']; |
|
| 2215 | + } |
|
| 2216 | + } |
|
| 2217 | + } |
|
| 2218 | + |
|
| 2219 | + return $where; |
|
| 2220 | 2220 | } |
| 2221 | 2221 | |
| 2222 | 2222 | /** |
@@ -2231,14 +2231,14 @@ discard block |
||
| 2231 | 2231 | */ |
| 2232 | 2232 | function geodir_function_widget_listings_orderby($orderby) |
| 2233 | 2233 | {
|
| 2234 | - global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2234 | + global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2235 | 2235 | |
| 2236 | - $query_args = $gd_query_args_widgets; |
|
| 2237 | - if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2238 | - return $orderby; |
|
| 2239 | - } |
|
| 2236 | + $query_args = $gd_query_args_widgets; |
|
| 2237 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2238 | + return $orderby; |
|
| 2239 | + } |
|
| 2240 | 2240 | |
| 2241 | - return $orderby; |
|
| 2241 | + return $orderby; |
|
| 2242 | 2242 | } |
| 2243 | 2243 | |
| 2244 | 2244 | /** |
@@ -2253,18 +2253,18 @@ discard block |
||
| 2253 | 2253 | */ |
| 2254 | 2254 | function geodir_function_widget_listings_limit($limit) |
| 2255 | 2255 | {
|
| 2256 | - global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2256 | + global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2257 | 2257 | |
| 2258 | - $query_args = $gd_query_args_widgets; |
|
| 2259 | - if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2260 | - return $limit; |
|
| 2261 | - } |
|
| 2258 | + $query_args = $gd_query_args_widgets; |
|
| 2259 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2260 | + return $limit; |
|
| 2261 | + } |
|
| 2262 | 2262 | |
| 2263 | - if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
|
|
| 2264 | - $limit = (int)$query_args['posts_per_page']; |
|
| 2265 | - } |
|
| 2263 | + if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
|
|
| 2264 | + $limit = (int)$query_args['posts_per_page']; |
|
| 2265 | + } |
|
| 2266 | 2266 | |
| 2267 | - return $limit; |
|
| 2267 | + return $limit; |
|
| 2268 | 2268 | } |
| 2269 | 2269 | |
| 2270 | 2270 | /** |
@@ -2278,24 +2278,24 @@ discard block |
||
| 2278 | 2278 | */ |
| 2279 | 2279 | function geodir_media_image_large_width($default = 800, $params = '') |
| 2280 | 2280 | {
|
| 2281 | - $large_size_w = get_option('large_size_w');
|
|
| 2282 | - $large_size_w = $large_size_w > 0 ? $large_size_w : $default; |
|
| 2283 | - $large_size_w = absint($large_size_w); |
|
| 2284 | - |
|
| 2285 | - if (!get_option('geodir_use_wp_media_large_size')) {
|
|
| 2286 | - $large_size_w = 800; |
|
| 2287 | - } |
|
| 2288 | - |
|
| 2289 | - /** |
|
| 2290 | - * Filter large image width. |
|
| 2291 | - * |
|
| 2292 | - * @since 1.0.0 |
|
| 2293 | - * @param int $large_size_w Large image width. |
|
| 2294 | - * @param int $default Default width. |
|
| 2295 | - * @param string|array $params Image parameters. |
|
| 2296 | - */ |
|
| 2297 | - $large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
|
|
| 2298 | - return $large_size_w; |
|
| 2281 | + $large_size_w = get_option('large_size_w');
|
|
| 2282 | + $large_size_w = $large_size_w > 0 ? $large_size_w : $default; |
|
| 2283 | + $large_size_w = absint($large_size_w); |
|
| 2284 | + |
|
| 2285 | + if (!get_option('geodir_use_wp_media_large_size')) {
|
|
| 2286 | + $large_size_w = 800; |
|
| 2287 | + } |
|
| 2288 | + |
|
| 2289 | + /** |
|
| 2290 | + * Filter large image width. |
|
| 2291 | + * |
|
| 2292 | + * @since 1.0.0 |
|
| 2293 | + * @param int $large_size_w Large image width. |
|
| 2294 | + * @param int $default Default width. |
|
| 2295 | + * @param string|array $params Image parameters. |
|
| 2296 | + */ |
|
| 2297 | + $large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
|
|
| 2298 | + return $large_size_w; |
|
| 2299 | 2299 | } |
| 2300 | 2300 | |
| 2301 | 2301 | /** |
@@ -2309,25 +2309,25 @@ discard block |
||
| 2309 | 2309 | */ |
| 2310 | 2310 | function geodir_media_image_large_height($default = 800, $params = '') |
| 2311 | 2311 | {
|
| 2312 | - $large_size_h = get_option('large_size_h');
|
|
| 2313 | - $large_size_h = $large_size_h > 0 ? $large_size_h : $default; |
|
| 2314 | - $large_size_h = absint($large_size_h); |
|
| 2315 | - |
|
| 2316 | - if (!get_option('geodir_use_wp_media_large_size')) {
|
|
| 2317 | - $large_size_h = 800; |
|
| 2318 | - } |
|
| 2319 | - |
|
| 2320 | - /** |
|
| 2321 | - * Filter large image height. |
|
| 2322 | - * |
|
| 2323 | - * @since 1.0.0 |
|
| 2324 | - * @param int $large_size_h Large image height. |
|
| 2325 | - * @param int $default Default height. |
|
| 2326 | - * @param string|array $params Image parameters. |
|
| 2327 | - */ |
|
| 2328 | - $large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
|
|
| 2312 | + $large_size_h = get_option('large_size_h');
|
|
| 2313 | + $large_size_h = $large_size_h > 0 ? $large_size_h : $default; |
|
| 2314 | + $large_size_h = absint($large_size_h); |
|
| 2315 | + |
|
| 2316 | + if (!get_option('geodir_use_wp_media_large_size')) {
|
|
| 2317 | + $large_size_h = 800; |
|
| 2318 | + } |
|
| 2329 | 2319 | |
| 2330 | - return $large_size_h; |
|
| 2320 | + /** |
|
| 2321 | + * Filter large image height. |
|
| 2322 | + * |
|
| 2323 | + * @since 1.0.0 |
|
| 2324 | + * @param int $large_size_h Large image height. |
|
| 2325 | + * @param int $default Default height. |
|
| 2326 | + * @param string|array $params Image parameters. |
|
| 2327 | + */ |
|
| 2328 | + $large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
|
|
| 2329 | + |
|
| 2330 | + return $large_size_h; |
|
| 2331 | 2331 | } |
| 2332 | 2332 | |
| 2333 | 2333 | /** |
@@ -2342,25 +2342,25 @@ discard block |
||
| 2342 | 2342 | */ |
| 2343 | 2343 | function geodir_sanitize_location_name($type, $name, $translate = true) |
| 2344 | 2344 | {
|
| 2345 | - if ($name == '') {
|
|
| 2346 | - return NULL; |
|
| 2347 | - } |
|
| 2348 | - |
|
| 2349 | - $type = $type == 'gd_country' ? 'country' : $type; |
|
| 2350 | - $type = $type == 'gd_region' ? 'region' : $type; |
|
| 2351 | - $type = $type == 'gd_city' ? 'city' : $type; |
|
| 2352 | - |
|
| 2353 | - $return = $name; |
|
| 2354 | - if (function_exists('get_actual_location_name')) {
|
|
| 2355 | - $return = get_actual_location_name($type, $name, $translate); |
|
| 2356 | - } else {
|
|
| 2357 | - $return = preg_replace('/-(\d+)$/', '', $return);
|
|
| 2358 | - $return = preg_replace('/[_-]/', ' ', $return);
|
|
| 2359 | - $return = geodir_ucwords($return); |
|
| 2360 | - $return = $translate ? __($return, 'geodirectory') : $return; |
|
| 2361 | - } |
|
| 2362 | - |
|
| 2363 | - return $return; |
|
| 2345 | + if ($name == '') {
|
|
| 2346 | + return NULL; |
|
| 2347 | + } |
|
| 2348 | + |
|
| 2349 | + $type = $type == 'gd_country' ? 'country' : $type; |
|
| 2350 | + $type = $type == 'gd_region' ? 'region' : $type; |
|
| 2351 | + $type = $type == 'gd_city' ? 'city' : $type; |
|
| 2352 | + |
|
| 2353 | + $return = $name; |
|
| 2354 | + if (function_exists('get_actual_location_name')) {
|
|
| 2355 | + $return = get_actual_location_name($type, $name, $translate); |
|
| 2356 | + } else {
|
|
| 2357 | + $return = preg_replace('/-(\d+)$/', '', $return);
|
|
| 2358 | + $return = preg_replace('/[_-]/', ' ', $return);
|
|
| 2359 | + $return = geodir_ucwords($return); |
|
| 2360 | + $return = $translate ? __($return, 'geodirectory') : $return; |
|
| 2361 | + } |
|
| 2362 | + |
|
| 2363 | + return $return; |
|
| 2364 | 2364 | } |
| 2365 | 2365 | |
| 2366 | 2366 | |
@@ -2374,14 +2374,14 @@ discard block |
||
| 2374 | 2374 | function geodir_comments_number($number) |
| 2375 | 2375 | {
|
| 2376 | 2376 | |
| 2377 | - if ($number > 1) {
|
|
| 2378 | - $output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
|
|
| 2379 | - } elseif ($number == 0 || $number == '') {
|
|
| 2380 | - $output = __('No Reviews', 'geodirectory');
|
|
| 2381 | - } else { // must be one
|
|
| 2382 | - $output = __('1 Review', 'geodirectory');
|
|
| 2383 | - } |
|
| 2384 | - echo $output; |
|
| 2377 | + if ($number > 1) {
|
|
| 2378 | + $output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
|
|
| 2379 | + } elseif ($number == 0 || $number == '') {
|
|
| 2380 | + $output = __('No Reviews', 'geodirectory');
|
|
| 2381 | + } else { // must be one
|
|
| 2382 | + $output = __('1 Review', 'geodirectory');
|
|
| 2383 | + } |
|
| 2384 | + echo $output; |
|
| 2385 | 2385 | } |
| 2386 | 2386 | |
| 2387 | 2387 | /** |
@@ -2394,23 +2394,23 @@ discard block |
||
| 2394 | 2394 | */ |
| 2395 | 2395 | function is_page_geodir_home() |
| 2396 | 2396 | {
|
| 2397 | - global $wpdb; |
|
| 2398 | - $cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
|
|
| 2399 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 2400 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 2401 | - } |
|
| 2402 | - $home_url = home_url('', 'http');
|
|
| 2403 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 2404 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 2405 | - } |
|
| 2406 | - $home_url = str_replace("www.", "", $home_url);
|
|
| 2407 | - if ( (strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')) ) {
|
|
| 2408 | - return true; |
|
| 2409 | - }elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
|
|
| 2410 | - return true; |
|
| 2411 | - } else {
|
|
| 2412 | - return false; |
|
| 2413 | - } |
|
| 2397 | + global $wpdb; |
|
| 2398 | + $cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
|
|
| 2399 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 2400 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 2401 | + } |
|
| 2402 | + $home_url = home_url('', 'http');
|
|
| 2403 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 2404 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 2405 | + } |
|
| 2406 | + $home_url = str_replace("www.", "", $home_url);
|
|
| 2407 | + if ( (strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')) ) {
|
|
| 2408 | + return true; |
|
| 2409 | + }elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
|
|
| 2410 | + return true; |
|
| 2411 | + } else {
|
|
| 2412 | + return false; |
|
| 2413 | + } |
|
| 2414 | 2414 | |
| 2415 | 2415 | } |
| 2416 | 2416 | |
@@ -2426,13 +2426,13 @@ discard block |
||
| 2426 | 2426 | */ |
| 2427 | 2427 | function geodir_wpseo_homepage_canonical($url) |
| 2428 | 2428 | {
|
| 2429 | - global $post; |
|
| 2429 | + global $post; |
|
| 2430 | 2430 | |
| 2431 | - if (is_page_geodir_home()) {
|
|
| 2432 | - return home_url(); |
|
| 2433 | - } |
|
| 2431 | + if (is_page_geodir_home()) {
|
|
| 2432 | + return home_url(); |
|
| 2433 | + } |
|
| 2434 | 2434 | |
| 2435 | - return $url; |
|
| 2435 | + return $url; |
|
| 2436 | 2436 | } |
| 2437 | 2437 | |
| 2438 | 2438 | add_filter('wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10);
|
@@ -2449,16 +2449,16 @@ discard block |
||
| 2449 | 2449 | */ |
| 2450 | 2450 | function geodir_googlemap_script_extra_details_page($extra) |
| 2451 | 2451 | {
|
| 2452 | - global $post; |
|
| 2453 | - $add_google_places_api = false; |
|
| 2454 | - if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
|
|
| 2455 | - $add_google_places_api = true; |
|
| 2456 | - } |
|
| 2457 | - if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
|
|
| 2458 | - $extra .= "&libraries=places"; |
|
| 2459 | - } |
|
| 2460 | - |
|
| 2461 | - return $extra; |
|
| 2452 | + global $post; |
|
| 2453 | + $add_google_places_api = false; |
|
| 2454 | + if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
|
|
| 2455 | + $add_google_places_api = true; |
|
| 2456 | + } |
|
| 2457 | + if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
|
|
| 2458 | + $extra .= "&libraries=places"; |
|
| 2459 | + } |
|
| 2460 | + |
|
| 2461 | + return $extra; |
|
| 2462 | 2462 | } |
| 2463 | 2463 | |
| 2464 | 2464 | add_filter('geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1);
|
@@ -2478,98 +2478,98 @@ discard block |
||
| 2478 | 2478 | */ |
| 2479 | 2479 | function geodir_popular_post_category_output($args = '', $instance = '') |
| 2480 | 2480 | {
|
| 2481 | - // prints the widget |
|
| 2482 | - global $wpdb, $plugin_prefix, $geodir_post_category_str; |
|
| 2483 | - extract($args, EXTR_SKIP); |
|
| 2484 | - |
|
| 2485 | - echo $before_widget; |
|
| 2486 | - |
|
| 2487 | - /** This filter is documented in geodirectory_widgets.php */ |
|
| 2488 | - $title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2489 | - |
|
| 2490 | - $gd_post_type = geodir_get_current_posttype(); |
|
| 2491 | - |
|
| 2492 | - $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15; |
|
| 2493 | - if(!empty($gd_post_type)){
|
|
| 2494 | - $default_post_type = $gd_post_type; |
|
| 2495 | - }elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
|
|
| 2496 | - $default_post_type = $instance['default_post_type']; |
|
| 2497 | - }else{
|
|
| 2498 | - $all_gd_post_type = geodir_get_posttypes(); |
|
| 2499 | - $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : ''; |
|
| 2500 | - } |
|
| 2501 | - |
|
| 2502 | - $taxonomy = array(); |
|
| 2503 | - if (!empty($gd_post_type)) {
|
|
| 2504 | - $taxonomy[] = $gd_post_type . "category"; |
|
| 2505 | - } else {
|
|
| 2506 | - $taxonomy = geodir_get_taxonomies($gd_post_type); |
|
| 2507 | - } |
|
| 2508 | - |
|
| 2509 | - $terms = get_terms($taxonomy); |
|
| 2510 | - $a_terms = array(); |
|
| 2511 | - $b_terms = array(); |
|
| 2512 | - |
|
| 2513 | - foreach ($terms as $term) {
|
|
| 2514 | - if ($term->count > 0) {
|
|
| 2515 | - $a_terms[$term->taxonomy][] = $term; |
|
| 2516 | - } |
|
| 2517 | - } |
|
| 2518 | - |
|
| 2519 | - if (!empty($a_terms)) {
|
|
| 2520 | - foreach ($a_terms as $b_key => $b_val) {
|
|
| 2521 | - $b_terms[$b_key] = geodir_sort_terms($b_val, 'count'); |
|
| 2522 | - } |
|
| 2523 | - |
|
| 2524 | - $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : ''; |
|
| 2525 | - |
|
| 2526 | - $tax_change_output = ''; |
|
| 2527 | - if (count($b_terms) > 1) {
|
|
| 2528 | - $tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax' onchange='geodir_get_post_term(this);'>"; |
|
| 2529 | - foreach ($b_terms as $key => $val) {
|
|
| 2530 | - $ptype = get_post_type_object(str_replace("category", "", $key));
|
|
| 2531 | - $cpt_name = __($ptype->labels->singular_name, 'geodirectory'); |
|
| 2532 | - $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
|
|
| 2533 | - } |
|
| 2534 | - $tax_change_output .= "</select>"; |
|
| 2535 | - } |
|
| 2536 | - |
|
| 2537 | - if (!empty($b_terms)) {
|
|
| 2538 | - $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array |
|
| 2539 | - global $cat_count;//make global so we can change via function |
|
| 2540 | - $cat_count = 0; |
|
| 2541 | - ?> |
|
| 2481 | + // prints the widget |
|
| 2482 | + global $wpdb, $plugin_prefix, $geodir_post_category_str; |
|
| 2483 | + extract($args, EXTR_SKIP); |
|
| 2484 | + |
|
| 2485 | + echo $before_widget; |
|
| 2486 | + |
|
| 2487 | + /** This filter is documented in geodirectory_widgets.php */ |
|
| 2488 | + $title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2489 | + |
|
| 2490 | + $gd_post_type = geodir_get_current_posttype(); |
|
| 2491 | + |
|
| 2492 | + $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15; |
|
| 2493 | + if(!empty($gd_post_type)){
|
|
| 2494 | + $default_post_type = $gd_post_type; |
|
| 2495 | + }elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
|
|
| 2496 | + $default_post_type = $instance['default_post_type']; |
|
| 2497 | + }else{
|
|
| 2498 | + $all_gd_post_type = geodir_get_posttypes(); |
|
| 2499 | + $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : ''; |
|
| 2500 | + } |
|
| 2501 | + |
|
| 2502 | + $taxonomy = array(); |
|
| 2503 | + if (!empty($gd_post_type)) {
|
|
| 2504 | + $taxonomy[] = $gd_post_type . "category"; |
|
| 2505 | + } else {
|
|
| 2506 | + $taxonomy = geodir_get_taxonomies($gd_post_type); |
|
| 2507 | + } |
|
| 2508 | + |
|
| 2509 | + $terms = get_terms($taxonomy); |
|
| 2510 | + $a_terms = array(); |
|
| 2511 | + $b_terms = array(); |
|
| 2512 | + |
|
| 2513 | + foreach ($terms as $term) {
|
|
| 2514 | + if ($term->count > 0) {
|
|
| 2515 | + $a_terms[$term->taxonomy][] = $term; |
|
| 2516 | + } |
|
| 2517 | + } |
|
| 2518 | + |
|
| 2519 | + if (!empty($a_terms)) {
|
|
| 2520 | + foreach ($a_terms as $b_key => $b_val) {
|
|
| 2521 | + $b_terms[$b_key] = geodir_sort_terms($b_val, 'count'); |
|
| 2522 | + } |
|
| 2523 | + |
|
| 2524 | + $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : ''; |
|
| 2525 | + |
|
| 2526 | + $tax_change_output = ''; |
|
| 2527 | + if (count($b_terms) > 1) {
|
|
| 2528 | + $tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax' onchange='geodir_get_post_term(this);'>"; |
|
| 2529 | + foreach ($b_terms as $key => $val) {
|
|
| 2530 | + $ptype = get_post_type_object(str_replace("category", "", $key));
|
|
| 2531 | + $cpt_name = __($ptype->labels->singular_name, 'geodirectory'); |
|
| 2532 | + $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
|
|
| 2533 | + } |
|
| 2534 | + $tax_change_output .= "</select>"; |
|
| 2535 | + } |
|
| 2536 | + |
|
| 2537 | + if (!empty($b_terms)) {
|
|
| 2538 | + $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array |
|
| 2539 | + global $cat_count;//make global so we can change via function |
|
| 2540 | + $cat_count = 0; |
|
| 2541 | + ?> |
|
| 2542 | 2542 | <div class="geodir-category-list-in clearfix"> |
| 2543 | 2543 | <div class="geodir-cat-list clearfix"> |
| 2544 | 2544 | <?php |
| 2545 | - echo $before_title . __($title) . $after_title; |
|
| 2545 | + echo $before_title . __($title) . $after_title; |
|
| 2546 | 2546 | |
| 2547 | - echo $tax_change_output; |
|
| 2547 | + echo $tax_change_output; |
|
| 2548 | 2548 | |
| 2549 | - echo '<ul class="geodir-popular-cat-list">'; |
|
| 2549 | + echo '<ul class="geodir-popular-cat-list">'; |
|
| 2550 | 2550 | |
| 2551 | - geodir_helper_cat_list_output($terms, $category_limit); |
|
| 2551 | + geodir_helper_cat_list_output($terms, $category_limit); |
|
| 2552 | 2552 | |
| 2553 | - echo '</ul>'; |
|
| 2554 | - ?> |
|
| 2553 | + echo '</ul>'; |
|
| 2554 | + ?> |
|
| 2555 | 2555 | </div> |
| 2556 | 2556 | <?php |
| 2557 | - $hide = ''; |
|
| 2558 | - if ($cat_count < $category_limit) {
|
|
| 2559 | - $hide = 'style="display:none;"'; |
|
| 2560 | - } |
|
| 2561 | - echo "<div class='geodir-cat-list-more' $hide >"; |
|
| 2562 | - echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
|
|
| 2563 | - echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
|
|
| 2564 | - echo "</div>"; |
|
| 2565 | - /* add scripts */ |
|
| 2566 | - add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
|
|
| 2567 | - ?> |
|
| 2557 | + $hide = ''; |
|
| 2558 | + if ($cat_count < $category_limit) {
|
|
| 2559 | + $hide = 'style="display:none;"'; |
|
| 2560 | + } |
|
| 2561 | + echo "<div class='geodir-cat-list-more' $hide >"; |
|
| 2562 | + echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
|
|
| 2563 | + echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
|
|
| 2564 | + echo "</div>"; |
|
| 2565 | + /* add scripts */ |
|
| 2566 | + add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
|
|
| 2567 | + ?> |
|
| 2568 | 2568 | </div> |
| 2569 | 2569 | <?php |
| 2570 | - } |
|
| 2571 | - } |
|
| 2572 | - echo $after_widget; |
|
| 2570 | + } |
|
| 2571 | + } |
|
| 2572 | + echo $after_widget; |
|
| 2573 | 2573 | } |
| 2574 | 2574 | |
| 2575 | 2575 | /** |
@@ -2583,38 +2583,38 @@ discard block |
||
| 2583 | 2583 | */ |
| 2584 | 2584 | function geodir_helper_cat_list_output($terms, $category_limit) |
| 2585 | 2585 | {
|
| 2586 | - global $geodir_post_category_str, $cat_count; |
|
| 2587 | - $term_icons = geodir_get_term_icon(); |
|
| 2586 | + global $geodir_post_category_str, $cat_count; |
|
| 2587 | + $term_icons = geodir_get_term_icon(); |
|
| 2588 | 2588 | |
| 2589 | - $geodir_post_category_str = array(); |
|
| 2589 | + $geodir_post_category_str = array(); |
|
| 2590 | 2590 | |
| 2591 | 2591 | |
| 2592 | - foreach ($terms as $cat) {
|
|
| 2593 | - $post_type = str_replace("category", "", $cat->taxonomy);
|
|
| 2594 | - $term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : ''; |
|
| 2592 | + foreach ($terms as $cat) {
|
|
| 2593 | + $post_type = str_replace("category", "", $cat->taxonomy);
|
|
| 2594 | + $term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : ''; |
|
| 2595 | 2595 | |
| 2596 | - $cat_count++; |
|
| 2596 | + $cat_count++; |
|
| 2597 | 2597 | |
| 2598 | - $geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
|
|
| 2598 | + $geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
|
|
| 2599 | 2599 | |
| 2600 | - $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show'; |
|
| 2601 | - $total_post = $cat->count; |
|
| 2600 | + $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show'; |
|
| 2601 | + $total_post = $cat->count; |
|
| 2602 | 2602 | |
| 2603 | - $term_link = get_term_link( $cat, $cat->taxonomy ); |
|
| 2604 | - /** |
|
| 2605 | - * Filer the category term link. |
|
| 2606 | - * |
|
| 2607 | - * @since 1.4.5 |
|
| 2608 | - * @param string $term_link The term permalink. |
|
| 2609 | - * @param int $cat->term_id The term id. |
|
| 2610 | - * @param string $post_type Wordpress post type. |
|
| 2611 | - */ |
|
| 2612 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type ); |
|
| 2603 | + $term_link = get_term_link( $cat, $cat->taxonomy ); |
|
| 2604 | + /** |
|
| 2605 | + * Filer the category term link. |
|
| 2606 | + * |
|
| 2607 | + * @since 1.4.5 |
|
| 2608 | + * @param string $term_link The term permalink. |
|
| 2609 | + * @param int $cat->term_id The term id. |
|
| 2610 | + * @param string $post_type Wordpress post type. |
|
| 2611 | + */ |
|
| 2612 | + $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type ); |
|
| 2613 | 2613 | |
| 2614 | - echo '<li class="' . $class_row . '"><a href="' . $term_link . '">'; |
|
| 2615 | - echo '<img alt="' . esc_attr($cat->name) . ' icon" style="height:20px;vertical-align:middle;" src="' . $term_icon_url . '"/> <span class="cat-link">'; echo $cat->name . '</span> <span class="geodir_term_class geodir_link_span geodir_category_class_' . $post_type . '_' . $cat->term_id . '">(' . $total_post . ')</span> ';
|
|
| 2616 | - echo '</a></li>'; |
|
| 2617 | - } |
|
| 2614 | + echo '<li class="' . $class_row . '"><a href="' . $term_link . '">'; |
|
| 2615 | + echo '<img alt="' . esc_attr($cat->name) . ' icon" style="height:20px;vertical-align:middle;" src="' . $term_icon_url . '"/> <span class="cat-link">'; echo $cat->name . '</span> <span class="geodir_term_class geodir_link_span geodir_category_class_' . $post_type . '_' . $cat->term_id . '">(' . $total_post . ')</span> ';
|
|
| 2616 | + echo '</a></li>'; |
|
| 2617 | + } |
|
| 2618 | 2618 | } |
| 2619 | 2619 | |
| 2620 | 2620 | /** |
@@ -2628,108 +2628,108 @@ discard block |
||
| 2628 | 2628 | */ |
| 2629 | 2629 | function geodir_listing_slider_widget_output($args = '', $instance = '') |
| 2630 | 2630 | {
|
| 2631 | - // prints the widget |
|
| 2632 | - extract($args, EXTR_SKIP); |
|
| 2633 | - |
|
| 2634 | - echo $before_widget; |
|
| 2635 | - |
|
| 2636 | - /** This filter is documented in geodirectory_widgets.php */ |
|
| 2637 | - $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2638 | - /** |
|
| 2639 | - * Filter the widget post type. |
|
| 2640 | - * |
|
| 2641 | - * @since 1.0.0 |
|
| 2642 | - * @param string $instance['post_type'] Post type of listing. |
|
| 2643 | - */ |
|
| 2644 | - $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
|
|
| 2645 | - /** |
|
| 2646 | - * Filter the widget's term. |
|
| 2647 | - * |
|
| 2648 | - * @since 1.0.0 |
|
| 2649 | - * @param string $instance['category'] Filter by term. Can be any valid term. |
|
| 2650 | - */ |
|
| 2651 | - $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
|
|
| 2652 | - /** |
|
| 2653 | - * Filter the widget listings limit. |
|
| 2654 | - * |
|
| 2655 | - * @since 1.0.0 |
|
| 2656 | - * @param string $instance['post_number'] Number of listings to display. |
|
| 2657 | - */ |
|
| 2658 | - $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
|
|
| 2659 | - /** |
|
| 2660 | - * Filter the widget listings limit shown at one time. |
|
| 2661 | - * |
|
| 2662 | - * @since 1.5.0 |
|
| 2663 | - * @param string $instance['max_show'] Number of listings to display on screen. |
|
| 2664 | - */ |
|
| 2665 | - $max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
|
|
| 2666 | - /** |
|
| 2667 | - * Filter the widget slide width. |
|
| 2668 | - * |
|
| 2669 | - * @since 1.5.0 |
|
| 2670 | - * @param string $instance['slide_width'] Width of the slides shown. |
|
| 2671 | - */ |
|
| 2672 | - $slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
|
|
| 2673 | - /** |
|
| 2674 | - * Filter widget's "show title" value. |
|
| 2675 | - * |
|
| 2676 | - * @since 1.0.0 |
|
| 2677 | - * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0. |
|
| 2678 | - */ |
|
| 2679 | - $show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
|
|
| 2680 | - /** |
|
| 2681 | - * Filter widget's "slideshow" value. |
|
| 2682 | - * |
|
| 2683 | - * @since 1.0.0 |
|
| 2684 | - * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically. |
|
| 2685 | - */ |
|
| 2686 | - $slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
|
|
| 2687 | - /** |
|
| 2688 | - * Filter widget's "animationLoop" value. |
|
| 2689 | - * |
|
| 2690 | - * @since 1.0.0 |
|
| 2691 | - * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop. |
|
| 2692 | - */ |
|
| 2693 | - $animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
|
|
| 2694 | - /** |
|
| 2695 | - * Filter widget's "directionNav" value. |
|
| 2696 | - * |
|
| 2697 | - * @since 1.0.0 |
|
| 2698 | - * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0. |
|
| 2699 | - */ |
|
| 2700 | - $directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
|
|
| 2701 | - /** |
|
| 2702 | - * Filter widget's "slideshowSpeed" value. |
|
| 2703 | - * |
|
| 2704 | - * @since 1.0.0 |
|
| 2705 | - * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds. |
|
| 2706 | - */ |
|
| 2707 | - $slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
|
|
| 2708 | - /** |
|
| 2709 | - * Filter widget's "animationSpeed" value. |
|
| 2710 | - * |
|
| 2711 | - * @since 1.0.0 |
|
| 2712 | - * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds. |
|
| 2713 | - */ |
|
| 2714 | - $animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
|
|
| 2715 | - /** |
|
| 2716 | - * Filter widget's "animation" value. |
|
| 2717 | - * |
|
| 2718 | - * @since 1.0.0 |
|
| 2719 | - * @param string $instance['animation'] Controls the animation type, "fade" or "slide". |
|
| 2720 | - */ |
|
| 2721 | - $animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
|
|
| 2722 | - /** |
|
| 2723 | - * Filter widget's "list_sort" type. |
|
| 2724 | - * |
|
| 2725 | - * @since 1.0.0 |
|
| 2726 | - * @param string $instance['list_sort'] Listing sort by type. |
|
| 2727 | - */ |
|
| 2728 | - $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
|
|
| 2729 | - $show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL; |
|
| 2730 | - |
|
| 2731 | - wp_enqueue_script('geodirectory-jquery-flexslider-js');
|
|
| 2732 | - ?> |
|
| 2631 | + // prints the widget |
|
| 2632 | + extract($args, EXTR_SKIP); |
|
| 2633 | + |
|
| 2634 | + echo $before_widget; |
|
| 2635 | + |
|
| 2636 | + /** This filter is documented in geodirectory_widgets.php */ |
|
| 2637 | + $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2638 | + /** |
|
| 2639 | + * Filter the widget post type. |
|
| 2640 | + * |
|
| 2641 | + * @since 1.0.0 |
|
| 2642 | + * @param string $instance['post_type'] Post type of listing. |
|
| 2643 | + */ |
|
| 2644 | + $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
|
|
| 2645 | + /** |
|
| 2646 | + * Filter the widget's term. |
|
| 2647 | + * |
|
| 2648 | + * @since 1.0.0 |
|
| 2649 | + * @param string $instance['category'] Filter by term. Can be any valid term. |
|
| 2650 | + */ |
|
| 2651 | + $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
|
|
| 2652 | + /** |
|
| 2653 | + * Filter the widget listings limit. |
|
| 2654 | + * |
|
| 2655 | + * @since 1.0.0 |
|
| 2656 | + * @param string $instance['post_number'] Number of listings to display. |
|
| 2657 | + */ |
|
| 2658 | + $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
|
|
| 2659 | + /** |
|
| 2660 | + * Filter the widget listings limit shown at one time. |
|
| 2661 | + * |
|
| 2662 | + * @since 1.5.0 |
|
| 2663 | + * @param string $instance['max_show'] Number of listings to display on screen. |
|
| 2664 | + */ |
|
| 2665 | + $max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
|
|
| 2666 | + /** |
|
| 2667 | + * Filter the widget slide width. |
|
| 2668 | + * |
|
| 2669 | + * @since 1.5.0 |
|
| 2670 | + * @param string $instance['slide_width'] Width of the slides shown. |
|
| 2671 | + */ |
|
| 2672 | + $slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
|
|
| 2673 | + /** |
|
| 2674 | + * Filter widget's "show title" value. |
|
| 2675 | + * |
|
| 2676 | + * @since 1.0.0 |
|
| 2677 | + * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0. |
|
| 2678 | + */ |
|
| 2679 | + $show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
|
|
| 2680 | + /** |
|
| 2681 | + * Filter widget's "slideshow" value. |
|
| 2682 | + * |
|
| 2683 | + * @since 1.0.0 |
|
| 2684 | + * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically. |
|
| 2685 | + */ |
|
| 2686 | + $slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
|
|
| 2687 | + /** |
|
| 2688 | + * Filter widget's "animationLoop" value. |
|
| 2689 | + * |
|
| 2690 | + * @since 1.0.0 |
|
| 2691 | + * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop. |
|
| 2692 | + */ |
|
| 2693 | + $animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
|
|
| 2694 | + /** |
|
| 2695 | + * Filter widget's "directionNav" value. |
|
| 2696 | + * |
|
| 2697 | + * @since 1.0.0 |
|
| 2698 | + * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0. |
|
| 2699 | + */ |
|
| 2700 | + $directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
|
|
| 2701 | + /** |
|
| 2702 | + * Filter widget's "slideshowSpeed" value. |
|
| 2703 | + * |
|
| 2704 | + * @since 1.0.0 |
|
| 2705 | + * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds. |
|
| 2706 | + */ |
|
| 2707 | + $slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
|
|
| 2708 | + /** |
|
| 2709 | + * Filter widget's "animationSpeed" value. |
|
| 2710 | + * |
|
| 2711 | + * @since 1.0.0 |
|
| 2712 | + * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds. |
|
| 2713 | + */ |
|
| 2714 | + $animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
|
|
| 2715 | + /** |
|
| 2716 | + * Filter widget's "animation" value. |
|
| 2717 | + * |
|
| 2718 | + * @since 1.0.0 |
|
| 2719 | + * @param string $instance['animation'] Controls the animation type, "fade" or "slide". |
|
| 2720 | + */ |
|
| 2721 | + $animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
|
|
| 2722 | + /** |
|
| 2723 | + * Filter widget's "list_sort" type. |
|
| 2724 | + * |
|
| 2725 | + * @since 1.0.0 |
|
| 2726 | + * @param string $instance['list_sort'] Listing sort by type. |
|
| 2727 | + */ |
|
| 2728 | + $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
|
|
| 2729 | + $show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL; |
|
| 2730 | + |
|
| 2731 | + wp_enqueue_script('geodirectory-jquery-flexslider-js');
|
|
| 2732 | + ?> |
|
| 2733 | 2733 | <script type="text/javascript"> |
| 2734 | 2734 | jQuery(window).load(function () {
|
| 2735 | 2735 | jQuery('#geodir_widget_carousel').flexslider({
|
@@ -2770,86 +2770,86 @@ discard block |
||
| 2770 | 2770 | }); |
| 2771 | 2771 | </script> |
| 2772 | 2772 | <?php |
| 2773 | - $query_args = array( |
|
| 2774 | - 'posts_per_page' => $post_number, |
|
| 2775 | - 'is_geodir_loop' => true, |
|
| 2776 | - 'post_type' => $post_type, |
|
| 2777 | - 'order_by' => $list_sort |
|
| 2778 | - ); |
|
| 2779 | - if ($show_featured_only) {
|
|
| 2780 | - $query_args['show_featured_only'] = 1; |
|
| 2781 | - } |
|
| 2782 | - |
|
| 2783 | - if ($category != 0 || $category != '') {
|
|
| 2784 | - $category_taxonomy = geodir_get_taxonomies($post_type); |
|
| 2785 | - $tax_query = array( |
|
| 2786 | - 'taxonomy' => $category_taxonomy[0], |
|
| 2787 | - 'field' => 'id', |
|
| 2788 | - 'terms' => $category |
|
| 2789 | - ); |
|
| 2790 | - |
|
| 2791 | - $query_args['tax_query'] = array($tax_query); |
|
| 2792 | - } |
|
| 2793 | - |
|
| 2794 | - // we want listings with featured image only |
|
| 2795 | - $query_args['featured_image_only'] = 1; |
|
| 2796 | - |
|
| 2797 | - if ($post_type == 'gd_event') {
|
|
| 2798 | - $query_args['gedir_event_listing_filter'] = 'upcoming'; |
|
| 2799 | - }// show only upcomming events |
|
| 2800 | - |
|
| 2801 | - $widget_listings = geodir_get_widget_listings($query_args); |
|
| 2802 | - if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
|
|
| 2803 | - if ($title) {
|
|
| 2804 | - echo $before_title . $title . $after_title; |
|
| 2805 | - } |
|
| 2806 | - |
|
| 2807 | - global $post; |
|
| 2808 | - |
|
| 2809 | - $current_post = $post;// keep current post info |
|
| 2810 | - |
|
| 2811 | - $widget_main_slides = ''; |
|
| 2812 | - $nav_slides = ''; |
|
| 2813 | - $widget_slides = 0; |
|
| 2814 | - |
|
| 2815 | - foreach ($widget_listings as $widget_listing) {
|
|
| 2816 | - global $gd_widget_listing_type; |
|
| 2817 | - $post = $widget_listing; |
|
| 2818 | - $widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
|
|
| 2819 | - |
|
| 2820 | - if (!empty($widget_image)) {
|
|
| 2821 | - if ($widget_image->height >= 200) {
|
|
| 2822 | - $widget_spacer_height = 0; |
|
| 2823 | - } else {
|
|
| 2824 | - $widget_spacer_height = ((200 - $widget_image->height) / 2); |
|
| 2825 | - } |
|
| 2826 | - |
|
| 2827 | - $widget_main_slides .= '<li class="geodir-listing-slider-widget"><img class="geodir-listing-slider-spacer" src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:' . $widget_spacer_height . 'px !important;margin:0 auto;" width="100" />'; |
|
| 2828 | - |
|
| 2829 | - $title = ''; |
|
| 2830 | - if ($show_title) {
|
|
| 2831 | - $title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>'; |
|
| 2832 | - $post_id = $post->ID; |
|
| 2833 | - $post_permalink = get_permalink($post->ID); |
|
| 2834 | - $post_title = get_the_title($post->ID); |
|
| 2835 | - /** |
|
| 2836 | - * Filter the listing slider widget title. |
|
| 2837 | - * |
|
| 2838 | - * @since 1.6.1 |
|
| 2839 | - * @param string $title_html The html output of the title. |
|
| 2840 | - * @param int $post_id The post id. |
|
| 2841 | - * @param string $post_permalink The post permalink url. |
|
| 2842 | - * @param string $post_title The post title text. |
|
| 2843 | - */ |
|
| 2844 | - $title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
|
|
| 2845 | - } |
|
| 2846 | - |
|
| 2847 | - $widget_main_slides .= $title . '<img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:200px;margin:0 auto;" /></li>'; |
|
| 2848 | - $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 2849 | - $widget_slides++; |
|
| 2850 | - } |
|
| 2851 | - } |
|
| 2852 | - ?> |
|
| 2773 | + $query_args = array( |
|
| 2774 | + 'posts_per_page' => $post_number, |
|
| 2775 | + 'is_geodir_loop' => true, |
|
| 2776 | + 'post_type' => $post_type, |
|
| 2777 | + 'order_by' => $list_sort |
|
| 2778 | + ); |
|
| 2779 | + if ($show_featured_only) {
|
|
| 2780 | + $query_args['show_featured_only'] = 1; |
|
| 2781 | + } |
|
| 2782 | + |
|
| 2783 | + if ($category != 0 || $category != '') {
|
|
| 2784 | + $category_taxonomy = geodir_get_taxonomies($post_type); |
|
| 2785 | + $tax_query = array( |
|
| 2786 | + 'taxonomy' => $category_taxonomy[0], |
|
| 2787 | + 'field' => 'id', |
|
| 2788 | + 'terms' => $category |
|
| 2789 | + ); |
|
| 2790 | + |
|
| 2791 | + $query_args['tax_query'] = array($tax_query); |
|
| 2792 | + } |
|
| 2793 | + |
|
| 2794 | + // we want listings with featured image only |
|
| 2795 | + $query_args['featured_image_only'] = 1; |
|
| 2796 | + |
|
| 2797 | + if ($post_type == 'gd_event') {
|
|
| 2798 | + $query_args['gedir_event_listing_filter'] = 'upcoming'; |
|
| 2799 | + }// show only upcomming events |
|
| 2800 | + |
|
| 2801 | + $widget_listings = geodir_get_widget_listings($query_args); |
|
| 2802 | + if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
|
|
| 2803 | + if ($title) {
|
|
| 2804 | + echo $before_title . $title . $after_title; |
|
| 2805 | + } |
|
| 2806 | + |
|
| 2807 | + global $post; |
|
| 2808 | + |
|
| 2809 | + $current_post = $post;// keep current post info |
|
| 2810 | + |
|
| 2811 | + $widget_main_slides = ''; |
|
| 2812 | + $nav_slides = ''; |
|
| 2813 | + $widget_slides = 0; |
|
| 2814 | + |
|
| 2815 | + foreach ($widget_listings as $widget_listing) {
|
|
| 2816 | + global $gd_widget_listing_type; |
|
| 2817 | + $post = $widget_listing; |
|
| 2818 | + $widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
|
|
| 2819 | + |
|
| 2820 | + if (!empty($widget_image)) {
|
|
| 2821 | + if ($widget_image->height >= 200) {
|
|
| 2822 | + $widget_spacer_height = 0; |
|
| 2823 | + } else {
|
|
| 2824 | + $widget_spacer_height = ((200 - $widget_image->height) / 2); |
|
| 2825 | + } |
|
| 2826 | + |
|
| 2827 | + $widget_main_slides .= '<li class="geodir-listing-slider-widget"><img class="geodir-listing-slider-spacer" src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:' . $widget_spacer_height . 'px !important;margin:0 auto;" width="100" />'; |
|
| 2828 | + |
|
| 2829 | + $title = ''; |
|
| 2830 | + if ($show_title) {
|
|
| 2831 | + $title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>'; |
|
| 2832 | + $post_id = $post->ID; |
|
| 2833 | + $post_permalink = get_permalink($post->ID); |
|
| 2834 | + $post_title = get_the_title($post->ID); |
|
| 2835 | + /** |
|
| 2836 | + * Filter the listing slider widget title. |
|
| 2837 | + * |
|
| 2838 | + * @since 1.6.1 |
|
| 2839 | + * @param string $title_html The html output of the title. |
|
| 2840 | + * @param int $post_id The post id. |
|
| 2841 | + * @param string $post_permalink The post permalink url. |
|
| 2842 | + * @param string $post_title The post title text. |
|
| 2843 | + */ |
|
| 2844 | + $title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
|
|
| 2845 | + } |
|
| 2846 | + |
|
| 2847 | + $widget_main_slides .= $title . '<img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:200px;margin:0 auto;" /></li>'; |
|
| 2848 | + $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 2849 | + $widget_slides++; |
|
| 2850 | + } |
|
| 2851 | + } |
|
| 2852 | + ?> |
|
| 2853 | 2853 | <div class="flex-container" style="min-height:200px;"> |
| 2854 | 2854 | <div class="geodir-listing-flex-loader"><i class="fa fa-refresh fa-spin"></i></div> |
| 2855 | 2855 | <div id="geodir_widget_slider" class="geodir_flexslider"> |
@@ -2862,10 +2862,10 @@ discard block |
||
| 2862 | 2862 | <?php } ?> |
| 2863 | 2863 | </div> |
| 2864 | 2864 | <?php |
| 2865 | - $GLOBALS['post'] = $current_post; |
|
| 2866 | - setup_postdata($current_post); |
|
| 2867 | - } |
|
| 2868 | - echo $after_widget; |
|
| 2865 | + $GLOBALS['post'] = $current_post; |
|
| 2866 | + setup_postdata($current_post); |
|
| 2867 | + } |
|
| 2868 | + echo $after_widget; |
|
| 2869 | 2869 | } |
| 2870 | 2870 | |
| 2871 | 2871 | |
@@ -2880,65 +2880,65 @@ discard block |
||
| 2880 | 2880 | */ |
| 2881 | 2881 | function geodir_loginwidget_output($args = '', $instance = '') |
| 2882 | 2882 | {
|
| 2883 | - //print_r($args); |
|
| 2884 | - //print_r($instance); |
|
| 2885 | - // prints the widget |
|
| 2886 | - extract($args, EXTR_SKIP); |
|
| 2883 | + //print_r($args); |
|
| 2884 | + //print_r($instance); |
|
| 2885 | + // prints the widget |
|
| 2886 | + extract($args, EXTR_SKIP); |
|
| 2887 | 2887 | |
| 2888 | - /** This filter is documented in geodirectory_widgets.php */ |
|
| 2889 | - $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2888 | + /** This filter is documented in geodirectory_widgets.php */ |
|
| 2889 | + $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2890 | 2890 | |
| 2891 | - echo $before_widget; |
|
| 2892 | - echo $before_title . $title . $after_title; |
|
| 2891 | + echo $before_widget; |
|
| 2892 | + echo $before_title . $title . $after_title; |
|
| 2893 | 2893 | |
| 2894 | - if (is_user_logged_in()) {
|
|
| 2895 | - global $current_user; |
|
| 2894 | + if (is_user_logged_in()) {
|
|
| 2895 | + global $current_user; |
|
| 2896 | 2896 | |
| 2897 | - $author_link = get_author_posts_url($current_user->data->ID); |
|
| 2898 | - $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
|
|
| 2897 | + $author_link = get_author_posts_url($current_user->data->ID); |
|
| 2898 | + $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
|
|
| 2899 | 2899 | |
| 2900 | - echo '<ul class="geodir-loginbox-list">'; |
|
| 2901 | - ob_start(); |
|
| 2902 | - ?> |
|
| 2900 | + echo '<ul class="geodir-loginbox-list">'; |
|
| 2901 | + ob_start(); |
|
| 2902 | + ?> |
|
| 2903 | 2903 | <li><a class="signin" |
| 2904 | 2904 | href="<?php echo wp_logout_url(home_url()); ?>"><?php _e('Logout', 'geodirectory'); ?></a></li>
|
| 2905 | 2905 | <?php |
| 2906 | - $post_types = geodir_get_posttypes('object');
|
|
| 2907 | - $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
|
|
| 2908 | - $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 2906 | + $post_types = geodir_get_posttypes('object');
|
|
| 2907 | + $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
|
|
| 2908 | + $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 2909 | 2909 | |
| 2910 | - if (!empty($show_add_listing_post_types_main_nav)) {
|
|
| 2911 | - $addlisting_links = ''; |
|
| 2912 | - foreach ($post_types as $key => $postobj) {
|
|
| 2910 | + if (!empty($show_add_listing_post_types_main_nav)) {
|
|
| 2911 | + $addlisting_links = ''; |
|
| 2912 | + foreach ($post_types as $key => $postobj) {
|
|
| 2913 | 2913 | |
| 2914 | - if (in_array($key, $show_add_listing_post_types_main_nav)) {
|
|
| 2914 | + if (in_array($key, $show_add_listing_post_types_main_nav)) {
|
|
| 2915 | 2915 | |
| 2916 | - if ($add_link = geodir_get_addlisting_link($key)) {
|
|
| 2916 | + if ($add_link = geodir_get_addlisting_link($key)) {
|
|
| 2917 | 2917 | |
| 2918 | - $name = $postobj->labels->name; |
|
| 2918 | + $name = $postobj->labels->name; |
|
| 2919 | 2919 | |
| 2920 | - $selected = ''; |
|
| 2921 | - if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
|
|
| 2922 | - $selected = 'selected="selected"'; |
|
| 2920 | + $selected = ''; |
|
| 2921 | + if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
|
|
| 2922 | + $selected = 'selected="selected"'; |
|
| 2923 | 2923 | |
| 2924 | - /** |
|
| 2925 | - * Filter add listing link. |
|
| 2926 | - * |
|
| 2927 | - * @since 1.0.0 |
|
| 2928 | - * @param string $add_link Add listing link. |
|
| 2929 | - * @param string $key Add listing array key. |
|
| 2930 | - * @param int $current_user->ID Current user ID. |
|
| 2931 | - */ |
|
| 2932 | - $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
|
|
| 2924 | + /** |
|
| 2925 | + * Filter add listing link. |
|
| 2926 | + * |
|
| 2927 | + * @since 1.0.0 |
|
| 2928 | + * @param string $add_link Add listing link. |
|
| 2929 | + * @param string $key Add listing array key. |
|
| 2930 | + * @param int $current_user->ID Current user ID. |
|
| 2931 | + */ |
|
| 2932 | + $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
|
|
| 2933 | 2933 | |
| 2934 | - $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 2934 | + $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 2935 | 2935 | |
| 2936 | - } |
|
| 2937 | - } |
|
| 2936 | + } |
|
| 2937 | + } |
|
| 2938 | 2938 | |
| 2939 | - } |
|
| 2939 | + } |
|
| 2940 | 2940 | |
| 2941 | - if ($addlisting_links != '') { ?>
|
|
| 2941 | + if ($addlisting_links != '') { ?>
|
|
| 2942 | 2942 | |
| 2943 | 2943 | <li><select id="geodir_add_listing" class="chosen_select" onchange="window.location.href=this.value" |
| 2944 | 2944 | option-autoredirect="1" name="geodir_add_listing" option-ajaxchosen="false" |
@@ -2947,42 +2947,42 @@ discard block |
||
| 2947 | 2947 | <?php echo $addlisting_links; ?> |
| 2948 | 2948 | </select></li> <?php |
| 2949 | 2949 | |
| 2950 | - } |
|
| 2951 | - |
|
| 2952 | - } |
|
| 2953 | - // My Favourites in Dashboard |
|
| 2954 | - $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
|
|
| 2955 | - $user_favourite = geodir_user_favourite_listing_count(); |
|
| 2956 | - |
|
| 2957 | - if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
|
|
| 2958 | - $favourite_links = ''; |
|
| 2959 | - |
|
| 2960 | - foreach ($post_types as $key => $postobj) {
|
|
| 2961 | - if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
|
|
| 2962 | - $name = $postobj->labels->name; |
|
| 2963 | - $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
|
|
| 2964 | - |
|
| 2965 | - $selected = ''; |
|
| 2966 | - |
|
| 2967 | - if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
|
|
| 2968 | - $selected = 'selected="selected"'; |
|
| 2969 | - } |
|
| 2970 | - /** |
|
| 2971 | - * Filter favorite listing link. |
|
| 2972 | - * |
|
| 2973 | - * @since 1.0.0 |
|
| 2974 | - * @param string $post_type_link Favorite listing link. |
|
| 2975 | - * @param string $key Favorite listing array key. |
|
| 2976 | - * @param int $current_user->ID Current user ID. |
|
| 2977 | - */ |
|
| 2978 | - $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
|
|
| 2979 | - |
|
| 2980 | - $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 2981 | - } |
|
| 2982 | - } |
|
| 2983 | - |
|
| 2984 | - if ($favourite_links != '') {
|
|
| 2985 | - ?> |
|
| 2950 | + } |
|
| 2951 | + |
|
| 2952 | + } |
|
| 2953 | + // My Favourites in Dashboard |
|
| 2954 | + $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
|
|
| 2955 | + $user_favourite = geodir_user_favourite_listing_count(); |
|
| 2956 | + |
|
| 2957 | + if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
|
|
| 2958 | + $favourite_links = ''; |
|
| 2959 | + |
|
| 2960 | + foreach ($post_types as $key => $postobj) {
|
|
| 2961 | + if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
|
|
| 2962 | + $name = $postobj->labels->name; |
|
| 2963 | + $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
|
|
| 2964 | + |
|
| 2965 | + $selected = ''; |
|
| 2966 | + |
|
| 2967 | + if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
|
|
| 2968 | + $selected = 'selected="selected"'; |
|
| 2969 | + } |
|
| 2970 | + /** |
|
| 2971 | + * Filter favorite listing link. |
|
| 2972 | + * |
|
| 2973 | + * @since 1.0.0 |
|
| 2974 | + * @param string $post_type_link Favorite listing link. |
|
| 2975 | + * @param string $key Favorite listing array key. |
|
| 2976 | + * @param int $current_user->ID Current user ID. |
|
| 2977 | + */ |
|
| 2978 | + $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
|
|
| 2979 | + |
|
| 2980 | + $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 2981 | + } |
|
| 2982 | + } |
|
| 2983 | + |
|
| 2984 | + if ($favourite_links != '') {
|
|
| 2985 | + ?> |
|
| 2986 | 2986 | <li> |
| 2987 | 2987 | <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value" |
| 2988 | 2988 | option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false" |
@@ -2992,42 +2992,42 @@ discard block |
||
| 2992 | 2992 | </select> |
| 2993 | 2993 | </li> |
| 2994 | 2994 | <?php |
| 2995 | - } |
|
| 2996 | - } |
|
| 2997 | - |
|
| 2998 | - |
|
| 2999 | - $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
|
|
| 3000 | - $user_listing = geodir_user_post_listing_count(); |
|
| 3001 | - |
|
| 3002 | - if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
|
|
| 3003 | - $listing_links = ''; |
|
| 3004 | - |
|
| 3005 | - foreach ($post_types as $key => $postobj) {
|
|
| 3006 | - if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
|
|
| 3007 | - $name = $postobj->labels->name; |
|
| 3008 | - $listing_link = geodir_getlink($author_link, array('stype' => $key), false);
|
|
| 3009 | - |
|
| 3010 | - $selected = ''; |
|
| 3011 | - if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
|
|
| 3012 | - $selected = 'selected="selected"'; |
|
| 3013 | - } |
|
| 3014 | - |
|
| 3015 | - /** |
|
| 3016 | - * Filter my listing link. |
|
| 3017 | - * |
|
| 3018 | - * @since 1.0.0 |
|
| 3019 | - * @param string $listing_link My listing link. |
|
| 3020 | - * @param string $key My listing array key. |
|
| 3021 | - * @param int $current_user->ID Current user ID. |
|
| 3022 | - */ |
|
| 3023 | - $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
|
|
| 3024 | - |
|
| 3025 | - $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 3026 | - } |
|
| 3027 | - } |
|
| 3028 | - |
|
| 3029 | - if ($listing_links != '') {
|
|
| 3030 | - ?> |
|
| 2995 | + } |
|
| 2996 | + } |
|
| 2997 | + |
|
| 2998 | + |
|
| 2999 | + $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
|
|
| 3000 | + $user_listing = geodir_user_post_listing_count(); |
|
| 3001 | + |
|
| 3002 | + if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
|
|
| 3003 | + $listing_links = ''; |
|
| 3004 | + |
|
| 3005 | + foreach ($post_types as $key => $postobj) {
|
|
| 3006 | + if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
|
|
| 3007 | + $name = $postobj->labels->name; |
|
| 3008 | + $listing_link = geodir_getlink($author_link, array('stype' => $key), false);
|
|
| 3009 | + |
|
| 3010 | + $selected = ''; |
|
| 3011 | + if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
|
|
| 3012 | + $selected = 'selected="selected"'; |
|
| 3013 | + } |
|
| 3014 | + |
|
| 3015 | + /** |
|
| 3016 | + * Filter my listing link. |
|
| 3017 | + * |
|
| 3018 | + * @since 1.0.0 |
|
| 3019 | + * @param string $listing_link My listing link. |
|
| 3020 | + * @param string $key My listing array key. |
|
| 3021 | + * @param int $current_user->ID Current user ID. |
|
| 3022 | + */ |
|
| 3023 | + $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
|
|
| 3024 | + |
|
| 3025 | + $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 3026 | + } |
|
| 3027 | + } |
|
| 3028 | + |
|
| 3029 | + if ($listing_links != '') {
|
|
| 3030 | + ?> |
|
| 3031 | 3031 | <li> |
| 3032 | 3032 | <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value" |
| 3033 | 3033 | option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false" |
@@ -3037,27 +3037,27 @@ discard block |
||
| 3037 | 3037 | </select> |
| 3038 | 3038 | </li> |
| 3039 | 3039 | <?php |
| 3040 | - } |
|
| 3041 | - } |
|
| 3042 | - |
|
| 3043 | - $dashboard_link = ob_get_clean(); |
|
| 3044 | - /** |
|
| 3045 | - * Filter dashboard links HTML. |
|
| 3046 | - * |
|
| 3047 | - * @since 1.0.0 |
|
| 3048 | - * @param string $dashboard_link Dashboard links HTML. |
|
| 3049 | - */ |
|
| 3050 | - echo apply_filters('geodir_dashboard_links', $dashboard_link);
|
|
| 3051 | - echo '</ul>'; |
|
| 3052 | - } else {
|
|
| 3053 | - ?> |
|
| 3040 | + } |
|
| 3041 | + } |
|
| 3042 | + |
|
| 3043 | + $dashboard_link = ob_get_clean(); |
|
| 3044 | + /** |
|
| 3045 | + * Filter dashboard links HTML. |
|
| 3046 | + * |
|
| 3047 | + * @since 1.0.0 |
|
| 3048 | + * @param string $dashboard_link Dashboard links HTML. |
|
| 3049 | + */ |
|
| 3050 | + echo apply_filters('geodir_dashboard_links', $dashboard_link);
|
|
| 3051 | + echo '</ul>'; |
|
| 3052 | + } else {
|
|
| 3053 | + ?> |
|
| 3054 | 3054 | <?php |
| 3055 | - /** |
|
| 3056 | - * Filter signup form action link. |
|
| 3057 | - * |
|
| 3058 | - * @since 1.0.0 |
|
| 3059 | - */ |
|
| 3060 | - ?> |
|
| 3055 | + /** |
|
| 3056 | + * Filter signup form action link. |
|
| 3057 | + * |
|
| 3058 | + * @since 1.0.0 |
|
| 3059 | + */ |
|
| 3060 | + ?> |
|
| 3061 | 3061 | <form name="loginform" class="loginform1" |
| 3062 | 3062 | action="<?php echo geodir_login_url(); ?>" |
| 3063 | 3063 | method="post"> |
@@ -3077,28 +3077,28 @@ discard block |
||
| 3077 | 3077 | |
| 3078 | 3078 | <p class="geodir-new-forgot-link"> |
| 3079 | 3079 | <?php |
| 3080 | - /** |
|
| 3081 | - * Filter signup page register form link. |
|
| 3082 | - * |
|
| 3083 | - * @since 1.0.0 |
|
| 3084 | - */ |
|
| 3085 | - ?> |
|
| 3080 | + /** |
|
| 3081 | + * Filter signup page register form link. |
|
| 3082 | + * |
|
| 3083 | + * @since 1.0.0 |
|
| 3084 | + */ |
|
| 3085 | + ?> |
|
| 3086 | 3086 | <a href="<?php echo geodir_login_url(array('signup' => true)); ?>"
|
| 3087 | 3087 | class="goedir-newuser-link"><?php echo NEW_USER_TEXT; ?></a> |
| 3088 | 3088 | |
| 3089 | 3089 | <?php |
| 3090 | - /** |
|
| 3091 | - * Filter signup page forgot password form link. |
|
| 3092 | - * |
|
| 3093 | - * @since 1.0.0 |
|
| 3094 | - */ |
|
| 3095 | - ?> |
|
| 3090 | + /** |
|
| 3091 | + * Filter signup page forgot password form link. |
|
| 3092 | + * |
|
| 3093 | + * @since 1.0.0 |
|
| 3094 | + */ |
|
| 3095 | + ?> |
|
| 3096 | 3096 | <a href="<?php echo geodir_login_url(array('forgot' => true)); ?>"
|
| 3097 | 3097 | class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?></a></p></div> |
| 3098 | 3098 | </form> |
| 3099 | 3099 | <?php } |
| 3100 | 3100 | |
| 3101 | - echo $after_widget; |
|
| 3101 | + echo $after_widget; |
|
| 3102 | 3102 | } |
| 3103 | 3103 | |
| 3104 | 3104 | |
@@ -3117,284 +3117,284 @@ discard block |
||
| 3117 | 3117 | * @param array|string $instance The settings for the particular instance of the widget. |
| 3118 | 3118 | */ |
| 3119 | 3119 | function geodir_popular_postview_output($args = '', $instance = '') {
|
| 3120 | - global $gd_session; |
|
| 3120 | + global $gd_session; |
|
| 3121 | 3121 | |
| 3122 | - // prints the widget |
|
| 3123 | - extract($args, EXTR_SKIP); |
|
| 3124 | - |
|
| 3125 | - echo $before_widget; |
|
| 3126 | - |
|
| 3127 | - /** This filter is documented in geodirectory_widgets.php */ |
|
| 3128 | - $title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 3129 | - /** |
|
| 3130 | - * Filter the widget post type. |
|
| 3131 | - * |
|
| 3132 | - * @since 1.0.0 |
|
| 3133 | - * @param string $instance['post_type'] Post type of listing. |
|
| 3134 | - */ |
|
| 3135 | - $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
|
|
| 3136 | - /** |
|
| 3137 | - * Filter the widget's term. |
|
| 3138 | - * |
|
| 3139 | - * @since 1.0.0 |
|
| 3140 | - * @param string $instance['category'] Filter by term. Can be any valid term. |
|
| 3141 | - */ |
|
| 3142 | - $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
|
|
| 3143 | - /** |
|
| 3144 | - * Filter the widget listings limit. |
|
| 3145 | - * |
|
| 3146 | - * @since 1.0.0 |
|
| 3147 | - * @param string $instance['post_number'] Number of listings to display. |
|
| 3148 | - */ |
|
| 3149 | - $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
|
|
| 3150 | - /** |
|
| 3151 | - * Filter widget's "layout" type. |
|
| 3152 | - * |
|
| 3153 | - * @since 1.0.0 |
|
| 3154 | - * @param string $instance['layout'] Widget layout type. |
|
| 3155 | - */ |
|
| 3156 | - $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
|
|
| 3157 | - /** |
|
| 3158 | - * Filter widget's "add_location_filter" value. |
|
| 3159 | - * |
|
| 3160 | - * @since 1.0.0 |
|
| 3161 | - * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0. |
|
| 3162 | - */ |
|
| 3163 | - $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
|
|
| 3164 | - /** |
|
| 3165 | - * Filter widget's listing width. |
|
| 3166 | - * |
|
| 3167 | - * @since 1.0.0 |
|
| 3168 | - * @param string $instance['listing_width'] Listing width. |
|
| 3169 | - */ |
|
| 3170 | - $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
|
|
| 3171 | - /** |
|
| 3172 | - * Filter widget's "list_sort" type. |
|
| 3173 | - * |
|
| 3174 | - * @since 1.0.0 |
|
| 3175 | - * @param string $instance['list_sort'] Listing sort by type. |
|
| 3176 | - */ |
|
| 3177 | - $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
|
|
| 3178 | - $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false; |
|
| 3179 | - |
|
| 3180 | - // set post type to current viewing post type |
|
| 3181 | - if ($use_viewing_post_type) {
|
|
| 3182 | - $current_post_type = geodir_get_current_posttype(); |
|
| 3183 | - if ($current_post_type != '' && $current_post_type != $post_type) {
|
|
| 3184 | - $post_type = $current_post_type; |
|
| 3185 | - $category = array(); // old post type category will not work for current changed post type |
|
| 3186 | - } |
|
| 3187 | - } |
|
| 3188 | - // replace widget title dynamically |
|
| 3189 | - $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory'); |
|
| 3190 | - $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory'); |
|
| 3191 | - |
|
| 3192 | - $title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
|
|
| 3193 | - $title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
|
|
| 3194 | - |
|
| 3195 | - if (isset($instance['character_count'])) {
|
|
| 3196 | - /** |
|
| 3197 | - * Filter the widget's excerpt character count. |
|
| 3198 | - * |
|
| 3199 | - * @since 1.0.0 |
|
| 3200 | - * @param int $instance['character_count'] Excerpt character count. |
|
| 3201 | - */ |
|
| 3202 | - $character_count = apply_filters('widget_list_character_count', $instance['character_count']);
|
|
| 3203 | - } else {
|
|
| 3204 | - $character_count = ''; |
|
| 3205 | - } |
|
| 3206 | - |
|
| 3207 | - if (empty($title) || $title == 'All') {
|
|
| 3208 | - $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory'); |
|
| 3209 | - } |
|
| 3210 | - |
|
| 3211 | - $location_url = array(); |
|
| 3212 | - $city = get_query_var('gd_city');
|
|
| 3213 | - if (!empty($city)) {
|
|
| 3214 | - $country = get_query_var('gd_country');
|
|
| 3215 | - $region = get_query_var('gd_region');
|
|
| 3216 | - |
|
| 3217 | - $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 3218 | - |
|
| 3219 | - if ($geodir_show_location_url == 'all') {
|
|
| 3220 | - if ($country != '') {
|
|
| 3221 | - $location_url[] = $country; |
|
| 3222 | - } |
|
| 3223 | - |
|
| 3224 | - if ($region != '') {
|
|
| 3225 | - $location_url[] = $region; |
|
| 3226 | - } |
|
| 3227 | - } else if ($geodir_show_location_url == 'country_city') {
|
|
| 3228 | - if ($country != '') {
|
|
| 3229 | - $location_url[] = $country; |
|
| 3230 | - } |
|
| 3231 | - } else if ($geodir_show_location_url == 'region_city') {
|
|
| 3232 | - if ($region != '') {
|
|
| 3233 | - $location_url[] = $region; |
|
| 3234 | - } |
|
| 3235 | - } |
|
| 3236 | - |
|
| 3237 | - $location_url[] = $city; |
|
| 3238 | - } |
|
| 3239 | - |
|
| 3240 | - $location_url = implode('/', $location_url);
|
|
| 3241 | - $skip_location = false; |
|
| 3242 | - if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
|
|
| 3243 | - $skip_location = true; |
|
| 3244 | - $gd_session->un_set('gd_multi_location');
|
|
| 3245 | - } |
|
| 3246 | - |
|
| 3247 | - if (get_option('permalink_structure')) {
|
|
| 3248 | - $viewall_url = get_post_type_archive_link($post_type); |
|
| 3249 | - } else {
|
|
| 3250 | - $viewall_url = get_post_type_archive_link($post_type); |
|
| 3251 | - } |
|
| 3252 | - |
|
| 3253 | - if (!empty($category) && $category[0] != '0') {
|
|
| 3254 | - global $geodir_add_location_url; |
|
| 3255 | - |
|
| 3256 | - $geodir_add_location_url = '0'; |
|
| 3257 | - |
|
| 3258 | - if ($add_location_filter != '0') {
|
|
| 3259 | - $geodir_add_location_url = '1'; |
|
| 3260 | - } |
|
| 3261 | - |
|
| 3262 | - $viewall_url = get_term_link((int)$category[0], $post_type . 'category'); |
|
| 3263 | - |
|
| 3264 | - $geodir_add_location_url = NULL; |
|
| 3265 | - } |
|
| 3266 | - if ($skip_location) {
|
|
| 3267 | - $gd_session->set('gd_multi_location', 1);
|
|
| 3268 | - } |
|
| 3269 | - |
|
| 3270 | - if(is_wp_error( $viewall_url )){$viewall_url = '';}
|
|
| 3271 | - |
|
| 3272 | - $query_args = array( |
|
| 3273 | - 'posts_per_page' => $post_number, |
|
| 3274 | - 'is_geodir_loop' => true, |
|
| 3275 | - 'gd_location' => $add_location_filter ? true : false, |
|
| 3276 | - 'post_type' => $post_type, |
|
| 3277 | - 'order_by' => $list_sort |
|
| 3278 | - ); |
|
| 3279 | - |
|
| 3280 | - if ($character_count) {
|
|
| 3281 | - $query_args['excerpt_length'] = $character_count; |
|
| 3282 | - } |
|
| 3283 | - |
|
| 3284 | - if (!empty($instance['show_featured_only'])) {
|
|
| 3285 | - $query_args['show_featured_only'] = 1; |
|
| 3286 | - } |
|
| 3287 | - |
|
| 3288 | - if (!empty($instance['show_special_only'])) {
|
|
| 3289 | - $query_args['show_special_only'] = 1; |
|
| 3290 | - } |
|
| 3291 | - |
|
| 3292 | - if (!empty($instance['with_pics_only'])) {
|
|
| 3293 | - $query_args['with_pics_only'] = 0; |
|
| 3294 | - $query_args['featured_image_only'] = 1; |
|
| 3295 | - } |
|
| 3296 | - |
|
| 3297 | - if (!empty($instance['with_videos_only'])) {
|
|
| 3298 | - $query_args['with_videos_only'] = 1; |
|
| 3299 | - } |
|
| 3300 | - $with_no_results = !empty($instance['without_no_results']) ? false : true; |
|
| 3301 | - |
|
| 3302 | - if (!empty($category) && $category[0] != '0') {
|
|
| 3303 | - $category_taxonomy = geodir_get_taxonomies($post_type); |
|
| 3304 | - |
|
| 3305 | - ######### WPML ######### |
|
| 3306 | - if (function_exists('icl_object_id')) {
|
|
| 3307 | - $category = gd_lang_object_ids($category, $category_taxonomy[0]); |
|
| 3308 | - } |
|
| 3309 | - ######### WPML ######### |
|
| 3310 | - |
|
| 3311 | - $tax_query = array( |
|
| 3312 | - 'taxonomy' => $category_taxonomy[0], |
|
| 3313 | - 'field' => 'id', |
|
| 3314 | - 'terms' => $category |
|
| 3315 | - ); |
|
| 3316 | - |
|
| 3317 | - $query_args['tax_query'] = array($tax_query); |
|
| 3318 | - } |
|
| 3319 | - |
|
| 3320 | - global $gridview_columns_widget, $geodir_is_widget_listing; |
|
| 3321 | - |
|
| 3322 | - $widget_listings = geodir_get_widget_listings($query_args); |
|
| 3323 | - |
|
| 3324 | - if (!empty($widget_listings) || $with_no_results) {
|
|
| 3325 | - ?> |
|
| 3122 | + // prints the widget |
|
| 3123 | + extract($args, EXTR_SKIP); |
|
| 3124 | + |
|
| 3125 | + echo $before_widget; |
|
| 3126 | + |
|
| 3127 | + /** This filter is documented in geodirectory_widgets.php */ |
|
| 3128 | + $title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 3129 | + /** |
|
| 3130 | + * Filter the widget post type. |
|
| 3131 | + * |
|
| 3132 | + * @since 1.0.0 |
|
| 3133 | + * @param string $instance['post_type'] Post type of listing. |
|
| 3134 | + */ |
|
| 3135 | + $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
|
|
| 3136 | + /** |
|
| 3137 | + * Filter the widget's term. |
|
| 3138 | + * |
|
| 3139 | + * @since 1.0.0 |
|
| 3140 | + * @param string $instance['category'] Filter by term. Can be any valid term. |
|
| 3141 | + */ |
|
| 3142 | + $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
|
|
| 3143 | + /** |
|
| 3144 | + * Filter the widget listings limit. |
|
| 3145 | + * |
|
| 3146 | + * @since 1.0.0 |
|
| 3147 | + * @param string $instance['post_number'] Number of listings to display. |
|
| 3148 | + */ |
|
| 3149 | + $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
|
|
| 3150 | + /** |
|
| 3151 | + * Filter widget's "layout" type. |
|
| 3152 | + * |
|
| 3153 | + * @since 1.0.0 |
|
| 3154 | + * @param string $instance['layout'] Widget layout type. |
|
| 3155 | + */ |
|
| 3156 | + $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
|
|
| 3157 | + /** |
|
| 3158 | + * Filter widget's "add_location_filter" value. |
|
| 3159 | + * |
|
| 3160 | + * @since 1.0.0 |
|
| 3161 | + * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0. |
|
| 3162 | + */ |
|
| 3163 | + $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
|
|
| 3164 | + /** |
|
| 3165 | + * Filter widget's listing width. |
|
| 3166 | + * |
|
| 3167 | + * @since 1.0.0 |
|
| 3168 | + * @param string $instance['listing_width'] Listing width. |
|
| 3169 | + */ |
|
| 3170 | + $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
|
|
| 3171 | + /** |
|
| 3172 | + * Filter widget's "list_sort" type. |
|
| 3173 | + * |
|
| 3174 | + * @since 1.0.0 |
|
| 3175 | + * @param string $instance['list_sort'] Listing sort by type. |
|
| 3176 | + */ |
|
| 3177 | + $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
|
|
| 3178 | + $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false; |
|
| 3179 | + |
|
| 3180 | + // set post type to current viewing post type |
|
| 3181 | + if ($use_viewing_post_type) {
|
|
| 3182 | + $current_post_type = geodir_get_current_posttype(); |
|
| 3183 | + if ($current_post_type != '' && $current_post_type != $post_type) {
|
|
| 3184 | + $post_type = $current_post_type; |
|
| 3185 | + $category = array(); // old post type category will not work for current changed post type |
|
| 3186 | + } |
|
| 3187 | + } |
|
| 3188 | + // replace widget title dynamically |
|
| 3189 | + $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory'); |
|
| 3190 | + $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory'); |
|
| 3191 | + |
|
| 3192 | + $title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
|
|
| 3193 | + $title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
|
|
| 3194 | + |
|
| 3195 | + if (isset($instance['character_count'])) {
|
|
| 3196 | + /** |
|
| 3197 | + * Filter the widget's excerpt character count. |
|
| 3198 | + * |
|
| 3199 | + * @since 1.0.0 |
|
| 3200 | + * @param int $instance['character_count'] Excerpt character count. |
|
| 3201 | + */ |
|
| 3202 | + $character_count = apply_filters('widget_list_character_count', $instance['character_count']);
|
|
| 3203 | + } else {
|
|
| 3204 | + $character_count = ''; |
|
| 3205 | + } |
|
| 3206 | + |
|
| 3207 | + if (empty($title) || $title == 'All') {
|
|
| 3208 | + $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory'); |
|
| 3209 | + } |
|
| 3210 | + |
|
| 3211 | + $location_url = array(); |
|
| 3212 | + $city = get_query_var('gd_city');
|
|
| 3213 | + if (!empty($city)) {
|
|
| 3214 | + $country = get_query_var('gd_country');
|
|
| 3215 | + $region = get_query_var('gd_region');
|
|
| 3216 | + |
|
| 3217 | + $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 3218 | + |
|
| 3219 | + if ($geodir_show_location_url == 'all') {
|
|
| 3220 | + if ($country != '') {
|
|
| 3221 | + $location_url[] = $country; |
|
| 3222 | + } |
|
| 3223 | + |
|
| 3224 | + if ($region != '') {
|
|
| 3225 | + $location_url[] = $region; |
|
| 3226 | + } |
|
| 3227 | + } else if ($geodir_show_location_url == 'country_city') {
|
|
| 3228 | + if ($country != '') {
|
|
| 3229 | + $location_url[] = $country; |
|
| 3230 | + } |
|
| 3231 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 3232 | + if ($region != '') {
|
|
| 3233 | + $location_url[] = $region; |
|
| 3234 | + } |
|
| 3235 | + } |
|
| 3236 | + |
|
| 3237 | + $location_url[] = $city; |
|
| 3238 | + } |
|
| 3239 | + |
|
| 3240 | + $location_url = implode('/', $location_url);
|
|
| 3241 | + $skip_location = false; |
|
| 3242 | + if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
|
|
| 3243 | + $skip_location = true; |
|
| 3244 | + $gd_session->un_set('gd_multi_location');
|
|
| 3245 | + } |
|
| 3246 | + |
|
| 3247 | + if (get_option('permalink_structure')) {
|
|
| 3248 | + $viewall_url = get_post_type_archive_link($post_type); |
|
| 3249 | + } else {
|
|
| 3250 | + $viewall_url = get_post_type_archive_link($post_type); |
|
| 3251 | + } |
|
| 3252 | + |
|
| 3253 | + if (!empty($category) && $category[0] != '0') {
|
|
| 3254 | + global $geodir_add_location_url; |
|
| 3255 | + |
|
| 3256 | + $geodir_add_location_url = '0'; |
|
| 3257 | + |
|
| 3258 | + if ($add_location_filter != '0') {
|
|
| 3259 | + $geodir_add_location_url = '1'; |
|
| 3260 | + } |
|
| 3261 | + |
|
| 3262 | + $viewall_url = get_term_link((int)$category[0], $post_type . 'category'); |
|
| 3263 | + |
|
| 3264 | + $geodir_add_location_url = NULL; |
|
| 3265 | + } |
|
| 3266 | + if ($skip_location) {
|
|
| 3267 | + $gd_session->set('gd_multi_location', 1);
|
|
| 3268 | + } |
|
| 3269 | + |
|
| 3270 | + if(is_wp_error( $viewall_url )){$viewall_url = '';}
|
|
| 3271 | + |
|
| 3272 | + $query_args = array( |
|
| 3273 | + 'posts_per_page' => $post_number, |
|
| 3274 | + 'is_geodir_loop' => true, |
|
| 3275 | + 'gd_location' => $add_location_filter ? true : false, |
|
| 3276 | + 'post_type' => $post_type, |
|
| 3277 | + 'order_by' => $list_sort |
|
| 3278 | + ); |
|
| 3279 | + |
|
| 3280 | + if ($character_count) {
|
|
| 3281 | + $query_args['excerpt_length'] = $character_count; |
|
| 3282 | + } |
|
| 3283 | + |
|
| 3284 | + if (!empty($instance['show_featured_only'])) {
|
|
| 3285 | + $query_args['show_featured_only'] = 1; |
|
| 3286 | + } |
|
| 3287 | + |
|
| 3288 | + if (!empty($instance['show_special_only'])) {
|
|
| 3289 | + $query_args['show_special_only'] = 1; |
|
| 3290 | + } |
|
| 3291 | + |
|
| 3292 | + if (!empty($instance['with_pics_only'])) {
|
|
| 3293 | + $query_args['with_pics_only'] = 0; |
|
| 3294 | + $query_args['featured_image_only'] = 1; |
|
| 3295 | + } |
|
| 3296 | + |
|
| 3297 | + if (!empty($instance['with_videos_only'])) {
|
|
| 3298 | + $query_args['with_videos_only'] = 1; |
|
| 3299 | + } |
|
| 3300 | + $with_no_results = !empty($instance['without_no_results']) ? false : true; |
|
| 3301 | + |
|
| 3302 | + if (!empty($category) && $category[0] != '0') {
|
|
| 3303 | + $category_taxonomy = geodir_get_taxonomies($post_type); |
|
| 3304 | + |
|
| 3305 | + ######### WPML ######### |
|
| 3306 | + if (function_exists('icl_object_id')) {
|
|
| 3307 | + $category = gd_lang_object_ids($category, $category_taxonomy[0]); |
|
| 3308 | + } |
|
| 3309 | + ######### WPML ######### |
|
| 3310 | + |
|
| 3311 | + $tax_query = array( |
|
| 3312 | + 'taxonomy' => $category_taxonomy[0], |
|
| 3313 | + 'field' => 'id', |
|
| 3314 | + 'terms' => $category |
|
| 3315 | + ); |
|
| 3316 | + |
|
| 3317 | + $query_args['tax_query'] = array($tax_query); |
|
| 3318 | + } |
|
| 3319 | + |
|
| 3320 | + global $gridview_columns_widget, $geodir_is_widget_listing; |
|
| 3321 | + |
|
| 3322 | + $widget_listings = geodir_get_widget_listings($query_args); |
|
| 3323 | + |
|
| 3324 | + if (!empty($widget_listings) || $with_no_results) {
|
|
| 3325 | + ?> |
|
| 3326 | 3326 | <div class="geodir_locations geodir_location_listing"> |
| 3327 | 3327 | |
| 3328 | 3328 | <?php |
| 3329 | - /** |
|
| 3330 | - * Called before the div containing the title and view all link in popular post view widget. |
|
| 3331 | - * |
|
| 3332 | - * @since 1.0.0 |
|
| 3333 | - */ |
|
| 3334 | - do_action('geodir_before_view_all_link_in_widget'); ?>
|
|
| 3329 | + /** |
|
| 3330 | + * Called before the div containing the title and view all link in popular post view widget. |
|
| 3331 | + * |
|
| 3332 | + * @since 1.0.0 |
|
| 3333 | + */ |
|
| 3334 | + do_action('geodir_before_view_all_link_in_widget'); ?>
|
|
| 3335 | 3335 | <div class="geodir_list_heading clearfix"> |
| 3336 | 3336 | <?php echo $before_title . $title . $after_title; ?> |
| 3337 | 3337 | <a href="<?php echo $viewall_url; ?>" |
| 3338 | 3338 | class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
|
| 3339 | 3339 | </div> |
| 3340 | 3340 | <?php |
| 3341 | - /** |
|
| 3342 | - * Called after the div containing the title and view all link in popular post view widget. |
|
| 3343 | - * |
|
| 3344 | - * @since 1.0.0 |
|
| 3345 | - */ |
|
| 3346 | - do_action('geodir_after_view_all_link_in_widget'); ?>
|
|
| 3341 | + /** |
|
| 3342 | + * Called after the div containing the title and view all link in popular post view widget. |
|
| 3343 | + * |
|
| 3344 | + * @since 1.0.0 |
|
| 3345 | + */ |
|
| 3346 | + do_action('geodir_after_view_all_link_in_widget'); ?>
|
|
| 3347 | 3347 | <?php |
| 3348 | - if (strstr($layout, 'gridview')) {
|
|
| 3349 | - $listing_view_exp = explode('_', $layout);
|
|
| 3350 | - $gridview_columns_widget = $layout; |
|
| 3351 | - $layout = $listing_view_exp[0]; |
|
| 3352 | - } else {
|
|
| 3353 | - $gridview_columns_widget = ''; |
|
| 3354 | - } |
|
| 3355 | - |
|
| 3356 | - /** |
|
| 3357 | - * Filter the widget listing listview template path. |
|
| 3358 | - * |
|
| 3359 | - * @since 1.0.0 |
|
| 3360 | - */ |
|
| 3361 | - $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
|
|
| 3362 | - if (!isset($character_count)) {
|
|
| 3363 | - /** |
|
| 3364 | - * Filter the widget's excerpt character count. |
|
| 3365 | - * |
|
| 3366 | - * @since 1.0.0 |
|
| 3367 | - * @param int $instance['character_count'] Excerpt character count. |
|
| 3368 | - */ |
|
| 3369 | - $character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
|
|
| 3370 | - } |
|
| 3371 | - |
|
| 3372 | - global $post, $map_jason, $map_canvas_arr; |
|
| 3373 | - |
|
| 3374 | - $current_post = $post; |
|
| 3375 | - $current_map_jason = $map_jason; |
|
| 3376 | - $current_map_canvas_arr = $map_canvas_arr; |
|
| 3377 | - $geodir_is_widget_listing = true; |
|
| 3378 | - |
|
| 3379 | - /** |
|
| 3380 | - * Includes related listing listview template. |
|
| 3381 | - * |
|
| 3382 | - * @since 1.0.0 |
|
| 3383 | - */ |
|
| 3384 | - include($template); |
|
| 3385 | - |
|
| 3386 | - $geodir_is_widget_listing = false; |
|
| 3387 | - |
|
| 3388 | - $GLOBALS['post'] = $current_post; |
|
| 3389 | - if (!empty($current_post)) |
|
| 3390 | - setup_postdata($current_post); |
|
| 3391 | - $map_jason = $current_map_jason; |
|
| 3392 | - $map_canvas_arr = $current_map_canvas_arr; |
|
| 3393 | - ?> |
|
| 3348 | + if (strstr($layout, 'gridview')) {
|
|
| 3349 | + $listing_view_exp = explode('_', $layout);
|
|
| 3350 | + $gridview_columns_widget = $layout; |
|
| 3351 | + $layout = $listing_view_exp[0]; |
|
| 3352 | + } else {
|
|
| 3353 | + $gridview_columns_widget = ''; |
|
| 3354 | + } |
|
| 3355 | + |
|
| 3356 | + /** |
|
| 3357 | + * Filter the widget listing listview template path. |
|
| 3358 | + * |
|
| 3359 | + * @since 1.0.0 |
|
| 3360 | + */ |
|
| 3361 | + $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
|
|
| 3362 | + if (!isset($character_count)) {
|
|
| 3363 | + /** |
|
| 3364 | + * Filter the widget's excerpt character count. |
|
| 3365 | + * |
|
| 3366 | + * @since 1.0.0 |
|
| 3367 | + * @param int $instance['character_count'] Excerpt character count. |
|
| 3368 | + */ |
|
| 3369 | + $character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
|
|
| 3370 | + } |
|
| 3371 | + |
|
| 3372 | + global $post, $map_jason, $map_canvas_arr; |
|
| 3373 | + |
|
| 3374 | + $current_post = $post; |
|
| 3375 | + $current_map_jason = $map_jason; |
|
| 3376 | + $current_map_canvas_arr = $map_canvas_arr; |
|
| 3377 | + $geodir_is_widget_listing = true; |
|
| 3378 | + |
|
| 3379 | + /** |
|
| 3380 | + * Includes related listing listview template. |
|
| 3381 | + * |
|
| 3382 | + * @since 1.0.0 |
|
| 3383 | + */ |
|
| 3384 | + include($template); |
|
| 3385 | + |
|
| 3386 | + $geodir_is_widget_listing = false; |
|
| 3387 | + |
|
| 3388 | + $GLOBALS['post'] = $current_post; |
|
| 3389 | + if (!empty($current_post)) |
|
| 3390 | + setup_postdata($current_post); |
|
| 3391 | + $map_jason = $current_map_jason; |
|
| 3392 | + $map_canvas_arr = $current_map_canvas_arr; |
|
| 3393 | + ?> |
|
| 3394 | 3394 | </div> |
| 3395 | 3395 | <?php |
| 3396 | - } |
|
| 3397 | - echo $after_widget; |
|
| 3396 | + } |
|
| 3397 | + echo $after_widget; |
|
| 3398 | 3398 | |
| 3399 | 3399 | } |
| 3400 | 3400 | |
@@ -3417,26 +3417,26 @@ discard block |
||
| 3417 | 3417 | */ |
| 3418 | 3418 | function geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type) |
| 3419 | 3419 | {
|
| 3420 | - global $wpdb, $plugin_prefix; |
|
| 3420 | + global $wpdb, $plugin_prefix; |
|
| 3421 | 3421 | |
| 3422 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 3422 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 3423 | 3423 | |
| 3424 | - $sql = "SELECT COALESCE(SUM(rating_count),0) FROM " . $detail_table . " WHERE post_status = 'publish' AND rating_count > 0 AND FIND_IN_SET(" . $term_id . ", " . $taxonomy . ")";
|
|
| 3424 | + $sql = "SELECT COALESCE(SUM(rating_count),0) FROM " . $detail_table . " WHERE post_status = 'publish' AND rating_count > 0 AND FIND_IN_SET(" . $term_id . ", " . $taxonomy . ")";
|
|
| 3425 | 3425 | |
| 3426 | - /** |
|
| 3427 | - * Filter count review sql query. |
|
| 3428 | - * |
|
| 3429 | - * @since 1.5.1 |
|
| 3430 | - * @param string $sql Database sql query.. |
|
| 3431 | - * @param int $term_id The term ID. |
|
| 3432 | - * @param int $taxonomy The taxonomy Id. |
|
| 3433 | - * @param string $post_type The post type. |
|
| 3434 | - */ |
|
| 3435 | - $sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
|
|
| 3426 | + /** |
|
| 3427 | + * Filter count review sql query. |
|
| 3428 | + * |
|
| 3429 | + * @since 1.5.1 |
|
| 3430 | + * @param string $sql Database sql query.. |
|
| 3431 | + * @param int $term_id The term ID. |
|
| 3432 | + * @param int $taxonomy The taxonomy Id. |
|
| 3433 | + * @param string $post_type The post type. |
|
| 3434 | + */ |
|
| 3435 | + $sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
|
|
| 3436 | 3436 | |
| 3437 | - $count = $wpdb->get_var($sql); |
|
| 3437 | + $count = $wpdb->get_var($sql); |
|
| 3438 | 3438 | |
| 3439 | - return $count; |
|
| 3439 | + return $count; |
|
| 3440 | 3440 | } |
| 3441 | 3441 | |
| 3442 | 3442 | /** |
@@ -3452,90 +3452,90 @@ discard block |
||
| 3452 | 3452 | * @return array Term array data. |
| 3453 | 3453 | */ |
| 3454 | 3454 | function geodir_count_reviews_by_terms($force_update = false, $post_ID = 0) {
|
| 3455 | - /** |
|
| 3456 | - * Filter review count option data. |
|
| 3457 | - * |
|
| 3458 | - * @since 1.0.0 |
|
| 3459 | - * @since 1.6.1 Added $post_ID param. |
|
| 3460 | - * @param bool $force_update Force update option value?. Default.false. |
|
| 3461 | - * @param int $post_ID The post id to update if any. |
|
| 3462 | - */ |
|
| 3463 | - $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
|
|
| 3464 | - if (!empty($option_data)) {
|
|
| 3465 | - return $option_data; |
|
| 3466 | - } |
|
| 3467 | - |
|
| 3468 | - $option_data = get_option('geodir_global_review_count');
|
|
| 3469 | - |
|
| 3470 | - if (!$option_data || $force_update) {
|
|
| 3471 | - if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
|
|
| 3472 | - global $gd_session; |
|
| 3473 | - $term_array = (array)$option_data; |
|
| 3474 | - $post_type = get_post_type($post_ID); |
|
| 3475 | - $taxonomy = $post_type . 'category'; |
|
| 3476 | - $terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
|
|
| 3477 | - |
|
| 3478 | - if (!empty($terms) && !is_wp_error($terms)) {
|
|
| 3479 | - foreach ($terms as $term_id) {
|
|
| 3480 | - $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type); |
|
| 3481 | - $children = get_term_children($term_id, $taxonomy); |
|
| 3482 | - $term_array[$term_id] = $count; |
|
| 3483 | - } |
|
| 3484 | - } |
|
| 3455 | + /** |
|
| 3456 | + * Filter review count option data. |
|
| 3457 | + * |
|
| 3458 | + * @since 1.0.0 |
|
| 3459 | + * @since 1.6.1 Added $post_ID param. |
|
| 3460 | + * @param bool $force_update Force update option value?. Default.false. |
|
| 3461 | + * @param int $post_ID The post id to update if any. |
|
| 3462 | + */ |
|
| 3463 | + $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
|
|
| 3464 | + if (!empty($option_data)) {
|
|
| 3465 | + return $option_data; |
|
| 3466 | + } |
|
| 3467 | + |
|
| 3468 | + $option_data = get_option('geodir_global_review_count');
|
|
| 3469 | + |
|
| 3470 | + if (!$option_data || $force_update) {
|
|
| 3471 | + if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
|
|
| 3472 | + global $gd_session; |
|
| 3473 | + $term_array = (array)$option_data; |
|
| 3474 | + $post_type = get_post_type($post_ID); |
|
| 3475 | + $taxonomy = $post_type . 'category'; |
|
| 3476 | + $terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
|
|
| 3477 | + |
|
| 3478 | + if (!empty($terms) && !is_wp_error($terms)) {
|
|
| 3479 | + foreach ($terms as $term_id) {
|
|
| 3480 | + $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type); |
|
| 3481 | + $children = get_term_children($term_id, $taxonomy); |
|
| 3482 | + $term_array[$term_id] = $count; |
|
| 3483 | + } |
|
| 3484 | + } |
|
| 3485 | 3485 | |
| 3486 | - $session_listing = $gd_session->get('listing');
|
|
| 3486 | + $session_listing = $gd_session->get('listing');
|
|
| 3487 | 3487 | |
| 3488 | - $terms = array(); |
|
| 3489 | - if (isset($_POST['post_category'][$taxonomy])) {
|
|
| 3490 | - $terms = (array)$_POST['post_category'][$taxonomy]; |
|
| 3491 | - } else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
|
|
| 3492 | - $terms = (array)$session_listing['post_category'][$taxonomy]; |
|
| 3493 | - } |
|
| 3488 | + $terms = array(); |
|
| 3489 | + if (isset($_POST['post_category'][$taxonomy])) {
|
|
| 3490 | + $terms = (array)$_POST['post_category'][$taxonomy]; |
|
| 3491 | + } else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
|
|
| 3492 | + $terms = (array)$session_listing['post_category'][$taxonomy]; |
|
| 3493 | + } |
|
| 3494 | 3494 | |
| 3495 | - if (!empty($terms)) {
|
|
| 3496 | - foreach ($terms as $term_id) {
|
|
| 3497 | - if ($term_id > 0) {
|
|
| 3498 | - $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type); |
|
| 3499 | - $children = get_term_children($term_id, $taxonomy); |
|
| 3500 | - $term_array[$term_id] = $count; |
|
| 3501 | - } |
|
| 3502 | - } |
|
| 3503 | - } |
|
| 3504 | - } else { // Update reviews count for all post categories.
|
|
| 3505 | - $term_array = array(); |
|
| 3506 | - $post_types = geodir_get_posttypes(); |
|
| 3507 | - foreach ($post_types as $post_type) {
|
|
| 3508 | - |
|
| 3509 | - $taxonomy = geodir_get_taxonomies($post_type); |
|
| 3510 | - $taxonomy = $taxonomy[0]; |
|
| 3511 | - |
|
| 3512 | - $args = array( |
|
| 3513 | - 'hide_empty' => false |
|
| 3514 | - ); |
|
| 3515 | - |
|
| 3516 | - $terms = get_terms($taxonomy, $args); |
|
| 3517 | - |
|
| 3518 | - foreach ($terms as $term) {
|
|
| 3519 | - $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type); |
|
| 3520 | - $children = get_term_children($term->term_id, $taxonomy); |
|
| 3521 | - /*if ( is_array( $children ) ) {
|
|
| 3495 | + if (!empty($terms)) {
|
|
| 3496 | + foreach ($terms as $term_id) {
|
|
| 3497 | + if ($term_id > 0) {
|
|
| 3498 | + $count = geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type); |
|
| 3499 | + $children = get_term_children($term_id, $taxonomy); |
|
| 3500 | + $term_array[$term_id] = $count; |
|
| 3501 | + } |
|
| 3502 | + } |
|
| 3503 | + } |
|
| 3504 | + } else { // Update reviews count for all post categories.
|
|
| 3505 | + $term_array = array(); |
|
| 3506 | + $post_types = geodir_get_posttypes(); |
|
| 3507 | + foreach ($post_types as $post_type) {
|
|
| 3508 | + |
|
| 3509 | + $taxonomy = geodir_get_taxonomies($post_type); |
|
| 3510 | + $taxonomy = $taxonomy[0]; |
|
| 3511 | + |
|
| 3512 | + $args = array( |
|
| 3513 | + 'hide_empty' => false |
|
| 3514 | + ); |
|
| 3515 | + |
|
| 3516 | + $terms = get_terms($taxonomy, $args); |
|
| 3517 | + |
|
| 3518 | + foreach ($terms as $term) {
|
|
| 3519 | + $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type); |
|
| 3520 | + $children = get_term_children($term->term_id, $taxonomy); |
|
| 3521 | + /*if ( is_array( $children ) ) {
|
|
| 3522 | 3522 | foreach ( $children as $child_id ) {
|
| 3523 | 3523 | $child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type); |
| 3524 | 3524 | $count = $count + $child_count; |
| 3525 | 3525 | } |
| 3526 | 3526 | }*/ |
| 3527 | - $term_array[$term->term_id] = $count; |
|
| 3528 | - } |
|
| 3529 | - } |
|
| 3530 | - } |
|
| 3531 | - |
|
| 3532 | - update_option('geodir_global_review_count', $term_array);
|
|
| 3533 | - //clear cache |
|
| 3534 | - wp_cache_delete('geodir_global_review_count');
|
|
| 3535 | - return $term_array; |
|
| 3536 | - } else {
|
|
| 3537 | - return $option_data; |
|
| 3538 | - } |
|
| 3527 | + $term_array[$term->term_id] = $count; |
|
| 3528 | + } |
|
| 3529 | + } |
|
| 3530 | + } |
|
| 3531 | + |
|
| 3532 | + update_option('geodir_global_review_count', $term_array);
|
|
| 3533 | + //clear cache |
|
| 3534 | + wp_cache_delete('geodir_global_review_count');
|
|
| 3535 | + return $term_array; |
|
| 3536 | + } else {
|
|
| 3537 | + return $option_data; |
|
| 3538 | + } |
|
| 3539 | 3539 | } |
| 3540 | 3540 | |
| 3541 | 3541 | /** |
@@ -3547,38 +3547,38 @@ discard block |
||
| 3547 | 3547 | * @return bool |
| 3548 | 3548 | */ |
| 3549 | 3549 | function geodir_term_review_count_force_update($new_status, $old_status = '', $post = '') {
|
| 3550 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
|
|
| 3551 | - return; // do not run if importing listings |
|
| 3552 | - } |
|
| 3550 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {
|
|
| 3551 | + return; // do not run if importing listings |
|
| 3552 | + } |
|
| 3553 | 3553 | |
| 3554 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
|
| 3555 | - return; |
|
| 3556 | - } |
|
| 3557 | - |
|
| 3558 | - $post_ID = 0; |
|
| 3559 | - if (!empty($post)) {
|
|
| 3560 | - if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
|
|
| 3561 | - return; |
|
| 3562 | - } |
|
| 3554 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
|
| 3555 | + return; |
|
| 3556 | + } |
|
| 3557 | + |
|
| 3558 | + $post_ID = 0; |
|
| 3559 | + if (!empty($post)) {
|
|
| 3560 | + if (isset($post->post_type) && strpos($post->post_type, 'gd_') !== 0) {
|
|
| 3561 | + return; |
|
| 3562 | + } |
|
| 3563 | 3563 | |
| 3564 | - if ($new_status == 'auto-draft' && $old_status == 'new') {
|
|
| 3565 | - return; |
|
| 3566 | - } |
|
| 3564 | + if ($new_status == 'auto-draft' && $old_status == 'new') {
|
|
| 3565 | + return; |
|
| 3566 | + } |
|
| 3567 | 3567 | |
| 3568 | - if (!empty($post->ID)) {
|
|
| 3569 | - $post_ID = $post->ID; |
|
| 3570 | - } |
|
| 3571 | - } |
|
| 3568 | + if (!empty($post->ID)) {
|
|
| 3569 | + $post_ID = $post->ID; |
|
| 3570 | + } |
|
| 3571 | + } |
|
| 3572 | 3572 | |
| 3573 | - if ($new_status != $old_status) {
|
|
| 3574 | - geodir_count_reviews_by_terms(true, $post_ID); |
|
| 3575 | - } |
|
| 3573 | + if ($new_status != $old_status) {
|
|
| 3574 | + geodir_count_reviews_by_terms(true, $post_ID); |
|
| 3575 | + } |
|
| 3576 | 3576 | |
| 3577 | - return true; |
|
| 3577 | + return true; |
|
| 3578 | 3578 | } |
| 3579 | 3579 | |
| 3580 | 3580 | function geodir_term_review_count_force_update_single_post($post_id){
|
| 3581 | - geodir_count_reviews_by_terms(true, $post_id); |
|
| 3581 | + geodir_count_reviews_by_terms(true, $post_id); |
|
| 3582 | 3582 | } |
| 3583 | 3583 | |
| 3584 | 3584 | /*-----------------------------------------------------------------------------------*/ |
@@ -3596,15 +3596,15 @@ discard block |
||
| 3596 | 3596 | function geodir_count_posts_by_term($data, $term) |
| 3597 | 3597 | {
|
| 3598 | 3598 | |
| 3599 | - if ($data) {
|
|
| 3600 | - if (isset($data[$term->term_id])) {
|
|
| 3601 | - return $data[$term->term_id]; |
|
| 3602 | - } else {
|
|
| 3603 | - return 0; |
|
| 3604 | - } |
|
| 3605 | - } else {
|
|
| 3606 | - return $term->count; |
|
| 3607 | - } |
|
| 3599 | + if ($data) {
|
|
| 3600 | + if (isset($data[$term->term_id])) {
|
|
| 3601 | + return $data[$term->term_id]; |
|
| 3602 | + } else {
|
|
| 3603 | + return 0; |
|
| 3604 | + } |
|
| 3605 | + } else {
|
|
| 3606 | + return $term->count; |
|
| 3607 | + } |
|
| 3608 | 3608 | } |
| 3609 | 3609 | |
| 3610 | 3610 | /** |
@@ -3617,8 +3617,8 @@ discard block |
||
| 3617 | 3617 | */ |
| 3618 | 3618 | function geodir_sort_terms_by_count($terms) |
| 3619 | 3619 | {
|
| 3620 | - usort($terms, "geodir_sort_by_count_obj"); |
|
| 3621 | - return $terms; |
|
| 3620 | + usort($terms, "geodir_sort_by_count_obj"); |
|
| 3621 | + return $terms; |
|
| 3622 | 3622 | } |
| 3623 | 3623 | |
| 3624 | 3624 | /** |
@@ -3631,8 +3631,8 @@ discard block |
||
| 3631 | 3631 | */ |
| 3632 | 3632 | function geodir_sort_terms_by_review_count($terms) |
| 3633 | 3633 | {
|
| 3634 | - usort($terms, "geodir_sort_by_review_count_obj"); |
|
| 3635 | - return $terms; |
|
| 3634 | + usort($terms, "geodir_sort_by_review_count_obj"); |
|
| 3635 | + return $terms; |
|
| 3636 | 3636 | } |
| 3637 | 3637 | |
| 3638 | 3638 | /** |
@@ -3646,12 +3646,12 @@ discard block |
||
| 3646 | 3646 | */ |
| 3647 | 3647 | function geodir_sort_terms($terms, $sort = 'count') |
| 3648 | 3648 | {
|
| 3649 | - if ($sort == 'count') {
|
|
| 3650 | - return geodir_sort_terms_by_count($terms); |
|
| 3651 | - } |
|
| 3652 | - if ($sort == 'review_count') {
|
|
| 3653 | - return geodir_sort_terms_by_review_count($terms); |
|
| 3654 | - } |
|
| 3649 | + if ($sort == 'count') {
|
|
| 3650 | + return geodir_sort_terms_by_count($terms); |
|
| 3651 | + } |
|
| 3652 | + if ($sort == 'review_count') {
|
|
| 3653 | + return geodir_sort_terms_by_review_count($terms); |
|
| 3654 | + } |
|
| 3655 | 3655 | } |
| 3656 | 3656 | |
| 3657 | 3657 | /*-----------------------------------------------------------------------------------*/ |
@@ -3668,7 +3668,7 @@ discard block |
||
| 3668 | 3668 | */ |
| 3669 | 3669 | function geodir_sort_by_count($a, $b) |
| 3670 | 3670 | {
|
| 3671 | - return $a['count'] < $b['count']; |
|
| 3671 | + return $a['count'] < $b['count']; |
|
| 3672 | 3672 | } |
| 3673 | 3673 | |
| 3674 | 3674 | /** |
@@ -3682,7 +3682,7 @@ discard block |
||
| 3682 | 3682 | */ |
| 3683 | 3683 | function geodir_sort_by_count_obj($a, $b) |
| 3684 | 3684 | {
|
| 3685 | - return $a->count < $b->count; |
|
| 3685 | + return $a->count < $b->count; |
|
| 3686 | 3686 | } |
| 3687 | 3687 | |
| 3688 | 3688 | /** |
@@ -3696,7 +3696,7 @@ discard block |
||
| 3696 | 3696 | */ |
| 3697 | 3697 | function geodir_sort_by_review_count_obj($a, $b) |
| 3698 | 3698 | {
|
| 3699 | - return $a->review_count < $b->review_count; |
|
| 3699 | + return $a->review_count < $b->review_count; |
|
| 3700 | 3700 | } |
| 3701 | 3701 | |
| 3702 | 3702 | /** |
@@ -3706,43 +3706,43 @@ discard block |
||
| 3706 | 3706 | * @package GeoDirectory |
| 3707 | 3707 | */ |
| 3708 | 3708 | function geodir_load_textdomain() {
|
| 3709 | - /** |
|
| 3710 | - * Filter the plugin locale. |
|
| 3711 | - * |
|
| 3712 | - * @since 1.4.2 |
|
| 3713 | - * @package GeoDirectory |
|
| 3714 | - */ |
|
| 3715 | - $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
|
|
| 3716 | - |
|
| 3717 | - load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
|
|
| 3718 | - load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
|
|
| 3709 | + /** |
|
| 3710 | + * Filter the plugin locale. |
|
| 3711 | + * |
|
| 3712 | + * @since 1.4.2 |
|
| 3713 | + * @package GeoDirectory |
|
| 3714 | + */ |
|
| 3715 | + $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
|
|
| 3716 | + |
|
| 3717 | + load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
|
|
| 3718 | + load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
|
|
| 3719 | + |
|
| 3720 | + /** |
|
| 3721 | + * Define language constants. |
|
| 3722 | + * |
|
| 3723 | + * @since 1.0.0 |
|
| 3724 | + */ |
|
| 3725 | + require_once(geodir_plugin_path() . '/language.php'); |
|
| 3726 | + |
|
| 3727 | + $language_file = geodir_plugin_path() . '/db-language.php'; |
|
| 3728 | + |
|
| 3729 | + // Load language string file if not created yet |
|
| 3730 | + if (!file_exists($language_file)) {
|
|
| 3731 | + geodirectory_load_db_language(); |
|
| 3732 | + } |
|
| 3719 | 3733 | |
| 3720 | - /** |
|
| 3721 | - * Define language constants. |
|
| 3722 | - * |
|
| 3723 | - * @since 1.0.0 |
|
| 3724 | - */ |
|
| 3725 | - require_once(geodir_plugin_path() . '/language.php'); |
|
| 3726 | - |
|
| 3727 | - $language_file = geodir_plugin_path() . '/db-language.php'; |
|
| 3728 | - |
|
| 3729 | - // Load language string file if not created yet |
|
| 3730 | - if (!file_exists($language_file)) {
|
|
| 3731 | - geodirectory_load_db_language(); |
|
| 3732 | - } |
|
| 3733 | - |
|
| 3734 | - if (file_exists($language_file)) {
|
|
| 3735 | - /** |
|
| 3736 | - * Language strings from database. |
|
| 3737 | - * |
|
| 3738 | - * @since 1.4.2 |
|
| 3739 | - */ |
|
| 3740 | - try {
|
|
| 3741 | - require_once($language_file); |
|
| 3742 | - } catch(Exception $e) {
|
|
| 3743 | - error_log('Language Error: ' . $e->getMessage());
|
|
| 3744 | - } |
|
| 3745 | - } |
|
| 3734 | + if (file_exists($language_file)) {
|
|
| 3735 | + /** |
|
| 3736 | + * Language strings from database. |
|
| 3737 | + * |
|
| 3738 | + * @since 1.4.2 |
|
| 3739 | + */ |
|
| 3740 | + try {
|
|
| 3741 | + require_once($language_file); |
|
| 3742 | + } catch(Exception $e) {
|
|
| 3743 | + error_log('Language Error: ' . $e->getMessage());
|
|
| 3744 | + } |
|
| 3745 | + } |
|
| 3746 | 3746 | } |
| 3747 | 3747 | |
| 3748 | 3748 | /** |
@@ -3756,66 +3756,66 @@ discard block |
||
| 3756 | 3756 | * @return bool True if file created otherwise false |
| 3757 | 3757 | */ |
| 3758 | 3758 | function geodirectory_load_db_language() {
|
| 3759 | - global $wp_filesystem; |
|
| 3760 | - if( empty( $wp_filesystem ) ) {
|
|
| 3761 | - require_once( ABSPATH .'/wp-admin/includes/file.php' ); |
|
| 3762 | - WP_Filesystem(); |
|
| 3763 | - global $wp_filesystem; |
|
| 3764 | - } |
|
| 3765 | - |
|
| 3766 | - $language_file = geodir_plugin_path() . '/db-language.php'; |
|
| 3759 | + global $wp_filesystem; |
|
| 3760 | + if( empty( $wp_filesystem ) ) {
|
|
| 3761 | + require_once( ABSPATH .'/wp-admin/includes/file.php' ); |
|
| 3762 | + WP_Filesystem(); |
|
| 3763 | + global $wp_filesystem; |
|
| 3764 | + } |
|
| 3767 | 3765 | |
| 3768 | - if(is_file($language_file) && !is_writable($language_file)) |
|
| 3769 | - return false; // Not possible to create. |
|
| 3766 | + $language_file = geodir_plugin_path() . '/db-language.php'; |
|
| 3767 | + |
|
| 3768 | + if(is_file($language_file) && !is_writable($language_file)) |
|
| 3769 | + return false; // Not possible to create. |
|
| 3770 | + |
|
| 3771 | + if(!is_file($language_file) && !is_writable(dirname($language_file))) |
|
| 3772 | + return false; // Not possible to create. |
|
| 3773 | + |
|
| 3774 | + $contents_strings = array(); |
|
| 3775 | + |
|
| 3776 | + /** |
|
| 3777 | + * Filter the language string from database to translate via po editor |
|
| 3778 | + * |
|
| 3779 | + * @since 1.4.2 |
|
| 3780 | + * |
|
| 3781 | + * @param array $contents_strings Array of strings. |
|
| 3782 | + */ |
|
| 3783 | + $contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
|
|
| 3784 | + |
|
| 3785 | + $contents_strings = array_unique($contents_strings); |
|
| 3786 | + |
|
| 3787 | + $contents_head = array(); |
|
| 3788 | + $contents_head[] = "<?php"; |
|
| 3789 | + $contents_head[] = "/**"; |
|
| 3790 | + $contents_head[] = " * Translate language string stored in database. Ex: Custom Fields"; |
|
| 3791 | + $contents_head[] = " *"; |
|
| 3792 | + $contents_head[] = " * @package GeoDirectory"; |
|
| 3793 | + $contents_head[] = " * @since 1.4.2"; |
|
| 3794 | + $contents_head[] = " */"; |
|
| 3795 | + $contents_head[] = ""; |
|
| 3796 | + $contents_head[] = "// Language keys"; |
|
| 3797 | + |
|
| 3798 | + $contents_foot = array(); |
|
| 3799 | + $contents_foot[] = ""; |
|
| 3800 | + $contents_foot[] = ""; |
|
| 3801 | + |
|
| 3802 | + $contents = implode(PHP_EOL, $contents_head); |
|
| 3803 | + |
|
| 3804 | + if (!empty($contents_strings)) {
|
|
| 3805 | + foreach ( $contents_strings as $string ) {
|
|
| 3806 | + if (is_scalar($string) && $string != '') {
|
|
| 3807 | + $string = str_replace("'", "\'", $string);
|
|
| 3808 | + $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
|
|
| 3809 | + } |
|
| 3810 | + } |
|
| 3811 | + } |
|
| 3770 | 3812 | |
| 3771 | - if(!is_file($language_file) && !is_writable(dirname($language_file))) |
|
| 3772 | - return false; // Not possible to create. |
|
| 3813 | + $contents .= implode(PHP_EOL, $contents_foot); |
|
| 3773 | 3814 | |
| 3774 | - $contents_strings = array(); |
|
| 3815 | + if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) |
|
| 3816 | + return false; // Failure; could not write file. |
|
| 3775 | 3817 | |
| 3776 | - /** |
|
| 3777 | - * Filter the language string from database to translate via po editor |
|
| 3778 | - * |
|
| 3779 | - * @since 1.4.2 |
|
| 3780 | - * |
|
| 3781 | - * @param array $contents_strings Array of strings. |
|
| 3782 | - */ |
|
| 3783 | - $contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
|
|
| 3784 | - |
|
| 3785 | - $contents_strings = array_unique($contents_strings); |
|
| 3786 | - |
|
| 3787 | - $contents_head = array(); |
|
| 3788 | - $contents_head[] = "<?php"; |
|
| 3789 | - $contents_head[] = "/**"; |
|
| 3790 | - $contents_head[] = " * Translate language string stored in database. Ex: Custom Fields"; |
|
| 3791 | - $contents_head[] = " *"; |
|
| 3792 | - $contents_head[] = " * @package GeoDirectory"; |
|
| 3793 | - $contents_head[] = " * @since 1.4.2"; |
|
| 3794 | - $contents_head[] = " */"; |
|
| 3795 | - $contents_head[] = ""; |
|
| 3796 | - $contents_head[] = "// Language keys"; |
|
| 3797 | - |
|
| 3798 | - $contents_foot = array(); |
|
| 3799 | - $contents_foot[] = ""; |
|
| 3800 | - $contents_foot[] = ""; |
|
| 3801 | - |
|
| 3802 | - $contents = implode(PHP_EOL, $contents_head); |
|
| 3803 | - |
|
| 3804 | - if (!empty($contents_strings)) {
|
|
| 3805 | - foreach ( $contents_strings as $string ) {
|
|
| 3806 | - if (is_scalar($string) && $string != '') {
|
|
| 3807 | - $string = str_replace("'", "\'", $string);
|
|
| 3808 | - $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
|
|
| 3809 | - } |
|
| 3810 | - } |
|
| 3811 | - } |
|
| 3812 | - |
|
| 3813 | - $contents .= implode(PHP_EOL, $contents_foot); |
|
| 3814 | - |
|
| 3815 | - if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) |
|
| 3816 | - return false; // Failure; could not write file. |
|
| 3817 | - |
|
| 3818 | - return true; |
|
| 3818 | + return true; |
|
| 3819 | 3819 | } |
| 3820 | 3820 | |
| 3821 | 3821 | /** |
@@ -3831,31 +3831,31 @@ discard block |
||
| 3831 | 3831 | * @return array Translation texts. |
| 3832 | 3832 | */ |
| 3833 | 3833 | function geodir_load_custom_field_translation($translation_texts = array()) {
|
| 3834 | - global $wpdb; |
|
| 3834 | + global $wpdb; |
|
| 3835 | 3835 | |
| 3836 | - // Custom fields table |
|
| 3837 | - $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE; |
|
| 3838 | - $rows = $wpdb->get_results($sql); |
|
| 3836 | + // Custom fields table |
|
| 3837 | + $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE; |
|
| 3838 | + $rows = $wpdb->get_results($sql); |
|
| 3839 | 3839 | |
| 3840 | - if (!empty($rows)) {
|
|
| 3841 | - foreach($rows as $row) {
|
|
| 3842 | - if (!empty($row->admin_title)) |
|
| 3843 | - $translation_texts[] = stripslashes_deep($row->admin_title); |
|
| 3840 | + if (!empty($rows)) {
|
|
| 3841 | + foreach($rows as $row) {
|
|
| 3842 | + if (!empty($row->admin_title)) |
|
| 3843 | + $translation_texts[] = stripslashes_deep($row->admin_title); |
|
| 3844 | 3844 | |
| 3845 | - if (!empty($row->admin_desc)) |
|
| 3846 | - $translation_texts[] = stripslashes_deep($row->admin_desc); |
|
| 3845 | + if (!empty($row->admin_desc)) |
|
| 3846 | + $translation_texts[] = stripslashes_deep($row->admin_desc); |
|
| 3847 | 3847 | |
| 3848 | - if (!empty($row->site_title)) |
|
| 3849 | - $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3848 | + if (!empty($row->site_title)) |
|
| 3849 | + $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3850 | 3850 | |
| 3851 | - if (!empty($row->clabels)) |
|
| 3852 | - $translation_texts[] = stripslashes_deep($row->clabels); |
|
| 3851 | + if (!empty($row->clabels)) |
|
| 3852 | + $translation_texts[] = stripslashes_deep($row->clabels); |
|
| 3853 | 3853 | |
| 3854 | - if (!empty($row->required_msg)) |
|
| 3855 | - $translation_texts[] = stripslashes_deep($row->required_msg); |
|
| 3854 | + if (!empty($row->required_msg)) |
|
| 3855 | + $translation_texts[] = stripslashes_deep($row->required_msg); |
|
| 3856 | 3856 | |
| 3857 | 3857 | if (!empty($row->default_value)) |
| 3858 | - $translation_texts[] = stripslashes_deep($row->default_value); |
|
| 3858 | + $translation_texts[] = stripslashes_deep($row->default_value); |
|
| 3859 | 3859 | |
| 3860 | 3860 | if (!empty($row->option_values)) {
|
| 3861 | 3861 | $option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values)); |
@@ -3868,25 +3868,25 @@ discard block |
||
| 3868 | 3868 | } |
| 3869 | 3869 | } |
| 3870 | 3870 | } |
| 3871 | - } |
|
| 3872 | - } |
|
| 3871 | + } |
|
| 3872 | + } |
|
| 3873 | 3873 | |
| 3874 | - // Custom sorting fields table |
|
| 3875 | - $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE; |
|
| 3876 | - $rows = $wpdb->get_results($sql); |
|
| 3877 | - |
|
| 3878 | - if (!empty($rows)) {
|
|
| 3879 | - foreach($rows as $row) {
|
|
| 3880 | - if (!empty($row->site_title)) |
|
| 3881 | - $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3882 | - |
|
| 3883 | - if (!empty($row->asc_title)) |
|
| 3884 | - $translation_texts[] = stripslashes_deep($row->asc_title); |
|
| 3885 | - |
|
| 3886 | - if (!empty($row->desc_title)) |
|
| 3887 | - $translation_texts[] = stripslashes_deep($row->desc_title); |
|
| 3888 | - } |
|
| 3889 | - } |
|
| 3874 | + // Custom sorting fields table |
|
| 3875 | + $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE; |
|
| 3876 | + $rows = $wpdb->get_results($sql); |
|
| 3877 | + |
|
| 3878 | + if (!empty($rows)) {
|
|
| 3879 | + foreach($rows as $row) {
|
|
| 3880 | + if (!empty($row->site_title)) |
|
| 3881 | + $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3882 | + |
|
| 3883 | + if (!empty($row->asc_title)) |
|
| 3884 | + $translation_texts[] = stripslashes_deep($row->asc_title); |
|
| 3885 | + |
|
| 3886 | + if (!empty($row->desc_title)) |
|
| 3887 | + $translation_texts[] = stripslashes_deep($row->desc_title); |
|
| 3888 | + } |
|
| 3889 | + } |
|
| 3890 | 3890 | |
| 3891 | 3891 | // Advance search filter fields table |
| 3892 | 3892 | if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
|
@@ -3907,9 +3907,9 @@ discard block |
||
| 3907 | 3907 | } |
| 3908 | 3908 | } |
| 3909 | 3909 | |
| 3910 | - $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
| 3910 | + $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
| 3911 | 3911 | |
| 3912 | - return $translation_texts; |
|
| 3912 | + return $translation_texts; |
|
| 3913 | 3913 | } |
| 3914 | 3914 | |
| 3915 | 3915 | /** |
@@ -3921,71 +3921,71 @@ discard block |
||
| 3921 | 3921 | * @return array Array of mime types. |
| 3922 | 3922 | */ |
| 3923 | 3923 | function geodir_allowed_mime_types() {
|
| 3924 | - /** |
|
| 3925 | - * Filter the list of mime types and file extensions allowed for file upload. |
|
| 3926 | - * |
|
| 3927 | - * @since 1.4.7 |
|
| 3928 | - * @package GeoDirectory |
|
| 3929 | - * |
|
| 3930 | - * @param array $geodir_allowed_mime_types and file extensions. |
|
| 3931 | - */ |
|
| 3932 | - return apply_filters( 'geodir_allowed_mime_types', array( |
|
| 3933 | - 'Image' => array( // Image formats. |
|
| 3934 | - 'jpg' => 'image/jpeg', |
|
| 3935 | - 'jpe' => 'image/jpeg', |
|
| 3936 | - 'jpeg' => 'image/jpeg', |
|
| 3937 | - 'gif' => 'image/gif', |
|
| 3938 | - 'png' => 'image/png', |
|
| 3939 | - 'bmp' => 'image/bmp', |
|
| 3940 | - 'ico' => 'image/x-icon', |
|
| 3941 | - ), |
|
| 3942 | - 'Video' => array( // Video formats. |
|
| 3943 | - 'asf' => 'video/x-ms-asf', |
|
| 3944 | - 'avi' => 'video/avi', |
|
| 3945 | - 'flv' => 'video/x-flv', |
|
| 3946 | - 'mkv' => 'video/x-matroska', |
|
| 3947 | - 'mp4' => 'video/mp4', |
|
| 3948 | - 'mpeg' => 'video/mpeg', |
|
| 3949 | - 'mpg' => 'video/mpeg', |
|
| 3950 | - 'wmv' => 'video/x-ms-wmv', |
|
| 3951 | - '3gp' => 'video/3gpp', |
|
| 3952 | - ), |
|
| 3953 | - 'Audio' => array( // Audio formats. |
|
| 3954 | - 'ogg' => 'audio/ogg', |
|
| 3955 | - 'mp3' => 'audio/mpeg', |
|
| 3956 | - 'wav' => 'audio/wav', |
|
| 3957 | - 'wma' => 'audio/x-ms-wma', |
|
| 3958 | - ), |
|
| 3959 | - 'Text' => array( // Text formats. |
|
| 3960 | - 'css' => 'text/css', |
|
| 3961 | - 'csv' => 'text/csv', |
|
| 3962 | - 'htm' => 'text/html', |
|
| 3963 | - 'html' => 'text/html', |
|
| 3964 | - 'txt' => 'text/plain', |
|
| 3965 | - 'rtx' => 'text/richtext', |
|
| 3966 | - 'vtt' => 'text/vtt', |
|
| 3967 | - ), |
|
| 3968 | - 'Application' => array( // Application formats. |
|
| 3969 | - 'doc' => 'application/msword', |
|
| 3970 | - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', |
|
| 3971 | - 'exe' => 'application/x-msdownload', |
|
| 3972 | - 'js' => 'application/javascript', |
|
| 3973 | - 'odt' => 'application/vnd.oasis.opendocument.text', |
|
| 3974 | - 'pdf' => 'application/pdf', |
|
| 3975 | - 'pot' => 'application/vnd.ms-powerpoint', |
|
| 3976 | - 'ppt' => 'application/vnd.ms-powerpoint', |
|
| 3977 | - 'pptx' => 'application/vnd.ms-powerpoint', |
|
| 3978 | - 'psd' => 'application/octet-stream', |
|
| 3979 | - 'rar' => 'application/rar', |
|
| 3980 | - 'rtf' => 'application/rtf', |
|
| 3981 | - 'swf' => 'application/x-shockwave-flash', |
|
| 3982 | - 'tar' => 'application/x-tar', |
|
| 3983 | - 'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
|
| 3984 | - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
|
| 3985 | - 'zip' => 'application/zip', |
|
| 3986 | - ) |
|
| 3987 | - ) |
|
| 3988 | - ); |
|
| 3924 | + /** |
|
| 3925 | + * Filter the list of mime types and file extensions allowed for file upload. |
|
| 3926 | + * |
|
| 3927 | + * @since 1.4.7 |
|
| 3928 | + * @package GeoDirectory |
|
| 3929 | + * |
|
| 3930 | + * @param array $geodir_allowed_mime_types and file extensions. |
|
| 3931 | + */ |
|
| 3932 | + return apply_filters( 'geodir_allowed_mime_types', array( |
|
| 3933 | + 'Image' => array( // Image formats. |
|
| 3934 | + 'jpg' => 'image/jpeg', |
|
| 3935 | + 'jpe' => 'image/jpeg', |
|
| 3936 | + 'jpeg' => 'image/jpeg', |
|
| 3937 | + 'gif' => 'image/gif', |
|
| 3938 | + 'png' => 'image/png', |
|
| 3939 | + 'bmp' => 'image/bmp', |
|
| 3940 | + 'ico' => 'image/x-icon', |
|
| 3941 | + ), |
|
| 3942 | + 'Video' => array( // Video formats. |
|
| 3943 | + 'asf' => 'video/x-ms-asf', |
|
| 3944 | + 'avi' => 'video/avi', |
|
| 3945 | + 'flv' => 'video/x-flv', |
|
| 3946 | + 'mkv' => 'video/x-matroska', |
|
| 3947 | + 'mp4' => 'video/mp4', |
|
| 3948 | + 'mpeg' => 'video/mpeg', |
|
| 3949 | + 'mpg' => 'video/mpeg', |
|
| 3950 | + 'wmv' => 'video/x-ms-wmv', |
|
| 3951 | + '3gp' => 'video/3gpp', |
|
| 3952 | + ), |
|
| 3953 | + 'Audio' => array( // Audio formats. |
|
| 3954 | + 'ogg' => 'audio/ogg', |
|
| 3955 | + 'mp3' => 'audio/mpeg', |
|
| 3956 | + 'wav' => 'audio/wav', |
|
| 3957 | + 'wma' => 'audio/x-ms-wma', |
|
| 3958 | + ), |
|
| 3959 | + 'Text' => array( // Text formats. |
|
| 3960 | + 'css' => 'text/css', |
|
| 3961 | + 'csv' => 'text/csv', |
|
| 3962 | + 'htm' => 'text/html', |
|
| 3963 | + 'html' => 'text/html', |
|
| 3964 | + 'txt' => 'text/plain', |
|
| 3965 | + 'rtx' => 'text/richtext', |
|
| 3966 | + 'vtt' => 'text/vtt', |
|
| 3967 | + ), |
|
| 3968 | + 'Application' => array( // Application formats. |
|
| 3969 | + 'doc' => 'application/msword', |
|
| 3970 | + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', |
|
| 3971 | + 'exe' => 'application/x-msdownload', |
|
| 3972 | + 'js' => 'application/javascript', |
|
| 3973 | + 'odt' => 'application/vnd.oasis.opendocument.text', |
|
| 3974 | + 'pdf' => 'application/pdf', |
|
| 3975 | + 'pot' => 'application/vnd.ms-powerpoint', |
|
| 3976 | + 'ppt' => 'application/vnd.ms-powerpoint', |
|
| 3977 | + 'pptx' => 'application/vnd.ms-powerpoint', |
|
| 3978 | + 'psd' => 'application/octet-stream', |
|
| 3979 | + 'rar' => 'application/rar', |
|
| 3980 | + 'rtf' => 'application/rtf', |
|
| 3981 | + 'swf' => 'application/x-shockwave-flash', |
|
| 3982 | + 'tar' => 'application/x-tar', |
|
| 3983 | + 'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
|
| 3984 | + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
|
| 3985 | + 'zip' => 'application/zip', |
|
| 3986 | + ) |
|
| 3987 | + ) |
|
| 3988 | + ); |
|
| 3989 | 3989 | } |
| 3990 | 3990 | |
| 3991 | 3991 | /** |
@@ -3997,21 +3997,21 @@ discard block |
||
| 3997 | 3997 | * @return string User display name. |
| 3998 | 3998 | */ |
| 3999 | 3999 | function geodir_get_client_name($user_id) {
|
| 4000 | - $client_name = ''; |
|
| 4000 | + $client_name = ''; |
|
| 4001 | 4001 | |
| 4002 | - $user_data = get_userdata($user_id); |
|
| 4002 | + $user_data = get_userdata($user_id); |
|
| 4003 | 4003 | |
| 4004 | - if (!empty($user_data)) {
|
|
| 4005 | - if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
|
|
| 4006 | - $client_name = trim($user_data->display_name); |
|
| 4007 | - } else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
|
|
| 4008 | - $client_name = trim($user_data->user_nicename); |
|
| 4009 | - } else {
|
|
| 4010 | - $client_name = trim($user_data->user_login); |
|
| 4011 | - } |
|
| 4012 | - } |
|
| 4004 | + if (!empty($user_data)) {
|
|
| 4005 | + if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
|
|
| 4006 | + $client_name = trim($user_data->display_name); |
|
| 4007 | + } else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
|
|
| 4008 | + $client_name = trim($user_data->user_nicename); |
|
| 4009 | + } else {
|
|
| 4010 | + $client_name = trim($user_data->user_login); |
|
| 4011 | + } |
|
| 4012 | + } |
|
| 4013 | 4013 | |
| 4014 | - return $client_name; |
|
| 4014 | + return $client_name; |
|
| 4015 | 4015 | } |
| 4016 | 4016 | |
| 4017 | 4017 | |
@@ -4026,125 +4026,125 @@ discard block |
||
| 4026 | 4026 | */ |
| 4027 | 4027 | function geodir_wpseo_replacements($vars){
|
| 4028 | 4028 | |
| 4029 | - global $wp; |
|
| 4030 | - $title = ''; |
|
| 4031 | - // location variables |
|
| 4032 | - $gd_post_type = geodir_get_current_posttype(); |
|
| 4033 | - $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 4034 | - /** |
|
| 4035 | - * Filter the title variables location variables array |
|
| 4036 | - * |
|
| 4037 | - * @since 1.5.5 |
|
| 4038 | - * @package GeoDirectory |
|
| 4039 | - * @param array $location_array The array of location variables. |
|
| 4040 | - * @param array $vars The page title variables. |
|
| 4041 | - */ |
|
| 4042 | - $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
|
|
| 4043 | - $location_titles = array(); |
|
| 4044 | - if(get_query_var( 'gd_country_full' )){
|
|
| 4045 | - if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
|
|
| 4046 | - if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
|
|
| 4047 | - if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
|
|
| 4048 | - } |
|
| 4049 | - $location_single = ''; |
|
| 4050 | - $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
| 4051 | - $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
| 4052 | - $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
| 4053 | - |
|
| 4054 | - $gd_country_actual = $gd_region_actual = $gd_city_actual = ''; |
|
| 4055 | - |
|
| 4056 | - if (function_exists('get_actual_location_name')) {
|
|
| 4057 | - $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
|
|
| 4058 | - $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
|
|
| 4059 | - $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
|
|
| 4060 | - } |
|
| 4061 | - |
|
| 4062 | - if ($gd_city != '') {
|
|
| 4063 | - if ($gd_city_actual != '') {
|
|
| 4064 | - $gd_city = $gd_city_actual; |
|
| 4065 | - } else {
|
|
| 4066 | - $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
|
|
| 4067 | - $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
|
|
| 4068 | - $gd_city = __(geodir_ucwords($gd_city), 'geodirectory'); |
|
| 4069 | - } |
|
| 4070 | - $location_single = $gd_city; |
|
| 4071 | - |
|
| 4072 | - } else if ($gd_region != '') {
|
|
| 4073 | - if ($gd_region_actual != '') {
|
|
| 4074 | - $gd_region = $gd_region_actual; |
|
| 4075 | - } else {
|
|
| 4076 | - $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
|
|
| 4077 | - $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
|
|
| 4078 | - $gd_region = __(geodir_ucwords($gd_region), 'geodirectory'); |
|
| 4079 | - } |
|
| 4080 | - |
|
| 4081 | - $location_single = $gd_region; |
|
| 4082 | - } else if ($gd_country != '') {
|
|
| 4083 | - if ($gd_country_actual != '') {
|
|
| 4084 | - $gd_country = $gd_country_actual; |
|
| 4085 | - } else {
|
|
| 4086 | - $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
|
|
| 4087 | - $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
|
|
| 4088 | - $gd_country = __(geodir_ucwords($gd_country), 'geodirectory'); |
|
| 4089 | - } |
|
| 4090 | - |
|
| 4091 | - $location_single = $gd_country; |
|
| 4092 | - } |
|
| 4093 | - |
|
| 4094 | - if (!empty($location_array)) {
|
|
| 4095 | - |
|
| 4096 | - $actual_location_name = function_exists('get_actual_location_name') ? true : false;
|
|
| 4097 | - $location_array = array_reverse($location_array); |
|
| 4098 | - |
|
| 4099 | - foreach ($location_array as $location_type => $location) {
|
|
| 4100 | - $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
|
|
| 4101 | - $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
|
|
| 4102 | - |
|
| 4103 | - $location_name = geodir_ucwords($gd_location_link_text); |
|
| 4104 | - $location_name = __($location_name, 'geodirectory'); |
|
| 4105 | - |
|
| 4106 | - if ($actual_location_name) {
|
|
| 4107 | - $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type; |
|
| 4108 | - $location_name = get_actual_location_name($location_type, $location, true); |
|
| 4109 | - } |
|
| 4110 | - |
|
| 4111 | - $location_titles[] = $location_name; |
|
| 4112 | - } |
|
| 4113 | - if (!empty($location_titles)) {
|
|
| 4114 | - $location_titles = array_unique($location_titles); |
|
| 4115 | - } |
|
| 4116 | - } |
|
| 4117 | - |
|
| 4118 | - |
|
| 4119 | - if(!empty($location_titles)) {
|
|
| 4120 | - $vars['%%location%%'] = implode(", ", $location_titles);
|
|
| 4121 | - } |
|
| 4122 | - |
|
| 4123 | - |
|
| 4124 | - if(!empty($location_titles)) {
|
|
| 4125 | - $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
|
|
| 4126 | - } |
|
| 4127 | - |
|
| 4128 | - |
|
| 4129 | - |
|
| 4130 | - if($location_single) {
|
|
| 4131 | - $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
|
|
| 4132 | - } |
|
| 4133 | - |
|
| 4134 | - |
|
| 4135 | - if($location_single) {
|
|
| 4136 | - $vars['%%location_single%%'] = $location_single; |
|
| 4137 | - } |
|
| 4138 | - |
|
| 4139 | - /** |
|
| 4140 | - * Filter the title variables after standard ones have been filtered for wpseo. |
|
| 4141 | - * |
|
| 4142 | - * @since 1.5.7 |
|
| 4143 | - * @package GeoDirectory |
|
| 4144 | - * @param string $vars The title with variables. |
|
| 4145 | - * @param array $location_array The array of location variables. |
|
| 4146 | - */ |
|
| 4147 | - return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
|
|
| 4029 | + global $wp; |
|
| 4030 | + $title = ''; |
|
| 4031 | + // location variables |
|
| 4032 | + $gd_post_type = geodir_get_current_posttype(); |
|
| 4033 | + $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 4034 | + /** |
|
| 4035 | + * Filter the title variables location variables array |
|
| 4036 | + * |
|
| 4037 | + * @since 1.5.5 |
|
| 4038 | + * @package GeoDirectory |
|
| 4039 | + * @param array $location_array The array of location variables. |
|
| 4040 | + * @param array $vars The page title variables. |
|
| 4041 | + */ |
|
| 4042 | + $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
|
|
| 4043 | + $location_titles = array(); |
|
| 4044 | + if(get_query_var( 'gd_country_full' )){
|
|
| 4045 | + if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
|
|
| 4046 | + if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
|
|
| 4047 | + if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
|
|
| 4048 | + } |
|
| 4049 | + $location_single = ''; |
|
| 4050 | + $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
| 4051 | + $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
| 4052 | + $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
| 4053 | + |
|
| 4054 | + $gd_country_actual = $gd_region_actual = $gd_city_actual = ''; |
|
| 4055 | + |
|
| 4056 | + if (function_exists('get_actual_location_name')) {
|
|
| 4057 | + $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
|
|
| 4058 | + $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
|
|
| 4059 | + $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
|
|
| 4060 | + } |
|
| 4061 | + |
|
| 4062 | + if ($gd_city != '') {
|
|
| 4063 | + if ($gd_city_actual != '') {
|
|
| 4064 | + $gd_city = $gd_city_actual; |
|
| 4065 | + } else {
|
|
| 4066 | + $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
|
|
| 4067 | + $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
|
|
| 4068 | + $gd_city = __(geodir_ucwords($gd_city), 'geodirectory'); |
|
| 4069 | + } |
|
| 4070 | + $location_single = $gd_city; |
|
| 4071 | + |
|
| 4072 | + } else if ($gd_region != '') {
|
|
| 4073 | + if ($gd_region_actual != '') {
|
|
| 4074 | + $gd_region = $gd_region_actual; |
|
| 4075 | + } else {
|
|
| 4076 | + $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
|
|
| 4077 | + $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
|
|
| 4078 | + $gd_region = __(geodir_ucwords($gd_region), 'geodirectory'); |
|
| 4079 | + } |
|
| 4080 | + |
|
| 4081 | + $location_single = $gd_region; |
|
| 4082 | + } else if ($gd_country != '') {
|
|
| 4083 | + if ($gd_country_actual != '') {
|
|
| 4084 | + $gd_country = $gd_country_actual; |
|
| 4085 | + } else {
|
|
| 4086 | + $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
|
|
| 4087 | + $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
|
|
| 4088 | + $gd_country = __(geodir_ucwords($gd_country), 'geodirectory'); |
|
| 4089 | + } |
|
| 4090 | + |
|
| 4091 | + $location_single = $gd_country; |
|
| 4092 | + } |
|
| 4093 | + |
|
| 4094 | + if (!empty($location_array)) {
|
|
| 4095 | + |
|
| 4096 | + $actual_location_name = function_exists('get_actual_location_name') ? true : false;
|
|
| 4097 | + $location_array = array_reverse($location_array); |
|
| 4098 | + |
|
| 4099 | + foreach ($location_array as $location_type => $location) {
|
|
| 4100 | + $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
|
|
| 4101 | + $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
|
|
| 4102 | + |
|
| 4103 | + $location_name = geodir_ucwords($gd_location_link_text); |
|
| 4104 | + $location_name = __($location_name, 'geodirectory'); |
|
| 4105 | + |
|
| 4106 | + if ($actual_location_name) {
|
|
| 4107 | + $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type; |
|
| 4108 | + $location_name = get_actual_location_name($location_type, $location, true); |
|
| 4109 | + } |
|
| 4110 | + |
|
| 4111 | + $location_titles[] = $location_name; |
|
| 4112 | + } |
|
| 4113 | + if (!empty($location_titles)) {
|
|
| 4114 | + $location_titles = array_unique($location_titles); |
|
| 4115 | + } |
|
| 4116 | + } |
|
| 4117 | + |
|
| 4118 | + |
|
| 4119 | + if(!empty($location_titles)) {
|
|
| 4120 | + $vars['%%location%%'] = implode(", ", $location_titles);
|
|
| 4121 | + } |
|
| 4122 | + |
|
| 4123 | + |
|
| 4124 | + if(!empty($location_titles)) {
|
|
| 4125 | + $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
|
|
| 4126 | + } |
|
| 4127 | + |
|
| 4128 | + |
|
| 4129 | + |
|
| 4130 | + if($location_single) {
|
|
| 4131 | + $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
|
|
| 4132 | + } |
|
| 4133 | + |
|
| 4134 | + |
|
| 4135 | + if($location_single) {
|
|
| 4136 | + $vars['%%location_single%%'] = $location_single; |
|
| 4137 | + } |
|
| 4138 | + |
|
| 4139 | + /** |
|
| 4140 | + * Filter the title variables after standard ones have been filtered for wpseo. |
|
| 4141 | + * |
|
| 4142 | + * @since 1.5.7 |
|
| 4143 | + * @package GeoDirectory |
|
| 4144 | + * @param string $vars The title with variables. |
|
| 4145 | + * @param array $location_array The array of location variables. |
|
| 4146 | + */ |
|
| 4147 | + return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
|
|
| 4148 | 4148 | } |
| 4149 | 4149 | |
| 4150 | 4150 | |
@@ -4154,10 +4154,10 @@ discard block |
||
| 4154 | 4154 | function geodir_filter_title_variables($title, $gd_page, $sep=''){
|
| 4155 | 4155 | |
| 4156 | 4156 | |
| 4157 | - if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
|
|
| 4158 | - global $post; |
|
| 4159 | - //print_r($post); |
|
| 4160 | - /* |
|
| 4157 | + if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
|
|
| 4158 | + global $post; |
|
| 4159 | + //print_r($post); |
|
| 4160 | + /* |
|
| 4161 | 4161 | %%date%% Replaced with the date of the post/page |
| 4162 | 4162 | %%title%% Replaced with the title of the post/page |
| 4163 | 4163 | %%sitename%% The site's name |
@@ -4184,314 +4184,314 @@ discard block |
||
| 4184 | 4184 | %%pagenumber%% Replaced with the current page number |
| 4185 | 4185 | */ |
| 4186 | 4186 | |
| 4187 | - if ($sep == '') {
|
|
| 4188 | - /** |
|
| 4189 | - * Filter the page title separator. |
|
| 4190 | - * |
|
| 4191 | - * @since 1.0.0 |
|
| 4192 | - * @package GeoDirectory |
|
| 4193 | - * @param string $sep The separator, default: `|`. |
|
| 4194 | - */ |
|
| 4195 | - $sep = apply_filters('geodir_page_title_separator', '|');
|
|
| 4196 | - } |
|
| 4197 | - |
|
| 4198 | - |
|
| 4199 | - if(strpos($title,'%%title%%') !== false){
|
|
| 4200 | - $title = str_replace("%%title%%",$post->post_title,$title);
|
|
| 4201 | - } |
|
| 4202 | - |
|
| 4203 | - if(strpos($title,'%%sitename%%') !== false){
|
|
| 4204 | - $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
|
|
| 4205 | - } |
|
| 4206 | - |
|
| 4207 | - if(strpos($title,'%%sitedesc%%') !== false){
|
|
| 4208 | - $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
|
|
| 4209 | - } |
|
| 4210 | - |
|
| 4211 | - if(strpos($title,'%%excerpt%%') !== false){
|
|
| 4212 | - $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
|
|
| 4213 | - } |
|
| 4214 | - |
|
| 4215 | - if(strpos($title,'%%pt_single%%') !== false){
|
|
| 4216 | - $single_name = ''; |
|
| 4217 | - if($gd_page=='search' || $gd_page=='author'){
|
|
| 4218 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 4219 | - $spt = esc_attr($_REQUEST['stype']); |
|
| 4220 | - if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
|
| 4221 | - $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
|
| 4222 | - } |
|
| 4223 | - }elseif($gd_page=='add-listing'){
|
|
| 4224 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 4225 | - $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : ''; |
|
| 4226 | - if(!$spt && isset($_REQUEST['pid'])){
|
|
| 4227 | - $spt = get_post_type( $_REQUEST['pid'] ); |
|
| 4228 | - } |
|
| 4229 | - if(!$spt){$spt='gd_place';}
|
|
| 4230 | - if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
|
| 4231 | - $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
|
| 4232 | - } |
|
| 4233 | - } |
|
| 4234 | - elseif($post->post_type){
|
|
| 4235 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 4236 | - if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
|
|
| 4237 | - $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory'); |
|
| 4238 | - } |
|
| 4239 | - |
|
| 4240 | - |
|
| 4241 | - } |
|
| 4242 | - $title = str_replace("%%pt_single%%",$single_name,$title);
|
|
| 4243 | - } |
|
| 4244 | - |
|
| 4245 | - if(strpos($title,'%%pt_plural%%') !== false){
|
|
| 4246 | - $plural_name = ''; |
|
| 4247 | - if($gd_page=='search' || $gd_page=='author'){
|
|
| 4248 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 4249 | - $spt = esc_attr($_REQUEST['stype']); |
|
| 4250 | - if(isset($geodir_post_types[$spt]['labels']['name'])){
|
|
| 4251 | - $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
|
| 4252 | - } |
|
| 4253 | - }elseif($gd_page=='add-listing'){
|
|
| 4254 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 4255 | - $spt = sanitize_text_field($_REQUEST['listing_type']); |
|
| 4256 | - if(!$spt){$spt='gd_place';}
|
|
| 4257 | - if(isset($geodir_post_types[$spt]['labels']['name'])){
|
|
| 4258 | - $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
|
| 4259 | - } |
|
| 4260 | - } |
|
| 4261 | - elseif(isset($post->post_type) && $post->post_type){
|
|
| 4262 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 4263 | - if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
|
|
| 4264 | - $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory'); |
|
| 4265 | - } |
|
| 4266 | - |
|
| 4267 | - } |
|
| 4268 | - $title = str_replace("%%pt_plural%%",$plural_name,$title);
|
|
| 4269 | - } |
|
| 4270 | - |
|
| 4271 | - |
|
| 4272 | - |
|
| 4273 | - if(strpos($title,'%%category%%') !== false){
|
|
| 4274 | - $cat_name = ''; |
|
| 4275 | - |
|
| 4276 | - if($gd_page=='detail') {
|
|
| 4277 | - if ($post->default_category) {
|
|
| 4278 | - $cat = get_term($post->default_category, $post->post_type . 'category'); |
|
| 4279 | - $cat_name = (isset($cat->name)) ? $cat->name : ''; |
|
| 4280 | - } |
|
| 4281 | - }elseif($gd_page=='listing'){
|
|
| 4282 | - $queried_object = get_queried_object(); |
|
| 4283 | - if(isset($queried_object->name)){
|
|
| 4284 | - $cat_name = $queried_object->name; |
|
| 4285 | - } |
|
| 4286 | - } |
|
| 4287 | - $title = str_replace("%%category%%",$cat_name,$title);
|
|
| 4288 | - } |
|
| 4289 | - |
|
| 4290 | - if(strpos($title,'%%tag%%') !== false){
|
|
| 4291 | - $cat_name = ''; |
|
| 4292 | - |
|
| 4293 | - if($gd_page=='detail') {
|
|
| 4294 | - if ($post->default_category) {
|
|
| 4295 | - $cat = get_term($post->default_category, $post->post_type . 'category'); |
|
| 4296 | - $cat_name = (isset($cat->name)) ? $cat->name : ''; |
|
| 4297 | - } |
|
| 4298 | - }elseif($gd_page=='listing'){
|
|
| 4299 | - $queried_object = get_queried_object(); |
|
| 4300 | - if(isset($queried_object->name)){
|
|
| 4301 | - $cat_name = $queried_object->name; |
|
| 4302 | - } |
|
| 4303 | - } |
|
| 4304 | - $title = str_replace("%%tag%%",$cat_name,$title);
|
|
| 4305 | - } |
|
| 4306 | - |
|
| 4307 | - |
|
| 4308 | - |
|
| 4309 | - if(strpos($title,'%%id%%') !== false){
|
|
| 4310 | - $ID = (isset($post->ID)) ? $post->ID : ''; |
|
| 4311 | - $title = str_replace("%%id%%",$ID,$title);
|
|
| 4312 | - } |
|
| 4313 | - |
|
| 4314 | - if(strpos($title,'%%sep%%') !== false){
|
|
| 4315 | - $title = str_replace("%%sep%%",$sep,$title);
|
|
| 4316 | - } |
|
| 4317 | - |
|
| 4318 | - |
|
| 4319 | - global $wp; |
|
| 4320 | - // location variables |
|
| 4321 | - $gd_post_type = geodir_get_current_posttype(); |
|
| 4322 | - $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 4323 | - /** |
|
| 4324 | - * Filter the title variables location variables array |
|
| 4325 | - * |
|
| 4326 | - * @since 1.5.5 |
|
| 4327 | - * @package GeoDirectory |
|
| 4328 | - * @param array $location_array The array of location variables. |
|
| 4329 | - * @param string $title The title with variables.. |
|
| 4330 | - * @param string $gd_page The page being filtered. |
|
| 4331 | - * @param string $sep The separator, default: `|`. |
|
| 4332 | - */ |
|
| 4333 | - $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
|
|
| 4334 | - $location_titles = array(); |
|
| 4335 | - if($gd_page=='location' && get_query_var( 'gd_country_full' )){
|
|
| 4336 | - if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
|
|
| 4337 | - if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
|
|
| 4338 | - if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
|
|
| 4339 | - } |
|
| 4340 | - $location_single = ''; |
|
| 4341 | - $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
| 4342 | - $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
| 4343 | - $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
| 4344 | - |
|
| 4345 | - $gd_country_actual = $gd_region_actual = $gd_city_actual = ''; |
|
| 4346 | - |
|
| 4347 | - if (function_exists('get_actual_location_name')) {
|
|
| 4348 | - $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
|
|
| 4349 | - $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
|
|
| 4350 | - $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
|
|
| 4351 | - } |
|
| 4352 | - |
|
| 4353 | - if ($gd_city != '') {
|
|
| 4354 | - if ($gd_city_actual != '') {
|
|
| 4355 | - $gd_city = $gd_city_actual; |
|
| 4356 | - } else {
|
|
| 4357 | - $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
|
|
| 4358 | - $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
|
|
| 4359 | - $gd_city = __(geodir_ucwords($gd_city), 'geodirectory'); |
|
| 4360 | - } |
|
| 4361 | - $location_single = $gd_city; |
|
| 4362 | - |
|
| 4363 | - } else if ($gd_region != '') {
|
|
| 4364 | - if ($gd_region_actual != '') {
|
|
| 4365 | - $gd_region = $gd_region_actual; |
|
| 4366 | - } else {
|
|
| 4367 | - $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
|
|
| 4368 | - $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
|
|
| 4369 | - $gd_region = __(geodir_ucwords($gd_region), 'geodirectory'); |
|
| 4370 | - } |
|
| 4371 | - |
|
| 4372 | - $location_single = $gd_region; |
|
| 4373 | - } else if ($gd_country != '') {
|
|
| 4374 | - if ($gd_country_actual != '') {
|
|
| 4375 | - $gd_country = $gd_country_actual; |
|
| 4376 | - } else {
|
|
| 4377 | - $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
|
|
| 4378 | - $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
|
|
| 4379 | - $gd_country = __(geodir_ucwords($gd_country), 'geodirectory'); |
|
| 4380 | - } |
|
| 4381 | - |
|
| 4382 | - $location_single = $gd_country; |
|
| 4383 | - } |
|
| 4384 | - |
|
| 4385 | - if (!empty($location_array)) {
|
|
| 4386 | - |
|
| 4387 | - $actual_location_name = function_exists('get_actual_location_name') ? true : false;
|
|
| 4388 | - $location_array = array_reverse($location_array); |
|
| 4389 | - |
|
| 4390 | - foreach ($location_array as $location_type => $location) {
|
|
| 4391 | - $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
|
|
| 4392 | - $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
|
|
| 4393 | - |
|
| 4394 | - $location_name = geodir_ucwords($gd_location_link_text); |
|
| 4395 | - $location_name = __($location_name, 'geodirectory'); |
|
| 4396 | - |
|
| 4397 | - if ($actual_location_name) {
|
|
| 4398 | - $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type; |
|
| 4399 | - $location_name = get_actual_location_name($location_type, $location, true); |
|
| 4400 | - } |
|
| 4401 | - |
|
| 4402 | - $location_titles[] = $location_name; |
|
| 4403 | - } |
|
| 4404 | - if (!empty($location_titles)) {
|
|
| 4405 | - $location_titles = array_unique($location_titles); |
|
| 4406 | - } |
|
| 4407 | - } |
|
| 4408 | - |
|
| 4409 | - |
|
| 4410 | - if(strpos($title,'%%location%%') !== false){
|
|
| 4411 | - $location = ''; |
|
| 4412 | - if($location_titles) {
|
|
| 4413 | - $location = implode(", ", $location_titles);
|
|
| 4414 | - } |
|
| 4415 | - $title = str_replace("%%location%%",$location,$title);
|
|
| 4416 | - } |
|
| 4417 | - |
|
| 4418 | - if(strpos($title,'%%in_location%%') !== false){
|
|
| 4419 | - $location = ''; |
|
| 4420 | - if($location_titles) {
|
|
| 4421 | - $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
|
|
| 4422 | - } |
|
| 4423 | - $title = str_replace("%%in_location%%",$location,$title);
|
|
| 4424 | - } |
|
| 4425 | - |
|
| 4426 | - if(strpos($title,'%%in_location_single%%') !== false){
|
|
| 4427 | - if($location_single) {
|
|
| 4428 | - $location_single = __('in', 'geodirectory') . ' ' .$location_single;
|
|
| 4429 | - } |
|
| 4430 | - $title = str_replace("%%in_location_single%%",$location_single,$title);
|
|
| 4431 | - } |
|
| 4432 | - |
|
| 4433 | - if(strpos($title,'%%location_single%%') !== false){
|
|
| 4434 | - $title = str_replace("%%location_single%%",$location_single,$title);
|
|
| 4435 | - } |
|
| 4436 | - |
|
| 4437 | - |
|
| 4438 | - if(strpos($title,'%%search_term%%') !== false){
|
|
| 4439 | - $search_term = ''; |
|
| 4440 | - if(isset($_REQUEST['s'])){
|
|
| 4441 | - $search_term = esc_attr($_REQUEST['s']); |
|
| 4442 | - } |
|
| 4443 | - $title = str_replace("%%search_term%%",$search_term,$title);
|
|
| 4444 | - } |
|
| 4445 | - |
|
| 4446 | - if(strpos($title,'%%search_near%%') !== false){
|
|
| 4447 | - $search_term = ''; |
|
| 4448 | - if(isset($_REQUEST['snear'])){
|
|
| 4449 | - $search_term = esc_attr($_REQUEST['snear']); |
|
| 4450 | - } |
|
| 4451 | - $title = str_replace("%%search_near%%",$search_term,$title);
|
|
| 4452 | - } |
|
| 4453 | - |
|
| 4454 | - if(strpos($title,'%%name%%') !== false){
|
|
| 4455 | - $author_name = get_the_author(); |
|
| 4456 | - if (!$author_name || $author_name === '') {
|
|
| 4457 | - $queried_object = get_queried_object(); |
|
| 4187 | + if ($sep == '') {
|
|
| 4188 | + /** |
|
| 4189 | + * Filter the page title separator. |
|
| 4190 | + * |
|
| 4191 | + * @since 1.0.0 |
|
| 4192 | + * @package GeoDirectory |
|
| 4193 | + * @param string $sep The separator, default: `|`. |
|
| 4194 | + */ |
|
| 4195 | + $sep = apply_filters('geodir_page_title_separator', '|');
|
|
| 4196 | + } |
|
| 4197 | + |
|
| 4198 | + |
|
| 4199 | + if(strpos($title,'%%title%%') !== false){
|
|
| 4200 | + $title = str_replace("%%title%%",$post->post_title,$title);
|
|
| 4201 | + } |
|
| 4202 | + |
|
| 4203 | + if(strpos($title,'%%sitename%%') !== false){
|
|
| 4204 | + $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
|
|
| 4205 | + } |
|
| 4206 | + |
|
| 4207 | + if(strpos($title,'%%sitedesc%%') !== false){
|
|
| 4208 | + $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
|
|
| 4209 | + } |
|
| 4210 | + |
|
| 4211 | + if(strpos($title,'%%excerpt%%') !== false){
|
|
| 4212 | + $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
|
|
| 4213 | + } |
|
| 4214 | + |
|
| 4215 | + if(strpos($title,'%%pt_single%%') !== false){
|
|
| 4216 | + $single_name = ''; |
|
| 4217 | + if($gd_page=='search' || $gd_page=='author'){
|
|
| 4218 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 4219 | + $spt = esc_attr($_REQUEST['stype']); |
|
| 4220 | + if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
|
| 4221 | + $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
|
| 4222 | + } |
|
| 4223 | + }elseif($gd_page=='add-listing'){
|
|
| 4224 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 4225 | + $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : ''; |
|
| 4226 | + if(!$spt && isset($_REQUEST['pid'])){
|
|
| 4227 | + $spt = get_post_type( $_REQUEST['pid'] ); |
|
| 4228 | + } |
|
| 4229 | + if(!$spt){$spt='gd_place';}
|
|
| 4230 | + if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
|
| 4231 | + $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
|
| 4232 | + } |
|
| 4233 | + } |
|
| 4234 | + elseif($post->post_type){
|
|
| 4235 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 4236 | + if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
|
|
| 4237 | + $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory'); |
|
| 4238 | + } |
|
| 4239 | + |
|
| 4240 | + |
|
| 4241 | + } |
|
| 4242 | + $title = str_replace("%%pt_single%%",$single_name,$title);
|
|
| 4243 | + } |
|
| 4244 | + |
|
| 4245 | + if(strpos($title,'%%pt_plural%%') !== false){
|
|
| 4246 | + $plural_name = ''; |
|
| 4247 | + if($gd_page=='search' || $gd_page=='author'){
|
|
| 4248 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 4249 | + $spt = esc_attr($_REQUEST['stype']); |
|
| 4250 | + if(isset($geodir_post_types[$spt]['labels']['name'])){
|
|
| 4251 | + $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
|
| 4252 | + } |
|
| 4253 | + }elseif($gd_page=='add-listing'){
|
|
| 4254 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 4255 | + $spt = sanitize_text_field($_REQUEST['listing_type']); |
|
| 4256 | + if(!$spt){$spt='gd_place';}
|
|
| 4257 | + if(isset($geodir_post_types[$spt]['labels']['name'])){
|
|
| 4258 | + $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
|
| 4259 | + } |
|
| 4260 | + } |
|
| 4261 | + elseif(isset($post->post_type) && $post->post_type){
|
|
| 4262 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 4263 | + if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
|
|
| 4264 | + $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory'); |
|
| 4265 | + } |
|
| 4266 | + |
|
| 4267 | + } |
|
| 4268 | + $title = str_replace("%%pt_plural%%",$plural_name,$title);
|
|
| 4269 | + } |
|
| 4270 | + |
|
| 4271 | + |
|
| 4272 | + |
|
| 4273 | + if(strpos($title,'%%category%%') !== false){
|
|
| 4274 | + $cat_name = ''; |
|
| 4275 | + |
|
| 4276 | + if($gd_page=='detail') {
|
|
| 4277 | + if ($post->default_category) {
|
|
| 4278 | + $cat = get_term($post->default_category, $post->post_type . 'category'); |
|
| 4279 | + $cat_name = (isset($cat->name)) ? $cat->name : ''; |
|
| 4280 | + } |
|
| 4281 | + }elseif($gd_page=='listing'){
|
|
| 4282 | + $queried_object = get_queried_object(); |
|
| 4283 | + if(isset($queried_object->name)){
|
|
| 4284 | + $cat_name = $queried_object->name; |
|
| 4285 | + } |
|
| 4286 | + } |
|
| 4287 | + $title = str_replace("%%category%%",$cat_name,$title);
|
|
| 4288 | + } |
|
| 4289 | + |
|
| 4290 | + if(strpos($title,'%%tag%%') !== false){
|
|
| 4291 | + $cat_name = ''; |
|
| 4292 | + |
|
| 4293 | + if($gd_page=='detail') {
|
|
| 4294 | + if ($post->default_category) {
|
|
| 4295 | + $cat = get_term($post->default_category, $post->post_type . 'category'); |
|
| 4296 | + $cat_name = (isset($cat->name)) ? $cat->name : ''; |
|
| 4297 | + } |
|
| 4298 | + }elseif($gd_page=='listing'){
|
|
| 4299 | + $queried_object = get_queried_object(); |
|
| 4300 | + if(isset($queried_object->name)){
|
|
| 4301 | + $cat_name = $queried_object->name; |
|
| 4302 | + } |
|
| 4303 | + } |
|
| 4304 | + $title = str_replace("%%tag%%",$cat_name,$title);
|
|
| 4305 | + } |
|
| 4306 | + |
|
| 4307 | + |
|
| 4308 | + |
|
| 4309 | + if(strpos($title,'%%id%%') !== false){
|
|
| 4310 | + $ID = (isset($post->ID)) ? $post->ID : ''; |
|
| 4311 | + $title = str_replace("%%id%%",$ID,$title);
|
|
| 4312 | + } |
|
| 4313 | + |
|
| 4314 | + if(strpos($title,'%%sep%%') !== false){
|
|
| 4315 | + $title = str_replace("%%sep%%",$sep,$title);
|
|
| 4316 | + } |
|
| 4317 | + |
|
| 4318 | + |
|
| 4319 | + global $wp; |
|
| 4320 | + // location variables |
|
| 4321 | + $gd_post_type = geodir_get_current_posttype(); |
|
| 4322 | + $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 4323 | + /** |
|
| 4324 | + * Filter the title variables location variables array |
|
| 4325 | + * |
|
| 4326 | + * @since 1.5.5 |
|
| 4327 | + * @package GeoDirectory |
|
| 4328 | + * @param array $location_array The array of location variables. |
|
| 4329 | + * @param string $title The title with variables.. |
|
| 4330 | + * @param string $gd_page The page being filtered. |
|
| 4331 | + * @param string $sep The separator, default: `|`. |
|
| 4332 | + */ |
|
| 4333 | + $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
|
|
| 4334 | + $location_titles = array(); |
|
| 4335 | + if($gd_page=='location' && get_query_var( 'gd_country_full' )){
|
|
| 4336 | + if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
|
|
| 4337 | + if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
|
|
| 4338 | + if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
|
|
| 4339 | + } |
|
| 4340 | + $location_single = ''; |
|
| 4341 | + $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
| 4342 | + $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
| 4343 | + $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
| 4344 | + |
|
| 4345 | + $gd_country_actual = $gd_region_actual = $gd_city_actual = ''; |
|
| 4346 | + |
|
| 4347 | + if (function_exists('get_actual_location_name')) {
|
|
| 4348 | + $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
|
|
| 4349 | + $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
|
|
| 4350 | + $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
|
|
| 4351 | + } |
|
| 4352 | + |
|
| 4353 | + if ($gd_city != '') {
|
|
| 4354 | + if ($gd_city_actual != '') {
|
|
| 4355 | + $gd_city = $gd_city_actual; |
|
| 4356 | + } else {
|
|
| 4357 | + $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
|
|
| 4358 | + $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
|
|
| 4359 | + $gd_city = __(geodir_ucwords($gd_city), 'geodirectory'); |
|
| 4360 | + } |
|
| 4361 | + $location_single = $gd_city; |
|
| 4362 | + |
|
| 4363 | + } else if ($gd_region != '') {
|
|
| 4364 | + if ($gd_region_actual != '') {
|
|
| 4365 | + $gd_region = $gd_region_actual; |
|
| 4366 | + } else {
|
|
| 4367 | + $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
|
|
| 4368 | + $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
|
|
| 4369 | + $gd_region = __(geodir_ucwords($gd_region), 'geodirectory'); |
|
| 4370 | + } |
|
| 4371 | + |
|
| 4372 | + $location_single = $gd_region; |
|
| 4373 | + } else if ($gd_country != '') {
|
|
| 4374 | + if ($gd_country_actual != '') {
|
|
| 4375 | + $gd_country = $gd_country_actual; |
|
| 4376 | + } else {
|
|
| 4377 | + $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
|
|
| 4378 | + $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
|
|
| 4379 | + $gd_country = __(geodir_ucwords($gd_country), 'geodirectory'); |
|
| 4380 | + } |
|
| 4381 | + |
|
| 4382 | + $location_single = $gd_country; |
|
| 4383 | + } |
|
| 4384 | + |
|
| 4385 | + if (!empty($location_array)) {
|
|
| 4386 | + |
|
| 4387 | + $actual_location_name = function_exists('get_actual_location_name') ? true : false;
|
|
| 4388 | + $location_array = array_reverse($location_array); |
|
| 4389 | + |
|
| 4390 | + foreach ($location_array as $location_type => $location) {
|
|
| 4391 | + $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
|
|
| 4392 | + $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
|
|
| 4393 | + |
|
| 4394 | + $location_name = geodir_ucwords($gd_location_link_text); |
|
| 4395 | + $location_name = __($location_name, 'geodirectory'); |
|
| 4396 | + |
|
| 4397 | + if ($actual_location_name) {
|
|
| 4398 | + $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type; |
|
| 4399 | + $location_name = get_actual_location_name($location_type, $location, true); |
|
| 4400 | + } |
|
| 4401 | + |
|
| 4402 | + $location_titles[] = $location_name; |
|
| 4403 | + } |
|
| 4404 | + if (!empty($location_titles)) {
|
|
| 4405 | + $location_titles = array_unique($location_titles); |
|
| 4406 | + } |
|
| 4407 | + } |
|
| 4408 | + |
|
| 4409 | + |
|
| 4410 | + if(strpos($title,'%%location%%') !== false){
|
|
| 4411 | + $location = ''; |
|
| 4412 | + if($location_titles) {
|
|
| 4413 | + $location = implode(", ", $location_titles);
|
|
| 4414 | + } |
|
| 4415 | + $title = str_replace("%%location%%",$location,$title);
|
|
| 4416 | + } |
|
| 4417 | + |
|
| 4418 | + if(strpos($title,'%%in_location%%') !== false){
|
|
| 4419 | + $location = ''; |
|
| 4420 | + if($location_titles) {
|
|
| 4421 | + $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
|
|
| 4422 | + } |
|
| 4423 | + $title = str_replace("%%in_location%%",$location,$title);
|
|
| 4424 | + } |
|
| 4425 | + |
|
| 4426 | + if(strpos($title,'%%in_location_single%%') !== false){
|
|
| 4427 | + if($location_single) {
|
|
| 4428 | + $location_single = __('in', 'geodirectory') . ' ' .$location_single;
|
|
| 4429 | + } |
|
| 4430 | + $title = str_replace("%%in_location_single%%",$location_single,$title);
|
|
| 4431 | + } |
|
| 4432 | + |
|
| 4433 | + if(strpos($title,'%%location_single%%') !== false){
|
|
| 4434 | + $title = str_replace("%%location_single%%",$location_single,$title);
|
|
| 4435 | + } |
|
| 4436 | + |
|
| 4437 | + |
|
| 4438 | + if(strpos($title,'%%search_term%%') !== false){
|
|
| 4439 | + $search_term = ''; |
|
| 4440 | + if(isset($_REQUEST['s'])){
|
|
| 4441 | + $search_term = esc_attr($_REQUEST['s']); |
|
| 4442 | + } |
|
| 4443 | + $title = str_replace("%%search_term%%",$search_term,$title);
|
|
| 4444 | + } |
|
| 4445 | + |
|
| 4446 | + if(strpos($title,'%%search_near%%') !== false){
|
|
| 4447 | + $search_term = ''; |
|
| 4448 | + if(isset($_REQUEST['snear'])){
|
|
| 4449 | + $search_term = esc_attr($_REQUEST['snear']); |
|
| 4450 | + } |
|
| 4451 | + $title = str_replace("%%search_near%%",$search_term,$title);
|
|
| 4452 | + } |
|
| 4453 | + |
|
| 4454 | + if(strpos($title,'%%name%%') !== false){
|
|
| 4455 | + $author_name = get_the_author(); |
|
| 4456 | + if (!$author_name || $author_name === '') {
|
|
| 4457 | + $queried_object = get_queried_object(); |
|
| 4458 | 4458 | |
| 4459 | - if (isset($queried_object->data->user_nicename)) {
|
|
| 4460 | - $author_name = $queried_object->data->user_nicename; |
|
| 4461 | - } |
|
| 4462 | - } |
|
| 4463 | - $title = str_replace("%%name%%", $author_name, $title);
|
|
| 4464 | - } |
|
| 4459 | + if (isset($queried_object->data->user_nicename)) {
|
|
| 4460 | + $author_name = $queried_object->data->user_nicename; |
|
| 4461 | + } |
|
| 4462 | + } |
|
| 4463 | + $title = str_replace("%%name%%", $author_name, $title);
|
|
| 4464 | + } |
|
| 4465 | 4465 | |
| 4466 | - if (strpos($title, '%%page%%') !== false) {
|
|
| 4467 | - $page = geodir_title_meta_page($sep); |
|
| 4468 | - $title = str_replace("%%page%%", $page, $title);
|
|
| 4469 | - } |
|
| 4470 | - if (strpos($title, '%%pagenumber%%') !== false) {
|
|
| 4471 | - $pagenumber = geodir_title_meta_pagenumber(); |
|
| 4472 | - $title = str_replace("%%pagenumber%%", $pagenumber, $title);
|
|
| 4473 | - } |
|
| 4474 | - if (strpos($title, '%%pagetotal%%') !== false) {
|
|
| 4475 | - $pagetotal = geodir_title_meta_pagetotal(); |
|
| 4476 | - $title = str_replace("%%pagetotal%%", $pagetotal, $title);
|
|
| 4477 | - } |
|
| 4478 | - |
|
| 4479 | - $title = wptexturize( $title ); |
|
| 4480 | - $title = convert_chars( $title ); |
|
| 4481 | - $title = esc_html( $title ); |
|
| 4482 | - |
|
| 4483 | - /** |
|
| 4484 | - * Filter the title variables after standard ones have been filtered. |
|
| 4485 | - * |
|
| 4486 | - * @since 1.5.7 |
|
| 4487 | - * @package GeoDirectory |
|
| 4488 | - * @param string $title The title with variables. |
|
| 4489 | - * @param array $location_array The array of location variables. |
|
| 4490 | - * @param string $gd_page The page being filtered. |
|
| 4491 | - * @param string $sep The separator, default: `|`. |
|
| 4492 | - */ |
|
| 4466 | + if (strpos($title, '%%page%%') !== false) {
|
|
| 4467 | + $page = geodir_title_meta_page($sep); |
|
| 4468 | + $title = str_replace("%%page%%", $page, $title);
|
|
| 4469 | + } |
|
| 4470 | + if (strpos($title, '%%pagenumber%%') !== false) {
|
|
| 4471 | + $pagenumber = geodir_title_meta_pagenumber(); |
|
| 4472 | + $title = str_replace("%%pagenumber%%", $pagenumber, $title);
|
|
| 4473 | + } |
|
| 4474 | + if (strpos($title, '%%pagetotal%%') !== false) {
|
|
| 4475 | + $pagetotal = geodir_title_meta_pagetotal(); |
|
| 4476 | + $title = str_replace("%%pagetotal%%", $pagetotal, $title);
|
|
| 4477 | + } |
|
| 4493 | 4478 | |
| 4494 | - return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
|
|
| 4479 | + $title = wptexturize( $title ); |
|
| 4480 | + $title = convert_chars( $title ); |
|
| 4481 | + $title = esc_html( $title ); |
|
| 4482 | + |
|
| 4483 | + /** |
|
| 4484 | + * Filter the title variables after standard ones have been filtered. |
|
| 4485 | + * |
|
| 4486 | + * @since 1.5.7 |
|
| 4487 | + * @package GeoDirectory |
|
| 4488 | + * @param string $title The title with variables. |
|
| 4489 | + * @param array $location_array The array of location variables. |
|
| 4490 | + * @param string $gd_page The page being filtered. |
|
| 4491 | + * @param string $sep The separator, default: `|`. |
|
| 4492 | + */ |
|
| 4493 | + |
|
| 4494 | + return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
|
|
| 4495 | 4495 | } |
| 4496 | 4496 | |
| 4497 | 4497 | /** |
@@ -4504,65 +4504,65 @@ discard block |
||
| 4504 | 4504 | * @return array Translation texts. |
| 4505 | 4505 | */ |
| 4506 | 4506 | function geodir_load_cpt_text_translation($translation_texts = array()) {
|
| 4507 | - $gd_post_types = geodir_get_posttypes('array');
|
|
| 4508 | - |
|
| 4509 | - if (!empty($gd_post_types)) {
|
|
| 4510 | - foreach ($gd_post_types as $post_type => $cpt_info) {
|
|
| 4511 | - $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : ''; |
|
| 4512 | - $description = isset($cpt_info['description']) ? $cpt_info['description'] : ''; |
|
| 4513 | - $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : ''; |
|
| 4514 | - |
|
| 4515 | - if (!empty($labels)) {
|
|
| 4516 | - if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) |
|
| 4517 | - $translation_texts[] = $labels['name']; |
|
| 4518 | - if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) |
|
| 4519 | - $translation_texts[] = $labels['singular_name']; |
|
| 4520 | - if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) |
|
| 4521 | - $translation_texts[] = $labels['add_new']; |
|
| 4522 | - if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) |
|
| 4523 | - $translation_texts[] = $labels['add_new_item']; |
|
| 4524 | - if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) |
|
| 4525 | - $translation_texts[] = $labels['edit_item']; |
|
| 4526 | - if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) |
|
| 4527 | - $translation_texts[] = $labels['new_item']; |
|
| 4528 | - if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) |
|
| 4529 | - $translation_texts[] = $labels['view_item']; |
|
| 4530 | - if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) |
|
| 4531 | - $translation_texts[] = $labels['search_items']; |
|
| 4532 | - if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) |
|
| 4533 | - $translation_texts[] = $labels['not_found']; |
|
| 4534 | - if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) |
|
| 4535 | - $translation_texts[] = $labels['not_found_in_trash']; |
|
| 4536 | - if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) |
|
| 4537 | - $translation_texts[] = $labels['label_post_profile']; |
|
| 4538 | - if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) |
|
| 4539 | - $translation_texts[] = $labels['label_post_info']; |
|
| 4540 | - if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) |
|
| 4541 | - $translation_texts[] = $labels['label_post_images']; |
|
| 4542 | - if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) |
|
| 4543 | - $translation_texts[] = $labels['label_post_map']; |
|
| 4544 | - if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) |
|
| 4545 | - $translation_texts[] = $labels['label_reviews']; |
|
| 4546 | - if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) |
|
| 4547 | - $translation_texts[] = $labels['label_related_listing']; |
|
| 4548 | - } |
|
| 4549 | - |
|
| 4550 | - if ($description != '' && !in_array($description, $translation_texts)) {
|
|
| 4551 | - $translation_texts[] = normalize_whitespace($description); |
|
| 4552 | - } |
|
| 4553 | - |
|
| 4554 | - if (!empty($seo)) {
|
|
| 4555 | - if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) |
|
| 4556 | - $translation_texts[] = normalize_whitespace($seo['meta_keyword']); |
|
| 4557 | - |
|
| 4558 | - if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) |
|
| 4559 | - $translation_texts[] = normalize_whitespace($seo['meta_description']); |
|
| 4560 | - } |
|
| 4561 | - } |
|
| 4562 | - } |
|
| 4563 | - $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
| 4564 | - |
|
| 4565 | - return $translation_texts; |
|
| 4507 | + $gd_post_types = geodir_get_posttypes('array');
|
|
| 4508 | + |
|
| 4509 | + if (!empty($gd_post_types)) {
|
|
| 4510 | + foreach ($gd_post_types as $post_type => $cpt_info) {
|
|
| 4511 | + $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : ''; |
|
| 4512 | + $description = isset($cpt_info['description']) ? $cpt_info['description'] : ''; |
|
| 4513 | + $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : ''; |
|
| 4514 | + |
|
| 4515 | + if (!empty($labels)) {
|
|
| 4516 | + if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) |
|
| 4517 | + $translation_texts[] = $labels['name']; |
|
| 4518 | + if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) |
|
| 4519 | + $translation_texts[] = $labels['singular_name']; |
|
| 4520 | + if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) |
|
| 4521 | + $translation_texts[] = $labels['add_new']; |
|
| 4522 | + if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) |
|
| 4523 | + $translation_texts[] = $labels['add_new_item']; |
|
| 4524 | + if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) |
|
| 4525 | + $translation_texts[] = $labels['edit_item']; |
|
| 4526 | + if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) |
|
| 4527 | + $translation_texts[] = $labels['new_item']; |
|
| 4528 | + if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) |
|
| 4529 | + $translation_texts[] = $labels['view_item']; |
|
| 4530 | + if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) |
|
| 4531 | + $translation_texts[] = $labels['search_items']; |
|
| 4532 | + if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) |
|
| 4533 | + $translation_texts[] = $labels['not_found']; |
|
| 4534 | + if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) |
|
| 4535 | + $translation_texts[] = $labels['not_found_in_trash']; |
|
| 4536 | + if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) |
|
| 4537 | + $translation_texts[] = $labels['label_post_profile']; |
|
| 4538 | + if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) |
|
| 4539 | + $translation_texts[] = $labels['label_post_info']; |
|
| 4540 | + if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) |
|
| 4541 | + $translation_texts[] = $labels['label_post_images']; |
|
| 4542 | + if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) |
|
| 4543 | + $translation_texts[] = $labels['label_post_map']; |
|
| 4544 | + if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) |
|
| 4545 | + $translation_texts[] = $labels['label_reviews']; |
|
| 4546 | + if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) |
|
| 4547 | + $translation_texts[] = $labels['label_related_listing']; |
|
| 4548 | + } |
|
| 4549 | + |
|
| 4550 | + if ($description != '' && !in_array($description, $translation_texts)) {
|
|
| 4551 | + $translation_texts[] = normalize_whitespace($description); |
|
| 4552 | + } |
|
| 4553 | + |
|
| 4554 | + if (!empty($seo)) {
|
|
| 4555 | + if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) |
|
| 4556 | + $translation_texts[] = normalize_whitespace($seo['meta_keyword']); |
|
| 4557 | + |
|
| 4558 | + if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) |
|
| 4559 | + $translation_texts[] = normalize_whitespace($seo['meta_description']); |
|
| 4560 | + } |
|
| 4561 | + } |
|
| 4562 | + } |
|
| 4563 | + $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
| 4564 | + |
|
| 4565 | + return $translation_texts; |
|
| 4566 | 4566 | } |
| 4567 | 4567 | |
| 4568 | 4568 | /** |
@@ -4575,27 +4575,27 @@ discard block |
||
| 4575 | 4575 | * @return array Location terms. |
| 4576 | 4576 | */ |
| 4577 | 4577 | function geodir_remove_location_terms($location_terms = array()) {
|
| 4578 | - $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 4579 | - |
|
| 4580 | - if (!empty($location_terms) && $location_manager) {
|
|
| 4581 | - $hide_country_part = get_option('geodir_location_hide_country_part');
|
|
| 4582 | - $hide_region_part = get_option('geodir_location_hide_region_part');
|
|
| 4583 | - |
|
| 4584 | - if ($hide_region_part && $hide_country_part) {
|
|
| 4585 | - if (isset($location_terms['gd_country'])) |
|
| 4586 | - unset($location_terms['gd_country']); |
|
| 4587 | - if (isset($location_terms['gd_region'])) |
|
| 4588 | - unset($location_terms['gd_region']); |
|
| 4589 | - } else if ($hide_region_part && !$hide_country_part) {
|
|
| 4590 | - if (isset($location_terms['gd_region'])) |
|
| 4591 | - unset($location_terms['gd_region']); |
|
| 4592 | - } else if (!$hide_region_part && $hide_country_part) {
|
|
| 4593 | - if (isset($location_terms['gd_country'])) |
|
| 4594 | - unset($location_terms['gd_country']); |
|
| 4595 | - } |
|
| 4596 | - } |
|
| 4597 | - |
|
| 4598 | - return $location_terms; |
|
| 4578 | + $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 4579 | + |
|
| 4580 | + if (!empty($location_terms) && $location_manager) {
|
|
| 4581 | + $hide_country_part = get_option('geodir_location_hide_country_part');
|
|
| 4582 | + $hide_region_part = get_option('geodir_location_hide_region_part');
|
|
| 4583 | + |
|
| 4584 | + if ($hide_region_part && $hide_country_part) {
|
|
| 4585 | + if (isset($location_terms['gd_country'])) |
|
| 4586 | + unset($location_terms['gd_country']); |
|
| 4587 | + if (isset($location_terms['gd_region'])) |
|
| 4588 | + unset($location_terms['gd_region']); |
|
| 4589 | + } else if ($hide_region_part && !$hide_country_part) {
|
|
| 4590 | + if (isset($location_terms['gd_region'])) |
|
| 4591 | + unset($location_terms['gd_region']); |
|
| 4592 | + } else if (!$hide_region_part && $hide_country_part) {
|
|
| 4593 | + if (isset($location_terms['gd_country'])) |
|
| 4594 | + unset($location_terms['gd_country']); |
|
| 4595 | + } |
|
| 4596 | + } |
|
| 4597 | + |
|
| 4598 | + return $location_terms; |
|
| 4599 | 4599 | } |
| 4600 | 4600 | |
| 4601 | 4601 | /** |
@@ -4609,47 +4609,47 @@ discard block |
||
| 4609 | 4609 | * @param bool $update Whether this is an existing listing being updated or not. |
| 4610 | 4610 | */ |
| 4611 | 4611 | function geodir_on_wp_insert_post($post_ID, $post, $update) {
|
| 4612 | - if (!$update) {
|
|
| 4613 | - return; |
|
| 4614 | - } |
|
| 4612 | + if (!$update) {
|
|
| 4613 | + return; |
|
| 4614 | + } |
|
| 4615 | 4615 | |
| 4616 | - $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
|
| 4617 | - $is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) ) ? true : false;
|
|
| 4618 | - $inline_save = $action == 'inline-save' ? true : false; |
|
| 4616 | + $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
|
| 4617 | + $is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) ) ? true : false;
|
|
| 4618 | + $inline_save = $action == 'inline-save' ? true : false; |
|
| 4619 | 4619 | |
| 4620 | - if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
|
|
| 4621 | - return; |
|
| 4622 | - } |
|
| 4620 | + if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
|
|
| 4621 | + return; |
|
| 4622 | + } |
|
| 4623 | 4623 | |
| 4624 | - if ($action != '' && in_array($action, array('geodir_import_export'))) {
|
|
| 4625 | - return; |
|
| 4626 | - } |
|
| 4624 | + if ($action != '' && in_array($action, array('geodir_import_export'))) {
|
|
| 4625 | + return; |
|
| 4626 | + } |
|
| 4627 | 4627 | |
| 4628 | - $user_id = (int)get_current_user_id(); |
|
| 4628 | + $user_id = (int)get_current_user_id(); |
|
| 4629 | 4629 | |
| 4630 | - if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
|
|
| 4631 | - $author_id = !empty($post->post_author) ? $post->post_author : 0; |
|
| 4630 | + if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
|
|
| 4631 | + $author_id = !empty($post->post_author) ? $post->post_author : 0; |
|
| 4632 | 4632 | |
| 4633 | - if ($user_id == $author_id && !is_super_admin()) {
|
|
| 4634 | - $from_email = get_option('site_email');
|
|
| 4635 | - $from_name = get_site_emailName(); |
|
| 4636 | - $to_email = get_option('admin_email');
|
|
| 4637 | - $to_name = get_option('name');
|
|
| 4638 | - $message_type = 'listing_edited'; |
|
| 4633 | + if ($user_id == $author_id && !is_super_admin()) {
|
|
| 4634 | + $from_email = get_option('site_email');
|
|
| 4635 | + $from_name = get_site_emailName(); |
|
| 4636 | + $to_email = get_option('admin_email');
|
|
| 4637 | + $to_name = get_option('name');
|
|
| 4638 | + $message_type = 'listing_edited'; |
|
| 4639 | 4639 | |
| 4640 | - $notify_edited = true; |
|
| 4641 | - /** |
|
| 4642 | - * Send notification when listing edited by author? |
|
| 4643 | - * |
|
| 4644 | - * @since 1.6.0 |
|
| 4645 | - * @param bool $notify_edited Notify on listing edited by author? |
|
| 4646 | - * @param object $post The current post object. |
|
| 4647 | - */ |
|
| 4648 | - $notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post);
|
|
| 4640 | + $notify_edited = true; |
|
| 4641 | + /** |
|
| 4642 | + * Send notification when listing edited by author? |
|
| 4643 | + * |
|
| 4644 | + * @since 1.6.0 |
|
| 4645 | + * @param bool $notify_edited Notify on listing edited by author? |
|
| 4646 | + * @param object $post The current post object. |
|
| 4647 | + */ |
|
| 4648 | + $notify_edited = apply_filters('geodir_notify_on_listing_edited', $notify_edited, $post);
|
|
| 4649 | 4649 | |
| 4650 | - geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID); |
|
| 4651 | - } |
|
| 4652 | - } |
|
| 4650 | + geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID); |
|
| 4651 | + } |
|
| 4652 | + } |
|
| 4653 | 4653 | } |
| 4654 | 4654 | |
| 4655 | 4655 | /** |
@@ -4663,16 +4663,16 @@ discard block |
||
| 4663 | 4663 | * @return string|null The current page start & end numbering. |
| 4664 | 4664 | */ |
| 4665 | 4665 | function geodir_title_meta_page($sep) {
|
| 4666 | - $replacement = null; |
|
| 4666 | + $replacement = null; |
|
| 4667 | 4667 | |
| 4668 | - $max = geodir_title_meta_pagenumbering('max');
|
|
| 4669 | - $nr = geodir_title_meta_pagenumbering('nr');
|
|
| 4668 | + $max = geodir_title_meta_pagenumbering('max');
|
|
| 4669 | + $nr = geodir_title_meta_pagenumbering('nr');
|
|
| 4670 | 4670 | |
| 4671 | - if ($max > 1 && $nr > 1) {
|
|
| 4672 | - $replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
|
|
| 4673 | - } |
|
| 4671 | + if ($max > 1 && $nr > 1) {
|
|
| 4672 | + $replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
|
|
| 4673 | + } |
|
| 4674 | 4674 | |
| 4675 | - return $replacement; |
|
| 4675 | + return $replacement; |
|
| 4676 | 4676 | } |
| 4677 | 4677 | |
| 4678 | 4678 | /** |
@@ -4684,14 +4684,14 @@ discard block |
||
| 4684 | 4684 | * @return string|null The current page number. |
| 4685 | 4685 | */ |
| 4686 | 4686 | function geodir_title_meta_pagenumber() {
|
| 4687 | - $replacement = null; |
|
| 4687 | + $replacement = null; |
|
| 4688 | 4688 | |
| 4689 | - $nr = geodir_title_meta_pagenumbering('nr');
|
|
| 4690 | - if (isset($nr) && $nr > 0) {
|
|
| 4691 | - $replacement = (string)$nr; |
|
| 4692 | - } |
|
| 4689 | + $nr = geodir_title_meta_pagenumbering('nr');
|
|
| 4690 | + if (isset($nr) && $nr > 0) {
|
|
| 4691 | + $replacement = (string)$nr; |
|
| 4692 | + } |
|
| 4693 | 4693 | |
| 4694 | - return $replacement; |
|
| 4694 | + return $replacement; |
|
| 4695 | 4695 | } |
| 4696 | 4696 | |
| 4697 | 4697 | /** |
@@ -4703,14 +4703,14 @@ discard block |
||
| 4703 | 4703 | * @return string|null The current page total. |
| 4704 | 4704 | */ |
| 4705 | 4705 | function geodir_title_meta_pagetotal() {
|
| 4706 | - $replacement = null; |
|
| 4706 | + $replacement = null; |
|
| 4707 | 4707 | |
| 4708 | - $max = geodir_title_meta_pagenumbering('max');
|
|
| 4709 | - if (isset($max) && $max > 0) {
|
|
| 4710 | - $replacement = (string)$max; |
|
| 4711 | - } |
|
| 4708 | + $max = geodir_title_meta_pagenumbering('max');
|
|
| 4709 | + if (isset($max) && $max > 0) {
|
|
| 4710 | + $replacement = (string)$max; |
|
| 4711 | + } |
|
| 4712 | 4712 | |
| 4713 | - return $replacement; |
|
| 4713 | + return $replacement; |
|
| 4714 | 4714 | } |
| 4715 | 4715 | |
| 4716 | 4716 | /** |
@@ -4727,44 +4727,44 @@ discard block |
||
| 4727 | 4727 | * @return int|null The current page numbering. |
| 4728 | 4728 | */ |
| 4729 | 4729 | function geodir_title_meta_pagenumbering($request = 'nr') {
|
| 4730 | - global $wp_query, $post; |
|
| 4731 | - $max_num_pages = null; |
|
| 4732 | - $page_number = null; |
|
| 4733 | - |
|
| 4734 | - $max_num_pages = 1; |
|
| 4735 | - |
|
| 4736 | - if (!is_singular()) {
|
|
| 4737 | - $page_number = get_query_var('paged');
|
|
| 4738 | - if ($page_number === 0 || $page_number === '') {
|
|
| 4739 | - $page_number = 1; |
|
| 4740 | - } |
|
| 4741 | - |
|
| 4742 | - if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
|
|
| 4743 | - $max_num_pages = $wp_query->max_num_pages; |
|
| 4744 | - } |
|
| 4745 | - } else {
|
|
| 4746 | - $page_number = get_query_var('page');
|
|
| 4747 | - if ($page_number === 0 || $page_number === '') {
|
|
| 4748 | - $page_number = 1; |
|
| 4749 | - } |
|
| 4750 | - |
|
| 4751 | - if (isset($post->post_content)) {
|
|
| 4752 | - $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1); |
|
| 4753 | - } |
|
| 4754 | - } |
|
| 4755 | - |
|
| 4756 | - $return = null; |
|
| 4757 | - |
|
| 4758 | - switch ($request) {
|
|
| 4759 | - case 'nr': |
|
| 4760 | - $return = $page_number; |
|
| 4761 | - break; |
|
| 4762 | - case 'max': |
|
| 4763 | - $return = $max_num_pages; |
|
| 4764 | - break; |
|
| 4765 | - } |
|
| 4766 | - |
|
| 4767 | - return $return; |
|
| 4730 | + global $wp_query, $post; |
|
| 4731 | + $max_num_pages = null; |
|
| 4732 | + $page_number = null; |
|
| 4733 | + |
|
| 4734 | + $max_num_pages = 1; |
|
| 4735 | + |
|
| 4736 | + if (!is_singular()) {
|
|
| 4737 | + $page_number = get_query_var('paged');
|
|
| 4738 | + if ($page_number === 0 || $page_number === '') {
|
|
| 4739 | + $page_number = 1; |
|
| 4740 | + } |
|
| 4741 | + |
|
| 4742 | + if (isset($wp_query->max_num_pages) && ($wp_query->max_num_pages != '' && $wp_query->max_num_pages != 0)) {
|
|
| 4743 | + $max_num_pages = $wp_query->max_num_pages; |
|
| 4744 | + } |
|
| 4745 | + } else {
|
|
| 4746 | + $page_number = get_query_var('page');
|
|
| 4747 | + if ($page_number === 0 || $page_number === '') {
|
|
| 4748 | + $page_number = 1; |
|
| 4749 | + } |
|
| 4750 | + |
|
| 4751 | + if (isset($post->post_content)) {
|
|
| 4752 | + $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1); |
|
| 4753 | + } |
|
| 4754 | + } |
|
| 4755 | + |
|
| 4756 | + $return = null; |
|
| 4757 | + |
|
| 4758 | + switch ($request) {
|
|
| 4759 | + case 'nr': |
|
| 4760 | + $return = $page_number; |
|
| 4761 | + break; |
|
| 4762 | + case 'max': |
|
| 4763 | + $return = $max_num_pages; |
|
| 4764 | + break; |
|
| 4765 | + } |
|
| 4766 | + |
|
| 4767 | + return $return; |
|
| 4768 | 4768 | } |
| 4769 | 4769 | |
| 4770 | 4770 | /** |
@@ -4776,15 +4776,15 @@ discard block |
||
| 4776 | 4776 | * @return array Terms. |
| 4777 | 4777 | */ |
| 4778 | 4778 | function geodir_filter_empty_terms($terms) {
|
| 4779 | - if (empty($terms)) {
|
|
| 4780 | - return $terms; |
|
| 4781 | - } |
|
| 4782 | - |
|
| 4783 | - $return = array(); |
|
| 4784 | - foreach ($terms as $term) {
|
|
| 4785 | - if (isset($term->count) && $term->count > 0) {
|
|
| 4786 | - $return[] = $term; |
|
| 4787 | - } |
|
| 4788 | - } |
|
| 4789 | - return $return; |
|
| 4779 | + if (empty($terms)) {
|
|
| 4780 | + return $terms; |
|
| 4781 | + } |
|
| 4782 | + |
|
| 4783 | + $return = array(); |
|
| 4784 | + foreach ($terms as $term) {
|
|
| 4785 | + if (isset($term->count) && $term->count > 0) {
|
|
| 4786 | + $return[] = $term; |
|
| 4787 | + } |
|
| 4788 | + } |
|
| 4789 | + return $return; |
|
| 4790 | 4790 | } |
| 4791 | 4791 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | /** |
| 11 | 11 | * Get All Plugin functions from WordPress |
| 12 | 12 | */ |
| 13 | -include_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 13 | +include_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
| 14 | 14 | |
| 15 | 15 | /*-----------------------------------------------------------------------------------*/ |
| 16 | 16 | /* Helper functions */ |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | {
|
| 30 | 30 | |
| 31 | 31 | if (is_ssl()) : |
| 32 | - return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename(dirname(dirname(__FILE__)));
|
|
| 32 | + return str_replace('http://', 'https://', WP_PLUGIN_URL)."/".plugin_basename(dirname(dirname(__FILE__)));
|
|
| 33 | 33 | else : |
| 34 | - return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__))); |
|
| 34 | + return WP_PLUGIN_URL."/".plugin_basename(dirname(dirname(__FILE__))); |
|
| 35 | 35 | endif; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | function geodir_plugin_path() |
| 49 | 49 | {
|
| 50 | - if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
|
|
| 50 | + if (defined('GD_TESTING_MODE') && GD_TESTING_MODE) {
|
|
| 51 | 51 | return dirname(dirname(__FILE__)); |
| 52 | 52 | } else {
|
| 53 | - return WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__))); |
|
| 53 | + return WP_PLUGIN_DIR."/".plugin_basename(dirname(dirname(__FILE__))); |
|
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | |
@@ -129,10 +129,10 @@ discard block |
||
| 129 | 129 | foreach ($params as $key => $value) {
|
| 130 | 130 | if (gettype($value) == 'array') { //Handle array data properly
|
| 131 | 131 | foreach ($value as $val) {
|
| 132 | - $params_arr[] = $key . '[]=' . urlencode($val); |
|
| 132 | + $params_arr[] = $key.'[]='.urlencode($val); |
|
| 133 | 133 | } |
| 134 | 134 | } else {
|
| 135 | - $params_arr[] = $key . '=' . urlencode($value); |
|
| 135 | + $params_arr[] = $key.'='.urlencode($value); |
|
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | $link .= implode('&', $params_arr);
|
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | $add_listing_link = get_page_link(geodir_add_listing_page_id()); |
| 162 | 162 | |
| 163 | - return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
|
|
| 163 | + return esc_url(add_query_arg(array('listing_type' => $post_type), $add_listing_link));
|
|
| 164 | 164 | } else |
| 165 | 165 | return get_bloginfo('url');
|
| 166 | 166 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | $pageURL .= "s"; |
| 181 | 181 | } |
| 182 | 182 | $pageURL .= "://"; |
| 183 | - $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; |
|
| 183 | + $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; |
|
| 184 | 184 | /** |
| 185 | 185 | * Filter the current page URL returned by function geodir_curPageURL(). |
| 186 | 186 | * |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | function geodir_is_page($gdpage = '') |
| 253 | 253 | {
|
| 254 | 254 | |
| 255 | - global $wp_query, $post,$wp; |
|
| 255 | + global $wp_query, $post, $wp; |
|
| 256 | 256 | //if(!is_admin()): |
| 257 | 257 | |
| 258 | 258 | switch ($gdpage): |
@@ -277,14 +277,14 @@ discard block |
||
| 277 | 277 | break; |
| 278 | 278 | case 'detail': |
| 279 | 279 | $post_type = get_query_var('post_type');
|
| 280 | - if(is_array($post_type)){$post_type = reset($post_type);}
|
|
| 280 | + if (is_array($post_type)) {$post_type = reset($post_type); }
|
|
| 281 | 281 | if (is_single() && in_array($post_type, geodir_get_posttypes())) |
| 282 | 282 | return true; |
| 283 | 283 | break; |
| 284 | 284 | case 'pt': |
| 285 | 285 | $post_type = get_query_var('post_type');
|
| 286 | - if(is_array($post_type)){$post_type = reset($post_type);}
|
|
| 287 | - if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax()) |
|
| 286 | + if (is_array($post_type)) {$post_type = reset($post_type); }
|
|
| 287 | + if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes()) && !is_tax()) |
|
| 288 | 288 | return true; |
| 289 | 289 | |
| 290 | 290 | break; |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | return true; |
| 296 | 296 | } |
| 297 | 297 | $post_type = get_query_var('post_type');
|
| 298 | - if(is_array($post_type)){$post_type = reset($post_type);}
|
|
| 298 | + if (is_array($post_type)) {$post_type = reset($post_type); }
|
|
| 299 | 299 | if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes())) |
| 300 | 300 | return true; |
| 301 | 301 | |
@@ -314,8 +314,8 @@ discard block |
||
| 314 | 314 | if (is_author() && isset($_REQUEST['geodir_dashbord'])) |
| 315 | 315 | return true; |
| 316 | 316 | |
| 317 | - if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
|
|
| 318 | - if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
|
|
| 317 | + if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int) bp_loggedin_user_id()) {
|
|
| 318 | + if (((bool) bp_is_current_component('listings') || (bool) bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int) bp_displayed_user_id()) {
|
|
| 319 | 319 | return true; |
| 320 | 320 | } |
| 321 | 321 | } |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
|
| 369 | 369 | if (get_option('geodir_set_as_home'))
|
| 370 | 370 | $wp->query_vars['gd_is_geodir_page'] = true; |
| 371 | - if(geodir_is_page('home')){
|
|
| 371 | + if (geodir_is_page('home')) {
|
|
| 372 | 372 | $wp->query_vars['gd_is_geodir_page'] = true; |
| 373 | 373 | } |
| 374 | 374 | |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | if (!isset($wp->query_vars['gd_is_geodir_page'])) {
|
| 422 | 422 | $geodir_taxonomis = geodir_get_taxonomies('', true);
|
| 423 | - if(!empty($geodir_taxonomis)){
|
|
| 423 | + if (!empty($geodir_taxonomis)) {
|
|
| 424 | 424 | foreach ($geodir_taxonomis as $taxonomy) {
|
| 425 | 425 | if (array_key_exists($taxonomy, $wp->query_vars)) {
|
| 426 | 426 | $wp->query_vars['gd_is_geodir_page'] = true; |
@@ -440,10 +440,10 @@ discard block |
||
| 440 | 440 | |
| 441 | 441 | |
| 442 | 442 | //check if homepage |
| 443 | - if(!isset($wp->query_vars['gd_is_geodir_page']) |
|
| 443 | + if (!isset($wp->query_vars['gd_is_geodir_page']) |
|
| 444 | 444 | && !isset($wp->query_vars['page_id']) |
| 445 | 445 | && !isset($wp->query_vars['pagename']) |
| 446 | - && is_page_geodir_home()){
|
|
| 446 | + && is_page_geodir_home()) {
|
|
| 447 | 447 | $wp->query_vars['gd_is_geodir_page'] = true; |
| 448 | 448 | } |
| 449 | 449 | //echo $wp->query_vars['gd_is_geodir_page'] ; |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | * @since 1.0.0 |
| 506 | 506 | * @param array $imagesizes[$size] Image size array of the passed key. |
| 507 | 507 | */ |
| 508 | - return apply_filters('geodir_get_imagesize_' . $size, $imagesizes[$size]);
|
|
| 508 | + return apply_filters('geodir_get_imagesize_'.$size, $imagesizes[$size]);
|
|
| 509 | 509 | |
| 510 | 510 | } elseif (!empty($size)) {
|
| 511 | 511 | |
@@ -544,13 +544,13 @@ discard block |
||
| 544 | 544 | function createRandomString() |
| 545 | 545 | {
|
| 546 | 546 | $chars = "abcdefghijkmlnopqrstuvwxyz1023456789"; |
| 547 | - srand((double)microtime() * 1000000); |
|
| 547 | + srand((double) microtime() * 1000000); |
|
| 548 | 548 | $i = 0; |
| 549 | 549 | $rstring = ''; |
| 550 | 550 | while ($i <= 25) {
|
| 551 | 551 | $num = rand() % 33; |
| 552 | 552 | $tmp = substr($chars, $num, 1); |
| 553 | - $rstring = $rstring . $tmp; |
|
| 553 | + $rstring = $rstring.$tmp; |
|
| 554 | 554 | $i++; |
| 555 | 555 | } |
| 556 | 556 | return $rstring; |
@@ -681,11 +681,11 @@ discard block |
||
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | if (!empty($subject)) {
|
| 684 | - $subject = __(stripslashes_deep($subject),'geodirectory'); |
|
| 684 | + $subject = __(stripslashes_deep($subject), 'geodirectory'); |
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | if (!empty($message)) {
|
| 688 | - $message = __(stripslashes_deep($message),'geodirectory'); |
|
| 688 | + $message = __(stripslashes_deep($message), 'geodirectory'); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | $to_message = nl2br($to_message); |
@@ -705,12 +705,12 @@ discard block |
||
| 705 | 705 | |
| 706 | 706 | if ($post_info) {
|
| 707 | 707 | $posted_date = $post_info->post_date; |
| 708 | - $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 708 | + $listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>'; |
|
| 709 | 709 | } |
| 710 | 710 | $siteurl = home_url(); |
| 711 | - $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; |
|
| 711 | + $siteurl_link = '<a href="'.$siteurl.'">'.$siteurl.'</a>'; |
|
| 712 | 712 | $loginurl = geodir_login_url(); |
| 713 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 713 | + $loginurl_link = '<a href="'.$loginurl.'">login</a>'; |
|
| 714 | 714 | |
| 715 | 715 | $post_author_id = !empty($post_info) ? $post_info->post_author : 0; |
| 716 | 716 | $post_author_name = geodir_get_client_name($post_author_id); |
@@ -724,18 +724,18 @@ discard block |
||
| 724 | 724 | $fromEmailName = get_option('site_email_name');
|
| 725 | 725 | } |
| 726 | 726 | |
| 727 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
|
|
| 728 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date); |
|
| 727 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]', '[#from_email#]', '[#user_login#]', '[#username#]', '[#post_author_id#]', '[#post_author_name#]', '[#current_date#]');
|
|
| 728 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date, $fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date); |
|
| 729 | 729 | $message = str_replace($search_array, $replace_array, $message); |
| 730 | 730 | |
| 731 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]','[#post_author_id#]','[#post_author_name#]','[#current_date#]');
|
|
| 732 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date); |
|
| 731 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]', '[#from_email#]', '[#user_login#]', '[#username#]', '[#post_author_id#]', '[#post_author_name#]', '[#current_date#]');
|
|
| 732 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $fromEmail, $user_login, $user_login, $post_author_id, $post_author_name, $current_date); |
|
| 733 | 733 | $subject = str_replace($search_array, $replace_array, $subject); |
| 734 | 734 | |
| 735 | - $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 736 | - $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 737 | - $headers .= "Reply-To: " . $fromEmail . "\r\n"; |
|
| 738 | - $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n"; |
|
| 735 | + $headers = 'MIME-Version: 1.0'."\r\n"; |
|
| 736 | + $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n"; |
|
| 737 | + $headers .= "Reply-To: ".$fromEmail."\r\n"; |
|
| 738 | + $headers .= 'From: '.$sitefromEmailName.' <'.$sitefromEmail.'>'."\r\n"; |
|
| 739 | 739 | |
| 740 | 740 | $to = $toEmail; |
| 741 | 741 | |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | * @param string $post_id The post ID. |
| 757 | 757 | * @param string $user_id The user ID. |
| 758 | 758 | */ |
| 759 | - $to = apply_filters('geodir_sendEmail_to',$to,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
|
| 759 | + $to = apply_filters('geodir_sendEmail_to', $to, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
|
|
| 760 | 760 | /** |
| 761 | 761 | * Filter the client email subject. |
| 762 | 762 | * |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | * @param string $post_id The post ID. |
| 775 | 775 | * @param string $user_id The user ID. |
| 776 | 776 | */ |
| 777 | - $subject = apply_filters('geodir_sendEmail_subject',$subject,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
|
| 777 | + $subject = apply_filters('geodir_sendEmail_subject', $subject, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
|
|
| 778 | 778 | /** |
| 779 | 779 | * Filter the client email message. |
| 780 | 780 | * |
@@ -792,7 +792,7 @@ discard block |
||
| 792 | 792 | * @param string $post_id The post ID. |
| 793 | 793 | * @param string $user_id The user ID. |
| 794 | 794 | */ |
| 795 | - $message = apply_filters('geodir_sendEmail_message',$message,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
|
| 795 | + $message = apply_filters('geodir_sendEmail_message', $message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
|
|
| 796 | 796 | /** |
| 797 | 797 | * Filter the client email headers. |
| 798 | 798 | * |
@@ -810,22 +810,22 @@ discard block |
||
| 810 | 810 | * @param string $post_id The post ID. |
| 811 | 811 | * @param string $user_id The user ID. |
| 812 | 812 | */ |
| 813 | - $headers = apply_filters('geodir_sendEmail_headers',$headers,$fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id );
|
|
| 813 | + $headers = apply_filters('geodir_sendEmail_headers', $headers, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id);
|
|
| 814 | 814 | |
| 815 | 815 | $sent = wp_mail($to, $subject, $message, $headers); |
| 816 | 816 | |
| 817 | - if( ! $sent ) {
|
|
| 818 | - if ( is_array( $to ) ) {
|
|
| 819 | - $to = implode( ',', $to ); |
|
| 817 | + if (!$sent) {
|
|
| 818 | + if (is_array($to)) {
|
|
| 819 | + $to = implode(',', $to);
|
|
| 820 | 820 | } |
| 821 | 821 | $log_message = sprintf( |
| 822 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 822 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 823 | 823 | $message_type, |
| 824 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 824 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 825 | 825 | $to, |
| 826 | 826 | $subject |
| 827 | 827 | ); |
| 828 | - geodir_error_log( $log_message ); |
|
| 828 | + geodir_error_log($log_message); |
|
| 829 | 829 | } |
| 830 | 830 | |
| 831 | 831 | ///////// ADMIN BCC EMIALS |
@@ -837,11 +837,11 @@ discard block |
||
| 837 | 837 | $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
|
| 838 | 838 | $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
|
| 839 | 839 | |
| 840 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
|
|
| 840 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]', '[#user_login#]', '[#username#]');
|
|
| 841 | 841 | $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date, $user_login, $user_login); |
| 842 | 842 | $message = str_replace($search_array, $replace_array, $message); |
| 843 | 843 | |
| 844 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
|
|
| 844 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]', '[#user_login#]', '[#username#]');
|
|
| 845 | 845 | $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login); |
| 846 | 846 | $subject = str_replace($search_array, $replace_array, $subject); |
| 847 | 847 | |
@@ -866,21 +866,21 @@ discard block |
||
| 866 | 866 | $admin_bcc = true; |
| 867 | 867 | } |
| 868 | 868 | |
| 869 | - if($admin_bcc===true){
|
|
| 869 | + if ($admin_bcc === true) {
|
|
| 870 | 870 | $sent = wp_mail($to, $subject, $message, $headers); |
| 871 | 871 | |
| 872 | - if( ! $sent ) {
|
|
| 873 | - if ( is_array( $to ) ) {
|
|
| 874 | - $to = implode( ',', $to ); |
|
| 872 | + if (!$sent) {
|
|
| 873 | + if (is_array($to)) {
|
|
| 874 | + $to = implode(',', $to);
|
|
| 875 | 875 | } |
| 876 | 876 | $log_message = sprintf( |
| 877 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 877 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 878 | 878 | $message_type, |
| 879 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 879 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 880 | 880 | $to, |
| 881 | 881 | $subject |
| 882 | 882 | ); |
| 883 | - geodir_error_log( $log_message ); |
|
| 883 | + geodir_error_log($log_message); |
|
| 884 | 884 | } |
| 885 | 885 | } |
| 886 | 886 | |
@@ -912,12 +912,12 @@ discard block |
||
| 912 | 912 | foreach ($parents as $parent): |
| 913 | 913 | $item = get_term_by('id', $parent, get_query_var('taxonomy'));
|
| 914 | 914 | $url = get_term_link($item, get_query_var('taxonomy'));
|
| 915 | - echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>'; |
|
| 915 | + echo '<li> > <a href="'.$url.'">'.$item->name.'</a></li>'; |
|
| 916 | 916 | endforeach; |
| 917 | 917 | |
| 918 | 918 | endif; |
| 919 | 919 | |
| 920 | - echo '<li> > ' . $term->name . '</li>'; |
|
| 920 | + echo '<li> > '.$term->name.'</li>'; |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | * |
| 952 | 952 | * @since 1.0.0 |
| 953 | 953 | */ |
| 954 | - $breadcrumb .= '<li>' . apply_filters('geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __('Home', 'geodirectory') . '</a>') . '</li>';
|
|
| 954 | + $breadcrumb .= '<li>'.apply_filters('geodir_breadcrumb_first_link', '<a href="'.home_url().'">'.__('Home', 'geodirectory').'</a>').'</li>';
|
|
| 955 | 955 | |
| 956 | 956 | $gd_post_type = geodir_get_current_posttype(); |
| 957 | 957 | $post_type_info = get_post_type_object($gd_post_type); |
@@ -975,7 +975,7 @@ discard block |
||
| 975 | 975 | $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
| 976 | 976 | $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
| 977 | 977 | |
| 978 | - if(geodir_is_page('detail') && isset($post->country_slug)){
|
|
| 978 | + if (geodir_is_page('detail') && isset($post->country_slug)) {
|
|
| 979 | 979 | $location_terms = array( |
| 980 | 980 | 'gd_country' => $post->country_slug, |
| 981 | 981 | 'gd_region' => $post->region_slug, |
@@ -1030,12 +1030,12 @@ discard block |
||
| 1030 | 1030 | $is_location_last = ''; |
| 1031 | 1031 | $is_taxonomy_last = ''; |
| 1032 | 1032 | $breadcrumb .= '<li>'; |
| 1033 | - if (get_query_var($gd_post_type . 'category')) |
|
| 1034 | - $gd_taxonomy = $gd_post_type . 'category'; |
|
| 1035 | - elseif (get_query_var($gd_post_type . '_tags')) |
|
| 1036 | - $gd_taxonomy = $gd_post_type . '_tags'; |
|
| 1033 | + if (get_query_var($gd_post_type.'category')) |
|
| 1034 | + $gd_taxonomy = $gd_post_type.'category'; |
|
| 1035 | + elseif (get_query_var($gd_post_type.'_tags')) |
|
| 1036 | + $gd_taxonomy = $gd_post_type.'_tags'; |
|
| 1037 | 1037 | |
| 1038 | - $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>'; |
|
| 1038 | + $breadcrumb .= $separator.'<a href="'.$listing_link.'">'.__(ucfirst($post_type_info->label), 'geodirectory').'</a>'; |
|
| 1039 | 1039 | if (!empty($gd_taxonomy) || geodir_is_page('detail'))
|
| 1040 | 1040 | $is_location_last = false; |
| 1041 | 1041 | else |
@@ -1085,18 +1085,18 @@ discard block |
||
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | if ($is_location_last && $key == 'gd_country' && !(isset($location_terms['gd_region']) && $location_terms['gd_region'] != '') && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
|
| 1088 | - $breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text; |
|
| 1088 | + $breadcrumb .= $location_term_actual_country != '' ? $separator.$location_term_actual_country : $separator.$gd_location_link_text; |
|
| 1089 | 1089 | } else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
|
| 1090 | - $breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text; |
|
| 1090 | + $breadcrumb .= $location_term_actual_region != '' ? $separator.$location_term_actual_region : $separator.$gd_location_link_text; |
|
| 1091 | 1091 | } else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
|
| 1092 | - $breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text; |
|
| 1092 | + $breadcrumb .= $location_term_actual_city != '' ? $separator.$location_term_actual_city : $separator.$gd_location_link_text; |
|
| 1093 | 1093 | } else if ($is_location_last && $key == 'gd_neighbourhood') {
|
| 1094 | - $breadcrumb .= $separator . $gd_location_link_text; |
|
| 1094 | + $breadcrumb .= $separator.$gd_location_link_text; |
|
| 1095 | 1095 | } else {
|
| 1096 | 1096 | if (get_option('permalink_structure') != '') {
|
| 1097 | - $location_link .= $location_term . '/'; |
|
| 1097 | + $location_link .= $location_term.'/'; |
|
| 1098 | 1098 | } else {
|
| 1099 | - $location_link .= "&$key=" . $location_term; |
|
| 1099 | + $location_link .= "&$key=".$location_term; |
|
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | 1102 | if ($key == 'gd_country' && $location_term_actual_country != '') {
|
@@ -1113,7 +1113,7 @@ discard block |
||
| 1113 | 1113 | } |
| 1114 | 1114 | */ |
| 1115 | 1115 | |
| 1116 | - $breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>'; |
|
| 1116 | + $breadcrumb .= $separator.'<a href="'.$location_link.'">'.$gd_location_link_text.'</a>'; |
|
| 1117 | 1117 | } |
| 1118 | 1118 | } |
| 1119 | 1119 | } |
@@ -1124,8 +1124,8 @@ discard block |
||
| 1124 | 1124 | |
| 1125 | 1125 | //if(get_option('geodir_add_categories_url'))
|
| 1126 | 1126 | {
|
| 1127 | - if (get_query_var($gd_post_type . '_tags')) {
|
|
| 1128 | - $cat_link = $listing_link . 'tags/'; |
|
| 1127 | + if (get_query_var($gd_post_type.'_tags')) {
|
|
| 1128 | + $cat_link = $listing_link.'tags/'; |
|
| 1129 | 1129 | } else |
| 1130 | 1130 | $cat_link = $listing_link; |
| 1131 | 1131 | |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | |
| 1137 | 1137 | if ($location_term != '') {
|
| 1138 | 1138 | if (get_option('permalink_structure') != '') {
|
| 1139 | - $cat_link .= $location_term . '/'; |
|
| 1139 | + $cat_link .= $location_term.'/'; |
|
| 1140 | 1140 | } |
| 1141 | 1141 | } |
| 1142 | 1142 | } |
@@ -1155,10 +1155,10 @@ discard block |
||
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | 1157 | if ($term_index == count($term_array) && $is_taxonomy_last) |
| 1158 | - $breadcrumb .= $separator . $term_link_text; |
|
| 1158 | + $breadcrumb .= $separator.$term_link_text; |
|
| 1159 | 1159 | else {
|
| 1160 | - $cat_link .= $term . '/'; |
|
| 1161 | - $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>'; |
|
| 1160 | + $cat_link .= $term.'/'; |
|
| 1161 | + $breadcrumb .= $separator.'<a href="'.$cat_link.'">'.$term_link_text.'</a>'; |
|
| 1162 | 1162 | } |
| 1163 | 1163 | $term_index++; |
| 1164 | 1164 | } |
@@ -1168,7 +1168,7 @@ discard block |
||
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | 1170 | if (geodir_is_page('detail'))
|
| 1171 | - $breadcrumb .= $separator . get_the_title(); |
|
| 1171 | + $breadcrumb .= $separator.get_the_title(); |
|
| 1172 | 1172 | |
| 1173 | 1173 | $breadcrumb .= '</li>'; |
| 1174 | 1174 | |
@@ -1188,7 +1188,7 @@ discard block |
||
| 1188 | 1188 | $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
|
| 1189 | 1189 | |
| 1190 | 1190 | $breadcrumb .= '<li>'; |
| 1191 | - $breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __('My Dashboard', 'geodirectory') . '</a>';
|
|
| 1191 | + $breadcrumb .= $separator.'<a href="'.$default_author_link.'">'.__('My Dashboard', 'geodirectory').'</a>';
|
|
| 1192 | 1192 | |
| 1193 | 1193 | if (isset($_REQUEST['list'])) {
|
| 1194 | 1194 | $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $_REQUEST['stype']), false);
|
@@ -1203,20 +1203,20 @@ discard block |
||
| 1203 | 1203 | */ |
| 1204 | 1204 | $author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
|
| 1205 | 1205 | |
| 1206 | - $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>'; |
|
| 1207 | - $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
|
|
| 1206 | + $breadcrumb .= $separator.'<a href="'.$author_link.'">'.__(ucfirst($post_type_info->label), 'geodirectory').'</a>'; |
|
| 1207 | + $breadcrumb .= $separator.ucfirst(__('My', 'geodirectory').' '.$_REQUEST['list']);
|
|
| 1208 | 1208 | } else |
| 1209 | - $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory'); |
|
| 1209 | + $breadcrumb .= $separator.__(ucfirst($post_type_info->label), 'geodirectory'); |
|
| 1210 | 1210 | |
| 1211 | 1211 | $breadcrumb .= '</li>'; |
| 1212 | 1212 | } elseif (is_category() || is_single()) {
|
| 1213 | 1213 | $category = get_the_category(); |
| 1214 | 1214 | if (is_category()) {
|
| 1215 | - $breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>'; |
|
| 1215 | + $breadcrumb .= '<li>'.$separator.$category[0]->cat_name.'</li>'; |
|
| 1216 | 1216 | } |
| 1217 | 1217 | if (is_single()) {
|
| 1218 | - $breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a></li>'; |
|
| 1219 | - $breadcrumb .= '<li>' . $separator . get_the_title() . '</li>'; |
|
| 1218 | + $breadcrumb .= '<li>'.$separator.'<a href="'.get_category_link($category[0]->term_id).'">'.$category[0]->cat_name.'</a></li>'; |
|
| 1219 | + $breadcrumb .= '<li>'.$separator.get_the_title().'</li>'; |
|
| 1220 | 1220 | } |
| 1221 | 1221 | /* End of my version ##################################################### */ |
| 1222 | 1222 | } else if (is_page()) {
|
@@ -1226,31 +1226,31 @@ discard block |
||
| 1226 | 1226 | $page_title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
|
| 1227 | 1227 | } |
| 1228 | 1228 | |
| 1229 | - $breadcrumb .= '<li>' . $separator; |
|
| 1229 | + $breadcrumb .= '<li>'.$separator; |
|
| 1230 | 1230 | $breadcrumb .= stripslashes_deep($page_title); |
| 1231 | 1231 | $breadcrumb .= '</li>'; |
| 1232 | 1232 | } else if (is_tag()) {
|
| 1233 | - $breadcrumb .= "<li> " . $separator . single_tag_title('',false) . '</li>';
|
|
| 1233 | + $breadcrumb .= "<li> ".$separator.single_tag_title('', false).'</li>';
|
|
| 1234 | 1234 | } else if (is_day()) {
|
| 1235 | - $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1235 | + $breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
|
|
| 1236 | 1236 | the_time('F jS, Y');
|
| 1237 | 1237 | $breadcrumb .= '</li>'; |
| 1238 | 1238 | } else if (is_month()) {
|
| 1239 | - $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1239 | + $breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
|
|
| 1240 | 1240 | the_time('F, Y');
|
| 1241 | 1241 | $breadcrumb .= '</li>'; |
| 1242 | 1242 | } else if (is_year()) {
|
| 1243 | - $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1243 | + $breadcrumb .= "<li> ".$separator.__(" Archive for", 'geodirectory')." ";
|
|
| 1244 | 1244 | the_time('Y');
|
| 1245 | 1245 | $breadcrumb .= '</li>'; |
| 1246 | 1246 | } else if (is_author()) {
|
| 1247 | - $breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
|
|
| 1247 | + $breadcrumb .= "<li> ".$separator.__(" Author Archive", 'geodirectory');
|
|
| 1248 | 1248 | $breadcrumb .= '</li>'; |
| 1249 | 1249 | } else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
|
| 1250 | - $breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
|
|
| 1250 | + $breadcrumb .= "<li>".$separator.__("Blog Archives", 'geodirectory');
|
|
| 1251 | 1251 | $breadcrumb .= '</li>'; |
| 1252 | 1252 | } else if (is_search()) {
|
| 1253 | - $breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
|
|
| 1253 | + $breadcrumb .= "<li> ".$separator.__(" Search Results", 'geodirectory');
|
|
| 1254 | 1254 | $breadcrumb .= '</li>'; |
| 1255 | 1255 | } |
| 1256 | 1256 | $breadcrumb .= '</ul></div>'; |
@@ -1306,7 +1306,7 @@ discard block |
||
| 1306 | 1306 | function fetch_remote_file($url) |
| 1307 | 1307 | {
|
| 1308 | 1308 | // extract the file name and extension from the url |
| 1309 | - require_once(ABSPATH . 'wp-includes/pluggable.php'); |
|
| 1309 | + require_once(ABSPATH.'wp-includes/pluggable.php'); |
|
| 1310 | 1310 | $file_name = basename($url); |
| 1311 | 1311 | if (strpos($file_name, '?') !== false) {
|
| 1312 | 1312 | list($file_name) = explode('?', $file_name);
|
@@ -1338,7 +1338,7 @@ discard block |
||
| 1338 | 1338 | return new WP_Error('upload_dir_error', $upload['error']);
|
| 1339 | 1339 | |
| 1340 | 1340 | // fetch the remote url and write it to the placeholder file |
| 1341 | - $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
|
|
| 1341 | + $headers = wp_remote_get($url, array('stream' => true, 'filename' => $upload['file']));
|
|
| 1342 | 1342 | |
| 1343 | 1343 | $log_message = ''; |
| 1344 | 1344 | $filesize = filesize($upload['file']); |
@@ -1351,21 +1351,21 @@ discard block |
||
| 1351 | 1351 | $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
|
| 1352 | 1352 | } |
| 1353 | 1353 | elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
|
| 1354 | - $log_message = __('Remote file is incorrect size', 'geodirectory');
|
|
| 1354 | + $log_message = __('Remote file is incorrect size', 'geodirectory');
|
|
| 1355 | 1355 | } |
| 1356 | 1356 | elseif (0 == $filesize) {
|
| 1357 | 1357 | $log_message = __('Zero size file downloaded', 'geodirectory');
|
| 1358 | 1358 | } |
| 1359 | 1359 | |
| 1360 | - if($log_message){
|
|
| 1360 | + if ($log_message) {
|
|
| 1361 | 1361 | $del = unlink($upload['file']); |
| 1362 | - if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
|
|
| 1363 | - return new WP_Error('import_file_error',$log_message );
|
|
| 1362 | + if (!$del) {geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory')); }
|
|
| 1363 | + return new WP_Error('import_file_error', $log_message);
|
|
| 1364 | 1364 | } |
| 1365 | 1365 | |
| 1366 | 1366 | if ($dummy && $add_to_cache && is_array($upload)) {
|
| 1367 | 1367 | $images = get_transient('cached_dummy_images');
|
| 1368 | - if(is_array($images)) |
|
| 1368 | + if (is_array($images)) |
|
| 1369 | 1369 | $images[$key] = $upload; |
| 1370 | 1370 | else |
| 1371 | 1371 | $images = array($key => $upload); |
@@ -1386,12 +1386,12 @@ discard block |
||
| 1386 | 1386 | */ |
| 1387 | 1387 | function geodir_max_upload_size() |
| 1388 | 1388 | {
|
| 1389 | - $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
|
|
| 1389 | + $max_filesize = (float) get_option('geodir_upload_max_filesize', 2);
|
|
| 1390 | 1390 | |
| 1391 | 1391 | if ($max_filesize > 0 && $max_filesize < 1) {
|
| 1392 | - $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
| 1392 | + $max_filesize = (int) ($max_filesize * 1024).'kb'; |
|
| 1393 | 1393 | } else {
|
| 1394 | - $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
|
| 1394 | + $max_filesize = $max_filesize > 0 ? $max_filesize.'mb' : '2mb'; |
|
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | 1397 | /** |
@@ -1414,7 +1414,7 @@ discard block |
||
| 1414 | 1414 | */ |
| 1415 | 1415 | function geodir_dummy_folder_exists() |
| 1416 | 1416 | {
|
| 1417 | - $path = geodir_plugin_path() . '/geodirectory-admin/dummy/'; |
|
| 1417 | + $path = geodir_plugin_path().'/geodirectory-admin/dummy/'; |
|
| 1418 | 1418 | if (!is_dir($path)) |
| 1419 | 1419 | return false; |
| 1420 | 1420 | else |
@@ -1458,35 +1458,35 @@ discard block |
||
| 1458 | 1458 | {
|
| 1459 | 1459 | global $wpdb; |
| 1460 | 1460 | if ($message_type == 'expiration') {
|
| 1461 | - $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
|
|
| 1462 | - $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
|
|
| 1461 | + $subject = stripslashes(__(get_option('renew_email_subject'), 'geodirectory'));
|
|
| 1462 | + $client_message = stripslashes(__(get_option('renew_email_content'), 'geodirectory'));
|
|
| 1463 | 1463 | } elseif ($message_type == 'post_submited') {
|
| 1464 | - $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
|
|
| 1465 | - $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
|
|
| 1464 | + $subject = __(get_option('post_submited_success_email_subject_admin'), 'geodirectory');
|
|
| 1465 | + $client_message = __(get_option('post_submited_success_email_content_admin'), 'geodirectory');
|
|
| 1466 | 1466 | } elseif ($message_type == 'renew') {
|
| 1467 | - $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
|
|
| 1468 | - $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
|
|
| 1467 | + $subject = __(get_option('post_renew_success_email_subject_admin'), 'geodirectory');
|
|
| 1468 | + $client_message = __(get_option('post_renew_success_email_content_admin'), 'geodirectory');
|
|
| 1469 | 1469 | } elseif ($message_type == 'upgrade') {
|
| 1470 | - $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
|
|
| 1471 | - $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
|
|
| 1470 | + $subject = __(get_option('post_upgrade_success_email_subject_admin'), 'geodirectory');
|
|
| 1471 | + $client_message = __(get_option('post_upgrade_success_email_content_admin'), 'geodirectory');
|
|
| 1472 | 1472 | } elseif ($message_type == 'claim_approved') {
|
| 1473 | - $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
|
|
| 1474 | - $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
|
|
| 1473 | + $subject = __(get_option('claim_approved_email_subject'), 'geodirectory');
|
|
| 1474 | + $client_message = __(get_option('claim_approved_email_content'), 'geodirectory');
|
|
| 1475 | 1475 | } elseif ($message_type == 'claim_rejected') {
|
| 1476 | - $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
|
|
| 1477 | - $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
|
|
| 1476 | + $subject = __(get_option('claim_rejected_email_subject'), 'geodirectory');
|
|
| 1477 | + $client_message = __(get_option('claim_rejected_email_content'), 'geodirectory');
|
|
| 1478 | 1478 | } elseif ($message_type == 'claim_requested') {
|
| 1479 | - $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
|
|
| 1480 | - $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
|
|
| 1479 | + $subject = __(get_option('claim_email_subject_admin'), 'geodirectory');
|
|
| 1480 | + $client_message = __(get_option('claim_email_content_admin'), 'geodirectory');
|
|
| 1481 | 1481 | } elseif ($message_type == 'auto_claim') {
|
| 1482 | - $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
|
|
| 1483 | - $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
|
|
| 1482 | + $subject = __(get_option('auto_claim_email_subject'), 'geodirectory');
|
|
| 1483 | + $client_message = __(get_option('auto_claim_email_content'), 'geodirectory');
|
|
| 1484 | 1484 | } elseif ($message_type == 'payment_success') {
|
| 1485 | - $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
|
|
| 1486 | - $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
|
|
| 1485 | + $subject = __(get_option('post_payment_success_admin_email_subject'), 'geodirectory');
|
|
| 1486 | + $client_message = __(get_option('post_payment_success_admin_email_content'), 'geodirectory');
|
|
| 1487 | 1487 | } elseif ($message_type == 'payment_fail') {
|
| 1488 | - $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
|
|
| 1489 | - $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
|
|
| 1488 | + $subject = __(get_option('post_payment_fail_admin_email_subject'), 'geodirectory');
|
|
| 1489 | + $client_message = __(get_option('post_payment_fail_admin_email_content'), 'geodirectory');
|
|
| 1490 | 1490 | } |
| 1491 | 1491 | $transaction_details = $custom_1; |
| 1492 | 1492 | $fromEmail = get_option('site_email');
|
@@ -1497,11 +1497,11 @@ discard block |
||
| 1497 | 1497 | $productlink = get_permalink($page_id); |
| 1498 | 1498 | $post_info = get_post($page_id); |
| 1499 | 1499 | $post_date = date('dS F,Y', strtotime($post_info->post_date));
|
| 1500 | - $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 1500 | + $listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>'; |
|
| 1501 | 1501 | $loginurl = geodir_login_url(); |
| 1502 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 1502 | + $loginurl_link = '<a href="'.$loginurl.'">login</a>'; |
|
| 1503 | 1503 | $siteurl = home_url(); |
| 1504 | - $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>'; |
|
| 1504 | + $siteurl_link = '<a href="'.$siteurl.'">'.$fromEmailName.'</a>'; |
|
| 1505 | 1505 | $user_info = get_userdata($user_id); |
| 1506 | 1506 | $user_email = $user_info->user_email; |
| 1507 | 1507 | $display_name = geodir_get_client_name($user_id); |
@@ -1515,14 +1515,14 @@ discard block |
||
| 1515 | 1515 | } else {
|
| 1516 | 1516 | $post_type = 'listing'; |
| 1517 | 1517 | } |
| 1518 | - $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>'; |
|
| 1518 | + $renew_link = '<a href="'.$siteurl.'?ptype=post_'.$post_type.'&renew=1&pid='.$page_id.'">'.RENEW_LINK.'</a>'; |
|
| 1519 | 1519 | $search_array = array('[#client_name#]', '[#listing_link#]', '[#posted_date#]', '[#number_of_days#]', '[#number_of_grace_days#]', '[#login_url#]', '[#username#]', '[#user_email#]', '[#site_name_url#]', '[#renew_link#]', '[#post_id#]', '[#site_name#]', '[#transaction_details#]');
|
| 1520 | 1520 | $replace_array = array($display_name, $listingLink, $post_date, $alivedays, $number_of_grace_days, $loginurl_link, $user_login, $user_email, $siteurl_link, $renew_link, $page_id, $fromEmailName, $transaction_details); |
| 1521 | 1521 | $client_message = str_replace($search_array, $replace_array, $client_message); |
| 1522 | 1522 | $subject = str_replace($search_array, $replace_array, $subject); |
| 1523 | - $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 1524 | - $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 1525 | - $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n"; |
|
| 1523 | + $headers = 'MIME-Version: 1.0'."\r\n"; |
|
| 1524 | + $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n"; |
|
| 1525 | + $headers .= 'From: '.$fromEmailName.' <'.$fromEmail.'>'."\r\n"; |
|
| 1526 | 1526 | |
| 1527 | 1527 | $to = $fromEmail; |
| 1528 | 1528 | $message = $client_message; |
@@ -1539,7 +1539,7 @@ discard block |
||
| 1539 | 1539 | * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
| 1540 | 1540 | * @param string $custom_1 Custom data to be sent. |
| 1541 | 1541 | */ |
| 1542 | - $to = apply_filters('geodir_adminEmail_to',$to,$page_id, $user_id, $message_type, $custom_1 );
|
|
| 1542 | + $to = apply_filters('geodir_adminEmail_to', $to, $page_id, $user_id, $message_type, $custom_1);
|
|
| 1543 | 1543 | /** |
| 1544 | 1544 | * Filter the admin email subject. |
| 1545 | 1545 | * |
@@ -1551,7 +1551,7 @@ discard block |
||
| 1551 | 1551 | * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
| 1552 | 1552 | * @param string $custom_1 Custom data to be sent. |
| 1553 | 1553 | */ |
| 1554 | - $subject = apply_filters('geodir_adminEmail_subject',$subject,$page_id, $user_id, $message_type, $custom_1);
|
|
| 1554 | + $subject = apply_filters('geodir_adminEmail_subject', $subject, $page_id, $user_id, $message_type, $custom_1);
|
|
| 1555 | 1555 | /** |
| 1556 | 1556 | * Filter the admin email message. |
| 1557 | 1557 | * |
@@ -1563,7 +1563,7 @@ discard block |
||
| 1563 | 1563 | * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
| 1564 | 1564 | * @param string $custom_1 Custom data to be sent. |
| 1565 | 1565 | */ |
| 1566 | - $message = apply_filters('geodir_adminEmail_message',$message,$page_id, $user_id, $message_type, $custom_1);
|
|
| 1566 | + $message = apply_filters('geodir_adminEmail_message', $message, $page_id, $user_id, $message_type, $custom_1);
|
|
| 1567 | 1567 | /** |
| 1568 | 1568 | * Filter the admin email headers. |
| 1569 | 1569 | * |
@@ -1575,23 +1575,23 @@ discard block |
||
| 1575 | 1575 | * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
| 1576 | 1576 | * @param string $custom_1 Custom data to be sent. |
| 1577 | 1577 | */ |
| 1578 | - $headers = apply_filters('geodir_adminEmail_headers',$headers,$page_id, $user_id, $message_type, $custom_1);
|
|
| 1578 | + $headers = apply_filters('geodir_adminEmail_headers', $headers, $page_id, $user_id, $message_type, $custom_1);
|
|
| 1579 | 1579 | |
| 1580 | 1580 | |
| 1581 | 1581 | |
| 1582 | 1582 | $sent = wp_mail($to, $subject, $message, $headers); |
| 1583 | - if( ! $sent ) {
|
|
| 1584 | - if ( is_array( $to ) ) {
|
|
| 1585 | - $to = implode( ',', $to ); |
|
| 1583 | + if (!$sent) {
|
|
| 1584 | + if (is_array($to)) {
|
|
| 1585 | + $to = implode(',', $to);
|
|
| 1586 | 1586 | } |
| 1587 | 1587 | $log_message = sprintf( |
| 1588 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1588 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 1589 | 1589 | $message_type, |
| 1590 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1590 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 1591 | 1591 | $to, |
| 1592 | 1592 | $subject |
| 1593 | 1593 | ); |
| 1594 | - geodir_error_log( $log_message ); |
|
| 1594 | + geodir_error_log($log_message); |
|
| 1595 | 1595 | } |
| 1596 | 1596 | } |
| 1597 | 1597 | } |
@@ -1617,18 +1617,18 @@ discard block |
||
| 1617 | 1617 | {
|
| 1618 | 1618 | $login_details = ''; |
| 1619 | 1619 | if ($message_type == 'send_friend') {
|
| 1620 | - $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
|
|
| 1621 | - $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
|
|
| 1620 | + $subject = stripslashes(__(get_option('email_friend_subject'), 'geodirectory'));
|
|
| 1621 | + $message = stripslashes(__(get_option('email_friend_content'), 'geodirectory'));
|
|
| 1622 | 1622 | } elseif ($message_type == 'send_enquiry') {
|
| 1623 | - $subject = __(get_option('email_enquiry_subject'),'geodirectory');
|
|
| 1624 | - $message = __(get_option('email_enquiry_content'),'geodirectory');
|
|
| 1623 | + $subject = __(get_option('email_enquiry_subject'), 'geodirectory');
|
|
| 1624 | + $message = __(get_option('email_enquiry_content'), 'geodirectory');
|
|
| 1625 | 1625 | } elseif ($message_type == 'forgot_password') {
|
| 1626 | - $subject = __(get_option('forgot_password_subject'),'geodirectory');
|
|
| 1627 | - $message = __(get_option('forgot_password_content'),'geodirectory');
|
|
| 1626 | + $subject = __(get_option('forgot_password_subject'), 'geodirectory');
|
|
| 1627 | + $message = __(get_option('forgot_password_content'), 'geodirectory');
|
|
| 1628 | 1628 | $login_details = $to_message; |
| 1629 | 1629 | } elseif ($message_type == 'registration') {
|
| 1630 | - $subject = __(get_option('registration_success_email_subject'),'geodirectory');
|
|
| 1631 | - $message = __(get_option('registration_success_email_content'),'geodirectory');
|
|
| 1630 | + $subject = __(get_option('registration_success_email_subject'), 'geodirectory');
|
|
| 1631 | + $message = __(get_option('registration_success_email_content'), 'geodirectory');
|
|
| 1632 | 1632 | $login_details = $to_message; |
| 1633 | 1633 | } |
| 1634 | 1634 | $to_message = nl2br($to_message); |
@@ -1636,11 +1636,11 @@ discard block |
||
| 1636 | 1636 | $sitefromEmailName = get_site_emailName(); |
| 1637 | 1637 | $productlink = get_permalink($post_id); |
| 1638 | 1638 | $post_info = get_post($post_id); |
| 1639 | - $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 1639 | + $listingLink = '<a href="'.$productlink.'"><b>'.$post_info->post_title.'</b></a>'; |
|
| 1640 | 1640 | $siteurl = home_url(); |
| 1641 | - $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; |
|
| 1641 | + $siteurl_link = '<a href="'.$siteurl.'">'.$siteurl.'</a>'; |
|
| 1642 | 1642 | $loginurl = geodir_login_url(); |
| 1643 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 1643 | + $loginurl_link = '<a href="'.$loginurl.'">login</a>'; |
|
| 1644 | 1644 | if ($fromEmail == '') {
|
| 1645 | 1645 | $fromEmail = get_option('site_email');
|
| 1646 | 1646 | } |
@@ -1654,26 +1654,26 @@ discard block |
||
| 1654 | 1654 | $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
|
| 1655 | 1655 | $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName); |
| 1656 | 1656 | $subject = str_replace($search_array, $replace_array, $subject); |
| 1657 | - $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 1658 | - $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 1659 | - $headers .= "Reply-To: " . $fromEmail . "\r\n"; |
|
| 1660 | - $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n"; |
|
| 1657 | + $headers = 'MIME-Version: 1.0'."\r\n"; |
|
| 1658 | + $headers .= 'Content-type: text/html; charset=UTF-8'."\r\n"; |
|
| 1659 | + $headers .= "Reply-To: ".$fromEmail."\r\n"; |
|
| 1660 | + $headers .= 'From: '.$sitefromEmailName.' <'.$sitefromEmail.'>'."\r\n"; |
|
| 1661 | 1661 | |
| 1662 | 1662 | $to = $toEmail; |
| 1663 | 1663 | |
| 1664 | 1664 | $sent = wp_mail($to, $subject, $message, $headers); |
| 1665 | - if( ! $sent ) {
|
|
| 1666 | - if ( is_array( $to ) ) {
|
|
| 1667 | - $to = implode( ',', $to ); |
|
| 1665 | + if (!$sent) {
|
|
| 1666 | + if (is_array($to)) {
|
|
| 1667 | + $to = implode(',', $to);
|
|
| 1668 | 1668 | } |
| 1669 | 1669 | $log_message = sprintf( |
| 1670 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1670 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 1671 | 1671 | $message_type, |
| 1672 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1672 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 1673 | 1673 | $to, |
| 1674 | 1674 | $subject |
| 1675 | 1675 | ); |
| 1676 | - geodir_error_log( $log_message ); |
|
| 1676 | + geodir_error_log($log_message); |
|
| 1677 | 1677 | } |
| 1678 | 1678 | |
| 1679 | 1679 | ///////// ADMIN BCC EMIALS |
@@ -1681,7 +1681,7 @@ discard block |
||
| 1681 | 1681 | if ($message_type == 'registration') {
|
| 1682 | 1682 | $message_raw = explode(__("Password:", 'geodirectory'), $message);
|
| 1683 | 1683 | $message_raw2 = explode("</p>", $message_raw[1], 2);
|
| 1684 | - $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
|
|
| 1684 | + $message = $message_raw[0].__('Password:', 'geodirectory').' **********</p>'.$message_raw2[1];
|
|
| 1685 | 1685 | } |
| 1686 | 1686 | $adminEmail = get_bloginfo('admin_email');
|
| 1687 | 1687 | $to = $adminEmail; |
@@ -1699,20 +1699,20 @@ discard block |
||
| 1699 | 1699 | $admin_bcc = true; |
| 1700 | 1700 | } |
| 1701 | 1701 | |
| 1702 | - if($admin_bcc === true){
|
|
| 1702 | + if ($admin_bcc === true) {
|
|
| 1703 | 1703 | $sent = wp_mail($to, $subject, $message, $headers); |
| 1704 | - if( ! $sent ) {
|
|
| 1705 | - if ( is_array( $to ) ) {
|
|
| 1706 | - $to = implode( ',', $to ); |
|
| 1704 | + if (!$sent) {
|
|
| 1705 | + if (is_array($to)) {
|
|
| 1706 | + $to = implode(',', $to);
|
|
| 1707 | 1707 | } |
| 1708 | 1708 | $log_message = sprintf( |
| 1709 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1709 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 1710 | 1710 | $message_type, |
| 1711 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1711 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 1712 | 1712 | $to, |
| 1713 | 1713 | $subject |
| 1714 | 1714 | ); |
| 1715 | - geodir_error_log( $log_message ); |
|
| 1715 | + geodir_error_log($log_message); |
|
| 1716 | 1716 | } |
| 1717 | 1717 | } |
| 1718 | 1718 | |
@@ -1760,7 +1760,7 @@ discard block |
||
| 1760 | 1760 | function geodir_custom_posts_body_class($classes) {
|
| 1761 | 1761 | global $wpdb, $wp; |
| 1762 | 1762 | $post_types = geodir_get_posttypes('object');
|
| 1763 | - if (!empty($post_types) && count((array)$post_types) > 1) {
|
|
| 1763 | + if (!empty($post_types) && count((array) $post_types) > 1) {
|
|
| 1764 | 1764 | $classes[] = 'geodir_custom_posts'; |
| 1765 | 1765 | } |
| 1766 | 1766 | |
@@ -1820,7 +1820,7 @@ discard block |
||
| 1820 | 1820 | $geodir_option = get_option($geodir_option_name); |
| 1821 | 1821 | |
| 1822 | 1822 | if (!empty($geodir_option)) {
|
| 1823 | - add_option($geodir_option_name . '_' . $version_date, $geodir_option); |
|
| 1823 | + add_option($geodir_option_name.'_'.$version_date, $geodir_option); |
|
| 1824 | 1824 | } |
| 1825 | 1825 | } |
| 1826 | 1826 | |
@@ -1926,36 +1926,36 @@ discard block |
||
| 1926 | 1926 | |
| 1927 | 1927 | $query_args = $gd_query_args_widgets; |
| 1928 | 1928 | if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
| 1929 | - return $wpdb->posts . ".post_date DESC, "; |
|
| 1929 | + return $wpdb->posts.".post_date DESC, "; |
|
| 1930 | 1930 | } |
| 1931 | 1931 | |
| 1932 | 1932 | $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
| 1933 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1933 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 1934 | 1934 | |
| 1935 | 1935 | $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : ''; |
| 1936 | 1936 | |
| 1937 | 1937 | switch ($sort_by) {
|
| 1938 | 1938 | case 'latest': |
| 1939 | 1939 | case 'newest': |
| 1940 | - $orderby = $wpdb->posts . ".post_date DESC, "; |
|
| 1940 | + $orderby = $wpdb->posts.".post_date DESC, "; |
|
| 1941 | 1941 | break; |
| 1942 | 1942 | case 'featured': |
| 1943 | - $orderby = $table . ".is_featured ASC, "; |
|
| 1943 | + $orderby = $table.".is_featured ASC, "; |
|
| 1944 | 1944 | break; |
| 1945 | 1945 | case 'az': |
| 1946 | - $orderby = $wpdb->posts . ".post_title ASC, "; |
|
| 1946 | + $orderby = $wpdb->posts.".post_title ASC, "; |
|
| 1947 | 1947 | break; |
| 1948 | 1948 | case 'high_review': |
| 1949 | - $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, "; |
|
| 1949 | + $orderby = $table.".rating_count DESC, ".$table.".overall_rating DESC, "; |
|
| 1950 | 1950 | break; |
| 1951 | 1951 | case 'high_rating': |
| 1952 | - $orderby = "( " . $table . ".overall_rating ) DESC, "; |
|
| 1952 | + $orderby = "( ".$table.".overall_rating ) DESC, "; |
|
| 1953 | 1953 | break; |
| 1954 | 1954 | case 'random': |
| 1955 | 1955 | $orderby = "RAND(), "; |
| 1956 | 1956 | break; |
| 1957 | 1957 | default: |
| 1958 | - $orderby = $wpdb->posts . ".post_title ASC, "; |
|
| 1958 | + $orderby = $wpdb->posts.".post_title ASC, "; |
|
| 1959 | 1959 | break; |
| 1960 | 1960 | } |
| 1961 | 1961 | |
@@ -1982,9 +1982,9 @@ discard block |
||
| 1982 | 1982 | $gd_query_args_widgets = $query_args; |
| 1983 | 1983 | |
| 1984 | 1984 | $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
| 1985 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1985 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 1986 | 1986 | |
| 1987 | - $fields = $wpdb->posts . ".*, " . $table . ".*"; |
|
| 1987 | + $fields = $wpdb->posts.".*, ".$table.".*"; |
|
| 1988 | 1988 | /** |
| 1989 | 1989 | * Filter widget listing fields string part that is being used for query. |
| 1990 | 1990 | * |
@@ -1995,7 +1995,7 @@ discard block |
||
| 1995 | 1995 | */ |
| 1996 | 1996 | $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
|
| 1997 | 1997 | |
| 1998 | - $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
|
|
| 1998 | + $join = "INNER JOIN ".$table." ON (".$table.".post_id = ".$wpdb->posts.".ID)";
|
|
| 1999 | 1999 | |
| 2000 | 2000 | ########### WPML ########### |
| 2001 | 2001 | |
@@ -2003,7 +2003,7 @@ discard block |
||
| 2003 | 2003 | global $sitepress; |
| 2004 | 2004 | $lang_code = ICL_LANGUAGE_CODE; |
| 2005 | 2005 | if ($lang_code) {
|
| 2006 | - $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID"; |
|
| 2006 | + $join .= " JOIN ".$table_prefix."icl_translations icl_t ON icl_t.element_id = ".$table_prefix."posts.ID"; |
|
| 2007 | 2007 | } |
| 2008 | 2008 | } |
| 2009 | 2009 | |
@@ -2018,9 +2018,9 @@ discard block |
||
| 2018 | 2018 | */ |
| 2019 | 2019 | $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
|
| 2020 | 2020 | |
| 2021 | - $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : ''; |
|
| 2021 | + $post_status = is_super_admin() ? " OR ".$wpdb->posts.".post_status = 'private'" : ''; |
|
| 2022 | 2022 | |
| 2023 | - $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'"; |
|
| 2023 | + $where = " AND ( ".$wpdb->posts.".post_status = 'publish' ".$post_status." ) AND ".$wpdb->posts.".post_type = '".$post_type."'"; |
|
| 2024 | 2024 | |
| 2025 | 2025 | ########### WPML ########### |
| 2026 | 2026 | if (function_exists('icl_object_id')) {
|
@@ -2037,7 +2037,7 @@ discard block |
||
| 2037 | 2037 | * @param string $post_type Post type. |
| 2038 | 2038 | */ |
| 2039 | 2039 | $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
|
| 2040 | - $where = $where != '' ? " WHERE 1=1 " . $where : ''; |
|
| 2040 | + $where = $where != '' ? " WHERE 1=1 ".$where : ''; |
|
| 2041 | 2041 | |
| 2042 | 2042 | $groupby = " GROUP BY $wpdb->posts.ID "; |
| 2043 | 2043 | /** |
@@ -2050,10 +2050,10 @@ discard block |
||
| 2050 | 2050 | $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
|
| 2051 | 2051 | |
| 2052 | 2052 | if ($count_only) {
|
| 2053 | - $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
|
|
| 2054 | - " . $join . " |
|
| 2053 | + $sql = "SELECT COUNT(".$wpdb->posts.".ID) AS total FROM ".$wpdb->posts."
|
|
| 2054 | + " . $join." |
|
| 2055 | 2055 | " . $where; |
| 2056 | - $rows = (int)$wpdb->get_var($sql); |
|
| 2056 | + $rows = (int) $wpdb->get_var($sql); |
|
| 2057 | 2057 | } else {
|
| 2058 | 2058 | $orderby = geodir_widget_listings_get_order($query_args); |
| 2059 | 2059 | /** |
@@ -2065,8 +2065,8 @@ discard block |
||
| 2065 | 2065 | * @param string $post_type Post type. |
| 2066 | 2066 | */ |
| 2067 | 2067 | $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
|
| 2068 | - $orderby .= $wpdb->posts . ".post_title ASC"; |
|
| 2069 | - $orderby = $orderby != '' ? " ORDER BY " . $orderby : ''; |
|
| 2068 | + $orderby .= $wpdb->posts.".post_title ASC"; |
|
| 2069 | + $orderby = $orderby != '' ? " ORDER BY ".$orderby : ''; |
|
| 2070 | 2070 | |
| 2071 | 2071 | $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5; |
| 2072 | 2072 | /** |
@@ -2079,16 +2079,16 @@ discard block |
||
| 2079 | 2079 | $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
|
| 2080 | 2080 | |
| 2081 | 2081 | $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1; |
| 2082 | - if ( !$page ) |
|
| 2082 | + if (!$page) |
|
| 2083 | 2083 | $page = 1; |
| 2084 | 2084 | |
| 2085 | - $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : ""; |
|
| 2085 | + $limit = (int) $limit > 0 ? " LIMIT ".absint(($page - 1) * (int) $limit).", ".(int) $limit : ""; |
|
| 2086 | 2086 | |
| 2087 | - $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . " |
|
| 2088 | - " . $join . " |
|
| 2089 | - " . $where . " |
|
| 2090 | - " . $groupby . " |
|
| 2091 | - " . $orderby . " |
|
| 2087 | + $sql = "SELECT SQL_CALC_FOUND_ROWS ".$fields." FROM ".$wpdb->posts." |
|
| 2088 | + " . $join." |
|
| 2089 | + " . $where." |
|
| 2090 | + " . $groupby." |
|
| 2091 | + " . $orderby." |
|
| 2092 | 2092 | " . $limit; |
| 2093 | 2093 | $rows = $wpdb->get_results($sql); |
| 2094 | 2094 | } |
@@ -2141,10 +2141,10 @@ discard block |
||
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | 2143 | $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
| 2144 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2144 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2145 | 2145 | |
| 2146 | 2146 | if (!empty($query_args['with_pics_only'])) {
|
| 2147 | - $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )"; |
|
| 2147 | + $join .= " LEFT JOIN ".GEODIR_ATTACHMENT_TABLE." ON ( ".GEODIR_ATTACHMENT_TABLE.".post_id=".$table.".post_id AND ".GEODIR_ATTACHMENT_TABLE.".mime_type LIKE '%image%' )"; |
|
| 2148 | 2148 | } |
| 2149 | 2149 | |
| 2150 | 2150 | if (!empty($query_args['tax_query'])) {
|
@@ -2176,7 +2176,7 @@ discard block |
||
| 2176 | 2176 | return $where; |
| 2177 | 2177 | } |
| 2178 | 2178 | $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
| 2179 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2179 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2180 | 2180 | |
| 2181 | 2181 | if (!empty($query_args)) {
|
| 2182 | 2182 | if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
|
@@ -2184,27 +2184,27 @@ discard block |
||
| 2184 | 2184 | } |
| 2185 | 2185 | |
| 2186 | 2186 | if (!empty($query_args['post_author'])) {
|
| 2187 | - $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author']; |
|
| 2187 | + $where .= " AND ".$wpdb->posts.".post_author = ".(int) $query_args['post_author']; |
|
| 2188 | 2188 | } |
| 2189 | 2189 | |
| 2190 | 2190 | if (!empty($query_args['show_featured_only'])) {
|
| 2191 | - $where .= " AND " . $table . ".is_featured = '1'"; |
|
| 2191 | + $where .= " AND ".$table.".is_featured = '1'"; |
|
| 2192 | 2192 | } |
| 2193 | 2193 | |
| 2194 | 2194 | if (!empty($query_args['show_special_only'])) {
|
| 2195 | - $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )"; |
|
| 2195 | + $where .= " AND ( ".$table.".geodir_special_offers != '' AND ".$table.".geodir_special_offers IS NOT NULL )"; |
|
| 2196 | 2196 | } |
| 2197 | 2197 | |
| 2198 | 2198 | if (!empty($query_args['with_pics_only'])) {
|
| 2199 | - $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL "; |
|
| 2199 | + $where .= " AND ".GEODIR_ATTACHMENT_TABLE.".ID IS NOT NULL "; |
|
| 2200 | 2200 | } |
| 2201 | 2201 | |
| 2202 | 2202 | if (!empty($query_args['featured_image_only'])) {
|
| 2203 | - $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' "; |
|
| 2203 | + $where .= " AND ".$table.".featured_image IS NOT NULL AND ".$table.".featured_image!='' "; |
|
| 2204 | 2204 | } |
| 2205 | 2205 | |
| 2206 | 2206 | if (!empty($query_args['with_videos_only'])) {
|
| 2207 | - $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )"; |
|
| 2207 | + $where .= " AND ( ".$table.".geodir_video != '' AND ".$table.".geodir_video IS NOT NULL )"; |
|
| 2208 | 2208 | } |
| 2209 | 2209 | |
| 2210 | 2210 | if (!empty($query_args['tax_query'])) {
|
@@ -2261,7 +2261,7 @@ discard block |
||
| 2261 | 2261 | } |
| 2262 | 2262 | |
| 2263 | 2263 | if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
|
| 2264 | - $limit = (int)$query_args['posts_per_page']; |
|
| 2264 | + $limit = (int) $query_args['posts_per_page']; |
|
| 2265 | 2265 | } |
| 2266 | 2266 | |
| 2267 | 2267 | return $limit; |
@@ -2404,9 +2404,9 @@ discard block |
||
| 2404 | 2404 | add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
| 2405 | 2405 | } |
| 2406 | 2406 | $home_url = str_replace("www.", "", $home_url);
|
| 2407 | - if ( (strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')) ) {
|
|
| 2407 | + if ((strpos($home_url, $cur_url) !== false || strpos($home_url.'/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front') == get_option('geodir_home_page'))) {
|
|
| 2408 | 2408 | return true; |
| 2409 | - }elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
|
|
| 2409 | + }elseif (get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front') == get_option('geodir_home_page')) {
|
|
| 2410 | 2410 | return true; |
| 2411 | 2411 | } else {
|
| 2412 | 2412 | return false; |
@@ -2489,19 +2489,19 @@ discard block |
||
| 2489 | 2489 | |
| 2490 | 2490 | $gd_post_type = geodir_get_current_posttype(); |
| 2491 | 2491 | |
| 2492 | - $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15; |
|
| 2493 | - if(!empty($gd_post_type)){
|
|
| 2492 | + $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15; |
|
| 2493 | + if (!empty($gd_post_type)) {
|
|
| 2494 | 2494 | $default_post_type = $gd_post_type; |
| 2495 | - }elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
|
|
| 2495 | + }elseif (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type'])) {
|
|
| 2496 | 2496 | $default_post_type = $instance['default_post_type']; |
| 2497 | - }else{
|
|
| 2497 | + } else {
|
|
| 2498 | 2498 | $all_gd_post_type = geodir_get_posttypes(); |
| 2499 | 2499 | $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : ''; |
| 2500 | 2500 | } |
| 2501 | 2501 | |
| 2502 | 2502 | $taxonomy = array(); |
| 2503 | 2503 | if (!empty($gd_post_type)) {
|
| 2504 | - $taxonomy[] = $gd_post_type . "category"; |
|
| 2504 | + $taxonomy[] = $gd_post_type."category"; |
|
| 2505 | 2505 | } else {
|
| 2506 | 2506 | $taxonomy = geodir_get_taxonomies($gd_post_type); |
| 2507 | 2507 | } |
@@ -2521,7 +2521,7 @@ discard block |
||
| 2521 | 2521 | $b_terms[$b_key] = geodir_sort_terms($b_val, 'count'); |
| 2522 | 2522 | } |
| 2523 | 2523 | |
| 2524 | - $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : ''; |
|
| 2524 | + $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type.'category']) ? $default_post_type.'category' : ''; |
|
| 2525 | 2525 | |
| 2526 | 2526 | $tax_change_output = ''; |
| 2527 | 2527 | if (count($b_terms) > 1) {
|
@@ -2529,20 +2529,20 @@ discard block |
||
| 2529 | 2529 | foreach ($b_terms as $key => $val) {
|
| 2530 | 2530 | $ptype = get_post_type_object(str_replace("category", "", $key));
|
| 2531 | 2531 | $cpt_name = __($ptype->labels->singular_name, 'geodirectory'); |
| 2532 | - $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
|
|
| 2532 | + $tax_change_output .= "<option value='$key' ".selected($key, $default_taxonomy, false).">".sprintf(__('%s Categories', 'geodirectory'), $cpt_name)."</option>";
|
|
| 2533 | 2533 | } |
| 2534 | 2534 | $tax_change_output .= "</select>"; |
| 2535 | 2535 | } |
| 2536 | 2536 | |
| 2537 | 2537 | if (!empty($b_terms)) {
|
| 2538 | - $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array |
|
| 2539 | - global $cat_count;//make global so we can change via function |
|
| 2538 | + $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms); // get the first array |
|
| 2539 | + global $cat_count; //make global so we can change via function |
|
| 2540 | 2540 | $cat_count = 0; |
| 2541 | 2541 | ?> |
| 2542 | 2542 | <div class="geodir-category-list-in clearfix"> |
| 2543 | 2543 | <div class="geodir-cat-list clearfix"> |
| 2544 | 2544 | <?php |
| 2545 | - echo $before_title . __($title) . $after_title; |
|
| 2545 | + echo $before_title.__($title).$after_title; |
|
| 2546 | 2546 | |
| 2547 | 2547 | echo $tax_change_output; |
| 2548 | 2548 | |
@@ -2559,8 +2559,8 @@ discard block |
||
| 2559 | 2559 | $hide = 'style="display:none;"'; |
| 2560 | 2560 | } |
| 2561 | 2561 | echo "<div class='geodir-cat-list-more' $hide >"; |
| 2562 | - echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
|
|
| 2563 | - echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
|
|
| 2562 | + echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">'.__('More Categories', 'geodirectory').'</a>';
|
|
| 2563 | + echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">'.__('Less Categories', 'geodirectory').'</a>';
|
|
| 2564 | 2564 | echo "</div>"; |
| 2565 | 2565 | /* add scripts */ |
| 2566 | 2566 | add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
|
@@ -2600,7 +2600,7 @@ discard block |
||
| 2600 | 2600 | $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show'; |
| 2601 | 2601 | $total_post = $cat->count; |
| 2602 | 2602 | |
| 2603 | - $term_link = get_term_link( $cat, $cat->taxonomy ); |
|
| 2603 | + $term_link = get_term_link($cat, $cat->taxonomy); |
|
| 2604 | 2604 | /** |
| 2605 | 2605 | * Filer the category term link. |
| 2606 | 2606 | * |
@@ -2609,10 +2609,10 @@ discard block |
||
| 2609 | 2609 | * @param int $cat->term_id The term id. |
| 2610 | 2610 | * @param string $post_type Wordpress post type. |
| 2611 | 2611 | */ |
| 2612 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type ); |
|
| 2612 | + $term_link = apply_filters('geodir_category_term_link', $term_link, $cat->term_id, $post_type);
|
|
| 2613 | 2613 | |
| 2614 | - echo '<li class="' . $class_row . '"><a href="' . $term_link . '">'; |
|
| 2615 | - echo '<img alt="' . esc_attr($cat->name) . ' icon" style="height:20px;vertical-align:middle;" src="' . $term_icon_url . '"/> <span class="cat-link">'; echo $cat->name . '</span> <span class="geodir_term_class geodir_link_span geodir_category_class_' . $post_type . '_' . $cat->term_id . '">(' . $total_post . ')</span> ';
|
|
| 2614 | + echo '<li class="'.$class_row.'"><a href="'.$term_link.'">'; |
|
| 2615 | + echo '<img alt="'.esc_attr($cat->name).' icon" style="height:20px;vertical-align:middle;" src="'.$term_icon_url.'"/> <span class="cat-link">'; echo $cat->name.'</span> <span class="geodir_term_class geodir_link_span geodir_category_class_'.$post_type.'_'.$cat->term_id.'">('.$total_post.')</span> ';
|
|
| 2616 | 2616 | echo '</a></li>'; |
| 2617 | 2617 | } |
| 2618 | 2618 | } |
@@ -2743,29 +2743,29 @@ discard block |
||
| 2743 | 2743 | itemWidth: 75, |
| 2744 | 2744 | itemMargin: 5, |
| 2745 | 2745 | asNavFor: '#geodir_widget_slider', |
| 2746 | - rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?> |
|
| 2746 | + rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?> |
|
| 2747 | 2747 | }); |
| 2748 | 2748 | |
| 2749 | 2749 | jQuery('#geodir_widget_slider').flexslider({
|
| 2750 | - animation: "<?php echo $animation;?>", |
|
| 2750 | + animation: "<?php echo $animation; ?>", |
|
| 2751 | 2751 | selector: ".geodir-slides > li", |
| 2752 | 2752 | namespace: "geodir-", |
| 2753 | 2753 | controlNav: true, |
| 2754 | - animationLoop: <?php echo $animationLoop;?>, |
|
| 2755 | - slideshow: <?php echo $slideshow;?>, |
|
| 2756 | - slideshowSpeed: <?php echo $slideshowSpeed;?>, |
|
| 2757 | - animationSpeed: <?php echo $animationSpeed;?>, |
|
| 2758 | - directionNav: <?php echo $directionNav;?>, |
|
| 2759 | - maxItems: <?php echo $max_show;?>, |
|
| 2754 | + animationLoop: <?php echo $animationLoop; ?>, |
|
| 2755 | + slideshow: <?php echo $slideshow; ?>, |
|
| 2756 | + slideshowSpeed: <?php echo $slideshowSpeed; ?>, |
|
| 2757 | + animationSpeed: <?php echo $animationSpeed; ?>, |
|
| 2758 | + directionNav: <?php echo $directionNav; ?>, |
|
| 2759 | + maxItems: <?php echo $max_show; ?>, |
|
| 2760 | 2760 | move: 1, |
| 2761 | - <?php if($slide_width){ echo "itemWidth: ".$slide_width.",";}?>
|
|
| 2761 | + <?php if ($slide_width) { echo "itemWidth: ".$slide_width.","; }?>
|
|
| 2762 | 2762 | sync: "#geodir_widget_carousel", |
| 2763 | 2763 | start: function (slider) {
|
| 2764 | 2764 | jQuery('.geodir-listing-flex-loader').hide();
|
| 2765 | 2765 | jQuery('#geodir_widget_slider').css({'visibility': 'visible'});
|
| 2766 | 2766 | jQuery('#geodir_widget_carousel').css({'visibility': 'visible'});
|
| 2767 | 2767 | }, |
| 2768 | - rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?> |
|
| 2768 | + rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?> |
|
| 2769 | 2769 | }); |
| 2770 | 2770 | }); |
| 2771 | 2771 | </script> |
@@ -2801,12 +2801,12 @@ discard block |
||
| 2801 | 2801 | $widget_listings = geodir_get_widget_listings($query_args); |
| 2802 | 2802 | if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
|
| 2803 | 2803 | if ($title) {
|
| 2804 | - echo $before_title . $title . $after_title; |
|
| 2804 | + echo $before_title.$title.$after_title; |
|
| 2805 | 2805 | } |
| 2806 | 2806 | |
| 2807 | 2807 | global $post; |
| 2808 | 2808 | |
| 2809 | - $current_post = $post;// keep current post info |
|
| 2809 | + $current_post = $post; // keep current post info |
|
| 2810 | 2810 | |
| 2811 | 2811 | $widget_main_slides = ''; |
| 2812 | 2812 | $nav_slides = ''; |
@@ -2824,11 +2824,11 @@ discard block |
||
| 2824 | 2824 | $widget_spacer_height = ((200 - $widget_image->height) / 2); |
| 2825 | 2825 | } |
| 2826 | 2826 | |
| 2827 | - $widget_main_slides .= '<li class="geodir-listing-slider-widget"><img class="geodir-listing-slider-spacer" src="' . geodir_plugin_url() . "/geodirectory-assets/images/spacer.gif" . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:' . $widget_spacer_height . 'px !important;margin:0 auto;" width="100" />'; |
|
| 2827 | + $widget_main_slides .= '<li class="geodir-listing-slider-widget"><img class="geodir-listing-slider-spacer" src="'.geodir_plugin_url()."/geodirectory-assets/images/spacer.gif".'" alt="'.$widget_image->title.'" title="'.$widget_image->title.'" style="max-height:'.$widget_spacer_height.'px !important;margin:0 auto;" width="100" />'; |
|
| 2828 | 2828 | |
| 2829 | 2829 | $title = ''; |
| 2830 | 2830 | if ($show_title) {
|
| 2831 | - $title_html = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>'; |
|
| 2831 | + $title_html = '<div class="geodir-slider-title"><a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a></div>'; |
|
| 2832 | 2832 | $post_id = $post->ID; |
| 2833 | 2833 | $post_permalink = get_permalink($post->ID); |
| 2834 | 2834 | $post_title = get_the_title($post->ID); |
@@ -2841,11 +2841,11 @@ discard block |
||
| 2841 | 2841 | * @param string $post_permalink The post permalink url. |
| 2842 | 2842 | * @param string $post_title The post title text. |
| 2843 | 2843 | */ |
| 2844 | - $title = apply_filters('geodir_listing_slider_title',$title_html,$post_id,$post_permalink,$post_title);
|
|
| 2844 | + $title = apply_filters('geodir_listing_slider_title', $title_html, $post_id, $post_permalink, $post_title);
|
|
| 2845 | 2845 | } |
| 2846 | 2846 | |
| 2847 | - $widget_main_slides .= $title . '<img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:200px;margin:0 auto;" /></li>'; |
|
| 2848 | - $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 2847 | + $widget_main_slides .= $title.'<img src="'.$widget_image->src.'" alt="'.$widget_image->title.'" title="'.$widget_image->title.'" style="max-height:200px;margin:0 auto;" /></li>'; |
|
| 2848 | + $nav_slides .= '<li><img src="'.$widget_image->src.'" alt="'.$widget_image->title.'" title="'.$widget_image->title.'" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 2849 | 2849 | $widget_slides++; |
| 2850 | 2850 | } |
| 2851 | 2851 | } |
@@ -2889,7 +2889,7 @@ discard block |
||
| 2889 | 2889 | $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
| 2890 | 2890 | |
| 2891 | 2891 | echo $before_widget; |
| 2892 | - echo $before_title . $title . $after_title; |
|
| 2892 | + echo $before_title.$title.$after_title; |
|
| 2893 | 2893 | |
| 2894 | 2894 | if (is_user_logged_in()) {
|
| 2895 | 2895 | global $current_user; |
@@ -2931,7 +2931,7 @@ discard block |
||
| 2931 | 2931 | */ |
| 2932 | 2932 | $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
|
| 2933 | 2933 | |
| 2934 | - $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 2934 | + $addlisting_links .= '<option '.$selected.' value="'.$add_link.'">'.__(ucfirst($name), 'geodirectory').'</option>'; |
|
| 2935 | 2935 | |
| 2936 | 2936 | } |
| 2937 | 2937 | } |
@@ -2977,7 +2977,7 @@ discard block |
||
| 2977 | 2977 | */ |
| 2978 | 2978 | $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
|
| 2979 | 2979 | |
| 2980 | - $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 2980 | + $favourite_links .= '<option '.$selected.' value="'.$post_type_link.'">'.__(ucfirst($name), 'geodirectory').'</option>'; |
|
| 2981 | 2981 | } |
| 2982 | 2982 | } |
| 2983 | 2983 | |
@@ -3022,7 +3022,7 @@ discard block |
||
| 3022 | 3022 | */ |
| 3023 | 3023 | $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
|
| 3024 | 3024 | |
| 3025 | - $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 3025 | + $listing_links .= '<option '.$selected.' value="'.$listing_link.'">'.__(ucfirst($name), 'geodirectory').'</option>'; |
|
| 3026 | 3026 | } |
| 3027 | 3027 | } |
| 3028 | 3028 | |
@@ -3205,7 +3205,7 @@ discard block |
||
| 3205 | 3205 | } |
| 3206 | 3206 | |
| 3207 | 3207 | if (empty($title) || $title == 'All') {
|
| 3208 | - $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory'); |
|
| 3208 | + $title .= ' '.__(get_post_type_plural_label($post_type), 'geodirectory'); |
|
| 3209 | 3209 | } |
| 3210 | 3210 | |
| 3211 | 3211 | $location_url = array(); |
@@ -3259,7 +3259,7 @@ discard block |
||
| 3259 | 3259 | $geodir_add_location_url = '1'; |
| 3260 | 3260 | } |
| 3261 | 3261 | |
| 3262 | - $viewall_url = get_term_link((int)$category[0], $post_type . 'category'); |
|
| 3262 | + $viewall_url = get_term_link((int) $category[0], $post_type.'category'); |
|
| 3263 | 3263 | |
| 3264 | 3264 | $geodir_add_location_url = NULL; |
| 3265 | 3265 | } |
@@ -3267,7 +3267,7 @@ discard block |
||
| 3267 | 3267 | $gd_session->set('gd_multi_location', 1);
|
| 3268 | 3268 | } |
| 3269 | 3269 | |
| 3270 | - if(is_wp_error( $viewall_url )){$viewall_url = '';}
|
|
| 3270 | + if (is_wp_error($viewall_url)) {$viewall_url = ''; }
|
|
| 3271 | 3271 | |
| 3272 | 3272 | $query_args = array( |
| 3273 | 3273 | 'posts_per_page' => $post_number, |
@@ -3333,7 +3333,7 @@ discard block |
||
| 3333 | 3333 | */ |
| 3334 | 3334 | do_action('geodir_before_view_all_link_in_widget'); ?>
|
| 3335 | 3335 | <div class="geodir_list_heading clearfix"> |
| 3336 | - <?php echo $before_title . $title . $after_title; ?> |
|
| 3336 | + <?php echo $before_title.$title.$after_title; ?> |
|
| 3337 | 3337 | <a href="<?php echo $viewall_url; ?>" |
| 3338 | 3338 | class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
|
| 3339 | 3339 | </div> |
@@ -3419,9 +3419,9 @@ discard block |
||
| 3419 | 3419 | {
|
| 3420 | 3420 | global $wpdb, $plugin_prefix; |
| 3421 | 3421 | |
| 3422 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 3422 | + $detail_table = $plugin_prefix.$post_type.'_detail'; |
|
| 3423 | 3423 | |
| 3424 | - $sql = "SELECT COALESCE(SUM(rating_count),0) FROM " . $detail_table . " WHERE post_status = 'publish' AND rating_count > 0 AND FIND_IN_SET(" . $term_id . ", " . $taxonomy . ")";
|
|
| 3424 | + $sql = "SELECT COALESCE(SUM(rating_count),0) FROM ".$detail_table." WHERE post_status = 'publish' AND rating_count > 0 AND FIND_IN_SET(".$term_id.", ".$taxonomy.")";
|
|
| 3425 | 3425 | |
| 3426 | 3426 | /** |
| 3427 | 3427 | * Filter count review sql query. |
@@ -3460,7 +3460,7 @@ discard block |
||
| 3460 | 3460 | * @param bool $force_update Force update option value?. Default.false. |
| 3461 | 3461 | * @param int $post_ID The post id to update if any. |
| 3462 | 3462 | */ |
| 3463 | - $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update,$post_ID);
|
|
| 3463 | + $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update, $post_ID);
|
|
| 3464 | 3464 | if (!empty($option_data)) {
|
| 3465 | 3465 | return $option_data; |
| 3466 | 3466 | } |
@@ -3468,11 +3468,11 @@ discard block |
||
| 3468 | 3468 | $option_data = get_option('geodir_global_review_count');
|
| 3469 | 3469 | |
| 3470 | 3470 | if (!$option_data || $force_update) {
|
| 3471 | - if ((int)$post_ID > 0) { // Update reviews count for specific post categories only.
|
|
| 3471 | + if ((int) $post_ID > 0) { // Update reviews count for specific post categories only.
|
|
| 3472 | 3472 | global $gd_session; |
| 3473 | - $term_array = (array)$option_data; |
|
| 3473 | + $term_array = (array) $option_data; |
|
| 3474 | 3474 | $post_type = get_post_type($post_ID); |
| 3475 | - $taxonomy = $post_type . 'category'; |
|
| 3475 | + $taxonomy = $post_type.'category'; |
|
| 3476 | 3476 | $terms = wp_get_object_terms($post_ID, $taxonomy, array('fields' => 'ids'));
|
| 3477 | 3477 | |
| 3478 | 3478 | if (!empty($terms) && !is_wp_error($terms)) {
|
@@ -3487,9 +3487,9 @@ discard block |
||
| 3487 | 3487 | |
| 3488 | 3488 | $terms = array(); |
| 3489 | 3489 | if (isset($_POST['post_category'][$taxonomy])) {
|
| 3490 | - $terms = (array)$_POST['post_category'][$taxonomy]; |
|
| 3490 | + $terms = (array) $_POST['post_category'][$taxonomy]; |
|
| 3491 | 3491 | } else if (!empty($session_listing) && isset($session_listing['post_category'][$taxonomy])) {
|
| 3492 | - $terms = (array)$session_listing['post_category'][$taxonomy]; |
|
| 3492 | + $terms = (array) $session_listing['post_category'][$taxonomy]; |
|
| 3493 | 3493 | } |
| 3494 | 3494 | |
| 3495 | 3495 | if (!empty($terms)) {
|
@@ -3577,7 +3577,7 @@ discard block |
||
| 3577 | 3577 | return true; |
| 3578 | 3578 | } |
| 3579 | 3579 | |
| 3580 | -function geodir_term_review_count_force_update_single_post($post_id){
|
|
| 3580 | +function geodir_term_review_count_force_update_single_post($post_id) {
|
|
| 3581 | 3581 | geodir_count_reviews_by_terms(true, $post_id); |
| 3582 | 3582 | } |
| 3583 | 3583 | |
@@ -3714,17 +3714,17 @@ discard block |
||
| 3714 | 3714 | */ |
| 3715 | 3715 | $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
|
| 3716 | 3716 | |
| 3717 | - load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
|
|
| 3718 | - load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
|
|
| 3717 | + load_textdomain('geodirectory', WP_LANG_DIR.'/'.'geodirectory'.'/'.'geodirectory'.'-'.$locale.'.mo');
|
|
| 3718 | + load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))).'/geodirectory-languages');
|
|
| 3719 | 3719 | |
| 3720 | 3720 | /** |
| 3721 | 3721 | * Define language constants. |
| 3722 | 3722 | * |
| 3723 | 3723 | * @since 1.0.0 |
| 3724 | 3724 | */ |
| 3725 | - require_once(geodir_plugin_path() . '/language.php'); |
|
| 3725 | + require_once(geodir_plugin_path().'/language.php'); |
|
| 3726 | 3726 | |
| 3727 | - $language_file = geodir_plugin_path() . '/db-language.php'; |
|
| 3727 | + $language_file = geodir_plugin_path().'/db-language.php'; |
|
| 3728 | 3728 | |
| 3729 | 3729 | // Load language string file if not created yet |
| 3730 | 3730 | if (!file_exists($language_file)) {
|
@@ -3739,8 +3739,8 @@ discard block |
||
| 3739 | 3739 | */ |
| 3740 | 3740 | try {
|
| 3741 | 3741 | require_once($language_file); |
| 3742 | - } catch(Exception $e) {
|
|
| 3743 | - error_log('Language Error: ' . $e->getMessage());
|
|
| 3742 | + } catch (Exception $e) {
|
|
| 3743 | + error_log('Language Error: '.$e->getMessage());
|
|
| 3744 | 3744 | } |
| 3745 | 3745 | } |
| 3746 | 3746 | } |
@@ -3757,18 +3757,18 @@ discard block |
||
| 3757 | 3757 | */ |
| 3758 | 3758 | function geodirectory_load_db_language() {
|
| 3759 | 3759 | global $wp_filesystem; |
| 3760 | - if( empty( $wp_filesystem ) ) {
|
|
| 3761 | - require_once( ABSPATH .'/wp-admin/includes/file.php' ); |
|
| 3760 | + if (empty($wp_filesystem)) {
|
|
| 3761 | + require_once(ABSPATH.'/wp-admin/includes/file.php'); |
|
| 3762 | 3762 | WP_Filesystem(); |
| 3763 | 3763 | global $wp_filesystem; |
| 3764 | 3764 | } |
| 3765 | 3765 | |
| 3766 | - $language_file = geodir_plugin_path() . '/db-language.php'; |
|
| 3766 | + $language_file = geodir_plugin_path().'/db-language.php'; |
|
| 3767 | 3767 | |
| 3768 | - if(is_file($language_file) && !is_writable($language_file)) |
|
| 3768 | + if (is_file($language_file) && !is_writable($language_file)) |
|
| 3769 | 3769 | return false; // Not possible to create. |
| 3770 | 3770 | |
| 3771 | - if(!is_file($language_file) && !is_writable(dirname($language_file))) |
|
| 3771 | + if (!is_file($language_file) && !is_writable(dirname($language_file))) |
|
| 3772 | 3772 | return false; // Not possible to create. |
| 3773 | 3773 | |
| 3774 | 3774 | $contents_strings = array(); |
@@ -3802,17 +3802,17 @@ discard block |
||
| 3802 | 3802 | $contents = implode(PHP_EOL, $contents_head); |
| 3803 | 3803 | |
| 3804 | 3804 | if (!empty($contents_strings)) {
|
| 3805 | - foreach ( $contents_strings as $string ) {
|
|
| 3805 | + foreach ($contents_strings as $string) {
|
|
| 3806 | 3806 | if (is_scalar($string) && $string != '') {
|
| 3807 | 3807 | $string = str_replace("'", "\'", $string);
|
| 3808 | - $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
|
|
| 3808 | + $contents .= PHP_EOL."__('".$string."', 'geodirectory');";
|
|
| 3809 | 3809 | } |
| 3810 | 3810 | } |
| 3811 | 3811 | } |
| 3812 | 3812 | |
| 3813 | 3813 | $contents .= implode(PHP_EOL, $contents_foot); |
| 3814 | 3814 | |
| 3815 | - if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) |
|
| 3815 | + if ($wp_filesystem->put_contents($language_file, $contents, FS_CHMOD_FILE)) |
|
| 3816 | 3816 | return false; // Failure; could not write file. |
| 3817 | 3817 | |
| 3818 | 3818 | return true; |
@@ -3834,11 +3834,11 @@ discard block |
||
| 3834 | 3834 | global $wpdb; |
| 3835 | 3835 | |
| 3836 | 3836 | // Custom fields table |
| 3837 | - $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE; |
|
| 3837 | + $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM ".GEODIR_CUSTOM_FIELDS_TABLE; |
|
| 3838 | 3838 | $rows = $wpdb->get_results($sql); |
| 3839 | 3839 | |
| 3840 | 3840 | if (!empty($rows)) {
|
| 3841 | - foreach($rows as $row) {
|
|
| 3841 | + foreach ($rows as $row) {
|
|
| 3842 | 3842 | if (!empty($row->admin_title)) |
| 3843 | 3843 | $translation_texts[] = stripslashes_deep($row->admin_title); |
| 3844 | 3844 | |
@@ -3872,11 +3872,11 @@ discard block |
||
| 3872 | 3872 | } |
| 3873 | 3873 | |
| 3874 | 3874 | // Custom sorting fields table |
| 3875 | - $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE; |
|
| 3875 | + $sql = "SELECT site_title, asc_title, desc_title FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE; |
|
| 3876 | 3876 | $rows = $wpdb->get_results($sql); |
| 3877 | 3877 | |
| 3878 | 3878 | if (!empty($rows)) {
|
| 3879 | - foreach($rows as $row) {
|
|
| 3879 | + foreach ($rows as $row) {
|
|
| 3880 | 3880 | if (!empty($row->site_title)) |
| 3881 | 3881 | $translation_texts[] = stripslashes_deep($row->site_title); |
| 3882 | 3882 | |
@@ -3890,11 +3890,11 @@ discard block |
||
| 3890 | 3890 | |
| 3891 | 3891 | // Advance search filter fields table |
| 3892 | 3892 | if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
|
| 3893 | - $sql = "SELECT field_site_name, front_search_title, field_desc FROM " . GEODIR_ADVANCE_SEARCH_TABLE; |
|
| 3893 | + $sql = "SELECT field_site_name, front_search_title, field_desc FROM ".GEODIR_ADVANCE_SEARCH_TABLE; |
|
| 3894 | 3894 | $rows = $wpdb->get_results($sql); |
| 3895 | 3895 | |
| 3896 | 3896 | if (!empty($rows)) {
|
| 3897 | - foreach($rows as $row) {
|
|
| 3897 | + foreach ($rows as $row) {
|
|
| 3898 | 3898 | if (!empty($row->field_site_name)) |
| 3899 | 3899 | $translation_texts[] = stripslashes_deep($row->field_site_name); |
| 3900 | 3900 | |
@@ -3929,7 +3929,7 @@ discard block |
||
| 3929 | 3929 | * |
| 3930 | 3930 | * @param array $geodir_allowed_mime_types and file extensions. |
| 3931 | 3931 | */ |
| 3932 | - return apply_filters( 'geodir_allowed_mime_types', array( |
|
| 3932 | + return apply_filters('geodir_allowed_mime_types', array(
|
|
| 3933 | 3933 | 'Image' => array( // Image formats. |
| 3934 | 3934 | 'jpg' => 'image/jpeg', |
| 3935 | 3935 | 'jpe' => 'image/jpeg', |
@@ -4018,13 +4018,13 @@ discard block |
||
| 4018 | 4018 | |
| 4019 | 4019 | |
| 4020 | 4020 | |
| 4021 | -add_filter('wpseo_replacements','geodir_wpseo_replacements',10,1);
|
|
| 4021 | +add_filter('wpseo_replacements', 'geodir_wpseo_replacements', 10, 1);
|
|
| 4022 | 4022 | /* |
| 4023 | 4023 | * Add location variables to wpseo replacements. |
| 4024 | 4024 | * |
| 4025 | 4025 | * @since 1.5.4 |
| 4026 | 4026 | */ |
| 4027 | -function geodir_wpseo_replacements($vars){
|
|
| 4027 | +function geodir_wpseo_replacements($vars) {
|
|
| 4028 | 4028 | |
| 4029 | 4029 | global $wp; |
| 4030 | 4030 | $title = ''; |
@@ -4039,12 +4039,12 @@ discard block |
||
| 4039 | 4039 | * @param array $location_array The array of location variables. |
| 4040 | 4040 | * @param array $vars The page title variables. |
| 4041 | 4041 | */ |
| 4042 | - $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
|
|
| 4042 | + $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo', $location_array, $vars);
|
|
| 4043 | 4043 | $location_titles = array(); |
| 4044 | - if(get_query_var( 'gd_country_full' )){
|
|
| 4045 | - if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
|
|
| 4046 | - if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
|
|
| 4047 | - if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
|
|
| 4044 | + if (get_query_var('gd_country_full')) {
|
|
| 4045 | + if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
|
|
| 4046 | + if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
|
|
| 4047 | + if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
|
|
| 4048 | 4048 | } |
| 4049 | 4049 | $location_single = ''; |
| 4050 | 4050 | $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
@@ -4116,23 +4116,23 @@ discard block |
||
| 4116 | 4116 | } |
| 4117 | 4117 | |
| 4118 | 4118 | |
| 4119 | - if(!empty($location_titles)) {
|
|
| 4119 | + if (!empty($location_titles)) {
|
|
| 4120 | 4120 | $vars['%%location%%'] = implode(", ", $location_titles);
|
| 4121 | 4121 | } |
| 4122 | 4122 | |
| 4123 | 4123 | |
| 4124 | - if(!empty($location_titles)) {
|
|
| 4125 | - $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
|
|
| 4124 | + if (!empty($location_titles)) {
|
|
| 4125 | + $vars['%%in_location%%'] = __('in ', 'geodirectory').implode(", ", $location_titles);
|
|
| 4126 | 4126 | } |
| 4127 | 4127 | |
| 4128 | 4128 | |
| 4129 | 4129 | |
| 4130 | - if($location_single) {
|
|
| 4131 | - $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
|
|
| 4130 | + if ($location_single) {
|
|
| 4131 | + $vars['%%in_location_single%%'] = __('in', 'geodirectory').' '.$location_single;
|
|
| 4132 | 4132 | } |
| 4133 | 4133 | |
| 4134 | 4134 | |
| 4135 | - if($location_single) {
|
|
| 4135 | + if ($location_single) {
|
|
| 4136 | 4136 | $vars['%%location_single%%'] = $location_single; |
| 4137 | 4137 | } |
| 4138 | 4138 | |
@@ -4144,17 +4144,17 @@ discard block |
||
| 4144 | 4144 | * @param string $vars The title with variables. |
| 4145 | 4145 | * @param array $location_array The array of location variables. |
| 4146 | 4146 | */ |
| 4147 | - return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
|
|
| 4147 | + return apply_filters('geodir_wpseo_replacements_vars', $vars, $location_array);
|
|
| 4148 | 4148 | } |
| 4149 | 4149 | |
| 4150 | 4150 | |
| 4151 | -add_filter('geodir_seo_meta_title','geodir_filter_title_variables',10,3);
|
|
| 4152 | -add_filter('geodir_seo_page_title','geodir_filter_title_variables',10,2);
|
|
| 4153 | -add_filter('geodir_seo_meta_description_pre','geodir_filter_title_variables',10,3);
|
|
| 4154 | -function geodir_filter_title_variables($title, $gd_page, $sep=''){
|
|
| 4151 | +add_filter('geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3);
|
|
| 4152 | +add_filter('geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2);
|
|
| 4153 | +add_filter('geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3);
|
|
| 4154 | +function geodir_filter_title_variables($title, $gd_page, $sep = '') {
|
|
| 4155 | 4155 | |
| 4156 | 4156 | |
| 4157 | - if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
|
|
| 4157 | + if (!$gd_page || !$title) {return $title; }// if no a GD page then bail.
|
|
| 4158 | 4158 | global $post; |
| 4159 | 4159 | //print_r($post); |
| 4160 | 4160 | /* |
@@ -4196,123 +4196,123 @@ discard block |
||
| 4196 | 4196 | } |
| 4197 | 4197 | |
| 4198 | 4198 | |
| 4199 | - if(strpos($title,'%%title%%') !== false){
|
|
| 4200 | - $title = str_replace("%%title%%",$post->post_title,$title);
|
|
| 4199 | + if (strpos($title, '%%title%%') !== false) {
|
|
| 4200 | + $title = str_replace("%%title%%", $post->post_title, $title);
|
|
| 4201 | 4201 | } |
| 4202 | 4202 | |
| 4203 | - if(strpos($title,'%%sitename%%') !== false){
|
|
| 4204 | - $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
|
|
| 4203 | + if (strpos($title, '%%sitename%%') !== false) {
|
|
| 4204 | + $title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
|
|
| 4205 | 4205 | } |
| 4206 | 4206 | |
| 4207 | - if(strpos($title,'%%sitedesc%%') !== false){
|
|
| 4208 | - $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
|
|
| 4207 | + if (strpos($title, '%%sitedesc%%') !== false) {
|
|
| 4208 | + $title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
|
|
| 4209 | 4209 | } |
| 4210 | 4210 | |
| 4211 | - if(strpos($title,'%%excerpt%%') !== false){
|
|
| 4212 | - $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
|
|
| 4211 | + if (strpos($title, '%%excerpt%%') !== false) {
|
|
| 4212 | + $title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
|
|
| 4213 | 4213 | } |
| 4214 | 4214 | |
| 4215 | - if(strpos($title,'%%pt_single%%') !== false){
|
|
| 4215 | + if (strpos($title, '%%pt_single%%') !== false) {
|
|
| 4216 | 4216 | $single_name = ''; |
| 4217 | - if($gd_page=='search' || $gd_page=='author'){
|
|
| 4217 | + if ($gd_page == 'search' || $gd_page == 'author') {
|
|
| 4218 | 4218 | $geodir_post_types = get_option('geodir_post_types');
|
| 4219 | 4219 | $spt = esc_attr($_REQUEST['stype']); |
| 4220 | - if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
|
| 4221 | - $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
|
| 4220 | + if (isset($geodir_post_types[$spt]['labels']['singular_name'])) {
|
|
| 4221 | + $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory'); |
|
| 4222 | 4222 | } |
| 4223 | - }elseif($gd_page=='add-listing'){
|
|
| 4223 | + }elseif ($gd_page == 'add-listing') {
|
|
| 4224 | 4224 | $geodir_post_types = get_option('geodir_post_types');
|
| 4225 | 4225 | $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : ''; |
| 4226 | - if(!$spt && isset($_REQUEST['pid'])){
|
|
| 4227 | - $spt = get_post_type( $_REQUEST['pid'] ); |
|
| 4226 | + if (!$spt && isset($_REQUEST['pid'])) {
|
|
| 4227 | + $spt = get_post_type($_REQUEST['pid']); |
|
| 4228 | 4228 | } |
| 4229 | - if(!$spt){$spt='gd_place';}
|
|
| 4230 | - if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
|
| 4231 | - $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
|
| 4229 | + if (!$spt) {$spt = 'gd_place'; }
|
|
| 4230 | + if (isset($geodir_post_types[$spt]['labels']['singular_name'])) {
|
|
| 4231 | + $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory'); |
|
| 4232 | 4232 | } |
| 4233 | 4233 | } |
| 4234 | - elseif($post->post_type){
|
|
| 4234 | + elseif ($post->post_type) {
|
|
| 4235 | 4235 | $geodir_post_types = get_option('geodir_post_types');
|
| 4236 | - if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
|
|
| 4237 | - $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory'); |
|
| 4236 | + if (isset($geodir_post_types[$post->post_type]['labels']['singular_name'])) {
|
|
| 4237 | + $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'], 'geodirectory'); |
|
| 4238 | 4238 | } |
| 4239 | 4239 | |
| 4240 | 4240 | |
| 4241 | 4241 | } |
| 4242 | - $title = str_replace("%%pt_single%%",$single_name,$title);
|
|
| 4242 | + $title = str_replace("%%pt_single%%", $single_name, $title);
|
|
| 4243 | 4243 | } |
| 4244 | 4244 | |
| 4245 | - if(strpos($title,'%%pt_plural%%') !== false){
|
|
| 4245 | + if (strpos($title, '%%pt_plural%%') !== false) {
|
|
| 4246 | 4246 | $plural_name = ''; |
| 4247 | - if($gd_page=='search' || $gd_page=='author'){
|
|
| 4247 | + if ($gd_page == 'search' || $gd_page == 'author') {
|
|
| 4248 | 4248 | $geodir_post_types = get_option('geodir_post_types');
|
| 4249 | 4249 | $spt = esc_attr($_REQUEST['stype']); |
| 4250 | - if(isset($geodir_post_types[$spt]['labels']['name'])){
|
|
| 4251 | - $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
|
| 4250 | + if (isset($geodir_post_types[$spt]['labels']['name'])) {
|
|
| 4251 | + $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory'); |
|
| 4252 | 4252 | } |
| 4253 | - }elseif($gd_page=='add-listing'){
|
|
| 4253 | + }elseif ($gd_page == 'add-listing') {
|
|
| 4254 | 4254 | $geodir_post_types = get_option('geodir_post_types');
|
| 4255 | 4255 | $spt = sanitize_text_field($_REQUEST['listing_type']); |
| 4256 | - if(!$spt){$spt='gd_place';}
|
|
| 4257 | - if(isset($geodir_post_types[$spt]['labels']['name'])){
|
|
| 4258 | - $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
|
| 4256 | + if (!$spt) {$spt = 'gd_place'; }
|
|
| 4257 | + if (isset($geodir_post_types[$spt]['labels']['name'])) {
|
|
| 4258 | + $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory'); |
|
| 4259 | 4259 | } |
| 4260 | 4260 | } |
| 4261 | - elseif(isset($post->post_type) && $post->post_type){
|
|
| 4261 | + elseif (isset($post->post_type) && $post->post_type) {
|
|
| 4262 | 4262 | $geodir_post_types = get_option('geodir_post_types');
|
| 4263 | - if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
|
|
| 4264 | - $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory'); |
|
| 4263 | + if (isset($geodir_post_types[$post->post_type]['labels']['name'])) {
|
|
| 4264 | + $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'], 'geodirectory'); |
|
| 4265 | 4265 | } |
| 4266 | 4266 | |
| 4267 | 4267 | } |
| 4268 | - $title = str_replace("%%pt_plural%%",$plural_name,$title);
|
|
| 4268 | + $title = str_replace("%%pt_plural%%", $plural_name, $title);
|
|
| 4269 | 4269 | } |
| 4270 | 4270 | |
| 4271 | 4271 | |
| 4272 | 4272 | |
| 4273 | - if(strpos($title,'%%category%%') !== false){
|
|
| 4273 | + if (strpos($title, '%%category%%') !== false) {
|
|
| 4274 | 4274 | $cat_name = ''; |
| 4275 | 4275 | |
| 4276 | - if($gd_page=='detail') {
|
|
| 4276 | + if ($gd_page == 'detail') {
|
|
| 4277 | 4277 | if ($post->default_category) {
|
| 4278 | - $cat = get_term($post->default_category, $post->post_type . 'category'); |
|
| 4278 | + $cat = get_term($post->default_category, $post->post_type.'category'); |
|
| 4279 | 4279 | $cat_name = (isset($cat->name)) ? $cat->name : ''; |
| 4280 | 4280 | } |
| 4281 | - }elseif($gd_page=='listing'){
|
|
| 4281 | + }elseif ($gd_page == 'listing') {
|
|
| 4282 | 4282 | $queried_object = get_queried_object(); |
| 4283 | - if(isset($queried_object->name)){
|
|
| 4283 | + if (isset($queried_object->name)) {
|
|
| 4284 | 4284 | $cat_name = $queried_object->name; |
| 4285 | 4285 | } |
| 4286 | 4286 | } |
| 4287 | - $title = str_replace("%%category%%",$cat_name,$title);
|
|
| 4287 | + $title = str_replace("%%category%%", $cat_name, $title);
|
|
| 4288 | 4288 | } |
| 4289 | 4289 | |
| 4290 | - if(strpos($title,'%%tag%%') !== false){
|
|
| 4290 | + if (strpos($title, '%%tag%%') !== false) {
|
|
| 4291 | 4291 | $cat_name = ''; |
| 4292 | 4292 | |
| 4293 | - if($gd_page=='detail') {
|
|
| 4293 | + if ($gd_page == 'detail') {
|
|
| 4294 | 4294 | if ($post->default_category) {
|
| 4295 | - $cat = get_term($post->default_category, $post->post_type . 'category'); |
|
| 4295 | + $cat = get_term($post->default_category, $post->post_type.'category'); |
|
| 4296 | 4296 | $cat_name = (isset($cat->name)) ? $cat->name : ''; |
| 4297 | 4297 | } |
| 4298 | - }elseif($gd_page=='listing'){
|
|
| 4298 | + }elseif ($gd_page == 'listing') {
|
|
| 4299 | 4299 | $queried_object = get_queried_object(); |
| 4300 | - if(isset($queried_object->name)){
|
|
| 4300 | + if (isset($queried_object->name)) {
|
|
| 4301 | 4301 | $cat_name = $queried_object->name; |
| 4302 | 4302 | } |
| 4303 | 4303 | } |
| 4304 | - $title = str_replace("%%tag%%",$cat_name,$title);
|
|
| 4304 | + $title = str_replace("%%tag%%", $cat_name, $title);
|
|
| 4305 | 4305 | } |
| 4306 | 4306 | |
| 4307 | 4307 | |
| 4308 | 4308 | |
| 4309 | - if(strpos($title,'%%id%%') !== false){
|
|
| 4309 | + if (strpos($title, '%%id%%') !== false) {
|
|
| 4310 | 4310 | $ID = (isset($post->ID)) ? $post->ID : ''; |
| 4311 | - $title = str_replace("%%id%%",$ID,$title);
|
|
| 4311 | + $title = str_replace("%%id%%", $ID, $title);
|
|
| 4312 | 4312 | } |
| 4313 | 4313 | |
| 4314 | - if(strpos($title,'%%sep%%') !== false){
|
|
| 4315 | - $title = str_replace("%%sep%%",$sep,$title);
|
|
| 4314 | + if (strpos($title, '%%sep%%') !== false) {
|
|
| 4315 | + $title = str_replace("%%sep%%", $sep, $title);
|
|
| 4316 | 4316 | } |
| 4317 | 4317 | |
| 4318 | 4318 | |
@@ -4330,12 +4330,12 @@ discard block |
||
| 4330 | 4330 | * @param string $gd_page The page being filtered. |
| 4331 | 4331 | * @param string $sep The separator, default: `|`. |
| 4332 | 4332 | */ |
| 4333 | - $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
|
|
| 4333 | + $location_array = apply_filters('geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep);
|
|
| 4334 | 4334 | $location_titles = array(); |
| 4335 | - if($gd_page=='location' && get_query_var( 'gd_country_full' )){
|
|
| 4336 | - if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
|
|
| 4337 | - if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
|
|
| 4338 | - if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
|
|
| 4335 | + if ($gd_page == 'location' && get_query_var('gd_country_full')) {
|
|
| 4336 | + if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
|
|
| 4337 | + if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
|
|
| 4338 | + if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
|
|
| 4339 | 4339 | } |
| 4340 | 4340 | $location_single = ''; |
| 4341 | 4341 | $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
@@ -4407,51 +4407,51 @@ discard block |
||
| 4407 | 4407 | } |
| 4408 | 4408 | |
| 4409 | 4409 | |
| 4410 | - if(strpos($title,'%%location%%') !== false){
|
|
| 4410 | + if (strpos($title, '%%location%%') !== false) {
|
|
| 4411 | 4411 | $location = ''; |
| 4412 | - if($location_titles) {
|
|
| 4412 | + if ($location_titles) {
|
|
| 4413 | 4413 | $location = implode(", ", $location_titles);
|
| 4414 | 4414 | } |
| 4415 | - $title = str_replace("%%location%%",$location,$title);
|
|
| 4415 | + $title = str_replace("%%location%%", $location, $title);
|
|
| 4416 | 4416 | } |
| 4417 | 4417 | |
| 4418 | - if(strpos($title,'%%in_location%%') !== false){
|
|
| 4418 | + if (strpos($title, '%%in_location%%') !== false) {
|
|
| 4419 | 4419 | $location = ''; |
| 4420 | - if($location_titles) {
|
|
| 4421 | - $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
|
|
| 4420 | + if ($location_titles) {
|
|
| 4421 | + $location = __('in ', 'geodirectory').implode(", ", $location_titles);
|
|
| 4422 | 4422 | } |
| 4423 | - $title = str_replace("%%in_location%%",$location,$title);
|
|
| 4423 | + $title = str_replace("%%in_location%%", $location, $title);
|
|
| 4424 | 4424 | } |
| 4425 | 4425 | |
| 4426 | - if(strpos($title,'%%in_location_single%%') !== false){
|
|
| 4427 | - if($location_single) {
|
|
| 4428 | - $location_single = __('in', 'geodirectory') . ' ' .$location_single;
|
|
| 4426 | + if (strpos($title, '%%in_location_single%%') !== false) {
|
|
| 4427 | + if ($location_single) {
|
|
| 4428 | + $location_single = __('in', 'geodirectory').' '.$location_single;
|
|
| 4429 | 4429 | } |
| 4430 | - $title = str_replace("%%in_location_single%%",$location_single,$title);
|
|
| 4430 | + $title = str_replace("%%in_location_single%%", $location_single, $title);
|
|
| 4431 | 4431 | } |
| 4432 | 4432 | |
| 4433 | - if(strpos($title,'%%location_single%%') !== false){
|
|
| 4434 | - $title = str_replace("%%location_single%%",$location_single,$title);
|
|
| 4433 | + if (strpos($title, '%%location_single%%') !== false) {
|
|
| 4434 | + $title = str_replace("%%location_single%%", $location_single, $title);
|
|
| 4435 | 4435 | } |
| 4436 | 4436 | |
| 4437 | 4437 | |
| 4438 | - if(strpos($title,'%%search_term%%') !== false){
|
|
| 4438 | + if (strpos($title, '%%search_term%%') !== false) {
|
|
| 4439 | 4439 | $search_term = ''; |
| 4440 | - if(isset($_REQUEST['s'])){
|
|
| 4440 | + if (isset($_REQUEST['s'])) {
|
|
| 4441 | 4441 | $search_term = esc_attr($_REQUEST['s']); |
| 4442 | 4442 | } |
| 4443 | - $title = str_replace("%%search_term%%",$search_term,$title);
|
|
| 4443 | + $title = str_replace("%%search_term%%", $search_term, $title);
|
|
| 4444 | 4444 | } |
| 4445 | 4445 | |
| 4446 | - if(strpos($title,'%%search_near%%') !== false){
|
|
| 4446 | + if (strpos($title, '%%search_near%%') !== false) {
|
|
| 4447 | 4447 | $search_term = ''; |
| 4448 | - if(isset($_REQUEST['snear'])){
|
|
| 4448 | + if (isset($_REQUEST['snear'])) {
|
|
| 4449 | 4449 | $search_term = esc_attr($_REQUEST['snear']); |
| 4450 | 4450 | } |
| 4451 | - $title = str_replace("%%search_near%%",$search_term,$title);
|
|
| 4451 | + $title = str_replace("%%search_near%%", $search_term, $title);
|
|
| 4452 | 4452 | } |
| 4453 | 4453 | |
| 4454 | - if(strpos($title,'%%name%%') !== false){
|
|
| 4454 | + if (strpos($title, '%%name%%') !== false) {
|
|
| 4455 | 4455 | $author_name = get_the_author(); |
| 4456 | 4456 | if (!$author_name || $author_name === '') {
|
| 4457 | 4457 | $queried_object = get_queried_object(); |
@@ -4476,9 +4476,9 @@ discard block |
||
| 4476 | 4476 | $title = str_replace("%%pagetotal%%", $pagetotal, $title);
|
| 4477 | 4477 | } |
| 4478 | 4478 | |
| 4479 | - $title = wptexturize( $title ); |
|
| 4480 | - $title = convert_chars( $title ); |
|
| 4481 | - $title = esc_html( $title ); |
|
| 4479 | + $title = wptexturize($title); |
|
| 4480 | + $title = convert_chars($title); |
|
| 4481 | + $title = esc_html($title); |
|
| 4482 | 4482 | |
| 4483 | 4483 | /** |
| 4484 | 4484 | * Filter the title variables after standard ones have been filtered. |
@@ -4491,7 +4491,7 @@ discard block |
||
| 4491 | 4491 | * @param string $sep The separator, default: `|`. |
| 4492 | 4492 | */ |
| 4493 | 4493 | |
| 4494 | - return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
|
|
| 4494 | + return apply_filters('geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep);
|
|
| 4495 | 4495 | } |
| 4496 | 4496 | |
| 4497 | 4497 | /** |
@@ -4614,7 +4614,7 @@ discard block |
||
| 4614 | 4614 | } |
| 4615 | 4615 | |
| 4616 | 4616 | $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : ''; |
| 4617 | - $is_admin = is_admin() && ( !defined('DOING_AJAX' ) || ( defined('DOING_AJAX') && !DOING_AJAX ) ) ? true : false;
|
|
| 4617 | + $is_admin = is_admin() && (!defined('DOING_AJAX') || (defined('DOING_AJAX') && !DOING_AJAX)) ? true : false;
|
|
| 4618 | 4618 | $inline_save = $action == 'inline-save' ? true : false; |
| 4619 | 4619 | |
| 4620 | 4620 | if (empty($post->post_type) || $is_admin || $inline_save || (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)) {
|
@@ -4625,7 +4625,7 @@ discard block |
||
| 4625 | 4625 | return; |
| 4626 | 4626 | } |
| 4627 | 4627 | |
| 4628 | - $user_id = (int)get_current_user_id(); |
|
| 4628 | + $user_id = (int) get_current_user_id(); |
|
| 4629 | 4629 | |
| 4630 | 4630 | if ($user_id > 0 && get_option('geodir_notify_post_edited') && !wp_is_post_revision($post_ID) && in_array($post->post_type, geodir_get_posttypes())) {
|
| 4631 | 4631 | $author_id = !empty($post->post_author) ? $post->post_author : 0; |
@@ -4669,7 +4669,7 @@ discard block |
||
| 4669 | 4669 | $nr = geodir_title_meta_pagenumbering('nr');
|
| 4670 | 4670 | |
| 4671 | 4671 | if ($max > 1 && $nr > 1) {
|
| 4672 | - $replacement = sprintf($sep . ' ' . __('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
|
|
| 4672 | + $replacement = sprintf($sep.' '.__('Page %1$d of %2$d', 'geodirectory'), $nr, $max);
|
|
| 4673 | 4673 | } |
| 4674 | 4674 | |
| 4675 | 4675 | return $replacement; |
@@ -4688,7 +4688,7 @@ discard block |
||
| 4688 | 4688 | |
| 4689 | 4689 | $nr = geodir_title_meta_pagenumbering('nr');
|
| 4690 | 4690 | if (isset($nr) && $nr > 0) {
|
| 4691 | - $replacement = (string)$nr; |
|
| 4691 | + $replacement = (string) $nr; |
|
| 4692 | 4692 | } |
| 4693 | 4693 | |
| 4694 | 4694 | return $replacement; |
@@ -4707,7 +4707,7 @@ discard block |
||
| 4707 | 4707 | |
| 4708 | 4708 | $max = geodir_title_meta_pagenumbering('max');
|
| 4709 | 4709 | if (isset($max) && $max > 0) {
|
| 4710 | - $replacement = (string)$max; |
|
| 4710 | + $replacement = (string) $max; |
|
| 4711 | 4711 | } |
| 4712 | 4712 | |
| 4713 | 4713 | return $replacement; |
@@ -4749,7 +4749,7 @@ discard block |
||
| 4749 | 4749 | } |
| 4750 | 4750 | |
| 4751 | 4751 | if (isset($post->post_content)) {
|
| 4752 | - $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->' ) + 1); |
|
| 4752 | + $max_num_pages = (substr_count($post->post_content, '<!--nextpage-->') + 1); |
|
| 4753 | 4753 | } |
| 4754 | 4754 | } |
| 4755 | 4755 | |
@@ -30,8 +30,10 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | if (is_ssl()) : |
| 32 | 32 | return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename(dirname(dirname(__FILE__)));
|
| 33 | - else : |
|
| 34 | - return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__))); |
|
| 33 | + else { |
|
| 34 | + : |
|
| 35 | + return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__))); |
|
| 36 | + } |
|
| 35 | 37 | endif; |
| 36 | 38 | } |
| 37 | 39 | |
@@ -67,7 +69,9 @@ discard block |
||
| 67 | 69 | {
|
| 68 | 70 | $active_plugins = get_option('active_plugins');
|
| 69 | 71 | foreach ($active_plugins as $key => $active_plugin) {
|
| 70 | - if (strstr($active_plugin, $plugin)) return true; |
|
| 72 | + if (strstr($active_plugin, $plugin)) { |
|
| 73 | + return true; |
|
| 74 | + } |
|
| 71 | 75 | } |
| 72 | 76 | return false; |
| 73 | 77 | } |
@@ -118,12 +122,25 @@ discard block |
||
| 118 | 122 | */ |
| 119 | 123 | function geodir_getlink($url, $params = array(), $use_existing_arguments = false) |
| 120 | 124 | {
|
| 121 | - if ($use_existing_arguments) $params = $params + $_GET; |
|
| 122 | - if (!$params) return $url; |
|
| 125 | + if ($use_existing_arguments) { |
|
| 126 | + $params = $params + $_GET; |
|
| 127 | + } |
|
| 128 | + if (!$params) { |
|
| 129 | + return $url; |
|
| 130 | + } |
|
| 123 | 131 | $link = $url; |
| 124 | - if (strpos($link, '?') === false) $link .= '?'; //If there is no '?' add one at the end |
|
| 125 | - elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) $link .= '&'; //If there is no '&' at the END, add one. |
|
| 126 | - elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) $link .= '&'; //If there is no '&' at the END, add one.
|
|
| 132 | + if (strpos($link, '?') === false) { |
|
| 133 | + $link .= '?'; |
|
| 134 | + } |
|
| 135 | + //If there is no '?' add one at the end |
|
| 136 | + elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) { |
|
| 137 | + $link .= '&'; |
|
| 138 | + } |
|
| 139 | + //If there is no '&' at the END, add one. |
|
| 140 | + elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) { |
|
| 141 | + $link .= '&'; |
|
| 142 | + } |
|
| 143 | + //If there is no '&' at the END, add one. |
|
| 127 | 144 | |
| 128 | 145 | $params_arr = array(); |
| 129 | 146 | foreach ($params as $key => $value) {
|
@@ -161,9 +178,10 @@ discard block |
||
| 161 | 178 | $add_listing_link = get_page_link(geodir_add_listing_page_id()); |
| 162 | 179 | |
| 163 | 180 | return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
|
| 164 | - } else |
|
| 165 | - return get_bloginfo('url');
|
|
| 166 | -} |
|
| 181 | + } else { |
|
| 182 | + return get_bloginfo('url'); |
|
| 183 | + } |
|
| 184 | + } |
|
| 167 | 185 | |
| 168 | 186 | /** |
| 169 | 187 | * Get the current page URL. |
@@ -268,24 +286,28 @@ discard block |
||
| 268 | 286 | case 'preview': |
| 269 | 287 | if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
|
| 270 | 288 | && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) |
| 271 | - ) |
|
| 272 | - return true; |
|
| 289 | + ) { |
|
| 290 | + return true; |
|
| 291 | + } |
|
| 273 | 292 | break; |
| 274 | 293 | case 'listing-success': |
| 275 | - if (is_page() && get_query_var('page_id') == geodir_success_page_id())
|
|
| 276 | - return true; |
|
| 294 | + if (is_page() && get_query_var('page_id') == geodir_success_page_id()) { |
|
| 295 | + return true; |
|
| 296 | + } |
|
| 277 | 297 | break; |
| 278 | 298 | case 'detail': |
| 279 | 299 | $post_type = get_query_var('post_type');
|
| 280 | 300 | if(is_array($post_type)){$post_type = reset($post_type);}
|
| 281 | - if (is_single() && in_array($post_type, geodir_get_posttypes())) |
|
| 282 | - return true; |
|
| 301 | + if (is_single() && in_array($post_type, geodir_get_posttypes())) { |
|
| 302 | + return true; |
|
| 303 | + } |
|
| 283 | 304 | break; |
| 284 | 305 | case 'pt': |
| 285 | 306 | $post_type = get_query_var('post_type');
|
| 286 | 307 | if(is_array($post_type)){$post_type = reset($post_type);}
|
| 287 | - if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax()) |
|
| 288 | - return true; |
|
| 308 | + if (is_post_type_archive() && in_array($post_type , geodir_get_posttypes()) && !is_tax()) { |
|
| 309 | + return true; |
|
| 310 | + } |
|
| 289 | 311 | |
| 290 | 312 | break; |
| 291 | 313 | case 'listing': |
@@ -296,23 +318,27 @@ discard block |
||
| 296 | 318 | } |
| 297 | 319 | $post_type = get_query_var('post_type');
|
| 298 | 320 | if(is_array($post_type)){$post_type = reset($post_type);}
|
| 299 | - if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes())) |
|
| 300 | - return true; |
|
| 321 | + if (is_post_type_archive() && in_array($post_type, geodir_get_posttypes())) { |
|
| 322 | + return true; |
|
| 323 | + } |
|
| 301 | 324 | |
| 302 | 325 | break; |
| 303 | 326 | case 'home': |
| 304 | 327 | |
| 305 | - if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
|
|
| 306 | - return true; |
|
| 328 | + if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home()) { |
|
| 329 | + return true; |
|
| 330 | + } |
|
| 307 | 331 | |
| 308 | 332 | break; |
| 309 | 333 | case 'location': |
| 310 | - if (is_page() && get_query_var('page_id') == geodir_location_page_id())
|
|
| 311 | - return true; |
|
| 334 | + if (is_page() && get_query_var('page_id') == geodir_location_page_id()) { |
|
| 335 | + return true; |
|
| 336 | + } |
|
| 312 | 337 | break; |
| 313 | 338 | case 'author': |
| 314 | - if (is_author() && isset($_REQUEST['geodir_dashbord'])) |
|
| 315 | - return true; |
|
| 339 | + if (is_author() && isset($_REQUEST['geodir_dashbord'])) { |
|
| 340 | + return true; |
|
| 341 | + } |
|
| 316 | 342 | |
| 317 | 343 | if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
|
| 318 | 344 | if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
|
@@ -321,24 +347,29 @@ discard block |
||
| 321 | 347 | } |
| 322 | 348 | break; |
| 323 | 349 | case 'search': |
| 324 | - if (is_search() && isset($_REQUEST['geodir_search'])) |
|
| 325 | - return true; |
|
| 350 | + if (is_search() && isset($_REQUEST['geodir_search'])) { |
|
| 351 | + return true; |
|
| 352 | + } |
|
| 326 | 353 | break; |
| 327 | 354 | case 'info': |
| 328 | - if (is_page() && get_query_var('page_id') == geodir_info_page_id())
|
|
| 329 | - return true; |
|
| 355 | + if (is_page() && get_query_var('page_id') == geodir_info_page_id()) { |
|
| 356 | + return true; |
|
| 357 | + } |
|
| 330 | 358 | break; |
| 331 | 359 | case 'login': |
| 332 | - if (is_page() && get_query_var('page_id') == geodir_login_page_id())
|
|
| 333 | - return true; |
|
| 360 | + if (is_page() && get_query_var('page_id') == geodir_login_page_id()) { |
|
| 361 | + return true; |
|
| 362 | + } |
|
| 334 | 363 | break; |
| 335 | 364 | case 'checkout': |
| 336 | - if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
|
|
| 337 | - return true; |
|
| 365 | + if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id()) { |
|
| 366 | + return true; |
|
| 367 | + } |
|
| 338 | 368 | break; |
| 339 | 369 | case 'invoices': |
| 340 | - if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
|
|
| 341 | - return true; |
|
| 370 | + if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id()) { |
|
| 371 | + return true; |
|
| 372 | + } |
|
| 342 | 373 | break; |
| 343 | 374 | default: |
| 344 | 375 | return false; |
@@ -366,8 +397,9 @@ discard block |
||
| 366 | 397 | //$wp->query_vars['gd_is_geodir_page'] = false; |
| 367 | 398 | //print_r() |
| 368 | 399 | if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
|
| 369 | - if (get_option('geodir_set_as_home'))
|
|
| 370 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 400 | + if (get_option('geodir_set_as_home')) { |
|
| 401 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 402 | + } |
|
| 371 | 403 | if(geodir_is_page('home')){
|
| 372 | 404 | $wp->query_vars['gd_is_geodir_page'] = true; |
| 373 | 405 | } |
@@ -386,8 +418,9 @@ discard block |
||
| 386 | 418 | || $wp->query_vars['page_id'] == geodir_login_page_id() |
| 387 | 419 | || (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
|
| 388 | 420 | || (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
|
| 389 | - ) |
|
| 390 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 421 | + ) { |
|
| 422 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 423 | + } |
|
| 391 | 424 | } |
| 392 | 425 | |
| 393 | 426 | if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
|
@@ -404,8 +437,9 @@ discard block |
||
| 404 | 437 | || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
|
| 405 | 438 | || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
|
| 406 | 439 | ) |
| 407 | - ) |
|
| 408 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 440 | + ) { |
|
| 441 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 442 | + } |
|
| 409 | 443 | } |
| 410 | 444 | |
| 411 | 445 | |
@@ -431,12 +465,14 @@ discard block |
||
| 431 | 465 | |
| 432 | 466 | } |
| 433 | 467 | |
| 434 | - if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord'])) |
|
| 435 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 468 | + if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord'])) { |
|
| 469 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 470 | + } |
|
| 436 | 471 | |
| 437 | 472 | |
| 438 | - if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) |
|
| 439 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 473 | + if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) { |
|
| 474 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 475 | + } |
|
| 440 | 476 | |
| 441 | 477 | |
| 442 | 478 | //check if homepage |
@@ -466,11 +502,12 @@ discard block |
||
| 466 | 502 | function geodir_is_geodir_page() |
| 467 | 503 | {
|
| 468 | 504 | global $wp; |
| 469 | - if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page']) |
|
| 470 | - return true; |
|
| 471 | - else |
|
| 472 | - return false; |
|
| 473 | -} |
|
| 505 | + if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page']) { |
|
| 506 | + return true; |
|
| 507 | + } else { |
|
| 508 | + return false; |
|
| 509 | + } |
|
| 510 | + } |
|
| 474 | 511 | |
| 475 | 512 | if (!function_exists('geodir_get_imagesize')) {
|
| 476 | 513 | /** |
@@ -848,20 +885,16 @@ discard block |
||
| 848 | 885 | $subject .= ' - ADMIN BCC COPY'; |
| 849 | 886 | $admin_bcc = true; |
| 850 | 887 | |
| 851 | - } |
|
| 852 | - elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
|
|
| 888 | + } elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
|
|
| 853 | 889 | $subject .= ' - ADMIN BCC COPY'; |
| 854 | 890 | $admin_bcc = true; |
| 855 | - } |
|
| 856 | - elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
|
|
| 891 | + } elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
|
|
| 857 | 892 | $subject .= ' - ADMIN BCC COPY'; |
| 858 | 893 | $admin_bcc = true; |
| 859 | - } |
|
| 860 | - elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
|
|
| 894 | + } elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
|
|
| 861 | 895 | $subject .= ' - ADMIN BCC COPY'; |
| 862 | 896 | $admin_bcc = true; |
| 863 | - } |
|
| 864 | - elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
|
|
| 897 | + } elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
|
|
| 865 | 898 | $subject .= ' - ADMIN BCC COPY'; |
| 866 | 899 | $admin_bcc = true; |
| 867 | 900 | } |
@@ -1030,21 +1063,24 @@ discard block |
||
| 1030 | 1063 | $is_location_last = ''; |
| 1031 | 1064 | $is_taxonomy_last = ''; |
| 1032 | 1065 | $breadcrumb .= '<li>'; |
| 1033 | - if (get_query_var($gd_post_type . 'category')) |
|
| 1034 | - $gd_taxonomy = $gd_post_type . 'category'; |
|
| 1035 | - elseif (get_query_var($gd_post_type . '_tags')) |
|
| 1036 | - $gd_taxonomy = $gd_post_type . '_tags'; |
|
| 1066 | + if (get_query_var($gd_post_type . 'category')) { |
|
| 1067 | + $gd_taxonomy = $gd_post_type . 'category'; |
|
| 1068 | + } elseif (get_query_var($gd_post_type . '_tags')) { |
|
| 1069 | + $gd_taxonomy = $gd_post_type . '_tags'; |
|
| 1070 | + } |
|
| 1037 | 1071 | |
| 1038 | 1072 | $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>'; |
| 1039 | - if (!empty($gd_taxonomy) || geodir_is_page('detail'))
|
|
| 1040 | - $is_location_last = false; |
|
| 1041 | - else |
|
| 1042 | - $is_location_last = true; |
|
| 1043 | - |
|
| 1044 | - if (!empty($gd_taxonomy) && geodir_is_page('listing'))
|
|
| 1045 | - $is_taxonomy_last = true; |
|
| 1046 | - else |
|
| 1047 | - $is_taxonomy_last = false; |
|
| 1073 | + if (!empty($gd_taxonomy) || geodir_is_page('detail')) { |
|
| 1074 | + $is_location_last = false; |
|
| 1075 | + } else { |
|
| 1076 | + $is_location_last = true; |
|
| 1077 | + } |
|
| 1078 | + |
|
| 1079 | + if (!empty($gd_taxonomy) && geodir_is_page('listing')) { |
|
| 1080 | + $is_taxonomy_last = true; |
|
| 1081 | + } else { |
|
| 1082 | + $is_taxonomy_last = false; |
|
| 1083 | + } |
|
| 1048 | 1084 | |
| 1049 | 1085 | if (!empty($location_terms)) {
|
| 1050 | 1086 | $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
|
@@ -1126,8 +1162,9 @@ discard block |
||
| 1126 | 1162 | {
|
| 1127 | 1163 | if (get_query_var($gd_post_type . '_tags')) {
|
| 1128 | 1164 | $cat_link = $listing_link . 'tags/'; |
| 1129 | - } else |
|
| 1130 | - $cat_link = $listing_link; |
|
| 1165 | + } else { |
|
| 1166 | + $cat_link = $listing_link; |
|
| 1167 | + } |
|
| 1131 | 1168 | |
| 1132 | 1169 | foreach ($location_terms as $key => $location_term) {
|
| 1133 | 1170 | if ($location_manager && in_array($key, $hide_url_part)) {
|
@@ -1154,9 +1191,9 @@ discard block |
||
| 1154 | 1191 | $term_link_text = geodir_ucwords(urldecode($term_link_text)); |
| 1155 | 1192 | } |
| 1156 | 1193 | |
| 1157 | - if ($term_index == count($term_array) && $is_taxonomy_last) |
|
| 1158 | - $breadcrumb .= $separator . $term_link_text; |
|
| 1159 | - else {
|
|
| 1194 | + if ($term_index == count($term_array) && $is_taxonomy_last) { |
|
| 1195 | + $breadcrumb .= $separator . $term_link_text; |
|
| 1196 | + } else {
|
|
| 1160 | 1197 | $cat_link .= $term . '/'; |
| 1161 | 1198 | $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>'; |
| 1162 | 1199 | } |
@@ -1167,8 +1204,9 @@ discard block |
||
| 1167 | 1204 | |
| 1168 | 1205 | } |
| 1169 | 1206 | |
| 1170 | - if (geodir_is_page('detail'))
|
|
| 1171 | - $breadcrumb .= $separator . get_the_title(); |
|
| 1207 | + if (geodir_is_page('detail')) { |
|
| 1208 | + $breadcrumb .= $separator . get_the_title(); |
|
| 1209 | + } |
|
| 1172 | 1210 | |
| 1173 | 1211 | $breadcrumb .= '</li>'; |
| 1174 | 1212 | |
@@ -1205,8 +1243,9 @@ discard block |
||
| 1205 | 1243 | |
| 1206 | 1244 | $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>'; |
| 1207 | 1245 | $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
|
| 1208 | - } else |
|
| 1209 | - $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory'); |
|
| 1246 | + } else { |
|
| 1247 | + $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory'); |
|
| 1248 | + } |
|
| 1210 | 1249 | |
| 1211 | 1250 | $breadcrumb .= '</li>'; |
| 1212 | 1251 | } elseif (is_category() || is_single()) {
|
@@ -1281,12 +1320,14 @@ discard block |
||
| 1281 | 1320 | function geodir_allow_wpadmin() |
| 1282 | 1321 | {
|
| 1283 | 1322 | global $wpdb; |
| 1284 | - if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
|
|
| 1323 | + if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) { |
|
| 1324 | + // checking action in request to allow ajax request go through |
|
| 1285 | 1325 | {
|
| 1286 | 1326 | if (current_user_can('manage_options')) {
|
| 1287 | 1327 | } else {
|
| 1288 | 1328 | |
| 1289 | - wp_redirect(home_url()); |
|
| 1329 | + wp_redirect(home_url()); |
|
| 1330 | + } |
|
| 1290 | 1331 | exit; |
| 1291 | 1332 | } |
| 1292 | 1333 | |
@@ -1334,8 +1375,9 @@ discard block |
||
| 1334 | 1375 | $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : ''; |
| 1335 | 1376 | |
| 1336 | 1377 | $upload = wp_upload_bits($file_name, 0, '', $post_upload_date); |
| 1337 | - if ($upload['error']) |
|
| 1338 | - return new WP_Error('upload_dir_error', $upload['error']);
|
|
| 1378 | + if ($upload['error']) { |
|
| 1379 | + return new WP_Error('upload_dir_error', $upload['error']); |
|
| 1380 | + } |
|
| 1339 | 1381 | |
| 1340 | 1382 | // fetch the remote url and write it to the placeholder file |
| 1341 | 1383 | $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
|
@@ -1349,11 +1391,9 @@ discard block |
||
| 1349 | 1391 | // make sure the fetch was successful |
| 1350 | 1392 | elseif ($headers['response']['code'] != '200') {
|
| 1351 | 1393 | $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
|
| 1352 | - } |
|
| 1353 | - elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
|
|
| 1394 | + } elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
|
|
| 1354 | 1395 | $log_message = __('Remote file is incorrect size', 'geodirectory');
|
| 1355 | - } |
|
| 1356 | - elseif (0 == $filesize) {
|
|
| 1396 | + } elseif (0 == $filesize) {
|
|
| 1357 | 1397 | $log_message = __('Zero size file downloaded', 'geodirectory');
|
| 1358 | 1398 | } |
| 1359 | 1399 | |
@@ -1365,10 +1405,11 @@ discard block |
||
| 1365 | 1405 | |
| 1366 | 1406 | if ($dummy && $add_to_cache && is_array($upload)) {
|
| 1367 | 1407 | $images = get_transient('cached_dummy_images');
|
| 1368 | - if(is_array($images)) |
|
| 1369 | - $images[$key] = $upload; |
|
| 1370 | - else |
|
| 1371 | - $images = array($key => $upload); |
|
| 1408 | + if(is_array($images)) { |
|
| 1409 | + $images[$key] = $upload; |
|
| 1410 | + } else { |
|
| 1411 | + $images = array($key => $upload); |
|
| 1412 | + } |
|
| 1372 | 1413 | |
| 1373 | 1414 | //setting the cache using the WP Transient API |
| 1374 | 1415 | set_transient('cached_dummy_images', $images, 60 * 10); //10 minutes cache
|
@@ -1415,10 +1456,11 @@ discard block |
||
| 1415 | 1456 | function geodir_dummy_folder_exists() |
| 1416 | 1457 | {
|
| 1417 | 1458 | $path = geodir_plugin_path() . '/geodirectory-admin/dummy/'; |
| 1418 | - if (!is_dir($path)) |
|
| 1419 | - return false; |
|
| 1420 | - else |
|
| 1421 | - return true; |
|
| 1459 | + if (!is_dir($path)) { |
|
| 1460 | + return false; |
|
| 1461 | + } else { |
|
| 1462 | + return true; |
|
| 1463 | + } |
|
| 1422 | 1464 | |
| 1423 | 1465 | } |
| 1424 | 1466 | |
@@ -1689,12 +1731,10 @@ discard block |
||
| 1689 | 1731 | if ($message_type == 'registration' && get_option('bcc_new_user')) {
|
| 1690 | 1732 | $subject .= ' - ADMIN BCC COPY'; |
| 1691 | 1733 | $admin_bcc = true; |
| 1692 | - } |
|
| 1693 | - elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
|
|
| 1734 | + } elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
|
|
| 1694 | 1735 | $subject .= ' - ADMIN BCC COPY'; |
| 1695 | 1736 | $admin_bcc = true; |
| 1696 | - } |
|
| 1697 | - elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
|
|
| 1737 | + } elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
|
|
| 1698 | 1738 | $subject .= ' - ADMIN BCC COPY'; |
| 1699 | 1739 | $admin_bcc = true; |
| 1700 | 1740 | } |
@@ -1738,7 +1778,9 @@ discard block |
||
| 1738 | 1778 | $res = array(); |
| 1739 | 1779 | foreach ($ids_array as $id) {
|
| 1740 | 1780 | $xlat = icl_object_id($id, $type, false); |
| 1741 | - if (!is_null($xlat)) $res[] = $xlat; |
|
| 1781 | + if (!is_null($xlat)) { |
|
| 1782 | + $res[] = $xlat; |
|
| 1783 | + } |
|
| 1742 | 1784 | } |
| 1743 | 1785 | return $res; |
| 1744 | 1786 | } else {
|
@@ -2079,8 +2121,9 @@ discard block |
||
| 2079 | 2121 | $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
|
| 2080 | 2122 | |
| 2081 | 2123 | $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1; |
| 2082 | - if ( !$page ) |
|
| 2083 | - $page = 1; |
|
| 2124 | + if ( !$page ) { |
|
| 2125 | + $page = 1; |
|
| 2126 | + } |
|
| 2084 | 2127 | |
| 2085 | 2128 | $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : ""; |
| 2086 | 2129 | |
@@ -2406,7 +2449,7 @@ discard block |
||
| 2406 | 2449 | $home_url = str_replace("www.", "", $home_url);
|
| 2407 | 2450 | if ( (strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')) ) {
|
| 2408 | 2451 | return true; |
| 2409 | - }elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
|
|
| 2452 | + } elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
|
|
| 2410 | 2453 | return true; |
| 2411 | 2454 | } else {
|
| 2412 | 2455 | return false; |
@@ -2492,9 +2535,9 @@ discard block |
||
| 2492 | 2535 | $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15; |
| 2493 | 2536 | if(!empty($gd_post_type)){
|
| 2494 | 2537 | $default_post_type = $gd_post_type; |
| 2495 | - }elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
|
|
| 2538 | + } elseif(isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ){
|
|
| 2496 | 2539 | $default_post_type = $instance['default_post_type']; |
| 2497 | - }else{
|
|
| 2540 | + } else{
|
|
| 2498 | 2541 | $all_gd_post_type = geodir_get_posttypes(); |
| 2499 | 2542 | $default_post_type = (isset($all_gd_post_type[0])) ? $all_gd_post_type[0] : ''; |
| 2500 | 2543 | } |
@@ -2918,8 +2961,9 @@ discard block |
||
| 2918 | 2961 | $name = $postobj->labels->name; |
| 2919 | 2962 | |
| 2920 | 2963 | $selected = ''; |
| 2921 | - if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
|
|
| 2922 | - $selected = 'selected="selected"'; |
|
| 2964 | + if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing')) { |
|
| 2965 | + $selected = 'selected="selected"'; |
|
| 2966 | + } |
|
| 2923 | 2967 | |
| 2924 | 2968 | /** |
| 2925 | 2969 | * Filter add listing link. |
@@ -3386,8 +3430,9 @@ discard block |
||
| 3386 | 3430 | $geodir_is_widget_listing = false; |
| 3387 | 3431 | |
| 3388 | 3432 | $GLOBALS['post'] = $current_post; |
| 3389 | - if (!empty($current_post)) |
|
| 3390 | - setup_postdata($current_post); |
|
| 3433 | + if (!empty($current_post)) { |
|
| 3434 | + setup_postdata($current_post); |
|
| 3435 | + } |
|
| 3391 | 3436 | $map_jason = $current_map_jason; |
| 3392 | 3437 | $map_canvas_arr = $current_map_canvas_arr; |
| 3393 | 3438 | ?> |
@@ -3765,11 +3810,15 @@ discard block |
||
| 3765 | 3810 | |
| 3766 | 3811 | $language_file = geodir_plugin_path() . '/db-language.php'; |
| 3767 | 3812 | |
| 3768 | - if(is_file($language_file) && !is_writable($language_file)) |
|
| 3769 | - return false; // Not possible to create. |
|
| 3813 | + if(is_file($language_file) && !is_writable($language_file)) { |
|
| 3814 | + return false; |
|
| 3815 | + } |
|
| 3816 | + // Not possible to create. |
|
| 3770 | 3817 | |
| 3771 | - if(!is_file($language_file) && !is_writable(dirname($language_file))) |
|
| 3772 | - return false; // Not possible to create. |
|
| 3818 | + if(!is_file($language_file) && !is_writable(dirname($language_file))) { |
|
| 3819 | + return false; |
|
| 3820 | + } |
|
| 3821 | + // Not possible to create. |
|
| 3773 | 3822 | |
| 3774 | 3823 | $contents_strings = array(); |
| 3775 | 3824 | |
@@ -3812,8 +3861,10 @@ discard block |
||
| 3812 | 3861 | |
| 3813 | 3862 | $contents .= implode(PHP_EOL, $contents_foot); |
| 3814 | 3863 | |
| 3815 | - if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) |
|
| 3816 | - return false; // Failure; could not write file. |
|
| 3864 | + if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) { |
|
| 3865 | + return false; |
|
| 3866 | + } |
|
| 3867 | + // Failure; could not write file. |
|
| 3817 | 3868 | |
| 3818 | 3869 | return true; |
| 3819 | 3870 | } |
@@ -3839,23 +3890,29 @@ discard block |
||
| 3839 | 3890 | |
| 3840 | 3891 | if (!empty($rows)) {
|
| 3841 | 3892 | foreach($rows as $row) {
|
| 3842 | - if (!empty($row->admin_title)) |
|
| 3843 | - $translation_texts[] = stripslashes_deep($row->admin_title); |
|
| 3893 | + if (!empty($row->admin_title)) { |
|
| 3894 | + $translation_texts[] = stripslashes_deep($row->admin_title); |
|
| 3895 | + } |
|
| 3844 | 3896 | |
| 3845 | - if (!empty($row->admin_desc)) |
|
| 3846 | - $translation_texts[] = stripslashes_deep($row->admin_desc); |
|
| 3897 | + if (!empty($row->admin_desc)) { |
|
| 3898 | + $translation_texts[] = stripslashes_deep($row->admin_desc); |
|
| 3899 | + } |
|
| 3847 | 3900 | |
| 3848 | - if (!empty($row->site_title)) |
|
| 3849 | - $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3901 | + if (!empty($row->site_title)) { |
|
| 3902 | + $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3903 | + } |
|
| 3850 | 3904 | |
| 3851 | - if (!empty($row->clabels)) |
|
| 3852 | - $translation_texts[] = stripslashes_deep($row->clabels); |
|
| 3905 | + if (!empty($row->clabels)) { |
|
| 3906 | + $translation_texts[] = stripslashes_deep($row->clabels); |
|
| 3907 | + } |
|
| 3853 | 3908 | |
| 3854 | - if (!empty($row->required_msg)) |
|
| 3855 | - $translation_texts[] = stripslashes_deep($row->required_msg); |
|
| 3909 | + if (!empty($row->required_msg)) { |
|
| 3910 | + $translation_texts[] = stripslashes_deep($row->required_msg); |
|
| 3911 | + } |
|
| 3856 | 3912 | |
| 3857 | - if (!empty($row->default_value)) |
|
| 3858 | - $translation_texts[] = stripslashes_deep($row->default_value); |
|
| 3913 | + if (!empty($row->default_value)) { |
|
| 3914 | + $translation_texts[] = stripslashes_deep($row->default_value); |
|
| 3915 | + } |
|
| 3859 | 3916 | |
| 3860 | 3917 | if (!empty($row->option_values)) {
|
| 3861 | 3918 | $option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values)); |
@@ -3877,14 +3934,17 @@ discard block |
||
| 3877 | 3934 | |
| 3878 | 3935 | if (!empty($rows)) {
|
| 3879 | 3936 | foreach($rows as $row) {
|
| 3880 | - if (!empty($row->site_title)) |
|
| 3881 | - $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3937 | + if (!empty($row->site_title)) { |
|
| 3938 | + $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3939 | + } |
|
| 3882 | 3940 | |
| 3883 | - if (!empty($row->asc_title)) |
|
| 3884 | - $translation_texts[] = stripslashes_deep($row->asc_title); |
|
| 3941 | + if (!empty($row->asc_title)) { |
|
| 3942 | + $translation_texts[] = stripslashes_deep($row->asc_title); |
|
| 3943 | + } |
|
| 3885 | 3944 | |
| 3886 | - if (!empty($row->desc_title)) |
|
| 3887 | - $translation_texts[] = stripslashes_deep($row->desc_title); |
|
| 3945 | + if (!empty($row->desc_title)) { |
|
| 3946 | + $translation_texts[] = stripslashes_deep($row->desc_title); |
|
| 3947 | + } |
|
| 3888 | 3948 | } |
| 3889 | 3949 | } |
| 3890 | 3950 | |
@@ -3895,14 +3955,17 @@ discard block |
||
| 3895 | 3955 | |
| 3896 | 3956 | if (!empty($rows)) {
|
| 3897 | 3957 | foreach($rows as $row) {
|
| 3898 | - if (!empty($row->field_site_name)) |
|
| 3899 | - $translation_texts[] = stripslashes_deep($row->field_site_name); |
|
| 3958 | + if (!empty($row->field_site_name)) { |
|
| 3959 | + $translation_texts[] = stripslashes_deep($row->field_site_name); |
|
| 3960 | + } |
|
| 3900 | 3961 | |
| 3901 | - if (!empty($row->front_search_title)) |
|
| 3902 | - $translation_texts[] = stripslashes_deep($row->front_search_title); |
|
| 3962 | + if (!empty($row->front_search_title)) { |
|
| 3963 | + $translation_texts[] = stripslashes_deep($row->front_search_title); |
|
| 3964 | + } |
|
| 3903 | 3965 | |
| 3904 | - if (!empty($row->field_desc)) |
|
| 3905 | - $translation_texts[] = stripslashes_deep($row->field_desc); |
|
| 3966 | + if (!empty($row->field_desc)) { |
|
| 3967 | + $translation_texts[] = stripslashes_deep($row->field_desc); |
|
| 3968 | + } |
|
| 3906 | 3969 | } |
| 3907 | 3970 | } |
| 3908 | 3971 | } |
@@ -4220,7 +4283,7 @@ discard block |
||
| 4220 | 4283 | if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
| 4221 | 4284 | $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
| 4222 | 4285 | } |
| 4223 | - }elseif($gd_page=='add-listing'){
|
|
| 4286 | + } elseif($gd_page=='add-listing'){
|
|
| 4224 | 4287 | $geodir_post_types = get_option('geodir_post_types');
|
| 4225 | 4288 | $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : ''; |
| 4226 | 4289 | if(!$spt && isset($_REQUEST['pid'])){
|
@@ -4230,8 +4293,7 @@ discard block |
||
| 4230 | 4293 | if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
| 4231 | 4294 | $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
| 4232 | 4295 | } |
| 4233 | - } |
|
| 4234 | - elseif($post->post_type){
|
|
| 4296 | + } elseif($post->post_type){
|
|
| 4235 | 4297 | $geodir_post_types = get_option('geodir_post_types');
|
| 4236 | 4298 | if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
|
| 4237 | 4299 | $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory'); |
@@ -4250,15 +4312,14 @@ discard block |
||
| 4250 | 4312 | if(isset($geodir_post_types[$spt]['labels']['name'])){
|
| 4251 | 4313 | $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
| 4252 | 4314 | } |
| 4253 | - }elseif($gd_page=='add-listing'){
|
|
| 4315 | + } elseif($gd_page=='add-listing'){
|
|
| 4254 | 4316 | $geodir_post_types = get_option('geodir_post_types');
|
| 4255 | 4317 | $spt = sanitize_text_field($_REQUEST['listing_type']); |
| 4256 | 4318 | if(!$spt){$spt='gd_place';}
|
| 4257 | 4319 | if(isset($geodir_post_types[$spt]['labels']['name'])){
|
| 4258 | 4320 | $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
| 4259 | 4321 | } |
| 4260 | - } |
|
| 4261 | - elseif(isset($post->post_type) && $post->post_type){
|
|
| 4322 | + } elseif(isset($post->post_type) && $post->post_type){
|
|
| 4262 | 4323 | $geodir_post_types = get_option('geodir_post_types');
|
| 4263 | 4324 | if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
|
| 4264 | 4325 | $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory'); |
@@ -4278,7 +4339,7 @@ discard block |
||
| 4278 | 4339 | $cat = get_term($post->default_category, $post->post_type . 'category'); |
| 4279 | 4340 | $cat_name = (isset($cat->name)) ? $cat->name : ''; |
| 4280 | 4341 | } |
| 4281 | - }elseif($gd_page=='listing'){
|
|
| 4342 | + } elseif($gd_page=='listing'){
|
|
| 4282 | 4343 | $queried_object = get_queried_object(); |
| 4283 | 4344 | if(isset($queried_object->name)){
|
| 4284 | 4345 | $cat_name = $queried_object->name; |
@@ -4295,7 +4356,7 @@ discard block |
||
| 4295 | 4356 | $cat = get_term($post->default_category, $post->post_type . 'category'); |
| 4296 | 4357 | $cat_name = (isset($cat->name)) ? $cat->name : ''; |
| 4297 | 4358 | } |
| 4298 | - }elseif($gd_page=='listing'){
|
|
| 4359 | + } elseif($gd_page=='listing'){
|
|
| 4299 | 4360 | $queried_object = get_queried_object(); |
| 4300 | 4361 | if(isset($queried_object->name)){
|
| 4301 | 4362 | $cat_name = $queried_object->name; |
@@ -4513,38 +4574,54 @@ discard block |
||
| 4513 | 4574 | $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : ''; |
| 4514 | 4575 | |
| 4515 | 4576 | if (!empty($labels)) {
|
| 4516 | - if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) |
|
| 4517 | - $translation_texts[] = $labels['name']; |
|
| 4518 | - if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) |
|
| 4519 | - $translation_texts[] = $labels['singular_name']; |
|
| 4520 | - if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) |
|
| 4521 | - $translation_texts[] = $labels['add_new']; |
|
| 4522 | - if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) |
|
| 4523 | - $translation_texts[] = $labels['add_new_item']; |
|
| 4524 | - if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) |
|
| 4525 | - $translation_texts[] = $labels['edit_item']; |
|
| 4526 | - if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) |
|
| 4527 | - $translation_texts[] = $labels['new_item']; |
|
| 4528 | - if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) |
|
| 4529 | - $translation_texts[] = $labels['view_item']; |
|
| 4530 | - if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) |
|
| 4531 | - $translation_texts[] = $labels['search_items']; |
|
| 4532 | - if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) |
|
| 4533 | - $translation_texts[] = $labels['not_found']; |
|
| 4534 | - if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) |
|
| 4535 | - $translation_texts[] = $labels['not_found_in_trash']; |
|
| 4536 | - if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) |
|
| 4537 | - $translation_texts[] = $labels['label_post_profile']; |
|
| 4538 | - if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) |
|
| 4539 | - $translation_texts[] = $labels['label_post_info']; |
|
| 4540 | - if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) |
|
| 4541 | - $translation_texts[] = $labels['label_post_images']; |
|
| 4542 | - if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) |
|
| 4543 | - $translation_texts[] = $labels['label_post_map']; |
|
| 4544 | - if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) |
|
| 4545 | - $translation_texts[] = $labels['label_reviews']; |
|
| 4546 | - if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) |
|
| 4547 | - $translation_texts[] = $labels['label_related_listing']; |
|
| 4577 | + if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) { |
|
| 4578 | + $translation_texts[] = $labels['name']; |
|
| 4579 | + } |
|
| 4580 | + if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) { |
|
| 4581 | + $translation_texts[] = $labels['singular_name']; |
|
| 4582 | + } |
|
| 4583 | + if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) { |
|
| 4584 | + $translation_texts[] = $labels['add_new']; |
|
| 4585 | + } |
|
| 4586 | + if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) { |
|
| 4587 | + $translation_texts[] = $labels['add_new_item']; |
|
| 4588 | + } |
|
| 4589 | + if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) { |
|
| 4590 | + $translation_texts[] = $labels['edit_item']; |
|
| 4591 | + } |
|
| 4592 | + if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) { |
|
| 4593 | + $translation_texts[] = $labels['new_item']; |
|
| 4594 | + } |
|
| 4595 | + if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) { |
|
| 4596 | + $translation_texts[] = $labels['view_item']; |
|
| 4597 | + } |
|
| 4598 | + if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) { |
|
| 4599 | + $translation_texts[] = $labels['search_items']; |
|
| 4600 | + } |
|
| 4601 | + if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) { |
|
| 4602 | + $translation_texts[] = $labels['not_found']; |
|
| 4603 | + } |
|
| 4604 | + if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) { |
|
| 4605 | + $translation_texts[] = $labels['not_found_in_trash']; |
|
| 4606 | + } |
|
| 4607 | + if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) { |
|
| 4608 | + $translation_texts[] = $labels['label_post_profile']; |
|
| 4609 | + } |
|
| 4610 | + if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) { |
|
| 4611 | + $translation_texts[] = $labels['label_post_info']; |
|
| 4612 | + } |
|
| 4613 | + if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) { |
|
| 4614 | + $translation_texts[] = $labels['label_post_images']; |
|
| 4615 | + } |
|
| 4616 | + if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) { |
|
| 4617 | + $translation_texts[] = $labels['label_post_map']; |
|
| 4618 | + } |
|
| 4619 | + if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) { |
|
| 4620 | + $translation_texts[] = $labels['label_reviews']; |
|
| 4621 | + } |
|
| 4622 | + if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) { |
|
| 4623 | + $translation_texts[] = $labels['label_related_listing']; |
|
| 4624 | + } |
|
| 4548 | 4625 | } |
| 4549 | 4626 | |
| 4550 | 4627 | if ($description != '' && !in_array($description, $translation_texts)) {
|
@@ -4552,11 +4629,13 @@ discard block |
||
| 4552 | 4629 | } |
| 4553 | 4630 | |
| 4554 | 4631 | if (!empty($seo)) {
|
| 4555 | - if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) |
|
| 4556 | - $translation_texts[] = normalize_whitespace($seo['meta_keyword']); |
|
| 4632 | + if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) { |
|
| 4633 | + $translation_texts[] = normalize_whitespace($seo['meta_keyword']); |
|
| 4634 | + } |
|
| 4557 | 4635 | |
| 4558 | - if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) |
|
| 4559 | - $translation_texts[] = normalize_whitespace($seo['meta_description']); |
|
| 4636 | + if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) { |
|
| 4637 | + $translation_texts[] = normalize_whitespace($seo['meta_description']); |
|
| 4638 | + } |
|
| 4560 | 4639 | } |
| 4561 | 4640 | } |
| 4562 | 4641 | } |
@@ -4582,16 +4661,20 @@ discard block |
||
| 4582 | 4661 | $hide_region_part = get_option('geodir_location_hide_region_part');
|
| 4583 | 4662 | |
| 4584 | 4663 | if ($hide_region_part && $hide_country_part) {
|
| 4585 | - if (isset($location_terms['gd_country'])) |
|
| 4586 | - unset($location_terms['gd_country']); |
|
| 4587 | - if (isset($location_terms['gd_region'])) |
|
| 4588 | - unset($location_terms['gd_region']); |
|
| 4664 | + if (isset($location_terms['gd_country'])) { |
|
| 4665 | + unset($location_terms['gd_country']); |
|
| 4666 | + } |
|
| 4667 | + if (isset($location_terms['gd_region'])) { |
|
| 4668 | + unset($location_terms['gd_region']); |
|
| 4669 | + } |
|
| 4589 | 4670 | } else if ($hide_region_part && !$hide_country_part) {
|
| 4590 | - if (isset($location_terms['gd_region'])) |
|
| 4591 | - unset($location_terms['gd_region']); |
|
| 4671 | + if (isset($location_terms['gd_region'])) { |
|
| 4672 | + unset($location_terms['gd_region']); |
|
| 4673 | + } |
|
| 4592 | 4674 | } else if (!$hide_region_part && $hide_country_part) {
|
| 4593 | - if (isset($location_terms['gd_country'])) |
|
| 4594 | - unset($location_terms['gd_country']); |
|
| 4675 | + if (isset($location_terms['gd_country'])) { |
|
| 4676 | + unset($location_terms['gd_country']); |
|
| 4677 | + } |
|
| 4595 | 4678 | } |
| 4596 | 4679 | } |
| 4597 | 4680 | |