@@ -30,30 +30,30 @@ discard block |
||
| 30 | 30 | * CHECK FOR OLD COMPATIBILITY PACKS AND DISABLE IF THEY ARE ACTIVE |
| 31 | 31 | */ |
| 32 | 32 | if (is_admin()) {
|
| 33 | - /** |
|
| 34 | - * Include WordPress core file so we can use core functions to check for active plugins. |
|
| 35 | - */ |
|
| 36 | - include_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 33 | + /** |
|
| 34 | + * Include WordPress core file so we can use core functions to check for active plugins. |
|
| 35 | + */ |
|
| 36 | + include_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 37 | 37 | |
| 38 | - if (is_plugin_active('geodirectory-genesis-compatibility-pack/geodir_genesis_compatibility.php')) {
|
|
| 39 | - deactivate_plugins('geodirectory-genesis-compatibility-pack/geodir_genesis_compatibility.php');
|
|
| 40 | - } |
|
| 38 | + if (is_plugin_active('geodirectory-genesis-compatibility-pack/geodir_genesis_compatibility.php')) {
|
|
| 39 | + deactivate_plugins('geodirectory-genesis-compatibility-pack/geodir_genesis_compatibility.php');
|
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - if (is_plugin_active('geodirectory-x-theme-compatibility-pack/geodir_x_compatibility.php')) {
|
|
| 43 | - deactivate_plugins('geodirectory-x-theme-compatibility-pack/geodir_x_compatibility.php');
|
|
| 44 | - } |
|
| 42 | + if (is_plugin_active('geodirectory-x-theme-compatibility-pack/geodir_x_compatibility.php')) {
|
|
| 43 | + deactivate_plugins('geodirectory-x-theme-compatibility-pack/geodir_x_compatibility.php');
|
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - if (is_plugin_active('geodirectory-enfold-theme-compatibility-pack/geodir_enfold_compatibility.php')) {
|
|
| 47 | - deactivate_plugins('geodirectory-enfold-theme-compatibility-pack/geodir_enfold_compatibility.php');
|
|
| 48 | - } |
|
| 46 | + if (is_plugin_active('geodirectory-enfold-theme-compatibility-pack/geodir_enfold_compatibility.php')) {
|
|
| 47 | + deactivate_plugins('geodirectory-enfold-theme-compatibility-pack/geodir_enfold_compatibility.php');
|
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - if (is_plugin_active('geodir_avada_compatibility/geodir_avada_compatibility.php')) {
|
|
| 51 | - deactivate_plugins('geodir_avada_compatibility/geodir_avada_compatibility.php');
|
|
| 52 | - } |
|
| 50 | + if (is_plugin_active('geodir_avada_compatibility/geodir_avada_compatibility.php')) {
|
|
| 51 | + deactivate_plugins('geodir_avada_compatibility/geodir_avada_compatibility.php');
|
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - if (is_plugin_active('geodir_compat_pack_divi/geodir_divi_compatibility.php')) {
|
|
| 55 | - deactivate_plugins('geodir_compat_pack_divi/geodir_divi_compatibility.php');
|
|
| 56 | - } |
|
| 54 | + if (is_plugin_active('geodir_compat_pack_divi/geodir_divi_compatibility.php')) {
|
|
| 55 | + deactivate_plugins('geodir_compat_pack_divi/geodir_divi_compatibility.php');
|
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | 58 | } |
| 59 | 59 | |
@@ -104,11 +104,11 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | |
| 106 | 106 | if ($_SERVER['REQUEST_URI'] == '' || $_SERVER['REQUEST_URI'] == '/') {
|
| 107 | - /** |
|
| 108 | - * This tries to disable cache on homepage as it can be very dynamic. |
|
| 109 | - */ |
|
| 110 | - define('DONOTCACHEPAGE', TRUE);
|
|
| 111 | - $_SERVER['DONOTCACHEPAGE']= TRUE; |
|
| 107 | + /** |
|
| 108 | + * This tries to disable cache on homepage as it can be very dynamic. |
|
| 109 | + */ |
|
| 110 | + define('DONOTCACHEPAGE', TRUE);
|
|
| 111 | + $_SERVER['DONOTCACHEPAGE']= TRUE; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | |
@@ -130,19 +130,19 @@ discard block |
||
| 130 | 130 | * @package GeoDirectory |
| 131 | 131 | */ |
| 132 | 132 | function geodir_error_log($log){
|
| 133 | - /* |
|
| 133 | + /* |
|
| 134 | 134 | * A filter to override the WP_DEBUG setting for function geodir_error_log(). |
| 135 | 135 | * |
| 136 | 136 | * @since 1.5.7 |
| 137 | 137 | */ |
| 138 | - $should_log = apply_filters( 'geodir_log_errors', WP_DEBUG); |
|
| 139 | - if ( true === $should_log ) {
|
|
| 140 | - if ( is_array( $log ) || is_object( $log ) ) {
|
|
| 141 | - error_log( print_r( $log, true ) ); |
|
| 142 | - } else {
|
|
| 143 | - error_log( $log ); |
|
| 144 | - } |
|
| 145 | - } |
|
| 138 | + $should_log = apply_filters( 'geodir_log_errors', WP_DEBUG); |
|
| 139 | + if ( true === $should_log ) {
|
|
| 140 | + if ( is_array( $log ) || is_object( $log ) ) {
|
|
| 141 | + error_log( print_r( $log, true ) ); |
|
| 142 | + } else {
|
|
| 143 | + error_log( $log ); |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -182,62 +182,62 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | if (is_admin() || geodir_is_testing_mode()) {
|
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * Include functions used in admin area only. |
|
| 187 | - * |
|
| 188 | - * @since 1.0.0 |
|
| 189 | - */ |
|
| 190 | - require_once('geodirectory-admin/admin_functions.php');
|
|
| 191 | - /** |
|
| 192 | - * Most actions/hooks used in admin area only are called from here. |
|
| 193 | - * |
|
| 194 | - * @since 1.0.0 |
|
| 195 | - */ |
|
| 196 | - require_once('geodirectory-admin/admin_hooks_actions.php');
|
|
| 197 | - /** |
|
| 198 | - * Most admin JS and CSS is called from here. |
|
| 199 | - * |
|
| 200 | - * @since 1.0.0 |
|
| 201 | - */ |
|
| 202 | - require_once('geodirectory-admin/admin_template_tags.php');
|
|
| 203 | - /** |
|
| 204 | - * Include any functions needed for upgrades. |
|
| 205 | - * |
|
| 206 | - * @since 1.0.0 |
|
| 207 | - */ |
|
| 208 | - require_once(geodir_plugin_path() . '/upgrade.php'); |
|
| 209 | - if (get_option('geodir_installed') != 1) {
|
|
| 210 | - /** |
|
| 211 | - * Define language constants, here as they are not loaded yet. |
|
| 212 | - * |
|
| 213 | - * @since 1.0.0 |
|
| 214 | - */ |
|
| 215 | - require_once(geodir_plugin_path() . '/language.php'); |
|
| 216 | - /** |
|
| 217 | - * Include the plugin install file that sets up the databases and any options on first run. |
|
| 218 | - * |
|
| 219 | - * @since 1.0.0 |
|
| 220 | - */ |
|
| 221 | - require_once('geodirectory-admin/admin_install.php');
|
|
| 222 | - register_activation_hook(__FILE__, 'geodir_activation'); |
|
| 223 | - } |
|
| 224 | - register_deactivation_hook(__FILE__, 'geodir_deactivation'); |
|
| 225 | - register_uninstall_hook(__FILE__, 'geodir_uninstall'); |
|
| 185 | + /** |
|
| 186 | + * Include functions used in admin area only. |
|
| 187 | + * |
|
| 188 | + * @since 1.0.0 |
|
| 189 | + */ |
|
| 190 | + require_once('geodirectory-admin/admin_functions.php');
|
|
| 191 | + /** |
|
| 192 | + * Most actions/hooks used in admin area only are called from here. |
|
| 193 | + * |
|
| 194 | + * @since 1.0.0 |
|
| 195 | + */ |
|
| 196 | + require_once('geodirectory-admin/admin_hooks_actions.php');
|
|
| 197 | + /** |
|
| 198 | + * Most admin JS and CSS is called from here. |
|
| 199 | + * |
|
| 200 | + * @since 1.0.0 |
|
| 201 | + */ |
|
| 202 | + require_once('geodirectory-admin/admin_template_tags.php');
|
|
| 203 | + /** |
|
| 204 | + * Include any functions needed for upgrades. |
|
| 205 | + * |
|
| 206 | + * @since 1.0.0 |
|
| 207 | + */ |
|
| 208 | + require_once(geodir_plugin_path() . '/upgrade.php'); |
|
| 209 | + if (get_option('geodir_installed') != 1) {
|
|
| 210 | + /** |
|
| 211 | + * Define language constants, here as they are not loaded yet. |
|
| 212 | + * |
|
| 213 | + * @since 1.0.0 |
|
| 214 | + */ |
|
| 215 | + require_once(geodir_plugin_path() . '/language.php'); |
|
| 216 | + /** |
|
| 217 | + * Include the plugin install file that sets up the databases and any options on first run. |
|
| 218 | + * |
|
| 219 | + * @since 1.0.0 |
|
| 220 | + */ |
|
| 221 | + require_once('geodirectory-admin/admin_install.php');
|
|
| 222 | + register_activation_hook(__FILE__, 'geodir_activation'); |
|
| 223 | + } |
|
| 224 | + register_deactivation_hook(__FILE__, 'geodir_deactivation'); |
|
| 225 | + register_uninstall_hook(__FILE__, 'geodir_uninstall'); |
|
| 226 | 226 | |
| 227 | - /* |
|
| 227 | + /* |
|
| 228 | 228 | * Show a upgrade warning message if applicable. |
| 229 | 229 | * |
| 230 | 230 | * @since 1.5.6 |
| 231 | 231 | */ |
| 232 | - global $pagenow; |
|
| 232 | + global $pagenow; |
|
| 233 | 233 | if ( 'plugins.php' === $pagenow ) |
| 234 | - {
|
|
| 235 | - // Better update message |
|
| 236 | - $file = basename( __FILE__ ); |
|
| 237 | - $folder = basename( dirname( __FILE__ ) ); |
|
| 238 | - $hook = "in_plugin_update_message-{$folder}/{$file}";
|
|
| 239 | - add_action( $hook, 'geodire_admin_upgrade_notice', 20, 2 ); |
|
| 240 | - } |
|
| 234 | + {
|
|
| 235 | + // Better update message |
|
| 236 | + $file = basename( __FILE__ ); |
|
| 237 | + $folder = basename( dirname( __FILE__ ) ); |
|
| 238 | + $hook = "in_plugin_update_message-{$folder}/{$file}";
|
|
| 239 | + add_action( $hook, 'geodire_admin_upgrade_notice', 20, 2 ); |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | 242 | } |
| 243 | 243 | |
@@ -249,9 +249,9 @@ discard block |
||
| 249 | 249 | * @since 1.5.7 |
| 250 | 250 | */ |
| 251 | 251 | function geodir_is_testing_mode() {
|
| 252 | - if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
|
|
| 253 | - return true; |
|
| 254 | - } else {
|
|
| 255 | - return false; |
|
| 256 | - } |
|
| 252 | + if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
|
|
| 253 | + return true; |
|
| 254 | + } else {
|
|
| 255 | + return false; |
|
| 256 | + } |
|
| 257 | 257 | } |
| 258 | 258 | \ No newline at end of file |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | /** |
| 84 | 84 | * Define constants |
| 85 | 85 | */ |
| 86 | -if(!defined('GEODIRECTORY_PLUGIN_DIR')) define('GEODIRECTORY_PLUGIN_DIR', plugin_dir_path( __FILE__ ));
|
|
| 86 | +if (!defined('GEODIRECTORY_PLUGIN_DIR')) define('GEODIRECTORY_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
|
| 87 | 87 | |
| 88 | 88 | /* |
| 89 | 89 | * Declare database table names. All since version 1.0.0 |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | * This tries to disable cache on homepage as it can be very dynamic. |
| 109 | 109 | */ |
| 110 | 110 | define('DONOTCACHEPAGE', TRUE);
|
| 111 | - $_SERVER['DONOTCACHEPAGE']= TRUE; |
|
| 111 | + $_SERVER['DONOTCACHEPAGE'] = TRUE; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | if (!defined('GEODIRECTORY_TEXTDOMAIN')) define('GEODIRECTORY_TEXTDOMAIN', 'geodirectory');
|
| 119 | 119 | |
| 120 | 120 | // Load geodirectory plugin textdomain. |
| 121 | -add_action( 'plugins_loaded', 'geodir_load_textdomain' ); |
|
| 121 | +add_action('plugins_loaded', 'geodir_load_textdomain');
|
|
| 122 | 122 | |
| 123 | 123 | /* |
| 124 | 124 | * A function to log GD errors no matter the type given. |
@@ -129,18 +129,18 @@ discard block |
||
| 129 | 129 | * @param mixed $log The thing that should be logged. |
| 130 | 130 | * @package GeoDirectory |
| 131 | 131 | */ |
| 132 | -function geodir_error_log($log){
|
|
| 132 | +function geodir_error_log($log) {
|
|
| 133 | 133 | /* |
| 134 | 134 | * A filter to override the WP_DEBUG setting for function geodir_error_log(). |
| 135 | 135 | * |
| 136 | 136 | * @since 1.5.7 |
| 137 | 137 | */ |
| 138 | - $should_log = apply_filters( 'geodir_log_errors', WP_DEBUG); |
|
| 139 | - if ( true === $should_log ) {
|
|
| 140 | - if ( is_array( $log ) || is_object( $log ) ) {
|
|
| 141 | - error_log( print_r( $log, true ) ); |
|
| 138 | + $should_log = apply_filters('geodir_log_errors', WP_DEBUG);
|
|
| 139 | + if (true === $should_log) {
|
|
| 140 | + if (is_array($log) || is_object($log)) {
|
|
| 141 | + error_log(print_r($log, true)); |
|
| 142 | 142 | } else {
|
| 143 | - error_log( $log ); |
|
| 143 | + error_log($log); |
|
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -230,13 +230,13 @@ discard block |
||
| 230 | 230 | * @since 1.5.6 |
| 231 | 231 | */ |
| 232 | 232 | global $pagenow; |
| 233 | - if ( 'plugins.php' === $pagenow ) |
|
| 233 | + if ('plugins.php' === $pagenow)
|
|
| 234 | 234 | {
|
| 235 | 235 | // Better update message |
| 236 | - $file = basename( __FILE__ ); |
|
| 237 | - $folder = basename( dirname( __FILE__ ) ); |
|
| 236 | + $file = basename(__FILE__); |
|
| 237 | + $folder = basename(dirname(__FILE__)); |
|
| 238 | 238 | $hook = "in_plugin_update_message-{$folder}/{$file}";
|
| 239 | - add_action( $hook, 'geodire_admin_upgrade_notice', 20, 2 ); |
|
| 239 | + add_action($hook, 'geodire_admin_upgrade_notice', 20, 2); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * @since 1.5.7 |
| 250 | 250 | */ |
| 251 | 251 | function geodir_is_testing_mode() {
|
| 252 | - if ( defined( 'GD_TESTING_MODE' ) && GD_TESTING_MODE ) {
|
|
| 252 | + if (defined('GD_TESTING_MODE') && GD_TESTING_MODE) {
|
|
| 253 | 253 | return true; |
| 254 | 254 | } else {
|
| 255 | 255 | return false; |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Account Signup functions. |
|
| 4 | - * |
|
| 5 | - * @since 1.0.0 |
|
| 6 | - * @package GeoDirectory |
|
| 7 | - */ |
|
| 3 | + * Account Signup functions. |
|
| 4 | + * |
|
| 5 | + * @since 1.0.0 |
|
| 6 | + * @package GeoDirectory |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Check whether the user is logged in or not. |
@@ -17,18 +17,18 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | function geodir_is_login($redirect = false) |
| 19 | 19 | {
|
| 20 | - global $current_user; |
|
| 21 | - if (!$current_user->ID) {
|
|
| 22 | - if ($redirect) {
|
|
| 23 | - ?> |
|
| 20 | + global $current_user; |
|
| 21 | + if (!$current_user->ID) {
|
|
| 22 | + if ($redirect) {
|
|
| 23 | + ?> |
|
| 24 | 24 | <script type="text/javascript"> |
| 25 | 25 | window.location.href = '<?php echo geodir_login_url();?>'; |
| 26 | 26 | </script> |
| 27 | 27 | <?php |
| 28 | - } else |
|
| 29 | - return false; |
|
| 30 | - } else |
|
| 31 | - return true; |
|
| 28 | + } else |
|
| 29 | + return false; |
|
| 30 | + } else |
|
| 31 | + return true; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
@@ -42,25 +42,25 @@ discard block |
||
| 42 | 42 | {
|
| 43 | 43 | |
| 44 | 44 | // Redirect to https login if forced to use SSL |
| 45 | - if (force_ssl_admin() && !is_ssl()) {
|
|
| 46 | - if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
|
|
| 47 | - wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
|
|
| 48 | - exit(); |
|
| 49 | - } else {
|
|
| 50 | - wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
|
| 51 | - exit(); |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Filter the login message. |
|
| 57 | - * |
|
| 58 | - * @since 1.0.0 |
|
| 59 | - * |
|
| 60 | - * @param string $message Login message. |
|
| 61 | - */ |
|
| 62 | - $message = apply_filters('login_message', $message);
|
|
| 63 | - if (!empty($message)) echo $message . "\n"; |
|
| 45 | + if (force_ssl_admin() && !is_ssl()) {
|
|
| 46 | + if (0 === strpos($_SERVER['REQUEST_URI'], 'http')) {
|
|
| 47 | + wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
|
|
| 48 | + exit(); |
|
| 49 | + } else {
|
|
| 50 | + wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
|
|
| 51 | + exit(); |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Filter the login message. |
|
| 57 | + * |
|
| 58 | + * @since 1.0.0 |
|
| 59 | + * |
|
| 60 | + * @param string $message Login message. |
|
| 61 | + */ |
|
| 62 | + $message = apply_filters('login_message', $message);
|
|
| 63 | + if (!empty($message)) echo $message . "\n"; |
|
| 64 | 64 | |
| 65 | 65 | } |
| 66 | 66 | |
@@ -73,59 +73,59 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | function geodir_get_site_email_id() |
| 75 | 75 | {
|
| 76 | - if (get_option('site_email')) {
|
|
| 76 | + if (get_option('site_email')) {
|
|
| 77 | 77 | |
| 78 | - return get_option('site_email');
|
|
| 78 | + return get_option('site_email');
|
|
| 79 | 79 | |
| 80 | - } else {
|
|
| 80 | + } else {
|
|
| 81 | 81 | |
| 82 | - return get_option('admin_email');
|
|
| 82 | + return get_option('admin_email');
|
|
| 83 | 83 | |
| 84 | - } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | |
| 89 | 89 | if (!function_exists('get_site_emailName')) {
|
| 90 | - /** |
|
| 91 | - * Get site name for sending emails. |
|
| 92 | - * |
|
| 93 | - * @since 1.0.0 |
|
| 94 | - * @package GeoDirectory |
|
| 95 | - * @return string Site name. |
|
| 96 | - */ |
|
| 97 | - function get_site_emailName() |
|
| 90 | + /** |
|
| 91 | + * Get site name for sending emails. |
|
| 92 | + * |
|
| 93 | + * @since 1.0.0 |
|
| 94 | + * @package GeoDirectory |
|
| 95 | + * @return string Site name. |
|
| 96 | + */ |
|
| 97 | + function get_site_emailName() |
|
| 98 | 98 | |
| 99 | - {
|
|
| 99 | + {
|
|
| 100 | 100 | |
| 101 | - if (get_option('site_email_name')) {
|
|
| 101 | + if (get_option('site_email_name')) {
|
|
| 102 | 102 | |
| 103 | - return stripslashes(get_option('site_email_name'));
|
|
| 103 | + return stripslashes(get_option('site_email_name'));
|
|
| 104 | 104 | |
| 105 | - } else {
|
|
| 105 | + } else {
|
|
| 106 | 106 | |
| 107 | - return stripslashes(get_option('blogname'));
|
|
| 107 | + return stripslashes(get_option('blogname'));
|
|
| 108 | 108 | |
| 109 | - } |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - } |
|
| 111 | + } |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | if (!function_exists('is_allow_user_register')) {
|
| 115 | - /** |
|
| 116 | - * Checks whether the site allowing user registration or not. |
|
| 117 | - * |
|
| 118 | - * @since 1.0.0 |
|
| 119 | - * @package GeoDirectory |
|
| 120 | - * @return bool|string |
|
| 121 | - */ |
|
| 122 | - function is_allow_user_register() |
|
| 115 | + /** |
|
| 116 | + * Checks whether the site allowing user registration or not. |
|
| 117 | + * |
|
| 118 | + * @since 1.0.0 |
|
| 119 | + * @package GeoDirectory |
|
| 120 | + * @return bool|string |
|
| 121 | + */ |
|
| 122 | + function is_allow_user_register() |
|
| 123 | 123 | |
| 124 | - {
|
|
| 124 | + {
|
|
| 125 | 125 | |
| 126 | - return get_option('users_can_register');
|
|
| 126 | + return get_option('users_can_register');
|
|
| 127 | 127 | |
| 128 | - } |
|
| 128 | + } |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -138,107 +138,107 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | function geodir_retrieve_password() |
| 140 | 140 | {
|
| 141 | - global $wpdb; |
|
| 142 | - |
|
| 143 | - $errors = new WP_Error(); |
|
| 144 | - if (empty($_POST['user_login']) && empty($_POST['user_email'])) |
|
| 145 | - $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'geodirectory'));
|
|
| 146 | - |
|
| 147 | - if (strpos($_POST['user_login'], '@')) {
|
|
| 148 | - //$user_data = get_user_by_email(trim($_POST['user_login'])); |
|
| 149 | - $user_data = get_user_by('email', trim($_POST['user_login']));
|
|
| 150 | - if (empty($user_data)) |
|
| 151 | - $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'geodirectory'));
|
|
| 152 | - } else {
|
|
| 153 | - $login = trim($_POST['user_login']); |
|
| 154 | - $user_data = get_user_by('email', $login);
|
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * Called in the geodir_retrieve_password() function before any errors are set or any emails are sent. |
|
| 159 | - * |
|
| 160 | - * @since 1.0.0 |
|
| 161 | - */ |
|
| 162 | - do_action('lostpassword_post');
|
|
| 163 | - |
|
| 164 | - if ($errors->get_error_code()) |
|
| 165 | - return $errors; |
|
| 166 | - |
|
| 167 | - if (!$user_data) {
|
|
| 168 | - $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'geodirectory'));
|
|
| 169 | - return $errors; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - // redefining user_login ensures we return the right case in the email |
|
| 173 | - $user_login = $user_data->user_login; |
|
| 174 | - $user_email = $user_data->user_email; |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * Called in the geodir_retrieve_password() function before any emails are sent. |
|
| 178 | - * |
|
| 179 | - * @since 1.0.0 |
|
| 180 | - * @param string $user_login The users username. |
|
| 181 | - */ |
|
| 182 | - do_action('retrieve_password', $user_login);
|
|
| 183 | - |
|
| 184 | - //////////////////////////////////// |
|
| 185 | - $user_email = isset($_POST['user_email']) ? $_POST['user_email'] : ''; |
|
| 186 | - $user_login = $_POST['user_login']; |
|
| 187 | - |
|
| 188 | - $user = $wpdb->get_row( |
|
| 189 | - $wpdb->prepare( |
|
| 190 | - "SELECT * FROM $wpdb->users WHERE user_login like %s or user_email like %s", |
|
| 191 | - array($user_login, $user_login) |
|
| 192 | - ) |
|
| 193 | - ); |
|
| 194 | - |
|
| 195 | - if (empty($user)) |
|
| 196 | - return new WP_Error('invalid_key', __('Invalid key', 'geodirectory'));
|
|
| 197 | - |
|
| 198 | - $new_pass = wp_generate_password(12, false); |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * Called in the geodir_retrieve_password() function before any emails are sent. |
|
| 202 | - * |
|
| 203 | - * @since 1.0.0 |
|
| 204 | - * @param object $user The user object. |
|
| 205 | - * @param string $new_pass The new pass being sent to the user. |
|
| 206 | - */ |
|
| 207 | - do_action('password_reset', $user, $new_pass);
|
|
| 208 | - |
|
| 209 | - wp_set_password($new_pass, $user->ID); |
|
| 210 | - update_user_meta($user->ID, 'default_password_nag', true); //Set up the Password change nag. |
|
| 211 | - $message = '<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>';
|
|
| 212 | - $message .= '<p>' . sprintf(__('Username: %s', 'geodirectory'), $user->user_login) . "</p>";
|
|
| 213 | - $message .= '<p>' . sprintf(__('Password: %s', 'geodirectory'), $new_pass) . "</p>";
|
|
| 214 | - //$message .= '<p>You can login to : <a href="'.home_url().'/?ptype=login' . "\">Login</a> or the URL is : ".home_url()."/?ptype=login</p>"; |
|
| 215 | - //$message .= '<p>Thank You,<br> '.get_option('blogname').'</p>';
|
|
| 216 | - $user_email = $user_data->user_email; |
|
| 217 | - $user_name = geodir_get_client_name($user->ID); |
|
| 218 | - $fromEmail = geodir_get_site_email_id(); |
|
| 219 | - $fromEmailName = get_site_emailName(); |
|
| 220 | - $title = sprintf(__('[%s] Your new password', 'geodirectory'), get_option('blogname'));
|
|
| 221 | - /** |
|
| 222 | - * Filter the password reset email subject part. |
|
| 223 | - * |
|
| 224 | - * @since 1.0.0 |
|
| 225 | - * |
|
| 226 | - * @param string $title Password reset email subject. |
|
| 227 | - */ |
|
| 228 | - $title = apply_filters('password_reset_title', $title);
|
|
| 229 | - /** |
|
| 230 | - * Filter the password reset email message part. |
|
| 231 | - * |
|
| 232 | - * @since 1.0.0 |
|
| 233 | - * |
|
| 234 | - * @param string $message Password reset email message. |
|
| 235 | - * @param string $new_pass The new password string. |
|
| 236 | - */ |
|
| 237 | - $message = apply_filters('password_reset_message', $message, $new_pass);
|
|
| 238 | - //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$user_name,$title,$message,$extra='');///forgot password email |
|
| 239 | - geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID);///forgot password email |
|
| 240 | - |
|
| 241 | - return true; |
|
| 141 | + global $wpdb; |
|
| 142 | + |
|
| 143 | + $errors = new WP_Error(); |
|
| 144 | + if (empty($_POST['user_login']) && empty($_POST['user_email'])) |
|
| 145 | + $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'geodirectory'));
|
|
| 146 | + |
|
| 147 | + if (strpos($_POST['user_login'], '@')) {
|
|
| 148 | + //$user_data = get_user_by_email(trim($_POST['user_login'])); |
|
| 149 | + $user_data = get_user_by('email', trim($_POST['user_login']));
|
|
| 150 | + if (empty($user_data)) |
|
| 151 | + $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'geodirectory'));
|
|
| 152 | + } else {
|
|
| 153 | + $login = trim($_POST['user_login']); |
|
| 154 | + $user_data = get_user_by('email', $login);
|
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * Called in the geodir_retrieve_password() function before any errors are set or any emails are sent. |
|
| 159 | + * |
|
| 160 | + * @since 1.0.0 |
|
| 161 | + */ |
|
| 162 | + do_action('lostpassword_post');
|
|
| 163 | + |
|
| 164 | + if ($errors->get_error_code()) |
|
| 165 | + return $errors; |
|
| 166 | + |
|
| 167 | + if (!$user_data) {
|
|
| 168 | + $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'geodirectory'));
|
|
| 169 | + return $errors; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + // redefining user_login ensures we return the right case in the email |
|
| 173 | + $user_login = $user_data->user_login; |
|
| 174 | + $user_email = $user_data->user_email; |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * Called in the geodir_retrieve_password() function before any emails are sent. |
|
| 178 | + * |
|
| 179 | + * @since 1.0.0 |
|
| 180 | + * @param string $user_login The users username. |
|
| 181 | + */ |
|
| 182 | + do_action('retrieve_password', $user_login);
|
|
| 183 | + |
|
| 184 | + //////////////////////////////////// |
|
| 185 | + $user_email = isset($_POST['user_email']) ? $_POST['user_email'] : ''; |
|
| 186 | + $user_login = $_POST['user_login']; |
|
| 187 | + |
|
| 188 | + $user = $wpdb->get_row( |
|
| 189 | + $wpdb->prepare( |
|
| 190 | + "SELECT * FROM $wpdb->users WHERE user_login like %s or user_email like %s", |
|
| 191 | + array($user_login, $user_login) |
|
| 192 | + ) |
|
| 193 | + ); |
|
| 194 | + |
|
| 195 | + if (empty($user)) |
|
| 196 | + return new WP_Error('invalid_key', __('Invalid key', 'geodirectory'));
|
|
| 197 | + |
|
| 198 | + $new_pass = wp_generate_password(12, false); |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * Called in the geodir_retrieve_password() function before any emails are sent. |
|
| 202 | + * |
|
| 203 | + * @since 1.0.0 |
|
| 204 | + * @param object $user The user object. |
|
| 205 | + * @param string $new_pass The new pass being sent to the user. |
|
| 206 | + */ |
|
| 207 | + do_action('password_reset', $user, $new_pass);
|
|
| 208 | + |
|
| 209 | + wp_set_password($new_pass, $user->ID); |
|
| 210 | + update_user_meta($user->ID, 'default_password_nag', true); //Set up the Password change nag. |
|
| 211 | + $message = '<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>';
|
|
| 212 | + $message .= '<p>' . sprintf(__('Username: %s', 'geodirectory'), $user->user_login) . "</p>";
|
|
| 213 | + $message .= '<p>' . sprintf(__('Password: %s', 'geodirectory'), $new_pass) . "</p>";
|
|
| 214 | + //$message .= '<p>You can login to : <a href="'.home_url().'/?ptype=login' . "\">Login</a> or the URL is : ".home_url()."/?ptype=login</p>"; |
|
| 215 | + //$message .= '<p>Thank You,<br> '.get_option('blogname').'</p>';
|
|
| 216 | + $user_email = $user_data->user_email; |
|
| 217 | + $user_name = geodir_get_client_name($user->ID); |
|
| 218 | + $fromEmail = geodir_get_site_email_id(); |
|
| 219 | + $fromEmailName = get_site_emailName(); |
|
| 220 | + $title = sprintf(__('[%s] Your new password', 'geodirectory'), get_option('blogname'));
|
|
| 221 | + /** |
|
| 222 | + * Filter the password reset email subject part. |
|
| 223 | + * |
|
| 224 | + * @since 1.0.0 |
|
| 225 | + * |
|
| 226 | + * @param string $title Password reset email subject. |
|
| 227 | + */ |
|
| 228 | + $title = apply_filters('password_reset_title', $title);
|
|
| 229 | + /** |
|
| 230 | + * Filter the password reset email message part. |
|
| 231 | + * |
|
| 232 | + * @since 1.0.0 |
|
| 233 | + * |
|
| 234 | + * @param string $message Password reset email message. |
|
| 235 | + * @param string $new_pass The new password string. |
|
| 236 | + */ |
|
| 237 | + $message = apply_filters('password_reset_message', $message, $new_pass);
|
|
| 238 | + //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$user_name,$title,$message,$extra='');///forgot password email |
|
| 239 | + geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID);///forgot password email |
|
| 240 | + |
|
| 241 | + return true; |
|
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | /** |
@@ -253,80 +253,80 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | function geodir_register_new_user($user_login, $user_email) |
| 255 | 255 | {
|
| 256 | - global $wpdb; |
|
| 257 | - $errors = new WP_Error(); |
|
| 258 | - |
|
| 259 | - |
|
| 260 | - $user_login = sanitize_user($user_login); |
|
| 261 | - $user_login = str_replace(",", "", $user_login);
|
|
| 262 | - $user_email = str_replace(",", "", $user_email);
|
|
| 263 | - /** |
|
| 264 | - * Filter the user registration email. |
|
| 265 | - * |
|
| 266 | - * @since 1.0.0 |
|
| 267 | - * |
|
| 268 | - * @param string $user_email User registration email. |
|
| 269 | - */ |
|
| 270 | - $user_email = apply_filters('user_registration_email', $user_email);
|
|
| 271 | - |
|
| 272 | - |
|
| 273 | - if (get_option('geodir_allow_cpass')) {
|
|
| 274 | - $user_pass = $_REQUEST['user_pass']; |
|
| 275 | - $user_pass2 = $_REQUEST['user_pass2']; |
|
| 276 | - // Check the password |
|
| 277 | - if ($user_pass != $user_pass2) {
|
|
| 278 | - $errors->add('pass_match', __('ERROR: Passwords do not match.', 'geodirectory'));
|
|
| 279 | - } elseif (strlen($user_pass) < 7) {
|
|
| 280 | - $errors->add('pass_match', __('ERROR: Password must be 7 characters or more.', 'geodirectory'));
|
|
| 281 | - } |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - // Check the username |
|
| 285 | - if ($user_login == '') |
|
| 286 | - $errors->add('empty_username', __('ERROR: Please enter a username.', 'geodirectory'));
|
|
| 287 | - elseif (!validate_username($user_login)) {
|
|
| 288 | - $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.', 'geodirectory'));
|
|
| 289 | - $user_login = ''; |
|
| 290 | - } elseif (username_exists($user_login)) |
|
| 291 | - $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'geodirectory'));
|
|
| 292 | - |
|
| 293 | - // Check the e-mail address |
|
| 294 | - if ($user_email == '') {
|
|
| 295 | - $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.', 'geodirectory'));
|
|
| 296 | - } elseif (!is_email($user_email)) {
|
|
| 297 | - $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.', 'geodirectory'));
|
|
| 298 | - $user_email = ''; |
|
| 299 | - } elseif (email_exists($user_email)) |
|
| 300 | - $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'geodirectory'));
|
|
| 301 | - |
|
| 302 | - /** |
|
| 303 | - * Called when registering a new user. |
|
| 304 | - * |
|
| 305 | - * This is a WordPress core hook. |
|
| 306 | - * |
|
| 307 | - * @link https://codex.wordpress.org/Plugin_API/Action_Reference/register_post |
|
| 308 | - * @since 1.0.0 |
|
| 309 | - */ |
|
| 310 | - do_action('register_post', $user_login, $user_email, $errors);
|
|
| 311 | - /** |
|
| 312 | - * Filter the registration error messages. |
|
| 313 | - * |
|
| 314 | - * @since 1.0.0 |
|
| 315 | - * |
|
| 316 | - * @param object $errors Registration error messages. |
|
| 317 | - */ |
|
| 318 | - $errors = apply_filters('registration_errors', $errors);
|
|
| 319 | - |
|
| 320 | - if ($errors->get_error_code()) |
|
| 321 | - return $errors; |
|
| 322 | - |
|
| 323 | - |
|
| 324 | - if (!isset($user_pass) || $user_pass == '') {
|
|
| 325 | - $user_pass = wp_generate_password(12, false); |
|
| 326 | - } |
|
| 327 | - $user_id = wp_create_user($user_login, $user_pass, $user_email); |
|
| 328 | - $user_web = ''; |
|
| 329 | - /*$user_add1 = $_POST['user_add1']; |
|
| 256 | + global $wpdb; |
|
| 257 | + $errors = new WP_Error(); |
|
| 258 | + |
|
| 259 | + |
|
| 260 | + $user_login = sanitize_user($user_login); |
|
| 261 | + $user_login = str_replace(",", "", $user_login);
|
|
| 262 | + $user_email = str_replace(",", "", $user_email);
|
|
| 263 | + /** |
|
| 264 | + * Filter the user registration email. |
|
| 265 | + * |
|
| 266 | + * @since 1.0.0 |
|
| 267 | + * |
|
| 268 | + * @param string $user_email User registration email. |
|
| 269 | + */ |
|
| 270 | + $user_email = apply_filters('user_registration_email', $user_email);
|
|
| 271 | + |
|
| 272 | + |
|
| 273 | + if (get_option('geodir_allow_cpass')) {
|
|
| 274 | + $user_pass = $_REQUEST['user_pass']; |
|
| 275 | + $user_pass2 = $_REQUEST['user_pass2']; |
|
| 276 | + // Check the password |
|
| 277 | + if ($user_pass != $user_pass2) {
|
|
| 278 | + $errors->add('pass_match', __('ERROR: Passwords do not match.', 'geodirectory'));
|
|
| 279 | + } elseif (strlen($user_pass) < 7) {
|
|
| 280 | + $errors->add('pass_match', __('ERROR: Password must be 7 characters or more.', 'geodirectory'));
|
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + // Check the username |
|
| 285 | + if ($user_login == '') |
|
| 286 | + $errors->add('empty_username', __('ERROR: Please enter a username.', 'geodirectory'));
|
|
| 287 | + elseif (!validate_username($user_login)) {
|
|
| 288 | + $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.', 'geodirectory'));
|
|
| 289 | + $user_login = ''; |
|
| 290 | + } elseif (username_exists($user_login)) |
|
| 291 | + $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'geodirectory'));
|
|
| 292 | + |
|
| 293 | + // Check the e-mail address |
|
| 294 | + if ($user_email == '') {
|
|
| 295 | + $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.', 'geodirectory'));
|
|
| 296 | + } elseif (!is_email($user_email)) {
|
|
| 297 | + $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.', 'geodirectory'));
|
|
| 298 | + $user_email = ''; |
|
| 299 | + } elseif (email_exists($user_email)) |
|
| 300 | + $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'geodirectory'));
|
|
| 301 | + |
|
| 302 | + /** |
|
| 303 | + * Called when registering a new user. |
|
| 304 | + * |
|
| 305 | + * This is a WordPress core hook. |
|
| 306 | + * |
|
| 307 | + * @link https://codex.wordpress.org/Plugin_API/Action_Reference/register_post |
|
| 308 | + * @since 1.0.0 |
|
| 309 | + */ |
|
| 310 | + do_action('register_post', $user_login, $user_email, $errors);
|
|
| 311 | + /** |
|
| 312 | + * Filter the registration error messages. |
|
| 313 | + * |
|
| 314 | + * @since 1.0.0 |
|
| 315 | + * |
|
| 316 | + * @param object $errors Registration error messages. |
|
| 317 | + */ |
|
| 318 | + $errors = apply_filters('registration_errors', $errors);
|
|
| 319 | + |
|
| 320 | + if ($errors->get_error_code()) |
|
| 321 | + return $errors; |
|
| 322 | + |
|
| 323 | + |
|
| 324 | + if (!isset($user_pass) || $user_pass == '') {
|
|
| 325 | + $user_pass = wp_generate_password(12, false); |
|
| 326 | + } |
|
| 327 | + $user_id = wp_create_user($user_login, $user_pass, $user_email); |
|
| 328 | + $user_web = ''; |
|
| 329 | + /*$user_add1 = $_POST['user_add1']; |
|
| 330 | 330 | $user_add2 = $_POST['user_add2']; |
| 331 | 331 | $user_city = $_POST['user_city']; |
| 332 | 332 | $user_state = $_POST['user_state']; |
@@ -335,77 +335,77 @@ discard block |
||
| 335 | 335 | $user_web = $_POST['user_web']; |
| 336 | 336 | $user_phone = $_POST['user_phone']; |
| 337 | 337 | $user_twitter = $_POST['user_twitter']; */ |
| 338 | - $user_fname = sanitize_user($_POST['user_fname']); |
|
| 339 | - $user_fname = str_replace(",", "", $user_fname);
|
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * Filter the submitted user meta. |
|
| 343 | - * |
|
| 344 | - * @since 1.0.0 |
|
| 345 | - * |
|
| 346 | - * @param int $user_id User ID. |
|
| 347 | - */ |
|
| 348 | - $user_address_info = apply_filters('geodir_manage_user_meta', array(
|
|
| 349 | - "user_add1" => '', |
|
| 350 | - "user_add2" => '', |
|
| 351 | - "user_city" => '', |
|
| 352 | - "user_state" => '', |
|
| 353 | - "user_country" => '', |
|
| 354 | - "user_postalcode" => '', |
|
| 355 | - "user_phone" => '', |
|
| 356 | - "user_twitter" => '', |
|
| 357 | - "first_name" => $user_fname, |
|
| 358 | - "last_name" => '', |
|
| 359 | - ), $user_id); |
|
| 360 | - foreach ($user_address_info as $key => $val) {
|
|
| 361 | - update_user_meta($user_id, $key, $val); // User Address Information Here |
|
| 362 | - } |
|
| 363 | - //update_user_meta($user_id, 'user_address_info', ($user_address_info)); // User Address Information Here |
|
| 364 | - $userName = $user_fname; |
|
| 365 | - update_user_meta($user_id, 'first_name', $userName); // User Address Information Here |
|
| 366 | - //update_user_meta($user_id, 'last_name', $_POST['user_lname']); // User Address Information Here |
|
| 367 | - |
|
| 368 | - // Changed by vikas sharma to enable all type of characters in author permalink... |
|
| 369 | - $user_nicename = sanitize_title($userName); |
|
| 370 | - |
|
| 371 | - $updateUsersql = $wpdb->prepare("update $wpdb->users set user_url=%s, user_nicename=%s, display_name=%s where ID=%d", array($user_web, $user_nicename, $userName, $user_id));
|
|
| 372 | - |
|
| 373 | - $wpdb->query($updateUsersql); |
|
| 374 | - |
|
| 375 | - if (!$user_id) {
|
|
| 376 | - $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'geodirectory'), get_option('admin_email')));
|
|
| 377 | - return $errors; |
|
| 378 | - } |
|
| 379 | - global $upload_folder_path; |
|
| 380 | - |
|
| 381 | - if ($user_id) {
|
|
| 382 | - |
|
| 383 | - /** |
|
| 384 | - * Called after registering a user and before the registration email is sent. |
|
| 385 | - * |
|
| 386 | - * @since 1.0.0 |
|
| 387 | - * @param int $user_id The user ID of the registered user. |
|
| 388 | - */ |
|
| 389 | - do_action('geodir_user_register', $user_id);
|
|
| 390 | - ///////REGISTRATION EMAIL START////// |
|
| 391 | - $fromEmail = geodir_get_site_email_id(); |
|
| 392 | - $fromEmailName = get_site_emailName(); |
|
| 393 | - $message = __('<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>
|
|
| 338 | + $user_fname = sanitize_user($_POST['user_fname']); |
|
| 339 | + $user_fname = str_replace(",", "", $user_fname);
|
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * Filter the submitted user meta. |
|
| 343 | + * |
|
| 344 | + * @since 1.0.0 |
|
| 345 | + * |
|
| 346 | + * @param int $user_id User ID. |
|
| 347 | + */ |
|
| 348 | + $user_address_info = apply_filters('geodir_manage_user_meta', array(
|
|
| 349 | + "user_add1" => '', |
|
| 350 | + "user_add2" => '', |
|
| 351 | + "user_city" => '', |
|
| 352 | + "user_state" => '', |
|
| 353 | + "user_country" => '', |
|
| 354 | + "user_postalcode" => '', |
|
| 355 | + "user_phone" => '', |
|
| 356 | + "user_twitter" => '', |
|
| 357 | + "first_name" => $user_fname, |
|
| 358 | + "last_name" => '', |
|
| 359 | + ), $user_id); |
|
| 360 | + foreach ($user_address_info as $key => $val) {
|
|
| 361 | + update_user_meta($user_id, $key, $val); // User Address Information Here |
|
| 362 | + } |
|
| 363 | + //update_user_meta($user_id, 'user_address_info', ($user_address_info)); // User Address Information Here |
|
| 364 | + $userName = $user_fname; |
|
| 365 | + update_user_meta($user_id, 'first_name', $userName); // User Address Information Here |
|
| 366 | + //update_user_meta($user_id, 'last_name', $_POST['user_lname']); // User Address Information Here |
|
| 367 | + |
|
| 368 | + // Changed by vikas sharma to enable all type of characters in author permalink... |
|
| 369 | + $user_nicename = sanitize_title($userName); |
|
| 370 | + |
|
| 371 | + $updateUsersql = $wpdb->prepare("update $wpdb->users set user_url=%s, user_nicename=%s, display_name=%s where ID=%d", array($user_web, $user_nicename, $userName, $user_id));
|
|
| 372 | + |
|
| 373 | + $wpdb->query($updateUsersql); |
|
| 374 | + |
|
| 375 | + if (!$user_id) {
|
|
| 376 | + $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'geodirectory'), get_option('admin_email')));
|
|
| 377 | + return $errors; |
|
| 378 | + } |
|
| 379 | + global $upload_folder_path; |
|
| 380 | + |
|
| 381 | + if ($user_id) {
|
|
| 382 | + |
|
| 383 | + /** |
|
| 384 | + * Called after registering a user and before the registration email is sent. |
|
| 385 | + * |
|
| 386 | + * @since 1.0.0 |
|
| 387 | + * @param int $user_id The user ID of the registered user. |
|
| 388 | + */ |
|
| 389 | + do_action('geodir_user_register', $user_id);
|
|
| 390 | + ///////REGISTRATION EMAIL START////// |
|
| 391 | + $fromEmail = geodir_get_site_email_id(); |
|
| 392 | + $fromEmailName = get_site_emailName(); |
|
| 393 | + $message = __('<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>
|
|
| 394 | 394 | <p>' . __('Username:', 'geodirectory') . ' ' . $user_login . '</p>
|
| 395 | 395 | <p>' . __('Password:', 'geodirectory') . ' ' . $user_pass . '</p>');
|
| 396 | 396 | |
| 397 | - /////////////customer email////////////// |
|
| 398 | - //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$userName,$subject,$client_message,$extra='');///To client email |
|
| 399 | - geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id);/// registration email |
|
| 400 | - //////REGISTRATION EMAIL END//////// |
|
| 401 | - } |
|
| 397 | + /////////////customer email////////////// |
|
| 398 | + //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$userName,$subject,$client_message,$extra='');///To client email |
|
| 399 | + geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id);/// registration email |
|
| 400 | + //////REGISTRATION EMAIL END//////// |
|
| 401 | + } |
|
| 402 | 402 | |
| 403 | - if (get_option('ptthemes_auto_login')) {
|
|
| 404 | - $errors->add('auto_login', __('<strong>SUCCESS</strong>: Thank you for registering, please check your email for your login details.', 'geodirectory'));
|
|
| 405 | - return $errors; |
|
| 406 | - } |
|
| 403 | + if (get_option('ptthemes_auto_login')) {
|
|
| 404 | + $errors->add('auto_login', __('<strong>SUCCESS</strong>: Thank you for registering, please check your email for your login details.', 'geodirectory'));
|
|
| 405 | + return $errors; |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - return array($user_id, $user_pass); |
|
| 408 | + return array($user_id, $user_pass); |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | /** |
@@ -418,317 +418,317 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | function geodir_user_signup() |
| 420 | 420 | {
|
| 421 | - global $errors; |
|
| 422 | - $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login'; |
|
| 423 | - |
|
| 424 | - $errors = new WP_Error(); |
|
| 425 | - |
|
| 426 | - if (isset($_GET['key'])) |
|
| 427 | - $action = 'resetpass'; |
|
| 428 | - |
|
| 429 | - // validate action so as to default to the login screen |
|
| 430 | - if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action))
|
|
| 431 | - $action = 'login'; |
|
| 432 | - |
|
| 433 | - nocache_headers(); |
|
| 434 | - |
|
| 435 | - if (defined('RELOCATE')) { // Move flag is set
|
|
| 436 | - if (isset($_SERVER['PATH_INFO']) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF'])) |
|
| 437 | - $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); |
|
| 438 | - |
|
| 439 | - $schema = (isset($_SERVER['HTTPS']) && geodir_strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://'; |
|
| 440 | - if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url()) |
|
| 441 | - update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']));
|
|
| 442 | - } |
|
| 443 | - |
|
| 444 | - //Set a cookie now to see if they are supported by the browser. |
|
| 445 | - //setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN); |
|
| 446 | - if (SITECOOKIEPATH != COOKIEPATH) |
|
| 447 | - setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); |
|
| 448 | - |
|
| 449 | - /** |
|
| 450 | - * Allow plugins to override the default actions, and to add extra actions if they want on the register/signin page. |
|
| 451 | - * |
|
| 452 | - * Used dynamic hook login_form_$action |
|
| 453 | - * |
|
| 454 | - * @since 1.0.0 |
|
| 455 | - */ |
|
| 456 | - do_action('login_form_' . $action);
|
|
| 457 | - |
|
| 458 | - $http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
|
|
| 459 | - |
|
| 460 | - switch ($action): |
|
| 461 | - |
|
| 462 | - case 'logout' : |
|
| 463 | - //check_admin_referer('log-out');
|
|
| 464 | - wp_logout(); |
|
| 465 | - |
|
| 466 | - $redirect_to = $_SERVER['HTTP_REFERER']; |
|
| 467 | - //$redirect_to = home_url().'/?ptype=login&loggedout=true'; |
|
| 468 | - if (isset($_REQUEST['redirect_to'])) |
|
| 469 | - $redirect_to = $_REQUEST['redirect_to']; |
|
| 470 | - $redirect_to = home_url(); |
|
| 471 | - wp_safe_redirect($redirect_to); |
|
| 472 | - exit(); |
|
| 473 | - |
|
| 474 | - break; |
|
| 475 | - |
|
| 476 | - case 'lostpassword' : |
|
| 477 | - case 'retrievepassword' : |
|
| 478 | - if ($http_post) {
|
|
| 479 | - $errors = geodir_retrieve_password(); |
|
| 480 | - $error_message = isset($errors->errors['invalid_email'][0]) ? $errors->errors['invalid_email'][0] : ''; |
|
| 481 | - if (!is_wp_error($errors)) {
|
|
| 482 | - wp_redirect(geodir_login_url(array('checkemail'=>'confirm')));
|
|
| 483 | - gd_die(); |
|
| 484 | - } else {
|
|
| 485 | - wp_redirect(geodir_login_url(array('emsg'=>'fw')));
|
|
| 486 | - gd_die(); |
|
| 487 | - } |
|
| 488 | - } |
|
| 489 | - if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'geodirectory'));
|
|
| 490 | - /** |
|
| 491 | - * Called in the geodir_user_signup() function during the lostpassword case. |
|
| 492 | - * |
|
| 493 | - * @since 1.0.0 |
|
| 494 | - */ |
|
| 495 | - do_action('lost_password');
|
|
| 496 | - $message = '<div class="sucess_msg">' . ENTER_USER_EMAIL_NEW_PW_MSG . '</div>'; |
|
| 497 | - $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; |
|
| 498 | - |
|
| 499 | - break; |
|
| 500 | - |
|
| 501 | - case 'resetpass' : |
|
| 502 | - case 'rp' : |
|
| 503 | - $errors = reset_password($_GET['key'], $_GET['login']); |
|
| 504 | - |
|
| 505 | - if (!is_wp_error($errors)) {
|
|
| 506 | - wp_redirect(geodir_login_url(array('checkemail'=>'newpass')));
|
|
| 507 | - exit(); |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - wp_redirect(geodir_login_url(array('error'=>'invalidkey','action'=>'lostpassword')));
|
|
| 511 | - exit(); |
|
| 512 | - |
|
| 513 | - break; |
|
| 514 | - |
|
| 515 | - case 'register' : |
|
| 516 | - ############################### fix by Stiofan - HebTech.co.uk ### SECURITY FIX ############################## |
|
| 517 | - if (!get_option('users_can_register')) {
|
|
| 518 | - wp_redirect(geodir_login_url(array('emsg'=>'regnewusr')));
|
|
| 519 | - exit(); |
|
| 520 | - } |
|
| 521 | - ############################### fix by Stiofan - HebTech.co.uk ### SECURITY FIX ############################## |
|
| 522 | - global $user_email, $user_fname; |
|
| 523 | - $user_login = ''; |
|
| 524 | - $user_email = ''; |
|
| 525 | - if ($http_post) {
|
|
| 526 | - $user_login = $_POST['user_email']; |
|
| 527 | - $user_email = $_POST['user_email']; |
|
| 528 | - $user_fname = $_POST['user_fname']; |
|
| 529 | - |
|
| 530 | - $errors = geodir_register_new_user($user_login, $user_email); |
|
| 531 | - |
|
| 532 | - /* display error in registration form */ |
|
| 533 | - if (is_wp_error($errors)) {
|
|
| 534 | - $error_code = $errors->get_error_code(); |
|
| 535 | - $error_message = $errors->get_error_message($error_code); |
|
| 536 | - if (!isset($_POST['user_login']) && ($error_code == 'empty_username' || $error_code == 'invalid_username' || $error_code == 'username_exists')) {
|
|
| 537 | - if ($error_code == 'empty_username') {
|
|
| 538 | - $error_code = 'empty_email'; |
|
| 539 | - } else if ($error_code == 'invalid_username') {
|
|
| 540 | - $error_code = 'invalid_email'; |
|
| 541 | - } else if ($error_code == 'username_exists') {
|
|
| 542 | - $error_code = 'email_exists'; |
|
| 543 | - } |
|
| 544 | - |
|
| 545 | - $error_message = $errors->get_error_message($error_code); |
|
| 546 | - } |
|
| 547 | - global $geodir_signup_error; |
|
| 548 | - $geodir_signup_error = $error_message; |
|
| 549 | - } |
|
| 550 | - |
|
| 551 | - if (!is_wp_error($errors)) {
|
|
| 552 | - $_POST['log'] = $user_login; |
|
| 553 | - $_POST['pwd'] = $errors[1]; |
|
| 554 | - $_POST['testcookie'] = 1; |
|
| 555 | - |
|
| 556 | - $secure_cookie = ''; |
|
| 557 | - // If the user wants ssl but the session is not ssl, force a secure cookie. |
|
| 558 | - if (!empty($_POST['log'])) {
|
|
| 559 | - $user_name = sanitize_user($_POST['log']); |
|
| 560 | - if ($user = get_user_by('email', $user_name)) {
|
|
| 561 | - if (get_user_option('use_ssl', $user->ID)) {
|
|
| 562 | - $secure_cookie = true; |
|
| 563 | - force_ssl_admin(true); |
|
| 564 | - } |
|
| 565 | - } |
|
| 566 | - } |
|
| 567 | - |
|
| 568 | - $redirect_to = $_REQUEST['redirect_to']; |
|
| 569 | - |
|
| 570 | - if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') {
|
|
| 571 | - if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], home_url())) {
|
|
| 572 | - $redirect_to = $_SERVER['HTTP_REFERER']; |
|
| 573 | - } else {
|
|
| 574 | - $redirect_to = home_url(); |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - } |
|
| 578 | - |
|
| 579 | - if (isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '') {
|
|
| 580 | - |
|
| 581 | - $redirect_to = $_REQUEST['redirect_add_listing']; |
|
| 582 | - } |
|
| 583 | - |
|
| 584 | - |
|
| 585 | - if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) |
|
| 586 | - $secure_cookie = false; |
|
| 587 | - |
|
| 588 | - $user = wp_signon('', $secure_cookie);
|
|
| 589 | - |
|
| 590 | - $requested_redirect_to = isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '' ? $_REQUEST['redirect_add_listing'] : (isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''); |
|
| 591 | - /** |
|
| 592 | - * Filter the login redirect URL. |
|
| 593 | - * |
|
| 594 | - * @since 1.4.9 |
|
| 595 | - * @param string $redirect_to The redirect destination URL. |
|
| 596 | - * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. |
|
| 597 | - * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. |
|
| 598 | - */ |
|
| 599 | - $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
|
|
| 600 | - |
|
| 601 | - |
|
| 602 | - if (!is_wp_error($user)) {
|
|
| 603 | - wp_safe_redirect($redirect_to); |
|
| 604 | - exit(); |
|
| 605 | - } |
|
| 606 | - exit(); |
|
| 607 | - } |
|
| 608 | - } |
|
| 609 | - |
|
| 610 | - break; |
|
| 611 | - |
|
| 612 | - case 'login' : |
|
| 613 | - default: |
|
| 614 | - $secure_cookie = ''; |
|
| 615 | - |
|
| 616 | - if (!empty($_POST['log'])) {
|
|
| 617 | - $user_name = sanitize_user($_POST['log']); |
|
| 618 | - if ($user = get_user_by('login', $user_name)) {
|
|
| 619 | - |
|
| 620 | - if (get_user_option('use_ssl', $user->ID)) {
|
|
| 621 | - $secure_cookie = true; |
|
| 622 | - force_ssl_admin(true); |
|
| 623 | - } |
|
| 624 | - } elseif ($user = get_user_by('email', $user_name)) {
|
|
| 625 | - $_POST['log'] = $user->user_login; // If signing in by email, set the username for normal WP login |
|
| 626 | - if (get_user_option('use_ssl', $user->ID)) {
|
|
| 627 | - $secure_cookie = true; |
|
| 628 | - force_ssl_admin(true); |
|
| 629 | - } |
|
| 630 | - } |
|
| 631 | - } |
|
| 632 | - /////////////////////////// |
|
| 633 | - if (isset($_REQUEST['redirect_add_listing'])) {
|
|
| 634 | - $_REQUEST['redirect_to'] = $_REQUEST['redirect_add_listing']; |
|
| 635 | - } |
|
| 636 | - |
|
| 637 | - |
|
| 638 | - if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') {
|
|
| 639 | - if (is_user_logged_in()) : |
|
| 640 | - $user_ID = isset($user->ID) ? $user->ID : ''; |
|
| 641 | - $author_link = get_author_posts_url($user_ID); |
|
| 642 | - $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
|
|
| 643 | - |
|
| 644 | - /** |
|
| 645 | - * Filter the author link. |
|
| 646 | - * |
|
| 647 | - * @since 1.0.0 |
|
| 648 | - * |
|
| 649 | - * @param string $default_author_link Default author link. |
|
| 650 | - * @param int $user_ID The user ID. |
|
| 651 | - */ |
|
| 652 | - $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_ID);
|
|
| 653 | - |
|
| 654 | - $_REQUEST['redirect_to'] = $default_author_link; |
|
| 655 | - else: |
|
| 656 | - $_REQUEST['redirect_to'] = home_url(); |
|
| 657 | - endif; |
|
| 658 | - |
|
| 659 | - } |
|
| 660 | - if (isset($_REQUEST['redirect_to'])) {
|
|
| 661 | - $redirect_to = $_REQUEST['redirect_to']; |
|
| 662 | - // Redirect to https if user wants ssl |
|
| 663 | - if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) |
|
| 664 | - $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
|
|
| 665 | - } else {
|
|
| 666 | - $redirect_to = admin_url(); |
|
| 667 | - } |
|
| 668 | - |
|
| 669 | - if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) |
|
| 670 | - $secure_cookie = false; |
|
| 671 | - $user = wp_signon('', $secure_cookie);
|
|
| 672 | - |
|
| 673 | - |
|
| 674 | - /** |
|
| 675 | - * Filter the login redirect URL. |
|
| 676 | - * |
|
| 677 | - * @since 1.4.9 |
|
| 678 | - * @param string $redirect_to The redirect destination URL. |
|
| 679 | - * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. |
|
| 680 | - */ |
|
| 681 | - $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
|
|
| 682 | - |
|
| 683 | - if (is_wp_error($user)) {
|
|
| 684 | - if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'ptype=property_submit') && $_POST['log'] != '' && $_POST['pwd'] != '') {
|
|
| 685 | - wp_redirect($_SERVER['HTTP_REFERER'] . '&emsg=1'); |
|
| 686 | - } |
|
| 687 | - } |
|
| 688 | - if (!is_wp_error($user)) {
|
|
| 689 | - |
|
| 690 | - // Some servers are not logging the user in properly after wp_signon, se we set the user here. |
|
| 691 | - //wp_set_current_user($user->ID); |
|
| 692 | - //echo '###';exit; |
|
| 693 | - |
|
| 694 | - if ($redirect_to) {
|
|
| 695 | - wp_redirect($redirect_to); |
|
| 696 | - } else {
|
|
| 697 | - wp_redirect(home_url()); |
|
| 698 | - } |
|
| 699 | - gd_die(); |
|
| 700 | - } |
|
| 701 | - |
|
| 702 | - $errors = $user; |
|
| 703 | - |
|
| 704 | - // Clear errors if loggedout is set. |
|
| 705 | - if (!empty($_GET['loggedout'])) |
|
| 706 | - $errors = new WP_Error(); |
|
| 707 | - // If cookies are disabled we can't log in even with a valid user+pass |
|
| 708 | - if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) |
|
| 709 | - $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'geodirectory'));
|
|
| 710 | - |
|
| 711 | - // Some parts of this script use the main login form to display a message |
|
| 712 | - if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) {
|
|
| 713 | - $successmsg = '<div class="sucess_msg">' . YOU_ARE_LOGED_OUT_MSG . '</div>'; |
|
| 714 | - } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
|
|
| 715 | - $successmsg = USER_REG_NOT_ALLOW_MSG; |
|
| 716 | - } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
|
|
| 717 | - $successmsg = EMAIL_CONFIRM_LINK_MSG; |
|
| 718 | - } elseif (isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail']) {
|
|
| 719 | - $successmsg = NEW_PW_EMAIL_MSG; |
|
| 720 | - } elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) {
|
|
| 721 | - $successmsg = REG_COMPLETE_MSG; |
|
| 722 | - } |
|
| 723 | - |
|
| 724 | - if ((isset($_POST['log']) && $_POST['log'] != '' && $errors) || ((!isset($_POST['log']) || $_POST['log'] == '') && isset($_REQUEST['testcookie']) && $_REQUEST['testcookie'])) {
|
|
| 725 | - if (isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] != '') {
|
|
| 726 | - wp_redirect($_REQUEST['pagetype'] . '&emsg=1'); |
|
| 727 | - } else {
|
|
| 728 | - wp_redirect(geodir_login_url(array('logemsg'=>'1','redirect_to'=>urlencode($_REQUEST['redirect_to']))));
|
|
| 729 | - } |
|
| 730 | - gd_die(); |
|
| 731 | - } |
|
| 732 | - break; |
|
| 733 | - endswitch; // end action switch |
|
| 421 | + global $errors; |
|
| 422 | + $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'login'; |
|
| 423 | + |
|
| 424 | + $errors = new WP_Error(); |
|
| 425 | + |
|
| 426 | + if (isset($_GET['key'])) |
|
| 427 | + $action = 'resetpass'; |
|
| 428 | + |
|
| 429 | + // validate action so as to default to the login screen |
|
| 430 | + if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_' . $action))
|
|
| 431 | + $action = 'login'; |
|
| 432 | + |
|
| 433 | + nocache_headers(); |
|
| 434 | + |
|
| 435 | + if (defined('RELOCATE')) { // Move flag is set
|
|
| 436 | + if (isset($_SERVER['PATH_INFO']) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF'])) |
|
| 437 | + $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); |
|
| 438 | + |
|
| 439 | + $schema = (isset($_SERVER['HTTPS']) && geodir_strtolower($_SERVER['HTTPS']) == 'on') ? 'https://' : 'http://'; |
|
| 440 | + if (dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != home_url()) |
|
| 441 | + update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']));
|
|
| 442 | + } |
|
| 443 | + |
|
| 444 | + //Set a cookie now to see if they are supported by the browser. |
|
| 445 | + //setcookie(TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN); |
|
| 446 | + if (SITECOOKIEPATH != COOKIEPATH) |
|
| 447 | + setcookie(TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN); |
|
| 448 | + |
|
| 449 | + /** |
|
| 450 | + * Allow plugins to override the default actions, and to add extra actions if they want on the register/signin page. |
|
| 451 | + * |
|
| 452 | + * Used dynamic hook login_form_$action |
|
| 453 | + * |
|
| 454 | + * @since 1.0.0 |
|
| 455 | + */ |
|
| 456 | + do_action('login_form_' . $action);
|
|
| 457 | + |
|
| 458 | + $http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
|
|
| 459 | + |
|
| 460 | + switch ($action): |
|
| 461 | + |
|
| 462 | + case 'logout' : |
|
| 463 | + //check_admin_referer('log-out');
|
|
| 464 | + wp_logout(); |
|
| 465 | + |
|
| 466 | + $redirect_to = $_SERVER['HTTP_REFERER']; |
|
| 467 | + //$redirect_to = home_url().'/?ptype=login&loggedout=true'; |
|
| 468 | + if (isset($_REQUEST['redirect_to'])) |
|
| 469 | + $redirect_to = $_REQUEST['redirect_to']; |
|
| 470 | + $redirect_to = home_url(); |
|
| 471 | + wp_safe_redirect($redirect_to); |
|
| 472 | + exit(); |
|
| 473 | + |
|
| 474 | + break; |
|
| 475 | + |
|
| 476 | + case 'lostpassword' : |
|
| 477 | + case 'retrievepassword' : |
|
| 478 | + if ($http_post) {
|
|
| 479 | + $errors = geodir_retrieve_password(); |
|
| 480 | + $error_message = isset($errors->errors['invalid_email'][0]) ? $errors->errors['invalid_email'][0] : ''; |
|
| 481 | + if (!is_wp_error($errors)) {
|
|
| 482 | + wp_redirect(geodir_login_url(array('checkemail'=>'confirm')));
|
|
| 483 | + gd_die(); |
|
| 484 | + } else {
|
|
| 485 | + wp_redirect(geodir_login_url(array('emsg'=>'fw')));
|
|
| 486 | + gd_die(); |
|
| 487 | + } |
|
| 488 | + } |
|
| 489 | + if (isset($_GET['error']) && 'invalidkey' == $_GET['error']) $errors->add('invalidkey', __('Sorry, that key does not appear to be valid.', 'geodirectory'));
|
|
| 490 | + /** |
|
| 491 | + * Called in the geodir_user_signup() function during the lostpassword case. |
|
| 492 | + * |
|
| 493 | + * @since 1.0.0 |
|
| 494 | + */ |
|
| 495 | + do_action('lost_password');
|
|
| 496 | + $message = '<div class="sucess_msg">' . ENTER_USER_EMAIL_NEW_PW_MSG . '</div>'; |
|
| 497 | + $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; |
|
| 498 | + |
|
| 499 | + break; |
|
| 500 | + |
|
| 501 | + case 'resetpass' : |
|
| 502 | + case 'rp' : |
|
| 503 | + $errors = reset_password($_GET['key'], $_GET['login']); |
|
| 504 | + |
|
| 505 | + if (!is_wp_error($errors)) {
|
|
| 506 | + wp_redirect(geodir_login_url(array('checkemail'=>'newpass')));
|
|
| 507 | + exit(); |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + wp_redirect(geodir_login_url(array('error'=>'invalidkey','action'=>'lostpassword')));
|
|
| 511 | + exit(); |
|
| 512 | + |
|
| 513 | + break; |
|
| 514 | + |
|
| 515 | + case 'register' : |
|
| 516 | + ############################### fix by Stiofan - HebTech.co.uk ### SECURITY FIX ############################## |
|
| 517 | + if (!get_option('users_can_register')) {
|
|
| 518 | + wp_redirect(geodir_login_url(array('emsg'=>'regnewusr')));
|
|
| 519 | + exit(); |
|
| 520 | + } |
|
| 521 | + ############################### fix by Stiofan - HebTech.co.uk ### SECURITY FIX ############################## |
|
| 522 | + global $user_email, $user_fname; |
|
| 523 | + $user_login = ''; |
|
| 524 | + $user_email = ''; |
|
| 525 | + if ($http_post) {
|
|
| 526 | + $user_login = $_POST['user_email']; |
|
| 527 | + $user_email = $_POST['user_email']; |
|
| 528 | + $user_fname = $_POST['user_fname']; |
|
| 529 | + |
|
| 530 | + $errors = geodir_register_new_user($user_login, $user_email); |
|
| 531 | + |
|
| 532 | + /* display error in registration form */ |
|
| 533 | + if (is_wp_error($errors)) {
|
|
| 534 | + $error_code = $errors->get_error_code(); |
|
| 535 | + $error_message = $errors->get_error_message($error_code); |
|
| 536 | + if (!isset($_POST['user_login']) && ($error_code == 'empty_username' || $error_code == 'invalid_username' || $error_code == 'username_exists')) {
|
|
| 537 | + if ($error_code == 'empty_username') {
|
|
| 538 | + $error_code = 'empty_email'; |
|
| 539 | + } else if ($error_code == 'invalid_username') {
|
|
| 540 | + $error_code = 'invalid_email'; |
|
| 541 | + } else if ($error_code == 'username_exists') {
|
|
| 542 | + $error_code = 'email_exists'; |
|
| 543 | + } |
|
| 544 | + |
|
| 545 | + $error_message = $errors->get_error_message($error_code); |
|
| 546 | + } |
|
| 547 | + global $geodir_signup_error; |
|
| 548 | + $geodir_signup_error = $error_message; |
|
| 549 | + } |
|
| 550 | + |
|
| 551 | + if (!is_wp_error($errors)) {
|
|
| 552 | + $_POST['log'] = $user_login; |
|
| 553 | + $_POST['pwd'] = $errors[1]; |
|
| 554 | + $_POST['testcookie'] = 1; |
|
| 555 | + |
|
| 556 | + $secure_cookie = ''; |
|
| 557 | + // If the user wants ssl but the session is not ssl, force a secure cookie. |
|
| 558 | + if (!empty($_POST['log'])) {
|
|
| 559 | + $user_name = sanitize_user($_POST['log']); |
|
| 560 | + if ($user = get_user_by('email', $user_name)) {
|
|
| 561 | + if (get_user_option('use_ssl', $user->ID)) {
|
|
| 562 | + $secure_cookie = true; |
|
| 563 | + force_ssl_admin(true); |
|
| 564 | + } |
|
| 565 | + } |
|
| 566 | + } |
|
| 567 | + |
|
| 568 | + $redirect_to = $_REQUEST['redirect_to']; |
|
| 569 | + |
|
| 570 | + if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') {
|
|
| 571 | + if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], home_url())) {
|
|
| 572 | + $redirect_to = $_SERVER['HTTP_REFERER']; |
|
| 573 | + } else {
|
|
| 574 | + $redirect_to = home_url(); |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + } |
|
| 578 | + |
|
| 579 | + if (isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '') {
|
|
| 580 | + |
|
| 581 | + $redirect_to = $_REQUEST['redirect_add_listing']; |
|
| 582 | + } |
|
| 583 | + |
|
| 584 | + |
|
| 585 | + if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) |
|
| 586 | + $secure_cookie = false; |
|
| 587 | + |
|
| 588 | + $user = wp_signon('', $secure_cookie);
|
|
| 589 | + |
|
| 590 | + $requested_redirect_to = isset($_REQUEST['redirect_add_listing']) && $_REQUEST['redirect_add_listing'] != '' ? $_REQUEST['redirect_add_listing'] : (isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : ''); |
|
| 591 | + /** |
|
| 592 | + * Filter the login redirect URL. |
|
| 593 | + * |
|
| 594 | + * @since 1.4.9 |
|
| 595 | + * @param string $redirect_to The redirect destination URL. |
|
| 596 | + * @param string $requested_redirect_to The requested redirect destination URL passed as a parameter. |
|
| 597 | + * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. |
|
| 598 | + */ |
|
| 599 | + $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
|
|
| 600 | + |
|
| 601 | + |
|
| 602 | + if (!is_wp_error($user)) {
|
|
| 603 | + wp_safe_redirect($redirect_to); |
|
| 604 | + exit(); |
|
| 605 | + } |
|
| 606 | + exit(); |
|
| 607 | + } |
|
| 608 | + } |
|
| 609 | + |
|
| 610 | + break; |
|
| 611 | + |
|
| 612 | + case 'login' : |
|
| 613 | + default: |
|
| 614 | + $secure_cookie = ''; |
|
| 615 | + |
|
| 616 | + if (!empty($_POST['log'])) {
|
|
| 617 | + $user_name = sanitize_user($_POST['log']); |
|
| 618 | + if ($user = get_user_by('login', $user_name)) {
|
|
| 619 | + |
|
| 620 | + if (get_user_option('use_ssl', $user->ID)) {
|
|
| 621 | + $secure_cookie = true; |
|
| 622 | + force_ssl_admin(true); |
|
| 623 | + } |
|
| 624 | + } elseif ($user = get_user_by('email', $user_name)) {
|
|
| 625 | + $_POST['log'] = $user->user_login; // If signing in by email, set the username for normal WP login |
|
| 626 | + if (get_user_option('use_ssl', $user->ID)) {
|
|
| 627 | + $secure_cookie = true; |
|
| 628 | + force_ssl_admin(true); |
|
| 629 | + } |
|
| 630 | + } |
|
| 631 | + } |
|
| 632 | + /////////////////////////// |
|
| 633 | + if (isset($_REQUEST['redirect_add_listing'])) {
|
|
| 634 | + $_REQUEST['redirect_to'] = $_REQUEST['redirect_add_listing']; |
|
| 635 | + } |
|
| 636 | + |
|
| 637 | + |
|
| 638 | + if (!isset($_REQUEST['redirect_to']) || $_REQUEST['redirect_to'] == '') {
|
|
| 639 | + if (is_user_logged_in()) : |
|
| 640 | + $user_ID = isset($user->ID) ? $user->ID : ''; |
|
| 641 | + $author_link = get_author_posts_url($user_ID); |
|
| 642 | + $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
|
|
| 643 | + |
|
| 644 | + /** |
|
| 645 | + * Filter the author link. |
|
| 646 | + * |
|
| 647 | + * @since 1.0.0 |
|
| 648 | + * |
|
| 649 | + * @param string $default_author_link Default author link. |
|
| 650 | + * @param int $user_ID The user ID. |
|
| 651 | + */ |
|
| 652 | + $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_ID);
|
|
| 653 | + |
|
| 654 | + $_REQUEST['redirect_to'] = $default_author_link; |
|
| 655 | + else: |
|
| 656 | + $_REQUEST['redirect_to'] = home_url(); |
|
| 657 | + endif; |
|
| 658 | + |
|
| 659 | + } |
|
| 660 | + if (isset($_REQUEST['redirect_to'])) {
|
|
| 661 | + $redirect_to = $_REQUEST['redirect_to']; |
|
| 662 | + // Redirect to https if user wants ssl |
|
| 663 | + if ($secure_cookie && false !== strpos($redirect_to, 'wp-admin')) |
|
| 664 | + $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
|
|
| 665 | + } else {
|
|
| 666 | + $redirect_to = admin_url(); |
|
| 667 | + } |
|
| 668 | + |
|
| 669 | + if (!$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && (0 !== strpos($redirect_to, 'https')) && (0 === strpos($redirect_to, 'http'))) |
|
| 670 | + $secure_cookie = false; |
|
| 671 | + $user = wp_signon('', $secure_cookie);
|
|
| 672 | + |
|
| 673 | + |
|
| 674 | + /** |
|
| 675 | + * Filter the login redirect URL. |
|
| 676 | + * |
|
| 677 | + * @since 1.4.9 |
|
| 678 | + * @param string $redirect_to The redirect destination URL. |
|
| 679 | + * @param WP_User|WP_Error $user WP_User object if login was successful, WP_Error object otherwise. |
|
| 680 | + */ |
|
| 681 | + $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
|
|
| 682 | + |
|
| 683 | + if (is_wp_error($user)) {
|
|
| 684 | + if (isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'ptype=property_submit') && $_POST['log'] != '' && $_POST['pwd'] != '') {
|
|
| 685 | + wp_redirect($_SERVER['HTTP_REFERER'] . '&emsg=1'); |
|
| 686 | + } |
|
| 687 | + } |
|
| 688 | + if (!is_wp_error($user)) {
|
|
| 689 | + |
|
| 690 | + // Some servers are not logging the user in properly after wp_signon, se we set the user here. |
|
| 691 | + //wp_set_current_user($user->ID); |
|
| 692 | + //echo '###';exit; |
|
| 693 | + |
|
| 694 | + if ($redirect_to) {
|
|
| 695 | + wp_redirect($redirect_to); |
|
| 696 | + } else {
|
|
| 697 | + wp_redirect(home_url()); |
|
| 698 | + } |
|
| 699 | + gd_die(); |
|
| 700 | + } |
|
| 701 | + |
|
| 702 | + $errors = $user; |
|
| 703 | + |
|
| 704 | + // Clear errors if loggedout is set. |
|
| 705 | + if (!empty($_GET['loggedout'])) |
|
| 706 | + $errors = new WP_Error(); |
|
| 707 | + // If cookies are disabled we can't log in even with a valid user+pass |
|
| 708 | + if (isset($_POST['testcookie']) && empty($_COOKIE[TEST_COOKIE])) |
|
| 709 | + $errors->add('test_cookie', __("<strong>ERROR</strong>: Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to use WordPress.", 'geodirectory'));
|
|
| 710 | + |
|
| 711 | + // Some parts of this script use the main login form to display a message |
|
| 712 | + if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) {
|
|
| 713 | + $successmsg = '<div class="sucess_msg">' . YOU_ARE_LOGED_OUT_MSG . '</div>'; |
|
| 714 | + } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
|
|
| 715 | + $successmsg = USER_REG_NOT_ALLOW_MSG; |
|
| 716 | + } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
|
|
| 717 | + $successmsg = EMAIL_CONFIRM_LINK_MSG; |
|
| 718 | + } elseif (isset($_GET['checkemail']) && 'newpass' == $_GET['checkemail']) {
|
|
| 719 | + $successmsg = NEW_PW_EMAIL_MSG; |
|
| 720 | + } elseif (isset($_GET['checkemail']) && 'registered' == $_GET['checkemail']) {
|
|
| 721 | + $successmsg = REG_COMPLETE_MSG; |
|
| 722 | + } |
|
| 723 | + |
|
| 724 | + if ((isset($_POST['log']) && $_POST['log'] != '' && $errors) || ((!isset($_POST['log']) || $_POST['log'] == '') && isset($_REQUEST['testcookie']) && $_REQUEST['testcookie'])) {
|
|
| 725 | + if (isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] != '') {
|
|
| 726 | + wp_redirect($_REQUEST['pagetype'] . '&emsg=1'); |
|
| 727 | + } else {
|
|
| 728 | + wp_redirect(geodir_login_url(array('logemsg'=>'1','redirect_to'=>urlencode($_REQUEST['redirect_to']))));
|
|
| 729 | + } |
|
| 730 | + gd_die(); |
|
| 731 | + } |
|
| 732 | + break; |
|
| 733 | + endswitch; // end action switch |
|
| 734 | 734 | } |
| 735 | 735 | \ No newline at end of file |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Custom functions |
|
| 4 | - * |
|
| 5 | - * @since 1.0.0 |
|
| 6 | - * @package GeoDirectory |
|
| 7 | - */ |
|
| 3 | + * Custom functions |
|
| 4 | + * |
|
| 5 | + * @since 1.0.0 |
|
| 6 | + * @package GeoDirectory |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Front end listing view template selection. |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | * @global object $gd_session GeoDirectory Session object. |
| 18 | 18 | */ |
| 19 | 19 | function geodir_list_view_select() {
|
| 20 | - global $gd_session; |
|
| 20 | + global $gd_session; |
|
| 21 | 21 | ?> |
| 22 | 22 | <script type="text/javascript"> |
| 23 | 23 | function geodir_list_view_select(list) {
|
@@ -86,63 +86,63 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | function geodir_max_excerpt($charlength) |
| 88 | 88 | {
|
| 89 | - global $post; |
|
| 90 | - if ($charlength == '0') {
|
|
| 91 | - return; |
|
| 92 | - } |
|
| 93 | - $out = ''; |
|
| 89 | + global $post; |
|
| 90 | + if ($charlength == '0') {
|
|
| 91 | + return; |
|
| 92 | + } |
|
| 93 | + $out = ''; |
|
| 94 | 94 | |
| 95 | 95 | $temp_post = $post; |
| 96 | 96 | $excerpt = get_the_excerpt(); |
| 97 | 97 | |
| 98 | - $charlength++; |
|
| 99 | - $excerpt_more = function_exists('geodirf_excerpt_more') ? geodirf_excerpt_more('') : geodir_excerpt_more('');
|
|
| 100 | - if (mb_strlen($excerpt) > $charlength) {
|
|
| 101 | - if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
|
|
| 102 | - $excut = -(mb_strlen($excerpt_more)); |
|
| 103 | - $subex = mb_substr($excerpt, 0, $excut); |
|
| 104 | - if ($charlength > 0 && mb_strlen($subex) > $charlength) {
|
|
| 105 | - $subex = mb_substr($subex, 0, $charlength); |
|
| 106 | - } |
|
| 107 | - $out .= $subex; |
|
| 108 | - } else {
|
|
| 109 | - $subex = mb_substr($excerpt, 0, $charlength - 5); |
|
| 110 | - $exwords = explode(' ', $subex);
|
|
| 111 | - $excut = -(mb_strlen($exwords[count($exwords) - 1])); |
|
| 112 | - if ($excut < 0) {
|
|
| 113 | - $out .= mb_substr($subex, 0, $excut); |
|
| 114 | - } else {
|
|
| 115 | - $out .= $subex; |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">'; |
|
| 119 | - /** |
|
| 120 | - * Filter excerpt read more text. |
|
| 121 | - * |
|
| 122 | - * @since 1.0.0 |
|
| 123 | - */ |
|
| 124 | - $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
|
|
| 125 | - $out .= '</a>'; |
|
| 126 | - |
|
| 127 | - } else {
|
|
| 128 | - if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
|
|
| 129 | - $excut = -(mb_strlen($excerpt_more)); |
|
| 130 | - $out .= mb_substr($excerpt, 0, $excut); |
|
| 131 | - $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">'; |
|
| 132 | - /** |
|
| 133 | - * Filter excerpt read more text. |
|
| 134 | - * |
|
| 135 | - * @since 1.0.0 |
|
| 136 | - */ |
|
| 137 | - $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
|
|
| 138 | - $out .= '</a>'; |
|
| 139 | - } else {
|
|
| 140 | - $out .= $excerpt; |
|
| 141 | - } |
|
| 142 | - } |
|
| 98 | + $charlength++; |
|
| 99 | + $excerpt_more = function_exists('geodirf_excerpt_more') ? geodirf_excerpt_more('') : geodir_excerpt_more('');
|
|
| 100 | + if (mb_strlen($excerpt) > $charlength) {
|
|
| 101 | + if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
|
|
| 102 | + $excut = -(mb_strlen($excerpt_more)); |
|
| 103 | + $subex = mb_substr($excerpt, 0, $excut); |
|
| 104 | + if ($charlength > 0 && mb_strlen($subex) > $charlength) {
|
|
| 105 | + $subex = mb_substr($subex, 0, $charlength); |
|
| 106 | + } |
|
| 107 | + $out .= $subex; |
|
| 108 | + } else {
|
|
| 109 | + $subex = mb_substr($excerpt, 0, $charlength - 5); |
|
| 110 | + $exwords = explode(' ', $subex);
|
|
| 111 | + $excut = -(mb_strlen($exwords[count($exwords) - 1])); |
|
| 112 | + if ($excut < 0) {
|
|
| 113 | + $out .= mb_substr($subex, 0, $excut); |
|
| 114 | + } else {
|
|
| 115 | + $out .= $subex; |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">'; |
|
| 119 | + /** |
|
| 120 | + * Filter excerpt read more text. |
|
| 121 | + * |
|
| 122 | + * @since 1.0.0 |
|
| 123 | + */ |
|
| 124 | + $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
|
|
| 125 | + $out .= '</a>'; |
|
| 126 | + |
|
| 127 | + } else {
|
|
| 128 | + if (mb_strlen($excerpt_more) > 0 && mb_strpos($excerpt, $excerpt_more) !== false) {
|
|
| 129 | + $excut = -(mb_strlen($excerpt_more)); |
|
| 130 | + $out .= mb_substr($excerpt, 0, $excut); |
|
| 131 | + $out .= ' <a class="excerpt-read-more" href="' . get_permalink() . '" title="' . get_the_title() . '">'; |
|
| 132 | + /** |
|
| 133 | + * Filter excerpt read more text. |
|
| 134 | + * |
|
| 135 | + * @since 1.0.0 |
|
| 136 | + */ |
|
| 137 | + $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
|
|
| 138 | + $out .= '</a>'; |
|
| 139 | + } else {
|
|
| 140 | + $out .= $excerpt; |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | 143 | $post = $temp_post; |
| 144 | 144 | |
| 145 | - return $out; |
|
| 145 | + return $out; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -157,34 +157,34 @@ discard block |
||
| 157 | 157 | */ |
| 158 | 158 | function geodir_post_package_info($package_info, $post = '', $post_type = '') |
| 159 | 159 | {
|
| 160 | - $package_info['pid'] = 0; |
|
| 161 | - $package_info['days'] = 0; |
|
| 162 | - $package_info['amount'] = 0; |
|
| 163 | - $package_info['is_featured'] = 0; |
|
| 164 | - $package_info['image_limit'] = ''; |
|
| 165 | - $package_info['google_analytics'] = 1; |
|
| 166 | - $package_info['sendtofriend'] = 1; |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Filter listing package info. |
|
| 170 | - * |
|
| 171 | - * @since 1.0.0 |
|
| 172 | - * @param array $package_info {
|
|
| 173 | - * Attributes of the package_info. |
|
| 174 | - * |
|
| 175 | - * @type int $pid Package ID. Default 0. |
|
| 176 | - * @type int $days Package validity in Days. Default 0. |
|
| 177 | - * @type int $amount Package amount. Default 0. |
|
| 178 | - * @type int $is_featured Is this featured package? Default 0. |
|
| 179 | - * @type string $image_limit Image limit for this package. Default "". |
|
| 180 | - * @type int $google_analytics Add analytics to this package. Default 1. |
|
| 181 | - * @type int $sendtofriend Send to friend. Default 1. |
|
| 182 | - * |
|
| 183 | - * } |
|
| 184 | - * @param object|string $post The post object. |
|
| 185 | - * @param string $post_type The post type. |
|
| 186 | - */ |
|
| 187 | - return (object)apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
|
|
| 160 | + $package_info['pid'] = 0; |
|
| 161 | + $package_info['days'] = 0; |
|
| 162 | + $package_info['amount'] = 0; |
|
| 163 | + $package_info['is_featured'] = 0; |
|
| 164 | + $package_info['image_limit'] = ''; |
|
| 165 | + $package_info['google_analytics'] = 1; |
|
| 166 | + $package_info['sendtofriend'] = 1; |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Filter listing package info. |
|
| 170 | + * |
|
| 171 | + * @since 1.0.0 |
|
| 172 | + * @param array $package_info {
|
|
| 173 | + * Attributes of the package_info. |
|
| 174 | + * |
|
| 175 | + * @type int $pid Package ID. Default 0. |
|
| 176 | + * @type int $days Package validity in Days. Default 0. |
|
| 177 | + * @type int $amount Package amount. Default 0. |
|
| 178 | + * @type int $is_featured Is this featured package? Default 0. |
|
| 179 | + * @type string $image_limit Image limit for this package. Default "". |
|
| 180 | + * @type int $google_analytics Add analytics to this package. Default 1. |
|
| 181 | + * @type int $sendtofriend Send to friend. Default 1. |
|
| 182 | + * |
|
| 183 | + * } |
|
| 184 | + * @param object|string $post The post object. |
|
| 185 | + * @param string $post_type The post type. |
|
| 186 | + */ |
|
| 187 | + return (object)apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
|
|
| 188 | 188 | |
| 189 | 189 | } |
| 190 | 190 | |
@@ -212,127 +212,127 @@ discard block |
||
| 212 | 212 | */ |
| 213 | 213 | function geodir_send_inquiry($request) |
| 214 | 214 | {
|
| 215 | - global $wpdb; |
|
| 215 | + global $wpdb; |
|
| 216 | 216 | |
| 217 | - // strip slashes from text |
|
| 218 | - $request = !empty($request) ? stripslashes_deep($request) : $request; |
|
| 217 | + // strip slashes from text |
|
| 218 | + $request = !empty($request) ? stripslashes_deep($request) : $request; |
|
| 219 | 219 | |
| 220 | - $yourname = $request['inq_name']; |
|
| 221 | - $youremail = $request['inq_email']; |
|
| 222 | - $inq_phone = $request['inq_phone']; |
|
| 223 | - $frnd_comments = $request['inq_msg']; |
|
| 224 | - $pid = $request['pid']; |
|
| 220 | + $yourname = $request['inq_name']; |
|
| 221 | + $youremail = $request['inq_email']; |
|
| 222 | + $inq_phone = $request['inq_phone']; |
|
| 223 | + $frnd_comments = $request['inq_msg']; |
|
| 224 | + $pid = $request['pid']; |
|
| 225 | 225 | |
| 226 | - $author_id = ''; |
|
| 227 | - $post_title = ''; |
|
| 226 | + $author_id = ''; |
|
| 227 | + $post_title = ''; |
|
| 228 | 228 | |
| 229 | - if ($request['pid']) {
|
|
| 229 | + if ($request['pid']) {
|
|
| 230 | 230 | |
| 231 | - $productinfosql = $wpdb->prepare( |
|
| 232 | - "select ID,post_author,post_title from $wpdb->posts where ID =%d", |
|
| 233 | - array($request['pid']) |
|
| 234 | - ); |
|
| 235 | - $productinfo = $wpdb->get_row($productinfosql); |
|
| 231 | + $productinfosql = $wpdb->prepare( |
|
| 232 | + "select ID,post_author,post_title from $wpdb->posts where ID =%d", |
|
| 233 | + array($request['pid']) |
|
| 234 | + ); |
|
| 235 | + $productinfo = $wpdb->get_row($productinfosql); |
|
| 236 | 236 | |
| 237 | - $author_id = $productinfo->post_author; |
|
| 238 | - $post_title = $productinfo->post_title; |
|
| 239 | - } |
|
| 237 | + $author_id = $productinfo->post_author; |
|
| 238 | + $post_title = $productinfo->post_title; |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - $post_title = '<a href="' . get_permalink($pid) . '">' . $post_title . '</a>'; |
|
| 241 | + $post_title = '<a href="' . get_permalink($pid) . '">' . $post_title . '</a>'; |
|
| 242 | 242 | |
| 243 | - $user_info = get_userdata($author_id); |
|
| 244 | - $to_email = geodir_get_post_meta($pid, 'geodir_email', true); |
|
| 245 | - $to_name = geodir_get_client_name($author_id); |
|
| 243 | + $user_info = get_userdata($author_id); |
|
| 244 | + $to_email = geodir_get_post_meta($pid, 'geodir_email', true); |
|
| 245 | + $to_name = geodir_get_client_name($author_id); |
|
| 246 | 246 | |
| 247 | - if ($to_email == '') {
|
|
| 248 | - $to_email = get_option('admin_email');
|
|
| 249 | - } |
|
| 247 | + if ($to_email == '') {
|
|
| 248 | + $to_email = get_option('admin_email');
|
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - /** |
|
| 252 | - * Called after the send enquiry var have been set but before the email has been sent. |
|
| 253 | - * |
|
| 254 | - * @since 1.0.0 |
|
| 255 | - * @param array $request {
|
|
| 256 | - * The submitted form fields as an array. |
|
| 257 | - * |
|
| 258 | - * @type string $sendact Enquiry type. Default "send_inqury". |
|
| 259 | - * @type string $pid Post ID. |
|
| 260 | - * @type string $inq_name Sender name. |
|
| 261 | - * @type string $inq_email Sender mail. |
|
| 262 | - * @type string $inq_phone Sender phone. |
|
| 263 | - * @type string $inq_msg Email message. |
|
| 264 | - * |
|
| 265 | - * } |
|
| 266 | - * @param string $type The form type, default: `Enquiry`. |
|
| 267 | - */ |
|
| 268 | - do_action('geodir_after_send_enquiry', $request, 'Enquiry');
|
|
| 269 | - |
|
| 270 | - $client_message = $frnd_comments; |
|
| 271 | - $client_message .= '<br>' . __('From :', 'geodirectory') . ' ' . $yourname . '<br>' . __('Phone :', 'geodirectory') . ' ' . $inq_phone . '<br>' . __('Email :', 'geodirectory') . ' ' . $youremail . '<br><br>' . __('Sent from', 'geodirectory') . ' - <b><a href="' . trailingslashit(home_url()) . '">' . get_option('blogname') . '</a></b>.';
|
|
| 272 | - /** |
|
| 273 | - * Filter client message text. |
|
| 274 | - * |
|
| 275 | - * @since 1.0.0 |
|
| 276 | - * @param string $client_message Client message text. |
|
| 277 | - */ |
|
| 278 | - $client_message = apply_filters('geodir_inquiry_email_msg', $client_message);
|
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * Called before the send enquiry email is sent. |
|
| 282 | - * |
|
| 283 | - * @since 1.0.0 |
|
| 284 | - * @param array $request {
|
|
| 285 | - * The submitted form fields as an array. |
|
| 286 | - * |
|
| 287 | - * @type string $sendact Enquiry type. Default "send_inqury". |
|
| 288 | - * @type string $pid Post ID. |
|
| 289 | - * @type string $inq_name Sender name. |
|
| 290 | - * @type string $inq_email Sender mail. |
|
| 291 | - * @type string $inq_phone Sender phone. |
|
| 292 | - * @type string $inq_msg Email message. |
|
| 293 | - * |
|
| 294 | - * } |
|
| 295 | - */ |
|
| 296 | - do_action('geodir_before_send_enquiry_email', $request);
|
|
| 297 | - if ($to_email) {
|
|
| 298 | - // strip slashes message |
|
| 299 | - $client_message = stripslashes_deep($client_message); |
|
| 300 | - |
|
| 301 | - geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']);//To client email |
|
| 302 | - } |
|
| 251 | + /** |
|
| 252 | + * Called after the send enquiry var have been set but before the email has been sent. |
|
| 253 | + * |
|
| 254 | + * @since 1.0.0 |
|
| 255 | + * @param array $request {
|
|
| 256 | + * The submitted form fields as an array. |
|
| 257 | + * |
|
| 258 | + * @type string $sendact Enquiry type. Default "send_inqury". |
|
| 259 | + * @type string $pid Post ID. |
|
| 260 | + * @type string $inq_name Sender name. |
|
| 261 | + * @type string $inq_email Sender mail. |
|
| 262 | + * @type string $inq_phone Sender phone. |
|
| 263 | + * @type string $inq_msg Email message. |
|
| 264 | + * |
|
| 265 | + * } |
|
| 266 | + * @param string $type The form type, default: `Enquiry`. |
|
| 267 | + */ |
|
| 268 | + do_action('geodir_after_send_enquiry', $request, 'Enquiry');
|
|
| 303 | 269 | |
| 304 | - /** |
|
| 305 | - * Called after the send enquiry email is sent. |
|
| 306 | - * |
|
| 307 | - * @since 1.0.0 |
|
| 308 | - * @param array $request {
|
|
| 309 | - * The submitted form fields as an array. |
|
| 310 | - * |
|
| 311 | - * @type string $sendact Enquiry type. Default "send_inqury". |
|
| 312 | - * @type string $pid Post ID. |
|
| 313 | - * @type string $inq_name Sender name. |
|
| 314 | - * @type string $inq_email Sender mail. |
|
| 315 | - * @type string $inq_phone Sender phone. |
|
| 316 | - * @type string $inq_msg Email message. |
|
| 317 | - * |
|
| 318 | - * } |
|
| 319 | - */ |
|
| 320 | - do_action('geodir_after_send_enquiry_email', $request);
|
|
| 321 | - $url = get_permalink($pid); |
|
| 322 | - if (strstr($url, '?')) {
|
|
| 323 | - $url = $url . "&send_inquiry=success"; |
|
| 324 | - } else {
|
|
| 325 | - $url = $url . "?send_inquiry=success"; |
|
| 326 | - } |
|
| 327 | - /** |
|
| 328 | - * Filter redirect url after the send enquiry email is sent. |
|
| 329 | - * |
|
| 330 | - * @since 1.0.0 |
|
| 331 | - * @param string $url Redirect url. |
|
| 332 | - */ |
|
| 333 | - $url = apply_filters('geodir_send_enquiry_after_submit_redirect', $url);
|
|
| 334 | - wp_redirect($url); |
|
| 335 | - gd_die(); |
|
| 270 | + $client_message = $frnd_comments; |
|
| 271 | + $client_message .= '<br>' . __('From :', 'geodirectory') . ' ' . $yourname . '<br>' . __('Phone :', 'geodirectory') . ' ' . $inq_phone . '<br>' . __('Email :', 'geodirectory') . ' ' . $youremail . '<br><br>' . __('Sent from', 'geodirectory') . ' - <b><a href="' . trailingslashit(home_url()) . '">' . get_option('blogname') . '</a></b>.';
|
|
| 272 | + /** |
|
| 273 | + * Filter client message text. |
|
| 274 | + * |
|
| 275 | + * @since 1.0.0 |
|
| 276 | + * @param string $client_message Client message text. |
|
| 277 | + */ |
|
| 278 | + $client_message = apply_filters('geodir_inquiry_email_msg', $client_message);
|
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * Called before the send enquiry email is sent. |
|
| 282 | + * |
|
| 283 | + * @since 1.0.0 |
|
| 284 | + * @param array $request {
|
|
| 285 | + * The submitted form fields as an array. |
|
| 286 | + * |
|
| 287 | + * @type string $sendact Enquiry type. Default "send_inqury". |
|
| 288 | + * @type string $pid Post ID. |
|
| 289 | + * @type string $inq_name Sender name. |
|
| 290 | + * @type string $inq_email Sender mail. |
|
| 291 | + * @type string $inq_phone Sender phone. |
|
| 292 | + * @type string $inq_msg Email message. |
|
| 293 | + * |
|
| 294 | + * } |
|
| 295 | + */ |
|
| 296 | + do_action('geodir_before_send_enquiry_email', $request);
|
|
| 297 | + if ($to_email) {
|
|
| 298 | + // strip slashes message |
|
| 299 | + $client_message = stripslashes_deep($client_message); |
|
| 300 | + |
|
| 301 | + geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']);//To client email |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * Called after the send enquiry email is sent. |
|
| 306 | + * |
|
| 307 | + * @since 1.0.0 |
|
| 308 | + * @param array $request {
|
|
| 309 | + * The submitted form fields as an array. |
|
| 310 | + * |
|
| 311 | + * @type string $sendact Enquiry type. Default "send_inqury". |
|
| 312 | + * @type string $pid Post ID. |
|
| 313 | + * @type string $inq_name Sender name. |
|
| 314 | + * @type string $inq_email Sender mail. |
|
| 315 | + * @type string $inq_phone Sender phone. |
|
| 316 | + * @type string $inq_msg Email message. |
|
| 317 | + * |
|
| 318 | + * } |
|
| 319 | + */ |
|
| 320 | + do_action('geodir_after_send_enquiry_email', $request);
|
|
| 321 | + $url = get_permalink($pid); |
|
| 322 | + if (strstr($url, '?')) {
|
|
| 323 | + $url = $url . "&send_inquiry=success"; |
|
| 324 | + } else {
|
|
| 325 | + $url = $url . "?send_inquiry=success"; |
|
| 326 | + } |
|
| 327 | + /** |
|
| 328 | + * Filter redirect url after the send enquiry email is sent. |
|
| 329 | + * |
|
| 330 | + * @since 1.0.0 |
|
| 331 | + * @param string $url Redirect url. |
|
| 332 | + */ |
|
| 333 | + $url = apply_filters('geodir_send_enquiry_after_submit_redirect', $url);
|
|
| 334 | + wp_redirect($url); |
|
| 335 | + gd_die(); |
|
| 336 | 336 | |
| 337 | 337 | } |
| 338 | 338 | |
@@ -361,85 +361,85 @@ discard block |
||
| 361 | 361 | */ |
| 362 | 362 | function geodir_send_friend($request) |
| 363 | 363 | {
|
| 364 | - global $wpdb; |
|
| 365 | - |
|
| 366 | - // strip slashes from text |
|
| 367 | - $request = !empty($request) ? stripslashes_deep($request) : $request; |
|
| 368 | - |
|
| 369 | - $yourname = $request['yourname']; |
|
| 370 | - $youremail = $request['youremail']; |
|
| 371 | - $frnd_subject = $request['frnd_subject']; |
|
| 372 | - $frnd_comments = $request['frnd_comments']; |
|
| 373 | - $pid = $request['pid']; |
|
| 374 | - $to_email = $request['to_email']; |
|
| 375 | - $to_name = $request['to_name']; |
|
| 376 | - if ($request['pid']) {
|
|
| 377 | - $productinfosql = $wpdb->prepare( |
|
| 378 | - "select ID,post_title from $wpdb->posts where ID =%d", |
|
| 379 | - array($request['pid']) |
|
| 380 | - ); |
|
| 381 | - $productinfo = $wpdb->get_results($productinfosql); |
|
| 382 | - foreach ($productinfo as $productinfoObj) {
|
|
| 383 | - $post_title = $productinfoObj->post_title; |
|
| 384 | - } |
|
| 385 | - } |
|
| 364 | + global $wpdb; |
|
| 365 | + |
|
| 366 | + // strip slashes from text |
|
| 367 | + $request = !empty($request) ? stripslashes_deep($request) : $request; |
|
| 368 | + |
|
| 369 | + $yourname = $request['yourname']; |
|
| 370 | + $youremail = $request['youremail']; |
|
| 371 | + $frnd_subject = $request['frnd_subject']; |
|
| 372 | + $frnd_comments = $request['frnd_comments']; |
|
| 373 | + $pid = $request['pid']; |
|
| 374 | + $to_email = $request['to_email']; |
|
| 375 | + $to_name = $request['to_name']; |
|
| 376 | + if ($request['pid']) {
|
|
| 377 | + $productinfosql = $wpdb->prepare( |
|
| 378 | + "select ID,post_title from $wpdb->posts where ID =%d", |
|
| 379 | + array($request['pid']) |
|
| 380 | + ); |
|
| 381 | + $productinfo = $wpdb->get_results($productinfosql); |
|
| 382 | + foreach ($productinfo as $productinfoObj) {
|
|
| 383 | + $post_title = $productinfoObj->post_title; |
|
| 384 | + } |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | - /** |
|
| 388 | - * Called before the send to friend email is sent. |
|
| 389 | - * |
|
| 390 | - * @since 1.0.0 |
|
| 391 | - * @param array $request {
|
|
| 392 | - * The submitted form fields as an array. |
|
| 393 | - * |
|
| 394 | - * @type string $sendact Enquiry type. Default "email_frnd". |
|
| 395 | - * @type string $pid Post ID. |
|
| 396 | - * @type string $to_name Friend name. |
|
| 397 | - * @type string $to_email Friend email. |
|
| 398 | - * @type string $yourname Sender name. |
|
| 399 | - * @type string $youremail Sender email. |
|
| 400 | - * @type string $frnd_subject Email subject. |
|
| 401 | - * @type string $frnd_comments Email Message. |
|
| 402 | - * |
|
| 403 | - * } |
|
| 404 | - */ |
|
| 405 | - do_action('geodir_before_send_to_friend_email', $request);
|
|
| 406 | - geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']);//To client email |
|
| 407 | - |
|
| 408 | - /** |
|
| 409 | - * Called after the send to friend email is sent. |
|
| 410 | - * |
|
| 411 | - * @since 1.0.0 |
|
| 412 | - * @param array $request {
|
|
| 413 | - * The submitted form fields as an array. |
|
| 414 | - * |
|
| 415 | - * @type string $sendact Enquiry type. Default "email_frnd". |
|
| 416 | - * @type string $pid Post ID. |
|
| 417 | - * @type string $to_name Friend name. |
|
| 418 | - * @type string $to_email Friend email. |
|
| 419 | - * @type string $yourname Sender name. |
|
| 420 | - * @type string $youremail Sender email. |
|
| 421 | - * @type string $frnd_subject Email subject. |
|
| 422 | - * @type string $frnd_comments Email Message. |
|
| 423 | - * |
|
| 424 | - * } |
|
| 425 | - */ |
|
| 426 | - do_action('geodir_after_send_to_friend_email', $request);
|
|
| 427 | - |
|
| 428 | - $url = get_permalink($pid); |
|
| 429 | - if (strstr($url, '?')) {
|
|
| 430 | - $url = $url . "&sendtofrnd=success"; |
|
| 431 | - } else {
|
|
| 432 | - $url = $url . "?sendtofrnd=success"; |
|
| 433 | - } |
|
| 434 | - /** |
|
| 435 | - * Filter redirect url after the send to friend email is sent. |
|
| 436 | - * |
|
| 437 | - * @since 1.0.0 |
|
| 438 | - * @param string $url Redirect url. |
|
| 439 | - */ |
|
| 440 | - $url = apply_filters('geodir_send_to_friend_after_submit_redirect', $url);
|
|
| 441 | - wp_redirect($url); |
|
| 442 | - gd_die(); |
|
| 387 | + /** |
|
| 388 | + * Called before the send to friend email is sent. |
|
| 389 | + * |
|
| 390 | + * @since 1.0.0 |
|
| 391 | + * @param array $request {
|
|
| 392 | + * The submitted form fields as an array. |
|
| 393 | + * |
|
| 394 | + * @type string $sendact Enquiry type. Default "email_frnd". |
|
| 395 | + * @type string $pid Post ID. |
|
| 396 | + * @type string $to_name Friend name. |
|
| 397 | + * @type string $to_email Friend email. |
|
| 398 | + * @type string $yourname Sender name. |
|
| 399 | + * @type string $youremail Sender email. |
|
| 400 | + * @type string $frnd_subject Email subject. |
|
| 401 | + * @type string $frnd_comments Email Message. |
|
| 402 | + * |
|
| 403 | + * } |
|
| 404 | + */ |
|
| 405 | + do_action('geodir_before_send_to_friend_email', $request);
|
|
| 406 | + geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']);//To client email |
|
| 407 | + |
|
| 408 | + /** |
|
| 409 | + * Called after the send to friend email is sent. |
|
| 410 | + * |
|
| 411 | + * @since 1.0.0 |
|
| 412 | + * @param array $request {
|
|
| 413 | + * The submitted form fields as an array. |
|
| 414 | + * |
|
| 415 | + * @type string $sendact Enquiry type. Default "email_frnd". |
|
| 416 | + * @type string $pid Post ID. |
|
| 417 | + * @type string $to_name Friend name. |
|
| 418 | + * @type string $to_email Friend email. |
|
| 419 | + * @type string $yourname Sender name. |
|
| 420 | + * @type string $youremail Sender email. |
|
| 421 | + * @type string $frnd_subject Email subject. |
|
| 422 | + * @type string $frnd_comments Email Message. |
|
| 423 | + * |
|
| 424 | + * } |
|
| 425 | + */ |
|
| 426 | + do_action('geodir_after_send_to_friend_email', $request);
|
|
| 427 | + |
|
| 428 | + $url = get_permalink($pid); |
|
| 429 | + if (strstr($url, '?')) {
|
|
| 430 | + $url = $url . "&sendtofrnd=success"; |
|
| 431 | + } else {
|
|
| 432 | + $url = $url . "?sendtofrnd=success"; |
|
| 433 | + } |
|
| 434 | + /** |
|
| 435 | + * Filter redirect url after the send to friend email is sent. |
|
| 436 | + * |
|
| 437 | + * @since 1.0.0 |
|
| 438 | + * @param string $url Redirect url. |
|
| 439 | + */ |
|
| 440 | + $url = apply_filters('geodir_send_to_friend_after_submit_redirect', $url);
|
|
| 441 | + wp_redirect($url); |
|
| 442 | + gd_die(); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
@@ -453,28 +453,28 @@ discard block |
||
| 453 | 453 | */ |
| 454 | 454 | function geodir_before_tab_content($hash_key) |
| 455 | 455 | {
|
| 456 | - switch ($hash_key) {
|
|
| 457 | - case 'post_info' : |
|
| 458 | - echo '<div class="geodir-company_info field-group">'; |
|
| 459 | - break; |
|
| 460 | - case 'post_images' : |
|
| 461 | - /** |
|
| 462 | - * Filter post gallery HTML id. |
|
| 463 | - * |
|
| 464 | - * @since 1.0.0 |
|
| 465 | - */ |
|
| 466 | - echo ' <div id="' . apply_filters('geodir_post_gallery_id', 'geodir-post-gallery') . '" class="clearfix" >';
|
|
| 467 | - break; |
|
| 468 | - case 'reviews' : |
|
| 469 | - echo '<div id="reviews-wrap" class="clearfix"> '; |
|
| 470 | - break; |
|
| 471 | - case 'post_video': |
|
| 472 | - echo ' <div id="post_video-wrap" class="clearfix">'; |
|
| 473 | - break; |
|
| 474 | - case 'special_offers': |
|
| 475 | - echo '<div id="special_offers-wrap" class="clearfix">'; |
|
| 476 | - break; |
|
| 477 | - } |
|
| 456 | + switch ($hash_key) {
|
|
| 457 | + case 'post_info' : |
|
| 458 | + echo '<div class="geodir-company_info field-group">'; |
|
| 459 | + break; |
|
| 460 | + case 'post_images' : |
|
| 461 | + /** |
|
| 462 | + * Filter post gallery HTML id. |
|
| 463 | + * |
|
| 464 | + * @since 1.0.0 |
|
| 465 | + */ |
|
| 466 | + echo ' <div id="' . apply_filters('geodir_post_gallery_id', 'geodir-post-gallery') . '" class="clearfix" >';
|
|
| 467 | + break; |
|
| 468 | + case 'reviews' : |
|
| 469 | + echo '<div id="reviews-wrap" class="clearfix"> '; |
|
| 470 | + break; |
|
| 471 | + case 'post_video': |
|
| 472 | + echo ' <div id="post_video-wrap" class="clearfix">'; |
|
| 473 | + break; |
|
| 474 | + case 'special_offers': |
|
| 475 | + echo '<div id="special_offers-wrap" class="clearfix">'; |
|
| 476 | + break; |
|
| 477 | + } |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | /** |
@@ -488,23 +488,23 @@ discard block |
||
| 488 | 488 | */ |
| 489 | 489 | function geodir_after_tab_content($hash_key) |
| 490 | 490 | {
|
| 491 | - switch ($hash_key) {
|
|
| 492 | - case 'post_info' : |
|
| 493 | - echo '</div>'; |
|
| 494 | - break; |
|
| 495 | - case 'post_images' : |
|
| 496 | - echo '</div>'; |
|
| 497 | - break; |
|
| 498 | - case 'reviews' : |
|
| 499 | - echo '</div>'; |
|
| 500 | - break; |
|
| 501 | - case 'post_video': |
|
| 502 | - echo '</div>'; |
|
| 503 | - break; |
|
| 504 | - case 'special_offers': |
|
| 505 | - echo '</div>'; |
|
| 506 | - break; |
|
| 507 | - } |
|
| 491 | + switch ($hash_key) {
|
|
| 492 | + case 'post_info' : |
|
| 493 | + echo '</div>'; |
|
| 494 | + break; |
|
| 495 | + case 'post_images' : |
|
| 496 | + echo '</div>'; |
|
| 497 | + break; |
|
| 498 | + case 'reviews' : |
|
| 499 | + echo '</div>'; |
|
| 500 | + break; |
|
| 501 | + case 'post_video': |
|
| 502 | + echo '</div>'; |
|
| 503 | + break; |
|
| 504 | + case 'special_offers': |
|
| 505 | + echo '</div>'; |
|
| 506 | + break; |
|
| 507 | + } |
|
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | |
@@ -520,21 +520,21 @@ discard block |
||
| 520 | 520 | function geodir_get_posts_default_sort($post_type) |
| 521 | 521 | {
|
| 522 | 522 | |
| 523 | - global $wpdb; |
|
| 523 | + global $wpdb; |
|
| 524 | 524 | |
| 525 | - if ($post_type != '') {
|
|
| 525 | + if ($post_type != '') {
|
|
| 526 | 526 | |
| 527 | - $all_postypes = geodir_get_posttypes(); |
|
| 527 | + $all_postypes = geodir_get_posttypes(); |
|
| 528 | 528 | |
| 529 | - if (!in_array($post_type, $all_postypes)) |
|
| 530 | - return false; |
|
| 529 | + if (!in_array($post_type, $all_postypes)) |
|
| 530 | + return false; |
|
| 531 | 531 | |
| 532 | - $sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type= %s and is_active=%d and is_default=%d", array($post_type, 1, 1)));
|
|
| 532 | + $sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type= %s and is_active=%d and is_default=%d", array($post_type, 1, 1)));
|
|
| 533 | 533 | |
| 534 | - if (!empty($sort_field_info)) |
|
| 535 | - return $sort_field_info; |
|
| 534 | + if (!empty($sort_field_info)) |
|
| 535 | + return $sort_field_info; |
|
| 536 | 536 | |
| 537 | - } |
|
| 537 | + } |
|
| 538 | 538 | |
| 539 | 539 | } |
| 540 | 540 | |
@@ -549,24 +549,24 @@ discard block |
||
| 549 | 549 | * @return bool|mixed|void Returns sort results, when the post type is valid. Otherwise returns false. |
| 550 | 550 | */ |
| 551 | 551 | function geodir_get_sort_options($post_type) {
|
| 552 | - global $wpdb; |
|
| 553 | - |
|
| 554 | - if ($post_type != '') {
|
|
| 555 | - $all_postypes = geodir_get_posttypes(); |
|
| 556 | - |
|
| 557 | - if (!in_array($post_type, $all_postypes)) |
|
| 558 | - return false; |
|
| 559 | - |
|
| 560 | - $sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array($post_type, 1)));
|
|
| 561 | - /** |
|
| 562 | - * Filter post sort options. |
|
| 563 | - * |
|
| 564 | - * @since 1.0.0 |
|
| 565 | - * @param array $sort_field_info Unfiltered sort field array. |
|
| 566 | - * @param string $post_type Post type. |
|
| 567 | - */ |
|
| 568 | - return apply_filters('geodir_get_sort_options', $sort_field_info, $post_type);
|
|
| 569 | - } |
|
| 552 | + global $wpdb; |
|
| 553 | + |
|
| 554 | + if ($post_type != '') {
|
|
| 555 | + $all_postypes = geodir_get_posttypes(); |
|
| 556 | + |
|
| 557 | + if (!in_array($post_type, $all_postypes)) |
|
| 558 | + return false; |
|
| 559 | + |
|
| 560 | + $sort_field_info = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type=%s AND is_active=%d AND (sort_asc=1 || sort_desc=1 || field_type='random') AND field_type != 'address' ORDER BY sort_order ASC", array($post_type, 1)));
|
|
| 561 | + /** |
|
| 562 | + * Filter post sort options. |
|
| 563 | + * |
|
| 564 | + * @since 1.0.0 |
|
| 565 | + * @param array $sort_field_info Unfiltered sort field array. |
|
| 566 | + * @param string $post_type Post type. |
|
| 567 | + */ |
|
| 568 | + return apply_filters('geodir_get_sort_options', $sort_field_info, $post_type);
|
|
| 569 | + } |
|
| 570 | 570 | |
| 571 | 571 | } |
| 572 | 572 | |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | */ |
| 581 | 581 | function geodir_display_sort_options() |
| 582 | 582 | {
|
| 583 | - global $wp_query; |
|
| 583 | + global $wp_query; |
|
| 584 | 584 | |
| 585 | 585 | /** |
| 586 | 586 | * On search pages there should be no sort options, sorting is done by search criteria. |
@@ -591,57 +591,57 @@ discard block |
||
| 591 | 591 | return; |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - $sort_by = ''; |
|
| 594 | + $sort_by = ''; |
|
| 595 | 595 | |
| 596 | - if (isset($_REQUEST['sort_by'])) $sort_by = $_REQUEST['sort_by']; |
|
| 596 | + if (isset($_REQUEST['sort_by'])) $sort_by = $_REQUEST['sort_by']; |
|
| 597 | 597 | |
| 598 | - $gd_post_type = geodir_get_current_posttype(); |
|
| 598 | + $gd_post_type = geodir_get_current_posttype(); |
|
| 599 | 599 | |
| 600 | - $sort_options = geodir_get_sort_options($gd_post_type); |
|
| 600 | + $sort_options = geodir_get_sort_options($gd_post_type); |
|
| 601 | 601 | |
| 602 | 602 | |
| 603 | - $sort_field_options = ''; |
|
| 603 | + $sort_field_options = ''; |
|
| 604 | 604 | |
| 605 | - if (!empty($sort_options)) {
|
|
| 606 | - foreach ($sort_options as $sort) {
|
|
| 605 | + if (!empty($sort_options)) {
|
|
| 606 | + foreach ($sort_options as $sort) {
|
|
| 607 | 607 | $sort = stripslashes_deep($sort); // strip slashes |
| 608 | 608 | |
| 609 | - $label = __($sort->site_title, 'geodirectory'); |
|
| 609 | + $label = __($sort->site_title, 'geodirectory'); |
|
| 610 | 610 | |
| 611 | - if ($sort->field_type == 'random') {
|
|
| 612 | - $key = $sort->field_type; |
|
| 613 | - ($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 614 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
|
|
| 615 | - } |
|
| 611 | + if ($sort->field_type == 'random') {
|
|
| 612 | + $key = $sort->field_type; |
|
| 613 | + ($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 614 | + $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
|
|
| 615 | + } |
|
| 616 | 616 | |
| 617 | - if ($sort->htmlvar_name == 'comment_count') {
|
|
| 618 | - $sort->htmlvar_name = 'rating_count'; |
|
| 619 | - } |
|
| 617 | + if ($sort->htmlvar_name == 'comment_count') {
|
|
| 618 | + $sort->htmlvar_name = 'rating_count'; |
|
| 619 | + } |
|
| 620 | 620 | |
| 621 | - if ($sort->sort_asc) {
|
|
| 622 | - $key = $sort->htmlvar_name . '_asc'; |
|
| 623 | - $label = $sort->site_title; |
|
| 624 | - if ($sort->asc_title) |
|
| 625 | - $label = $sort->asc_title; |
|
| 626 | - ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 627 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
|
|
| 628 | - } |
|
| 621 | + if ($sort->sort_asc) {
|
|
| 622 | + $key = $sort->htmlvar_name . '_asc'; |
|
| 623 | + $label = $sort->site_title; |
|
| 624 | + if ($sort->asc_title) |
|
| 625 | + $label = $sort->asc_title; |
|
| 626 | + ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 627 | + $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
|
|
| 628 | + } |
|
| 629 | 629 | |
| 630 | - if ($sort->sort_desc) {
|
|
| 631 | - $key = $sort->htmlvar_name . '_desc'; |
|
| 632 | - $label = $sort->site_title; |
|
| 633 | - if ($sort->desc_title) |
|
| 634 | - $label = $sort->desc_title; |
|
| 635 | - ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 636 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
|
|
| 637 | - } |
|
| 630 | + if ($sort->sort_desc) {
|
|
| 631 | + $key = $sort->htmlvar_name . '_desc'; |
|
| 632 | + $label = $sort->site_title; |
|
| 633 | + if ($sort->desc_title) |
|
| 634 | + $label = $sort->desc_title; |
|
| 635 | + ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
|
| 636 | + $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
|
|
| 637 | + } |
|
| 638 | 638 | |
| 639 | - } |
|
| 640 | - } |
|
| 639 | + } |
|
| 640 | + } |
|
| 641 | 641 | |
| 642 | - if ($sort_field_options != '') {
|
|
| 642 | + if ($sort_field_options != '') {
|
|
| 643 | 643 | |
| 644 | - ?> |
|
| 644 | + ?> |
|
| 645 | 645 | |
| 646 | 646 | <div class="geodir-tax-sort"> |
| 647 | 647 | |
@@ -650,14 +650,14 @@ discard block |
||
| 650 | 650 | <option |
| 651 | 651 | value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') echo 'selected="selected"';?>><?php _e('Sort By', 'geodirectory');?></option><?php
|
| 652 | 652 | |
| 653 | - echo $sort_field_options;?> |
|
| 653 | + echo $sort_field_options;?> |
|
| 654 | 654 | |
| 655 | 655 | </select> |
| 656 | 656 | |
| 657 | 657 | </div> |
| 658 | 658 | <?php |
| 659 | 659 | |
| 660 | - } |
|
| 660 | + } |
|
| 661 | 661 | |
| 662 | 662 | } |
| 663 | 663 | |
@@ -677,10 +677,10 @@ discard block |
||
| 677 | 677 | function geodir_advance_customfields_heading($title, $field_type) |
| 678 | 678 | {
|
| 679 | 679 | |
| 680 | - if (in_array($field_type, array('multiselect', 'textarea', 'taxonomy'))) {
|
|
| 681 | - $title = ''; |
|
| 682 | - } |
|
| 683 | - return $title; |
|
| 680 | + if (in_array($field_type, array('multiselect', 'textarea', 'taxonomy'))) {
|
|
| 681 | + $title = ''; |
|
| 682 | + } |
|
| 683 | + return $title; |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | |
@@ -697,69 +697,69 @@ discard block |
||
| 697 | 697 | * @return string Returns related posts html. |
| 698 | 698 | */ |
| 699 | 699 | function geodir_related_posts_display($request) {
|
| 700 | - if (!empty($request)) {
|
|
| 701 | - $before_title = (isset($request['before_title']) && !empty($request['before_title'])) ? $request['before_title'] : ''; |
|
| 702 | - $after_title = (isset($request['after_title']) && !empty($request['after_title'])) ? $request['after_title'] : ''; |
|
| 703 | - |
|
| 704 | - $title = (isset($request['title']) && !empty($request['title'])) ? $request['title'] : __('Related Listings', 'geodirectory');
|
|
| 705 | - $post_number = (isset($request['post_number']) && !empty($request['post_number'])) ? $request['post_number'] : '5'; |
|
| 706 | - $relate_to = (isset($request['relate_to']) && !empty($request['relate_to'])) ? $request['relate_to'] : 'category'; |
|
| 707 | - $layout = (isset($request['layout']) && !empty($request['layout'])) ? $request['layout'] : 'gridview_onehalf'; |
|
| 708 | - $add_location_filter = (isset($request['add_location_filter']) && !empty($request['add_location_filter'])) ? $request['add_location_filter'] : '0'; |
|
| 709 | - $listing_width = (isset($request['listing_width']) && !empty($request['listing_width'])) ? $request['listing_width'] : ''; |
|
| 710 | - $list_sort = (isset($request['list_sort']) && !empty($request['list_sort'])) ? $request['list_sort'] : 'latest'; |
|
| 711 | - $character_count = (isset($request['character_count']) && !empty($request['character_count'])) ? $request['character_count'] : ''; |
|
| 712 | - |
|
| 713 | - global $wpdb, $post, $gd_session; |
|
| 714 | - $origi_post = $post; |
|
| 715 | - $post_type = ''; |
|
| 716 | - $post_id = ''; |
|
| 717 | - $category_taxonomy = ''; |
|
| 718 | - $tax_field = 'id'; |
|
| 719 | - $category = array(); |
|
| 720 | - |
|
| 721 | - if (isset($_REQUEST['backandedit'])) {
|
|
| 722 | - $post = (object)$gd_session->get('listing');
|
|
| 723 | - $post_type = $post->listing_type; |
|
| 724 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 725 | - $post_id = $_REQUEST['pid']; |
|
| 726 | - } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 727 | - $post = geodir_get_post_info($_REQUEST['pid']); |
|
| 728 | - $post_type = $post->post_type; |
|
| 729 | - $post_id = $_REQUEST['pid']; |
|
| 730 | - } elseif (isset($post->post_type) && $post->post_type != '') {
|
|
| 731 | - $post_type = $post->post_type; |
|
| 732 | - $post_id = $post->ID; |
|
| 733 | - } |
|
| 700 | + if (!empty($request)) {
|
|
| 701 | + $before_title = (isset($request['before_title']) && !empty($request['before_title'])) ? $request['before_title'] : ''; |
|
| 702 | + $after_title = (isset($request['after_title']) && !empty($request['after_title'])) ? $request['after_title'] : ''; |
|
| 703 | + |
|
| 704 | + $title = (isset($request['title']) && !empty($request['title'])) ? $request['title'] : __('Related Listings', 'geodirectory');
|
|
| 705 | + $post_number = (isset($request['post_number']) && !empty($request['post_number'])) ? $request['post_number'] : '5'; |
|
| 706 | + $relate_to = (isset($request['relate_to']) && !empty($request['relate_to'])) ? $request['relate_to'] : 'category'; |
|
| 707 | + $layout = (isset($request['layout']) && !empty($request['layout'])) ? $request['layout'] : 'gridview_onehalf'; |
|
| 708 | + $add_location_filter = (isset($request['add_location_filter']) && !empty($request['add_location_filter'])) ? $request['add_location_filter'] : '0'; |
|
| 709 | + $listing_width = (isset($request['listing_width']) && !empty($request['listing_width'])) ? $request['listing_width'] : ''; |
|
| 710 | + $list_sort = (isset($request['list_sort']) && !empty($request['list_sort'])) ? $request['list_sort'] : 'latest'; |
|
| 711 | + $character_count = (isset($request['character_count']) && !empty($request['character_count'])) ? $request['character_count'] : ''; |
|
| 712 | + |
|
| 713 | + global $wpdb, $post, $gd_session; |
|
| 714 | + $origi_post = $post; |
|
| 715 | + $post_type = ''; |
|
| 716 | + $post_id = ''; |
|
| 717 | + $category_taxonomy = ''; |
|
| 718 | + $tax_field = 'id'; |
|
| 719 | + $category = array(); |
|
| 720 | + |
|
| 721 | + if (isset($_REQUEST['backandedit'])) {
|
|
| 722 | + $post = (object)$gd_session->get('listing');
|
|
| 723 | + $post_type = $post->listing_type; |
|
| 724 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 725 | + $post_id = $_REQUEST['pid']; |
|
| 726 | + } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 727 | + $post = geodir_get_post_info($_REQUEST['pid']); |
|
| 728 | + $post_type = $post->post_type; |
|
| 729 | + $post_id = $_REQUEST['pid']; |
|
| 730 | + } elseif (isset($post->post_type) && $post->post_type != '') {
|
|
| 731 | + $post_type = $post->post_type; |
|
| 732 | + $post_id = $post->ID; |
|
| 733 | + } |
|
| 734 | 734 | |
| 735 | - if ($relate_to == 'category') {
|
|
| 735 | + if ($relate_to == 'category') {
|
|
| 736 | 736 | |
| 737 | - $category_taxonomy = $post_type . $relate_to; |
|
| 738 | - if (isset($post->$category_taxonomy) && $post->$category_taxonomy != '') |
|
| 739 | - $category = explode(',', trim($post->$category_taxonomy, ','));
|
|
| 737 | + $category_taxonomy = $post_type . $relate_to; |
|
| 738 | + if (isset($post->$category_taxonomy) && $post->$category_taxonomy != '') |
|
| 739 | + $category = explode(',', trim($post->$category_taxonomy, ','));
|
|
| 740 | 740 | |
| 741 | - } elseif ($relate_to == 'tags') {
|
|
| 741 | + } elseif ($relate_to == 'tags') {
|
|
| 742 | 742 | |
| 743 | - $category_taxonomy = $post_type . '_' . $relate_to; |
|
| 744 | - if ($post->post_tags != '') |
|
| 745 | - $category = explode(',', trim($post->post_tags, ','));
|
|
| 746 | - $tax_field = 'name'; |
|
| 747 | - } |
|
| 743 | + $category_taxonomy = $post_type . '_' . $relate_to; |
|
| 744 | + if ($post->post_tags != '') |
|
| 745 | + $category = explode(',', trim($post->post_tags, ','));
|
|
| 746 | + $tax_field = 'name'; |
|
| 747 | + } |
|
| 748 | 748 | |
| 749 | - /* --- return false in invalid request --- */ |
|
| 750 | - if (empty($category)) |
|
| 751 | - return false; |
|
| 749 | + /* --- return false in invalid request --- */ |
|
| 750 | + if (empty($category)) |
|
| 751 | + return false; |
|
| 752 | 752 | |
| 753 | - $all_postypes = geodir_get_posttypes(); |
|
| 753 | + $all_postypes = geodir_get_posttypes(); |
|
| 754 | 754 | |
| 755 | - if (!in_array($post_type, $all_postypes)) |
|
| 756 | - return false; |
|
| 755 | + if (!in_array($post_type, $all_postypes)) |
|
| 756 | + return false; |
|
| 757 | 757 | |
| 758 | - /* --- return false in invalid request --- */ |
|
| 758 | + /* --- return false in invalid request --- */ |
|
| 759 | 759 | |
| 760 | - $location_url = ''; |
|
| 761 | - if ($add_location_filter != '0') {
|
|
| 762 | - $location_url = array(); |
|
| 760 | + $location_url = ''; |
|
| 761 | + if ($add_location_filter != '0') {
|
|
| 762 | + $location_url = array(); |
|
| 763 | 763 | $geodir_show_location_url = get_option('geodir_show_location_url');
|
| 764 | 764 | |
| 765 | 765 | $gd_city = get_query_var('gd_city');
|
@@ -767,13 +767,13 @@ discard block |
||
| 767 | 767 | if ($gd_city) {
|
| 768 | 768 | $gd_country = get_query_var('gd_country');
|
| 769 | 769 | $gd_region = get_query_var('gd_region');
|
| 770 | - } else {
|
|
| 771 | - $location = geodir_get_default_location(); |
|
| 770 | + } else {
|
|
| 771 | + $location = geodir_get_default_location(); |
|
| 772 | 772 | |
| 773 | 773 | $gd_country = isset($location->country_slug) ? $location->country_slug : ''; |
| 774 | 774 | $gd_region = isset($location->region_slug) ? $location->region_slug : ''; |
| 775 | 775 | $gd_city = isset($location->city_slug) ? $location->city_slug : ''; |
| 776 | - } |
|
| 776 | + } |
|
| 777 | 777 | |
| 778 | 778 | if ($geodir_show_location_url == 'all') {
|
| 779 | 779 | $location_url[] = $gd_country; |
@@ -786,92 +786,92 @@ discard block |
||
| 786 | 786 | |
| 787 | 787 | $location_url[] = $gd_city; |
| 788 | 788 | |
| 789 | - $location_url = implode('/', $location_url);
|
|
| 790 | - } |
|
| 789 | + $location_url = implode('/', $location_url);
|
|
| 790 | + } |
|
| 791 | 791 | |
| 792 | 792 | |
| 793 | - if (!empty($category)) {
|
|
| 794 | - global $geodir_add_location_url; |
|
| 795 | - $geodir_add_location_url = '0'; |
|
| 796 | - if ($add_location_filter != '0') {
|
|
| 797 | - $geodir_add_location_url = '1'; |
|
| 798 | - } |
|
| 799 | - $viewall_url = get_term_link((int)$category[0], $post_type . $category_taxonomy); |
|
| 800 | - $geodir_add_location_url = NULL; |
|
| 801 | - } |
|
| 802 | - ob_start(); |
|
| 803 | - ?> |
|
| 793 | + if (!empty($category)) {
|
|
| 794 | + global $geodir_add_location_url; |
|
| 795 | + $geodir_add_location_url = '0'; |
|
| 796 | + if ($add_location_filter != '0') {
|
|
| 797 | + $geodir_add_location_url = '1'; |
|
| 798 | + } |
|
| 799 | + $viewall_url = get_term_link((int)$category[0], $post_type . $category_taxonomy); |
|
| 800 | + $geodir_add_location_url = NULL; |
|
| 801 | + } |
|
| 802 | + ob_start(); |
|
| 803 | + ?> |
|
| 804 | 804 | |
| 805 | 805 | |
| 806 | 806 | <div class="geodir_locations geodir_location_listing"> |
| 807 | 807 | |
| 808 | 808 | <?php |
| 809 | - if (isset($request['is_widget']) && $request['is_widget'] == '1') {
|
|
| 810 | - /** geodir_before_title filter Documented in geodirectory_widgets.php */ |
|
| 811 | - $before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">');
|
|
| 812 | - /** geodir_after_title filter Documented in geodirectory_widgets.php */ |
|
| 813 | - $after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
|
|
| 814 | - ?> |
|
| 809 | + if (isset($request['is_widget']) && $request['is_widget'] == '1') {
|
|
| 810 | + /** geodir_before_title filter Documented in geodirectory_widgets.php */ |
|
| 811 | + $before_title = isset($before_title) ? $before_title : apply_filters('geodir_before_title', '<h3 class="widget-title">');
|
|
| 812 | + /** geodir_after_title filter Documented in geodirectory_widgets.php */ |
|
| 813 | + $after_title = isset($after_title) ? $after_title : apply_filters('geodir_after_title', '</h3>');
|
|
| 814 | + ?> |
|
| 815 | 815 | <div class="location_list_heading clearfix"> |
| 816 | 816 | <?php echo $before_title . $title . $after_title; ?> |
| 817 | 817 | </div> |
| 818 | 818 | <?php |
| 819 | - } |
|
| 820 | - $query_args = array( |
|
| 821 | - 'posts_per_page' => $post_number, |
|
| 822 | - 'is_geodir_loop' => true, |
|
| 823 | - 'gd_location' => ($add_location_filter) ? true : false, |
|
| 824 | - 'post_type' => $post_type, |
|
| 825 | - 'order_by' => $list_sort, |
|
| 826 | - 'post__not_in' => array($post_id), |
|
| 827 | - 'excerpt_length' => $character_count, |
|
| 828 | - ); |
|
| 819 | + } |
|
| 820 | + $query_args = array( |
|
| 821 | + 'posts_per_page' => $post_number, |
|
| 822 | + 'is_geodir_loop' => true, |
|
| 823 | + 'gd_location' => ($add_location_filter) ? true : false, |
|
| 824 | + 'post_type' => $post_type, |
|
| 825 | + 'order_by' => $list_sort, |
|
| 826 | + 'post__not_in' => array($post_id), |
|
| 827 | + 'excerpt_length' => $character_count, |
|
| 828 | + ); |
|
| 829 | 829 | |
| 830 | - $tax_query = array('taxonomy' => $category_taxonomy,
|
|
| 831 | - 'field' => $tax_field, |
|
| 832 | - 'terms' => $category |
|
| 833 | - ); |
|
| 830 | + $tax_query = array('taxonomy' => $category_taxonomy,
|
|
| 831 | + 'field' => $tax_field, |
|
| 832 | + 'terms' => $category |
|
| 833 | + ); |
|
| 834 | 834 | |
| 835 | - $query_args['tax_query'] = array($tax_query); |
|
| 835 | + $query_args['tax_query'] = array($tax_query); |
|
| 836 | 836 | |
| 837 | 837 | |
| 838 | - global $gridview_columns, $post; |
|
| 838 | + global $gridview_columns, $post; |
|
| 839 | 839 | |
| 840 | 840 | |
| 841 | - query_posts($query_args); |
|
| 841 | + query_posts($query_args); |
|
| 842 | 842 | |
| 843 | - if (strstr($layout, 'gridview')) {
|
|
| 844 | - $listing_view_exp = explode('_', $layout);
|
|
| 845 | - $gridview_columns = $layout; |
|
| 846 | - $layout = $listing_view_exp[0]; |
|
| 847 | - } else if ($layout == 'list') {
|
|
| 848 | - $gridview_columns = ''; |
|
| 849 | - } |
|
| 850 | - $related_posts = true; |
|
| 851 | - |
|
| 852 | - /** |
|
| 853 | - * Filters related listing listview template. |
|
| 854 | - * |
|
| 855 | - * @since 1.0.0 |
|
| 856 | - */ |
|
| 857 | - $template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview'));
|
|
| 858 | - |
|
| 859 | - /** |
|
| 860 | - * Includes related listing listview template. |
|
| 861 | - * |
|
| 862 | - * @since 1.0.0 |
|
| 863 | - */ |
|
| 864 | - include($template); |
|
| 865 | - |
|
| 866 | - wp_reset_query(); |
|
| 867 | - $post = $origi_post; |
|
| 868 | - ?> |
|
| 843 | + if (strstr($layout, 'gridview')) {
|
|
| 844 | + $listing_view_exp = explode('_', $layout);
|
|
| 845 | + $gridview_columns = $layout; |
|
| 846 | + $layout = $listing_view_exp[0]; |
|
| 847 | + } else if ($layout == 'list') {
|
|
| 848 | + $gridview_columns = ''; |
|
| 849 | + } |
|
| 850 | + $related_posts = true; |
|
| 851 | + |
|
| 852 | + /** |
|
| 853 | + * Filters related listing listview template. |
|
| 854 | + * |
|
| 855 | + * @since 1.0.0 |
|
| 856 | + */ |
|
| 857 | + $template = apply_filters("geodir_template_part-related-listing-listview", geodir_locate_template('listing-listview'));
|
|
| 858 | + |
|
| 859 | + /** |
|
| 860 | + * Includes related listing listview template. |
|
| 861 | + * |
|
| 862 | + * @since 1.0.0 |
|
| 863 | + */ |
|
| 864 | + include($template); |
|
| 865 | + |
|
| 866 | + wp_reset_query(); |
|
| 867 | + $post = $origi_post; |
|
| 868 | + ?> |
|
| 869 | 869 | |
| 870 | 870 | </div> |
| 871 | 871 | <?php |
| 872 | - return $html = ob_get_clean(); |
|
| 872 | + return $html = ob_get_clean(); |
|
| 873 | 873 | |
| 874 | - } |
|
| 874 | + } |
|
| 875 | 875 | |
| 876 | 876 | } |
| 877 | 877 | |
@@ -887,17 +887,17 @@ discard block |
||
| 887 | 887 | */ |
| 888 | 888 | function geodir_category_count_script() |
| 889 | 889 | {
|
| 890 | - global $geodir_post_category_str; |
|
| 890 | + global $geodir_post_category_str; |
|
| 891 | 891 | |
| 892 | - if (!empty($geodir_post_category_str)) {
|
|
| 893 | - $geodir_post_category_str = serialize($geodir_post_category_str); |
|
| 894 | - } |
|
| 892 | + if (!empty($geodir_post_category_str)) {
|
|
| 893 | + $geodir_post_category_str = serialize($geodir_post_category_str); |
|
| 894 | + } |
|
| 895 | 895 | |
| 896 | - $all_var['post_category_array'] = html_entity_decode((string)$geodir_post_category_str, ENT_QUOTES, 'UTF-8'); |
|
| 897 | - $script = "var post_category_array = " . json_encode($all_var) . ';'; |
|
| 898 | - echo '<script>'; |
|
| 899 | - echo $script; |
|
| 900 | - echo '</script>'; |
|
| 896 | + $all_var['post_category_array'] = html_entity_decode((string)$geodir_post_category_str, ENT_QUOTES, 'UTF-8'); |
|
| 897 | + $script = "var post_category_array = " . json_encode($all_var) . ';'; |
|
| 898 | + echo '<script>'; |
|
| 899 | + echo $script; |
|
| 900 | + echo '</script>'; |
|
| 901 | 901 | |
| 902 | 902 | } |
| 903 | 903 | |
@@ -910,16 +910,16 @@ discard block |
||
| 910 | 910 | */ |
| 911 | 911 | function geodir_get_map_default_language() |
| 912 | 912 | {
|
| 913 | - $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 914 | - if (empty($geodir_default_map_language)) |
|
| 915 | - $geodir_default_map_language = 'en'; |
|
| 916 | - /** |
|
| 917 | - * Filter default map language. |
|
| 918 | - * |
|
| 919 | - * @since 1.0.0 |
|
| 920 | - * @param string $geodir_default_map_language Default map language. |
|
| 921 | - */ |
|
| 922 | - return apply_filters('geodir_default_map_language', $geodir_default_map_language);
|
|
| 913 | + $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 914 | + if (empty($geodir_default_map_language)) |
|
| 915 | + $geodir_default_map_language = 'en'; |
|
| 916 | + /** |
|
| 917 | + * Filter default map language. |
|
| 918 | + * |
|
| 919 | + * @since 1.0.0 |
|
| 920 | + * @param string $geodir_default_map_language Default map language. |
|
| 921 | + */ |
|
| 922 | + return apply_filters('geodir_default_map_language', $geodir_default_map_language);
|
|
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | |
@@ -936,12 +936,12 @@ discard block |
||
| 936 | 936 | */ |
| 937 | 937 | function geodir_add_meta_keywords() |
| 938 | 938 | {
|
| 939 | - global $wp, $post, $wp_query, $wpdb, $geodir_addon_list; |
|
| 939 | + global $wp, $post, $wp_query, $wpdb, $geodir_addon_list; |
|
| 940 | 940 | |
| 941 | - $is_geodir_page = geodir_is_geodir_page(); |
|
| 942 | - if (!$is_geodir_page) {
|
|
| 943 | - return; |
|
| 944 | - }// if non GD page, bail |
|
| 941 | + $is_geodir_page = geodir_is_geodir_page(); |
|
| 942 | + if (!$is_geodir_page) {
|
|
| 943 | + return; |
|
| 944 | + }// if non GD page, bail |
|
| 945 | 945 | |
| 946 | 946 | $use_gd_meta = true; |
| 947 | 947 | if (class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) {
|
@@ -956,182 +956,182 @@ discard block |
||
| 956 | 956 | return; |
| 957 | 957 | }// bail if Yoast Wordpress SEO or All_in_One_SEO_Pack active. |
| 958 | 958 | |
| 959 | - $current_term = $wp_query->get_queried_object(); |
|
| 959 | + $current_term = $wp_query->get_queried_object(); |
|
| 960 | 960 | |
| 961 | - $all_postypes = geodir_get_posttypes(); |
|
| 961 | + $all_postypes = geodir_get_posttypes(); |
|
| 962 | 962 | |
| 963 | - $geodir_taxonomies = geodir_get_taxonomies('', true);
|
|
| 963 | + $geodir_taxonomies = geodir_get_taxonomies('', true);
|
|
| 964 | 964 | |
| 965 | - $meta_desc = ''; |
|
| 966 | - $meta_key = ''; |
|
| 967 | - if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) {
|
|
| 968 | - /** |
|
| 969 | - * Filter SEO meta location description. |
|
| 970 | - * |
|
| 971 | - * @since 1.0.0 |
|
| 972 | - */ |
|
| 973 | - $meta_desc = apply_filters('geodir_seo_meta_location_description', '');
|
|
| 974 | - $meta_desc .= ''; |
|
| 975 | - } |
|
| 976 | - if (have_posts() && is_single() OR is_page()) {
|
|
| 977 | - while (have_posts()) {
|
|
| 978 | - the_post(); |
|
| 979 | - |
|
| 980 | - if (has_excerpt()) {
|
|
| 981 | - $out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt())); |
|
| 982 | - if (empty($out_excerpt)) {
|
|
| 983 | - $out_excerpt = strip_tags(do_shortcode(get_the_excerpt())); |
|
| 984 | - } |
|
| 985 | - $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt);
|
|
| 986 | - } else {
|
|
| 987 | - $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content);
|
|
| 988 | - $out_excerpt = strip_tags(strip_shortcodes($out_excerpt)); |
|
| 989 | - if (empty($out_excerpt)) {
|
|
| 990 | - $out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content |
|
| 991 | - } |
|
| 992 | - $out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-'); |
|
| 993 | - } |
|
| 965 | + $meta_desc = ''; |
|
| 966 | + $meta_key = ''; |
|
| 967 | + if (isset($current_term->ID) && $current_term->ID == geodir_location_page_id()) {
|
|
| 968 | + /** |
|
| 969 | + * Filter SEO meta location description. |
|
| 970 | + * |
|
| 971 | + * @since 1.0.0 |
|
| 972 | + */ |
|
| 973 | + $meta_desc = apply_filters('geodir_seo_meta_location_description', '');
|
|
| 974 | + $meta_desc .= ''; |
|
| 975 | + } |
|
| 976 | + if (have_posts() && is_single() OR is_page()) {
|
|
| 977 | + while (have_posts()) {
|
|
| 978 | + the_post(); |
|
| 979 | + |
|
| 980 | + if (has_excerpt()) {
|
|
| 981 | + $out_excerpt = strip_tags(strip_shortcodes(get_the_excerpt())); |
|
| 982 | + if (empty($out_excerpt)) {
|
|
| 983 | + $out_excerpt = strip_tags(do_shortcode(get_the_excerpt())); |
|
| 984 | + } |
|
| 985 | + $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $out_excerpt);
|
|
| 986 | + } else {
|
|
| 987 | + $out_excerpt = str_replace(array("\r\n", "\r", "\n"), "", $post->post_content);
|
|
| 988 | + $out_excerpt = strip_tags(strip_shortcodes($out_excerpt)); |
|
| 989 | + if (empty($out_excerpt)) {
|
|
| 990 | + $out_excerpt = strip_tags(do_shortcode($out_excerpt)); // parse short code from content |
|
| 991 | + } |
|
| 992 | + $out_excerpt = trim(wp_trim_words($out_excerpt, 35, ''), '.!?,;:-'); |
|
| 993 | + } |
|
| 994 | 994 | |
| 995 | - $meta_desc .= $out_excerpt; |
|
| 996 | - } |
|
| 997 | - } elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
|
|
| 998 | - if (is_category()) {
|
|
| 999 | - $meta_desc .= __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE));
|
|
| 1000 | - } elseif (is_tag()) {
|
|
| 1001 | - $meta_desc .= __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE));
|
|
| 1002 | - } |
|
| 1003 | - } elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
|
|
| 1004 | - $meta_desc .= isset($current_term->description) ? $current_term->description : ''; |
|
| 1005 | - } |
|
| 995 | + $meta_desc .= $out_excerpt; |
|
| 996 | + } |
|
| 997 | + } elseif ((is_category() || is_tag()) && isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
|
|
| 998 | + if (is_category()) {
|
|
| 999 | + $meta_desc .= __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE));
|
|
| 1000 | + } elseif (is_tag()) {
|
|
| 1001 | + $meta_desc .= __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE));
|
|
| 1002 | + } |
|
| 1003 | + } elseif (isset($current_term->taxonomy) && in_array($current_term->taxonomy, $geodir_taxonomies)) {
|
|
| 1004 | + $meta_desc .= isset($current_term->description) ? $current_term->description : ''; |
|
| 1005 | + } |
|
| 1006 | 1006 | |
| 1007 | 1007 | |
| 1008 | - $geodir_post_type = geodir_get_current_posttype(); |
|
| 1009 | - $geodir_post_type_info = get_post_type_object($geodir_post_type); |
|
| 1010 | - $geodir_is_page_listing = geodir_is_page('listing') ? true : false;
|
|
| 1011 | - |
|
| 1012 | - $category_taxonomy = geodir_get_taxonomies($geodir_post_type); |
|
| 1013 | - $tag_taxonomy = geodir_get_taxonomies($geodir_post_type, true); |
|
| 1014 | - |
|
| 1015 | - $geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false; |
|
| 1016 | - $geodir_is_tag = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false; |
|
| 1017 | - |
|
| 1018 | - $geodir_is_search = geodir_is_page('search') ? true : false;
|
|
| 1019 | - $geodir_is_location = geodir_is_page('location') ? true : false;
|
|
| 1020 | - $geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false; |
|
| 1021 | - $godir_location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1022 | - $gd_city = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : NULL; |
|
| 1023 | - $gd_region = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : NULL; |
|
| 1024 | - $gd_country = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : NULL; |
|
| 1025 | - $replace_location = __('Everywhere', 'geodirectory');
|
|
| 1026 | - $location_id = NULL; |
|
| 1027 | - if ($geodir_location_manager) {
|
|
| 1028 | - $sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
|
|
| 1029 | - $location_id = (int)$wpdb->get_var($sql); |
|
| 1030 | - $location_type = geodir_what_is_current_location(); |
|
| 1031 | - if ($location_type == 'city') {
|
|
| 1032 | - $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
|
|
| 1033 | - } elseif ($location_type == 'region') {
|
|
| 1034 | - $replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
|
|
| 1035 | - } elseif ($location_type == 'country') {
|
|
| 1036 | - $replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
|
|
| 1037 | - $replace_location = __($replace_location, 'geodirectory'); |
|
| 1038 | - } |
|
| 1039 | - $country = get_query_var('gd_country');
|
|
| 1040 | - $region = get_query_var('gd_region');
|
|
| 1041 | - $city = get_query_var('gd_city');
|
|
| 1042 | - $current_location = ''; |
|
| 1043 | - if ($country != '') {
|
|
| 1044 | - $current_location = get_actual_location_name('country', $country, true);
|
|
| 1045 | - } |
|
| 1046 | - if ($region != '') {
|
|
| 1047 | - $current_location = get_actual_location_name('region', $region);
|
|
| 1048 | - } |
|
| 1049 | - if ($city != '') {
|
|
| 1050 | - $current_location = get_actual_location_name('city', $city);
|
|
| 1051 | - } |
|
| 1052 | - $replace_location = $current_location != '' ? $current_location : $replace_location; |
|
| 1053 | - } |
|
| 1008 | + $geodir_post_type = geodir_get_current_posttype(); |
|
| 1009 | + $geodir_post_type_info = get_post_type_object($geodir_post_type); |
|
| 1010 | + $geodir_is_page_listing = geodir_is_page('listing') ? true : false;
|
|
| 1011 | + |
|
| 1012 | + $category_taxonomy = geodir_get_taxonomies($geodir_post_type); |
|
| 1013 | + $tag_taxonomy = geodir_get_taxonomies($geodir_post_type, true); |
|
| 1014 | + |
|
| 1015 | + $geodir_is_category = isset($category_taxonomy[0]) && get_query_var($category_taxonomy[0]) ? get_query_var($category_taxonomy[0]) : false; |
|
| 1016 | + $geodir_is_tag = isset($tag_taxonomy[0]) && get_query_var($tag_taxonomy[0]) ? true : false; |
|
| 1017 | + |
|
| 1018 | + $geodir_is_search = geodir_is_page('search') ? true : false;
|
|
| 1019 | + $geodir_is_location = geodir_is_page('location') ? true : false;
|
|
| 1020 | + $geodir_location_manager = isset($geodir_addon_list['geodir_location_manager']) && $geodir_addon_list['geodir_location_manager'] = 'yes' ? true : false; |
|
| 1021 | + $godir_location_terms = geodir_get_current_location_terms('query_vars');
|
|
| 1022 | + $gd_city = $geodir_location_manager && isset($godir_location_terms['gd_city']) ? $godir_location_terms['gd_city'] : NULL; |
|
| 1023 | + $gd_region = $geodir_location_manager && isset($godir_location_terms['gd_region']) ? $godir_location_terms['gd_region'] : NULL; |
|
| 1024 | + $gd_country = $geodir_location_manager && isset($godir_location_terms['gd_country']) ? $godir_location_terms['gd_country'] : NULL; |
|
| 1025 | + $replace_location = __('Everywhere', 'geodirectory');
|
|
| 1026 | + $location_id = NULL; |
|
| 1027 | + if ($geodir_location_manager) {
|
|
| 1028 | + $sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
|
|
| 1029 | + $location_id = (int)$wpdb->get_var($sql); |
|
| 1030 | + $location_type = geodir_what_is_current_location(); |
|
| 1031 | + if ($location_type == 'city') {
|
|
| 1032 | + $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
|
|
| 1033 | + } elseif ($location_type == 'region') {
|
|
| 1034 | + $replace_location = geodir_get_current_location(array('what' => 'region', 'echo' => false));
|
|
| 1035 | + } elseif ($location_type == 'country') {
|
|
| 1036 | + $replace_location = geodir_get_current_location(array('what' => 'country', 'echo' => false));
|
|
| 1037 | + $replace_location = __($replace_location, 'geodirectory'); |
|
| 1038 | + } |
|
| 1039 | + $country = get_query_var('gd_country');
|
|
| 1040 | + $region = get_query_var('gd_region');
|
|
| 1041 | + $city = get_query_var('gd_city');
|
|
| 1042 | + $current_location = ''; |
|
| 1043 | + if ($country != '') {
|
|
| 1044 | + $current_location = get_actual_location_name('country', $country, true);
|
|
| 1045 | + } |
|
| 1046 | + if ($region != '') {
|
|
| 1047 | + $current_location = get_actual_location_name('region', $region);
|
|
| 1048 | + } |
|
| 1049 | + if ($city != '') {
|
|
| 1050 | + $current_location = get_actual_location_name('city', $city);
|
|
| 1051 | + } |
|
| 1052 | + $replace_location = $current_location != '' ? $current_location : $replace_location; |
|
| 1053 | + } |
|
| 1054 | 1054 | |
| 1055 | - $geodir_meta_keys = ''; |
|
| 1056 | - $geodir_meta_desc = ''; |
|
| 1057 | - if ($is_geodir_page && !empty($geodir_post_type_info)) {
|
|
| 1058 | - if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) {
|
|
| 1059 | - $geodir_meta_keys = isset($geodir_post_type_info->seo['meta_keyword']) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys; |
|
| 1060 | - |
|
| 1061 | - $geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc; |
|
| 1062 | - $geodir_meta_desc = isset($geodir_post_type_info->seo['meta_description']) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc; |
|
| 1063 | - |
|
| 1064 | - if ($geodir_is_category) {
|
|
| 1065 | - $category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : NULL;
|
|
| 1066 | - if (isset($category->term_id) && !empty($category->term_id)) {
|
|
| 1067 | - $category_id = $category->term_id; |
|
| 1068 | - $category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type); |
|
| 1069 | - if ($location_id) {
|
|
| 1070 | - $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id; |
|
| 1071 | - $cat_loc_option = get_option($option_name); |
|
| 1072 | - |
|
| 1073 | - $gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false; |
|
| 1074 | - if (!$gd_cat_loc_default) {
|
|
| 1075 | - $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id; |
|
| 1076 | - $option = get_option($option_name); |
|
| 1077 | - $category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc; |
|
| 1078 | - } |
|
| 1079 | - } |
|
| 1080 | - $geodir_meta_desc = __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE)) . '. ' . $category_desc;
|
|
| 1081 | - } |
|
| 1082 | - } else if ($geodir_is_tag) {
|
|
| 1083 | - $geodir_meta_desc = __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE)) . '. ' . $geodir_meta_desc;
|
|
| 1084 | - } |
|
| 1085 | - } |
|
| 1086 | - } |
|
| 1055 | + $geodir_meta_keys = ''; |
|
| 1056 | + $geodir_meta_desc = ''; |
|
| 1057 | + if ($is_geodir_page && !empty($geodir_post_type_info)) {
|
|
| 1058 | + if ($geodir_is_page_listing || $geodir_is_search || geodir_is_page('add-listing')) {
|
|
| 1059 | + $geodir_meta_keys = isset($geodir_post_type_info->seo['meta_keyword']) && $geodir_post_type_info->seo['meta_keyword'] != '' ? $geodir_post_type_info->seo['meta_keyword'] : $geodir_meta_keys; |
|
| 1060 | + |
|
| 1061 | + $geodir_meta_desc = isset($geodir_post_type_info->description) ? $geodir_post_type_info->description : $geodir_meta_desc; |
|
| 1062 | + $geodir_meta_desc = isset($geodir_post_type_info->seo['meta_description']) && $geodir_post_type_info->seo['meta_description'] != '' ? $geodir_post_type_info->seo['meta_description'] : $geodir_meta_desc; |
|
| 1063 | + |
|
| 1064 | + if ($geodir_is_category) {
|
|
| 1065 | + $category = $geodir_is_category ? get_term_by('slug', $geodir_is_category, $category_taxonomy[0]) : NULL;
|
|
| 1066 | + if (isset($category->term_id) && !empty($category->term_id)) {
|
|
| 1067 | + $category_id = $category->term_id; |
|
| 1068 | + $category_desc = trim($category->description) != '' ? trim($category->description) : get_tax_meta($category_id, 'ct_cat_top_desc', false, $geodir_post_type); |
|
| 1069 | + if ($location_id) {
|
|
| 1070 | + $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id; |
|
| 1071 | + $cat_loc_option = get_option($option_name); |
|
| 1072 | + |
|
| 1073 | + $gd_cat_loc_default = !empty($cat_loc_option) && isset($cat_loc_option['gd_cat_loc_default']) && $cat_loc_option['gd_cat_loc_default'] > 0 ? true : false; |
|
| 1074 | + if (!$gd_cat_loc_default) {
|
|
| 1075 | + $option_name = 'geodir_cat_loc_' . $geodir_post_type . '_' . $category_id . '_' . $location_id; |
|
| 1076 | + $option = get_option($option_name); |
|
| 1077 | + $category_desc = isset($option['gd_cat_loc_desc']) && trim($option['gd_cat_loc_desc']) != '' ? trim($option['gd_cat_loc_desc']) : $category_desc; |
|
| 1078 | + } |
|
| 1079 | + } |
|
| 1080 | + $geodir_meta_desc = __("Posts related to Category:", 'geodirectory') . " " . ucfirst(single_cat_title("", FALSE)) . '. ' . $category_desc;
|
|
| 1081 | + } |
|
| 1082 | + } else if ($geodir_is_tag) {
|
|
| 1083 | + $geodir_meta_desc = __("Posts related to Tag:", 'geodirectory') . " " . ucfirst(single_tag_title("", FALSE)) . '. ' . $geodir_meta_desc;
|
|
| 1084 | + } |
|
| 1085 | + } |
|
| 1086 | + } |
|
| 1087 | 1087 | |
| 1088 | 1088 | |
| 1089 | - $gd_page = ''; |
|
| 1090 | - if(geodir_is_page('home')){
|
|
| 1091 | - $gd_page = 'home'; |
|
| 1092 | - $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
|
|
| 1093 | - } |
|
| 1094 | - elseif(geodir_is_page('detail')){
|
|
| 1095 | - $gd_page = 'detail'; |
|
| 1096 | - $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
|
|
| 1097 | - } |
|
| 1098 | - elseif(geodir_is_page('pt')){
|
|
| 1099 | - $gd_page = 'pt'; |
|
| 1100 | - $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
|
|
| 1101 | - } |
|
| 1102 | - elseif(geodir_is_page('listing')){
|
|
| 1103 | - $gd_page = 'listing'; |
|
| 1104 | - $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
|
|
| 1105 | - } |
|
| 1106 | - elseif(geodir_is_page('location')){
|
|
| 1107 | - $gd_page = 'location'; |
|
| 1108 | - $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
|
|
| 1109 | - $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
|
|
| 1089 | + $gd_page = ''; |
|
| 1090 | + if(geodir_is_page('home')){
|
|
| 1091 | + $gd_page = 'home'; |
|
| 1092 | + $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
|
|
| 1093 | + } |
|
| 1094 | + elseif(geodir_is_page('detail')){
|
|
| 1095 | + $gd_page = 'detail'; |
|
| 1096 | + $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
|
|
| 1097 | + } |
|
| 1098 | + elseif(geodir_is_page('pt')){
|
|
| 1099 | + $gd_page = 'pt'; |
|
| 1100 | + $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
|
|
| 1101 | + } |
|
| 1102 | + elseif(geodir_is_page('listing')){
|
|
| 1103 | + $gd_page = 'listing'; |
|
| 1104 | + $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
|
|
| 1105 | + } |
|
| 1106 | + elseif(geodir_is_page('location')){
|
|
| 1107 | + $gd_page = 'location'; |
|
| 1108 | + $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
|
|
| 1109 | + $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
|
|
| 1110 | 1110 | |
| 1111 | - } |
|
| 1112 | - elseif(geodir_is_page('search')){
|
|
| 1113 | - $gd_page = 'search'; |
|
| 1114 | - $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
|
|
| 1115 | - } |
|
| 1116 | - elseif(geodir_is_page('add-listing')){
|
|
| 1117 | - $gd_page = 'add-listing'; |
|
| 1118 | - $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
|
|
| 1119 | - } |
|
| 1120 | - elseif(geodir_is_page('author')){
|
|
| 1121 | - $gd_page = 'author'; |
|
| 1122 | - $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
|
|
| 1123 | - } |
|
| 1124 | - elseif(geodir_is_page('login')){
|
|
| 1125 | - $gd_page = 'login'; |
|
| 1126 | - $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
|
|
| 1127 | - } |
|
| 1128 | - elseif(geodir_is_page('listing-success')){
|
|
| 1129 | - $gd_page = 'listing-success'; |
|
| 1130 | - $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
|
|
| 1131 | - } |
|
| 1111 | + } |
|
| 1112 | + elseif(geodir_is_page('search')){
|
|
| 1113 | + $gd_page = 'search'; |
|
| 1114 | + $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
|
|
| 1115 | + } |
|
| 1116 | + elseif(geodir_is_page('add-listing')){
|
|
| 1117 | + $gd_page = 'add-listing'; |
|
| 1118 | + $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
|
|
| 1119 | + } |
|
| 1120 | + elseif(geodir_is_page('author')){
|
|
| 1121 | + $gd_page = 'author'; |
|
| 1122 | + $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
|
|
| 1123 | + } |
|
| 1124 | + elseif(geodir_is_page('login')){
|
|
| 1125 | + $gd_page = 'login'; |
|
| 1126 | + $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
|
|
| 1127 | + } |
|
| 1128 | + elseif(geodir_is_page('listing-success')){
|
|
| 1129 | + $gd_page = 'listing-success'; |
|
| 1130 | + $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
|
|
| 1131 | + } |
|
| 1132 | 1132 | |
| 1133 | 1133 | |
| 1134 | - /* |
|
| 1134 | + /* |
|
| 1135 | 1135 | $geodir_meta_desc = $geodir_meta_desc != '' ? $geodir_meta_desc : $meta_desc; |
| 1136 | 1136 | if ($geodir_meta_desc != '') {
|
| 1137 | 1137 | $geodir_meta_desc = strip_tags($geodir_meta_desc); |
@@ -1144,74 +1144,74 @@ discard block |
||
| 1144 | 1144 | */ |
| 1145 | 1145 | |
| 1146 | 1146 | |
| 1147 | - if ($meta_desc) {
|
|
| 1148 | - $meta_desc = stripslashes_deep($meta_desc); |
|
| 1149 | - /** |
|
| 1150 | - * Filter page description to replace variables. |
|
| 1151 | - * |
|
| 1152 | - * @since 1.5.4 |
|
| 1153 | - * @param string $title The page description including variables. |
|
| 1154 | - * @param string $gd_page The GeoDirectory page type if any. |
|
| 1155 | - */ |
|
| 1156 | - $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'),$gd_page,'');
|
|
| 1157 | - |
|
| 1158 | - /** |
|
| 1159 | - * Filter SEO meta description. |
|
| 1160 | - * |
|
| 1161 | - * @since 1.0.0 |
|
| 1162 | - * @param string $meta_desc Meta description content. |
|
| 1163 | - */ |
|
| 1164 | - echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc);
|
|
| 1165 | - } |
|
| 1147 | + if ($meta_desc) {
|
|
| 1148 | + $meta_desc = stripslashes_deep($meta_desc); |
|
| 1149 | + /** |
|
| 1150 | + * Filter page description to replace variables. |
|
| 1151 | + * |
|
| 1152 | + * @since 1.5.4 |
|
| 1153 | + * @param string $title The page description including variables. |
|
| 1154 | + * @param string $gd_page The GeoDirectory page type if any. |
|
| 1155 | + */ |
|
| 1156 | + $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'),$gd_page,'');
|
|
| 1157 | + |
|
| 1158 | + /** |
|
| 1159 | + * Filter SEO meta description. |
|
| 1160 | + * |
|
| 1161 | + * @since 1.0.0 |
|
| 1162 | + * @param string $meta_desc Meta description content. |
|
| 1163 | + */ |
|
| 1164 | + echo apply_filters('geodir_seo_meta_description', '<meta name="description" content="' . $meta_desc . '" />', $meta_desc);
|
|
| 1165 | + } |
|
| 1166 | 1166 | |
| 1167 | - // meta keywords |
|
| 1168 | - if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
|
|
| 1169 | - $place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names"));
|
|
| 1170 | - $place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names"));
|
|
| 1171 | - |
|
| 1172 | - $meta_key .= implode(", ", array_merge((array)$place_cats, (array)$place_tags));
|
|
| 1173 | - } else {
|
|
| 1174 | - $posttags = get_the_tags(); |
|
| 1175 | - if ($posttags) {
|
|
| 1176 | - foreach ($posttags as $tag) {
|
|
| 1177 | - $meta_key .= $tag->name . ' '; |
|
| 1178 | - } |
|
| 1179 | - } else {
|
|
| 1180 | - $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
|
|
| 1181 | - $xt = 1; |
|
| 1167 | + // meta keywords |
|
| 1168 | + if (isset($post->post_type) && in_array($post->post_type, $all_postypes)) {
|
|
| 1169 | + $place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names"));
|
|
| 1170 | + $place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names"));
|
|
| 1171 | + |
|
| 1172 | + $meta_key .= implode(", ", array_merge((array)$place_cats, (array)$place_tags));
|
|
| 1173 | + } else {
|
|
| 1174 | + $posttags = get_the_tags(); |
|
| 1175 | + if ($posttags) {
|
|
| 1176 | + foreach ($posttags as $tag) {
|
|
| 1177 | + $meta_key .= $tag->name . ' '; |
|
| 1178 | + } |
|
| 1179 | + } else {
|
|
| 1180 | + $tags = get_tags(array('orderby' => 'count', 'order' => 'DESC'));
|
|
| 1181 | + $xt = 1; |
|
| 1182 | 1182 | |
| 1183 | - foreach ($tags as $tag) {
|
|
| 1184 | - if ($xt <= 20) {
|
|
| 1185 | - $meta_key .= $tag->name . ", "; |
|
| 1186 | - } |
|
| 1183 | + foreach ($tags as $tag) {
|
|
| 1184 | + if ($xt <= 20) {
|
|
| 1185 | + $meta_key .= $tag->name . ", "; |
|
| 1186 | + } |
|
| 1187 | 1187 | |
| 1188 | - $xt++; |
|
| 1189 | - } |
|
| 1190 | - } |
|
| 1191 | - } |
|
| 1188 | + $xt++; |
|
| 1189 | + } |
|
| 1190 | + } |
|
| 1191 | + } |
|
| 1192 | 1192 | |
| 1193 | - $meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key; |
|
| 1194 | - $geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys) : $meta_key; |
|
| 1195 | - if ($geodir_meta_keys != '') {
|
|
| 1196 | - $geodir_meta_keys = strip_tags($geodir_meta_keys); |
|
| 1197 | - $geodir_meta_keys = esc_html($geodir_meta_keys); |
|
| 1198 | - $geodir_meta_keys = geodir_strtolower($geodir_meta_keys); |
|
| 1199 | - $geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, ''); |
|
| 1200 | - $geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys);
|
|
| 1193 | + $meta_key = $meta_key != '' ? rtrim(trim($meta_key), ",") : $meta_key; |
|
| 1194 | + $geodir_meta_keys = $geodir_meta_keys != '' ? ($meta_key != '' ? $meta_key . ', ' . $geodir_meta_keys : $geodir_meta_keys) : $meta_key; |
|
| 1195 | + if ($geodir_meta_keys != '') {
|
|
| 1196 | + $geodir_meta_keys = strip_tags($geodir_meta_keys); |
|
| 1197 | + $geodir_meta_keys = esc_html($geodir_meta_keys); |
|
| 1198 | + $geodir_meta_keys = geodir_strtolower($geodir_meta_keys); |
|
| 1199 | + $geodir_meta_keys = wp_html_excerpt($geodir_meta_keys, 1000, ''); |
|
| 1200 | + $geodir_meta_keys = str_replace('%location%', $replace_location, $geodir_meta_keys);
|
|
| 1201 | 1201 | |
| 1202 | - $meta_key = rtrim(trim($geodir_meta_keys), ","); |
|
| 1203 | - } |
|
| 1202 | + $meta_key = rtrim(trim($geodir_meta_keys), ","); |
|
| 1203 | + } |
|
| 1204 | 1204 | |
| 1205 | - if ($meta_key) {
|
|
| 1206 | - $meta_key = stripslashes_deep($meta_key); |
|
| 1207 | - /** |
|
| 1208 | - * Filter SEO meta keywords. |
|
| 1209 | - * |
|
| 1210 | - * @since 1.0.0 |
|
| 1211 | - * @param string $meta_desc Meta keywords. |
|
| 1212 | - */ |
|
| 1213 | - echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key);
|
|
| 1214 | - } |
|
| 1205 | + if ($meta_key) {
|
|
| 1206 | + $meta_key = stripslashes_deep($meta_key); |
|
| 1207 | + /** |
|
| 1208 | + * Filter SEO meta keywords. |
|
| 1209 | + * |
|
| 1210 | + * @since 1.0.0 |
|
| 1211 | + * @param string $meta_desc Meta keywords. |
|
| 1212 | + */ |
|
| 1213 | + echo apply_filters('geodir_seo_meta_keywords', '<meta name="keywords" content="' . $meta_key . '" />', $meta_key);
|
|
| 1214 | + } |
|
| 1215 | 1215 | |
| 1216 | 1216 | } |
| 1217 | 1217 | |
@@ -1226,14 +1226,14 @@ discard block |
||
| 1226 | 1226 | */ |
| 1227 | 1227 | function geodir_detail_page_tabs_key_value_array() |
| 1228 | 1228 | {
|
| 1229 | - $geodir_detail_page_tabs_key_value_array = array(); |
|
| 1229 | + $geodir_detail_page_tabs_key_value_array = array(); |
|
| 1230 | 1230 | |
| 1231 | - $geodir_detail_page_tabs_array = geodir_detail_page_tabs_array(); |
|
| 1231 | + $geodir_detail_page_tabs_array = geodir_detail_page_tabs_array(); |
|
| 1232 | 1232 | |
| 1233 | - foreach ($geodir_detail_page_tabs_array as $key => $tabs_obj) {
|
|
| 1234 | - $geodir_detail_page_tabs_key_value_array[$key] = $tabs_obj['heading_text']; |
|
| 1235 | - } |
|
| 1236 | - return $geodir_detail_page_tabs_key_value_array; |
|
| 1233 | + foreach ($geodir_detail_page_tabs_array as $key => $tabs_obj) {
|
|
| 1234 | + $geodir_detail_page_tabs_key_value_array[$key] = $tabs_obj['heading_text']; |
|
| 1235 | + } |
|
| 1236 | + return $geodir_detail_page_tabs_key_value_array; |
|
| 1237 | 1237 | } |
| 1238 | 1238 | |
| 1239 | 1239 | /** |
@@ -1246,73 +1246,73 @@ discard block |
||
| 1246 | 1246 | function geodir_detail_page_tabs_array() |
| 1247 | 1247 | {
|
| 1248 | 1248 | |
| 1249 | - $arr_tabs = array(); |
|
| 1250 | - /** |
|
| 1251 | - * Filter detail page tab display. |
|
| 1252 | - * |
|
| 1253 | - * @since 1.0.0 |
|
| 1254 | - */ |
|
| 1255 | - $arr_tabs['post_profile'] = array( |
|
| 1256 | - 'heading_text' => __('Profile', 'geodirectory'),
|
|
| 1257 | - 'is_active_tab' => true, |
|
| 1258 | - 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_profile'),
|
|
| 1259 | - 'tab_content' => '' |
|
| 1260 | - ); |
|
| 1261 | - $arr_tabs['post_info'] = array( |
|
| 1262 | - 'heading_text' => __('More Info', 'geodirectory'),
|
|
| 1263 | - 'is_active_tab' => false, |
|
| 1264 | - 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_info'),
|
|
| 1265 | - 'tab_content' => '' |
|
| 1266 | - ); |
|
| 1267 | - |
|
| 1268 | - $arr_tabs['post_images'] = array( |
|
| 1269 | - 'heading_text' => __('Photo', 'geodirectory'),
|
|
| 1270 | - 'is_active_tab' => false, |
|
| 1271 | - 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_images'),
|
|
| 1272 | - 'tab_content' => '' |
|
| 1273 | - ); |
|
| 1274 | - |
|
| 1275 | - $arr_tabs['post_video'] = array( |
|
| 1276 | - 'heading_text' => __('Video', 'geodirectory'),
|
|
| 1277 | - 'is_active_tab' => false, |
|
| 1278 | - 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_video'),
|
|
| 1279 | - 'tab_content' => '' |
|
| 1280 | - ); |
|
| 1281 | - |
|
| 1282 | - $arr_tabs['special_offers'] = array( |
|
| 1283 | - 'heading_text' => __('Special Offers', 'geodirectory'),
|
|
| 1284 | - 'is_active_tab' => false, |
|
| 1285 | - 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'special_offers'),
|
|
| 1286 | - 'tab_content' => '' |
|
| 1287 | - ); |
|
| 1288 | - |
|
| 1289 | - $arr_tabs['post_map'] = array( |
|
| 1290 | - 'heading_text' => __('Map', 'geodirectory'),
|
|
| 1291 | - 'is_active_tab' => false, |
|
| 1292 | - 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_map'),
|
|
| 1293 | - 'tab_content' => '' |
|
| 1294 | - ); |
|
| 1295 | - |
|
| 1296 | - $arr_tabs['reviews'] = array( |
|
| 1297 | - 'heading_text' => __('Reviews', 'geodirectory'),
|
|
| 1298 | - 'is_active_tab' => false, |
|
| 1299 | - 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'reviews'),
|
|
| 1300 | - 'tab_content' => 'review display' |
|
| 1301 | - ); |
|
| 1302 | - |
|
| 1303 | - $arr_tabs['related_listing'] = array( |
|
| 1304 | - 'heading_text' => __('Related Listing', 'geodirectory'),
|
|
| 1305 | - 'is_active_tab' => false, |
|
| 1306 | - 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'related_listing'),
|
|
| 1307 | - 'tab_content' => '' |
|
| 1308 | - ); |
|
| 1309 | - |
|
| 1310 | - /** |
|
| 1311 | - * Filter the tabs array. |
|
| 1312 | - * |
|
| 1313 | - * @since 1.0.0 |
|
| 1314 | - */ |
|
| 1315 | - return apply_filters('geodir_detail_page_tab_list_extend', $arr_tabs);
|
|
| 1249 | + $arr_tabs = array(); |
|
| 1250 | + /** |
|
| 1251 | + * Filter detail page tab display. |
|
| 1252 | + * |
|
| 1253 | + * @since 1.0.0 |
|
| 1254 | + */ |
|
| 1255 | + $arr_tabs['post_profile'] = array( |
|
| 1256 | + 'heading_text' => __('Profile', 'geodirectory'),
|
|
| 1257 | + 'is_active_tab' => true, |
|
| 1258 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_profile'),
|
|
| 1259 | + 'tab_content' => '' |
|
| 1260 | + ); |
|
| 1261 | + $arr_tabs['post_info'] = array( |
|
| 1262 | + 'heading_text' => __('More Info', 'geodirectory'),
|
|
| 1263 | + 'is_active_tab' => false, |
|
| 1264 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_info'),
|
|
| 1265 | + 'tab_content' => '' |
|
| 1266 | + ); |
|
| 1267 | + |
|
| 1268 | + $arr_tabs['post_images'] = array( |
|
| 1269 | + 'heading_text' => __('Photo', 'geodirectory'),
|
|
| 1270 | + 'is_active_tab' => false, |
|
| 1271 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_images'),
|
|
| 1272 | + 'tab_content' => '' |
|
| 1273 | + ); |
|
| 1274 | + |
|
| 1275 | + $arr_tabs['post_video'] = array( |
|
| 1276 | + 'heading_text' => __('Video', 'geodirectory'),
|
|
| 1277 | + 'is_active_tab' => false, |
|
| 1278 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_video'),
|
|
| 1279 | + 'tab_content' => '' |
|
| 1280 | + ); |
|
| 1281 | + |
|
| 1282 | + $arr_tabs['special_offers'] = array( |
|
| 1283 | + 'heading_text' => __('Special Offers', 'geodirectory'),
|
|
| 1284 | + 'is_active_tab' => false, |
|
| 1285 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'special_offers'),
|
|
| 1286 | + 'tab_content' => '' |
|
| 1287 | + ); |
|
| 1288 | + |
|
| 1289 | + $arr_tabs['post_map'] = array( |
|
| 1290 | + 'heading_text' => __('Map', 'geodirectory'),
|
|
| 1291 | + 'is_active_tab' => false, |
|
| 1292 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'post_map'),
|
|
| 1293 | + 'tab_content' => '' |
|
| 1294 | + ); |
|
| 1295 | + |
|
| 1296 | + $arr_tabs['reviews'] = array( |
|
| 1297 | + 'heading_text' => __('Reviews', 'geodirectory'),
|
|
| 1298 | + 'is_active_tab' => false, |
|
| 1299 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'reviews'),
|
|
| 1300 | + 'tab_content' => 'review display' |
|
| 1301 | + ); |
|
| 1302 | + |
|
| 1303 | + $arr_tabs['related_listing'] = array( |
|
| 1304 | + 'heading_text' => __('Related Listing', 'geodirectory'),
|
|
| 1305 | + 'is_active_tab' => false, |
|
| 1306 | + 'is_display' => apply_filters('geodir_detail_page_tab_is_display', true, 'related_listing'),
|
|
| 1307 | + 'tab_content' => '' |
|
| 1308 | + ); |
|
| 1309 | + |
|
| 1310 | + /** |
|
| 1311 | + * Filter the tabs array. |
|
| 1312 | + * |
|
| 1313 | + * @since 1.0.0 |
|
| 1314 | + */ |
|
| 1315 | + return apply_filters('geodir_detail_page_tab_list_extend', $arr_tabs);
|
|
| 1316 | 1316 | |
| 1317 | 1317 | |
| 1318 | 1318 | } |
@@ -1327,15 +1327,15 @@ discard block |
||
| 1327 | 1327 | */ |
| 1328 | 1328 | function geodir_detail_page_tabs_list() |
| 1329 | 1329 | {
|
| 1330 | - $tabs_excluded = get_option('geodir_detail_page_tabs_excluded');
|
|
| 1331 | - $tabs_array = geodir_detail_page_tabs_array(); |
|
| 1332 | - if (!empty($tabs_excluded)) {
|
|
| 1333 | - foreach ($tabs_excluded as $tab) {
|
|
| 1334 | - if (array_key_exists($tab, $tabs_array)) |
|
| 1335 | - unset($tabs_array[$tab]); |
|
| 1336 | - } |
|
| 1337 | - } |
|
| 1338 | - return $tabs_array; |
|
| 1330 | + $tabs_excluded = get_option('geodir_detail_page_tabs_excluded');
|
|
| 1331 | + $tabs_array = geodir_detail_page_tabs_array(); |
|
| 1332 | + if (!empty($tabs_excluded)) {
|
|
| 1333 | + foreach ($tabs_excluded as $tab) {
|
|
| 1334 | + if (array_key_exists($tab, $tabs_array)) |
|
| 1335 | + unset($tabs_array[$tab]); |
|
| 1336 | + } |
|
| 1337 | + } |
|
| 1338 | + return $tabs_array; |
|
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | 1341 | |
@@ -1353,145 +1353,145 @@ discard block |
||
| 1353 | 1353 | */ |
| 1354 | 1354 | function geodir_show_detail_page_tabs() |
| 1355 | 1355 | {
|
| 1356 | - global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields; |
|
| 1356 | + global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields; |
|
| 1357 | 1357 | |
| 1358 | - $post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0; |
|
| 1359 | - $request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0; |
|
| 1360 | - $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend |
|
| 1358 | + $post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0; |
|
| 1359 | + $request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0; |
|
| 1360 | + $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend |
|
| 1361 | 1361 | |
| 1362 | - if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
|
|
| 1363 | - $post = geodir_get_post_info($request_post_id); |
|
| 1364 | - setup_postdata($post); |
|
| 1365 | - } |
|
| 1362 | + if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
|
|
| 1363 | + $post = geodir_get_post_info($request_post_id); |
|
| 1364 | + setup_postdata($post); |
|
| 1365 | + } |
|
| 1366 | 1366 | |
| 1367 | - $geodir_post_detail_fields = geodir_show_listing_info('detail');
|
|
| 1368 | - |
|
| 1369 | - if (geodir_is_page('detail')) {
|
|
| 1370 | - $video = geodir_get_video($post->ID); |
|
| 1371 | - $special_offers = geodir_get_special_offers($post->ID); |
|
| 1372 | - $related_listing_array = array(); |
|
| 1373 | - if (get_option('geodir_add_related_listing_posttypes'))
|
|
| 1374 | - $related_listing_array = get_option('geodir_add_related_listing_posttypes');
|
|
| 1375 | - |
|
| 1376 | - $related_listing = ''; |
|
| 1377 | - if (in_array($post->post_type, $related_listing_array)) {
|
|
| 1378 | - $request = array('post_number' => get_option('geodir_related_post_count'),
|
|
| 1379 | - 'relate_to' => get_option('geodir_related_post_relate_to'),
|
|
| 1380 | - 'layout' => get_option('geodir_related_post_listing_view'),
|
|
| 1381 | - 'add_location_filter' => get_option('geodir_related_post_location_filter'),
|
|
| 1382 | - 'list_sort' => get_option('geodir_related_post_sortby'),
|
|
| 1383 | - 'character_count' => get_option('geodir_related_post_excerpt'));
|
|
| 1384 | - |
|
| 1385 | - $related_listing = geodir_related_posts_display($request); |
|
| 1386 | - } |
|
| 1367 | + $geodir_post_detail_fields = geodir_show_listing_info('detail');
|
|
| 1368 | + |
|
| 1369 | + if (geodir_is_page('detail')) {
|
|
| 1370 | + $video = geodir_get_video($post->ID); |
|
| 1371 | + $special_offers = geodir_get_special_offers($post->ID); |
|
| 1372 | + $related_listing_array = array(); |
|
| 1373 | + if (get_option('geodir_add_related_listing_posttypes'))
|
|
| 1374 | + $related_listing_array = get_option('geodir_add_related_listing_posttypes');
|
|
| 1375 | + |
|
| 1376 | + $related_listing = ''; |
|
| 1377 | + if (in_array($post->post_type, $related_listing_array)) {
|
|
| 1378 | + $request = array('post_number' => get_option('geodir_related_post_count'),
|
|
| 1379 | + 'relate_to' => get_option('geodir_related_post_relate_to'),
|
|
| 1380 | + 'layout' => get_option('geodir_related_post_listing_view'),
|
|
| 1381 | + 'add_location_filter' => get_option('geodir_related_post_location_filter'),
|
|
| 1382 | + 'list_sort' => get_option('geodir_related_post_sortby'),
|
|
| 1383 | + 'character_count' => get_option('geodir_related_post_excerpt'));
|
|
| 1384 | + |
|
| 1385 | + $related_listing = geodir_related_posts_display($request); |
|
| 1386 | + } |
|
| 1387 | 1387 | |
| 1388 | - $post_images = geodir_get_images($post->ID, 'thumbnail'); |
|
| 1389 | - $thumb_image = ''; |
|
| 1390 | - if (!empty($post_images)) {
|
|
| 1391 | - foreach ($post_images as $image) {
|
|
| 1392 | - $caption = (!empty($image->caption)) ? $image->caption : ''; |
|
| 1393 | - $thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">'; |
|
| 1394 | - $thumb_image .= geodir_show_image($image, 'thumbnail', true, false); |
|
| 1395 | - $thumb_image .= '</a>'; |
|
| 1396 | - } |
|
| 1397 | - } |
|
| 1388 | + $post_images = geodir_get_images($post->ID, 'thumbnail'); |
|
| 1389 | + $thumb_image = ''; |
|
| 1390 | + if (!empty($post_images)) {
|
|
| 1391 | + foreach ($post_images as $image) {
|
|
| 1392 | + $caption = (!empty($image->caption)) ? $image->caption : ''; |
|
| 1393 | + $thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">'; |
|
| 1394 | + $thumb_image .= geodir_show_image($image, 'thumbnail', true, false); |
|
| 1395 | + $thumb_image .= '</a>'; |
|
| 1396 | + } |
|
| 1397 | + } |
|
| 1398 | 1398 | |
| 1399 | - $map_args = array(); |
|
| 1400 | - $map_args['map_canvas_name'] = 'detail_page_map_canvas'; |
|
| 1401 | - $map_args['width'] = '600'; |
|
| 1402 | - $map_args['height'] = '300'; |
|
| 1403 | - if ($post->post_mapzoom) {
|
|
| 1404 | - $map_args['zoom'] = '' . $post->post_mapzoom . ''; |
|
| 1405 | - } |
|
| 1406 | - $map_args['autozoom'] = false; |
|
| 1407 | - $map_args['child_collapse'] = '0'; |
|
| 1408 | - $map_args['enable_cat_filters'] = false; |
|
| 1409 | - $map_args['enable_text_search'] = false; |
|
| 1410 | - $map_args['enable_post_type_filters'] = false; |
|
| 1411 | - $map_args['enable_location_filters'] = false; |
|
| 1412 | - $map_args['enable_jason_on_load'] = true; |
|
| 1413 | - $map_args['enable_map_direction'] = true; |
|
| 1414 | - $map_args['map_class_name'] = 'geodir-map-detail-page'; |
|
| 1415 | - $map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP'; |
|
| 1416 | - } else if (geodir_is_page('preview')) {
|
|
| 1417 | - $video = isset($post->geodir_video) ? $post->geodir_video : ''; |
|
| 1418 | - $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : ''; |
|
| 1419 | - |
|
| 1420 | - if (isset($post->post_images)) |
|
| 1421 | - $post->post_images = trim($post->post_images, ","); |
|
| 1422 | - |
|
| 1423 | - if (isset($post->post_images) && !empty($post->post_images)) |
|
| 1424 | - $post_images = explode(",", $post->post_images);
|
|
| 1425 | - |
|
| 1426 | - $thumb_image = ''; |
|
| 1427 | - if (!empty($post_images)) {
|
|
| 1428 | - foreach ($post_images as $image) {
|
|
| 1429 | - if ($image != '') {
|
|
| 1430 | - $thumb_image .= '<a href="' . $image . '">'; |
|
| 1431 | - $thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
|
|
| 1432 | - $thumb_image .= '</a>'; |
|
| 1433 | - } |
|
| 1434 | - } |
|
| 1435 | - } |
|
| 1399 | + $map_args = array(); |
|
| 1400 | + $map_args['map_canvas_name'] = 'detail_page_map_canvas'; |
|
| 1401 | + $map_args['width'] = '600'; |
|
| 1402 | + $map_args['height'] = '300'; |
|
| 1403 | + if ($post->post_mapzoom) {
|
|
| 1404 | + $map_args['zoom'] = '' . $post->post_mapzoom . ''; |
|
| 1405 | + } |
|
| 1406 | + $map_args['autozoom'] = false; |
|
| 1407 | + $map_args['child_collapse'] = '0'; |
|
| 1408 | + $map_args['enable_cat_filters'] = false; |
|
| 1409 | + $map_args['enable_text_search'] = false; |
|
| 1410 | + $map_args['enable_post_type_filters'] = false; |
|
| 1411 | + $map_args['enable_location_filters'] = false; |
|
| 1412 | + $map_args['enable_jason_on_load'] = true; |
|
| 1413 | + $map_args['enable_map_direction'] = true; |
|
| 1414 | + $map_args['map_class_name'] = 'geodir-map-detail-page'; |
|
| 1415 | + $map_args['maptype'] = (!empty($post->post_mapview)) ? $post->post_mapview : 'ROADMAP'; |
|
| 1416 | + } else if (geodir_is_page('preview')) {
|
|
| 1417 | + $video = isset($post->geodir_video) ? $post->geodir_video : ''; |
|
| 1418 | + $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : ''; |
|
| 1419 | + |
|
| 1420 | + if (isset($post->post_images)) |
|
| 1421 | + $post->post_images = trim($post->post_images, ","); |
|
| 1422 | + |
|
| 1423 | + if (isset($post->post_images) && !empty($post->post_images)) |
|
| 1424 | + $post_images = explode(",", $post->post_images);
|
|
| 1425 | + |
|
| 1426 | + $thumb_image = ''; |
|
| 1427 | + if (!empty($post_images)) {
|
|
| 1428 | + foreach ($post_images as $image) {
|
|
| 1429 | + if ($image != '') {
|
|
| 1430 | + $thumb_image .= '<a href="' . $image . '">'; |
|
| 1431 | + $thumb_image .= geodir_show_image(array('src' => $image), 'thumbnail', true, false);
|
|
| 1432 | + $thumb_image .= '</a>'; |
|
| 1433 | + } |
|
| 1434 | + } |
|
| 1435 | + } |
|
| 1436 | 1436 | |
| 1437 | - global $map_jason; |
|
| 1438 | - $map_jason[] = $post->marker_json; |
|
| 1437 | + global $map_jason; |
|
| 1438 | + $map_jason[] = $post->marker_json; |
|
| 1439 | 1439 | |
| 1440 | - $address_latitude = isset($post->post_latitude) ? $post->post_latitude : ''; |
|
| 1441 | - $address_longitude = isset($post->post_longitude) ? $post->post_longitude : ''; |
|
| 1442 | - $mapview = isset($post->post_mapview) ? $post->post_mapview : ''; |
|
| 1443 | - $mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : ''; |
|
| 1444 | - if (!$mapzoom) {
|
|
| 1445 | - $mapzoom = 12; |
|
| 1446 | - } |
|
| 1440 | + $address_latitude = isset($post->post_latitude) ? $post->post_latitude : ''; |
|
| 1441 | + $address_longitude = isset($post->post_longitude) ? $post->post_longitude : ''; |
|
| 1442 | + $mapview = isset($post->post_mapview) ? $post->post_mapview : ''; |
|
| 1443 | + $mapzoom = isset($post->post_mapzoom) ? $post->post_mapzoom : ''; |
|
| 1444 | + if (!$mapzoom) {
|
|
| 1445 | + $mapzoom = 12; |
|
| 1446 | + } |
|
| 1447 | 1447 | |
| 1448 | - $map_args = array(); |
|
| 1449 | - $map_args['map_canvas_name'] = 'preview_map_canvas'; |
|
| 1450 | - $map_args['width'] = '950'; |
|
| 1451 | - $map_args['height'] = '300'; |
|
| 1452 | - $map_args['child_collapse'] = '0'; |
|
| 1453 | - $map_args['maptype'] = $mapview; |
|
| 1454 | - $map_args['autozoom'] = false; |
|
| 1455 | - $map_args['zoom'] = "$mapzoom"; |
|
| 1456 | - $map_args['latitude'] = $address_latitude; |
|
| 1457 | - $map_args['longitude'] = $address_longitude; |
|
| 1458 | - $map_args['enable_cat_filters'] = false; |
|
| 1459 | - $map_args['enable_text_search'] = false; |
|
| 1460 | - $map_args['enable_post_type_filters'] = false; |
|
| 1461 | - $map_args['enable_location_filters'] = false; |
|
| 1462 | - $map_args['enable_jason_on_load'] = true; |
|
| 1463 | - $map_args['enable_map_direction'] = true; |
|
| 1464 | - $map_args['map_class_name'] = 'geodir-map-preview-page'; |
|
| 1465 | - } |
|
| 1448 | + $map_args = array(); |
|
| 1449 | + $map_args['map_canvas_name'] = 'preview_map_canvas'; |
|
| 1450 | + $map_args['width'] = '950'; |
|
| 1451 | + $map_args['height'] = '300'; |
|
| 1452 | + $map_args['child_collapse'] = '0'; |
|
| 1453 | + $map_args['maptype'] = $mapview; |
|
| 1454 | + $map_args['autozoom'] = false; |
|
| 1455 | + $map_args['zoom'] = "$mapzoom"; |
|
| 1456 | + $map_args['latitude'] = $address_latitude; |
|
| 1457 | + $map_args['longitude'] = $address_longitude; |
|
| 1458 | + $map_args['enable_cat_filters'] = false; |
|
| 1459 | + $map_args['enable_text_search'] = false; |
|
| 1460 | + $map_args['enable_post_type_filters'] = false; |
|
| 1461 | + $map_args['enable_location_filters'] = false; |
|
| 1462 | + $map_args['enable_jason_on_load'] = true; |
|
| 1463 | + $map_args['enable_map_direction'] = true; |
|
| 1464 | + $map_args['map_class_name'] = 'geodir-map-preview-page'; |
|
| 1465 | + } |
|
| 1466 | 1466 | |
| 1467 | - $arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user |
|
| 1467 | + $arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user |
|
| 1468 | 1468 | |
| 1469 | - $active_tab = ''; |
|
| 1470 | - $active_tab_name = ''; |
|
| 1471 | - $default_tab = ''; |
|
| 1472 | - $default_tab_name = ''; |
|
| 1473 | - foreach($arr_detail_page_tabs as $tab_index => $tabs){
|
|
| 1474 | - if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
|
|
| 1475 | - $active_tab = $tab_index; |
|
| 1476 | - $active_tab_name = __($tabs['heading_text'], 'geodirectory'); |
|
| 1477 | - } |
|
| 1469 | + $active_tab = ''; |
|
| 1470 | + $active_tab_name = ''; |
|
| 1471 | + $default_tab = ''; |
|
| 1472 | + $default_tab_name = ''; |
|
| 1473 | + foreach($arr_detail_page_tabs as $tab_index => $tabs){
|
|
| 1474 | + if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && !empty($tabs['is_display']) && isset($tabs['heading_text']) && $tabs['heading_text']) {
|
|
| 1475 | + $active_tab = $tab_index; |
|
| 1476 | + $active_tab_name = __($tabs['heading_text'], 'geodirectory'); |
|
| 1477 | + } |
|
| 1478 | 1478 | |
| 1479 | - if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
|
|
| 1480 | - $default_tab = $tab_index; |
|
| 1481 | - $default_tab_name = __($tabs['heading_text'], 'geodirectory'); |
|
| 1482 | - } |
|
| 1483 | - } |
|
| 1479 | + if ($default_tab === '' && !empty($tabs['is_display']) && !empty($tabs['heading_text'])) {
|
|
| 1480 | + $default_tab = $tab_index; |
|
| 1481 | + $default_tab_name = __($tabs['heading_text'], 'geodirectory'); |
|
| 1482 | + } |
|
| 1483 | + } |
|
| 1484 | 1484 | |
| 1485 | - if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
|
|
| 1486 | - if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
|
|
| 1487 | - $arr_detail_page_tabs[$active_tab]['is_active_tab'] = false; |
|
| 1488 | - } |
|
| 1485 | + if ($active_tab === '' && $default_tab !== '') { // Make first tab acs a active tab if not any tab is active.
|
|
| 1486 | + if (isset($arr_detail_page_tabs[$active_tab]) && isset($arr_detail_page_tabs[$active_tab]['is_active_tab'])) {
|
|
| 1487 | + $arr_detail_page_tabs[$active_tab]['is_active_tab'] = false; |
|
| 1488 | + } |
|
| 1489 | 1489 | |
| 1490 | - $arr_detail_page_tabs[$default_tab]['is_active_tab'] = true; |
|
| 1491 | - $active_tab = $default_tab; |
|
| 1492 | - $active_tab_name = $default_tab_name; |
|
| 1493 | - } |
|
| 1494 | - ?> |
|
| 1490 | + $arr_detail_page_tabs[$default_tab]['is_active_tab'] = true; |
|
| 1491 | + $active_tab = $default_tab; |
|
| 1492 | + $active_tab_name = $default_tab_name; |
|
| 1493 | + } |
|
| 1494 | + ?> |
|
| 1495 | 1495 | <div class="geodir-tabs" id="gd-tabs" style="position:relative;"> |
| 1496 | 1496 | <div id="geodir-tab-mobile-menu" > |
| 1497 | 1497 | <i class="fa fa-bars"></i> |
@@ -1500,147 +1500,147 @@ discard block |
||
| 1500 | 1500 | </div> |
| 1501 | 1501 | <dl class="geodir-tab-head"> |
| 1502 | 1502 | <?php |
| 1503 | - /** |
|
| 1504 | - * Called before the details page tab list headings, inside the `dl` tag. |
|
| 1505 | - * |
|
| 1506 | - * @since 1.0.0 |
|
| 1507 | - * @see 'geodir_after_tab_list' |
|
| 1508 | - */ |
|
| 1509 | - do_action('geodir_before_tab_list'); ?>
|
|
| 1503 | + /** |
|
| 1504 | + * Called before the details page tab list headings, inside the `dl` tag. |
|
| 1505 | + * |
|
| 1506 | + * @since 1.0.0 |
|
| 1507 | + * @see 'geodir_after_tab_list' |
|
| 1508 | + */ |
|
| 1509 | + do_action('geodir_before_tab_list'); ?>
|
|
| 1510 | 1510 | <?php |
| 1511 | - foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
|
|
| 1512 | - if ($detail_page_tab['is_display']) {
|
|
| 1513 | - ?> |
|
| 1511 | + foreach ($arr_detail_page_tabs as $tab_index => $detail_page_tab) {
|
|
| 1512 | + if ($detail_page_tab['is_display']) {
|
|
| 1513 | + ?> |
|
| 1514 | 1514 | <dt></dt> <!-- added to comply with validation --> |
| 1515 | 1515 | <dd <?php if ($detail_page_tab['is_active_tab']){ ?>class="geodir-tab-active"<?php }?> ><a data-tab="#<?php echo $tab_index;?>" data-status="enable"><?php _e($detail_page_tab['heading_text'],'geodirectory');?></a>
|
| 1516 | 1516 | </dd> |
| 1517 | 1517 | <?php |
| 1518 | - ob_start() // start tab content buffering |
|
| 1519 | - ?> |
|
| 1518 | + ob_start() // start tab content buffering |
|
| 1519 | + ?> |
|
| 1520 | 1520 | <li id="<?php echo $tab_index;?>Tab"> |
| 1521 | 1521 | <div id="<?php echo $tab_index;?>" class="hash-offset"></div> |
| 1522 | 1522 | <?php |
| 1523 | - /** |
|
| 1524 | - * Called before the details tab content is output per tab. |
|
| 1525 | - * |
|
| 1526 | - * @since 1.0.0 |
|
| 1527 | - * @param string $tab_index The tab name ID. |
|
| 1528 | - */ |
|
| 1529 | - do_action('geodir_before_tab_content', $tab_index);
|
|
| 1530 | - |
|
| 1531 | - /** |
|
| 1532 | - * Called before the details tab content is output per tab. |
|
| 1533 | - * |
|
| 1534 | - * Uses dynamic hook name: geodir_before_$tab_index_tab_content |
|
| 1535 | - * |
|
| 1536 | - * @since 1.0.0 |
|
| 1537 | - * @todo do we need this if we have the hook above? 'geodir_before_tab_content' |
|
| 1538 | - */ |
|
| 1539 | - do_action('geodir_before_' . $tab_index . '_tab_content');
|
|
| 1540 | - /// write a code to generate content of each tab |
|
| 1541 | - switch ($tab_index) {
|
|
| 1542 | - case 'post_profile': |
|
| 1543 | - /** |
|
| 1544 | - * Called before the listing description content on the details page tab. |
|
| 1545 | - * |
|
| 1546 | - * @since 1.0.0 |
|
| 1547 | - */ |
|
| 1548 | - do_action('geodir_before_description_on_listing_detail');
|
|
| 1549 | - if (geodir_is_page('detail')) {
|
|
| 1550 | - the_content(); |
|
| 1551 | - } else {
|
|
| 1552 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 1553 | - echo apply_filters('the_content', stripslashes($post->post_desc));
|
|
| 1554 | - } |
|
| 1555 | - |
|
| 1556 | - /** |
|
| 1557 | - * Called after the listing description content on the details page tab. |
|
| 1558 | - * |
|
| 1559 | - * @since 1.0.0 |
|
| 1560 | - */ |
|
| 1561 | - do_action('geodir_after_description_on_listing_detail');
|
|
| 1562 | - break; |
|
| 1563 | - case 'post_info': |
|
| 1564 | - echo $geodir_post_detail_fields; |
|
| 1565 | - break; |
|
| 1566 | - case 'post_images': |
|
| 1567 | - echo $thumb_image; |
|
| 1568 | - break; |
|
| 1569 | - case 'post_video': |
|
| 1570 | - /** This action is documented in geodirectory_template_actions.php */ |
|
| 1571 | - echo apply_filters('the_content', stripslashes($video));// we apply the_content filter so oembed works also;
|
|
| 1572 | - break; |
|
| 1573 | - case 'special_offers': |
|
| 1574 | - echo wpautop(stripslashes($special_offers)); |
|
| 1575 | - |
|
| 1576 | - break; |
|
| 1577 | - case 'post_map': |
|
| 1578 | - geodir_draw_map($map_args); |
|
| 1579 | - break; |
|
| 1580 | - case 'reviews': |
|
| 1581 | - comments_template(); |
|
| 1582 | - break; |
|
| 1583 | - case 'related_listing': |
|
| 1584 | - echo $related_listing; |
|
| 1585 | - break; |
|
| 1586 | - default: {
|
|
| 1587 | - if ((isset($post->$tab_index) || (!isset($post->$tab_index) && (strpos($tab_index, 'gd_tab_') !== false || $tab_index == 'link_business'))) && !empty($detail_page_tab['tab_content'])) {
|
|
| 1588 | - echo $detail_page_tab['tab_content']; |
|
| 1589 | - } |
|
| 1590 | - } |
|
| 1591 | - break; |
|
| 1592 | - } |
|
| 1593 | - |
|
| 1594 | - /** |
|
| 1595 | - * Called after the details tab content is output per tab. |
|
| 1596 | - * |
|
| 1597 | - * @since 1.0.0 |
|
| 1598 | - */ |
|
| 1599 | - do_action('geodir_after_tab_content', $tab_index);
|
|
| 1600 | - |
|
| 1601 | - /** |
|
| 1602 | - * Called after the details tab content is output per tab. |
|
| 1603 | - * |
|
| 1604 | - * Uses dynamic hook name: geodir_after_$tab_index_tab_content |
|
| 1605 | - * |
|
| 1606 | - * @since 1.0.0 |
|
| 1607 | - * @todo do we need this if we have the hook above? 'geodir_after_tab_content' |
|
| 1608 | - */ |
|
| 1609 | - do_action('geodir_after_' . $tab_index . '_tab_content');
|
|
| 1610 | - ?> </li> |
|
| 1523 | + /** |
|
| 1524 | + * Called before the details tab content is output per tab. |
|
| 1525 | + * |
|
| 1526 | + * @since 1.0.0 |
|
| 1527 | + * @param string $tab_index The tab name ID. |
|
| 1528 | + */ |
|
| 1529 | + do_action('geodir_before_tab_content', $tab_index);
|
|
| 1530 | + |
|
| 1531 | + /** |
|
| 1532 | + * Called before the details tab content is output per tab. |
|
| 1533 | + * |
|
| 1534 | + * Uses dynamic hook name: geodir_before_$tab_index_tab_content |
|
| 1535 | + * |
|
| 1536 | + * @since 1.0.0 |
|
| 1537 | + * @todo do we need this if we have the hook above? 'geodir_before_tab_content' |
|
| 1538 | + */ |
|
| 1539 | + do_action('geodir_before_' . $tab_index . '_tab_content');
|
|
| 1540 | + /// write a code to generate content of each tab |
|
| 1541 | + switch ($tab_index) {
|
|
| 1542 | + case 'post_profile': |
|
| 1543 | + /** |
|
| 1544 | + * Called before the listing description content on the details page tab. |
|
| 1545 | + * |
|
| 1546 | + * @since 1.0.0 |
|
| 1547 | + */ |
|
| 1548 | + do_action('geodir_before_description_on_listing_detail');
|
|
| 1549 | + if (geodir_is_page('detail')) {
|
|
| 1550 | + the_content(); |
|
| 1551 | + } else {
|
|
| 1552 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 1553 | + echo apply_filters('the_content', stripslashes($post->post_desc));
|
|
| 1554 | + } |
|
| 1555 | + |
|
| 1556 | + /** |
|
| 1557 | + * Called after the listing description content on the details page tab. |
|
| 1558 | + * |
|
| 1559 | + * @since 1.0.0 |
|
| 1560 | + */ |
|
| 1561 | + do_action('geodir_after_description_on_listing_detail');
|
|
| 1562 | + break; |
|
| 1563 | + case 'post_info': |
|
| 1564 | + echo $geodir_post_detail_fields; |
|
| 1565 | + break; |
|
| 1566 | + case 'post_images': |
|
| 1567 | + echo $thumb_image; |
|
| 1568 | + break; |
|
| 1569 | + case 'post_video': |
|
| 1570 | + /** This action is documented in geodirectory_template_actions.php */ |
|
| 1571 | + echo apply_filters('the_content', stripslashes($video));// we apply the_content filter so oembed works also;
|
|
| 1572 | + break; |
|
| 1573 | + case 'special_offers': |
|
| 1574 | + echo wpautop(stripslashes($special_offers)); |
|
| 1575 | + |
|
| 1576 | + break; |
|
| 1577 | + case 'post_map': |
|
| 1578 | + geodir_draw_map($map_args); |
|
| 1579 | + break; |
|
| 1580 | + case 'reviews': |
|
| 1581 | + comments_template(); |
|
| 1582 | + break; |
|
| 1583 | + case 'related_listing': |
|
| 1584 | + echo $related_listing; |
|
| 1585 | + break; |
|
| 1586 | + default: {
|
|
| 1587 | + if ((isset($post->$tab_index) || (!isset($post->$tab_index) && (strpos($tab_index, 'gd_tab_') !== false || $tab_index == 'link_business'))) && !empty($detail_page_tab['tab_content'])) {
|
|
| 1588 | + echo $detail_page_tab['tab_content']; |
|
| 1589 | + } |
|
| 1590 | + } |
|
| 1591 | + break; |
|
| 1592 | + } |
|
| 1593 | + |
|
| 1594 | + /** |
|
| 1595 | + * Called after the details tab content is output per tab. |
|
| 1596 | + * |
|
| 1597 | + * @since 1.0.0 |
|
| 1598 | + */ |
|
| 1599 | + do_action('geodir_after_tab_content', $tab_index);
|
|
| 1600 | + |
|
| 1601 | + /** |
|
| 1602 | + * Called after the details tab content is output per tab. |
|
| 1603 | + * |
|
| 1604 | + * Uses dynamic hook name: geodir_after_$tab_index_tab_content |
|
| 1605 | + * |
|
| 1606 | + * @since 1.0.0 |
|
| 1607 | + * @todo do we need this if we have the hook above? 'geodir_after_tab_content' |
|
| 1608 | + */ |
|
| 1609 | + do_action('geodir_after_' . $tab_index . '_tab_content');
|
|
| 1610 | + ?> </li> |
|
| 1611 | 1611 | <?php |
| 1612 | - /** |
|
| 1613 | - * Filter the current tab content. |
|
| 1614 | - * |
|
| 1615 | - * @since 1.0.0 |
|
| 1616 | - */ |
|
| 1617 | - $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean());
|
|
| 1618 | - } // end of if for is_display |
|
| 1619 | - }// end of foreach |
|
| 1620 | - |
|
| 1621 | - /** |
|
| 1622 | - * Called after the details page tab list headings, inside the `dl` tag. |
|
| 1623 | - * |
|
| 1624 | - * @since 1.0.0 |
|
| 1625 | - * @see 'geodir_before_tab_list' |
|
| 1626 | - */ |
|
| 1627 | - do_action('geodir_after_tab_list');
|
|
| 1628 | - ?> |
|
| 1612 | + /** |
|
| 1613 | + * Filter the current tab content. |
|
| 1614 | + * |
|
| 1615 | + * @since 1.0.0 |
|
| 1616 | + */ |
|
| 1617 | + $arr_detail_page_tabs[$tab_index]['tab_content'] = apply_filters("geodir_modify_" . $detail_page_tab['tab_content'] . "_tab_content", ob_get_clean());
|
|
| 1618 | + } // end of if for is_display |
|
| 1619 | + }// end of foreach |
|
| 1620 | + |
|
| 1621 | + /** |
|
| 1622 | + * Called after the details page tab list headings, inside the `dl` tag. |
|
| 1623 | + * |
|
| 1624 | + * @since 1.0.0 |
|
| 1625 | + * @see 'geodir_before_tab_list' |
|
| 1626 | + */ |
|
| 1627 | + do_action('geodir_after_tab_list');
|
|
| 1628 | + ?> |
|
| 1629 | 1629 | </dl> |
| 1630 | 1630 | <ul class="geodir-tabs-content entry-content" style="position:relative;"> |
| 1631 | 1631 | <?php |
| 1632 | - foreach ($arr_detail_page_tabs as $detail_page_tab) {
|
|
| 1633 | - if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
|
|
| 1634 | - echo $detail_page_tab['tab_content']; |
|
| 1635 | - }// end of if |
|
| 1636 | - }// end of foreach |
|
| 1637 | - |
|
| 1638 | - /** |
|
| 1639 | - * Called after all the tab content is output in `li` tags, called before the closing `ul` tag. |
|
| 1640 | - * |
|
| 1641 | - * @since 1.0.0 |
|
| 1642 | - */ |
|
| 1643 | - do_action('geodir_add_tab_content'); ?>
|
|
| 1632 | + foreach ($arr_detail_page_tabs as $detail_page_tab) {
|
|
| 1633 | + if ($detail_page_tab['is_display'] && !empty($detail_page_tab['tab_content'])) {
|
|
| 1634 | + echo $detail_page_tab['tab_content']; |
|
| 1635 | + }// end of if |
|
| 1636 | + }// end of foreach |
|
| 1637 | + |
|
| 1638 | + /** |
|
| 1639 | + * Called after all the tab content is output in `li` tags, called before the closing `ul` tag. |
|
| 1640 | + * |
|
| 1641 | + * @since 1.0.0 |
|
| 1642 | + */ |
|
| 1643 | + do_action('geodir_add_tab_content'); ?>
|
|
| 1644 | 1644 | </ul> |
| 1645 | 1645 | <!--gd-tabs-content ul end--> |
| 1646 | 1646 | </div> |
@@ -1677,127 +1677,127 @@ discard block |
||
| 1677 | 1677 | */ |
| 1678 | 1678 | function geodir_exif($file) |
| 1679 | 1679 | {
|
| 1680 | - if (empty($file) || !is_array($file)) {
|
|
| 1681 | - return $file; |
|
| 1682 | - } |
|
| 1680 | + if (empty($file) || !is_array($file)) {
|
|
| 1681 | + return $file; |
|
| 1682 | + } |
|
| 1683 | 1683 | |
| 1684 | - $file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : ''; |
|
| 1685 | - if (!($file_path && file_exists($file_path))) {
|
|
| 1686 | - return $file; |
|
| 1687 | - } |
|
| 1688 | - $file['file'] = $file_path; |
|
| 1684 | + $file_path = !empty($file['tmp_name']) ? sanitize_text_field($file['tmp_name']) : ''; |
|
| 1685 | + if (!($file_path && file_exists($file_path))) {
|
|
| 1686 | + return $file; |
|
| 1687 | + } |
|
| 1688 | + $file['file'] = $file_path; |
|
| 1689 | 1689 | |
| 1690 | - if (!file_is_valid_image($file_path)) {
|
|
| 1691 | - return $file; // Bail if file is not an image. |
|
| 1692 | - } |
|
| 1690 | + if (!file_is_valid_image($file_path)) {
|
|
| 1691 | + return $file; // Bail if file is not an image. |
|
| 1692 | + } |
|
| 1693 | 1693 | |
| 1694 | - if (!function_exists('wp_get_image_editor')) {
|
|
| 1695 | - return $file; |
|
| 1696 | - } |
|
| 1694 | + if (!function_exists('wp_get_image_editor')) {
|
|
| 1695 | + return $file; |
|
| 1696 | + } |
|
| 1697 | 1697 | |
| 1698 | - $mime_type = $file['type']; |
|
| 1699 | - $exif = array(); |
|
| 1700 | - if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
|
|
| 1701 | - try {
|
|
| 1702 | - $exif = exif_read_data($file_path); |
|
| 1703 | - } catch(Exception $e) {
|
|
| 1704 | - $exif = array(); |
|
| 1705 | - } |
|
| 1706 | - } |
|
| 1698 | + $mime_type = $file['type']; |
|
| 1699 | + $exif = array(); |
|
| 1700 | + if ($mime_type == 'image/jpeg' && function_exists('exif_read_data')) {
|
|
| 1701 | + try {
|
|
| 1702 | + $exif = exif_read_data($file_path); |
|
| 1703 | + } catch(Exception $e) {
|
|
| 1704 | + $exif = array(); |
|
| 1705 | + } |
|
| 1706 | + } |
|
| 1707 | 1707 | |
| 1708 | - $rotate = false; |
|
| 1709 | - $flip = false; |
|
| 1710 | - $modify = false; |
|
| 1711 | - $orientation = 0; |
|
| 1712 | - if (!empty($exif) && isset($exif['Orientation'])) {
|
|
| 1713 | - switch ((int)$exif['Orientation']) {
|
|
| 1714 | - case 1: |
|
| 1715 | - // do nothing |
|
| 1716 | - break; |
|
| 1717 | - case 2: |
|
| 1718 | - $flip = array(false, true); |
|
| 1719 | - $modify = true; |
|
| 1720 | - break; |
|
| 1721 | - case 3: |
|
| 1722 | - $orientation = -180; |
|
| 1723 | - $rotate = true; |
|
| 1724 | - $modify = true; |
|
| 1725 | - break; |
|
| 1726 | - case 4: |
|
| 1727 | - $flip = array(true, false); |
|
| 1728 | - $modify = true; |
|
| 1729 | - break; |
|
| 1730 | - case 5: |
|
| 1731 | - $orientation = -90; |
|
| 1732 | - $rotate = true; |
|
| 1733 | - $flip = array(false, true); |
|
| 1734 | - $modify = true; |
|
| 1735 | - break; |
|
| 1736 | - case 6: |
|
| 1737 | - $orientation = -90; |
|
| 1738 | - $rotate = true; |
|
| 1739 | - $modify = true; |
|
| 1740 | - break; |
|
| 1741 | - case 7: |
|
| 1742 | - $orientation = -270; |
|
| 1743 | - $rotate = true; |
|
| 1744 | - $flip = array(false, true); |
|
| 1745 | - $modify = true; |
|
| 1746 | - break; |
|
| 1747 | - case 8: |
|
| 1748 | - case 9: |
|
| 1749 | - $orientation = -270; |
|
| 1750 | - $rotate = true; |
|
| 1751 | - $modify = true; |
|
| 1752 | - break; |
|
| 1753 | - default: |
|
| 1754 | - $orientation = 0; |
|
| 1755 | - $rotate = true; |
|
| 1756 | - $modify = true; |
|
| 1757 | - break; |
|
| 1758 | - } |
|
| 1759 | - } |
|
| 1708 | + $rotate = false; |
|
| 1709 | + $flip = false; |
|
| 1710 | + $modify = false; |
|
| 1711 | + $orientation = 0; |
|
| 1712 | + if (!empty($exif) && isset($exif['Orientation'])) {
|
|
| 1713 | + switch ((int)$exif['Orientation']) {
|
|
| 1714 | + case 1: |
|
| 1715 | + // do nothing |
|
| 1716 | + break; |
|
| 1717 | + case 2: |
|
| 1718 | + $flip = array(false, true); |
|
| 1719 | + $modify = true; |
|
| 1720 | + break; |
|
| 1721 | + case 3: |
|
| 1722 | + $orientation = -180; |
|
| 1723 | + $rotate = true; |
|
| 1724 | + $modify = true; |
|
| 1725 | + break; |
|
| 1726 | + case 4: |
|
| 1727 | + $flip = array(true, false); |
|
| 1728 | + $modify = true; |
|
| 1729 | + break; |
|
| 1730 | + case 5: |
|
| 1731 | + $orientation = -90; |
|
| 1732 | + $rotate = true; |
|
| 1733 | + $flip = array(false, true); |
|
| 1734 | + $modify = true; |
|
| 1735 | + break; |
|
| 1736 | + case 6: |
|
| 1737 | + $orientation = -90; |
|
| 1738 | + $rotate = true; |
|
| 1739 | + $modify = true; |
|
| 1740 | + break; |
|
| 1741 | + case 7: |
|
| 1742 | + $orientation = -270; |
|
| 1743 | + $rotate = true; |
|
| 1744 | + $flip = array(false, true); |
|
| 1745 | + $modify = true; |
|
| 1746 | + break; |
|
| 1747 | + case 8: |
|
| 1748 | + case 9: |
|
| 1749 | + $orientation = -270; |
|
| 1750 | + $rotate = true; |
|
| 1751 | + $modify = true; |
|
| 1752 | + break; |
|
| 1753 | + default: |
|
| 1754 | + $orientation = 0; |
|
| 1755 | + $rotate = true; |
|
| 1756 | + $modify = true; |
|
| 1757 | + break; |
|
| 1758 | + } |
|
| 1759 | + } |
|
| 1760 | 1760 | |
| 1761 | - $quality = null; |
|
| 1762 | - /** |
|
| 1763 | - * Filter the image quality. |
|
| 1764 | - * |
|
| 1765 | - * @since 1.5.7 |
|
| 1766 | - * @param int|null $quality Image Compression quality between 1-100% scale. Default null. |
|
| 1767 | - * @param string $quality Image mime type. |
|
| 1768 | - */ |
|
| 1769 | - $quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
|
|
| 1770 | - if ($quality !== null) {
|
|
| 1771 | - $modify = true; |
|
| 1772 | - } |
|
| 1761 | + $quality = null; |
|
| 1762 | + /** |
|
| 1763 | + * Filter the image quality. |
|
| 1764 | + * |
|
| 1765 | + * @since 1.5.7 |
|
| 1766 | + * @param int|null $quality Image Compression quality between 1-100% scale. Default null. |
|
| 1767 | + * @param string $quality Image mime type. |
|
| 1768 | + */ |
|
| 1769 | + $quality = apply_filters('geodir_image_upload_set_quality', $quality, $mime_type);
|
|
| 1770 | + if ($quality !== null) {
|
|
| 1771 | + $modify = true; |
|
| 1772 | + } |
|
| 1773 | 1773 | |
| 1774 | - if (!$modify) {
|
|
| 1775 | - return $file; // no change |
|
| 1776 | - } |
|
| 1774 | + if (!$modify) {
|
|
| 1775 | + return $file; // no change |
|
| 1776 | + } |
|
| 1777 | 1777 | |
| 1778 | - $image = wp_get_image_editor($file_path); |
|
| 1779 | - if (!is_wp_error($image)) {
|
|
| 1780 | - if ($rotate) {
|
|
| 1781 | - $image->rotate($orientation); |
|
| 1782 | - } |
|
| 1778 | + $image = wp_get_image_editor($file_path); |
|
| 1779 | + if (!is_wp_error($image)) {
|
|
| 1780 | + if ($rotate) {
|
|
| 1781 | + $image->rotate($orientation); |
|
| 1782 | + } |
|
| 1783 | 1783 | |
| 1784 | - if (!empty($flip)) {
|
|
| 1785 | - $image->flip($flip[0], $flip[1]); |
|
| 1786 | - } |
|
| 1784 | + if (!empty($flip)) {
|
|
| 1785 | + $image->flip($flip[0], $flip[1]); |
|
| 1786 | + } |
|
| 1787 | 1787 | |
| 1788 | - if ($quality !== null) {
|
|
| 1789 | - $image->set_quality((int)$quality); |
|
| 1790 | - } |
|
| 1788 | + if ($quality !== null) {
|
|
| 1789 | + $image->set_quality((int)$quality); |
|
| 1790 | + } |
|
| 1791 | 1791 | |
| 1792 | - $result = $image->save($file_path); |
|
| 1793 | - if (!is_wp_error($result)) {
|
|
| 1794 | - $file['file'] = $result['path']; |
|
| 1795 | - $file['tmp_name'] = $result['path']; |
|
| 1796 | - } |
|
| 1797 | - } |
|
| 1792 | + $result = $image->save($file_path); |
|
| 1793 | + if (!is_wp_error($result)) {
|
|
| 1794 | + $file['file'] = $result['path']; |
|
| 1795 | + $file['tmp_name'] = $result['path']; |
|
| 1796 | + } |
|
| 1797 | + } |
|
| 1798 | 1798 | |
| 1799 | - // The image orientation is fixed, pass it back for further processing |
|
| 1800 | - return $file; |
|
| 1799 | + // The image orientation is fixed, pass it back for further processing |
|
| 1800 | + return $file; |
|
| 1801 | 1801 | } |
| 1802 | 1802 | |
| 1803 | 1803 | /** |
@@ -1816,138 +1816,138 @@ discard block |
||
| 1816 | 1816 | * @return string Returns the recent reviews html. |
| 1817 | 1817 | */ |
| 1818 | 1818 | function geodir_get_recent_reviews($g_size = 60, $no_comments = 10, $comment_lenth = 60, $show_pass_post = false) {
|
| 1819 | - global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session; |
|
| 1820 | - $tablecomments = $wpdb->comments; |
|
| 1821 | - $tableposts = $wpdb->posts; |
|
| 1822 | - |
|
| 1823 | - $comments_echo = ''; |
|
| 1824 | - $city_filter = ''; |
|
| 1825 | - $region_filter = ''; |
|
| 1826 | - $country_filter = ''; |
|
| 1827 | - |
|
| 1828 | - if ($gd_session->get('gd_multi_location')) {
|
|
| 1829 | - if ($gd_ses_country = $gd_session->get('gd_country')) {
|
|
| 1830 | - $country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
|
|
| 1831 | - } |
|
| 1819 | + global $wpdb, $tablecomments, $tableposts, $rating_table_name, $gd_session; |
|
| 1820 | + $tablecomments = $wpdb->comments; |
|
| 1821 | + $tableposts = $wpdb->posts; |
|
| 1822 | + |
|
| 1823 | + $comments_echo = ''; |
|
| 1824 | + $city_filter = ''; |
|
| 1825 | + $region_filter = ''; |
|
| 1826 | + $country_filter = ''; |
|
| 1827 | + |
|
| 1828 | + if ($gd_session->get('gd_multi_location')) {
|
|
| 1829 | + if ($gd_ses_country = $gd_session->get('gd_country')) {
|
|
| 1830 | + $country_filter = $wpdb->prepare(" AND r.post_country=%s ", str_replace("-", " ", $gd_ses_country));
|
|
| 1831 | + } |
|
| 1832 | 1832 | |
| 1833 | - if ($gd_ses_region = $gd_session->get('gd_region')) {
|
|
| 1834 | - $region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
|
|
| 1835 | - } |
|
| 1833 | + if ($gd_ses_region = $gd_session->get('gd_region')) {
|
|
| 1834 | + $region_filter = $wpdb->prepare(" AND r.post_region=%s ", str_replace("-", " ", $gd_ses_region));
|
|
| 1835 | + } |
|
| 1836 | 1836 | |
| 1837 | - if ($gd_ses_city = $gd_session->get('gd_city')) {
|
|
| 1838 | - $city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
|
|
| 1839 | - } |
|
| 1840 | - } |
|
| 1837 | + if ($gd_ses_city = $gd_session->get('gd_city')) {
|
|
| 1838 | + $city_filter = $wpdb->prepare(" AND r.post_city=%s ", str_replace("-", " ", $gd_ses_city));
|
|
| 1839 | + } |
|
| 1840 | + } |
|
| 1841 | 1841 | |
| 1842 | - $review_table = GEODIR_REVIEW_TABLE; |
|
| 1843 | - $request = "SELECT r.id as ID, r.post_type, r.comment_id as comment_ID, r.post_date as comment_date,r.overall_rating, r.user_id, r.post_id FROM $review_table as r WHERE r.post_status = 1 AND r.status =1 AND r.overall_rating>=1 $country_filter $region_filter $city_filter ORDER BY r.post_date DESC, r.id DESC LIMIT $no_comments"; |
|
| 1844 | - |
|
| 1845 | - $comments = $wpdb->get_results($request); |
|
| 1846 | - |
|
| 1847 | - foreach ($comments as $comment) {
|
|
| 1848 | - // Set the extra comment info needed. |
|
| 1849 | - $comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
|
|
| 1850 | - //echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID"; |
|
| 1851 | - $comment->comment_content = $comment_extra->comment_content; |
|
| 1852 | - $comment->comment_author = $comment_extra->comment_author; |
|
| 1853 | - $comment->comment_author_email = $comment_extra->comment_author_email; |
|
| 1854 | - |
|
| 1855 | - $comment_id = ''; |
|
| 1856 | - $comment_id = $comment->comment_ID; |
|
| 1857 | - $comment_content = strip_tags($comment->comment_content); |
|
| 1858 | - |
|
| 1859 | - $comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
|
|
| 1860 | - |
|
| 1861 | - $permalink = get_permalink($comment->ID) . "#comment-" . $comment->comment_ID; |
|
| 1862 | - $comment_author_email = $comment->comment_author_email; |
|
| 1863 | - $comment_post_ID = $comment->post_id; |
|
| 1864 | - |
|
| 1865 | - $na = true; |
|
| 1866 | - if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
|
|
| 1867 | - $comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false); |
|
| 1868 | - if ($comment_post_ID == $comment_post_ID2) {
|
|
| 1869 | - } else {
|
|
| 1870 | - $na = false; |
|
| 1871 | - } |
|
| 1872 | - } |
|
| 1842 | + $review_table = GEODIR_REVIEW_TABLE; |
|
| 1843 | + $request = "SELECT r.id as ID, r.post_type, r.comment_id as comment_ID, r.post_date as comment_date,r.overall_rating, r.user_id, r.post_id FROM $review_table as r WHERE r.post_status = 1 AND r.status =1 AND r.overall_rating>=1 $country_filter $region_filter $city_filter ORDER BY r.post_date DESC, r.id DESC LIMIT $no_comments"; |
|
| 1844 | + |
|
| 1845 | + $comments = $wpdb->get_results($request); |
|
| 1846 | + |
|
| 1847 | + foreach ($comments as $comment) {
|
|
| 1848 | + // Set the extra comment info needed. |
|
| 1849 | + $comment_extra = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID");
|
|
| 1850 | + //echo "SELECT * FROM $wpdb->comments WHERE comment_ID =$comment->comment_ID"; |
|
| 1851 | + $comment->comment_content = $comment_extra->comment_content; |
|
| 1852 | + $comment->comment_author = $comment_extra->comment_author; |
|
| 1853 | + $comment->comment_author_email = $comment_extra->comment_author_email; |
|
| 1854 | + |
|
| 1855 | + $comment_id = ''; |
|
| 1856 | + $comment_id = $comment->comment_ID; |
|
| 1857 | + $comment_content = strip_tags($comment->comment_content); |
|
| 1858 | + |
|
| 1859 | + $comment_content = preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_content);
|
|
| 1860 | + |
|
| 1861 | + $permalink = get_permalink($comment->ID) . "#comment-" . $comment->comment_ID; |
|
| 1862 | + $comment_author_email = $comment->comment_author_email; |
|
| 1863 | + $comment_post_ID = $comment->post_id; |
|
| 1864 | + |
|
| 1865 | + $na = true; |
|
| 1866 | + if (function_exists('icl_object_id') && icl_object_id($comment_post_ID, $comment->post_type, true)) {
|
|
| 1867 | + $comment_post_ID2 = icl_object_id($comment_post_ID, $comment->post_type, false); |
|
| 1868 | + if ($comment_post_ID == $comment_post_ID2) {
|
|
| 1869 | + } else {
|
|
| 1870 | + $na = false; |
|
| 1871 | + } |
|
| 1872 | + } |
|
| 1873 | 1873 | |
| 1874 | - $post_title = get_the_title($comment_post_ID); |
|
| 1875 | - $permalink = get_permalink($comment_post_ID); |
|
| 1876 | - $comment_permalink = $permalink . "#comment-" . $comment->comment_ID; |
|
| 1877 | - $read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __('Read more', 'geodirectory') . '</a>';
|
|
| 1874 | + $post_title = get_the_title($comment_post_ID); |
|
| 1875 | + $permalink = get_permalink($comment_post_ID); |
|
| 1876 | + $comment_permalink = $permalink . "#comment-" . $comment->comment_ID; |
|
| 1877 | + $read_more = '<a class="comment_excerpt" href="' . $comment_permalink . '">' . __('Read more', 'geodirectory') . '</a>';
|
|
| 1878 | 1878 | |
| 1879 | - $comment_content_length = strlen($comment_content); |
|
| 1880 | - if ($comment_content_length > $comment_lenth) {
|
|
| 1881 | - $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth) . '... ' . $read_more; |
|
| 1882 | - } else {
|
|
| 1883 | - $comment_excerpt = $comment_content; |
|
| 1884 | - } |
|
| 1879 | + $comment_content_length = strlen($comment_content); |
|
| 1880 | + if ($comment_content_length > $comment_lenth) {
|
|
| 1881 | + $comment_excerpt = mb_substr($comment_content, 0, $comment_lenth) . '... ' . $read_more; |
|
| 1882 | + } else {
|
|
| 1883 | + $comment_excerpt = $comment_content; |
|
| 1884 | + } |
|
| 1885 | 1885 | |
| 1886 | - if ($comment->user_id) {
|
|
| 1887 | - $user_profile_url = get_author_posts_url($comment->user_id); |
|
| 1888 | - } else {
|
|
| 1889 | - $user_profile_url = ''; |
|
| 1890 | - } |
|
| 1886 | + if ($comment->user_id) {
|
|
| 1887 | + $user_profile_url = get_author_posts_url($comment->user_id); |
|
| 1888 | + } else {
|
|
| 1889 | + $user_profile_url = ''; |
|
| 1890 | + } |
|
| 1891 | 1891 | |
| 1892 | - if ($comment_id && $na) {
|
|
| 1893 | - $comments_echo .= '<li class="clearfix">'; |
|
| 1894 | - $comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">"; |
|
| 1895 | - if (function_exists('get_avatar')) {
|
|
| 1896 | - if (!isset($comment->comment_type)) {
|
|
| 1897 | - if ($user_profile_url) {
|
|
| 1898 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 1899 | - } |
|
| 1900 | - $comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png'); |
|
| 1901 | - if ($user_profile_url) {
|
|
| 1902 | - $comments_echo .= '</a>'; |
|
| 1903 | - } |
|
| 1904 | - } elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
|
|
| 1905 | - if ($user_profile_url) {
|
|
| 1906 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 1907 | - } |
|
| 1908 | - $comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png'); |
|
| 1909 | - } |
|
| 1910 | - } elseif (function_exists('gravatar')) {
|
|
| 1911 | - if ($user_profile_url) {
|
|
| 1912 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 1913 | - } |
|
| 1914 | - $comments_echo .= "<img src=\""; |
|
| 1915 | - if ('' == $comment->comment_type) {
|
|
| 1916 | - $comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png'); |
|
| 1917 | - if ($user_profile_url) {
|
|
| 1918 | - $comments_echo .= '</a>'; |
|
| 1919 | - } |
|
| 1920 | - } elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
|
|
| 1921 | - if ($user_profile_url) {
|
|
| 1922 | - $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 1923 | - } |
|
| 1924 | - $comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png'); |
|
| 1925 | - if ($user_profile_url) {
|
|
| 1926 | - $comments_echo .= '</a>'; |
|
| 1927 | - } |
|
| 1928 | - } |
|
| 1929 | - $comments_echo .= "\" alt=\"\" class=\"avatar\" />"; |
|
| 1930 | - } |
|
| 1892 | + if ($comment_id && $na) {
|
|
| 1893 | + $comments_echo .= '<li class="clearfix">'; |
|
| 1894 | + $comments_echo .= "<span class=\"li" . $comment_id . " geodir_reviewer_image\">"; |
|
| 1895 | + if (function_exists('get_avatar')) {
|
|
| 1896 | + if (!isset($comment->comment_type)) {
|
|
| 1897 | + if ($user_profile_url) {
|
|
| 1898 | + $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 1899 | + } |
|
| 1900 | + $comments_echo .= get_avatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png'); |
|
| 1901 | + if ($user_profile_url) {
|
|
| 1902 | + $comments_echo .= '</a>'; |
|
| 1903 | + } |
|
| 1904 | + } elseif ((isset($comment->comment_type) && $comment->comment_type == 'trackback') || (isset($comment->comment_type) && $comment->comment_type == 'pingback')) {
|
|
| 1905 | + if ($user_profile_url) {
|
|
| 1906 | + $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 1907 | + } |
|
| 1908 | + $comments_echo .= get_avatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png'); |
|
| 1909 | + } |
|
| 1910 | + } elseif (function_exists('gravatar')) {
|
|
| 1911 | + if ($user_profile_url) {
|
|
| 1912 | + $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 1913 | + } |
|
| 1914 | + $comments_echo .= "<img src=\""; |
|
| 1915 | + if ('' == $comment->comment_type) {
|
|
| 1916 | + $comments_echo .= gravatar($comment->comment_author_email, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png'); |
|
| 1917 | + if ($user_profile_url) {
|
|
| 1918 | + $comments_echo .= '</a>'; |
|
| 1919 | + } |
|
| 1920 | + } elseif (('trackback' == $comment->comment_type) || ('pingback' == $comment->comment_type)) {
|
|
| 1921 | + if ($user_profile_url) {
|
|
| 1922 | + $comments_echo .= '<a href="' . $user_profile_url . '">'; |
|
| 1923 | + } |
|
| 1924 | + $comments_echo .= gravatar($comment->comment_author_url, $g_size, geodir_plugin_url() . '/geodirectory-assets/images/gravatar2.png'); |
|
| 1925 | + if ($user_profile_url) {
|
|
| 1926 | + $comments_echo .= '</a>'; |
|
| 1927 | + } |
|
| 1928 | + } |
|
| 1929 | + $comments_echo .= "\" alt=\"\" class=\"avatar\" />"; |
|
| 1930 | + } |
|
| 1931 | 1931 | |
| 1932 | - $comments_echo .= "</span>\n"; |
|
| 1933 | - |
|
| 1934 | - $comments_echo .= '<span class="geodir_reviewer_content">'; |
|
| 1935 | - if($comment->user_id){$comments_echo .= '<a href="'.get_author_posts_url( $comment->user_id ).'">';}
|
|
| 1936 | - $comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> '; |
|
| 1937 | - if($comment->user_id){$comments_echo .= '</a>';}
|
|
| 1938 | - $comments_echo .= '<span class="geodir_reviewer_reviewed">' . __('reviewed', 'geodirectory') . '</span> ';
|
|
| 1939 | - $comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>'; |
|
| 1940 | - $comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID); |
|
| 1941 | - $comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . ''; |
|
| 1942 | - //echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
|
|
| 1943 | - $comments_echo .= '</p>'; |
|
| 1944 | - |
|
| 1945 | - $comments_echo .= "</span>\n"; |
|
| 1946 | - $comments_echo .= '</li>'; |
|
| 1947 | - } |
|
| 1948 | - } |
|
| 1932 | + $comments_echo .= "</span>\n"; |
|
| 1933 | + |
|
| 1934 | + $comments_echo .= '<span class="geodir_reviewer_content">'; |
|
| 1935 | + if($comment->user_id){$comments_echo .= '<a href="'.get_author_posts_url( $comment->user_id ).'">';}
|
|
| 1936 | + $comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> '; |
|
| 1937 | + if($comment->user_id){$comments_echo .= '</a>';}
|
|
| 1938 | + $comments_echo .= '<span class="geodir_reviewer_reviewed">' . __('reviewed', 'geodirectory') . '</span> ';
|
|
| 1939 | + $comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>'; |
|
| 1940 | + $comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID); |
|
| 1941 | + $comments_echo .= '<p class="geodir_reviewer_text">' . $comment_excerpt . ''; |
|
| 1942 | + //echo preg_replace('#(\\[img\\]).+(\\[\\/img\\])#', '', $comment_excerpt);
|
|
| 1943 | + $comments_echo .= '</p>'; |
|
| 1944 | + |
|
| 1945 | + $comments_echo .= "</span>\n"; |
|
| 1946 | + $comments_echo .= '</li>'; |
|
| 1947 | + } |
|
| 1948 | + } |
|
| 1949 | 1949 | |
| 1950 | - return $comments_echo; |
|
| 1950 | + return $comments_echo; |
|
| 1951 | 1951 | } |
| 1952 | 1952 | |
| 1953 | 1953 | /** |
@@ -1959,29 +1959,29 @@ discard block |
||
| 1959 | 1959 | */ |
| 1960 | 1960 | function geodir_home_map_cats_key_value_array() |
| 1961 | 1961 | {
|
| 1962 | - $post_types = geodir_get_posttypes('object');
|
|
| 1962 | + $post_types = geodir_get_posttypes('object');
|
|
| 1963 | 1963 | |
| 1964 | - $return = array(); |
|
| 1965 | - if (!empty($post_types)) {
|
|
| 1966 | - foreach ($post_types as $key => $post_type) {
|
|
| 1967 | - $cpt_name = __($post_type->labels->singular_name, 'geodirectory'); |
|
| 1968 | - $post_type_name = sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
|
|
| 1969 | - $taxonomies = geodir_get_taxonomies($key); |
|
| 1970 | - $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL; |
|
| 1971 | - $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL; |
|
| 1964 | + $return = array(); |
|
| 1965 | + if (!empty($post_types)) {
|
|
| 1966 | + foreach ($post_types as $key => $post_type) {
|
|
| 1967 | + $cpt_name = __($post_type->labels->singular_name, 'geodirectory'); |
|
| 1968 | + $post_type_name = sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
|
|
| 1969 | + $taxonomies = geodir_get_taxonomies($key); |
|
| 1970 | + $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL; |
|
| 1971 | + $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL; |
|
| 1972 | 1972 | |
| 1973 | - if (!empty($cat_terms)) {
|
|
| 1974 | - $return['optgroup_start-' . $key] = $post_type_name; |
|
| 1973 | + if (!empty($cat_terms)) {
|
|
| 1974 | + $return['optgroup_start-' . $key] = $post_type_name; |
|
| 1975 | 1975 | |
| 1976 | - foreach ($cat_terms as $cat_term) {
|
|
| 1977 | - $return[$key . '_' . $cat_term->term_id] = $cat_term->name; |
|
| 1978 | - } |
|
| 1976 | + foreach ($cat_terms as $cat_term) {
|
|
| 1977 | + $return[$key . '_' . $cat_term->term_id] = $cat_term->name; |
|
| 1978 | + } |
|
| 1979 | 1979 | |
| 1980 | - $return['optgroup_end-' . $key] = $post_type_name; |
|
| 1981 | - } |
|
| 1982 | - } |
|
| 1983 | - } |
|
| 1984 | - return $return; |
|
| 1980 | + $return['optgroup_end-' . $key] = $post_type_name; |
|
| 1981 | + } |
|
| 1982 | + } |
|
| 1983 | + } |
|
| 1984 | + return $return; |
|
| 1985 | 1985 | } |
| 1986 | 1986 | |
| 1987 | 1987 | /** |
@@ -1993,7 +1993,7 @@ discard block |
||
| 1993 | 1993 | */ |
| 1994 | 1994 | function geodir_twitter_tweet_button() |
| 1995 | 1995 | {
|
| 1996 | - ?> |
|
| 1996 | + ?> |
|
| 1997 | 1997 | <a href="http://twitter.com/share" |
| 1998 | 1998 | class="twitter-share-button"><?php _e('Tweet', 'geodirectory'); ?></a>
|
| 1999 | 1999 | <script type="text/javascript" src="//platform.twitter.com/widgets.js"></script> |
@@ -2011,11 +2011,11 @@ discard block |
||
| 2011 | 2011 | */ |
| 2012 | 2012 | function geodir_fb_like_button() |
| 2013 | 2013 | {
|
| 2014 | - global $post; |
|
| 2015 | - ?> |
|
| 2014 | + global $post; |
|
| 2015 | + ?> |
|
| 2016 | 2016 | <iframe <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
|
| 2017 | - echo 'allowtransparency="true"'; |
|
| 2018 | - } ?> class="facebook" |
|
| 2017 | + echo 'allowtransparency="true"'; |
|
| 2018 | + } ?> class="facebook" |
|
| 2019 | 2019 | src="//www.facebook.com/plugins/like.php?href=<?php echo urlencode(get_permalink($post->ID)); ?>&layout=button_count&show_faces=false&width=100&action=like&colorscheme=light" |
| 2020 | 2020 | style="border:none; overflow:hidden; width:100px; height:20px"></iframe> |
| 2021 | 2021 | <?php |
@@ -2031,7 +2031,7 @@ discard block |
||
| 2031 | 2031 | */ |
| 2032 | 2032 | function geodir_google_plus_button() |
| 2033 | 2033 | {
|
| 2034 | - ?> |
|
| 2034 | + ?> |
|
| 2035 | 2035 | <div id="plusone-div" class="g-plusone" data-size="medium"></div> |
| 2036 | 2036 | <script type="text/javascript"> |
| 2037 | 2037 | (function () {
|
@@ -2057,8 +2057,8 @@ discard block |
||
| 2057 | 2057 | */ |
| 2058 | 2058 | function geodir_share_this_button_code() |
| 2059 | 2059 | {
|
| 2060 | - global $post; |
|
| 2061 | - ?> |
|
| 2060 | + global $post; |
|
| 2061 | + ?> |
|
| 2062 | 2062 | <div class="addthis_toolbox addthis_default_style"> |
| 2063 | 2063 | <span id='st_sharethis'></span> |
| 2064 | 2064 | <script type="text/javascript">var switchTo5x = false;</script> |
@@ -2085,12 +2085,12 @@ discard block |
||
| 2085 | 2085 | |
| 2086 | 2086 | function geodir_listing_bounce_map_pin_on_hover(){
|
| 2087 | 2087 | |
| 2088 | - if(get_option('geodir_listing_hover_bounce_map_pin')) {
|
|
| 2089 | - global $wp_query; |
|
| 2088 | + if(get_option('geodir_listing_hover_bounce_map_pin')) {
|
|
| 2089 | + global $wp_query; |
|
| 2090 | 2090 | |
| 2091 | - $show_pin_point = $wp_query->is_main_query(); |
|
| 2092 | - if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
|
|
| 2093 | - ?> |
|
| 2091 | + $show_pin_point = $wp_query->is_main_query(); |
|
| 2092 | + if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
|
|
| 2093 | + ?> |
|
| 2094 | 2094 | <script> |
| 2095 | 2095 | jQuery(function ($) {
|
| 2096 | 2096 | var groupTab = $("ul.geodir_category_list_view").children("li");
|
@@ -2104,36 +2104,36 @@ discard block |
||
| 2104 | 2104 | </script> |
| 2105 | 2105 | |
| 2106 | 2106 | <?php |
| 2107 | - } |
|
| 2108 | - } |
|
| 2107 | + } |
|
| 2108 | + } |
|
| 2109 | 2109 | } |
| 2110 | 2110 | add_action('geodir_after_listing_listview','geodir_listing_bounce_map_pin_on_hover',10);
|
| 2111 | 2111 | |
| 2112 | 2112 | add_action('geodir_after_favorite_html','geodir_output_favourite_html_listings',1,1);
|
| 2113 | 2113 | |
| 2114 | 2114 | function geodir_output_favourite_html_listings( $post_id){
|
| 2115 | - geodir_favourite_html('', $post_id);
|
|
| 2115 | + geodir_favourite_html('', $post_id);
|
|
| 2116 | 2116 | } |
| 2117 | 2117 | |
| 2118 | 2118 | |
| 2119 | 2119 | do_action( 'geodir_listing_after_pinpoint', 'geodir_output_pinpoint_html_listings',1,2 ); |
| 2120 | 2120 | |
| 2121 | 2121 | function geodir_output_pinpoint_html_listings( $post_id, $post){
|
| 2122 | - global $wp_query; |
|
| 2122 | + global $wp_query; |
|
| 2123 | 2123 | |
| 2124 | - $show_pin_point = $wp_query->is_main_query(); |
|
| 2125 | - if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
|
|
| 2124 | + $show_pin_point = $wp_query->is_main_query(); |
|
| 2125 | + if (!empty($show_pin_point) && is_active_widget(false, "", "geodir_map_v3_listing_map")) {
|
|
| 2126 | 2126 | |
| 2127 | - /*if($json_info = json_decode($post->marker_json)) |
|
| 2127 | + /*if($json_info = json_decode($post->marker_json)) |
|
| 2128 | 2128 | $marker_icon = $json_info->icon;*/ |
| 2129 | 2129 | |
| 2130 | - $term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type); |
|
| 2131 | - $marker_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
|
|
| 2132 | - ?> |
|
| 2130 | + $term_icon_url = get_tax_meta($post->default_category, 'ct_cat_icon', false, $post->post_type); |
|
| 2131 | + $marker_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : get_option('geodir_default_marker_icon');
|
|
| 2132 | + ?> |
|
| 2133 | 2133 | <span class="geodir-pinpoint" |
| 2134 | 2134 | style=" background:url('<?php if (isset($marker_icon)) {
|
| 2135 | - echo $marker_icon; |
|
| 2136 | - } ?>') no-repeat scroll left top transparent; background-size:auto 100%; -webkit-background-size:auto 100%; -moz-background-size:auto 100%; height:9px; width:14px; "> |
|
| 2135 | + echo $marker_icon; |
|
| 2136 | + } ?>') no-repeat scroll left top transparent; background-size:auto 100%; -webkit-background-size:auto 100%; -moz-background-size:auto 100%; height:9px; width:14px; "> |
|
| 2137 | 2137 | <?php echo apply_filters('geodir_listing_listview_pinpoint_inner_content', '', 'listing'); ?>
|
| 2138 | 2138 | </span> |
| 2139 | 2139 | <a class="geodir-pinpoint-link" href="javascript:void(0)" |
@@ -47,7 +47,7 @@ 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 | 53 | return WP_PLUGIN_DIR . "/" . plugin_basename(dirname(dirname(__FILE__))); |
@@ -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 | } |
@@ -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'] ; |
@@ -544,7 +544,7 @@ 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) {
|
@@ -678,11 +678,11 @@ discard block |
||
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | if (!empty($subject)) {
|
| 681 | - $subject = __(stripslashes_deep($subject),'geodirectory'); |
|
| 681 | + $subject = __(stripslashes_deep($subject), 'geodirectory'); |
|
| 682 | 682 | } |
| 683 | 683 | |
| 684 | 684 | if (!empty($message)) {
|
| 685 | - $message = __(stripslashes_deep($message),'geodirectory'); |
|
| 685 | + $message = __(stripslashes_deep($message), 'geodirectory'); |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | $to_message = nl2br($to_message); |
@@ -717,12 +717,12 @@ discard block |
||
| 717 | 717 | $fromEmailName = get_option('site_email_name');
|
| 718 | 718 | } |
| 719 | 719 | |
| 720 | - $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#]');
|
|
| 721 | - $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); |
|
| 720 | + $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#]');
|
|
| 721 | + $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); |
|
| 722 | 722 | $message = str_replace($search_array, $replace_array, $message); |
| 723 | 723 | |
| 724 | - $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#]');
|
|
| 725 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login); |
|
| 724 | + $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#]');
|
|
| 725 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $fromEmail, $user_login, $user_login); |
|
| 726 | 726 | $subject = str_replace($search_array, $replace_array, $subject); |
| 727 | 727 | |
| 728 | 728 | $headers = 'MIME-Version: 1.0' . "\r\n"; |
@@ -733,18 +733,18 @@ discard block |
||
| 733 | 733 | $to = $toEmail; |
| 734 | 734 | $sent = wp_mail($to, $subject, $message, $headers); |
| 735 | 735 | |
| 736 | - if( ! $sent ) {
|
|
| 737 | - if ( is_array( $to ) ) {
|
|
| 738 | - $to = implode( ',', $to ); |
|
| 736 | + if (!$sent) {
|
|
| 737 | + if (is_array($to)) {
|
|
| 738 | + $to = implode(',', $to);
|
|
| 739 | 739 | } |
| 740 | 740 | $log_message = sprintf( |
| 741 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 741 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 742 | 742 | $message_type, |
| 743 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 743 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 744 | 744 | $to, |
| 745 | 745 | $subject |
| 746 | 746 | ); |
| 747 | - geodir_error_log( $log_message ); |
|
| 747 | + geodir_error_log($log_message); |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | ///////// ADMIN BCC EMIALS |
@@ -756,11 +756,11 @@ discard block |
||
| 756 | 756 | $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
|
| 757 | 757 | $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
|
| 758 | 758 | |
| 759 | - $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#]');
|
|
| 759 | + $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#]');
|
|
| 760 | 760 | $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); |
| 761 | 761 | $message = str_replace($search_array, $replace_array, $message); |
| 762 | 762 | |
| 763 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
|
|
| 763 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]', '[#user_login#]', '[#username#]');
|
|
| 764 | 764 | $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login); |
| 765 | 765 | $subject = str_replace($search_array, $replace_array, $subject); |
| 766 | 766 | |
@@ -785,21 +785,21 @@ discard block |
||
| 785 | 785 | $admin_bcc = true; |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | - if($admin_bcc===true){
|
|
| 788 | + if ($admin_bcc === true) {
|
|
| 789 | 789 | $sent = wp_mail($to, $subject, $message, $headers); |
| 790 | 790 | |
| 791 | - if( ! $sent ) {
|
|
| 792 | - if ( is_array( $to ) ) {
|
|
| 793 | - $to = implode( ',', $to ); |
|
| 791 | + if (!$sent) {
|
|
| 792 | + if (is_array($to)) {
|
|
| 793 | + $to = implode(',', $to);
|
|
| 794 | 794 | } |
| 795 | 795 | $log_message = sprintf( |
| 796 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 796 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 797 | 797 | $message_type, |
| 798 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 798 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 799 | 799 | $to, |
| 800 | 800 | $subject |
| 801 | 801 | ); |
| 802 | - geodir_error_log( $log_message ); |
|
| 802 | + geodir_error_log($log_message); |
|
| 803 | 803 | } |
| 804 | 804 | } |
| 805 | 805 | |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
| 895 | 895 | $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
| 896 | 896 | |
| 897 | - if(geodir_is_page('detail') && isset($post->country_slug)){
|
|
| 897 | + if (geodir_is_page('detail') && isset($post->country_slug)) {
|
|
| 898 | 898 | $location_terms = array( |
| 899 | 899 | 'gd_country' => $post->country_slug, |
| 900 | 900 | 'gd_region' => $post->region_slug, |
@@ -1149,7 +1149,7 @@ discard block |
||
| 1149 | 1149 | $breadcrumb .= stripslashes_deep($page_title); |
| 1150 | 1150 | $breadcrumb .= '</li>'; |
| 1151 | 1151 | } else if (is_tag()) {
|
| 1152 | - $breadcrumb .= "<li> " . $separator . single_tag_title('',false) . '</li>';
|
|
| 1152 | + $breadcrumb .= "<li> " . $separator . single_tag_title('', false) . '</li>';
|
|
| 1153 | 1153 | } else if (is_day()) {
|
| 1154 | 1154 | $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
| 1155 | 1155 | the_time('F jS, Y');
|
@@ -1241,7 +1241,7 @@ discard block |
||
| 1241 | 1241 | return new WP_Error('upload_dir_error', $upload['error']);
|
| 1242 | 1242 | |
| 1243 | 1243 | // fetch the remote url and write it to the placeholder file |
| 1244 | - $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
|
|
| 1244 | + $headers = wp_remote_get($url, array('stream' => true, 'filename' => $upload['file']));
|
|
| 1245 | 1245 | |
| 1246 | 1246 | $log_message = ''; |
| 1247 | 1247 | $filesize = filesize($upload['file']); |
@@ -1254,16 +1254,16 @@ discard block |
||
| 1254 | 1254 | $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
|
| 1255 | 1255 | } |
| 1256 | 1256 | elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
|
| 1257 | - $log_message = __('Remote file is incorrect size', 'geodirectory');
|
|
| 1257 | + $log_message = __('Remote file is incorrect size', 'geodirectory');
|
|
| 1258 | 1258 | } |
| 1259 | 1259 | elseif (0 == $filesize) {
|
| 1260 | 1260 | $log_message = __('Zero size file downloaded', 'geodirectory');
|
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | - if($log_message){
|
|
| 1263 | + if ($log_message) {
|
|
| 1264 | 1264 | $del = unlink($upload['file']); |
| 1265 | - if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
|
|
| 1266 | - return new WP_Error('import_file_error',$log_message );
|
|
| 1265 | + if (!$del) {geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory')); }
|
|
| 1266 | + return new WP_Error('import_file_error', $log_message);
|
|
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | 1269 | |
@@ -1279,10 +1279,10 @@ discard block |
||
| 1279 | 1279 | */ |
| 1280 | 1280 | function geodir_max_upload_size() |
| 1281 | 1281 | {
|
| 1282 | - $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
|
|
| 1282 | + $max_filesize = (float) get_option('geodir_upload_max_filesize', 2);
|
|
| 1283 | 1283 | |
| 1284 | 1284 | if ($max_filesize > 0 && $max_filesize < 1) {
|
| 1285 | - $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
| 1285 | + $max_filesize = (int) ($max_filesize * 1024) . 'kb'; |
|
| 1286 | 1286 | } else {
|
| 1287 | 1287 | $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
| 1288 | 1288 | } |
@@ -1351,35 +1351,35 @@ discard block |
||
| 1351 | 1351 | {
|
| 1352 | 1352 | global $wpdb; |
| 1353 | 1353 | if ($message_type == 'expiration') {
|
| 1354 | - $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
|
|
| 1355 | - $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
|
|
| 1354 | + $subject = stripslashes(__(get_option('renew_email_subject'), 'geodirectory'));
|
|
| 1355 | + $client_message = stripslashes(__(get_option('renew_email_content'), 'geodirectory'));
|
|
| 1356 | 1356 | } elseif ($message_type == 'post_submited') {
|
| 1357 | - $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
|
|
| 1358 | - $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
|
|
| 1357 | + $subject = __(get_option('post_submited_success_email_subject_admin'), 'geodirectory');
|
|
| 1358 | + $client_message = __(get_option('post_submited_success_email_content_admin'), 'geodirectory');
|
|
| 1359 | 1359 | } elseif ($message_type == 'renew') {
|
| 1360 | - $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
|
|
| 1361 | - $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
|
|
| 1360 | + $subject = __(get_option('post_renew_success_email_subject_admin'), 'geodirectory');
|
|
| 1361 | + $client_message = __(get_option('post_renew_success_email_content_admin'), 'geodirectory');
|
|
| 1362 | 1362 | } elseif ($message_type == 'upgrade') {
|
| 1363 | - $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
|
|
| 1364 | - $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
|
|
| 1363 | + $subject = __(get_option('post_upgrade_success_email_subject_admin'), 'geodirectory');
|
|
| 1364 | + $client_message = __(get_option('post_upgrade_success_email_content_admin'), 'geodirectory');
|
|
| 1365 | 1365 | } elseif ($message_type == 'claim_approved') {
|
| 1366 | - $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
|
|
| 1367 | - $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
|
|
| 1366 | + $subject = __(get_option('claim_approved_email_subject'), 'geodirectory');
|
|
| 1367 | + $client_message = __(get_option('claim_approved_email_content'), 'geodirectory');
|
|
| 1368 | 1368 | } elseif ($message_type == 'claim_rejected') {
|
| 1369 | - $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
|
|
| 1370 | - $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
|
|
| 1369 | + $subject = __(get_option('claim_rejected_email_subject'), 'geodirectory');
|
|
| 1370 | + $client_message = __(get_option('claim_rejected_email_content'), 'geodirectory');
|
|
| 1371 | 1371 | } elseif ($message_type == 'claim_requested') {
|
| 1372 | - $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
|
|
| 1373 | - $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
|
|
| 1372 | + $subject = __(get_option('claim_email_subject_admin'), 'geodirectory');
|
|
| 1373 | + $client_message = __(get_option('claim_email_content_admin'), 'geodirectory');
|
|
| 1374 | 1374 | } elseif ($message_type == 'auto_claim') {
|
| 1375 | - $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
|
|
| 1376 | - $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
|
|
| 1375 | + $subject = __(get_option('auto_claim_email_subject'), 'geodirectory');
|
|
| 1376 | + $client_message = __(get_option('auto_claim_email_content'), 'geodirectory');
|
|
| 1377 | 1377 | } elseif ($message_type == 'payment_success') {
|
| 1378 | - $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
|
|
| 1379 | - $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
|
|
| 1378 | + $subject = __(get_option('post_payment_success_admin_email_subject'), 'geodirectory');
|
|
| 1379 | + $client_message = __(get_option('post_payment_success_admin_email_content'), 'geodirectory');
|
|
| 1380 | 1380 | } elseif ($message_type == 'payment_fail') {
|
| 1381 | - $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
|
|
| 1382 | - $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
|
|
| 1381 | + $subject = __(get_option('post_payment_fail_admin_email_subject'), 'geodirectory');
|
|
| 1382 | + $client_message = __(get_option('post_payment_fail_admin_email_content'), 'geodirectory');
|
|
| 1383 | 1383 | } |
| 1384 | 1384 | $transaction_details = $custom_1; |
| 1385 | 1385 | $fromEmail = get_option('site_email');
|
@@ -1420,18 +1420,18 @@ discard block |
||
| 1420 | 1420 | $to = $fromEmail; |
| 1421 | 1421 | $message = $client_message; |
| 1422 | 1422 | $sent = wp_mail($to, $subject, $message, $headers); |
| 1423 | - if( ! $sent ) {
|
|
| 1424 | - if ( is_array( $to ) ) {
|
|
| 1425 | - $to = implode( ',', $to ); |
|
| 1423 | + if (!$sent) {
|
|
| 1424 | + if (is_array($to)) {
|
|
| 1425 | + $to = implode(',', $to);
|
|
| 1426 | 1426 | } |
| 1427 | 1427 | $log_message = sprintf( |
| 1428 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1428 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 1429 | 1429 | $message_type, |
| 1430 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1430 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 1431 | 1431 | $to, |
| 1432 | 1432 | $subject |
| 1433 | 1433 | ); |
| 1434 | - geodir_error_log( $log_message ); |
|
| 1434 | + geodir_error_log($log_message); |
|
| 1435 | 1435 | } |
| 1436 | 1436 | } |
| 1437 | 1437 | } |
@@ -1457,18 +1457,18 @@ discard block |
||
| 1457 | 1457 | {
|
| 1458 | 1458 | $login_details = ''; |
| 1459 | 1459 | if ($message_type == 'send_friend') {
|
| 1460 | - $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
|
|
| 1461 | - $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
|
|
| 1460 | + $subject = stripslashes(__(get_option('email_friend_subject'), 'geodirectory'));
|
|
| 1461 | + $message = stripslashes(__(get_option('email_friend_content'), 'geodirectory'));
|
|
| 1462 | 1462 | } elseif ($message_type == 'send_enquiry') {
|
| 1463 | - $subject = __(get_option('email_enquiry_subject'),'geodirectory');
|
|
| 1464 | - $message = __(get_option('email_enquiry_content'),'geodirectory');
|
|
| 1463 | + $subject = __(get_option('email_enquiry_subject'), 'geodirectory');
|
|
| 1464 | + $message = __(get_option('email_enquiry_content'), 'geodirectory');
|
|
| 1465 | 1465 | } elseif ($message_type == 'forgot_password') {
|
| 1466 | - $subject = __(get_option('forgot_password_subject'),'geodirectory');
|
|
| 1467 | - $message = __(get_option('forgot_password_content'),'geodirectory');
|
|
| 1466 | + $subject = __(get_option('forgot_password_subject'), 'geodirectory');
|
|
| 1467 | + $message = __(get_option('forgot_password_content'), 'geodirectory');
|
|
| 1468 | 1468 | $login_details = $to_message; |
| 1469 | 1469 | } elseif ($message_type == 'registration') {
|
| 1470 | - $subject = __(get_option('registration_success_email_subject'),'geodirectory');
|
|
| 1471 | - $message = __(get_option('registration_success_email_content'),'geodirectory');
|
|
| 1470 | + $subject = __(get_option('registration_success_email_subject'), 'geodirectory');
|
|
| 1471 | + $message = __(get_option('registration_success_email_content'), 'geodirectory');
|
|
| 1472 | 1472 | $login_details = $to_message; |
| 1473 | 1473 | } |
| 1474 | 1474 | $to_message = nl2br($to_message); |
@@ -1502,18 +1502,18 @@ discard block |
||
| 1502 | 1502 | $to = $toEmail; |
| 1503 | 1503 | |
| 1504 | 1504 | $sent = wp_mail($to, $subject, $message, $headers); |
| 1505 | - if( ! $sent ) {
|
|
| 1506 | - if ( is_array( $to ) ) {
|
|
| 1507 | - $to = implode( ',', $to ); |
|
| 1505 | + if (!$sent) {
|
|
| 1506 | + if (is_array($to)) {
|
|
| 1507 | + $to = implode(',', $to);
|
|
| 1508 | 1508 | } |
| 1509 | 1509 | $log_message = sprintf( |
| 1510 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1510 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 1511 | 1511 | $message_type, |
| 1512 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1512 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 1513 | 1513 | $to, |
| 1514 | 1514 | $subject |
| 1515 | 1515 | ); |
| 1516 | - geodir_error_log( $log_message ); |
|
| 1516 | + geodir_error_log($log_message); |
|
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | 1519 | ///////// ADMIN BCC EMIALS |
@@ -1539,20 +1539,20 @@ discard block |
||
| 1539 | 1539 | $admin_bcc = true; |
| 1540 | 1540 | } |
| 1541 | 1541 | |
| 1542 | - if($admin_bcc === true){
|
|
| 1542 | + if ($admin_bcc === true) {
|
|
| 1543 | 1543 | $sent = wp_mail($to, $subject, $message, $headers); |
| 1544 | - if( ! $sent ) {
|
|
| 1545 | - if ( is_array( $to ) ) {
|
|
| 1546 | - $to = implode( ',', $to ); |
|
| 1544 | + if (!$sent) {
|
|
| 1545 | + if (is_array($to)) {
|
|
| 1546 | + $to = implode(',', $to);
|
|
| 1547 | 1547 | } |
| 1548 | 1548 | $log_message = sprintf( |
| 1549 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1549 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 1550 | 1550 | $message_type, |
| 1551 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1551 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 1552 | 1552 | $to, |
| 1553 | 1553 | $subject |
| 1554 | 1554 | ); |
| 1555 | - geodir_error_log( $log_message ); |
|
| 1555 | + geodir_error_log($log_message); |
|
| 1556 | 1556 | } |
| 1557 | 1557 | } |
| 1558 | 1558 | |
@@ -1600,7 +1600,7 @@ discard block |
||
| 1600 | 1600 | function geodir_custom_posts_body_class($classes) {
|
| 1601 | 1601 | global $wpdb, $wp; |
| 1602 | 1602 | $post_types = geodir_get_posttypes('object');
|
| 1603 | - if (!empty($post_types) && count((array)$post_types) > 1) {
|
|
| 1603 | + if (!empty($post_types) && count((array) $post_types) > 1) {
|
|
| 1604 | 1604 | $classes[] = 'geodir_custom_posts'; |
| 1605 | 1605 | } |
| 1606 | 1606 | |
@@ -1894,7 +1894,7 @@ discard block |
||
| 1894 | 1894 | $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
|
| 1895 | 1895 | " . $join . " |
| 1896 | 1896 | " . $where; |
| 1897 | - $rows = (int)$wpdb->get_var($sql); |
|
| 1897 | + $rows = (int) $wpdb->get_var($sql); |
|
| 1898 | 1898 | } else {
|
| 1899 | 1899 | $orderby = geodir_widget_listings_get_order($query_args); |
| 1900 | 1900 | /** |
@@ -1920,10 +1920,10 @@ discard block |
||
| 1920 | 1920 | $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
|
| 1921 | 1921 | |
| 1922 | 1922 | $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1; |
| 1923 | - if ( !$page ) |
|
| 1923 | + if (!$page) |
|
| 1924 | 1924 | $page = 1; |
| 1925 | 1925 | |
| 1926 | - $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : ""; |
|
| 1926 | + $limit = (int) $limit > 0 ? " LIMIT " . absint(($page - 1) * (int) $limit) . ", " . (int) $limit : ""; |
|
| 1927 | 1927 | |
| 1928 | 1928 | $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . " |
| 1929 | 1929 | " . $join . " |
@@ -2038,7 +2038,7 @@ discard block |
||
| 2038 | 2038 | } |
| 2039 | 2039 | |
| 2040 | 2040 | if (!empty($query_args['post_author'])) {
|
| 2041 | - $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author']; |
|
| 2041 | + $where .= " AND " . $wpdb->posts . ".post_author = " . (int) $query_args['post_author']; |
|
| 2042 | 2042 | } |
| 2043 | 2043 | |
| 2044 | 2044 | if (!empty($query_args['show_featured_only'])) {
|
@@ -2124,7 +2124,7 @@ discard block |
||
| 2124 | 2124 | } |
| 2125 | 2125 | |
| 2126 | 2126 | if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
|
| 2127 | - $limit = (int)$query_args['posts_per_page']; |
|
| 2127 | + $limit = (int) $query_args['posts_per_page']; |
|
| 2128 | 2128 | } |
| 2129 | 2129 | |
| 2130 | 2130 | return $limit; |
@@ -2267,9 +2267,9 @@ discard block |
||
| 2267 | 2267 | add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
| 2268 | 2268 | } |
| 2269 | 2269 | $home_url = str_replace("www.", "", $home_url);
|
| 2270 | - 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')) ) {
|
|
| 2270 | + 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'))) {
|
|
| 2271 | 2271 | return true; |
| 2272 | - }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')){
|
|
| 2272 | + }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')) {
|
|
| 2273 | 2273 | return true; |
| 2274 | 2274 | } else {
|
| 2275 | 2275 | return false; |
@@ -2352,7 +2352,7 @@ discard block |
||
| 2352 | 2352 | |
| 2353 | 2353 | $gd_post_type = geodir_get_current_posttype(); |
| 2354 | 2354 | |
| 2355 | - $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15; |
|
| 2355 | + $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15; |
|
| 2356 | 2356 | $default_post_type = !empty($gd_post_type) ? $gd_post_type : (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ? $instance['default_post_type'] : ''); |
| 2357 | 2357 | |
| 2358 | 2358 | $taxonomy = array(); |
@@ -2385,14 +2385,14 @@ discard block |
||
| 2385 | 2385 | foreach ($b_terms as $key => $val) {
|
| 2386 | 2386 | $ptype = get_post_type_object(str_replace("category", "", $key));
|
| 2387 | 2387 | $cpt_name = __($ptype->labels->singular_name, 'geodirectory'); |
| 2388 | - $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
|
|
| 2388 | + $tax_change_output .= "<option value='$key' " . selected($key, $default_taxonomy, false) . ">" . sprintf(__('%s Categories', 'geodirectory'), $cpt_name) . "</option>";
|
|
| 2389 | 2389 | } |
| 2390 | 2390 | $tax_change_output .= "</select>"; |
| 2391 | 2391 | } |
| 2392 | 2392 | |
| 2393 | 2393 | if (!empty($b_terms)) {
|
| 2394 | - $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array |
|
| 2395 | - global $cat_count;//make global so we can change via function |
|
| 2394 | + $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms); // get the first array |
|
| 2395 | + global $cat_count; //make global so we can change via function |
|
| 2396 | 2396 | $cat_count = 0; |
| 2397 | 2397 | ?> |
| 2398 | 2398 | <div class="geodir-category-list-in clearfix"> |
@@ -2456,7 +2456,7 @@ discard block |
||
| 2456 | 2456 | $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show'; |
| 2457 | 2457 | $total_post = $cat->count; |
| 2458 | 2458 | |
| 2459 | - $term_link = get_term_link( $cat, $cat->taxonomy ); |
|
| 2459 | + $term_link = get_term_link($cat, $cat->taxonomy); |
|
| 2460 | 2460 | /** |
| 2461 | 2461 | * Filer the category term link. |
| 2462 | 2462 | * |
@@ -2465,7 +2465,7 @@ discard block |
||
| 2465 | 2465 | * @param int $cat->term_id The term id. |
| 2466 | 2466 | * @param string $post_type Wordpress post type. |
| 2467 | 2467 | */ |
| 2468 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type ); |
|
| 2468 | + $term_link = apply_filters('geodir_category_term_link', $term_link, $cat->term_id, $post_type);
|
|
| 2469 | 2469 | |
| 2470 | 2470 | echo '<li class="' . $class_row . '"><a href="' . $term_link . '">'; |
| 2471 | 2471 | 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> ';
|
@@ -2599,29 +2599,29 @@ discard block |
||
| 2599 | 2599 | itemWidth: 75, |
| 2600 | 2600 | itemMargin: 5, |
| 2601 | 2601 | asNavFor: '#geodir_widget_slider', |
| 2602 | - rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?> |
|
| 2602 | + rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?> |
|
| 2603 | 2603 | }); |
| 2604 | 2604 | |
| 2605 | 2605 | jQuery('#geodir_widget_slider').flexslider({
|
| 2606 | - animation: "<?php echo $animation;?>", |
|
| 2606 | + animation: "<?php echo $animation; ?>", |
|
| 2607 | 2607 | selector: ".geodir-slides > li", |
| 2608 | 2608 | namespace: "geodir-", |
| 2609 | 2609 | controlNav: true, |
| 2610 | - animationLoop: <?php echo $animationLoop;?>, |
|
| 2611 | - slideshow: <?php echo $slideshow;?>, |
|
| 2612 | - slideshowSpeed: <?php echo $slideshowSpeed;?>, |
|
| 2613 | - animationSpeed: <?php echo $animationSpeed;?>, |
|
| 2614 | - directionNav: <?php echo $directionNav;?>, |
|
| 2615 | - maxItems: <?php echo $max_show;?>, |
|
| 2610 | + animationLoop: <?php echo $animationLoop; ?>, |
|
| 2611 | + slideshow: <?php echo $slideshow; ?>, |
|
| 2612 | + slideshowSpeed: <?php echo $slideshowSpeed; ?>, |
|
| 2613 | + animationSpeed: <?php echo $animationSpeed; ?>, |
|
| 2614 | + directionNav: <?php echo $directionNav; ?>, |
|
| 2615 | + maxItems: <?php echo $max_show; ?>, |
|
| 2616 | 2616 | move: 1, |
| 2617 | - <?php if($slide_width){ echo "itemWidth: ".$slide_width.",";}?>
|
|
| 2617 | + <?php if ($slide_width) { echo "itemWidth: " . $slide_width . ","; }?>
|
|
| 2618 | 2618 | sync: "#geodir_widget_carousel", |
| 2619 | 2619 | start: function (slider) {
|
| 2620 | 2620 | jQuery('.geodir-listing-flex-loader').hide();
|
| 2621 | 2621 | jQuery('#geodir_widget_slider').css({'visibility': 'visible'});
|
| 2622 | 2622 | jQuery('#geodir_widget_carousel').css({'visibility': 'visible'});
|
| 2623 | 2623 | }, |
| 2624 | - rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?> |
|
| 2624 | + rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?> |
|
| 2625 | 2625 | }); |
| 2626 | 2626 | }); |
| 2627 | 2627 | </script> |
@@ -2662,7 +2662,7 @@ discard block |
||
| 2662 | 2662 | |
| 2663 | 2663 | global $post; |
| 2664 | 2664 | |
| 2665 | - $current_post = $post;// keep current post info |
|
| 2665 | + $current_post = $post; // keep current post info |
|
| 2666 | 2666 | |
| 2667 | 2667 | $widget_main_slides = ''; |
| 2668 | 2668 | $nav_slides = ''; |
@@ -3105,7 +3105,7 @@ discard block |
||
| 3105 | 3105 | $geodir_add_location_url = '1'; |
| 3106 | 3106 | } |
| 3107 | 3107 | |
| 3108 | - $viewall_url = get_term_link((int)$category[0], $post_type . 'category'); |
|
| 3108 | + $viewall_url = get_term_link((int) $category[0], $post_type . 'category'); |
|
| 3109 | 3109 | |
| 3110 | 3110 | $geodir_add_location_url = NULL; |
| 3111 | 3111 | } |
@@ -3113,7 +3113,7 @@ discard block |
||
| 3113 | 3113 | $gd_session->set('gd_multi_location', 1);
|
| 3114 | 3114 | } |
| 3115 | 3115 | |
| 3116 | - if(is_wp_error( $viewall_url )){$viewall_url = '';}
|
|
| 3116 | + if (is_wp_error($viewall_url)) {$viewall_url = ''; }
|
|
| 3117 | 3117 | |
| 3118 | 3118 | $query_args = array( |
| 3119 | 3119 | 'posts_per_page' => $post_number, |
@@ -3351,14 +3351,14 @@ discard block |
||
| 3351 | 3351 | * @package GeoDirectory |
| 3352 | 3352 | * @return bool |
| 3353 | 3353 | */ |
| 3354 | -function geodir_term_review_count_force_update($new_status, $old_status='', $post='') |
|
| 3354 | +function geodir_term_review_count_force_update($new_status, $old_status = '', $post = '') |
|
| 3355 | 3355 | {
|
| 3356 | - if(isset($_REQUEST['action']) && $_REQUEST['action']=='geodir_import_export'){return;}//do not run if importing listings
|
|
| 3356 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {return; }//do not run if importing listings
|
|
| 3357 | 3357 | |
| 3358 | - if(isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')){
|
|
| 3358 | + if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) {
|
|
| 3359 | 3359 | return; |
| 3360 | 3360 | } |
| 3361 | - if($new_status!=$old_status) {
|
|
| 3361 | + if ($new_status != $old_status) {
|
|
| 3362 | 3362 | geodir_count_reviews_by_terms(true); |
| 3363 | 3363 | } |
| 3364 | 3364 | return true; |
@@ -3523,7 +3523,7 @@ discard block |
||
| 3523 | 3523 | */ |
| 3524 | 3524 | try {
|
| 3525 | 3525 | require_once($language_file); |
| 3526 | - } catch(Exception $e) {
|
|
| 3526 | + } catch (Exception $e) {
|
|
| 3527 | 3527 | error_log('Language Error: ' . $e->getMessage());
|
| 3528 | 3528 | } |
| 3529 | 3529 | } |
@@ -3541,18 +3541,18 @@ discard block |
||
| 3541 | 3541 | */ |
| 3542 | 3542 | function geodirectory_load_db_language() {
|
| 3543 | 3543 | global $wp_filesystem; |
| 3544 | - if( empty( $wp_filesystem ) ) {
|
|
| 3545 | - require_once( ABSPATH .'/wp-admin/includes/file.php' ); |
|
| 3544 | + if (empty($wp_filesystem)) {
|
|
| 3545 | + require_once(ABSPATH . '/wp-admin/includes/file.php'); |
|
| 3546 | 3546 | WP_Filesystem(); |
| 3547 | 3547 | global $wp_filesystem; |
| 3548 | 3548 | } |
| 3549 | 3549 | |
| 3550 | 3550 | $language_file = geodir_plugin_path() . '/db-language.php'; |
| 3551 | 3551 | |
| 3552 | - if(is_file($language_file) && !is_writable($language_file)) |
|
| 3552 | + if (is_file($language_file) && !is_writable($language_file)) |
|
| 3553 | 3553 | return false; // Not possible to create. |
| 3554 | 3554 | |
| 3555 | - if(!is_file($language_file) && !is_writable(dirname($language_file))) |
|
| 3555 | + if (!is_file($language_file) && !is_writable(dirname($language_file))) |
|
| 3556 | 3556 | return false; // Not possible to create. |
| 3557 | 3557 | |
| 3558 | 3558 | $contents_strings = array(); |
@@ -3586,7 +3586,7 @@ discard block |
||
| 3586 | 3586 | $contents = implode(PHP_EOL, $contents_head); |
| 3587 | 3587 | |
| 3588 | 3588 | if (!empty($contents_strings)) {
|
| 3589 | - foreach ( $contents_strings as $string ) {
|
|
| 3589 | + foreach ($contents_strings as $string) {
|
|
| 3590 | 3590 | if (is_scalar($string) && $string != '') {
|
| 3591 | 3591 | $string = str_replace("'", "\'", $string);
|
| 3592 | 3592 | $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
|
@@ -3596,7 +3596,7 @@ discard block |
||
| 3596 | 3596 | |
| 3597 | 3597 | $contents .= implode(PHP_EOL, $contents_foot); |
| 3598 | 3598 | |
| 3599 | - if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) |
|
| 3599 | + if ($wp_filesystem->put_contents($language_file, $contents, FS_CHMOD_FILE)) |
|
| 3600 | 3600 | return false; // Failure; could not write file. |
| 3601 | 3601 | |
| 3602 | 3602 | return true; |
@@ -3622,7 +3622,7 @@ discard block |
||
| 3622 | 3622 | $rows = $wpdb->get_results($sql); |
| 3623 | 3623 | |
| 3624 | 3624 | if (!empty($rows)) {
|
| 3625 | - foreach($rows as $row) {
|
|
| 3625 | + foreach ($rows as $row) {
|
|
| 3626 | 3626 | if (!empty($row->admin_title)) |
| 3627 | 3627 | $translation_texts[] = stripslashes_deep($row->admin_title); |
| 3628 | 3628 | |
@@ -3660,7 +3660,7 @@ discard block |
||
| 3660 | 3660 | $rows = $wpdb->get_results($sql); |
| 3661 | 3661 | |
| 3662 | 3662 | if (!empty($rows)) {
|
| 3663 | - foreach($rows as $row) {
|
|
| 3663 | + foreach ($rows as $row) {
|
|
| 3664 | 3664 | if (!empty($row->site_title)) |
| 3665 | 3665 | $translation_texts[] = stripslashes_deep($row->site_title); |
| 3666 | 3666 | |
@@ -3678,7 +3678,7 @@ discard block |
||
| 3678 | 3678 | $rows = $wpdb->get_results($sql); |
| 3679 | 3679 | |
| 3680 | 3680 | if (!empty($rows)) {
|
| 3681 | - foreach($rows as $row) {
|
|
| 3681 | + foreach ($rows as $row) {
|
|
| 3682 | 3682 | if (!empty($row->field_site_name)) |
| 3683 | 3683 | $translation_texts[] = stripslashes_deep($row->field_site_name); |
| 3684 | 3684 | |
@@ -3713,7 +3713,7 @@ discard block |
||
| 3713 | 3713 | * |
| 3714 | 3714 | * @param array $geodir_allowed_mime_types and file extensions. |
| 3715 | 3715 | */ |
| 3716 | - return apply_filters( 'geodir_allowed_mime_types', array( |
|
| 3716 | + return apply_filters('geodir_allowed_mime_types', array(
|
|
| 3717 | 3717 | 'Image' => array( // Image formats. |
| 3718 | 3718 | 'jpg' => 'image/jpeg', |
| 3719 | 3719 | 'jpe' => 'image/jpeg', |
@@ -3802,13 +3802,13 @@ discard block |
||
| 3802 | 3802 | |
| 3803 | 3803 | |
| 3804 | 3804 | |
| 3805 | -add_filter('wpseo_replacements','geodir_wpseo_replacements',10,1);
|
|
| 3805 | +add_filter('wpseo_replacements', 'geodir_wpseo_replacements', 10, 1);
|
|
| 3806 | 3806 | /* |
| 3807 | 3807 | * Add location variables to wpseo replacements. |
| 3808 | 3808 | * |
| 3809 | 3809 | * @since 1.5.4 |
| 3810 | 3810 | */ |
| 3811 | -function geodir_wpseo_replacements($vars){
|
|
| 3811 | +function geodir_wpseo_replacements($vars) {
|
|
| 3812 | 3812 | |
| 3813 | 3813 | global $wp; |
| 3814 | 3814 | $title = ''; |
@@ -3823,12 +3823,12 @@ discard block |
||
| 3823 | 3823 | * @param array $location_array The array of location variables. |
| 3824 | 3824 | * @param array $vars The page title variables. |
| 3825 | 3825 | */ |
| 3826 | - $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
|
|
| 3826 | + $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo', $location_array, $vars);
|
|
| 3827 | 3827 | $location_titles = array(); |
| 3828 | - if(get_query_var( 'gd_country_full' )){
|
|
| 3829 | - if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
|
|
| 3830 | - if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
|
|
| 3831 | - if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
|
|
| 3828 | + if (get_query_var('gd_country_full')) {
|
|
| 3829 | + if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
|
|
| 3830 | + if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
|
|
| 3831 | + if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
|
|
| 3832 | 3832 | } |
| 3833 | 3833 | $location_single = ''; |
| 3834 | 3834 | $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
@@ -3900,23 +3900,23 @@ discard block |
||
| 3900 | 3900 | } |
| 3901 | 3901 | |
| 3902 | 3902 | |
| 3903 | - if(!empty($location_titles)) {
|
|
| 3903 | + if (!empty($location_titles)) {
|
|
| 3904 | 3904 | $vars['%%location%%'] = implode(", ", $location_titles);
|
| 3905 | 3905 | } |
| 3906 | 3906 | |
| 3907 | 3907 | |
| 3908 | - if(!empty($location_titles)) {
|
|
| 3908 | + if (!empty($location_titles)) {
|
|
| 3909 | 3909 | $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
|
| 3910 | 3910 | } |
| 3911 | 3911 | |
| 3912 | 3912 | |
| 3913 | 3913 | |
| 3914 | - if($location_single) {
|
|
| 3915 | - $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
|
|
| 3914 | + if ($location_single) {
|
|
| 3915 | + $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' . $location_single;
|
|
| 3916 | 3916 | } |
| 3917 | 3917 | |
| 3918 | 3918 | |
| 3919 | - if($location_single) {
|
|
| 3919 | + if ($location_single) {
|
|
| 3920 | 3920 | $vars['%%location_single%%'] = $location_single; |
| 3921 | 3921 | } |
| 3922 | 3922 | |
@@ -3928,17 +3928,17 @@ discard block |
||
| 3928 | 3928 | * @param string $vars The title with variables. |
| 3929 | 3929 | * @param array $location_array The array of location variables. |
| 3930 | 3930 | */ |
| 3931 | - return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
|
|
| 3931 | + return apply_filters('geodir_wpseo_replacements_vars', $vars, $location_array);
|
|
| 3932 | 3932 | } |
| 3933 | 3933 | |
| 3934 | 3934 | |
| 3935 | -add_filter('geodir_seo_meta_title','geodir_filter_title_variables',10,3);
|
|
| 3936 | -add_filter('geodir_seo_page_title','geodir_filter_title_variables',10,2);
|
|
| 3937 | -add_filter('geodir_seo_meta_description_pre','geodir_filter_title_variables',10,3);
|
|
| 3938 | -function geodir_filter_title_variables($title, $gd_page, $sep=''){
|
|
| 3935 | +add_filter('geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3);
|
|
| 3936 | +add_filter('geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2);
|
|
| 3937 | +add_filter('geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3);
|
|
| 3938 | +function geodir_filter_title_variables($title, $gd_page, $sep = '') {
|
|
| 3939 | 3939 | |
| 3940 | 3940 | |
| 3941 | - if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
|
|
| 3941 | + if (!$gd_page || !$title) {return $title; }// if no a GD page then bail.
|
|
| 3942 | 3942 | global $post; |
| 3943 | 3943 | //print_r($post); |
| 3944 | 3944 | /* |
@@ -3980,119 +3980,119 @@ discard block |
||
| 3980 | 3980 | } |
| 3981 | 3981 | |
| 3982 | 3982 | |
| 3983 | - if(strpos($title,'%%title%%') !== false){
|
|
| 3984 | - $title = str_replace("%%title%%",$post->post_title,$title);
|
|
| 3983 | + if (strpos($title, '%%title%%') !== false) {
|
|
| 3984 | + $title = str_replace("%%title%%", $post->post_title, $title);
|
|
| 3985 | 3985 | } |
| 3986 | 3986 | |
| 3987 | - if(strpos($title,'%%sitename%%') !== false){
|
|
| 3988 | - $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
|
|
| 3987 | + if (strpos($title, '%%sitename%%') !== false) {
|
|
| 3988 | + $title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
|
|
| 3989 | 3989 | } |
| 3990 | 3990 | |
| 3991 | - if(strpos($title,'%%sitedesc%%') !== false){
|
|
| 3992 | - $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
|
|
| 3991 | + if (strpos($title, '%%sitedesc%%') !== false) {
|
|
| 3992 | + $title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
|
|
| 3993 | 3993 | } |
| 3994 | 3994 | |
| 3995 | - if(strpos($title,'%%excerpt%%') !== false){
|
|
| 3996 | - $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
|
|
| 3995 | + if (strpos($title, '%%excerpt%%') !== false) {
|
|
| 3996 | + $title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
|
|
| 3997 | 3997 | } |
| 3998 | 3998 | |
| 3999 | - if(strpos($title,'%%pt_single%%') !== false){
|
|
| 3999 | + if (strpos($title, '%%pt_single%%') !== false) {
|
|
| 4000 | 4000 | $single_name = ''; |
| 4001 | - if($gd_page=='search' || $gd_page=='author'){
|
|
| 4001 | + if ($gd_page == 'search' || $gd_page == 'author') {
|
|
| 4002 | 4002 | $geodir_post_types = get_option('geodir_post_types');
|
| 4003 | 4003 | $spt = esc_attr($_REQUEST['stype']); |
| 4004 | - if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
|
| 4005 | - $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
|
| 4004 | + if (isset($geodir_post_types[$spt]['labels']['singular_name'])) {
|
|
| 4005 | + $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory'); |
|
| 4006 | 4006 | } |
| 4007 | - }elseif($gd_page=='add-listing'){
|
|
| 4007 | + }elseif ($gd_page == 'add-listing') {
|
|
| 4008 | 4008 | $geodir_post_types = get_option('geodir_post_types');
|
| 4009 | 4009 | $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : ''; |
| 4010 | - if(!$spt && isset($_REQUEST['pid'])){
|
|
| 4011 | - $spt = get_post_type( $_REQUEST['pid'] ); |
|
| 4010 | + if (!$spt && isset($_REQUEST['pid'])) {
|
|
| 4011 | + $spt = get_post_type($_REQUEST['pid']); |
|
| 4012 | 4012 | } |
| 4013 | - if(!$spt){$spt='gd_place';}
|
|
| 4014 | - if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
|
| 4015 | - $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
|
| 4013 | + if (!$spt) {$spt = 'gd_place'; }
|
|
| 4014 | + if (isset($geodir_post_types[$spt]['labels']['singular_name'])) {
|
|
| 4015 | + $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory'); |
|
| 4016 | 4016 | } |
| 4017 | 4017 | } |
| 4018 | - elseif($post->post_type){
|
|
| 4018 | + elseif ($post->post_type) {
|
|
| 4019 | 4019 | $geodir_post_types = get_option('geodir_post_types');
|
| 4020 | - if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
|
|
| 4021 | - $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory'); |
|
| 4020 | + if (isset($geodir_post_types[$post->post_type]['labels']['singular_name'])) {
|
|
| 4021 | + $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'], 'geodirectory'); |
|
| 4022 | 4022 | } |
| 4023 | 4023 | |
| 4024 | 4024 | |
| 4025 | 4025 | } |
| 4026 | - $title = str_replace("%%pt_single%%",$single_name,$title);
|
|
| 4026 | + $title = str_replace("%%pt_single%%", $single_name, $title);
|
|
| 4027 | 4027 | } |
| 4028 | 4028 | |
| 4029 | - if(strpos($title,'%%pt_plural%%') !== false){
|
|
| 4029 | + if (strpos($title, '%%pt_plural%%') !== false) {
|
|
| 4030 | 4030 | $plural_name = ''; |
| 4031 | - if($gd_page=='search' || $gd_page=='author'){
|
|
| 4031 | + if ($gd_page == 'search' || $gd_page == 'author') {
|
|
| 4032 | 4032 | $geodir_post_types = get_option('geodir_post_types');
|
| 4033 | 4033 | $spt = esc_attr($_REQUEST['stype']); |
| 4034 | - if(isset($geodir_post_types[$spt]['labels']['name'])){
|
|
| 4035 | - $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
|
| 4034 | + if (isset($geodir_post_types[$spt]['labels']['name'])) {
|
|
| 4035 | + $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory'); |
|
| 4036 | 4036 | } |
| 4037 | - }elseif($gd_page=='add-listing'){
|
|
| 4037 | + }elseif ($gd_page == 'add-listing') {
|
|
| 4038 | 4038 | $geodir_post_types = get_option('geodir_post_types');
|
| 4039 | 4039 | $spt = sanitize_text_field($_REQUEST['listing_type']); |
| 4040 | - if(!$spt){$spt='gd_place';}
|
|
| 4041 | - if(isset($geodir_post_types[$spt]['labels']['name'])){
|
|
| 4042 | - $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
|
| 4040 | + if (!$spt) {$spt = 'gd_place'; }
|
|
| 4041 | + if (isset($geodir_post_types[$spt]['labels']['name'])) {
|
|
| 4042 | + $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory'); |
|
| 4043 | 4043 | } |
| 4044 | 4044 | } |
| 4045 | - elseif(isset($post->post_type) && $post->post_type){
|
|
| 4045 | + elseif (isset($post->post_type) && $post->post_type) {
|
|
| 4046 | 4046 | $geodir_post_types = get_option('geodir_post_types');
|
| 4047 | - if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
|
|
| 4048 | - $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory'); |
|
| 4047 | + if (isset($geodir_post_types[$post->post_type]['labels']['name'])) {
|
|
| 4048 | + $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'], 'geodirectory'); |
|
| 4049 | 4049 | } |
| 4050 | 4050 | |
| 4051 | 4051 | } |
| 4052 | - $title = str_replace("%%pt_plural%%",$plural_name,$title);
|
|
| 4052 | + $title = str_replace("%%pt_plural%%", $plural_name, $title);
|
|
| 4053 | 4053 | } |
| 4054 | 4054 | |
| 4055 | 4055 | |
| 4056 | 4056 | |
| 4057 | - if(strpos($title,'%%category%%') !== false){
|
|
| 4057 | + if (strpos($title, '%%category%%') !== false) {
|
|
| 4058 | 4058 | $cat_name = ''; |
| 4059 | 4059 | |
| 4060 | - if($gd_page=='detail') {
|
|
| 4060 | + if ($gd_page == 'detail') {
|
|
| 4061 | 4061 | if ($post->default_category) {
|
| 4062 | 4062 | $cat = get_term($post->default_category, $post->post_type . 'category'); |
| 4063 | 4063 | $cat_name = (isset($cat->name)) ? $cat->name : ''; |
| 4064 | 4064 | } |
| 4065 | - }elseif($gd_page=='listing'){
|
|
| 4065 | + }elseif ($gd_page == 'listing') {
|
|
| 4066 | 4066 | $queried_object = get_queried_object(); |
| 4067 | - if(isset($queried_object->name)){
|
|
| 4067 | + if (isset($queried_object->name)) {
|
|
| 4068 | 4068 | $cat_name = $queried_object->name; |
| 4069 | 4069 | } |
| 4070 | 4070 | } |
| 4071 | - $title = str_replace("%%category%%",$cat_name,$title);
|
|
| 4071 | + $title = str_replace("%%category%%", $cat_name, $title);
|
|
| 4072 | 4072 | } |
| 4073 | 4073 | |
| 4074 | - if(strpos($title,'%%tag%%') !== false){
|
|
| 4074 | + if (strpos($title, '%%tag%%') !== false) {
|
|
| 4075 | 4075 | $cat_name = ''; |
| 4076 | 4076 | |
| 4077 | - if($gd_page=='detail') {
|
|
| 4077 | + if ($gd_page == 'detail') {
|
|
| 4078 | 4078 | if ($post->default_category) {
|
| 4079 | 4079 | $cat = get_term($post->default_category, $post->post_type . 'category'); |
| 4080 | 4080 | $cat_name = (isset($cat->name)) ? $cat->name : ''; |
| 4081 | 4081 | } |
| 4082 | - }elseif($gd_page=='listing'){
|
|
| 4082 | + }elseif ($gd_page == 'listing') {
|
|
| 4083 | 4083 | $queried_object = get_queried_object(); |
| 4084 | - if(isset($queried_object->name)){
|
|
| 4084 | + if (isset($queried_object->name)) {
|
|
| 4085 | 4085 | $cat_name = $queried_object->name; |
| 4086 | 4086 | } |
| 4087 | 4087 | } |
| 4088 | - $title = str_replace("%%tag%%",$cat_name,$title);
|
|
| 4088 | + $title = str_replace("%%tag%%", $cat_name, $title);
|
|
| 4089 | 4089 | } |
| 4090 | 4090 | |
| 4091 | 4091 | |
| 4092 | 4092 | |
| 4093 | - if(strpos($title,'%%id%%') !== false){
|
|
| 4093 | + if (strpos($title, '%%id%%') !== false) {
|
|
| 4094 | 4094 | $ID = (isset($post->ID)) ? $post->ID : ''; |
| 4095 | - $title = str_replace("%%id%%",$ID,$title);
|
|
| 4095 | + $title = str_replace("%%id%%", $ID, $title);
|
|
| 4096 | 4096 | } |
| 4097 | 4097 | |
| 4098 | 4098 | /* |
@@ -4105,8 +4105,8 @@ discard block |
||
| 4105 | 4105 | } |
| 4106 | 4106 | */ |
| 4107 | 4107 | |
| 4108 | - if(strpos($title,'%%sep%%') !== false){
|
|
| 4109 | - $title = str_replace("%%sep%%",$sep,$title);
|
|
| 4108 | + if (strpos($title, '%%sep%%') !== false) {
|
|
| 4109 | + $title = str_replace("%%sep%%", $sep, $title);
|
|
| 4110 | 4110 | } |
| 4111 | 4111 | |
| 4112 | 4112 | |
@@ -4124,12 +4124,12 @@ discard block |
||
| 4124 | 4124 | * @param string $gd_page The page being filtered. |
| 4125 | 4125 | * @param string $sep The separator, default: `|`. |
| 4126 | 4126 | */ |
| 4127 | - $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
|
|
| 4127 | + $location_array = apply_filters('geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep);
|
|
| 4128 | 4128 | $location_titles = array(); |
| 4129 | - if($gd_page=='location' && get_query_var( 'gd_country_full' )){
|
|
| 4130 | - if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
|
|
| 4131 | - if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
|
|
| 4132 | - if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
|
|
| 4129 | + if ($gd_page == 'location' && get_query_var('gd_country_full')) {
|
|
| 4130 | + if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
|
|
| 4131 | + if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
|
|
| 4132 | + if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
|
|
| 4133 | 4133 | } |
| 4134 | 4134 | $location_single = ''; |
| 4135 | 4135 | $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
@@ -4201,65 +4201,65 @@ discard block |
||
| 4201 | 4201 | } |
| 4202 | 4202 | |
| 4203 | 4203 | |
| 4204 | - if(strpos($title,'%%location%%') !== false){
|
|
| 4204 | + if (strpos($title, '%%location%%') !== false) {
|
|
| 4205 | 4205 | $location = ''; |
| 4206 | - if($location_titles) {
|
|
| 4206 | + if ($location_titles) {
|
|
| 4207 | 4207 | $location = implode(", ", $location_titles);
|
| 4208 | 4208 | } |
| 4209 | - $title = str_replace("%%location%%",$location,$title);
|
|
| 4209 | + $title = str_replace("%%location%%", $location, $title);
|
|
| 4210 | 4210 | } |
| 4211 | 4211 | |
| 4212 | - if(strpos($title,'%%in_location%%') !== false){
|
|
| 4212 | + if (strpos($title, '%%in_location%%') !== false) {
|
|
| 4213 | 4213 | $location = ''; |
| 4214 | - if($location_titles) {
|
|
| 4214 | + if ($location_titles) {
|
|
| 4215 | 4215 | $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
|
| 4216 | 4216 | } |
| 4217 | - $title = str_replace("%%in_location%%",$location,$title);
|
|
| 4217 | + $title = str_replace("%%in_location%%", $location, $title);
|
|
| 4218 | 4218 | } |
| 4219 | 4219 | |
| 4220 | - if(strpos($title,'%%in_location_single%%') !== false){
|
|
| 4221 | - if($location_single) {
|
|
| 4222 | - $location_single = __('in', 'geodirectory') . ' ' .$location_single;
|
|
| 4220 | + if (strpos($title, '%%in_location_single%%') !== false) {
|
|
| 4221 | + if ($location_single) {
|
|
| 4222 | + $location_single = __('in', 'geodirectory') . ' ' . $location_single;
|
|
| 4223 | 4223 | } |
| 4224 | - $title = str_replace("%%in_location_single%%",$location_single,$title);
|
|
| 4224 | + $title = str_replace("%%in_location_single%%", $location_single, $title);
|
|
| 4225 | 4225 | } |
| 4226 | 4226 | |
| 4227 | - if(strpos($title,'%%location_single%%') !== false){
|
|
| 4228 | - $title = str_replace("%%location_single%%",$location_single,$title);
|
|
| 4227 | + if (strpos($title, '%%location_single%%') !== false) {
|
|
| 4228 | + $title = str_replace("%%location_single%%", $location_single, $title);
|
|
| 4229 | 4229 | } |
| 4230 | 4230 | |
| 4231 | 4231 | |
| 4232 | - if(strpos($title,'%%search_term%%') !== false){
|
|
| 4232 | + if (strpos($title, '%%search_term%%') !== false) {
|
|
| 4233 | 4233 | $search_term = ''; |
| 4234 | - if(isset($_REQUEST['s'])){
|
|
| 4234 | + if (isset($_REQUEST['s'])) {
|
|
| 4235 | 4235 | $search_term = esc_attr($_REQUEST['s']); |
| 4236 | 4236 | } |
| 4237 | - $title = str_replace("%%search_term%%",$search_term,$title);
|
|
| 4237 | + $title = str_replace("%%search_term%%", $search_term, $title);
|
|
| 4238 | 4238 | } |
| 4239 | 4239 | |
| 4240 | - if(strpos($title,'%%search_near%%') !== false){
|
|
| 4240 | + if (strpos($title, '%%search_near%%') !== false) {
|
|
| 4241 | 4241 | $search_term = ''; |
| 4242 | - if(isset($_REQUEST['snear'])){
|
|
| 4242 | + if (isset($_REQUEST['snear'])) {
|
|
| 4243 | 4243 | $search_term = esc_attr($_REQUEST['snear']); |
| 4244 | 4244 | } |
| 4245 | - $title = str_replace("%%search_near%%",$search_term,$title);
|
|
| 4245 | + $title = str_replace("%%search_near%%", $search_term, $title);
|
|
| 4246 | 4246 | } |
| 4247 | 4247 | |
| 4248 | - if(strpos($title,'%%name%%') !== false){
|
|
| 4248 | + if (strpos($title, '%%name%%') !== false) {
|
|
| 4249 | 4249 | $author_name = ''; |
| 4250 | - if($author_name = get_the_author()){}
|
|
| 4251 | - else{
|
|
| 4250 | + if ($author_name = get_the_author()) {}
|
|
| 4251 | + else {
|
|
| 4252 | 4252 | $queried_object = get_queried_object(); |
| 4253 | - if(isset($queried_object->data->user_nicename)){
|
|
| 4253 | + if (isset($queried_object->data->user_nicename)) {
|
|
| 4254 | 4254 | $author_name = $queried_object->data->user_nicename; |
| 4255 | 4255 | } |
| 4256 | 4256 | } |
| 4257 | - $title = str_replace("%%name%%",$author_name,$title);
|
|
| 4257 | + $title = str_replace("%%name%%", $author_name, $title);
|
|
| 4258 | 4258 | } |
| 4259 | 4259 | |
| 4260 | - $title = wptexturize( $title ); |
|
| 4261 | - $title = convert_chars( $title ); |
|
| 4262 | - $title = esc_html( $title ); |
|
| 4260 | + $title = wptexturize($title); |
|
| 4261 | + $title = convert_chars($title); |
|
| 4262 | + $title = esc_html($title); |
|
| 4263 | 4263 | |
| 4264 | 4264 | /** |
| 4265 | 4265 | * Filter the title variables after standard ones have been filtered. |
@@ -4272,7 +4272,7 @@ discard block |
||
| 4272 | 4272 | * @param string $sep The separator, default: `|`. |
| 4273 | 4273 | */ |
| 4274 | 4274 | |
| 4275 | - return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
|
|
| 4275 | + return apply_filters('geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep);
|
|
| 4276 | 4276 | } |
| 4277 | 4277 | |
| 4278 | 4278 | /** |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Plugin general functions |
|
| 4 | - * |
|
| 5 | - * @since 1.0.0 |
|
| 6 | - * @package GeoDirectory |
|
| 7 | - */ |
|
| 3 | + * Plugin general functions |
|
| 4 | + * |
|
| 5 | + * @since 1.0.0 |
|
| 6 | + * @package GeoDirectory |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | /** |
@@ -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);
|
|
| 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 | 139 | |
| 140 | - return $link; |
|
| 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 | - } |
|
| 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 | 374 | |
| 375 | 375 | |
| 376 | - } |
|
| 376 | + } |
|
| 377 | 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 | - } |
|
| 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 | 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 | - } |
|
| 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 | 410 | |
| 411 | 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 | - } |
|
| 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 | 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 | - } |
|
| 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 | 431 | |
| 432 | - } |
|
| 432 | + } |
|
| 433 | 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; |
|
| 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 | 436 | |
| 437 | 437 | |
| 438 | - if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) |
|
| 439 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 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'));
|
|
| 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 | 513 | |
| 514 | - } |
|
| 514 | + } |
|
| 515 | 515 | |
| 516 | - return $imagesizes; |
|
| 517 | - } |
|
| 516 | + return $imagesizes; |
|
| 517 | + } |
|
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | /** |
@@ -534,148 +534,148 @@ 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($point2['latitude'] - $point1['latitude']); |
|
| 621 | - $deltaLongitude = deg2rad($point2['longitude'] - $point1['longitude']); |
|
| 622 | - $a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) + |
|
| 623 | - cos(deg2rad($point1['latitude'])) * cos(deg2rad($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($point2['latitude'] - $point1['latitude']); |
|
| 621 | + $deltaLongitude = deg2rad($point2['longitude'] - $point1['longitude']); |
|
| 622 | + $a = sin($deltaLatitude / 2) * sin($deltaLatitude / 2) + |
|
| 623 | + cos(deg2rad($point1['latitude'])) * cos(deg2rad($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 | - } |
|
| 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 | + } |
|
| 679 | 679 | |
| 680 | 680 | if (!empty($subject)) {
|
| 681 | 681 | $subject = __(stripslashes_deep($subject),'geodirectory'); |
@@ -685,125 +685,125 @@ discard block |
||
| 685 | 685 | $message = __(stripslashes_deep($message),'geodirectory'); |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | - $to_message = nl2br($to_message); |
|
| 689 | - $sitefromEmail = get_option('site_email');
|
|
| 690 | - $sitefromEmailName = get_site_emailName(); |
|
| 691 | - $productlink = get_permalink($post_id); |
|
| 688 | + $to_message = nl2br($to_message); |
|
| 689 | + $sitefromEmail = get_option('site_email');
|
|
| 690 | + $sitefromEmailName = get_site_emailName(); |
|
| 691 | + $productlink = get_permalink($post_id); |
|
| 692 | 692 | |
| 693 | - $user_login = ''; |
|
| 694 | - if ($user_id > 0 && $user_info = get_userdata($user_id)) {
|
|
| 695 | - $user_login = $user_info->user_login; |
|
| 696 | - } |
|
| 693 | + $user_login = ''; |
|
| 694 | + if ($user_id > 0 && $user_info = get_userdata($user_id)) {
|
|
| 695 | + $user_login = $user_info->user_login; |
|
| 696 | + } |
|
| 697 | 697 | |
| 698 | - $posted_date = ''; |
|
| 699 | - $listingLink = ''; |
|
| 698 | + $posted_date = ''; |
|
| 699 | + $listingLink = ''; |
|
| 700 | 700 | |
| 701 | - $post_info = get_post($post_id); |
|
| 701 | + $post_info = get_post($post_id); |
|
| 702 | 702 | |
| 703 | - if ($post_info) {
|
|
| 704 | - $posted_date = $post_info->post_date; |
|
| 705 | - $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 706 | - } |
|
| 707 | - $siteurl = home_url(); |
|
| 708 | - $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; |
|
| 709 | - $loginurl = geodir_login_url(); |
|
| 710 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 703 | + if ($post_info) {
|
|
| 704 | + $posted_date = $post_info->post_date; |
|
| 705 | + $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 706 | + } |
|
| 707 | + $siteurl = home_url(); |
|
| 708 | + $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; |
|
| 709 | + $loginurl = geodir_login_url(); |
|
| 710 | + $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 711 | 711 | |
| 712 | - if ($fromEmail == '') {
|
|
| 713 | - $fromEmail = get_option('site_email');
|
|
| 714 | - } |
|
| 712 | + if ($fromEmail == '') {
|
|
| 713 | + $fromEmail = get_option('site_email');
|
|
| 714 | + } |
|
| 715 | 715 | |
| 716 | - if ($fromEmailName == '') {
|
|
| 717 | - $fromEmailName = get_option('site_email_name');
|
|
| 718 | - } |
|
| 716 | + if ($fromEmailName == '') {
|
|
| 717 | + $fromEmailName = get_option('site_email_name');
|
|
| 718 | + } |
|
| 719 | 719 | |
| 720 | - $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#]');
|
|
| 721 | - $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); |
|
| 722 | - $message = str_replace($search_array, $replace_array, $message); |
|
| 723 | - |
|
| 724 | - $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#]');
|
|
| 725 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login); |
|
| 726 | - $subject = str_replace($search_array, $replace_array, $subject); |
|
| 727 | - |
|
| 728 | - $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 729 | - $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 730 | - $headers .= "Reply-To: " . $fromEmail . "\r\n"; |
|
| 731 | - $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n"; |
|
| 732 | - |
|
| 733 | - $to = $toEmail; |
|
| 734 | - $sent = wp_mail($to, $subject, $message, $headers); |
|
| 735 | - |
|
| 736 | - if( ! $sent ) {
|
|
| 737 | - if ( is_array( $to ) ) {
|
|
| 738 | - $to = implode( ',', $to ); |
|
| 739 | - } |
|
| 740 | - $log_message = sprintf( |
|
| 741 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 742 | - $message_type, |
|
| 743 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 744 | - $to, |
|
| 745 | - $subject |
|
| 746 | - ); |
|
| 747 | - geodir_error_log( $log_message ); |
|
| 748 | - } |
|
| 720 | + $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#]');
|
|
| 721 | + $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); |
|
| 722 | + $message = str_replace($search_array, $replace_array, $message); |
|
| 723 | + |
|
| 724 | + $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#]');
|
|
| 725 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login); |
|
| 726 | + $subject = str_replace($search_array, $replace_array, $subject); |
|
| 727 | + |
|
| 728 | + $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 729 | + $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 730 | + $headers .= "Reply-To: " . $fromEmail . "\r\n"; |
|
| 731 | + $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n"; |
|
| 749 | 732 | |
| 750 | - ///////// ADMIN BCC EMIALS |
|
| 751 | - $adminEmail = get_bloginfo('admin_email');
|
|
| 752 | - $to = $adminEmail; |
|
| 733 | + $to = $toEmail; |
|
| 734 | + $sent = wp_mail($to, $subject, $message, $headers); |
|
| 753 | 735 | |
| 754 | - $admin_bcc = false; |
|
| 755 | - if ($message_type == 'post_submit') {
|
|
| 756 | - $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
|
|
| 757 | - $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
|
|
| 736 | + if( ! $sent ) {
|
|
| 737 | + if ( is_array( $to ) ) {
|
|
| 738 | + $to = implode( ',', $to ); |
|
| 739 | + } |
|
| 740 | + $log_message = sprintf( |
|
| 741 | + __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 742 | + $message_type, |
|
| 743 | + date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 744 | + $to, |
|
| 745 | + $subject |
|
| 746 | + ); |
|
| 747 | + geodir_error_log( $log_message ); |
|
| 748 | + } |
|
| 758 | 749 | |
| 759 | - $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#]');
|
|
| 760 | - $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); |
|
| 761 | - $message = str_replace($search_array, $replace_array, $message); |
|
| 750 | + ///////// ADMIN BCC EMIALS |
|
| 751 | + $adminEmail = get_bloginfo('admin_email');
|
|
| 752 | + $to = $adminEmail; |
|
| 762 | 753 | |
| 763 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
|
|
| 764 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login); |
|
| 765 | - $subject = str_replace($search_array, $replace_array, $subject); |
|
| 754 | + $admin_bcc = false; |
|
| 755 | + if ($message_type == 'post_submit') {
|
|
| 756 | + $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
|
|
| 757 | + $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
|
|
| 766 | 758 | |
| 767 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 768 | - $admin_bcc = true; |
|
| 759 | + $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#]');
|
|
| 760 | + $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); |
|
| 761 | + $message = str_replace($search_array, $replace_array, $message); |
|
| 769 | 762 | |
| 770 | - } |
|
| 771 | - elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
|
|
| 772 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 773 | - $admin_bcc = true; |
|
| 774 | - } |
|
| 775 | - elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
|
|
| 776 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 777 | - $admin_bcc = true; |
|
| 778 | - } |
|
| 779 | - elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
|
|
| 780 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 781 | - $admin_bcc = true; |
|
| 782 | - } |
|
| 783 | - elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
|
|
| 784 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 785 | - $admin_bcc = true; |
|
| 786 | - } |
|
| 763 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
|
|
| 764 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login); |
|
| 765 | + $subject = str_replace($search_array, $replace_array, $subject); |
|
| 787 | 766 | |
| 788 | - if($admin_bcc===true){
|
|
| 789 | - $sent = wp_mail($to, $subject, $message, $headers); |
|
| 790 | - |
|
| 791 | - if( ! $sent ) {
|
|
| 792 | - if ( is_array( $to ) ) {
|
|
| 793 | - $to = implode( ',', $to ); |
|
| 794 | - } |
|
| 795 | - $log_message = sprintf( |
|
| 796 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 797 | - $message_type, |
|
| 798 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 799 | - $to, |
|
| 800 | - $subject |
|
| 801 | - ); |
|
| 802 | - geodir_error_log( $log_message ); |
|
| 803 | - } |
|
| 804 | - } |
|
| 767 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 768 | + $admin_bcc = true; |
|
| 769 | + |
|
| 770 | + } |
|
| 771 | + elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
|
|
| 772 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 773 | + $admin_bcc = true; |
|
| 774 | + } |
|
| 775 | + elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
|
|
| 776 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 777 | + $admin_bcc = true; |
|
| 778 | + } |
|
| 779 | + elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
|
|
| 780 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 781 | + $admin_bcc = true; |
|
| 782 | + } |
|
| 783 | + elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
|
|
| 784 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 785 | + $admin_bcc = true; |
|
| 786 | + } |
|
| 787 | + |
|
| 788 | + if($admin_bcc===true){
|
|
| 789 | + $sent = wp_mail($to, $subject, $message, $headers); |
|
| 790 | + |
|
| 791 | + if( ! $sent ) {
|
|
| 792 | + if ( is_array( $to ) ) {
|
|
| 793 | + $to = implode( ',', $to ); |
|
| 794 | + } |
|
| 795 | + $log_message = sprintf( |
|
| 796 | + __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 797 | + $message_type, |
|
| 798 | + date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 799 | + $to, |
|
| 800 | + $subject |
|
| 801 | + ); |
|
| 802 | + geodir_error_log( $log_message ); |
|
| 803 | + } |
|
| 804 | + } |
|
| 805 | 805 | |
| 806 | - } |
|
| 806 | + } |
|
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | |
@@ -816,27 +816,27 @@ discard block |
||
| 816 | 816 | function geodir_taxonomy_breadcrumb() |
| 817 | 817 | {
|
| 818 | 818 | |
| 819 | - $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
|
|
| 820 | - $parent = $term->parent; |
|
| 819 | + $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
|
|
| 820 | + $parent = $term->parent; |
|
| 821 | 821 | |
| 822 | - while ($parent): |
|
| 823 | - $parents[] = $parent; |
|
| 824 | - $new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
|
|
| 825 | - $parent = $new_parent->parent; |
|
| 826 | - endwhile; |
|
| 822 | + while ($parent): |
|
| 823 | + $parents[] = $parent; |
|
| 824 | + $new_parent = get_term_by('id', $parent, get_query_var('taxonomy'));
|
|
| 825 | + $parent = $new_parent->parent; |
|
| 826 | + endwhile; |
|
| 827 | 827 | |
| 828 | - if (!empty($parents)): |
|
| 829 | - $parents = array_reverse($parents); |
|
| 828 | + if (!empty($parents)): |
|
| 829 | + $parents = array_reverse($parents); |
|
| 830 | 830 | |
| 831 | - foreach ($parents as $parent): |
|
| 832 | - $item = get_term_by('id', $parent, get_query_var('taxonomy'));
|
|
| 833 | - $url = get_term_link($item, get_query_var('taxonomy'));
|
|
| 834 | - echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>'; |
|
| 835 | - endforeach; |
|
| 831 | + foreach ($parents as $parent): |
|
| 832 | + $item = get_term_by('id', $parent, get_query_var('taxonomy'));
|
|
| 833 | + $url = get_term_link($item, get_query_var('taxonomy'));
|
|
| 834 | + echo '<li> > <a href="' . $url . '">' . $item->name . '</a></li>'; |
|
| 835 | + endforeach; |
|
| 836 | 836 | |
| 837 | - endif; |
|
| 837 | + endif; |
|
| 838 | 838 | |
| 839 | - echo '<li> > ' . $term->name . '</li>'; |
|
| 839 | + echo '<li> > ' . $term->name . '</li>'; |
|
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | |
@@ -852,365 +852,365 @@ discard block |
||
| 852 | 852 | */ |
| 853 | 853 | function geodir_breadcrumb() |
| 854 | 854 | {
|
| 855 | - global $wp_query, $geodir_add_location_url; |
|
| 856 | - |
|
| 857 | - /** |
|
| 858 | - * Filter breadcrumb separator. |
|
| 859 | - * |
|
| 860 | - * @since 1.0.0 |
|
| 861 | - */ |
|
| 862 | - $separator = apply_filters('geodir_breadcrumb_separator', ' > ');
|
|
| 863 | - |
|
| 864 | - if (!geodir_is_page('home')) {
|
|
| 865 | - $breadcrumb = ''; |
|
| 866 | - $url_categoris = ''; |
|
| 867 | - $breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">'; |
|
| 868 | - /** |
|
| 869 | - * Filter breadcrumb's first link. |
|
| 870 | - * |
|
| 871 | - * @since 1.0.0 |
|
| 872 | - */ |
|
| 873 | - $breadcrumb .= '<li>' . apply_filters('geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __('Home', 'geodirectory') . '</a>') . '</li>';
|
|
| 855 | + global $wp_query, $geodir_add_location_url; |
|
| 856 | + |
|
| 857 | + /** |
|
| 858 | + * Filter breadcrumb separator. |
|
| 859 | + * |
|
| 860 | + * @since 1.0.0 |
|
| 861 | + */ |
|
| 862 | + $separator = apply_filters('geodir_breadcrumb_separator', ' > ');
|
|
| 863 | + |
|
| 864 | + if (!geodir_is_page('home')) {
|
|
| 865 | + $breadcrumb = ''; |
|
| 866 | + $url_categoris = ''; |
|
| 867 | + $breadcrumb .= '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">'; |
|
| 868 | + /** |
|
| 869 | + * Filter breadcrumb's first link. |
|
| 870 | + * |
|
| 871 | + * @since 1.0.0 |
|
| 872 | + */ |
|
| 873 | + $breadcrumb .= '<li>' . apply_filters('geodir_breadcrumb_first_link', '<a href="' . home_url() . '">' . __('Home', 'geodirectory') . '</a>') . '</li>';
|
|
| 874 | + |
|
| 875 | + $gd_post_type = geodir_get_current_posttype(); |
|
| 876 | + $post_type_info = get_post_type_object($gd_post_type); |
|
| 877 | + |
|
| 878 | + remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
|
|
| 879 | + |
|
| 880 | + $listing_link = get_post_type_archive_link($gd_post_type); |
|
| 881 | + |
|
| 882 | + add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
|
|
| 883 | + $listing_link = rtrim($listing_link, '/'); |
|
| 884 | + $listing_link .= '/'; |
|
| 885 | + |
|
| 886 | + $post_type_for_location_link = $listing_link; |
|
| 887 | + $location_terms = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 888 | + |
|
| 889 | + global $wp, $gd_session; |
|
| 890 | + $location_link = $post_type_for_location_link; |
|
| 891 | + |
|
| 892 | + if (geodir_is_page('detail') || geodir_is_page('listing')) {
|
|
| 893 | + global $post; |
|
| 894 | + $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 895 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 896 | + |
|
| 897 | + if(geodir_is_page('detail') && isset($post->country_slug)){
|
|
| 898 | + $location_terms = array( |
|
| 899 | + 'gd_country' => $post->country_slug, |
|
| 900 | + 'gd_region' => $post->region_slug, |
|
| 901 | + 'gd_city' => $post->city_slug |
|
| 902 | + ); |
|
| 903 | + |
|
| 904 | + if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
|
|
| 905 | + $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
|
| 906 | + } |
|
| 907 | + } |
|
| 874 | 908 | |
| 875 | - $gd_post_type = geodir_get_current_posttype(); |
|
| 876 | - $post_type_info = get_post_type_object($gd_post_type); |
|
| 909 | + $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 877 | 910 | |
| 878 | - remove_filter('post_type_archive_link', 'geodir_get_posttype_link');
|
|
| 911 | + $hide_url_part = array(); |
|
| 912 | + if ($location_manager) {
|
|
| 913 | + $hide_country_part = get_option('geodir_location_hide_country_part');
|
|
| 914 | + $hide_region_part = get_option('geodir_location_hide_region_part');
|
|
| 879 | 915 | |
| 880 | - $listing_link = get_post_type_archive_link($gd_post_type); |
|
| 916 | + if ($hide_region_part && $hide_country_part) {
|
|
| 917 | + $hide_url_part = array('gd_country', 'gd_region');
|
|
| 918 | + } else if ($hide_region_part && !$hide_country_part) {
|
|
| 919 | + $hide_url_part = array('gd_region');
|
|
| 920 | + } else if (!$hide_region_part && $hide_country_part) {
|
|
| 921 | + $hide_url_part = array('gd_country');
|
|
| 922 | + } |
|
| 923 | + } |
|
| 881 | 924 | |
| 882 | - add_filter('post_type_archive_link', 'geodir_get_posttype_link', 10, 2);
|
|
| 883 | - $listing_link = rtrim($listing_link, '/'); |
|
| 884 | - $listing_link .= '/'; |
|
| 925 | + $hide_text_part = array(); |
|
| 926 | + if ($geodir_show_location_url == 'country_city') {
|
|
| 927 | + $hide_text_part = array('gd_region');
|
|
| 885 | 928 | |
| 886 | - $post_type_for_location_link = $listing_link; |
|
| 887 | - $location_terms = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 929 | + if (isset($location_terms['gd_region']) && !$location_manager) {
|
|
| 930 | + unset($location_terms['gd_region']); |
|
| 931 | + } |
|
| 932 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 933 | + $hide_text_part = array('gd_country');
|
|
| 888 | 934 | |
| 889 | - global $wp, $gd_session; |
|
| 890 | - $location_link = $post_type_for_location_link; |
|
| 935 | + if (isset($location_terms['gd_country']) && !$location_manager) {
|
|
| 936 | + unset($location_terms['gd_country']); |
|
| 937 | + } |
|
| 938 | + } else if ($geodir_show_location_url == 'city') {
|
|
| 939 | + $hide_text_part = array('gd_country', 'gd_region');
|
|
| 891 | 940 | |
| 892 | - if (geodir_is_page('detail') || geodir_is_page('listing')) {
|
|
| 893 | - global $post; |
|
| 894 | - $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 895 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 896 | - |
|
| 897 | - if(geodir_is_page('detail') && isset($post->country_slug)){
|
|
| 898 | - $location_terms = array( |
|
| 899 | - 'gd_country' => $post->country_slug, |
|
| 900 | - 'gd_region' => $post->region_slug, |
|
| 901 | - 'gd_city' => $post->city_slug |
|
| 902 | - ); |
|
| 903 | - |
|
| 904 | - if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
|
|
| 905 | - $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
|
| 941 | + if (isset($location_terms['gd_country']) && !$location_manager) {
|
|
| 942 | + unset($location_terms['gd_country']); |
|
| 906 | 943 | } |
| 907 | - } |
|
| 908 | - |
|
| 909 | - $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 910 | - |
|
| 911 | - $hide_url_part = array(); |
|
| 912 | - if ($location_manager) {
|
|
| 913 | - $hide_country_part = get_option('geodir_location_hide_country_part');
|
|
| 914 | - $hide_region_part = get_option('geodir_location_hide_region_part');
|
|
| 915 | - |
|
| 916 | - if ($hide_region_part && $hide_country_part) {
|
|
| 917 | - $hide_url_part = array('gd_country', 'gd_region');
|
|
| 918 | - } else if ($hide_region_part && !$hide_country_part) {
|
|
| 919 | - $hide_url_part = array('gd_region');
|
|
| 920 | - } else if (!$hide_region_part && $hide_country_part) {
|
|
| 921 | - $hide_url_part = array('gd_country');
|
|
| 922 | - } |
|
| 923 | - } |
|
| 924 | - |
|
| 925 | - $hide_text_part = array(); |
|
| 926 | - if ($geodir_show_location_url == 'country_city') {
|
|
| 927 | - $hide_text_part = array('gd_region');
|
|
| 928 | - |
|
| 929 | - if (isset($location_terms['gd_region']) && !$location_manager) {
|
|
| 930 | - unset($location_terms['gd_region']); |
|
| 931 | - } |
|
| 932 | - } else if ($geodir_show_location_url == 'region_city') {
|
|
| 933 | - $hide_text_part = array('gd_country');
|
|
| 934 | - |
|
| 935 | - if (isset($location_terms['gd_country']) && !$location_manager) {
|
|
| 936 | - unset($location_terms['gd_country']); |
|
| 937 | - } |
|
| 938 | - } else if ($geodir_show_location_url == 'city') {
|
|
| 939 | - $hide_text_part = array('gd_country', 'gd_region');
|
|
| 940 | - |
|
| 941 | - if (isset($location_terms['gd_country']) && !$location_manager) {
|
|
| 942 | - unset($location_terms['gd_country']); |
|
| 943 | - } |
|
| 944 | - if (isset($location_terms['gd_region']) && !$location_manager) {
|
|
| 945 | - unset($location_terms['gd_region']); |
|
| 946 | - } |
|
| 947 | - } |
|
| 948 | - |
|
| 949 | - $is_location_last = ''; |
|
| 950 | - $is_taxonomy_last = ''; |
|
| 951 | - $breadcrumb .= '<li>'; |
|
| 952 | - if (get_query_var($gd_post_type . 'category')) |
|
| 953 | - $gd_taxonomy = $gd_post_type . 'category'; |
|
| 954 | - elseif (get_query_var($gd_post_type . '_tags')) |
|
| 955 | - $gd_taxonomy = $gd_post_type . '_tags'; |
|
| 956 | - |
|
| 957 | - $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>'; |
|
| 958 | - if (!empty($gd_taxonomy) || geodir_is_page('detail'))
|
|
| 959 | - $is_location_last = false; |
|
| 960 | - else |
|
| 961 | - $is_location_last = true; |
|
| 962 | - |
|
| 963 | - if (!empty($gd_taxonomy) && geodir_is_page('listing'))
|
|
| 964 | - $is_taxonomy_last = true; |
|
| 965 | - else |
|
| 966 | - $is_taxonomy_last = false; |
|
| 967 | - |
|
| 968 | - if (!empty($location_terms)) {
|
|
| 969 | - $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
|
|
| 970 | - |
|
| 971 | - foreach ($location_terms as $key => $location_term) {
|
|
| 972 | - if ($location_term != '') {
|
|
| 973 | - if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
|
|
| 974 | - continue; |
|
| 975 | - } |
|
| 976 | - |
|
| 977 | - $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
|
|
| 978 | - $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
|
|
| 979 | - $gd_location_link_text = ucfirst($gd_location_link_text); |
|
| 980 | - |
|
| 981 | - $location_term_actual_country = ''; |
|
| 982 | - $location_term_actual_region = ''; |
|
| 983 | - $location_term_actual_city = ''; |
|
| 984 | - if ($geodir_get_locations) {
|
|
| 985 | - if ($key == 'gd_country') {
|
|
| 986 | - $location_term_actual_country = get_actual_location_name('country', $location_term, true);
|
|
| 987 | - } else if ($key == 'gd_region') {
|
|
| 988 | - $location_term_actual_region = get_actual_location_name('region', $location_term, true);
|
|
| 989 | - } else if ($key == 'gd_city') {
|
|
| 990 | - $location_term_actual_city = get_actual_location_name('city', $location_term, true);
|
|
| 991 | - } |
|
| 992 | - } else {
|
|
| 993 | - $location_info = geodir_get_location(); |
|
| 994 | - |
|
| 995 | - if (!empty($location_info) && isset($location_info->location_id)) {
|
|
| 996 | - if ($key == 'gd_country') {
|
|
| 997 | - $location_term_actual_country = __($location_info->country, 'geodirectory'); |
|
| 998 | - } else if ($key == 'gd_region') {
|
|
| 999 | - $location_term_actual_region = __($location_info->region, 'geodirectory'); |
|
| 1000 | - } else if ($key == 'gd_city') {
|
|
| 1001 | - $location_term_actual_city = __($location_info->city, 'geodirectory'); |
|
| 1002 | - } |
|
| 1003 | - } |
|
| 1004 | - } |
|
| 1005 | - |
|
| 1006 | - 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'] != '')) {
|
|
| 1007 | - $breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text; |
|
| 1008 | - } else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
|
|
| 1009 | - $breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text; |
|
| 1010 | - } else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
|
|
| 1011 | - $breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text; |
|
| 1012 | - } else if ($is_location_last && $key == 'gd_neighbourhood') {
|
|
| 1013 | - $breadcrumb .= $separator . $gd_location_link_text; |
|
| 1014 | - } else {
|
|
| 1015 | - if (get_option('permalink_structure') != '') {
|
|
| 1016 | - $location_link .= $location_term . '/'; |
|
| 1017 | - } else {
|
|
| 1018 | - $location_link .= "&$key=" . $location_term; |
|
| 1019 | - } |
|
| 944 | + if (isset($location_terms['gd_region']) && !$location_manager) {
|
|
| 945 | + unset($location_terms['gd_region']); |
|
| 946 | + } |
|
| 947 | + } |
|
| 1020 | 948 | |
| 1021 | - if ($key == 'gd_country' && $location_term_actual_country != '') {
|
|
| 1022 | - $gd_location_link_text = $location_term_actual_country; |
|
| 1023 | - } else if ($key == 'gd_region' && $location_term_actual_region != '') {
|
|
| 1024 | - $gd_location_link_text = $location_term_actual_region; |
|
| 1025 | - } else if ($key == 'gd_city' && $location_term_actual_city != '') {
|
|
| 1026 | - $gd_location_link_text = $location_term_actual_city; |
|
| 1027 | - } |
|
| 949 | + $is_location_last = ''; |
|
| 950 | + $is_taxonomy_last = ''; |
|
| 951 | + $breadcrumb .= '<li>'; |
|
| 952 | + if (get_query_var($gd_post_type . 'category')) |
|
| 953 | + $gd_taxonomy = $gd_post_type . 'category'; |
|
| 954 | + elseif (get_query_var($gd_post_type . '_tags')) |
|
| 955 | + $gd_taxonomy = $gd_post_type . '_tags'; |
|
| 956 | + |
|
| 957 | + $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>'; |
|
| 958 | + if (!empty($gd_taxonomy) || geodir_is_page('detail'))
|
|
| 959 | + $is_location_last = false; |
|
| 960 | + else |
|
| 961 | + $is_location_last = true; |
|
| 962 | + |
|
| 963 | + if (!empty($gd_taxonomy) && geodir_is_page('listing'))
|
|
| 964 | + $is_taxonomy_last = true; |
|
| 965 | + else |
|
| 966 | + $is_taxonomy_last = false; |
|
| 967 | + |
|
| 968 | + if (!empty($location_terms)) {
|
|
| 969 | + $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
|
|
| 970 | + |
|
| 971 | + foreach ($location_terms as $key => $location_term) {
|
|
| 972 | + if ($location_term != '') {
|
|
| 973 | + if (!empty($hide_url_part) && in_array($key, $hide_url_part)) { // Hide location part from url & breadcrumb.
|
|
| 974 | + continue; |
|
| 975 | + } |
|
| 1028 | 976 | |
| 1029 | - /* |
|
| 977 | + $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location_term);
|
|
| 978 | + $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
|
|
| 979 | + $gd_location_link_text = ucfirst($gd_location_link_text); |
|
| 980 | + |
|
| 981 | + $location_term_actual_country = ''; |
|
| 982 | + $location_term_actual_region = ''; |
|
| 983 | + $location_term_actual_city = ''; |
|
| 984 | + if ($geodir_get_locations) {
|
|
| 985 | + if ($key == 'gd_country') {
|
|
| 986 | + $location_term_actual_country = get_actual_location_name('country', $location_term, true);
|
|
| 987 | + } else if ($key == 'gd_region') {
|
|
| 988 | + $location_term_actual_region = get_actual_location_name('region', $location_term, true);
|
|
| 989 | + } else if ($key == 'gd_city') {
|
|
| 990 | + $location_term_actual_city = get_actual_location_name('city', $location_term, true);
|
|
| 991 | + } |
|
| 992 | + } else {
|
|
| 993 | + $location_info = geodir_get_location(); |
|
| 994 | + |
|
| 995 | + if (!empty($location_info) && isset($location_info->location_id)) {
|
|
| 996 | + if ($key == 'gd_country') {
|
|
| 997 | + $location_term_actual_country = __($location_info->country, 'geodirectory'); |
|
| 998 | + } else if ($key == 'gd_region') {
|
|
| 999 | + $location_term_actual_region = __($location_info->region, 'geodirectory'); |
|
| 1000 | + } else if ($key == 'gd_city') {
|
|
| 1001 | + $location_term_actual_city = __($location_info->city, 'geodirectory'); |
|
| 1002 | + } |
|
| 1003 | + } |
|
| 1004 | + } |
|
| 1005 | + |
|
| 1006 | + 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'] != '')) {
|
|
| 1007 | + $breadcrumb .= $location_term_actual_country != '' ? $separator . $location_term_actual_country : $separator . $gd_location_link_text; |
|
| 1008 | + } else if ($is_location_last && $key == 'gd_region' && !(isset($location_terms['gd_city']) && $location_terms['gd_city'] != '')) {
|
|
| 1009 | + $breadcrumb .= $location_term_actual_region != '' ? $separator . $location_term_actual_region : $separator . $gd_location_link_text; |
|
| 1010 | + } else if ($is_location_last && $key == 'gd_city' && empty($location_terms['gd_neighbourhood'])) {
|
|
| 1011 | + $breadcrumb .= $location_term_actual_city != '' ? $separator . $location_term_actual_city : $separator . $gd_location_link_text; |
|
| 1012 | + } else if ($is_location_last && $key == 'gd_neighbourhood') {
|
|
| 1013 | + $breadcrumb .= $separator . $gd_location_link_text; |
|
| 1014 | + } else {
|
|
| 1015 | + if (get_option('permalink_structure') != '') {
|
|
| 1016 | + $location_link .= $location_term . '/'; |
|
| 1017 | + } else {
|
|
| 1018 | + $location_link .= "&$key=" . $location_term; |
|
| 1019 | + } |
|
| 1020 | + |
|
| 1021 | + if ($key == 'gd_country' && $location_term_actual_country != '') {
|
|
| 1022 | + $gd_location_link_text = $location_term_actual_country; |
|
| 1023 | + } else if ($key == 'gd_region' && $location_term_actual_region != '') {
|
|
| 1024 | + $gd_location_link_text = $location_term_actual_region; |
|
| 1025 | + } else if ($key == 'gd_city' && $location_term_actual_city != '') {
|
|
| 1026 | + $gd_location_link_text = $location_term_actual_city; |
|
| 1027 | + } |
|
| 1028 | + |
|
| 1029 | + /* |
|
| 1030 | 1030 | if (geodir_is_page('detail') && !empty($hide_text_part) && in_array($key, $hide_text_part)) {
|
| 1031 | 1031 | continue; |
| 1032 | 1032 | } |
| 1033 | 1033 | */ |
| 1034 | 1034 | |
| 1035 | - $breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>'; |
|
| 1036 | - } |
|
| 1037 | - } |
|
| 1038 | - } |
|
| 1039 | - } |
|
| 1040 | - |
|
| 1041 | - if (!empty($gd_taxonomy)) {
|
|
| 1042 | - $term_index = 1; |
|
| 1043 | - |
|
| 1044 | - //if(get_option('geodir_add_categories_url'))
|
|
| 1045 | - {
|
|
| 1046 | - if (get_query_var($gd_post_type . '_tags')) {
|
|
| 1047 | - $cat_link = $listing_link . 'tags/'; |
|
| 1048 | - } else |
|
| 1049 | - $cat_link = $listing_link; |
|
| 1050 | - |
|
| 1051 | - foreach ($location_terms as $key => $location_term) {
|
|
| 1052 | - if ($location_manager && in_array($key, $hide_url_part)) {
|
|
| 1053 | - continue; |
|
| 1054 | - } |
|
| 1055 | - |
|
| 1056 | - if ($location_term != '') {
|
|
| 1057 | - if (get_option('permalink_structure') != '') {
|
|
| 1058 | - $cat_link .= $location_term . '/'; |
|
| 1059 | - } |
|
| 1060 | - } |
|
| 1061 | - } |
|
| 1062 | - |
|
| 1063 | - $term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
|
|
| 1064 | - foreach ($term_array as $term) {
|
|
| 1065 | - $term_link_text = preg_replace('/-(\d+)$/', '', $term);
|
|
| 1066 | - $term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
|
|
| 1067 | - |
|
| 1068 | - // get term actual name |
|
| 1069 | - $term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
|
|
| 1070 | - if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
|
|
| 1071 | - $term_link_text = urldecode($term_info['name']); |
|
| 1072 | - } else {
|
|
| 1073 | - $term_link_text = geodir_ucwords(urldecode($term_link_text)); |
|
| 1074 | - } |
|
| 1075 | - |
|
| 1076 | - if ($term_index == count($term_array) && $is_taxonomy_last) |
|
| 1077 | - $breadcrumb .= $separator . $term_link_text; |
|
| 1078 | - else {
|
|
| 1079 | - $cat_link .= $term . '/'; |
|
| 1080 | - $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>'; |
|
| 1081 | - } |
|
| 1082 | - $term_index++; |
|
| 1083 | - } |
|
| 1084 | - } |
|
| 1085 | - |
|
| 1086 | - |
|
| 1087 | - } |
|
| 1088 | - |
|
| 1089 | - if (geodir_is_page('detail'))
|
|
| 1090 | - $breadcrumb .= $separator . get_the_title(); |
|
| 1091 | - |
|
| 1092 | - $breadcrumb .= '</li>'; |
|
| 1093 | - |
|
| 1094 | - |
|
| 1095 | - } elseif (geodir_is_page('author')) {
|
|
| 1096 | - $user_id = get_current_user_id(); |
|
| 1097 | - $author_link = get_author_posts_url($user_id); |
|
| 1098 | - $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
|
|
| 1099 | - |
|
| 1100 | - /** |
|
| 1101 | - * Filter author page link. |
|
| 1102 | - * |
|
| 1103 | - * @since 1.0.0 |
|
| 1104 | - * @param string $default_author_link Default author link. |
|
| 1105 | - * @param int $user_id Author ID. |
|
| 1106 | - */ |
|
| 1107 | - $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
|
|
| 1108 | - |
|
| 1109 | - $breadcrumb .= '<li>'; |
|
| 1110 | - $breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __('My Dashboard', 'geodirectory') . '</a>';
|
|
| 1111 | - |
|
| 1112 | - if (isset($_REQUEST['list'])) {
|
|
| 1113 | - $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $_REQUEST['stype']), false);
|
|
| 1114 | - |
|
| 1115 | - /** |
|
| 1116 | - * Filter author page link. |
|
| 1117 | - * |
|
| 1118 | - * @since 1.0.0 |
|
| 1119 | - * @param string $author_link Author page link. |
|
| 1120 | - * @param int $user_id Author ID. |
|
| 1121 | - * @param string $_REQUEST['stype'] Post type. |
|
| 1122 | - */ |
|
| 1123 | - $author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
|
|
| 1124 | - |
|
| 1125 | - $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>'; |
|
| 1126 | - $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
|
|
| 1127 | - } else |
|
| 1128 | - $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory'); |
|
| 1129 | - |
|
| 1130 | - $breadcrumb .= '</li>'; |
|
| 1131 | - } elseif (is_category() || is_single()) {
|
|
| 1132 | - $category = get_the_category(); |
|
| 1133 | - if (is_category()) {
|
|
| 1134 | - $breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>'; |
|
| 1135 | - } |
|
| 1136 | - if (is_single()) {
|
|
| 1137 | - $breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a></li>'; |
|
| 1138 | - $breadcrumb .= '<li>' . $separator . get_the_title() . '</li>'; |
|
| 1139 | - } |
|
| 1140 | - /* End of my version ##################################################### */ |
|
| 1141 | - } else if (is_page()) {
|
|
| 1142 | - $page_title = get_the_title(); |
|
| 1143 | - |
|
| 1144 | - if (geodir_is_page('location')) {
|
|
| 1145 | - $page_title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
|
|
| 1146 | - } |
|
| 1147 | - |
|
| 1148 | - $breadcrumb .= '<li>' . $separator; |
|
| 1149 | - $breadcrumb .= stripslashes_deep($page_title); |
|
| 1150 | - $breadcrumb .= '</li>'; |
|
| 1151 | - } else if (is_tag()) {
|
|
| 1152 | - $breadcrumb .= "<li> " . $separator . single_tag_title('',false) . '</li>';
|
|
| 1153 | - } else if (is_day()) {
|
|
| 1154 | - $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1155 | - the_time('F jS, Y');
|
|
| 1156 | - $breadcrumb .= '</li>'; |
|
| 1157 | - } else if (is_month()) {
|
|
| 1158 | - $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1159 | - the_time('F, Y');
|
|
| 1160 | - $breadcrumb .= '</li>'; |
|
| 1161 | - } else if (is_year()) {
|
|
| 1162 | - $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1163 | - the_time('Y');
|
|
| 1164 | - $breadcrumb .= '</li>'; |
|
| 1165 | - } else if (is_author()) {
|
|
| 1166 | - $breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
|
|
| 1167 | - $breadcrumb .= '</li>'; |
|
| 1168 | - } else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
|
|
| 1169 | - $breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
|
|
| 1170 | - $breadcrumb .= '</li>'; |
|
| 1171 | - } else if (is_search()) {
|
|
| 1172 | - $breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
|
|
| 1173 | - $breadcrumb .= '</li>'; |
|
| 1174 | - } |
|
| 1175 | - $breadcrumb .= '</ul></div>'; |
|
| 1176 | - |
|
| 1177 | - /** |
|
| 1178 | - * Filter breadcrumb html output. |
|
| 1179 | - * |
|
| 1180 | - * @since 1.0.0 |
|
| 1181 | - * @param string $breadcrumb Breadcrumb HTML. |
|
| 1182 | - * @param string $separator Breadcrumb separator. |
|
| 1183 | - */ |
|
| 1184 | - echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
|
|
| 1185 | - } |
|
| 1035 | + $breadcrumb .= $separator . '<a href="' . $location_link . '">' . $gd_location_link_text . '</a>'; |
|
| 1036 | + } |
|
| 1037 | + } |
|
| 1038 | + } |
|
| 1039 | + } |
|
| 1040 | + |
|
| 1041 | + if (!empty($gd_taxonomy)) {
|
|
| 1042 | + $term_index = 1; |
|
| 1043 | + |
|
| 1044 | + //if(get_option('geodir_add_categories_url'))
|
|
| 1045 | + {
|
|
| 1046 | + if (get_query_var($gd_post_type . '_tags')) {
|
|
| 1047 | + $cat_link = $listing_link . 'tags/'; |
|
| 1048 | + } else |
|
| 1049 | + $cat_link = $listing_link; |
|
| 1050 | + |
|
| 1051 | + foreach ($location_terms as $key => $location_term) {
|
|
| 1052 | + if ($location_manager && in_array($key, $hide_url_part)) {
|
|
| 1053 | + continue; |
|
| 1054 | + } |
|
| 1055 | + |
|
| 1056 | + if ($location_term != '') {
|
|
| 1057 | + if (get_option('permalink_structure') != '') {
|
|
| 1058 | + $cat_link .= $location_term . '/'; |
|
| 1059 | + } |
|
| 1060 | + } |
|
| 1061 | + } |
|
| 1062 | + |
|
| 1063 | + $term_array = explode("/", trim($wp_query->query[$gd_taxonomy], "/"));
|
|
| 1064 | + foreach ($term_array as $term) {
|
|
| 1065 | + $term_link_text = preg_replace('/-(\d+)$/', '', $term);
|
|
| 1066 | + $term_link_text = preg_replace('/[_-]/', ' ', $term_link_text);
|
|
| 1067 | + |
|
| 1068 | + // get term actual name |
|
| 1069 | + $term_info = get_term_by('slug', $term, $gd_taxonomy, 'ARRAY_A');
|
|
| 1070 | + if (!empty($term_info) && isset($term_info['name']) && $term_info['name'] != '') {
|
|
| 1071 | + $term_link_text = urldecode($term_info['name']); |
|
| 1072 | + } else {
|
|
| 1073 | + $term_link_text = geodir_ucwords(urldecode($term_link_text)); |
|
| 1074 | + } |
|
| 1075 | + |
|
| 1076 | + if ($term_index == count($term_array) && $is_taxonomy_last) |
|
| 1077 | + $breadcrumb .= $separator . $term_link_text; |
|
| 1078 | + else {
|
|
| 1079 | + $cat_link .= $term . '/'; |
|
| 1080 | + $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>'; |
|
| 1081 | + } |
|
| 1082 | + $term_index++; |
|
| 1083 | + } |
|
| 1084 | + } |
|
| 1085 | + |
|
| 1086 | + |
|
| 1087 | + } |
|
| 1088 | + |
|
| 1089 | + if (geodir_is_page('detail'))
|
|
| 1090 | + $breadcrumb .= $separator . get_the_title(); |
|
| 1091 | + |
|
| 1092 | + $breadcrumb .= '</li>'; |
|
| 1093 | + |
|
| 1094 | + |
|
| 1095 | + } elseif (geodir_is_page('author')) {
|
|
| 1096 | + $user_id = get_current_user_id(); |
|
| 1097 | + $author_link = get_author_posts_url($user_id); |
|
| 1098 | + $default_author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => 'gd_place'), false);
|
|
| 1099 | + |
|
| 1100 | + /** |
|
| 1101 | + * Filter author page link. |
|
| 1102 | + * |
|
| 1103 | + * @since 1.0.0 |
|
| 1104 | + * @param string $default_author_link Default author link. |
|
| 1105 | + * @param int $user_id Author ID. |
|
| 1106 | + */ |
|
| 1107 | + $default_author_link = apply_filters('geodir_dashboard_author_link', $default_author_link, $user_id);
|
|
| 1108 | + |
|
| 1109 | + $breadcrumb .= '<li>'; |
|
| 1110 | + $breadcrumb .= $separator . '<a href="' . $default_author_link . '">' . __('My Dashboard', 'geodirectory') . '</a>';
|
|
| 1111 | + |
|
| 1112 | + if (isset($_REQUEST['list'])) {
|
|
| 1113 | + $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true', 'stype' => $_REQUEST['stype']), false);
|
|
| 1114 | + |
|
| 1115 | + /** |
|
| 1116 | + * Filter author page link. |
|
| 1117 | + * |
|
| 1118 | + * @since 1.0.0 |
|
| 1119 | + * @param string $author_link Author page link. |
|
| 1120 | + * @param int $user_id Author ID. |
|
| 1121 | + * @param string $_REQUEST['stype'] Post type. |
|
| 1122 | + */ |
|
| 1123 | + $author_link = apply_filters('geodir_dashboard_author_link', $author_link, $user_id, $_REQUEST['stype']);
|
|
| 1124 | + |
|
| 1125 | + $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>'; |
|
| 1126 | + $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
|
|
| 1127 | + } else |
|
| 1128 | + $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory'); |
|
| 1129 | + |
|
| 1130 | + $breadcrumb .= '</li>'; |
|
| 1131 | + } elseif (is_category() || is_single()) {
|
|
| 1132 | + $category = get_the_category(); |
|
| 1133 | + if (is_category()) {
|
|
| 1134 | + $breadcrumb .= '<li>' . $separator . $category[0]->cat_name . '</li>'; |
|
| 1135 | + } |
|
| 1136 | + if (is_single()) {
|
|
| 1137 | + $breadcrumb .= '<li>' . $separator . '<a href="' . get_category_link($category[0]->term_id) . '">' . $category[0]->cat_name . '</a></li>'; |
|
| 1138 | + $breadcrumb .= '<li>' . $separator . get_the_title() . '</li>'; |
|
| 1139 | + } |
|
| 1140 | + /* End of my version ##################################################### */ |
|
| 1141 | + } else if (is_page()) {
|
|
| 1142 | + $page_title = get_the_title(); |
|
| 1143 | + |
|
| 1144 | + if (geodir_is_page('location')) {
|
|
| 1145 | + $page_title = defined('GD_LOCATION') ? GD_LOCATION : __('Location', 'geodirectory');
|
|
| 1146 | + } |
|
| 1147 | + |
|
| 1148 | + $breadcrumb .= '<li>' . $separator; |
|
| 1149 | + $breadcrumb .= stripslashes_deep($page_title); |
|
| 1150 | + $breadcrumb .= '</li>'; |
|
| 1151 | + } else if (is_tag()) {
|
|
| 1152 | + $breadcrumb .= "<li> " . $separator . single_tag_title('',false) . '</li>';
|
|
| 1153 | + } else if (is_day()) {
|
|
| 1154 | + $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1155 | + the_time('F jS, Y');
|
|
| 1156 | + $breadcrumb .= '</li>'; |
|
| 1157 | + } else if (is_month()) {
|
|
| 1158 | + $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1159 | + the_time('F, Y');
|
|
| 1160 | + $breadcrumb .= '</li>'; |
|
| 1161 | + } else if (is_year()) {
|
|
| 1162 | + $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
|
| 1163 | + the_time('Y');
|
|
| 1164 | + $breadcrumb .= '</li>'; |
|
| 1165 | + } else if (is_author()) {
|
|
| 1166 | + $breadcrumb .= "<li> " . $separator . __(" Author Archive", 'geodirectory');
|
|
| 1167 | + $breadcrumb .= '</li>'; |
|
| 1168 | + } else if (isset($_GET['paged']) && !empty($_GET['paged'])) {
|
|
| 1169 | + $breadcrumb .= "<li>" . $separator . __("Blog Archives", 'geodirectory');
|
|
| 1170 | + $breadcrumb .= '</li>'; |
|
| 1171 | + } else if (is_search()) {
|
|
| 1172 | + $breadcrumb .= "<li> " . $separator . __(" Search Results", 'geodirectory');
|
|
| 1173 | + $breadcrumb .= '</li>'; |
|
| 1174 | + } |
|
| 1175 | + $breadcrumb .= '</ul></div>'; |
|
| 1176 | + |
|
| 1177 | + /** |
|
| 1178 | + * Filter breadcrumb html output. |
|
| 1179 | + * |
|
| 1180 | + * @since 1.0.0 |
|
| 1181 | + * @param string $breadcrumb Breadcrumb HTML. |
|
| 1182 | + * @param string $separator Breadcrumb separator. |
|
| 1183 | + */ |
|
| 1184 | + echo $breadcrumb = apply_filters('geodir_breadcrumb', $breadcrumb, $separator);
|
|
| 1185 | + } |
|
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | 1188 | |
| 1189 | 1189 | add_action("admin_init", "geodir_allow_wpadmin"); // check user is admin
|
| 1190 | 1190 | if (!function_exists('geodir_allow_wpadmin')) {
|
| 1191 | - /** |
|
| 1192 | - * Allow only admins to access wp-admin. |
|
| 1193 | - * |
|
| 1194 | - * Normal users will be redirected to home page. |
|
| 1195 | - * |
|
| 1196 | - * @since 1.0.0 |
|
| 1197 | - * @package GeoDirectory |
|
| 1198 | - * @global object $wpdb WordPress Database object. |
|
| 1199 | - */ |
|
| 1200 | - function geodir_allow_wpadmin() |
|
| 1201 | - {
|
|
| 1202 | - global $wpdb; |
|
| 1203 | - if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
|
|
| 1204 | - {
|
|
| 1205 | - if (current_user_can('manage_options')) {
|
|
| 1206 | - } else {
|
|
| 1207 | - |
|
| 1208 | - wp_redirect(home_url()); |
|
| 1209 | - exit; |
|
| 1210 | - } |
|
| 1191 | + /** |
|
| 1192 | + * Allow only admins to access wp-admin. |
|
| 1193 | + * |
|
| 1194 | + * Normal users will be redirected to home page. |
|
| 1195 | + * |
|
| 1196 | + * @since 1.0.0 |
|
| 1197 | + * @package GeoDirectory |
|
| 1198 | + * @global object $wpdb WordPress Database object. |
|
| 1199 | + */ |
|
| 1200 | + function geodir_allow_wpadmin() |
|
| 1201 | + {
|
|
| 1202 | + global $wpdb; |
|
| 1203 | + if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
|
|
| 1204 | + {
|
|
| 1205 | + if (current_user_can('manage_options')) {
|
|
| 1206 | + } else {
|
|
| 1207 | + |
|
| 1208 | + wp_redirect(home_url()); |
|
| 1209 | + exit; |
|
| 1210 | + } |
|
| 1211 | 1211 | |
| 1212 | - } |
|
| 1213 | - } |
|
| 1212 | + } |
|
| 1213 | + } |
|
| 1214 | 1214 | } |
| 1215 | 1215 | |
| 1216 | 1216 | |
@@ -1224,50 +1224,50 @@ discard block |
||
| 1224 | 1224 | */ |
| 1225 | 1225 | function fetch_remote_file($url) |
| 1226 | 1226 | {
|
| 1227 | - // extract the file name and extension from the url |
|
| 1228 | - require_once(ABSPATH . 'wp-includes/pluggable.php'); |
|
| 1229 | - $file_name = basename($url); |
|
| 1230 | - if (strpos($file_name, '?') !== false) {
|
|
| 1231 | - list($file_name) = explode('?', $file_name);
|
|
| 1232 | - } |
|
| 1233 | - |
|
| 1234 | - |
|
| 1235 | - // get placeholder file in the upload dir with a unique, sanitized filename |
|
| 1236 | - |
|
| 1237 | - $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : ''; |
|
| 1238 | - |
|
| 1239 | - $upload = wp_upload_bits($file_name, 0, '', $post_upload_date); |
|
| 1240 | - if ($upload['error']) |
|
| 1241 | - return new WP_Error('upload_dir_error', $upload['error']);
|
|
| 1242 | - |
|
| 1243 | - // fetch the remote url and write it to the placeholder file |
|
| 1244 | - $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
|
|
| 1245 | - |
|
| 1246 | - $log_message = ''; |
|
| 1247 | - $filesize = filesize($upload['file']); |
|
| 1248 | - // request failed |
|
| 1249 | - if (!$headers) {
|
|
| 1250 | - $log_message = __('Remote server did not respond', 'geodirectory');
|
|
| 1251 | - } |
|
| 1252 | - // make sure the fetch was successful |
|
| 1253 | - elseif ($headers['response']['code'] != '200') {
|
|
| 1254 | - $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
|
|
| 1255 | - } |
|
| 1256 | - elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
|
|
| 1257 | - $log_message = __('Remote file is incorrect size', 'geodirectory');
|
|
| 1258 | - } |
|
| 1259 | - elseif (0 == $filesize) {
|
|
| 1260 | - $log_message = __('Zero size file downloaded', 'geodirectory');
|
|
| 1261 | - } |
|
| 1262 | - |
|
| 1263 | - if($log_message){
|
|
| 1264 | - $del = unlink($upload['file']); |
|
| 1265 | - if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
|
|
| 1266 | - return new WP_Error('import_file_error',$log_message );
|
|
| 1267 | - } |
|
| 1268 | - |
|
| 1269 | - |
|
| 1270 | - return $upload; |
|
| 1227 | + // extract the file name and extension from the url |
|
| 1228 | + require_once(ABSPATH . 'wp-includes/pluggable.php'); |
|
| 1229 | + $file_name = basename($url); |
|
| 1230 | + if (strpos($file_name, '?') !== false) {
|
|
| 1231 | + list($file_name) = explode('?', $file_name);
|
|
| 1232 | + } |
|
| 1233 | + |
|
| 1234 | + |
|
| 1235 | + // get placeholder file in the upload dir with a unique, sanitized filename |
|
| 1236 | + |
|
| 1237 | + $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : ''; |
|
| 1238 | + |
|
| 1239 | + $upload = wp_upload_bits($file_name, 0, '', $post_upload_date); |
|
| 1240 | + if ($upload['error']) |
|
| 1241 | + return new WP_Error('upload_dir_error', $upload['error']);
|
|
| 1242 | + |
|
| 1243 | + // fetch the remote url and write it to the placeholder file |
|
| 1244 | + $headers = wp_remote_get($url, array('stream' => true,'filename' => $upload['file']));
|
|
| 1245 | + |
|
| 1246 | + $log_message = ''; |
|
| 1247 | + $filesize = filesize($upload['file']); |
|
| 1248 | + // request failed |
|
| 1249 | + if (!$headers) {
|
|
| 1250 | + $log_message = __('Remote server did not respond', 'geodirectory');
|
|
| 1251 | + } |
|
| 1252 | + // make sure the fetch was successful |
|
| 1253 | + elseif ($headers['response']['code'] != '200') {
|
|
| 1254 | + $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
|
|
| 1255 | + } |
|
| 1256 | + elseif (isset($headers['headers']['content-length']) && $filesize != $headers['headers']['content-length']) {
|
|
| 1257 | + $log_message = __('Remote file is incorrect size', 'geodirectory');
|
|
| 1258 | + } |
|
| 1259 | + elseif (0 == $filesize) {
|
|
| 1260 | + $log_message = __('Zero size file downloaded', 'geodirectory');
|
|
| 1261 | + } |
|
| 1262 | + |
|
| 1263 | + if($log_message){
|
|
| 1264 | + $del = unlink($upload['file']); |
|
| 1265 | + if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
|
|
| 1266 | + return new WP_Error('import_file_error',$log_message );
|
|
| 1267 | + } |
|
| 1268 | + |
|
| 1269 | + |
|
| 1270 | + return $upload; |
|
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | 1273 | /** |
@@ -1279,21 +1279,21 @@ discard block |
||
| 1279 | 1279 | */ |
| 1280 | 1280 | function geodir_max_upload_size() |
| 1281 | 1281 | {
|
| 1282 | - $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
|
|
| 1283 | - |
|
| 1284 | - if ($max_filesize > 0 && $max_filesize < 1) {
|
|
| 1285 | - $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
| 1286 | - } else {
|
|
| 1287 | - $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
|
| 1288 | - } |
|
| 1289 | - |
|
| 1290 | - /** |
|
| 1291 | - * Filter default image upload size limit. |
|
| 1292 | - * |
|
| 1293 | - * @since 1.0.0 |
|
| 1294 | - * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb. |
|
| 1295 | - */ |
|
| 1296 | - return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
|
|
| 1282 | + $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
|
|
| 1283 | + |
|
| 1284 | + if ($max_filesize > 0 && $max_filesize < 1) {
|
|
| 1285 | + $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
| 1286 | + } else {
|
|
| 1287 | + $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
|
| 1288 | + } |
|
| 1289 | + |
|
| 1290 | + /** |
|
| 1291 | + * Filter default image upload size limit. |
|
| 1292 | + * |
|
| 1293 | + * @since 1.0.0 |
|
| 1294 | + * @param string $max_filesize Max file upload size. Ex. 10mb, 512kb. |
|
| 1295 | + */ |
|
| 1296 | + return apply_filters('geodir_default_image_upload_size_limit', $max_filesize);
|
|
| 1297 | 1297 | } |
| 1298 | 1298 | |
| 1299 | 1299 | /** |
@@ -1307,11 +1307,11 @@ discard block |
||
| 1307 | 1307 | */ |
| 1308 | 1308 | function geodir_dummy_folder_exists() |
| 1309 | 1309 | {
|
| 1310 | - $path = geodir_plugin_path() . '/geodirectory-admin/dummy/'; |
|
| 1311 | - if (!is_dir($path)) |
|
| 1312 | - return false; |
|
| 1313 | - else |
|
| 1314 | - return true; |
|
| 1310 | + $path = geodir_plugin_path() . '/geodirectory-admin/dummy/'; |
|
| 1311 | + if (!is_dir($path)) |
|
| 1312 | + return false; |
|
| 1313 | + else |
|
| 1314 | + return true; |
|
| 1315 | 1315 | |
| 1316 | 1316 | } |
| 1317 | 1317 | |
@@ -1326,237 +1326,237 @@ discard block |
||
| 1326 | 1326 | */ |
| 1327 | 1327 | function geodir_get_author_info($aid) |
| 1328 | 1328 | {
|
| 1329 | - global $wpdb; |
|
| 1330 | - /*$infosql = "select * from $wpdb->users where ID=$aid";*/ |
|
| 1331 | - $infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
|
|
| 1332 | - $info = $wpdb->get_results($infosql); |
|
| 1333 | - if ($info) {
|
|
| 1334 | - return $info[0]; |
|
| 1335 | - } |
|
| 1329 | + global $wpdb; |
|
| 1330 | + /*$infosql = "select * from $wpdb->users where ID=$aid";*/ |
|
| 1331 | + $infosql = $wpdb->prepare("select * from $wpdb->users where ID=%d", array($aid));
|
|
| 1332 | + $info = $wpdb->get_results($infosql); |
|
| 1333 | + if ($info) {
|
|
| 1334 | + return $info[0]; |
|
| 1335 | + } |
|
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | 1338 | if (!function_exists('adminEmail')) {
|
| 1339 | - /** |
|
| 1340 | - * Send emails to client on post submission, renew etc. |
|
| 1341 | - * |
|
| 1342 | - * @since 1.0.0 |
|
| 1343 | - * @package GeoDirectory |
|
| 1344 | - * @global object $wpdb WordPress Database object. |
|
| 1345 | - * @param int|string $page_id Page ID. |
|
| 1346 | - * @param int|string $user_id User ID. |
|
| 1347 | - * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
|
| 1348 | - * @param string $custom_1 Custom data to be sent. |
|
| 1349 | - */ |
|
| 1350 | - function adminEmail($page_id, $user_id, $message_type, $custom_1 = '') |
|
| 1351 | - {
|
|
| 1352 | - global $wpdb; |
|
| 1353 | - if ($message_type == 'expiration') {
|
|
| 1354 | - $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
|
|
| 1355 | - $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
|
|
| 1356 | - } elseif ($message_type == 'post_submited') {
|
|
| 1357 | - $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
|
|
| 1358 | - $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
|
|
| 1359 | - } elseif ($message_type == 'renew') {
|
|
| 1360 | - $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
|
|
| 1361 | - $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
|
|
| 1362 | - } elseif ($message_type == 'upgrade') {
|
|
| 1363 | - $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
|
|
| 1364 | - $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
|
|
| 1365 | - } elseif ($message_type == 'claim_approved') {
|
|
| 1366 | - $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
|
|
| 1367 | - $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
|
|
| 1368 | - } elseif ($message_type == 'claim_rejected') {
|
|
| 1369 | - $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
|
|
| 1370 | - $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
|
|
| 1371 | - } elseif ($message_type == 'claim_requested') {
|
|
| 1372 | - $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
|
|
| 1373 | - $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
|
|
| 1374 | - } elseif ($message_type == 'auto_claim') {
|
|
| 1375 | - $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
|
|
| 1376 | - $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
|
|
| 1377 | - } elseif ($message_type == 'payment_success') {
|
|
| 1378 | - $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
|
|
| 1379 | - $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
|
|
| 1380 | - } elseif ($message_type == 'payment_fail') {
|
|
| 1381 | - $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
|
|
| 1382 | - $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
|
|
| 1383 | - } |
|
| 1384 | - $transaction_details = $custom_1; |
|
| 1385 | - $fromEmail = get_option('site_email');
|
|
| 1386 | - $fromEmailName = get_site_emailName(); |
|
| 1339 | + /** |
|
| 1340 | + * Send emails to client on post submission, renew etc. |
|
| 1341 | + * |
|
| 1342 | + * @since 1.0.0 |
|
| 1343 | + * @package GeoDirectory |
|
| 1344 | + * @global object $wpdb WordPress Database object. |
|
| 1345 | + * @param int|string $page_id Page ID. |
|
| 1346 | + * @param int|string $user_id User ID. |
|
| 1347 | + * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. |
|
| 1348 | + * @param string $custom_1 Custom data to be sent. |
|
| 1349 | + */ |
|
| 1350 | + function adminEmail($page_id, $user_id, $message_type, $custom_1 = '') |
|
| 1351 | + {
|
|
| 1352 | + global $wpdb; |
|
| 1353 | + if ($message_type == 'expiration') {
|
|
| 1354 | + $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
|
|
| 1355 | + $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
|
|
| 1356 | + } elseif ($message_type == 'post_submited') {
|
|
| 1357 | + $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
|
|
| 1358 | + $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
|
|
| 1359 | + } elseif ($message_type == 'renew') {
|
|
| 1360 | + $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
|
|
| 1361 | + $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
|
|
| 1362 | + } elseif ($message_type == 'upgrade') {
|
|
| 1363 | + $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
|
|
| 1364 | + $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
|
|
| 1365 | + } elseif ($message_type == 'claim_approved') {
|
|
| 1366 | + $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
|
|
| 1367 | + $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
|
|
| 1368 | + } elseif ($message_type == 'claim_rejected') {
|
|
| 1369 | + $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
|
|
| 1370 | + $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
|
|
| 1371 | + } elseif ($message_type == 'claim_requested') {
|
|
| 1372 | + $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
|
|
| 1373 | + $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
|
|
| 1374 | + } elseif ($message_type == 'auto_claim') {
|
|
| 1375 | + $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
|
|
| 1376 | + $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
|
|
| 1377 | + } elseif ($message_type == 'payment_success') {
|
|
| 1378 | + $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
|
|
| 1379 | + $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
|
|
| 1380 | + } elseif ($message_type == 'payment_fail') {
|
|
| 1381 | + $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
|
|
| 1382 | + $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
|
|
| 1383 | + } |
|
| 1384 | + $transaction_details = $custom_1; |
|
| 1385 | + $fromEmail = get_option('site_email');
|
|
| 1386 | + $fromEmailName = get_site_emailName(); |
|
| 1387 | 1387 | //$alivedays = get_post_meta($page_id,'alive_days',true); |
| 1388 | - $pkg_limit = get_property_price_info_listing($page_id); |
|
| 1389 | - $alivedays = $pkg_limit['days']; |
|
| 1390 | - $productlink = get_permalink($page_id); |
|
| 1391 | - $post_info = get_post($page_id); |
|
| 1392 | - $post_date = date('dS F,Y', strtotime($post_info->post_date));
|
|
| 1393 | - $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 1394 | - $loginurl = geodir_login_url(); |
|
| 1395 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 1396 | - $siteurl = home_url(); |
|
| 1397 | - $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>'; |
|
| 1398 | - $user_info = get_userdata($user_id); |
|
| 1399 | - $user_email = $user_info->user_email; |
|
| 1400 | - $display_name = geodir_get_client_name($user_id); |
|
| 1401 | - $user_login = $user_info->user_login; |
|
| 1402 | - $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
|
|
| 1403 | - if ($number_of_grace_days == '') {
|
|
| 1404 | - $number_of_grace_days = 1; |
|
| 1405 | - } |
|
| 1406 | - if ($post_info->post_type == 'event') {
|
|
| 1407 | - $post_type = 'event'; |
|
| 1408 | - } else {
|
|
| 1409 | - $post_type = 'listing'; |
|
| 1410 | - } |
|
| 1411 | - $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>'; |
|
| 1412 | - $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#]');
|
|
| 1413 | - $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); |
|
| 1414 | - $client_message = str_replace($search_array, $replace_array, $client_message); |
|
| 1415 | - $subject = str_replace($search_array, $replace_array, $subject); |
|
| 1416 | - $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 1417 | - $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 1418 | - $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n"; |
|
| 1419 | - |
|
| 1420 | - $to = $fromEmail; |
|
| 1421 | - $message = $client_message; |
|
| 1422 | - $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1423 | - if( ! $sent ) {
|
|
| 1424 | - if ( is_array( $to ) ) {
|
|
| 1425 | - $to = implode( ',', $to ); |
|
| 1426 | - } |
|
| 1427 | - $log_message = sprintf( |
|
| 1428 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1429 | - $message_type, |
|
| 1430 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1431 | - $to, |
|
| 1432 | - $subject |
|
| 1433 | - ); |
|
| 1434 | - geodir_error_log( $log_message ); |
|
| 1435 | - } |
|
| 1436 | - } |
|
| 1388 | + $pkg_limit = get_property_price_info_listing($page_id); |
|
| 1389 | + $alivedays = $pkg_limit['days']; |
|
| 1390 | + $productlink = get_permalink($page_id); |
|
| 1391 | + $post_info = get_post($page_id); |
|
| 1392 | + $post_date = date('dS F,Y', strtotime($post_info->post_date));
|
|
| 1393 | + $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 1394 | + $loginurl = geodir_login_url(); |
|
| 1395 | + $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 1396 | + $siteurl = home_url(); |
|
| 1397 | + $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>'; |
|
| 1398 | + $user_info = get_userdata($user_id); |
|
| 1399 | + $user_email = $user_info->user_email; |
|
| 1400 | + $display_name = geodir_get_client_name($user_id); |
|
| 1401 | + $user_login = $user_info->user_login; |
|
| 1402 | + $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days');
|
|
| 1403 | + if ($number_of_grace_days == '') {
|
|
| 1404 | + $number_of_grace_days = 1; |
|
| 1405 | + } |
|
| 1406 | + if ($post_info->post_type == 'event') {
|
|
| 1407 | + $post_type = 'event'; |
|
| 1408 | + } else {
|
|
| 1409 | + $post_type = 'listing'; |
|
| 1410 | + } |
|
| 1411 | + $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>'; |
|
| 1412 | + $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#]');
|
|
| 1413 | + $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); |
|
| 1414 | + $client_message = str_replace($search_array, $replace_array, $client_message); |
|
| 1415 | + $subject = str_replace($search_array, $replace_array, $subject); |
|
| 1416 | + $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 1417 | + $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 1418 | + $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n"; |
|
| 1419 | + |
|
| 1420 | + $to = $fromEmail; |
|
| 1421 | + $message = $client_message; |
|
| 1422 | + $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1423 | + if( ! $sent ) {
|
|
| 1424 | + if ( is_array( $to ) ) {
|
|
| 1425 | + $to = implode( ',', $to ); |
|
| 1426 | + } |
|
| 1427 | + $log_message = sprintf( |
|
| 1428 | + __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1429 | + $message_type, |
|
| 1430 | + date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1431 | + $to, |
|
| 1432 | + $subject |
|
| 1433 | + ); |
|
| 1434 | + geodir_error_log( $log_message ); |
|
| 1435 | + } |
|
| 1436 | + } |
|
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | 1439 | if (!function_exists('sendEmail')) {
|
| 1440 | - /** |
|
| 1441 | - * @todo could be a duplicate of geodir_sendEmail. |
|
| 1442 | - * |
|
| 1443 | - * @since 1.0.0 |
|
| 1444 | - * @package GeoDirectory |
|
| 1445 | - * @param string $fromEmail Sender email address. |
|
| 1446 | - * @param string $fromEmailName Sender name. |
|
| 1447 | - * @param string $toEmail Receiver email address. |
|
| 1448 | - * @param string $toEmailName Receiver name. |
|
| 1449 | - * @param string $to_subject Email subject. |
|
| 1450 | - * @param string $to_message Email content. |
|
| 1451 | - * @param string $extra Not being used. |
|
| 1452 | - * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration. |
|
| 1453 | - * @param string $post_id The post ID. |
|
| 1454 | - * @param string $user_id The user ID. |
|
| 1455 | - */ |
|
| 1456 | - function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') |
|
| 1457 | - {
|
|
| 1458 | - $login_details = ''; |
|
| 1459 | - if ($message_type == 'send_friend') {
|
|
| 1460 | - $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
|
|
| 1461 | - $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
|
|
| 1462 | - } elseif ($message_type == 'send_enquiry') {
|
|
| 1463 | - $subject = __(get_option('email_enquiry_subject'),'geodirectory');
|
|
| 1464 | - $message = __(get_option('email_enquiry_content'),'geodirectory');
|
|
| 1465 | - } elseif ($message_type == 'forgot_password') {
|
|
| 1466 | - $subject = __(get_option('forgot_password_subject'),'geodirectory');
|
|
| 1467 | - $message = __(get_option('forgot_password_content'),'geodirectory');
|
|
| 1468 | - $login_details = $to_message; |
|
| 1469 | - } elseif ($message_type == 'registration') {
|
|
| 1470 | - $subject = __(get_option('registration_success_email_subject'),'geodirectory');
|
|
| 1471 | - $message = __(get_option('registration_success_email_content'),'geodirectory');
|
|
| 1472 | - $login_details = $to_message; |
|
| 1473 | - } |
|
| 1474 | - $to_message = nl2br($to_message); |
|
| 1475 | - $sitefromEmail = get_option('site_email');
|
|
| 1476 | - $sitefromEmailName = get_site_emailName(); |
|
| 1477 | - $productlink = get_permalink($post_id); |
|
| 1478 | - $post_info = get_post($post_id); |
|
| 1479 | - $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 1480 | - $siteurl = home_url(); |
|
| 1481 | - $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; |
|
| 1482 | - $loginurl = geodir_login_url(); |
|
| 1483 | - $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 1484 | - if ($fromEmail == '') {
|
|
| 1485 | - $fromEmail = get_option('site_email');
|
|
| 1486 | - } |
|
| 1487 | - if ($fromEmailName == '') {
|
|
| 1488 | - $fromEmailName = get_option('site_email_name');
|
|
| 1489 | - } |
|
| 1490 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
|
|
| 1491 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName); |
|
| 1492 | - $message = str_replace($search_array, $replace_array, $message); |
|
| 1493 | - |
|
| 1494 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
|
|
| 1495 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName); |
|
| 1496 | - $subject = str_replace($search_array, $replace_array, $subject); |
|
| 1497 | - $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 1498 | - $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 1499 | - $headers .= "Reply-To: " . $fromEmail . "\r\n"; |
|
| 1500 | - $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n"; |
|
| 1501 | - |
|
| 1502 | - $to = $toEmail; |
|
| 1503 | - |
|
| 1504 | - $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1505 | - if( ! $sent ) {
|
|
| 1506 | - if ( is_array( $to ) ) {
|
|
| 1507 | - $to = implode( ',', $to ); |
|
| 1508 | - } |
|
| 1509 | - $log_message = sprintf( |
|
| 1510 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1511 | - $message_type, |
|
| 1512 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1513 | - $to, |
|
| 1514 | - $subject |
|
| 1515 | - ); |
|
| 1516 | - geodir_error_log( $log_message ); |
|
| 1517 | - } |
|
| 1440 | + /** |
|
| 1441 | + * @todo could be a duplicate of geodir_sendEmail. |
|
| 1442 | + * |
|
| 1443 | + * @since 1.0.0 |
|
| 1444 | + * @package GeoDirectory |
|
| 1445 | + * @param string $fromEmail Sender email address. |
|
| 1446 | + * @param string $fromEmailName Sender name. |
|
| 1447 | + * @param string $toEmail Receiver email address. |
|
| 1448 | + * @param string $toEmailName Receiver name. |
|
| 1449 | + * @param string $to_subject Email subject. |
|
| 1450 | + * @param string $to_message Email content. |
|
| 1451 | + * @param string $extra Not being used. |
|
| 1452 | + * @param string $message_type The message type. Can be send_friend, send_enquiry, forgot_password, registration. |
|
| 1453 | + * @param string $post_id The post ID. |
|
| 1454 | + * @param string $user_id The user ID. |
|
| 1455 | + */ |
|
| 1456 | + function sendEmail($fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra = '', $message_type, $post_id = '', $user_id = '') |
|
| 1457 | + {
|
|
| 1458 | + $login_details = ''; |
|
| 1459 | + if ($message_type == 'send_friend') {
|
|
| 1460 | + $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
|
|
| 1461 | + $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
|
|
| 1462 | + } elseif ($message_type == 'send_enquiry') {
|
|
| 1463 | + $subject = __(get_option('email_enquiry_subject'),'geodirectory');
|
|
| 1464 | + $message = __(get_option('email_enquiry_content'),'geodirectory');
|
|
| 1465 | + } elseif ($message_type == 'forgot_password') {
|
|
| 1466 | + $subject = __(get_option('forgot_password_subject'),'geodirectory');
|
|
| 1467 | + $message = __(get_option('forgot_password_content'),'geodirectory');
|
|
| 1468 | + $login_details = $to_message; |
|
| 1469 | + } elseif ($message_type == 'registration') {
|
|
| 1470 | + $subject = __(get_option('registration_success_email_subject'),'geodirectory');
|
|
| 1471 | + $message = __(get_option('registration_success_email_content'),'geodirectory');
|
|
| 1472 | + $login_details = $to_message; |
|
| 1473 | + } |
|
| 1474 | + $to_message = nl2br($to_message); |
|
| 1475 | + $sitefromEmail = get_option('site_email');
|
|
| 1476 | + $sitefromEmailName = get_site_emailName(); |
|
| 1477 | + $productlink = get_permalink($post_id); |
|
| 1478 | + $post_info = get_post($post_id); |
|
| 1479 | + $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; |
|
| 1480 | + $siteurl = home_url(); |
|
| 1481 | + $siteurl_link = '<a href="' . $siteurl . '">' . $siteurl . '</a>'; |
|
| 1482 | + $loginurl = geodir_login_url(); |
|
| 1483 | + $loginurl_link = '<a href="' . $loginurl . '">login</a>'; |
|
| 1484 | + if ($fromEmail == '') {
|
|
| 1485 | + $fromEmail = get_option('site_email');
|
|
| 1486 | + } |
|
| 1487 | + if ($fromEmailName == '') {
|
|
| 1488 | + $fromEmailName = get_option('site_email_name');
|
|
| 1489 | + } |
|
| 1490 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]');
|
|
| 1491 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName); |
|
| 1492 | + $message = str_replace($search_array, $replace_array, $message); |
|
| 1493 | + |
|
| 1494 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]');
|
|
| 1495 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName); |
|
| 1496 | + $subject = str_replace($search_array, $replace_array, $subject); |
|
| 1497 | + $headers = 'MIME-Version: 1.0' . "\r\n"; |
|
| 1498 | + $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; |
|
| 1499 | + $headers .= "Reply-To: " . $fromEmail . "\r\n"; |
|
| 1500 | + $headers .= 'From: ' . $sitefromEmailName . ' <' . $sitefromEmail . '>' . "\r\n"; |
|
| 1501 | + |
|
| 1502 | + $to = $toEmail; |
|
| 1503 | + |
|
| 1504 | + $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1505 | + if( ! $sent ) {
|
|
| 1506 | + if ( is_array( $to ) ) {
|
|
| 1507 | + $to = implode( ',', $to ); |
|
| 1508 | + } |
|
| 1509 | + $log_message = sprintf( |
|
| 1510 | + __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1511 | + $message_type, |
|
| 1512 | + date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1513 | + $to, |
|
| 1514 | + $subject |
|
| 1515 | + ); |
|
| 1516 | + geodir_error_log( $log_message ); |
|
| 1517 | + } |
|
| 1518 | 1518 | |
| 1519 | - ///////// ADMIN BCC EMIALS |
|
| 1520 | - $admin_bcc = false; |
|
| 1521 | - if ($message_type == 'registration') {
|
|
| 1522 | - $message_raw = explode(__("Password:", 'geodirectory'), $message);
|
|
| 1523 | - $message_raw2 = explode("</p>", $message_raw[1], 2);
|
|
| 1524 | - $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
|
|
| 1525 | - } |
|
| 1526 | - $adminEmail = get_bloginfo('admin_email');
|
|
| 1527 | - $to = $adminEmail; |
|
| 1519 | + ///////// ADMIN BCC EMIALS |
|
| 1520 | + $admin_bcc = false; |
|
| 1521 | + if ($message_type == 'registration') {
|
|
| 1522 | + $message_raw = explode(__("Password:", 'geodirectory'), $message);
|
|
| 1523 | + $message_raw2 = explode("</p>", $message_raw[1], 2);
|
|
| 1524 | + $message = $message_raw[0] . __('Password:', 'geodirectory') . ' **********</p>' . $message_raw2[1];
|
|
| 1525 | + } |
|
| 1526 | + $adminEmail = get_bloginfo('admin_email');
|
|
| 1527 | + $to = $adminEmail; |
|
| 1528 | 1528 | |
| 1529 | - if ($message_type == 'registration' && get_option('bcc_new_user')) {
|
|
| 1530 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 1531 | - $admin_bcc = true; |
|
| 1532 | - } |
|
| 1533 | - elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
|
|
| 1534 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 1535 | - $admin_bcc = true; |
|
| 1536 | - } |
|
| 1537 | - elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
|
|
| 1538 | - $subject .= ' - ADMIN BCC COPY'; |
|
| 1539 | - $admin_bcc = true; |
|
| 1540 | - } |
|
| 1529 | + if ($message_type == 'registration' && get_option('bcc_new_user')) {
|
|
| 1530 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 1531 | + $admin_bcc = true; |
|
| 1532 | + } |
|
| 1533 | + elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
|
|
| 1534 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 1535 | + $admin_bcc = true; |
|
| 1536 | + } |
|
| 1537 | + elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
|
|
| 1538 | + $subject .= ' - ADMIN BCC COPY'; |
|
| 1539 | + $admin_bcc = true; |
|
| 1540 | + } |
|
| 1541 | 1541 | |
| 1542 | - if($admin_bcc === true){
|
|
| 1543 | - $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1544 | - if( ! $sent ) {
|
|
| 1545 | - if ( is_array( $to ) ) {
|
|
| 1546 | - $to = implode( ',', $to ); |
|
| 1547 | - } |
|
| 1548 | - $log_message = sprintf( |
|
| 1549 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1550 | - $message_type, |
|
| 1551 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1552 | - $to, |
|
| 1553 | - $subject |
|
| 1554 | - ); |
|
| 1555 | - geodir_error_log( $log_message ); |
|
| 1556 | - } |
|
| 1557 | - } |
|
| 1542 | + if($admin_bcc === true){
|
|
| 1543 | + $sent = wp_mail($to, $subject, $message, $headers); |
|
| 1544 | + if( ! $sent ) {
|
|
| 1545 | + if ( is_array( $to ) ) {
|
|
| 1546 | + $to = implode( ',', $to ); |
|
| 1547 | + } |
|
| 1548 | + $log_message = sprintf( |
|
| 1549 | + __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1550 | + $message_type, |
|
| 1551 | + date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1552 | + $to, |
|
| 1553 | + $subject |
|
| 1554 | + ); |
|
| 1555 | + geodir_error_log( $log_message ); |
|
| 1556 | + } |
|
| 1557 | + } |
|
| 1558 | 1558 | |
| 1559 | - } |
|
| 1559 | + } |
|
| 1560 | 1560 | } |
| 1561 | 1561 | |
| 1562 | 1562 | /* |
@@ -1574,16 +1574,16 @@ discard block |
||
| 1574 | 1574 | */ |
| 1575 | 1575 | function gd_lang_object_ids($ids_array, $type) |
| 1576 | 1576 | {
|
| 1577 | - if (function_exists('icl_object_id')) {
|
|
| 1578 | - $res = array(); |
|
| 1579 | - foreach ($ids_array as $id) {
|
|
| 1580 | - $xlat = icl_object_id($id, $type, false); |
|
| 1581 | - if (!is_null($xlat)) $res[] = $xlat; |
|
| 1582 | - } |
|
| 1583 | - return $res; |
|
| 1584 | - } else {
|
|
| 1585 | - return $ids_array; |
|
| 1586 | - } |
|
| 1577 | + if (function_exists('icl_object_id')) {
|
|
| 1578 | + $res = array(); |
|
| 1579 | + foreach ($ids_array as $id) {
|
|
| 1580 | + $xlat = icl_object_id($id, $type, false); |
|
| 1581 | + if (!is_null($xlat)) $res[] = $xlat; |
|
| 1582 | + } |
|
| 1583 | + return $res; |
|
| 1584 | + } else {
|
|
| 1585 | + return $ids_array; |
|
| 1586 | + } |
|
| 1587 | 1587 | } |
| 1588 | 1588 | |
| 1589 | 1589 | |
@@ -1598,31 +1598,31 @@ discard block |
||
| 1598 | 1598 | * @return array Modified Body CSS classes. |
| 1599 | 1599 | */ |
| 1600 | 1600 | function geodir_custom_posts_body_class($classes) {
|
| 1601 | - global $wpdb, $wp; |
|
| 1602 | - $post_types = geodir_get_posttypes('object');
|
|
| 1603 | - if (!empty($post_types) && count((array)$post_types) > 1) {
|
|
| 1604 | - $classes[] = 'geodir_custom_posts'; |
|
| 1605 | - } |
|
| 1606 | - |
|
| 1607 | - // fix body class for signup page |
|
| 1608 | - if (geodir_is_page('login')) {
|
|
| 1609 | - $new_classes = array(); |
|
| 1610 | - $new_classes[] = 'signup page-geodir-signup'; |
|
| 1611 | - if (!empty($classes)) {
|
|
| 1612 | - foreach ($classes as $class) {
|
|
| 1613 | - if ($class && $class != 'home' && $class != 'blog') {
|
|
| 1614 | - $new_classes[] = $class; |
|
| 1615 | - } |
|
| 1616 | - } |
|
| 1617 | - } |
|
| 1618 | - $classes = $new_classes; |
|
| 1619 | - } |
|
| 1601 | + global $wpdb, $wp; |
|
| 1602 | + $post_types = geodir_get_posttypes('object');
|
|
| 1603 | + if (!empty($post_types) && count((array)$post_types) > 1) {
|
|
| 1604 | + $classes[] = 'geodir_custom_posts'; |
|
| 1605 | + } |
|
| 1620 | 1606 | |
| 1621 | - if (geodir_is_geodir_page()) {
|
|
| 1622 | - $classes[] = 'geodir-page'; |
|
| 1623 | - } |
|
| 1607 | + // fix body class for signup page |
|
| 1608 | + if (geodir_is_page('login')) {
|
|
| 1609 | + $new_classes = array(); |
|
| 1610 | + $new_classes[] = 'signup page-geodir-signup'; |
|
| 1611 | + if (!empty($classes)) {
|
|
| 1612 | + foreach ($classes as $class) {
|
|
| 1613 | + if ($class && $class != 'home' && $class != 'blog') {
|
|
| 1614 | + $new_classes[] = $class; |
|
| 1615 | + } |
|
| 1616 | + } |
|
| 1617 | + } |
|
| 1618 | + $classes = $new_classes; |
|
| 1619 | + } |
|
| 1624 | 1620 | |
| 1625 | - return $classes; |
|
| 1621 | + if (geodir_is_geodir_page()) {
|
|
| 1622 | + $classes[] = 'geodir-page'; |
|
| 1623 | + } |
|
| 1624 | + |
|
| 1625 | + return $classes; |
|
| 1626 | 1626 | } |
| 1627 | 1627 | |
| 1628 | 1628 | 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
|
@@ -1637,12 +1637,12 @@ discard block |
||
| 1637 | 1637 | */ |
| 1638 | 1638 | function geodir_map_zoom_level() |
| 1639 | 1639 | {
|
| 1640 | - /** |
|
| 1641 | - * Filter GD map zoom level. |
|
| 1642 | - * |
|
| 1643 | - * @since 1.0.0 |
|
| 1644 | - */ |
|
| 1645 | - 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));
|
|
| 1640 | + /** |
|
| 1641 | + * Filter GD map zoom level. |
|
| 1642 | + * |
|
| 1643 | + * @since 1.0.0 |
|
| 1644 | + */ |
|
| 1645 | + 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));
|
|
| 1646 | 1646 | |
| 1647 | 1647 | } |
| 1648 | 1648 | |
@@ -1656,12 +1656,12 @@ discard block |
||
| 1656 | 1656 | */ |
| 1657 | 1657 | function geodir_option_version_backup($geodir_option_name) |
| 1658 | 1658 | {
|
| 1659 | - $version_date = time(); |
|
| 1660 | - $geodir_option = get_option($geodir_option_name); |
|
| 1659 | + $version_date = time(); |
|
| 1660 | + $geodir_option = get_option($geodir_option_name); |
|
| 1661 | 1661 | |
| 1662 | - if (!empty($geodir_option)) {
|
|
| 1663 | - add_option($geodir_option_name . '_' . $version_date, $geodir_option); |
|
| 1664 | - } |
|
| 1662 | + if (!empty($geodir_option)) {
|
|
| 1663 | + add_option($geodir_option_name . '_' . $version_date, $geodir_option); |
|
| 1664 | + } |
|
| 1665 | 1665 | } |
| 1666 | 1666 | |
| 1667 | 1667 | /** |
@@ -1674,11 +1674,11 @@ discard block |
||
| 1674 | 1674 | */ |
| 1675 | 1675 | function get_page_id_geodir_add_listing_page($page_id) |
| 1676 | 1676 | {
|
| 1677 | - if (geodir_wpml_multilingual_status()) {
|
|
| 1678 | - $post_type = 'post_page'; |
|
| 1679 | - $page_id = geodir_get_wpml_element_id($page_id, $post_type); |
|
| 1680 | - } |
|
| 1681 | - return $page_id; |
|
| 1677 | + if (geodir_wpml_multilingual_status()) {
|
|
| 1678 | + $post_type = 'post_page'; |
|
| 1679 | + $page_id = geodir_get_wpml_element_id($page_id, $post_type); |
|
| 1680 | + } |
|
| 1681 | + return $page_id; |
|
| 1682 | 1682 | } |
| 1683 | 1683 | |
| 1684 | 1684 | /** |
@@ -1690,10 +1690,10 @@ discard block |
||
| 1690 | 1690 | */ |
| 1691 | 1691 | function geodir_wpml_multilingual_status() |
| 1692 | 1692 | {
|
| 1693 | - if (function_exists('icl_object_id')) {
|
|
| 1694 | - return true; |
|
| 1695 | - } |
|
| 1696 | - return false; |
|
| 1693 | + if (function_exists('icl_object_id')) {
|
|
| 1694 | + return true; |
|
| 1695 | + } |
|
| 1696 | + return false; |
|
| 1697 | 1697 | } |
| 1698 | 1698 | |
| 1699 | 1699 | /** |
@@ -1707,22 +1707,22 @@ discard block |
||
| 1707 | 1707 | */ |
| 1708 | 1708 | function geodir_get_wpml_element_id($page_id, $post_type) |
| 1709 | 1709 | {
|
| 1710 | - global $sitepress; |
|
| 1711 | - if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
|
|
| 1712 | - $trid = $sitepress->get_element_trid($page_id, $post_type); |
|
| 1710 | + global $sitepress; |
|
| 1711 | + if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
|
|
| 1712 | + $trid = $sitepress->get_element_trid($page_id, $post_type); |
|
| 1713 | 1713 | |
| 1714 | - if ($trid > 0) {
|
|
| 1715 | - $translations = $sitepress->get_element_translations($trid, $post_type); |
|
| 1714 | + if ($trid > 0) {
|
|
| 1715 | + $translations = $sitepress->get_element_translations($trid, $post_type); |
|
| 1716 | 1716 | |
| 1717 | - $lang = $sitepress->get_current_language(); |
|
| 1718 | - $lang = $lang ? $lang : $sitepress->get_default_language(); |
|
| 1717 | + $lang = $sitepress->get_current_language(); |
|
| 1718 | + $lang = $lang ? $lang : $sitepress->get_default_language(); |
|
| 1719 | 1719 | |
| 1720 | - if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
|
|
| 1721 | - $page_id = $translations[$lang]->element_id; |
|
| 1722 | - } |
|
| 1723 | - } |
|
| 1724 | - } |
|
| 1725 | - return $page_id; |
|
| 1720 | + if (!empty($translations) && !empty($lang) && isset($translations[$lang]) && isset($translations[$lang]->element_id) && !empty($translations[$lang]->element_id)) {
|
|
| 1721 | + $page_id = $translations[$lang]->element_id; |
|
| 1722 | + } |
|
| 1723 | + } |
|
| 1724 | + } |
|
| 1725 | + return $page_id; |
|
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | 1728 | /** |
@@ -1734,20 +1734,20 @@ discard block |
||
| 1734 | 1734 | */ |
| 1735 | 1735 | function geodir_wpml_check_element_id() |
| 1736 | 1736 | {
|
| 1737 | - global $sitepress; |
|
| 1738 | - if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
|
|
| 1739 | - $el_type = 'post_page'; |
|
| 1740 | - $el_id = get_option('geodir_add_listing_page');
|
|
| 1741 | - $default_lang = $sitepress->get_default_language(); |
|
| 1742 | - $el_details = $sitepress->get_element_language_details($el_id, $el_type); |
|
| 1743 | - |
|
| 1744 | - if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
|
|
| 1745 | - if (!$el_details->source_language_code) {
|
|
| 1746 | - $sitepress->set_element_language_details($el_id, $el_type, '', $default_lang); |
|
| 1747 | - $sitepress->icl_translations_cache->clear(); |
|
| 1748 | - } |
|
| 1749 | - } |
|
| 1750 | - } |
|
| 1737 | + global $sitepress; |
|
| 1738 | + if (geodir_wpml_multilingual_status() && !empty($sitepress) && isset($sitepress->queries)) {
|
|
| 1739 | + $el_type = 'post_page'; |
|
| 1740 | + $el_id = get_option('geodir_add_listing_page');
|
|
| 1741 | + $default_lang = $sitepress->get_default_language(); |
|
| 1742 | + $el_details = $sitepress->get_element_language_details($el_id, $el_type); |
|
| 1743 | + |
|
| 1744 | + if (!($el_id > 0 && $default_lang && !empty($el_details) && isset($el_details->language_code) && $el_details->language_code == $default_lang)) {
|
|
| 1745 | + if (!$el_details->source_language_code) {
|
|
| 1746 | + $sitepress->set_element_language_details($el_id, $el_type, '', $default_lang); |
|
| 1747 | + $sitepress->icl_translations_cache->clear(); |
|
| 1748 | + } |
|
| 1749 | + } |
|
| 1750 | + } |
|
| 1751 | 1751 | } |
| 1752 | 1752 | |
| 1753 | 1753 | /** |
@@ -1762,44 +1762,44 @@ discard block |
||
| 1762 | 1762 | */ |
| 1763 | 1763 | function geodir_widget_listings_get_order($query_args) |
| 1764 | 1764 | {
|
| 1765 | - global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 1766 | - |
|
| 1767 | - $query_args = $gd_query_args_widgets; |
|
| 1768 | - if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 1769 | - return $wpdb->posts . ".post_date DESC, "; |
|
| 1770 | - } |
|
| 1771 | - |
|
| 1772 | - $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 1773 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1774 | - |
|
| 1775 | - $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : ''; |
|
| 1776 | - |
|
| 1777 | - switch ($sort_by) {
|
|
| 1778 | - case 'latest': |
|
| 1779 | - case 'newest': |
|
| 1780 | - $orderby = $wpdb->posts . ".post_date DESC, "; |
|
| 1781 | - break; |
|
| 1782 | - case 'featured': |
|
| 1783 | - $orderby = $table . ".is_featured ASC, "; |
|
| 1784 | - break; |
|
| 1785 | - case 'az': |
|
| 1786 | - $orderby = $wpdb->posts . ".post_title ASC, "; |
|
| 1787 | - break; |
|
| 1788 | - case 'high_review': |
|
| 1789 | - $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, "; |
|
| 1790 | - break; |
|
| 1791 | - case 'high_rating': |
|
| 1792 | - $orderby = "( " . $table . ".overall_rating ) DESC, "; |
|
| 1793 | - break; |
|
| 1794 | - case 'random': |
|
| 1795 | - $orderby = "RAND(), "; |
|
| 1796 | - break; |
|
| 1797 | - default: |
|
| 1798 | - $orderby = $wpdb->posts . ".post_title ASC, "; |
|
| 1799 | - break; |
|
| 1800 | - } |
|
| 1801 | - |
|
| 1802 | - return $orderby; |
|
| 1765 | + global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 1766 | + |
|
| 1767 | + $query_args = $gd_query_args_widgets; |
|
| 1768 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 1769 | + return $wpdb->posts . ".post_date DESC, "; |
|
| 1770 | + } |
|
| 1771 | + |
|
| 1772 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 1773 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1774 | + |
|
| 1775 | + $sort_by = !empty($query_args['order_by']) ? $query_args['order_by'] : ''; |
|
| 1776 | + |
|
| 1777 | + switch ($sort_by) {
|
|
| 1778 | + case 'latest': |
|
| 1779 | + case 'newest': |
|
| 1780 | + $orderby = $wpdb->posts . ".post_date DESC, "; |
|
| 1781 | + break; |
|
| 1782 | + case 'featured': |
|
| 1783 | + $orderby = $table . ".is_featured ASC, "; |
|
| 1784 | + break; |
|
| 1785 | + case 'az': |
|
| 1786 | + $orderby = $wpdb->posts . ".post_title ASC, "; |
|
| 1787 | + break; |
|
| 1788 | + case 'high_review': |
|
| 1789 | + $orderby = $table . ".rating_count DESC, " . $table . ".overall_rating DESC, "; |
|
| 1790 | + break; |
|
| 1791 | + case 'high_rating': |
|
| 1792 | + $orderby = "( " . $table . ".overall_rating ) DESC, "; |
|
| 1793 | + break; |
|
| 1794 | + case 'random': |
|
| 1795 | + $orderby = "RAND(), "; |
|
| 1796 | + break; |
|
| 1797 | + default: |
|
| 1798 | + $orderby = $wpdb->posts . ".post_title ASC, "; |
|
| 1799 | + break; |
|
| 1800 | + } |
|
| 1801 | + |
|
| 1802 | + return $orderby; |
|
| 1803 | 1803 | } |
| 1804 | 1804 | |
| 1805 | 1805 | /** |
@@ -1817,127 +1817,127 @@ discard block |
||
| 1817 | 1817 | */ |
| 1818 | 1818 | function geodir_get_widget_listings($query_args = array(), $count_only = false) |
| 1819 | 1819 | {
|
| 1820 | - global $wpdb, $plugin_prefix, $table_prefix; |
|
| 1821 | - $GLOBALS['gd_query_args_widgets'] = $query_args; |
|
| 1822 | - $gd_query_args_widgets = $query_args; |
|
| 1823 | - |
|
| 1824 | - $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 1825 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1826 | - |
|
| 1827 | - $fields = $wpdb->posts . ".*, " . $table . ".*"; |
|
| 1828 | - /** |
|
| 1829 | - * Filter widget listing fields string part that is being used for query. |
|
| 1830 | - * |
|
| 1831 | - * @since 1.0.0 |
|
| 1832 | - * @param string $fields Fields string. |
|
| 1833 | - * @param string $table Table name. |
|
| 1834 | - * @param string $post_type Post type. |
|
| 1835 | - */ |
|
| 1836 | - $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
|
|
| 1837 | - |
|
| 1838 | - $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
|
|
| 1839 | - |
|
| 1840 | - ########### WPML ########### |
|
| 1841 | - |
|
| 1842 | - if (function_exists('icl_object_id')) {
|
|
| 1843 | - global $sitepress; |
|
| 1844 | - $lang_code = ICL_LANGUAGE_CODE; |
|
| 1845 | - $default_lang_code = $sitepress->get_default_language(); |
|
| 1846 | - if ($lang_code) {
|
|
| 1847 | - $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID"; |
|
| 1848 | - } |
|
| 1849 | - } |
|
| 1850 | - |
|
| 1851 | - ########### WPML ########### |
|
| 1820 | + global $wpdb, $plugin_prefix, $table_prefix; |
|
| 1821 | + $GLOBALS['gd_query_args_widgets'] = $query_args; |
|
| 1822 | + $gd_query_args_widgets = $query_args; |
|
| 1823 | + |
|
| 1824 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 1825 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1826 | + |
|
| 1827 | + $fields = $wpdb->posts . ".*, " . $table . ".*"; |
|
| 1828 | + /** |
|
| 1829 | + * Filter widget listing fields string part that is being used for query. |
|
| 1830 | + * |
|
| 1831 | + * @since 1.0.0 |
|
| 1832 | + * @param string $fields Fields string. |
|
| 1833 | + * @param string $table Table name. |
|
| 1834 | + * @param string $post_type Post type. |
|
| 1835 | + */ |
|
| 1836 | + $fields = apply_filters('geodir_filter_widget_listings_fields', $fields, $table, $post_type);
|
|
| 1837 | + |
|
| 1838 | + $join = "INNER JOIN " . $table . " ON (" . $table . ".post_id = " . $wpdb->posts . ".ID)";
|
|
| 1839 | + |
|
| 1840 | + ########### WPML ########### |
|
| 1841 | + |
|
| 1842 | + if (function_exists('icl_object_id')) {
|
|
| 1843 | + global $sitepress; |
|
| 1844 | + $lang_code = ICL_LANGUAGE_CODE; |
|
| 1845 | + $default_lang_code = $sitepress->get_default_language(); |
|
| 1846 | + if ($lang_code) {
|
|
| 1847 | + $join .= " JOIN " . $table_prefix . "icl_translations icl_t ON icl_t.element_id = " . $table_prefix . "posts.ID"; |
|
| 1848 | + } |
|
| 1849 | + } |
|
| 1852 | 1850 | |
| 1853 | - /** |
|
| 1854 | - * Filter widget listing join clause string part that is being used for query. |
|
| 1855 | - * |
|
| 1856 | - * @since 1.0.0 |
|
| 1857 | - * @param string $join Join clause string. |
|
| 1858 | - * @param string $post_type Post type. |
|
| 1859 | - */ |
|
| 1860 | - $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
|
|
| 1851 | + ########### WPML ########### |
|
| 1861 | 1852 | |
| 1862 | - $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : ''; |
|
| 1853 | + /** |
|
| 1854 | + * Filter widget listing join clause string part that is being used for query. |
|
| 1855 | + * |
|
| 1856 | + * @since 1.0.0 |
|
| 1857 | + * @param string $join Join clause string. |
|
| 1858 | + * @param string $post_type Post type. |
|
| 1859 | + */ |
|
| 1860 | + $join = apply_filters('geodir_filter_widget_listings_join', $join, $post_type);
|
|
| 1863 | 1861 | |
| 1864 | - $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'"; |
|
| 1862 | + $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : ''; |
|
| 1865 | 1863 | |
| 1866 | - ########### WPML ########### |
|
| 1867 | - if (function_exists('icl_object_id')) {
|
|
| 1868 | - if ($lang_code) {
|
|
| 1869 | - $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' "; |
|
| 1870 | - } |
|
| 1871 | - } |
|
| 1872 | - ########### WPML ########### |
|
| 1873 | - /** |
|
| 1874 | - * Filter widget listing where clause string part that is being used for query. |
|
| 1875 | - * |
|
| 1876 | - * @since 1.0.0 |
|
| 1877 | - * @param string $where Where clause string. |
|
| 1878 | - * @param string $post_type Post type. |
|
| 1879 | - */ |
|
| 1880 | - $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
|
|
| 1881 | - $where = $where != '' ? " WHERE 1=1 " . $where : ''; |
|
| 1882 | - |
|
| 1883 | - $groupby = " GROUP BY $wpdb->posts.ID "; |
|
| 1884 | - /** |
|
| 1885 | - * Filter widget listing groupby clause string part that is being used for query. |
|
| 1886 | - * |
|
| 1887 | - * @since 1.0.0 |
|
| 1888 | - * @param string $groupby Group by clause string. |
|
| 1889 | - * @param string $post_type Post type. |
|
| 1890 | - */ |
|
| 1891 | - $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
|
|
| 1864 | + $where = " AND ( " . $wpdb->posts . ".post_status = 'publish' " . $post_status . " ) AND " . $wpdb->posts . ".post_type = '" . $post_type . "'"; |
|
| 1892 | 1865 | |
| 1893 | - if ($count_only) {
|
|
| 1894 | - $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
|
|
| 1866 | + ########### WPML ########### |
|
| 1867 | + if (function_exists('icl_object_id')) {
|
|
| 1868 | + if ($lang_code) {
|
|
| 1869 | + $where .= " AND icl_t.language_code = '$lang_code' AND icl_t.element_type = 'post_$post_type' "; |
|
| 1870 | + } |
|
| 1871 | + } |
|
| 1872 | + ########### WPML ########### |
|
| 1873 | + /** |
|
| 1874 | + * Filter widget listing where clause string part that is being used for query. |
|
| 1875 | + * |
|
| 1876 | + * @since 1.0.0 |
|
| 1877 | + * @param string $where Where clause string. |
|
| 1878 | + * @param string $post_type Post type. |
|
| 1879 | + */ |
|
| 1880 | + $where = apply_filters('geodir_filter_widget_listings_where', $where, $post_type);
|
|
| 1881 | + $where = $where != '' ? " WHERE 1=1 " . $where : ''; |
|
| 1882 | + |
|
| 1883 | + $groupby = " GROUP BY $wpdb->posts.ID "; |
|
| 1884 | + /** |
|
| 1885 | + * Filter widget listing groupby clause string part that is being used for query. |
|
| 1886 | + * |
|
| 1887 | + * @since 1.0.0 |
|
| 1888 | + * @param string $groupby Group by clause string. |
|
| 1889 | + * @param string $post_type Post type. |
|
| 1890 | + */ |
|
| 1891 | + $groupby = apply_filters('geodir_filter_widget_listings_groupby', $groupby, $post_type);
|
|
| 1892 | + |
|
| 1893 | + if ($count_only) {
|
|
| 1894 | + $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
|
|
| 1895 | 1895 | " . $join . " |
| 1896 | 1896 | " . $where; |
| 1897 | - $rows = (int)$wpdb->get_var($sql); |
|
| 1898 | - } else {
|
|
| 1899 | - $orderby = geodir_widget_listings_get_order($query_args); |
|
| 1900 | - /** |
|
| 1901 | - * Filter widget listing orderby clause string part that is being used for query. |
|
| 1902 | - * |
|
| 1903 | - * @since 1.0.0 |
|
| 1904 | - * @param string $orderby Order by clause string. |
|
| 1905 | - * @param string $table Table name. |
|
| 1906 | - * @param string $post_type Post type. |
|
| 1907 | - */ |
|
| 1908 | - $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
|
|
| 1909 | - $orderby .= $wpdb->posts . ".post_title ASC"; |
|
| 1910 | - $orderby = $orderby != '' ? " ORDER BY " . $orderby : ''; |
|
| 1911 | - |
|
| 1912 | - $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5; |
|
| 1913 | - /** |
|
| 1914 | - * Filter widget listing limit that is being used for query. |
|
| 1915 | - * |
|
| 1916 | - * @since 1.0.0 |
|
| 1917 | - * @param int $limit Query results limit. |
|
| 1918 | - * @param string $post_type Post type. |
|
| 1919 | - */ |
|
| 1920 | - $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
|
|
| 1921 | - |
|
| 1922 | - $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1; |
|
| 1923 | - if ( !$page ) |
|
| 1924 | - $page = 1; |
|
| 1925 | - |
|
| 1926 | - $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : ""; |
|
| 1927 | - |
|
| 1928 | - $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . " |
|
| 1897 | + $rows = (int)$wpdb->get_var($sql); |
|
| 1898 | + } else {
|
|
| 1899 | + $orderby = geodir_widget_listings_get_order($query_args); |
|
| 1900 | + /** |
|
| 1901 | + * Filter widget listing orderby clause string part that is being used for query. |
|
| 1902 | + * |
|
| 1903 | + * @since 1.0.0 |
|
| 1904 | + * @param string $orderby Order by clause string. |
|
| 1905 | + * @param string $table Table name. |
|
| 1906 | + * @param string $post_type Post type. |
|
| 1907 | + */ |
|
| 1908 | + $orderby = apply_filters('geodir_filter_widget_listings_orderby', $orderby, $table, $post_type);
|
|
| 1909 | + $orderby .= $wpdb->posts . ".post_title ASC"; |
|
| 1910 | + $orderby = $orderby != '' ? " ORDER BY " . $orderby : ''; |
|
| 1911 | + |
|
| 1912 | + $limit = !empty($query_args['posts_per_page']) ? $query_args['posts_per_page'] : 5; |
|
| 1913 | + /** |
|
| 1914 | + * Filter widget listing limit that is being used for query. |
|
| 1915 | + * |
|
| 1916 | + * @since 1.0.0 |
|
| 1917 | + * @param int $limit Query results limit. |
|
| 1918 | + * @param string $post_type Post type. |
|
| 1919 | + */ |
|
| 1920 | + $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
|
|
| 1921 | + |
|
| 1922 | + $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1; |
|
| 1923 | + if ( !$page ) |
|
| 1924 | + $page = 1; |
|
| 1925 | + |
|
| 1926 | + $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : ""; |
|
| 1927 | + |
|
| 1928 | + $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . " |
|
| 1929 | 1929 | " . $join . " |
| 1930 | 1930 | " . $where . " |
| 1931 | 1931 | " . $groupby . " |
| 1932 | 1932 | " . $orderby . " |
| 1933 | 1933 | " . $limit; |
| 1934 | - $rows = $wpdb->get_results($sql); |
|
| 1935 | - } |
|
| 1934 | + $rows = $wpdb->get_results($sql); |
|
| 1935 | + } |
|
| 1936 | 1936 | |
| 1937 | - unset($GLOBALS['gd_query_args_widgets']); |
|
| 1938 | - unset($gd_query_args_widgets); |
|
| 1937 | + unset($GLOBALS['gd_query_args_widgets']); |
|
| 1938 | + unset($gd_query_args_widgets); |
|
| 1939 | 1939 | |
| 1940 | - return $rows; |
|
| 1940 | + return $rows; |
|
| 1941 | 1941 | } |
| 1942 | 1942 | |
| 1943 | 1943 | /** |
@@ -1952,21 +1952,21 @@ discard block |
||
| 1952 | 1952 | */ |
| 1953 | 1953 | function geodir_function_widget_listings_fields($fields) |
| 1954 | 1954 | {
|
| 1955 | - global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 1955 | + global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 1956 | 1956 | |
| 1957 | - $query_args = $gd_query_args_widgets; |
|
| 1958 | - if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 1959 | - return $fields; |
|
| 1960 | - } |
|
| 1961 | - $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 1962 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1957 | + $query_args = $gd_query_args_widgets; |
|
| 1958 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 1959 | + return $fields; |
|
| 1960 | + } |
|
| 1961 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 1962 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1963 | 1963 | |
| 1964 | - /* |
|
| 1964 | + /* |
|
| 1965 | 1965 | if ( $post_type == 'gd_event' && defined( 'EVENT_SCHEDULE' ) ) {
|
| 1966 | 1966 | $fields .= $fields != '' ? ", " . EVENT_SCHEDULE . ".*" : EVENT_SCHEDULE . ".*"; |
| 1967 | 1967 | } |
| 1968 | 1968 | */ |
| 1969 | - return $fields; |
|
| 1969 | + return $fields; |
|
| 1970 | 1970 | } |
| 1971 | 1971 | |
| 1972 | 1972 | /** |
@@ -1981,34 +1981,34 @@ discard block |
||
| 1981 | 1981 | */ |
| 1982 | 1982 | function geodir_function_widget_listings_join($join) |
| 1983 | 1983 | {
|
| 1984 | - global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 1984 | + global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 1985 | 1985 | |
| 1986 | - $query_args = $gd_query_args_widgets; |
|
| 1987 | - if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 1988 | - return $where; |
|
| 1989 | - } |
|
| 1986 | + $query_args = $gd_query_args_widgets; |
|
| 1987 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 1988 | + return $where; |
|
| 1989 | + } |
|
| 1990 | 1990 | |
| 1991 | - $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 1992 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1991 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 1992 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1993 | 1993 | |
| 1994 | - if (!empty($query_args['with_pics_only'])) {
|
|
| 1995 | - $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )"; |
|
| 1996 | - } |
|
| 1994 | + if (!empty($query_args['with_pics_only'])) {
|
|
| 1995 | + $join .= " LEFT JOIN " . GEODIR_ATTACHMENT_TABLE . " ON ( " . GEODIR_ATTACHMENT_TABLE . ".post_id=" . $table . ".post_id AND " . GEODIR_ATTACHMENT_TABLE . ".mime_type LIKE '%image%' )"; |
|
| 1996 | + } |
|
| 1997 | 1997 | |
| 1998 | - /* |
|
| 1998 | + /* |
|
| 1999 | 1999 | if ( $post_type == 'gd_event' && defined( 'EVENT_SCHEDULE' ) ) {
|
| 2000 | 2000 | $join .= " INNER JOIN " . EVENT_SCHEDULE ." ON (" . EVENT_SCHEDULE .".event_id = " . $wpdb->posts . ".ID)";
|
| 2001 | 2001 | } |
| 2002 | 2002 | */ |
| 2003 | 2003 | |
| 2004 | - if (!empty($query_args['tax_query'])) {
|
|
| 2005 | - $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID'); |
|
| 2006 | - if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
|
|
| 2007 | - $join .= $tax_queries['join']; |
|
| 2008 | - } |
|
| 2009 | - } |
|
| 2004 | + if (!empty($query_args['tax_query'])) {
|
|
| 2005 | + $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID'); |
|
| 2006 | + if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
|
|
| 2007 | + $join .= $tax_queries['join']; |
|
| 2008 | + } |
|
| 2009 | + } |
|
| 2010 | 2010 | |
| 2011 | - return $join; |
|
| 2011 | + return $join; |
|
| 2012 | 2012 | } |
| 2013 | 2013 | |
| 2014 | 2014 | /** |
@@ -2023,54 +2023,54 @@ discard block |
||
| 2023 | 2023 | */ |
| 2024 | 2024 | function geodir_function_widget_listings_where($where) |
| 2025 | 2025 | {
|
| 2026 | - global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2027 | - |
|
| 2028 | - $query_args = $gd_query_args_widgets; |
|
| 2029 | - if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2030 | - return $where; |
|
| 2031 | - } |
|
| 2032 | - $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 2033 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2034 | - |
|
| 2035 | - if (!empty($query_args)) {
|
|
| 2036 | - if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
|
|
| 2037 | - $where = geodir_default_location_where($where, $table); |
|
| 2038 | - } |
|
| 2026 | + global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2039 | 2027 | |
| 2040 | - if (!empty($query_args['post_author'])) {
|
|
| 2041 | - $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author']; |
|
| 2042 | - } |
|
| 2043 | - |
|
| 2044 | - if (!empty($query_args['show_featured_only'])) {
|
|
| 2045 | - $where .= " AND " . $table . ".is_featured = '1'"; |
|
| 2046 | - } |
|
| 2028 | + $query_args = $gd_query_args_widgets; |
|
| 2029 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2030 | + return $where; |
|
| 2031 | + } |
|
| 2032 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 2033 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2047 | 2034 | |
| 2048 | - if (!empty($query_args['show_special_only'])) {
|
|
| 2049 | - $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )"; |
|
| 2050 | - } |
|
| 2035 | + if (!empty($query_args)) {
|
|
| 2036 | + if (!empty($query_args['gd_location']) && function_exists('geodir_default_location_where')) {
|
|
| 2037 | + $where = geodir_default_location_where($where, $table); |
|
| 2038 | + } |
|
| 2051 | 2039 | |
| 2052 | - if (!empty($query_args['with_pics_only'])) {
|
|
| 2053 | - $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL "; |
|
| 2054 | - } |
|
| 2040 | + if (!empty($query_args['post_author'])) {
|
|
| 2041 | + $where .= " AND " . $wpdb->posts . ".post_author = " . (int)$query_args['post_author']; |
|
| 2042 | + } |
|
| 2043 | + |
|
| 2044 | + if (!empty($query_args['show_featured_only'])) {
|
|
| 2045 | + $where .= " AND " . $table . ".is_featured = '1'"; |
|
| 2046 | + } |
|
| 2055 | 2047 | |
| 2056 | - if (!empty($query_args['featured_image_only'])) {
|
|
| 2057 | - $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' "; |
|
| 2058 | - } |
|
| 2048 | + if (!empty($query_args['show_special_only'])) {
|
|
| 2049 | + $where .= " AND ( " . $table . ".geodir_special_offers != '' AND " . $table . ".geodir_special_offers IS NOT NULL )"; |
|
| 2050 | + } |
|
| 2059 | 2051 | |
| 2060 | - if (!empty($query_args['with_videos_only'])) {
|
|
| 2061 | - $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )"; |
|
| 2062 | - } |
|
| 2052 | + if (!empty($query_args['with_pics_only'])) {
|
|
| 2053 | + $where .= " AND " . GEODIR_ATTACHMENT_TABLE . ".ID IS NOT NULL "; |
|
| 2054 | + } |
|
| 2063 | 2055 | |
| 2064 | - if (!empty($query_args['tax_query'])) {
|
|
| 2065 | - $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID'); |
|
| 2056 | + if (!empty($query_args['featured_image_only'])) {
|
|
| 2057 | + $where .= " AND " . $table . ".featured_image IS NOT NULL AND " . $table . ".featured_image!='' "; |
|
| 2058 | + } |
|
| 2066 | 2059 | |
| 2067 | - if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
|
|
| 2068 | - $where .= $tax_queries['where']; |
|
| 2069 | - } |
|
| 2070 | - } |
|
| 2071 | - } |
|
| 2060 | + if (!empty($query_args['with_videos_only'])) {
|
|
| 2061 | + $where .= " AND ( " . $table . ".geodir_video != '' AND " . $table . ".geodir_video IS NOT NULL )"; |
|
| 2062 | + } |
|
| 2063 | + |
|
| 2064 | + if (!empty($query_args['tax_query'])) {
|
|
| 2065 | + $tax_queries = get_tax_sql($query_args['tax_query'], $wpdb->posts, 'ID'); |
|
| 2072 | 2066 | |
| 2073 | - return $where; |
|
| 2067 | + if (!empty($tax_queries['join']) && !empty($tax_queries['where'])) {
|
|
| 2068 | + $where .= $tax_queries['where']; |
|
| 2069 | + } |
|
| 2070 | + } |
|
| 2071 | + } |
|
| 2072 | + |
|
| 2073 | + return $where; |
|
| 2074 | 2074 | } |
| 2075 | 2075 | |
| 2076 | 2076 | /** |
@@ -2085,23 +2085,23 @@ discard block |
||
| 2085 | 2085 | */ |
| 2086 | 2086 | function geodir_function_widget_listings_orderby($orderby) |
| 2087 | 2087 | {
|
| 2088 | - global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2088 | + global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2089 | 2089 | |
| 2090 | - $query_args = $gd_query_args_widgets; |
|
| 2091 | - if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2092 | - return $orderby; |
|
| 2093 | - } |
|
| 2090 | + $query_args = $gd_query_args_widgets; |
|
| 2091 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2092 | + return $orderby; |
|
| 2093 | + } |
|
| 2094 | 2094 | |
| 2095 | - $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 2096 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2095 | + $post_type = empty($query_args['post_type']) ? 'gd_place' : $query_args['post_type']; |
|
| 2096 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2097 | 2097 | |
| 2098 | - /* |
|
| 2098 | + /* |
|
| 2099 | 2099 | if ( $post_type == 'gd_event' && defined( 'EVENT_SCHEDULE' ) ) {
|
| 2100 | 2100 | $orderby .= EVENT_SCHEDULE . ".event_date ASC, " . EVENT_SCHEDULE . ".event_starttime ASC , " . $table . ".is_featured ASC, "; |
| 2101 | 2101 | } |
| 2102 | 2102 | */ |
| 2103 | 2103 | |
| 2104 | - return $orderby; |
|
| 2104 | + return $orderby; |
|
| 2105 | 2105 | } |
| 2106 | 2106 | |
| 2107 | 2107 | /** |
@@ -2116,18 +2116,18 @@ discard block |
||
| 2116 | 2116 | */ |
| 2117 | 2117 | function geodir_function_widget_listings_limit($limit) |
| 2118 | 2118 | {
|
| 2119 | - global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2119 | + global $wpdb, $plugin_prefix, $gd_query_args_widgets; |
|
| 2120 | 2120 | |
| 2121 | - $query_args = $gd_query_args_widgets; |
|
| 2122 | - if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2123 | - return $limit; |
|
| 2124 | - } |
|
| 2121 | + $query_args = $gd_query_args_widgets; |
|
| 2122 | + if (empty($query_args) || empty($query_args['is_geodir_loop'])) {
|
|
| 2123 | + return $limit; |
|
| 2124 | + } |
|
| 2125 | 2125 | |
| 2126 | - if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
|
|
| 2127 | - $limit = (int)$query_args['posts_per_page']; |
|
| 2128 | - } |
|
| 2126 | + if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
|
|
| 2127 | + $limit = (int)$query_args['posts_per_page']; |
|
| 2128 | + } |
|
| 2129 | 2129 | |
| 2130 | - return $limit; |
|
| 2130 | + return $limit; |
|
| 2131 | 2131 | } |
| 2132 | 2132 | |
| 2133 | 2133 | /** |
@@ -2141,24 +2141,24 @@ discard block |
||
| 2141 | 2141 | */ |
| 2142 | 2142 | function geodir_media_image_large_width($default = 800, $params = '') |
| 2143 | 2143 | {
|
| 2144 | - $large_size_w = get_option('large_size_w');
|
|
| 2145 | - $large_size_w = $large_size_w > 0 ? $large_size_w : $default; |
|
| 2146 | - $large_size_w = absint($large_size_w); |
|
| 2147 | - |
|
| 2148 | - if (!get_option('geodir_use_wp_media_large_size')) {
|
|
| 2149 | - $large_size_w = 800; |
|
| 2150 | - } |
|
| 2151 | - |
|
| 2152 | - /** |
|
| 2153 | - * Filter large image width. |
|
| 2154 | - * |
|
| 2155 | - * @since 1.0.0 |
|
| 2156 | - * @param int $large_size_w Large image width. |
|
| 2157 | - * @param int $default Default width. |
|
| 2158 | - * @param string|array $params Image parameters. |
|
| 2159 | - */ |
|
| 2160 | - $large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
|
|
| 2161 | - return $large_size_w; |
|
| 2144 | + $large_size_w = get_option('large_size_w');
|
|
| 2145 | + $large_size_w = $large_size_w > 0 ? $large_size_w : $default; |
|
| 2146 | + $large_size_w = absint($large_size_w); |
|
| 2147 | + |
|
| 2148 | + if (!get_option('geodir_use_wp_media_large_size')) {
|
|
| 2149 | + $large_size_w = 800; |
|
| 2150 | + } |
|
| 2151 | + |
|
| 2152 | + /** |
|
| 2153 | + * Filter large image width. |
|
| 2154 | + * |
|
| 2155 | + * @since 1.0.0 |
|
| 2156 | + * @param int $large_size_w Large image width. |
|
| 2157 | + * @param int $default Default width. |
|
| 2158 | + * @param string|array $params Image parameters. |
|
| 2159 | + */ |
|
| 2160 | + $large_size_w = apply_filters('geodir_filter_media_image_large_width', $large_size_w, $default, $params);
|
|
| 2161 | + return $large_size_w; |
|
| 2162 | 2162 | } |
| 2163 | 2163 | |
| 2164 | 2164 | /** |
@@ -2172,25 +2172,25 @@ discard block |
||
| 2172 | 2172 | */ |
| 2173 | 2173 | function geodir_media_image_large_height($default = 800, $params = '') |
| 2174 | 2174 | {
|
| 2175 | - $large_size_h = get_option('large_size_h');
|
|
| 2176 | - $large_size_h = $large_size_h > 0 ? $large_size_h : $default; |
|
| 2177 | - $large_size_h = absint($large_size_h); |
|
| 2178 | - |
|
| 2179 | - if (!get_option('geodir_use_wp_media_large_size')) {
|
|
| 2180 | - $large_size_h = 800; |
|
| 2181 | - } |
|
| 2182 | - |
|
| 2183 | - /** |
|
| 2184 | - * Filter large image height. |
|
| 2185 | - * |
|
| 2186 | - * @since 1.0.0 |
|
| 2187 | - * @param int $large_size_h Large image height. |
|
| 2188 | - * @param int $default Default height. |
|
| 2189 | - * @param string|array $params Image parameters. |
|
| 2190 | - */ |
|
| 2191 | - $large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
|
|
| 2175 | + $large_size_h = get_option('large_size_h');
|
|
| 2176 | + $large_size_h = $large_size_h > 0 ? $large_size_h : $default; |
|
| 2177 | + $large_size_h = absint($large_size_h); |
|
| 2192 | 2178 | |
| 2193 | - return $large_size_h; |
|
| 2179 | + if (!get_option('geodir_use_wp_media_large_size')) {
|
|
| 2180 | + $large_size_h = 800; |
|
| 2181 | + } |
|
| 2182 | + |
|
| 2183 | + /** |
|
| 2184 | + * Filter large image height. |
|
| 2185 | + * |
|
| 2186 | + * @since 1.0.0 |
|
| 2187 | + * @param int $large_size_h Large image height. |
|
| 2188 | + * @param int $default Default height. |
|
| 2189 | + * @param string|array $params Image parameters. |
|
| 2190 | + */ |
|
| 2191 | + $large_size_h = apply_filters('geodir_filter_media_image_large_height', $large_size_h, $default, $params);
|
|
| 2192 | + |
|
| 2193 | + return $large_size_h; |
|
| 2194 | 2194 | } |
| 2195 | 2195 | |
| 2196 | 2196 | /** |
@@ -2205,25 +2205,25 @@ discard block |
||
| 2205 | 2205 | */ |
| 2206 | 2206 | function geodir_sanitize_location_name($type, $name, $translate = true) |
| 2207 | 2207 | {
|
| 2208 | - if ($name == '') {
|
|
| 2209 | - return NULL; |
|
| 2210 | - } |
|
| 2211 | - |
|
| 2212 | - $type = $type == 'gd_country' ? 'country' : $type; |
|
| 2213 | - $type = $type == 'gd_region' ? 'region' : $type; |
|
| 2214 | - $type = $type == 'gd_city' ? 'city' : $type; |
|
| 2215 | - |
|
| 2216 | - $return = $name; |
|
| 2217 | - if (function_exists('get_actual_location_name')) {
|
|
| 2218 | - $return = get_actual_location_name($type, $name, $translate); |
|
| 2219 | - } else {
|
|
| 2220 | - $return = preg_replace('/-(\d+)$/', '', $return);
|
|
| 2221 | - $return = preg_replace('/[_-]/', ' ', $return);
|
|
| 2222 | - $return = geodir_ucwords($return); |
|
| 2223 | - $return = $translate ? __($return, 'geodirectory') : $return; |
|
| 2224 | - } |
|
| 2225 | - |
|
| 2226 | - return $return; |
|
| 2208 | + if ($name == '') {
|
|
| 2209 | + return NULL; |
|
| 2210 | + } |
|
| 2211 | + |
|
| 2212 | + $type = $type == 'gd_country' ? 'country' : $type; |
|
| 2213 | + $type = $type == 'gd_region' ? 'region' : $type; |
|
| 2214 | + $type = $type == 'gd_city' ? 'city' : $type; |
|
| 2215 | + |
|
| 2216 | + $return = $name; |
|
| 2217 | + if (function_exists('get_actual_location_name')) {
|
|
| 2218 | + $return = get_actual_location_name($type, $name, $translate); |
|
| 2219 | + } else {
|
|
| 2220 | + $return = preg_replace('/-(\d+)$/', '', $return);
|
|
| 2221 | + $return = preg_replace('/[_-]/', ' ', $return);
|
|
| 2222 | + $return = geodir_ucwords($return); |
|
| 2223 | + $return = $translate ? __($return, 'geodirectory') : $return; |
|
| 2224 | + } |
|
| 2225 | + |
|
| 2226 | + return $return; |
|
| 2227 | 2227 | } |
| 2228 | 2228 | |
| 2229 | 2229 | |
@@ -2237,14 +2237,14 @@ discard block |
||
| 2237 | 2237 | function geodir_comments_number($number) |
| 2238 | 2238 | {
|
| 2239 | 2239 | |
| 2240 | - if ($number > 1) {
|
|
| 2241 | - $output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
|
|
| 2242 | - } elseif ($number == 0 || $number == '') {
|
|
| 2243 | - $output = __('No Reviews', 'geodirectory');
|
|
| 2244 | - } else { // must be one
|
|
| 2245 | - $output = __('1 Review', 'geodirectory');
|
|
| 2246 | - } |
|
| 2247 | - echo $output; |
|
| 2240 | + if ($number > 1) {
|
|
| 2241 | + $output = str_replace('%', number_format_i18n($number), __('% Reviews', 'geodirectory'));
|
|
| 2242 | + } elseif ($number == 0 || $number == '') {
|
|
| 2243 | + $output = __('No Reviews', 'geodirectory');
|
|
| 2244 | + } else { // must be one
|
|
| 2245 | + $output = __('1 Review', 'geodirectory');
|
|
| 2246 | + } |
|
| 2247 | + echo $output; |
|
| 2248 | 2248 | } |
| 2249 | 2249 | |
| 2250 | 2250 | /** |
@@ -2257,23 +2257,23 @@ discard block |
||
| 2257 | 2257 | */ |
| 2258 | 2258 | function is_page_geodir_home() |
| 2259 | 2259 | {
|
| 2260 | - global $wpdb; |
|
| 2261 | - $cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
|
|
| 2262 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 2263 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 2264 | - } |
|
| 2265 | - $home_url = home_url('', 'http');
|
|
| 2266 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 2267 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 2268 | - } |
|
| 2269 | - $home_url = str_replace("www.", "", $home_url);
|
|
| 2270 | - 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')) ) {
|
|
| 2271 | - return true; |
|
| 2272 | - }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')){
|
|
| 2273 | - return true; |
|
| 2274 | - } else {
|
|
| 2275 | - return false; |
|
| 2276 | - } |
|
| 2260 | + global $wpdb; |
|
| 2261 | + $cur_url = str_replace(array("https://", "http://", "www."), array('', '', ''), geodir_curPageURL());
|
|
| 2262 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 2263 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 2264 | + } |
|
| 2265 | + $home_url = home_url('', 'http');
|
|
| 2266 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 2267 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 2268 | + } |
|
| 2269 | + $home_url = str_replace("www.", "", $home_url);
|
|
| 2270 | + 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')) ) {
|
|
| 2271 | + return true; |
|
| 2272 | + }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')){
|
|
| 2273 | + return true; |
|
| 2274 | + } else {
|
|
| 2275 | + return false; |
|
| 2276 | + } |
|
| 2277 | 2277 | |
| 2278 | 2278 | } |
| 2279 | 2279 | |
@@ -2289,13 +2289,13 @@ discard block |
||
| 2289 | 2289 | */ |
| 2290 | 2290 | function geodir_wpseo_homepage_canonical($url) |
| 2291 | 2291 | {
|
| 2292 | - global $post; |
|
| 2292 | + global $post; |
|
| 2293 | 2293 | |
| 2294 | - if (is_page_geodir_home()) {
|
|
| 2295 | - return home_url(); |
|
| 2296 | - } |
|
| 2294 | + if (is_page_geodir_home()) {
|
|
| 2295 | + return home_url(); |
|
| 2296 | + } |
|
| 2297 | 2297 | |
| 2298 | - return $url; |
|
| 2298 | + return $url; |
|
| 2299 | 2299 | } |
| 2300 | 2300 | |
| 2301 | 2301 | add_filter('wpseo_canonical', 'geodir_wpseo_homepage_canonical', 10);
|
@@ -2312,16 +2312,16 @@ discard block |
||
| 2312 | 2312 | */ |
| 2313 | 2313 | function geodir_googlemap_script_extra_details_page($extra) |
| 2314 | 2314 | {
|
| 2315 | - global $post; |
|
| 2316 | - $add_google_places_api = false; |
|
| 2317 | - if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
|
|
| 2318 | - $add_google_places_api = true; |
|
| 2319 | - } |
|
| 2320 | - if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
|
|
| 2321 | - $extra .= "&libraries=places"; |
|
| 2322 | - } |
|
| 2323 | - |
|
| 2324 | - return $extra; |
|
| 2315 | + global $post; |
|
| 2316 | + $add_google_places_api = false; |
|
| 2317 | + if (isset($post->post_content) && has_shortcode($post->post_content, 'gd_add_listing')) {
|
|
| 2318 | + $add_google_places_api = true; |
|
| 2319 | + } |
|
| 2320 | + if (!str_replace('libraries=places', '', $extra) && (geodir_is_page('detail') || $add_google_places_api)) {
|
|
| 2321 | + $extra .= "&libraries=places"; |
|
| 2322 | + } |
|
| 2323 | + |
|
| 2324 | + return $extra; |
|
| 2325 | 2325 | } |
| 2326 | 2326 | |
| 2327 | 2327 | add_filter('geodir_googlemap_script_extra', 'geodir_googlemap_script_extra_details_page', 101, 1);
|
@@ -2341,91 +2341,91 @@ discard block |
||
| 2341 | 2341 | */ |
| 2342 | 2342 | function geodir_popular_post_category_output($args = '', $instance = '') |
| 2343 | 2343 | {
|
| 2344 | - // prints the widget |
|
| 2345 | - global $wpdb, $plugin_prefix, $geodir_post_category_str; |
|
| 2346 | - extract($args, EXTR_SKIP); |
|
| 2344 | + // prints the widget |
|
| 2345 | + global $wpdb, $plugin_prefix, $geodir_post_category_str; |
|
| 2346 | + extract($args, EXTR_SKIP); |
|
| 2347 | 2347 | |
| 2348 | - echo $before_widget; |
|
| 2348 | + echo $before_widget; |
|
| 2349 | 2349 | |
| 2350 | - /** This filter is documented in geodirectory_widgets.php */ |
|
| 2351 | - $title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2350 | + /** This filter is documented in geodirectory_widgets.php */ |
|
| 2351 | + $title = empty($instance['title']) ? __('Popular Categories', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2352 | 2352 | |
| 2353 | - $gd_post_type = geodir_get_current_posttype(); |
|
| 2353 | + $gd_post_type = geodir_get_current_posttype(); |
|
| 2354 | 2354 | |
| 2355 | - $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15; |
|
| 2356 | - $default_post_type = !empty($gd_post_type) ? $gd_post_type : (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ? $instance['default_post_type'] : ''); |
|
| 2355 | + $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15; |
|
| 2356 | + $default_post_type = !empty($gd_post_type) ? $gd_post_type : (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ? $instance['default_post_type'] : ''); |
|
| 2357 | 2357 | |
| 2358 | - $taxonomy = array(); |
|
| 2359 | - if (!empty($gd_post_type)) {
|
|
| 2360 | - $taxonomy[] = $gd_post_type . "category"; |
|
| 2361 | - } else {
|
|
| 2362 | - $taxonomy = geodir_get_taxonomies($gd_post_type); |
|
| 2363 | - } |
|
| 2358 | + $taxonomy = array(); |
|
| 2359 | + if (!empty($gd_post_type)) {
|
|
| 2360 | + $taxonomy[] = $gd_post_type . "category"; |
|
| 2361 | + } else {
|
|
| 2362 | + $taxonomy = geodir_get_taxonomies($gd_post_type); |
|
| 2363 | + } |
|
| 2364 | 2364 | |
| 2365 | - $terms = get_terms($taxonomy); |
|
| 2366 | - $a_terms = array(); |
|
| 2367 | - $b_terms = array(); |
|
| 2365 | + $terms = get_terms($taxonomy); |
|
| 2366 | + $a_terms = array(); |
|
| 2367 | + $b_terms = array(); |
|
| 2368 | 2368 | |
| 2369 | - foreach ($terms as $term) {
|
|
| 2370 | - if ($term->count > 0) {
|
|
| 2371 | - $a_terms[$term->taxonomy][] = $term; |
|
| 2372 | - } |
|
| 2373 | - } |
|
| 2369 | + foreach ($terms as $term) {
|
|
| 2370 | + if ($term->count > 0) {
|
|
| 2371 | + $a_terms[$term->taxonomy][] = $term; |
|
| 2372 | + } |
|
| 2373 | + } |
|
| 2374 | 2374 | |
| 2375 | - if (!empty($a_terms)) {
|
|
| 2376 | - foreach ($a_terms as $b_key => $b_val) {
|
|
| 2377 | - $b_terms[$b_key] = geodir_sort_terms($b_val, 'count'); |
|
| 2378 | - } |
|
| 2375 | + if (!empty($a_terms)) {
|
|
| 2376 | + foreach ($a_terms as $b_key => $b_val) {
|
|
| 2377 | + $b_terms[$b_key] = geodir_sort_terms($b_val, 'count'); |
|
| 2378 | + } |
|
| 2379 | 2379 | |
| 2380 | - $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : ''; |
|
| 2381 | - |
|
| 2382 | - $tax_change_output = ''; |
|
| 2383 | - if (count($b_terms) > 1) {
|
|
| 2384 | - $tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax' onchange='geodir_get_post_term(this);'>"; |
|
| 2385 | - foreach ($b_terms as $key => $val) {
|
|
| 2386 | - $ptype = get_post_type_object(str_replace("category", "", $key));
|
|
| 2387 | - $cpt_name = __($ptype->labels->singular_name, 'geodirectory'); |
|
| 2388 | - $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
|
|
| 2389 | - } |
|
| 2390 | - $tax_change_output .= "</select>"; |
|
| 2391 | - } |
|
| 2380 | + $default_taxonomy = $default_post_type != '' && isset($b_terms[$default_post_type . 'category']) ? $default_post_type . 'category' : ''; |
|
| 2381 | + |
|
| 2382 | + $tax_change_output = ''; |
|
| 2383 | + if (count($b_terms) > 1) {
|
|
| 2384 | + $tax_change_output .= "<select data-limit='$category_limit' class='geodir-cat-list-tax' onchange='geodir_get_post_term(this);'>"; |
|
| 2385 | + foreach ($b_terms as $key => $val) {
|
|
| 2386 | + $ptype = get_post_type_object(str_replace("category", "", $key));
|
|
| 2387 | + $cpt_name = __($ptype->labels->singular_name, 'geodirectory'); |
|
| 2388 | + $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
|
|
| 2389 | + } |
|
| 2390 | + $tax_change_output .= "</select>"; |
|
| 2391 | + } |
|
| 2392 | 2392 | |
| 2393 | - if (!empty($b_terms)) {
|
|
| 2394 | - $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array |
|
| 2395 | - global $cat_count;//make global so we can change via function |
|
| 2396 | - $cat_count = 0; |
|
| 2397 | - ?> |
|
| 2393 | + if (!empty($b_terms)) {
|
|
| 2394 | + $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array |
|
| 2395 | + global $cat_count;//make global so we can change via function |
|
| 2396 | + $cat_count = 0; |
|
| 2397 | + ?> |
|
| 2398 | 2398 | <div class="geodir-category-list-in clearfix"> |
| 2399 | 2399 | <div class="geodir-cat-list clearfix"> |
| 2400 | 2400 | <?php |
| 2401 | - echo $before_title . __($title) . $after_title; |
|
| 2401 | + echo $before_title . __($title) . $after_title; |
|
| 2402 | 2402 | |
| 2403 | - echo $tax_change_output; |
|
| 2403 | + echo $tax_change_output; |
|
| 2404 | 2404 | |
| 2405 | - echo '<ul class="geodir-popular-cat-list">'; |
|
| 2405 | + echo '<ul class="geodir-popular-cat-list">'; |
|
| 2406 | 2406 | |
| 2407 | - geodir_helper_cat_list_output($terms, $category_limit); |
|
| 2407 | + geodir_helper_cat_list_output($terms, $category_limit); |
|
| 2408 | 2408 | |
| 2409 | - echo '</ul>'; |
|
| 2410 | - ?> |
|
| 2409 | + echo '</ul>'; |
|
| 2410 | + ?> |
|
| 2411 | 2411 | </div> |
| 2412 | 2412 | <?php |
| 2413 | - $hide = ''; |
|
| 2414 | - if ($cat_count < $category_limit) {
|
|
| 2415 | - $hide = 'style="display:none;"'; |
|
| 2416 | - } |
|
| 2417 | - echo "<div class='geodir-cat-list-more' $hide >"; |
|
| 2418 | - echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
|
|
| 2419 | - echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
|
|
| 2420 | - echo "</div>"; |
|
| 2421 | - /* add scripts */ |
|
| 2422 | - add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
|
|
| 2423 | - ?> |
|
| 2413 | + $hide = ''; |
|
| 2414 | + if ($cat_count < $category_limit) {
|
|
| 2415 | + $hide = 'style="display:none;"'; |
|
| 2416 | + } |
|
| 2417 | + echo "<div class='geodir-cat-list-more' $hide >"; |
|
| 2418 | + echo '<a href="javascript:void(0)" class="geodir-morecat geodir-showcat">' . __('More Categories', 'geodirectory') . '</a>';
|
|
| 2419 | + echo '<a href="javascript:void(0)" class="geodir-morecat geodir-hidecat geodir-hide">' . __('Less Categories', 'geodirectory') . '</a>';
|
|
| 2420 | + echo "</div>"; |
|
| 2421 | + /* add scripts */ |
|
| 2422 | + add_action('wp_footer', 'geodir_popular_category_add_scripts', 100);
|
|
| 2423 | + ?> |
|
| 2424 | 2424 | </div> |
| 2425 | 2425 | <?php |
| 2426 | - } |
|
| 2427 | - } |
|
| 2428 | - echo $after_widget; |
|
| 2426 | + } |
|
| 2427 | + } |
|
| 2428 | + echo $after_widget; |
|
| 2429 | 2429 | } |
| 2430 | 2430 | |
| 2431 | 2431 | /** |
@@ -2439,38 +2439,38 @@ discard block |
||
| 2439 | 2439 | */ |
| 2440 | 2440 | function geodir_helper_cat_list_output($terms, $category_limit) |
| 2441 | 2441 | {
|
| 2442 | - global $geodir_post_category_str, $cat_count; |
|
| 2443 | - $term_icons = geodir_get_term_icon(); |
|
| 2442 | + global $geodir_post_category_str, $cat_count; |
|
| 2443 | + $term_icons = geodir_get_term_icon(); |
|
| 2444 | 2444 | |
| 2445 | - $geodir_post_category_str = array(); |
|
| 2445 | + $geodir_post_category_str = array(); |
|
| 2446 | 2446 | |
| 2447 | 2447 | |
| 2448 | - foreach ($terms as $cat) {
|
|
| 2449 | - $post_type = str_replace("category", "", $cat->taxonomy);
|
|
| 2450 | - $term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : ''; |
|
| 2448 | + foreach ($terms as $cat) {
|
|
| 2449 | + $post_type = str_replace("category", "", $cat->taxonomy);
|
|
| 2450 | + $term_icon_url = !empty($term_icons) && isset($term_icons[$cat->term_id]) ? $term_icons[$cat->term_id] : ''; |
|
| 2451 | 2451 | |
| 2452 | - $cat_count++; |
|
| 2452 | + $cat_count++; |
|
| 2453 | 2453 | |
| 2454 | - $geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
|
|
| 2454 | + $geodir_post_category_str[] = array('posttype' => $post_type, 'termid' => $cat->term_id);
|
|
| 2455 | 2455 | |
| 2456 | - $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show'; |
|
| 2457 | - $total_post = $cat->count; |
|
| 2456 | + $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show'; |
|
| 2457 | + $total_post = $cat->count; |
|
| 2458 | 2458 | |
| 2459 | - $term_link = get_term_link( $cat, $cat->taxonomy ); |
|
| 2460 | - /** |
|
| 2461 | - * Filer the category term link. |
|
| 2462 | - * |
|
| 2463 | - * @since 1.4.5 |
|
| 2464 | - * @param string $term_link The term permalink. |
|
| 2465 | - * @param int $cat->term_id The term id. |
|
| 2466 | - * @param string $post_type Wordpress post type. |
|
| 2467 | - */ |
|
| 2468 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type ); |
|
| 2459 | + $term_link = get_term_link( $cat, $cat->taxonomy ); |
|
| 2460 | + /** |
|
| 2461 | + * Filer the category term link. |
|
| 2462 | + * |
|
| 2463 | + * @since 1.4.5 |
|
| 2464 | + * @param string $term_link The term permalink. |
|
| 2465 | + * @param int $cat->term_id The term id. |
|
| 2466 | + * @param string $post_type Wordpress post type. |
|
| 2467 | + */ |
|
| 2468 | + $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type ); |
|
| 2469 | 2469 | |
| 2470 | - echo '<li class="' . $class_row . '"><a href="' . $term_link . '">'; |
|
| 2471 | - 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> ';
|
|
| 2472 | - echo '</a></li>'; |
|
| 2473 | - } |
|
| 2470 | + echo '<li class="' . $class_row . '"><a href="' . $term_link . '">'; |
|
| 2471 | + 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> ';
|
|
| 2472 | + echo '</a></li>'; |
|
| 2473 | + } |
|
| 2474 | 2474 | } |
| 2475 | 2475 | |
| 2476 | 2476 | /** |
@@ -2484,108 +2484,108 @@ discard block |
||
| 2484 | 2484 | */ |
| 2485 | 2485 | function geodir_listing_slider_widget_output($args = '', $instance = '') |
| 2486 | 2486 | {
|
| 2487 | - // prints the widget |
|
| 2488 | - extract($args, EXTR_SKIP); |
|
| 2489 | - |
|
| 2490 | - echo $before_widget; |
|
| 2491 | - |
|
| 2492 | - /** This filter is documented in geodirectory_widgets.php */ |
|
| 2493 | - $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2494 | - /** |
|
| 2495 | - * Filter the widget post type. |
|
| 2496 | - * |
|
| 2497 | - * @since 1.0.0 |
|
| 2498 | - * @param string $instance['post_type'] Post type of listing. |
|
| 2499 | - */ |
|
| 2500 | - $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
|
|
| 2501 | - /** |
|
| 2502 | - * Filter the widget's term. |
|
| 2503 | - * |
|
| 2504 | - * @since 1.0.0 |
|
| 2505 | - * @param string $instance['category'] Filter by term. Can be any valid term. |
|
| 2506 | - */ |
|
| 2507 | - $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
|
|
| 2508 | - /** |
|
| 2509 | - * Filter the widget listings limit. |
|
| 2510 | - * |
|
| 2511 | - * @since 1.0.0 |
|
| 2512 | - * @param string $instance['post_number'] Number of listings to display. |
|
| 2513 | - */ |
|
| 2514 | - $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
|
|
| 2515 | - /** |
|
| 2516 | - * Filter the widget listings limit shown at one time. |
|
| 2517 | - * |
|
| 2518 | - * @since 1.5.0 |
|
| 2519 | - * @param string $instance['max_show'] Number of listings to display on screen. |
|
| 2520 | - */ |
|
| 2521 | - $max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
|
|
| 2522 | - /** |
|
| 2523 | - * Filter the widget slide width. |
|
| 2524 | - * |
|
| 2525 | - * @since 1.5.0 |
|
| 2526 | - * @param string $instance['slide_width'] Width of the slides shown. |
|
| 2527 | - */ |
|
| 2528 | - $slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
|
|
| 2529 | - /** |
|
| 2530 | - * Filter widget's "show title" value. |
|
| 2531 | - * |
|
| 2532 | - * @since 1.0.0 |
|
| 2533 | - * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0. |
|
| 2534 | - */ |
|
| 2535 | - $show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
|
|
| 2536 | - /** |
|
| 2537 | - * Filter widget's "slideshow" value. |
|
| 2538 | - * |
|
| 2539 | - * @since 1.0.0 |
|
| 2540 | - * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically. |
|
| 2541 | - */ |
|
| 2542 | - $slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
|
|
| 2543 | - /** |
|
| 2544 | - * Filter widget's "animationLoop" value. |
|
| 2545 | - * |
|
| 2546 | - * @since 1.0.0 |
|
| 2547 | - * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop. |
|
| 2548 | - */ |
|
| 2549 | - $animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
|
|
| 2550 | - /** |
|
| 2551 | - * Filter widget's "directionNav" value. |
|
| 2552 | - * |
|
| 2553 | - * @since 1.0.0 |
|
| 2554 | - * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0. |
|
| 2555 | - */ |
|
| 2556 | - $directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
|
|
| 2557 | - /** |
|
| 2558 | - * Filter widget's "slideshowSpeed" value. |
|
| 2559 | - * |
|
| 2560 | - * @since 1.0.0 |
|
| 2561 | - * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds. |
|
| 2562 | - */ |
|
| 2563 | - $slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
|
|
| 2564 | - /** |
|
| 2565 | - * Filter widget's "animationSpeed" value. |
|
| 2566 | - * |
|
| 2567 | - * @since 1.0.0 |
|
| 2568 | - * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds. |
|
| 2569 | - */ |
|
| 2570 | - $animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
|
|
| 2571 | - /** |
|
| 2572 | - * Filter widget's "animation" value. |
|
| 2573 | - * |
|
| 2574 | - * @since 1.0.0 |
|
| 2575 | - * @param string $instance['animation'] Controls the animation type, "fade" or "slide". |
|
| 2576 | - */ |
|
| 2577 | - $animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
|
|
| 2578 | - /** |
|
| 2579 | - * Filter widget's "list_sort" type. |
|
| 2580 | - * |
|
| 2581 | - * @since 1.0.0 |
|
| 2582 | - * @param string $instance['list_sort'] Listing sort by type. |
|
| 2583 | - */ |
|
| 2584 | - $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
|
|
| 2585 | - $show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL; |
|
| 2586 | - |
|
| 2587 | - wp_enqueue_script('geodirectory-jquery-flexslider-js');
|
|
| 2588 | - ?> |
|
| 2487 | + // prints the widget |
|
| 2488 | + extract($args, EXTR_SKIP); |
|
| 2489 | + |
|
| 2490 | + echo $before_widget; |
|
| 2491 | + |
|
| 2492 | + /** This filter is documented in geodirectory_widgets.php */ |
|
| 2493 | + $title = empty($instance['title']) ? '' : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2494 | + /** |
|
| 2495 | + * Filter the widget post type. |
|
| 2496 | + * |
|
| 2497 | + * @since 1.0.0 |
|
| 2498 | + * @param string $instance['post_type'] Post type of listing. |
|
| 2499 | + */ |
|
| 2500 | + $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
|
|
| 2501 | + /** |
|
| 2502 | + * Filter the widget's term. |
|
| 2503 | + * |
|
| 2504 | + * @since 1.0.0 |
|
| 2505 | + * @param string $instance['category'] Filter by term. Can be any valid term. |
|
| 2506 | + */ |
|
| 2507 | + $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
|
|
| 2508 | + /** |
|
| 2509 | + * Filter the widget listings limit. |
|
| 2510 | + * |
|
| 2511 | + * @since 1.0.0 |
|
| 2512 | + * @param string $instance['post_number'] Number of listings to display. |
|
| 2513 | + */ |
|
| 2514 | + $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
|
|
| 2515 | + /** |
|
| 2516 | + * Filter the widget listings limit shown at one time. |
|
| 2517 | + * |
|
| 2518 | + * @since 1.5.0 |
|
| 2519 | + * @param string $instance['max_show'] Number of listings to display on screen. |
|
| 2520 | + */ |
|
| 2521 | + $max_show = empty($instance['max_show']) ? '1' : apply_filters('widget_max_show', $instance['max_show']);
|
|
| 2522 | + /** |
|
| 2523 | + * Filter the widget slide width. |
|
| 2524 | + * |
|
| 2525 | + * @since 1.5.0 |
|
| 2526 | + * @param string $instance['slide_width'] Width of the slides shown. |
|
| 2527 | + */ |
|
| 2528 | + $slide_width = empty($instance['slide_width']) ? '' : apply_filters('widget_slide_width', $instance['slide_width']);
|
|
| 2529 | + /** |
|
| 2530 | + * Filter widget's "show title" value. |
|
| 2531 | + * |
|
| 2532 | + * @since 1.0.0 |
|
| 2533 | + * @param string|bool $instance['show_title'] Do you want to display title? Can be 1 or 0. |
|
| 2534 | + */ |
|
| 2535 | + $show_title = empty($instance['show_title']) ? '' : apply_filters('widget_show_title', $instance['show_title']);
|
|
| 2536 | + /** |
|
| 2537 | + * Filter widget's "slideshow" value. |
|
| 2538 | + * |
|
| 2539 | + * @since 1.0.0 |
|
| 2540 | + * @param int $instance['slideshow'] Setup a slideshow for the slider to animate automatically. |
|
| 2541 | + */ |
|
| 2542 | + $slideshow = empty($instance['slideshow']) ? 0 : apply_filters('widget_slideshow', $instance['slideshow']);
|
|
| 2543 | + /** |
|
| 2544 | + * Filter widget's "animationLoop" value. |
|
| 2545 | + * |
|
| 2546 | + * @since 1.0.0 |
|
| 2547 | + * @param int $instance['animationLoop'] Gives the slider a seamless infinite loop. |
|
| 2548 | + */ |
|
| 2549 | + $animationLoop = empty($instance['animationLoop']) ? 0 : apply_filters('widget_animationLoop', $instance['animationLoop']);
|
|
| 2550 | + /** |
|
| 2551 | + * Filter widget's "directionNav" value. |
|
| 2552 | + * |
|
| 2553 | + * @since 1.0.0 |
|
| 2554 | + * @param int $instance['directionNav'] Enable previous/next arrow navigation?. Can be 1 or 0. |
|
| 2555 | + */ |
|
| 2556 | + $directionNav = empty($instance['directionNav']) ? 0 : apply_filters('widget_directionNav', $instance['directionNav']);
|
|
| 2557 | + /** |
|
| 2558 | + * Filter widget's "slideshowSpeed" value. |
|
| 2559 | + * |
|
| 2560 | + * @since 1.0.0 |
|
| 2561 | + * @param int $instance['slideshowSpeed'] Set the speed of the slideshow cycling, in milliseconds. |
|
| 2562 | + */ |
|
| 2563 | + $slideshowSpeed = empty($instance['slideshowSpeed']) ? 5000 : apply_filters('widget_slideshowSpeed', $instance['slideshowSpeed']);
|
|
| 2564 | + /** |
|
| 2565 | + * Filter widget's "animationSpeed" value. |
|
| 2566 | + * |
|
| 2567 | + * @since 1.0.0 |
|
| 2568 | + * @param int $instance['animationSpeed'] Set the speed of animations, in milliseconds. |
|
| 2569 | + */ |
|
| 2570 | + $animationSpeed = empty($instance['animationSpeed']) ? 600 : apply_filters('widget_animationSpeed', $instance['animationSpeed']);
|
|
| 2571 | + /** |
|
| 2572 | + * Filter widget's "animation" value. |
|
| 2573 | + * |
|
| 2574 | + * @since 1.0.0 |
|
| 2575 | + * @param string $instance['animation'] Controls the animation type, "fade" or "slide". |
|
| 2576 | + */ |
|
| 2577 | + $animation = empty($instance['animation']) ? 'slide' : apply_filters('widget_animation', $instance['animation']);
|
|
| 2578 | + /** |
|
| 2579 | + * Filter widget's "list_sort" type. |
|
| 2580 | + * |
|
| 2581 | + * @since 1.0.0 |
|
| 2582 | + * @param string $instance['list_sort'] Listing sort by type. |
|
| 2583 | + */ |
|
| 2584 | + $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
|
|
| 2585 | + $show_featured_only = !empty($instance['show_featured_only']) ? 1 : NULL; |
|
| 2586 | + |
|
| 2587 | + wp_enqueue_script('geodirectory-jquery-flexslider-js');
|
|
| 2588 | + ?> |
|
| 2589 | 2589 | <script type="text/javascript"> |
| 2590 | 2590 | jQuery(window).load(function () {
|
| 2591 | 2591 | jQuery('#geodir_widget_carousel').flexslider({
|
@@ -2626,73 +2626,73 @@ discard block |
||
| 2626 | 2626 | }); |
| 2627 | 2627 | </script> |
| 2628 | 2628 | <?php |
| 2629 | - $query_args = array( |
|
| 2630 | - 'posts_per_page' => $post_number, |
|
| 2631 | - 'is_geodir_loop' => true, |
|
| 2632 | - 'post_type' => $post_type, |
|
| 2633 | - 'order_by' => $list_sort |
|
| 2634 | - ); |
|
| 2635 | - if ($show_featured_only) {
|
|
| 2636 | - $query_args['show_featured_only'] = 1; |
|
| 2637 | - } |
|
| 2638 | - |
|
| 2639 | - if ($category != 0 || $category != '') {
|
|
| 2640 | - $category_taxonomy = geodir_get_taxonomies($post_type); |
|
| 2641 | - $tax_query = array( |
|
| 2642 | - 'taxonomy' => $category_taxonomy[0], |
|
| 2643 | - 'field' => 'id', |
|
| 2644 | - 'terms' => $category |
|
| 2645 | - ); |
|
| 2646 | - |
|
| 2647 | - $query_args['tax_query'] = array($tax_query); |
|
| 2648 | - } |
|
| 2649 | - |
|
| 2650 | - // we want listings with featured image only |
|
| 2651 | - $query_args['featured_image_only'] = 1; |
|
| 2652 | - |
|
| 2653 | - if ($post_type == 'gd_event') {
|
|
| 2654 | - $query_args['gedir_event_listing_filter'] = 'upcoming'; |
|
| 2655 | - }// show only upcomming events |
|
| 2656 | - |
|
| 2657 | - $widget_listings = geodir_get_widget_listings($query_args); |
|
| 2658 | - if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
|
|
| 2659 | - if ($title) {
|
|
| 2660 | - echo $before_title . $title . $after_title; |
|
| 2661 | - } |
|
| 2629 | + $query_args = array( |
|
| 2630 | + 'posts_per_page' => $post_number, |
|
| 2631 | + 'is_geodir_loop' => true, |
|
| 2632 | + 'post_type' => $post_type, |
|
| 2633 | + 'order_by' => $list_sort |
|
| 2634 | + ); |
|
| 2635 | + if ($show_featured_only) {
|
|
| 2636 | + $query_args['show_featured_only'] = 1; |
|
| 2637 | + } |
|
| 2662 | 2638 | |
| 2663 | - global $post; |
|
| 2639 | + if ($category != 0 || $category != '') {
|
|
| 2640 | + $category_taxonomy = geodir_get_taxonomies($post_type); |
|
| 2641 | + $tax_query = array( |
|
| 2642 | + 'taxonomy' => $category_taxonomy[0], |
|
| 2643 | + 'field' => 'id', |
|
| 2644 | + 'terms' => $category |
|
| 2645 | + ); |
|
| 2664 | 2646 | |
| 2665 | - $current_post = $post;// keep current post info |
|
| 2647 | + $query_args['tax_query'] = array($tax_query); |
|
| 2648 | + } |
|
| 2666 | 2649 | |
| 2667 | - $widget_main_slides = ''; |
|
| 2668 | - $nav_slides = ''; |
|
| 2669 | - $widget_slides = 0; |
|
| 2650 | + // we want listings with featured image only |
|
| 2651 | + $query_args['featured_image_only'] = 1; |
|
| 2670 | 2652 | |
| 2671 | - foreach ($widget_listings as $widget_listing) {
|
|
| 2672 | - global $gd_widget_listing_type; |
|
| 2673 | - $post = $widget_listing; |
|
| 2674 | - $widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
|
|
| 2653 | + if ($post_type == 'gd_event') {
|
|
| 2654 | + $query_args['gedir_event_listing_filter'] = 'upcoming'; |
|
| 2655 | + }// show only upcomming events |
|
| 2675 | 2656 | |
| 2676 | - if (!empty($widget_image)) {
|
|
| 2677 | - if ($widget_image->height >= 200) {
|
|
| 2678 | - $widget_spacer_height = 0; |
|
| 2679 | - } else {
|
|
| 2680 | - $widget_spacer_height = ((200 - $widget_image->height) / 2); |
|
| 2681 | - } |
|
| 2657 | + $widget_listings = geodir_get_widget_listings($query_args); |
|
| 2658 | + if (!empty($widget_listings) || (isset($with_no_results) && $with_no_results)) {
|
|
| 2659 | + if ($title) {
|
|
| 2660 | + echo $before_title . $title . $after_title; |
|
| 2661 | + } |
|
| 2682 | 2662 | |
| 2683 | - $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" />'; |
|
| 2663 | + global $post; |
|
| 2684 | 2664 | |
| 2685 | - $title = ''; |
|
| 2686 | - if ($show_title) {
|
|
| 2687 | - $title = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>'; |
|
| 2688 | - } |
|
| 2665 | + $current_post = $post;// keep current post info |
|
| 2689 | 2666 | |
| 2690 | - $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>'; |
|
| 2691 | - $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 2692 | - $widget_slides++; |
|
| 2693 | - } |
|
| 2694 | - } |
|
| 2695 | - ?> |
|
| 2667 | + $widget_main_slides = ''; |
|
| 2668 | + $nav_slides = ''; |
|
| 2669 | + $widget_slides = 0; |
|
| 2670 | + |
|
| 2671 | + foreach ($widget_listings as $widget_listing) {
|
|
| 2672 | + global $gd_widget_listing_type; |
|
| 2673 | + $post = $widget_listing; |
|
| 2674 | + $widget_image = geodir_get_featured_image($post->ID, 'thumbnail', get_option('geodir_listing_no_img'));
|
|
| 2675 | + |
|
| 2676 | + if (!empty($widget_image)) {
|
|
| 2677 | + if ($widget_image->height >= 200) {
|
|
| 2678 | + $widget_spacer_height = 0; |
|
| 2679 | + } else {
|
|
| 2680 | + $widget_spacer_height = ((200 - $widget_image->height) / 2); |
|
| 2681 | + } |
|
| 2682 | + |
|
| 2683 | + $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" />'; |
|
| 2684 | + |
|
| 2685 | + $title = ''; |
|
| 2686 | + if ($show_title) {
|
|
| 2687 | + $title = '<div class="geodir-slider-title"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></div>'; |
|
| 2688 | + } |
|
| 2689 | + |
|
| 2690 | + $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>'; |
|
| 2691 | + $nav_slides .= '<li><img src="' . $widget_image->src . '" alt="' . $widget_image->title . '" title="' . $widget_image->title . '" style="max-height:48px;margin:0 auto;" /></li>'; |
|
| 2692 | + $widget_slides++; |
|
| 2693 | + } |
|
| 2694 | + } |
|
| 2695 | + ?> |
|
| 2696 | 2696 | <div class="flex-container" style="min-height:200px;"> |
| 2697 | 2697 | <div class="geodir-listing-flex-loader"><i class="fa fa-refresh fa-spin"></i></div> |
| 2698 | 2698 | <div id="geodir_widget_slider" class="geodir_flexslider"> |
@@ -2705,10 +2705,10 @@ discard block |
||
| 2705 | 2705 | <?php } ?> |
| 2706 | 2706 | </div> |
| 2707 | 2707 | <?php |
| 2708 | - $GLOBALS['post'] = $current_post; |
|
| 2709 | - setup_postdata($current_post); |
|
| 2710 | - } |
|
| 2711 | - echo $after_widget; |
|
| 2708 | + $GLOBALS['post'] = $current_post; |
|
| 2709 | + setup_postdata($current_post); |
|
| 2710 | + } |
|
| 2711 | + echo $after_widget; |
|
| 2712 | 2712 | } |
| 2713 | 2713 | |
| 2714 | 2714 | |
@@ -2723,68 +2723,68 @@ discard block |
||
| 2723 | 2723 | */ |
| 2724 | 2724 | function geodir_loginwidget_output($args = '', $instance = '') |
| 2725 | 2725 | {
|
| 2726 | - //print_r($args); |
|
| 2727 | - //print_r($instance); |
|
| 2728 | - // prints the widget |
|
| 2729 | - extract($args, EXTR_SKIP); |
|
| 2726 | + //print_r($args); |
|
| 2727 | + //print_r($instance); |
|
| 2728 | + // prints the widget |
|
| 2729 | + extract($args, EXTR_SKIP); |
|
| 2730 | 2730 | |
| 2731 | - /** This filter is documented in geodirectory_widgets.php */ |
|
| 2732 | - $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2731 | + /** This filter is documented in geodirectory_widgets.php */ |
|
| 2732 | + $title = empty($instance['title']) ? __('My Dashboard', 'geodirectory') : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2733 | 2733 | |
| 2734 | - echo $before_widget; |
|
| 2735 | - echo $before_title . $title . $after_title; |
|
| 2734 | + echo $before_widget; |
|
| 2735 | + echo $before_title . $title . $after_title; |
|
| 2736 | 2736 | |
| 2737 | - if (is_user_logged_in()) {
|
|
| 2738 | - global $current_user; |
|
| 2737 | + if (is_user_logged_in()) {
|
|
| 2738 | + global $current_user; |
|
| 2739 | 2739 | |
| 2740 | - $login_url = geodir_login_url(); |
|
| 2741 | - $add_listurl = get_permalink(geodir_add_listing_page_id()); |
|
| 2742 | - $add_listurl = geodir_getlink($add_listurl, array('listing_type' => 'gd_place'));
|
|
| 2743 | - $author_link = get_author_posts_url($current_user->data->ID); |
|
| 2744 | - $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
|
|
| 2740 | + $login_url = geodir_login_url(); |
|
| 2741 | + $add_listurl = get_permalink(geodir_add_listing_page_id()); |
|
| 2742 | + $add_listurl = geodir_getlink($add_listurl, array('listing_type' => 'gd_place'));
|
|
| 2743 | + $author_link = get_author_posts_url($current_user->data->ID); |
|
| 2744 | + $author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
|
|
| 2745 | 2745 | |
| 2746 | - echo '<ul class="geodir-loginbox-list">'; |
|
| 2747 | - ob_start(); |
|
| 2748 | - ?> |
|
| 2746 | + echo '<ul class="geodir-loginbox-list">'; |
|
| 2747 | + ob_start(); |
|
| 2748 | + ?> |
|
| 2749 | 2749 | <li><a class="signin" |
| 2750 | 2750 | href="<?php echo wp_logout_url(home_url()); ?>"><?php _e('Logout', 'geodirectory'); ?></a></li>
|
| 2751 | 2751 | <?php |
| 2752 | - $post_types = geodir_get_posttypes('object');
|
|
| 2753 | - $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
|
|
| 2754 | - $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 2752 | + $post_types = geodir_get_posttypes('object');
|
|
| 2753 | + $show_add_listing_post_types_main_nav = get_option('geodir_add_listing_link_user_dashboard');
|
|
| 2754 | + $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 2755 | 2755 | |
| 2756 | - if (!empty($show_add_listing_post_types_main_nav)) {
|
|
| 2757 | - $addlisting_links = ''; |
|
| 2758 | - foreach ($post_types as $key => $postobj) {
|
|
| 2756 | + if (!empty($show_add_listing_post_types_main_nav)) {
|
|
| 2757 | + $addlisting_links = ''; |
|
| 2758 | + foreach ($post_types as $key => $postobj) {
|
|
| 2759 | 2759 | |
| 2760 | - if (in_array($key, $show_add_listing_post_types_main_nav)) {
|
|
| 2760 | + if (in_array($key, $show_add_listing_post_types_main_nav)) {
|
|
| 2761 | 2761 | |
| 2762 | - if ($add_link = geodir_get_addlisting_link($key)) {
|
|
| 2762 | + if ($add_link = geodir_get_addlisting_link($key)) {
|
|
| 2763 | 2763 | |
| 2764 | - $name = $postobj->labels->name; |
|
| 2764 | + $name = $postobj->labels->name; |
|
| 2765 | 2765 | |
| 2766 | - $selected = ''; |
|
| 2767 | - if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
|
|
| 2768 | - $selected = 'selected="selected"'; |
|
| 2766 | + $selected = ''; |
|
| 2767 | + if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
|
|
| 2768 | + $selected = 'selected="selected"'; |
|
| 2769 | 2769 | |
| 2770 | - /** |
|
| 2771 | - * Filter add listing link. |
|
| 2772 | - * |
|
| 2773 | - * @since 1.0.0 |
|
| 2774 | - * @param string $add_link Add listing link. |
|
| 2775 | - * @param string $key Add listing array key. |
|
| 2776 | - * @param int $current_user->ID Current user ID. |
|
| 2777 | - */ |
|
| 2778 | - $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
|
|
| 2770 | + /** |
|
| 2771 | + * Filter add listing link. |
|
| 2772 | + * |
|
| 2773 | + * @since 1.0.0 |
|
| 2774 | + * @param string $add_link Add listing link. |
|
| 2775 | + * @param string $key Add listing array key. |
|
| 2776 | + * @param int $current_user->ID Current user ID. |
|
| 2777 | + */ |
|
| 2778 | + $add_link = apply_filters('geodir_dashboard_link_add_listing', $add_link, $key, $current_user->ID);
|
|
| 2779 | 2779 | |
| 2780 | - $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 2780 | + $addlisting_links .= '<option ' . $selected . ' value="' . $add_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 2781 | 2781 | |
| 2782 | - } |
|
| 2783 | - } |
|
| 2782 | + } |
|
| 2783 | + } |
|
| 2784 | 2784 | |
| 2785 | - } |
|
| 2785 | + } |
|
| 2786 | 2786 | |
| 2787 | - if ($addlisting_links != '') { ?>
|
|
| 2787 | + if ($addlisting_links != '') { ?>
|
|
| 2788 | 2788 | |
| 2789 | 2789 | <li><select id="geodir_add_listing" class="chosen_select" onchange="window.location.href=this.value" |
| 2790 | 2790 | option-autoredirect="1" name="geodir_add_listing" option-ajaxchosen="false" |
@@ -2793,42 +2793,42 @@ discard block |
||
| 2793 | 2793 | <?php echo $addlisting_links; ?> |
| 2794 | 2794 | </select></li> <?php |
| 2795 | 2795 | |
| 2796 | - } |
|
| 2796 | + } |
|
| 2797 | 2797 | |
| 2798 | - } |
|
| 2799 | - // My Favourites in Dashboard |
|
| 2800 | - $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
|
|
| 2801 | - $user_favourite = geodir_user_favourite_listing_count(); |
|
| 2802 | - |
|
| 2803 | - if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
|
|
| 2804 | - $favourite_links = ''; |
|
| 2805 | - |
|
| 2806 | - foreach ($post_types as $key => $postobj) {
|
|
| 2807 | - if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
|
|
| 2808 | - $name = $postobj->labels->name; |
|
| 2809 | - $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
|
|
| 2810 | - |
|
| 2811 | - $selected = ''; |
|
| 2812 | - |
|
| 2813 | - if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
|
|
| 2814 | - $selected = 'selected="selected"'; |
|
| 2815 | - } |
|
| 2816 | - /** |
|
| 2817 | - * Filter favorite listing link. |
|
| 2818 | - * |
|
| 2819 | - * @since 1.0.0 |
|
| 2820 | - * @param string $post_type_link Favorite listing link. |
|
| 2821 | - * @param string $key Favorite listing array key. |
|
| 2822 | - * @param int $current_user->ID Current user ID. |
|
| 2823 | - */ |
|
| 2824 | - $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
|
|
| 2825 | - |
|
| 2826 | - $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 2827 | - } |
|
| 2828 | - } |
|
| 2829 | - |
|
| 2830 | - if ($favourite_links != '') {
|
|
| 2831 | - ?> |
|
| 2798 | + } |
|
| 2799 | + // My Favourites in Dashboard |
|
| 2800 | + $show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
|
|
| 2801 | + $user_favourite = geodir_user_favourite_listing_count(); |
|
| 2802 | + |
|
| 2803 | + if (!empty($show_favorite_link_user_dashboard) && !empty($user_favourite)) {
|
|
| 2804 | + $favourite_links = ''; |
|
| 2805 | + |
|
| 2806 | + foreach ($post_types as $key => $postobj) {
|
|
| 2807 | + if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
|
|
| 2808 | + $name = $postobj->labels->name; |
|
| 2809 | + $post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
|
|
| 2810 | + |
|
| 2811 | + $selected = ''; |
|
| 2812 | + |
|
| 2813 | + if (isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key && isset($_REQUEST['geodir_dashbord'])) {
|
|
| 2814 | + $selected = 'selected="selected"'; |
|
| 2815 | + } |
|
| 2816 | + /** |
|
| 2817 | + * Filter favorite listing link. |
|
| 2818 | + * |
|
| 2819 | + * @since 1.0.0 |
|
| 2820 | + * @param string $post_type_link Favorite listing link. |
|
| 2821 | + * @param string $key Favorite listing array key. |
|
| 2822 | + * @param int $current_user->ID Current user ID. |
|
| 2823 | + */ |
|
| 2824 | + $post_type_link = apply_filters('geodir_dashboard_link_favorite_listing', $post_type_link, $key, $current_user->ID);
|
|
| 2825 | + |
|
| 2826 | + $favourite_links .= '<option ' . $selected . ' value="' . $post_type_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 2827 | + } |
|
| 2828 | + } |
|
| 2829 | + |
|
| 2830 | + if ($favourite_links != '') {
|
|
| 2831 | + ?> |
|
| 2832 | 2832 | <li> |
| 2833 | 2833 | <select id="geodir_my_favourites" class="chosen_select" onchange="window.location.href=this.value" |
| 2834 | 2834 | option-autoredirect="1" name="geodir_my_favourites" option-ajaxchosen="false" |
@@ -2838,42 +2838,42 @@ discard block |
||
| 2838 | 2838 | </select> |
| 2839 | 2839 | </li> |
| 2840 | 2840 | <?php |
| 2841 | - } |
|
| 2842 | - } |
|
| 2843 | - |
|
| 2841 | + } |
|
| 2842 | + } |
|
| 2844 | 2843 | |
| 2845 | - $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
|
|
| 2846 | - $user_listing = geodir_user_post_listing_count(); |
|
| 2847 | 2844 | |
| 2848 | - if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
|
|
| 2849 | - $listing_links = ''; |
|
| 2845 | + $show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
|
|
| 2846 | + $user_listing = geodir_user_post_listing_count(); |
|
| 2850 | 2847 | |
| 2851 | - foreach ($post_types as $key => $postobj) {
|
|
| 2852 | - if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
|
|
| 2853 | - $name = $postobj->labels->name; |
|
| 2854 | - $listing_link = geodir_getlink($author_link, array('stype' => $key), false);
|
|
| 2848 | + if (!empty($show_listing_link_user_dashboard) && !empty($user_listing)) {
|
|
| 2849 | + $listing_links = ''; |
|
| 2855 | 2850 | |
| 2856 | - $selected = ''; |
|
| 2857 | - if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
|
|
| 2858 | - $selected = 'selected="selected"'; |
|
| 2859 | - } |
|
| 2851 | + foreach ($post_types as $key => $postobj) {
|
|
| 2852 | + if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
|
|
| 2853 | + $name = $postobj->labels->name; |
|
| 2854 | + $listing_link = geodir_getlink($author_link, array('stype' => $key), false);
|
|
| 2860 | 2855 | |
| 2861 | - /** |
|
| 2862 | - * Filter my listing link. |
|
| 2863 | - * |
|
| 2864 | - * @since 1.0.0 |
|
| 2865 | - * @param string $listing_link My listing link. |
|
| 2866 | - * @param string $key My listing array key. |
|
| 2867 | - * @param int $current_user->ID Current user ID. |
|
| 2868 | - */ |
|
| 2869 | - $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
|
|
| 2856 | + $selected = ''; |
|
| 2857 | + if (!isset($_REQUEST['list']) && isset($_REQUEST['geodir_dashbord']) && isset($_REQUEST['stype']) && $_REQUEST['stype'] == $key) {
|
|
| 2858 | + $selected = 'selected="selected"'; |
|
| 2859 | + } |
|
| 2870 | 2860 | |
| 2871 | - $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 2872 | - } |
|
| 2873 | - } |
|
| 2861 | + /** |
|
| 2862 | + * Filter my listing link. |
|
| 2863 | + * |
|
| 2864 | + * @since 1.0.0 |
|
| 2865 | + * @param string $listing_link My listing link. |
|
| 2866 | + * @param string $key My listing array key. |
|
| 2867 | + * @param int $current_user->ID Current user ID. |
|
| 2868 | + */ |
|
| 2869 | + $listing_link = apply_filters('geodir_dashboard_link_my_listing', $listing_link, $key, $current_user->ID);
|
|
| 2870 | + |
|
| 2871 | + $listing_links .= '<option ' . $selected . ' value="' . $listing_link . '">' . __(ucfirst($name), 'geodirectory') . '</option>'; |
|
| 2872 | + } |
|
| 2873 | + } |
|
| 2874 | 2874 | |
| 2875 | - if ($listing_links != '') {
|
|
| 2876 | - ?> |
|
| 2875 | + if ($listing_links != '') {
|
|
| 2876 | + ?> |
|
| 2877 | 2877 | <li> |
| 2878 | 2878 | <select id="geodir_my_listings" class="chosen_select" onchange="window.location.href=this.value" |
| 2879 | 2879 | option-autoredirect="1" name="geodir_my_listings" option-ajaxchosen="false" |
@@ -2883,27 +2883,27 @@ discard block |
||
| 2883 | 2883 | </select> |
| 2884 | 2884 | </li> |
| 2885 | 2885 | <?php |
| 2886 | - } |
|
| 2887 | - } |
|
| 2886 | + } |
|
| 2887 | + } |
|
| 2888 | 2888 | |
| 2889 | - $dashboard_link = ob_get_clean(); |
|
| 2890 | - /** |
|
| 2891 | - * Filter dashboard links HTML. |
|
| 2892 | - * |
|
| 2893 | - * @since 1.0.0 |
|
| 2894 | - * @param string $dashboard_link Dashboard links HTML. |
|
| 2895 | - */ |
|
| 2896 | - echo apply_filters('geodir_dashboard_links', $dashboard_link);
|
|
| 2897 | - echo '</ul>'; |
|
| 2898 | - } else {
|
|
| 2899 | - ?> |
|
| 2889 | + $dashboard_link = ob_get_clean(); |
|
| 2890 | + /** |
|
| 2891 | + * Filter dashboard links HTML. |
|
| 2892 | + * |
|
| 2893 | + * @since 1.0.0 |
|
| 2894 | + * @param string $dashboard_link Dashboard links HTML. |
|
| 2895 | + */ |
|
| 2896 | + echo apply_filters('geodir_dashboard_links', $dashboard_link);
|
|
| 2897 | + echo '</ul>'; |
|
| 2898 | + } else {
|
|
| 2899 | + ?> |
|
| 2900 | 2900 | <?php |
| 2901 | - /** |
|
| 2902 | - * Filter signup form action link. |
|
| 2903 | - * |
|
| 2904 | - * @since 1.0.0 |
|
| 2905 | - */ |
|
| 2906 | - ?> |
|
| 2901 | + /** |
|
| 2902 | + * Filter signup form action link. |
|
| 2903 | + * |
|
| 2904 | + * @since 1.0.0 |
|
| 2905 | + */ |
|
| 2906 | + ?> |
|
| 2907 | 2907 | <form name="loginform" class="loginform1" |
| 2908 | 2908 | action="<?php echo geodir_login_url(); ?>" |
| 2909 | 2909 | method="post"> |
@@ -2923,28 +2923,28 @@ discard block |
||
| 2923 | 2923 | |
| 2924 | 2924 | <p class="geodir-new-forgot-link"> |
| 2925 | 2925 | <?php |
| 2926 | - /** |
|
| 2927 | - * Filter signup page register form link. |
|
| 2928 | - * |
|
| 2929 | - * @since 1.0.0 |
|
| 2930 | - */ |
|
| 2931 | - ?> |
|
| 2926 | + /** |
|
| 2927 | + * Filter signup page register form link. |
|
| 2928 | + * |
|
| 2929 | + * @since 1.0.0 |
|
| 2930 | + */ |
|
| 2931 | + ?> |
|
| 2932 | 2932 | <a href="<?php echo geodir_login_url(array('signup' => true)); ?>"
|
| 2933 | 2933 | class="goedir-newuser-link"><?php echo NEW_USER_TEXT; ?></a> |
| 2934 | 2934 | |
| 2935 | 2935 | <?php |
| 2936 | - /** |
|
| 2937 | - * Filter signup page forgot password form link. |
|
| 2938 | - * |
|
| 2939 | - * @since 1.0.0 |
|
| 2940 | - */ |
|
| 2941 | - ?> |
|
| 2936 | + /** |
|
| 2937 | + * Filter signup page forgot password form link. |
|
| 2938 | + * |
|
| 2939 | + * @since 1.0.0 |
|
| 2940 | + */ |
|
| 2941 | + ?> |
|
| 2942 | 2942 | <a href="<?php echo geodir_login_url(array('forgot' => true)); ?>"
|
| 2943 | 2943 | class="goedir-forgot-link"><?php echo FORGOT_PW_TEXT; ?></a></p></div> |
| 2944 | 2944 | </form> |
| 2945 | 2945 | <?php } |
| 2946 | 2946 | |
| 2947 | - echo $after_widget; |
|
| 2947 | + echo $after_widget; |
|
| 2948 | 2948 | } |
| 2949 | 2949 | |
| 2950 | 2950 | |
@@ -2963,284 +2963,284 @@ discard block |
||
| 2963 | 2963 | * @param array|string $instance The settings for the particular instance of the widget. |
| 2964 | 2964 | */ |
| 2965 | 2965 | function geodir_popular_postview_output($args = '', $instance = '') {
|
| 2966 | - global $gd_session; |
|
| 2966 | + global $gd_session; |
|
| 2967 | 2967 | |
| 2968 | - // prints the widget |
|
| 2969 | - extract($args, EXTR_SKIP); |
|
| 2970 | - |
|
| 2971 | - echo $before_widget; |
|
| 2972 | - |
|
| 2973 | - /** This filter is documented in geodirectory_widgets.php */ |
|
| 2974 | - $title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2975 | - /** |
|
| 2976 | - * Filter the widget post type. |
|
| 2977 | - * |
|
| 2978 | - * @since 1.0.0 |
|
| 2979 | - * @param string $instance['post_type'] Post type of listing. |
|
| 2980 | - */ |
|
| 2981 | - $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
|
|
| 2982 | - /** |
|
| 2983 | - * Filter the widget's term. |
|
| 2984 | - * |
|
| 2985 | - * @since 1.0.0 |
|
| 2986 | - * @param string $instance['category'] Filter by term. Can be any valid term. |
|
| 2987 | - */ |
|
| 2988 | - $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
|
|
| 2989 | - /** |
|
| 2990 | - * Filter the widget listings limit. |
|
| 2991 | - * |
|
| 2992 | - * @since 1.0.0 |
|
| 2993 | - * @param string $instance['post_number'] Number of listings to display. |
|
| 2994 | - */ |
|
| 2995 | - $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
|
|
| 2996 | - /** |
|
| 2997 | - * Filter widget's "layout" type. |
|
| 2998 | - * |
|
| 2999 | - * @since 1.0.0 |
|
| 3000 | - * @param string $instance['layout'] Widget layout type. |
|
| 3001 | - */ |
|
| 3002 | - $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
|
|
| 3003 | - /** |
|
| 3004 | - * Filter widget's "add_location_filter" value. |
|
| 3005 | - * |
|
| 3006 | - * @since 1.0.0 |
|
| 3007 | - * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0. |
|
| 3008 | - */ |
|
| 3009 | - $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
|
|
| 3010 | - /** |
|
| 3011 | - * Filter widget's listing width. |
|
| 3012 | - * |
|
| 3013 | - * @since 1.0.0 |
|
| 3014 | - * @param string $instance['listing_width'] Listing width. |
|
| 3015 | - */ |
|
| 3016 | - $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
|
|
| 3017 | - /** |
|
| 3018 | - * Filter widget's "list_sort" type. |
|
| 3019 | - * |
|
| 3020 | - * @since 1.0.0 |
|
| 3021 | - * @param string $instance['list_sort'] Listing sort by type. |
|
| 3022 | - */ |
|
| 3023 | - $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
|
|
| 3024 | - $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false; |
|
| 3025 | - |
|
| 3026 | - // set post type to current viewing post type |
|
| 3027 | - if ($use_viewing_post_type) {
|
|
| 3028 | - $current_post_type = geodir_get_current_posttype(); |
|
| 3029 | - if ($current_post_type != '' && $current_post_type != $post_type) {
|
|
| 3030 | - $post_type = $current_post_type; |
|
| 3031 | - $category = array(); // old post type category will not work for current changed post type |
|
| 3032 | - } |
|
| 3033 | - } |
|
| 3034 | - // replace widget title dynamically |
|
| 3035 | - $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory'); |
|
| 3036 | - $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory'); |
|
| 3037 | - |
|
| 3038 | - $title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
|
|
| 3039 | - $title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
|
|
| 3040 | - |
|
| 3041 | - if (isset($instance['character_count'])) {
|
|
| 3042 | - /** |
|
| 3043 | - * Filter the widget's excerpt character count. |
|
| 3044 | - * |
|
| 3045 | - * @since 1.0.0 |
|
| 3046 | - * @param int $instance['character_count'] Excerpt character count. |
|
| 3047 | - */ |
|
| 3048 | - $character_count = apply_filters('widget_list_character_count', $instance['character_count']);
|
|
| 3049 | - } else {
|
|
| 3050 | - $character_count = ''; |
|
| 3051 | - } |
|
| 3052 | - |
|
| 3053 | - if (empty($title) || $title == 'All') {
|
|
| 3054 | - $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory'); |
|
| 3055 | - } |
|
| 3056 | - |
|
| 3057 | - $location_url = array(); |
|
| 3058 | - $city = get_query_var('gd_city');
|
|
| 3059 | - if (!empty($city)) {
|
|
| 3060 | - $country = get_query_var('gd_country');
|
|
| 3061 | - $region = get_query_var('gd_region');
|
|
| 3062 | - |
|
| 3063 | - $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 3064 | - |
|
| 3065 | - if ($geodir_show_location_url == 'all') {
|
|
| 3066 | - if ($country != '') {
|
|
| 3067 | - $location_url[] = $country; |
|
| 3068 | - } |
|
| 3069 | - |
|
| 3070 | - if ($region != '') {
|
|
| 3071 | - $location_url[] = $region; |
|
| 3072 | - } |
|
| 3073 | - } else if ($geodir_show_location_url == 'country_city') {
|
|
| 3074 | - if ($country != '') {
|
|
| 3075 | - $location_url[] = $country; |
|
| 3076 | - } |
|
| 3077 | - } else if ($geodir_show_location_url == 'region_city') {
|
|
| 3078 | - if ($region != '') {
|
|
| 3079 | - $location_url[] = $region; |
|
| 3080 | - } |
|
| 3081 | - } |
|
| 2968 | + // prints the widget |
|
| 2969 | + extract($args, EXTR_SKIP); |
|
| 2970 | + |
|
| 2971 | + echo $before_widget; |
|
| 2972 | + |
|
| 2973 | + /** This filter is documented in geodirectory_widgets.php */ |
|
| 2974 | + $title = empty($instance['title']) ? geodir_ucwords($instance['category_title']) : apply_filters('widget_title', __($instance['title'], 'geodirectory'));
|
|
| 2975 | + /** |
|
| 2976 | + * Filter the widget post type. |
|
| 2977 | + * |
|
| 2978 | + * @since 1.0.0 |
|
| 2979 | + * @param string $instance['post_type'] Post type of listing. |
|
| 2980 | + */ |
|
| 2981 | + $post_type = empty($instance['post_type']) ? 'gd_place' : apply_filters('widget_post_type', $instance['post_type']);
|
|
| 2982 | + /** |
|
| 2983 | + * Filter the widget's term. |
|
| 2984 | + * |
|
| 2985 | + * @since 1.0.0 |
|
| 2986 | + * @param string $instance['category'] Filter by term. Can be any valid term. |
|
| 2987 | + */ |
|
| 2988 | + $category = empty($instance['category']) ? '0' : apply_filters('widget_category', $instance['category']);
|
|
| 2989 | + /** |
|
| 2990 | + * Filter the widget listings limit. |
|
| 2991 | + * |
|
| 2992 | + * @since 1.0.0 |
|
| 2993 | + * @param string $instance['post_number'] Number of listings to display. |
|
| 2994 | + */ |
|
| 2995 | + $post_number = empty($instance['post_number']) ? '5' : apply_filters('widget_post_number', $instance['post_number']);
|
|
| 2996 | + /** |
|
| 2997 | + * Filter widget's "layout" type. |
|
| 2998 | + * |
|
| 2999 | + * @since 1.0.0 |
|
| 3000 | + * @param string $instance['layout'] Widget layout type. |
|
| 3001 | + */ |
|
| 3002 | + $layout = empty($instance['layout']) ? 'gridview_onehalf' : apply_filters('widget_layout', $instance['layout']);
|
|
| 3003 | + /** |
|
| 3004 | + * Filter widget's "add_location_filter" value. |
|
| 3005 | + * |
|
| 3006 | + * @since 1.0.0 |
|
| 3007 | + * @param string|bool $instance['add_location_filter'] Do you want to add location filter? Can be 1 or 0. |
|
| 3008 | + */ |
|
| 3009 | + $add_location_filter = empty($instance['add_location_filter']) ? '0' : apply_filters('widget_add_location_filter', $instance['add_location_filter']);
|
|
| 3010 | + /** |
|
| 3011 | + * Filter widget's listing width. |
|
| 3012 | + * |
|
| 3013 | + * @since 1.0.0 |
|
| 3014 | + * @param string $instance['listing_width'] Listing width. |
|
| 3015 | + */ |
|
| 3016 | + $listing_width = empty($instance['listing_width']) ? '' : apply_filters('widget_listing_width', $instance['listing_width']);
|
|
| 3017 | + /** |
|
| 3018 | + * Filter widget's "list_sort" type. |
|
| 3019 | + * |
|
| 3020 | + * @since 1.0.0 |
|
| 3021 | + * @param string $instance['list_sort'] Listing sort by type. |
|
| 3022 | + */ |
|
| 3023 | + $list_sort = empty($instance['list_sort']) ? 'latest' : apply_filters('widget_list_sort', $instance['list_sort']);
|
|
| 3024 | + $use_viewing_post_type = !empty($instance['use_viewing_post_type']) ? true : false; |
|
| 3025 | + |
|
| 3026 | + // set post type to current viewing post type |
|
| 3027 | + if ($use_viewing_post_type) {
|
|
| 3028 | + $current_post_type = geodir_get_current_posttype(); |
|
| 3029 | + if ($current_post_type != '' && $current_post_type != $post_type) {
|
|
| 3030 | + $post_type = $current_post_type; |
|
| 3031 | + $category = array(); // old post type category will not work for current changed post type |
|
| 3032 | + } |
|
| 3033 | + } |
|
| 3034 | + // replace widget title dynamically |
|
| 3035 | + $posttype_plural_label = __(get_post_type_plural_label($post_type), 'geodirectory'); |
|
| 3036 | + $posttype_singular_label = __(get_post_type_singular_label($post_type), 'geodirectory'); |
|
| 3037 | + |
|
| 3038 | + $title = str_replace("%posttype_plural_label%", $posttype_plural_label, $title);
|
|
| 3039 | + $title = str_replace("%posttype_singular_label%", $posttype_singular_label, $title);
|
|
| 3040 | + |
|
| 3041 | + if (isset($instance['character_count'])) {
|
|
| 3042 | + /** |
|
| 3043 | + * Filter the widget's excerpt character count. |
|
| 3044 | + * |
|
| 3045 | + * @since 1.0.0 |
|
| 3046 | + * @param int $instance['character_count'] Excerpt character count. |
|
| 3047 | + */ |
|
| 3048 | + $character_count = apply_filters('widget_list_character_count', $instance['character_count']);
|
|
| 3049 | + } else {
|
|
| 3050 | + $character_count = ''; |
|
| 3051 | + } |
|
| 3082 | 3052 | |
| 3083 | - $location_url[] = $city; |
|
| 3084 | - } |
|
| 3053 | + if (empty($title) || $title == 'All') {
|
|
| 3054 | + $title .= ' ' . __(get_post_type_plural_label($post_type), 'geodirectory'); |
|
| 3055 | + } |
|
| 3085 | 3056 | |
| 3086 | - $location_url = implode('/', $location_url);
|
|
| 3087 | - $skip_location = false; |
|
| 3088 | - if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
|
|
| 3089 | - $skip_location = true; |
|
| 3090 | - $gd_session->un_set('gd_multi_location');
|
|
| 3091 | - } |
|
| 3057 | + $location_url = array(); |
|
| 3058 | + $city = get_query_var('gd_city');
|
|
| 3059 | + if (!empty($city)) {
|
|
| 3060 | + $country = get_query_var('gd_country');
|
|
| 3061 | + $region = get_query_var('gd_region');
|
|
| 3092 | 3062 | |
| 3093 | - if (get_option('permalink_structure')) {
|
|
| 3094 | - $viewall_url = get_post_type_archive_link($post_type); |
|
| 3095 | - } else {
|
|
| 3096 | - $viewall_url = get_post_type_archive_link($post_type); |
|
| 3097 | - } |
|
| 3063 | + $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 3098 | 3064 | |
| 3099 | - if (!empty($category) && $category[0] != '0') {
|
|
| 3100 | - global $geodir_add_location_url; |
|
| 3065 | + if ($geodir_show_location_url == 'all') {
|
|
| 3066 | + if ($country != '') {
|
|
| 3067 | + $location_url[] = $country; |
|
| 3068 | + } |
|
| 3069 | + |
|
| 3070 | + if ($region != '') {
|
|
| 3071 | + $location_url[] = $region; |
|
| 3072 | + } |
|
| 3073 | + } else if ($geodir_show_location_url == 'country_city') {
|
|
| 3074 | + if ($country != '') {
|
|
| 3075 | + $location_url[] = $country; |
|
| 3076 | + } |
|
| 3077 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 3078 | + if ($region != '') {
|
|
| 3079 | + $location_url[] = $region; |
|
| 3080 | + } |
|
| 3081 | + } |
|
| 3101 | 3082 | |
| 3102 | - $geodir_add_location_url = '0'; |
|
| 3083 | + $location_url[] = $city; |
|
| 3084 | + } |
|
| 3103 | 3085 | |
| 3104 | - if ($add_location_filter != '0') {
|
|
| 3105 | - $geodir_add_location_url = '1'; |
|
| 3106 | - } |
|
| 3086 | + $location_url = implode('/', $location_url);
|
|
| 3087 | + $skip_location = false; |
|
| 3088 | + if (!$add_location_filter && $gd_session->get('gd_multi_location')) {
|
|
| 3089 | + $skip_location = true; |
|
| 3090 | + $gd_session->un_set('gd_multi_location');
|
|
| 3091 | + } |
|
| 3107 | 3092 | |
| 3108 | - $viewall_url = get_term_link((int)$category[0], $post_type . 'category'); |
|
| 3093 | + if (get_option('permalink_structure')) {
|
|
| 3094 | + $viewall_url = get_post_type_archive_link($post_type); |
|
| 3095 | + } else {
|
|
| 3096 | + $viewall_url = get_post_type_archive_link($post_type); |
|
| 3097 | + } |
|
| 3109 | 3098 | |
| 3110 | - $geodir_add_location_url = NULL; |
|
| 3111 | - } |
|
| 3112 | - if ($skip_location) {
|
|
| 3113 | - $gd_session->set('gd_multi_location', 1);
|
|
| 3114 | - } |
|
| 3099 | + if (!empty($category) && $category[0] != '0') {
|
|
| 3100 | + global $geodir_add_location_url; |
|
| 3115 | 3101 | |
| 3116 | - if(is_wp_error( $viewall_url )){$viewall_url = '';}
|
|
| 3102 | + $geodir_add_location_url = '0'; |
|
| 3117 | 3103 | |
| 3118 | - $query_args = array( |
|
| 3119 | - 'posts_per_page' => $post_number, |
|
| 3120 | - 'is_geodir_loop' => true, |
|
| 3121 | - 'gd_location' => $add_location_filter ? true : false, |
|
| 3122 | - 'post_type' => $post_type, |
|
| 3123 | - 'order_by' => $list_sort |
|
| 3124 | - ); |
|
| 3104 | + if ($add_location_filter != '0') {
|
|
| 3105 | + $geodir_add_location_url = '1'; |
|
| 3106 | + } |
|
| 3125 | 3107 | |
| 3126 | - if ($character_count) {
|
|
| 3127 | - $query_args['excerpt_length'] = $character_count; |
|
| 3128 | - } |
|
| 3108 | + $viewall_url = get_term_link((int)$category[0], $post_type . 'category'); |
|
| 3109 | + |
|
| 3110 | + $geodir_add_location_url = NULL; |
|
| 3111 | + } |
|
| 3112 | + if ($skip_location) {
|
|
| 3113 | + $gd_session->set('gd_multi_location', 1);
|
|
| 3114 | + } |
|
| 3129 | 3115 | |
| 3130 | - if (!empty($instance['show_featured_only'])) {
|
|
| 3131 | - $query_args['show_featured_only'] = 1; |
|
| 3132 | - } |
|
| 3116 | + if(is_wp_error( $viewall_url )){$viewall_url = '';}
|
|
| 3133 | 3117 | |
| 3134 | - if (!empty($instance['show_special_only'])) {
|
|
| 3135 | - $query_args['show_special_only'] = 1; |
|
| 3136 | - } |
|
| 3118 | + $query_args = array( |
|
| 3119 | + 'posts_per_page' => $post_number, |
|
| 3120 | + 'is_geodir_loop' => true, |
|
| 3121 | + 'gd_location' => $add_location_filter ? true : false, |
|
| 3122 | + 'post_type' => $post_type, |
|
| 3123 | + 'order_by' => $list_sort |
|
| 3124 | + ); |
|
| 3137 | 3125 | |
| 3138 | - if (!empty($instance['with_pics_only'])) {
|
|
| 3139 | - $query_args['with_pics_only'] = 0; |
|
| 3140 | - $query_args['featured_image_only'] = 1; |
|
| 3141 | - } |
|
| 3126 | + if ($character_count) {
|
|
| 3127 | + $query_args['excerpt_length'] = $character_count; |
|
| 3128 | + } |
|
| 3142 | 3129 | |
| 3143 | - if (!empty($instance['with_videos_only'])) {
|
|
| 3144 | - $query_args['with_videos_only'] = 1; |
|
| 3145 | - } |
|
| 3146 | - $with_no_results = !empty($instance['without_no_results']) ? false : true; |
|
| 3130 | + if (!empty($instance['show_featured_only'])) {
|
|
| 3131 | + $query_args['show_featured_only'] = 1; |
|
| 3132 | + } |
|
| 3147 | 3133 | |
| 3148 | - if (!empty($category) && $category[0] != '0') {
|
|
| 3149 | - $category_taxonomy = geodir_get_taxonomies($post_type); |
|
| 3134 | + if (!empty($instance['show_special_only'])) {
|
|
| 3135 | + $query_args['show_special_only'] = 1; |
|
| 3136 | + } |
|
| 3150 | 3137 | |
| 3151 | - ######### WPML ######### |
|
| 3152 | - if (function_exists('icl_object_id')) {
|
|
| 3153 | - $category = gd_lang_object_ids($category, $category_taxonomy[0]); |
|
| 3154 | - } |
|
| 3155 | - ######### WPML ######### |
|
| 3138 | + if (!empty($instance['with_pics_only'])) {
|
|
| 3139 | + $query_args['with_pics_only'] = 0; |
|
| 3140 | + $query_args['featured_image_only'] = 1; |
|
| 3141 | + } |
|
| 3142 | + |
|
| 3143 | + if (!empty($instance['with_videos_only'])) {
|
|
| 3144 | + $query_args['with_videos_only'] = 1; |
|
| 3145 | + } |
|
| 3146 | + $with_no_results = !empty($instance['without_no_results']) ? false : true; |
|
| 3147 | + |
|
| 3148 | + if (!empty($category) && $category[0] != '0') {
|
|
| 3149 | + $category_taxonomy = geodir_get_taxonomies($post_type); |
|
| 3150 | + |
|
| 3151 | + ######### WPML ######### |
|
| 3152 | + if (function_exists('icl_object_id')) {
|
|
| 3153 | + $category = gd_lang_object_ids($category, $category_taxonomy[0]); |
|
| 3154 | + } |
|
| 3155 | + ######### WPML ######### |
|
| 3156 | 3156 | |
| 3157 | - $tax_query = array( |
|
| 3158 | - 'taxonomy' => $category_taxonomy[0], |
|
| 3159 | - 'field' => 'id', |
|
| 3160 | - 'terms' => $category |
|
| 3161 | - ); |
|
| 3157 | + $tax_query = array( |
|
| 3158 | + 'taxonomy' => $category_taxonomy[0], |
|
| 3159 | + 'field' => 'id', |
|
| 3160 | + 'terms' => $category |
|
| 3161 | + ); |
|
| 3162 | 3162 | |
| 3163 | - $query_args['tax_query'] = array($tax_query); |
|
| 3164 | - } |
|
| 3163 | + $query_args['tax_query'] = array($tax_query); |
|
| 3164 | + } |
|
| 3165 | 3165 | |
| 3166 | - global $gridview_columns_widget, $geodir_is_widget_listing; |
|
| 3166 | + global $gridview_columns_widget, $geodir_is_widget_listing; |
|
| 3167 | 3167 | |
| 3168 | - $widget_listings = geodir_get_widget_listings($query_args); |
|
| 3168 | + $widget_listings = geodir_get_widget_listings($query_args); |
|
| 3169 | 3169 | |
| 3170 | - if (!empty($widget_listings) || $with_no_results) {
|
|
| 3171 | - ?> |
|
| 3170 | + if (!empty($widget_listings) || $with_no_results) {
|
|
| 3171 | + ?> |
|
| 3172 | 3172 | <div class="geodir_locations geodir_location_listing"> |
| 3173 | 3173 | |
| 3174 | 3174 | <?php |
| 3175 | - /** |
|
| 3176 | - * Called before the div containing the title and view all link in popular post view widget. |
|
| 3177 | - * |
|
| 3178 | - * @since 1.0.0 |
|
| 3179 | - */ |
|
| 3180 | - do_action('geodir_before_view_all_link_in_widget'); ?>
|
|
| 3175 | + /** |
|
| 3176 | + * Called before the div containing the title and view all link in popular post view widget. |
|
| 3177 | + * |
|
| 3178 | + * @since 1.0.0 |
|
| 3179 | + */ |
|
| 3180 | + do_action('geodir_before_view_all_link_in_widget'); ?>
|
|
| 3181 | 3181 | <div class="geodir_list_heading clearfix"> |
| 3182 | 3182 | <?php echo $before_title . $title . $after_title; ?> |
| 3183 | 3183 | <a href="<?php echo $viewall_url; ?>" |
| 3184 | 3184 | class="geodir-viewall"><?php _e('View all', 'geodirectory'); ?></a>
|
| 3185 | 3185 | </div> |
| 3186 | 3186 | <?php |
| 3187 | - /** |
|
| 3188 | - * Called after the div containing the title and view all link in popular post view widget. |
|
| 3189 | - * |
|
| 3190 | - * @since 1.0.0 |
|
| 3191 | - */ |
|
| 3192 | - do_action('geodir_after_view_all_link_in_widget'); ?>
|
|
| 3187 | + /** |
|
| 3188 | + * Called after the div containing the title and view all link in popular post view widget. |
|
| 3189 | + * |
|
| 3190 | + * @since 1.0.0 |
|
| 3191 | + */ |
|
| 3192 | + do_action('geodir_after_view_all_link_in_widget'); ?>
|
|
| 3193 | 3193 | <?php |
| 3194 | - if (strstr($layout, 'gridview')) {
|
|
| 3195 | - $listing_view_exp = explode('_', $layout);
|
|
| 3196 | - $gridview_columns_widget = $layout; |
|
| 3197 | - $layout = $listing_view_exp[0]; |
|
| 3198 | - } else {
|
|
| 3199 | - $gridview_columns_widget = ''; |
|
| 3200 | - } |
|
| 3201 | - |
|
| 3202 | - /** |
|
| 3203 | - * Filter the widget listing listview template path. |
|
| 3204 | - * |
|
| 3205 | - * @since 1.0.0 |
|
| 3206 | - */ |
|
| 3207 | - $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
|
|
| 3208 | - if (!isset($character_count)) {
|
|
| 3209 | - /** |
|
| 3210 | - * Filter the widget's excerpt character count. |
|
| 3211 | - * |
|
| 3212 | - * @since 1.0.0 |
|
| 3213 | - * @param int $instance['character_count'] Excerpt character count. |
|
| 3214 | - */ |
|
| 3215 | - $character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
|
|
| 3216 | - } |
|
| 3217 | - |
|
| 3218 | - global $post, $map_jason, $map_canvas_arr; |
|
| 3219 | - |
|
| 3220 | - $current_post = $post; |
|
| 3221 | - $current_map_jason = $map_jason; |
|
| 3222 | - $current_map_canvas_arr = $map_canvas_arr; |
|
| 3223 | - $geodir_is_widget_listing = true; |
|
| 3224 | - |
|
| 3225 | - /** |
|
| 3226 | - * Includes related listing listview template. |
|
| 3227 | - * |
|
| 3228 | - * @since 1.0.0 |
|
| 3229 | - */ |
|
| 3230 | - include($template); |
|
| 3231 | - |
|
| 3232 | - $geodir_is_widget_listing = false; |
|
| 3233 | - |
|
| 3234 | - $GLOBALS['post'] = $current_post; |
|
| 3235 | - if (!empty($current_post)) |
|
| 3236 | - setup_postdata($current_post); |
|
| 3237 | - $map_jason = $current_map_jason; |
|
| 3238 | - $map_canvas_arr = $current_map_canvas_arr; |
|
| 3239 | - ?> |
|
| 3194 | + if (strstr($layout, 'gridview')) {
|
|
| 3195 | + $listing_view_exp = explode('_', $layout);
|
|
| 3196 | + $gridview_columns_widget = $layout; |
|
| 3197 | + $layout = $listing_view_exp[0]; |
|
| 3198 | + } else {
|
|
| 3199 | + $gridview_columns_widget = ''; |
|
| 3200 | + } |
|
| 3201 | + |
|
| 3202 | + /** |
|
| 3203 | + * Filter the widget listing listview template path. |
|
| 3204 | + * |
|
| 3205 | + * @since 1.0.0 |
|
| 3206 | + */ |
|
| 3207 | + $template = apply_filters("geodir_template_part-widget-listing-listview", geodir_locate_template('widget-listing-listview'));
|
|
| 3208 | + if (!isset($character_count)) {
|
|
| 3209 | + /** |
|
| 3210 | + * Filter the widget's excerpt character count. |
|
| 3211 | + * |
|
| 3212 | + * @since 1.0.0 |
|
| 3213 | + * @param int $instance['character_count'] Excerpt character count. |
|
| 3214 | + */ |
|
| 3215 | + $character_count = $character_count == '' ? 50 : apply_filters('widget_character_count', $character_count);
|
|
| 3216 | + } |
|
| 3217 | + |
|
| 3218 | + global $post, $map_jason, $map_canvas_arr; |
|
| 3219 | + |
|
| 3220 | + $current_post = $post; |
|
| 3221 | + $current_map_jason = $map_jason; |
|
| 3222 | + $current_map_canvas_arr = $map_canvas_arr; |
|
| 3223 | + $geodir_is_widget_listing = true; |
|
| 3224 | + |
|
| 3225 | + /** |
|
| 3226 | + * Includes related listing listview template. |
|
| 3227 | + * |
|
| 3228 | + * @since 1.0.0 |
|
| 3229 | + */ |
|
| 3230 | + include($template); |
|
| 3231 | + |
|
| 3232 | + $geodir_is_widget_listing = false; |
|
| 3233 | + |
|
| 3234 | + $GLOBALS['post'] = $current_post; |
|
| 3235 | + if (!empty($current_post)) |
|
| 3236 | + setup_postdata($current_post); |
|
| 3237 | + $map_jason = $current_map_jason; |
|
| 3238 | + $map_canvas_arr = $current_map_canvas_arr; |
|
| 3239 | + ?> |
|
| 3240 | 3240 | </div> |
| 3241 | 3241 | <?php |
| 3242 | - } |
|
| 3243 | - echo $after_widget; |
|
| 3242 | + } |
|
| 3243 | + echo $after_widget; |
|
| 3244 | 3244 | |
| 3245 | 3245 | } |
| 3246 | 3246 | |
@@ -3263,26 +3263,26 @@ discard block |
||
| 3263 | 3263 | */ |
| 3264 | 3264 | function geodir_count_reviews_by_term_id($term_id, $taxonomy, $post_type) |
| 3265 | 3265 | {
|
| 3266 | - global $wpdb, $plugin_prefix; |
|
| 3266 | + global $wpdb, $plugin_prefix; |
|
| 3267 | 3267 | |
| 3268 | - $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 3268 | + $detail_table = $plugin_prefix . $post_type . '_detail'; |
|
| 3269 | 3269 | |
| 3270 | - $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 . ")";
|
|
| 3270 | + $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 . ")";
|
|
| 3271 | 3271 | |
| 3272 | - /** |
|
| 3273 | - * Filter count review sql query. |
|
| 3274 | - * |
|
| 3275 | - * @since 1.5.1 |
|
| 3276 | - * @param string $sql Database sql query.. |
|
| 3277 | - * @param int $term_id The term ID. |
|
| 3278 | - * @param int $taxonomy The taxonomy Id. |
|
| 3279 | - * @param string $post_type The post type. |
|
| 3280 | - */ |
|
| 3281 | - $sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
|
|
| 3272 | + /** |
|
| 3273 | + * Filter count review sql query. |
|
| 3274 | + * |
|
| 3275 | + * @since 1.5.1 |
|
| 3276 | + * @param string $sql Database sql query.. |
|
| 3277 | + * @param int $term_id The term ID. |
|
| 3278 | + * @param int $taxonomy The taxonomy Id. |
|
| 3279 | + * @param string $post_type The post type. |
|
| 3280 | + */ |
|
| 3281 | + $sql = apply_filters('geodir_count_reviews_by_term_sql', $sql, $term_id, $taxonomy, $post_type);
|
|
| 3282 | 3282 | |
| 3283 | - $count = $wpdb->get_var($sql); |
|
| 3283 | + $count = $wpdb->get_var($sql); |
|
| 3284 | 3284 | |
| 3285 | - return $count; |
|
| 3285 | + return $count; |
|
| 3286 | 3286 | } |
| 3287 | 3287 | |
| 3288 | 3288 | /** |
@@ -3295,53 +3295,53 @@ discard block |
||
| 3295 | 3295 | */ |
| 3296 | 3296 | function geodir_count_reviews_by_terms($force_update = false) |
| 3297 | 3297 | {
|
| 3298 | - /** |
|
| 3299 | - * Filter review count option data. |
|
| 3300 | - * |
|
| 3301 | - * @since 1.0.0 |
|
| 3302 | - * @param bool $force_update Force update option value?. Default.false. |
|
| 3303 | - */ |
|
| 3304 | - $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update);
|
|
| 3305 | - if (!empty($option_data)) {
|
|
| 3306 | - return $option_data; |
|
| 3307 | - } |
|
| 3298 | + /** |
|
| 3299 | + * Filter review count option data. |
|
| 3300 | + * |
|
| 3301 | + * @since 1.0.0 |
|
| 3302 | + * @param bool $force_update Force update option value?. Default.false. |
|
| 3303 | + */ |
|
| 3304 | + $option_data = apply_filters('geodir_count_reviews_by_terms_before', '', $force_update);
|
|
| 3305 | + if (!empty($option_data)) {
|
|
| 3306 | + return $option_data; |
|
| 3307 | + } |
|
| 3308 | 3308 | |
| 3309 | - $option_data = get_option('geodir_global_review_count');
|
|
| 3309 | + $option_data = get_option('geodir_global_review_count');
|
|
| 3310 | 3310 | |
| 3311 | - if (!$option_data OR $force_update) {
|
|
| 3312 | - $post_types = geodir_get_posttypes(); |
|
| 3313 | - $term_array = array(); |
|
| 3314 | - foreach ($post_types as $post_type) {
|
|
| 3311 | + if (!$option_data OR $force_update) {
|
|
| 3312 | + $post_types = geodir_get_posttypes(); |
|
| 3313 | + $term_array = array(); |
|
| 3314 | + foreach ($post_types as $post_type) {
|
|
| 3315 | 3315 | |
| 3316 | - $taxonomy = geodir_get_taxonomies($post_type); |
|
| 3317 | - $taxonomy = $taxonomy[0]; |
|
| 3316 | + $taxonomy = geodir_get_taxonomies($post_type); |
|
| 3317 | + $taxonomy = $taxonomy[0]; |
|
| 3318 | 3318 | |
| 3319 | - $args = array( |
|
| 3320 | - 'hide_empty' => false |
|
| 3321 | - ); |
|
| 3319 | + $args = array( |
|
| 3320 | + 'hide_empty' => false |
|
| 3321 | + ); |
|
| 3322 | 3322 | |
| 3323 | - $terms = get_terms($taxonomy, $args); |
|
| 3323 | + $terms = get_terms($taxonomy, $args); |
|
| 3324 | 3324 | |
| 3325 | - foreach ($terms as $term) {
|
|
| 3326 | - $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type); |
|
| 3327 | - $children = get_term_children($term->term_id, $taxonomy); |
|
| 3328 | - /*if ( is_array( $children ) ) {
|
|
| 3325 | + foreach ($terms as $term) {
|
|
| 3326 | + $count = geodir_count_reviews_by_term_id($term->term_id, $taxonomy, $post_type); |
|
| 3327 | + $children = get_term_children($term->term_id, $taxonomy); |
|
| 3328 | + /*if ( is_array( $children ) ) {
|
|
| 3329 | 3329 | foreach ( $children as $child_id ) {
|
| 3330 | 3330 | $child_count = geodir_count_reviews_by_term_id($child_id, $taxonomy, $post_type); |
| 3331 | 3331 | $count = $count + $child_count; |
| 3332 | 3332 | } |
| 3333 | 3333 | }*/ |
| 3334 | - $term_array[$term->term_id] = $count; |
|
| 3335 | - } |
|
| 3336 | - } |
|
| 3334 | + $term_array[$term->term_id] = $count; |
|
| 3335 | + } |
|
| 3336 | + } |
|
| 3337 | 3337 | |
| 3338 | - update_option('geodir_global_review_count', $term_array);
|
|
| 3339 | - //clear cache |
|
| 3340 | - wp_cache_delete('geodir_global_review_count');
|
|
| 3341 | - return $term_array; |
|
| 3342 | - } else {
|
|
| 3343 | - return $option_data; |
|
| 3344 | - } |
|
| 3338 | + update_option('geodir_global_review_count', $term_array);
|
|
| 3339 | + //clear cache |
|
| 3340 | + wp_cache_delete('geodir_global_review_count');
|
|
| 3341 | + return $term_array; |
|
| 3342 | + } else {
|
|
| 3343 | + return $option_data; |
|
| 3344 | + } |
|
| 3345 | 3345 | } |
| 3346 | 3346 | |
| 3347 | 3347 | /** |
@@ -3353,15 +3353,15 @@ discard block |
||
| 3353 | 3353 | */ |
| 3354 | 3354 | function geodir_term_review_count_force_update($new_status, $old_status='', $post='') |
| 3355 | 3355 | {
|
| 3356 | - if(isset($_REQUEST['action']) && $_REQUEST['action']=='geodir_import_export'){return;}//do not run if importing listings
|
|
| 3357 | - |
|
| 3358 | - if(isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')){
|
|
| 3359 | - return; |
|
| 3360 | - } |
|
| 3361 | - if($new_status!=$old_status) {
|
|
| 3362 | - geodir_count_reviews_by_terms(true); |
|
| 3363 | - } |
|
| 3364 | - return true; |
|
| 3356 | + if(isset($_REQUEST['action']) && $_REQUEST['action']=='geodir_import_export'){return;}//do not run if importing listings
|
|
| 3357 | + |
|
| 3358 | + if(isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')){
|
|
| 3359 | + return; |
|
| 3360 | + } |
|
| 3361 | + if($new_status!=$old_status) {
|
|
| 3362 | + geodir_count_reviews_by_terms(true); |
|
| 3363 | + } |
|
| 3364 | + return true; |
|
| 3365 | 3365 | } |
| 3366 | 3366 | |
| 3367 | 3367 | |
@@ -3380,15 +3380,15 @@ discard block |
||
| 3380 | 3380 | function geodir_count_posts_by_term($data, $term) |
| 3381 | 3381 | {
|
| 3382 | 3382 | |
| 3383 | - if ($data) {
|
|
| 3384 | - if (isset($data[$term->term_id])) {
|
|
| 3385 | - return $data[$term->term_id]; |
|
| 3386 | - } else {
|
|
| 3387 | - return 0; |
|
| 3388 | - } |
|
| 3389 | - } else {
|
|
| 3390 | - return $term->count; |
|
| 3391 | - } |
|
| 3383 | + if ($data) {
|
|
| 3384 | + if (isset($data[$term->term_id])) {
|
|
| 3385 | + return $data[$term->term_id]; |
|
| 3386 | + } else {
|
|
| 3387 | + return 0; |
|
| 3388 | + } |
|
| 3389 | + } else {
|
|
| 3390 | + return $term->count; |
|
| 3391 | + } |
|
| 3392 | 3392 | } |
| 3393 | 3393 | |
| 3394 | 3394 | /** |
@@ -3401,8 +3401,8 @@ discard block |
||
| 3401 | 3401 | */ |
| 3402 | 3402 | function geodir_sort_terms_by_count($terms) |
| 3403 | 3403 | {
|
| 3404 | - usort($terms, "geodir_sort_by_count_obj"); |
|
| 3405 | - return $terms; |
|
| 3404 | + usort($terms, "geodir_sort_by_count_obj"); |
|
| 3405 | + return $terms; |
|
| 3406 | 3406 | } |
| 3407 | 3407 | |
| 3408 | 3408 | /** |
@@ -3415,8 +3415,8 @@ discard block |
||
| 3415 | 3415 | */ |
| 3416 | 3416 | function geodir_sort_terms_by_review_count($terms) |
| 3417 | 3417 | {
|
| 3418 | - usort($terms, "geodir_sort_by_review_count_obj"); |
|
| 3419 | - return $terms; |
|
| 3418 | + usort($terms, "geodir_sort_by_review_count_obj"); |
|
| 3419 | + return $terms; |
|
| 3420 | 3420 | } |
| 3421 | 3421 | |
| 3422 | 3422 | /** |
@@ -3430,12 +3430,12 @@ discard block |
||
| 3430 | 3430 | */ |
| 3431 | 3431 | function geodir_sort_terms($terms, $sort = 'count') |
| 3432 | 3432 | {
|
| 3433 | - if ($sort == 'count') {
|
|
| 3434 | - return geodir_sort_terms_by_count($terms); |
|
| 3435 | - } |
|
| 3436 | - if ($sort == 'review_count') {
|
|
| 3437 | - return geodir_sort_terms_by_review_count($terms); |
|
| 3438 | - } |
|
| 3433 | + if ($sort == 'count') {
|
|
| 3434 | + return geodir_sort_terms_by_count($terms); |
|
| 3435 | + } |
|
| 3436 | + if ($sort == 'review_count') {
|
|
| 3437 | + return geodir_sort_terms_by_review_count($terms); |
|
| 3438 | + } |
|
| 3439 | 3439 | } |
| 3440 | 3440 | |
| 3441 | 3441 | /*-----------------------------------------------------------------------------------*/ |
@@ -3452,7 +3452,7 @@ discard block |
||
| 3452 | 3452 | */ |
| 3453 | 3453 | function geodir_sort_by_count($a, $b) |
| 3454 | 3454 | {
|
| 3455 | - return $a['count'] < $b['count']; |
|
| 3455 | + return $a['count'] < $b['count']; |
|
| 3456 | 3456 | } |
| 3457 | 3457 | |
| 3458 | 3458 | /** |
@@ -3466,7 +3466,7 @@ discard block |
||
| 3466 | 3466 | */ |
| 3467 | 3467 | function geodir_sort_by_count_obj($a, $b) |
| 3468 | 3468 | {
|
| 3469 | - return $a->count < $b->count; |
|
| 3469 | + return $a->count < $b->count; |
|
| 3470 | 3470 | } |
| 3471 | 3471 | |
| 3472 | 3472 | /** |
@@ -3480,7 +3480,7 @@ discard block |
||
| 3480 | 3480 | */ |
| 3481 | 3481 | function geodir_sort_by_review_count_obj($a, $b) |
| 3482 | 3482 | {
|
| 3483 | - return $a->review_count < $b->review_count; |
|
| 3483 | + return $a->review_count < $b->review_count; |
|
| 3484 | 3484 | } |
| 3485 | 3485 | |
| 3486 | 3486 | /** |
@@ -3490,43 +3490,43 @@ discard block |
||
| 3490 | 3490 | * @package GeoDirectory |
| 3491 | 3491 | */ |
| 3492 | 3492 | function geodir_load_textdomain() {
|
| 3493 | - /** |
|
| 3494 | - * Filter the plugin locale. |
|
| 3495 | - * |
|
| 3496 | - * @since 1.4.2 |
|
| 3497 | - * @package GeoDirectory |
|
| 3498 | - */ |
|
| 3499 | - $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
|
|
| 3500 | - |
|
| 3501 | - load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
|
|
| 3502 | - load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
|
|
| 3493 | + /** |
|
| 3494 | + * Filter the plugin locale. |
|
| 3495 | + * |
|
| 3496 | + * @since 1.4.2 |
|
| 3497 | + * @package GeoDirectory |
|
| 3498 | + */ |
|
| 3499 | + $locale = apply_filters('plugin_locale', get_locale(), 'geodirectory');
|
|
| 3500 | + |
|
| 3501 | + load_textdomain('geodirectory', WP_LANG_DIR . '/' . 'geodirectory' . '/' . 'geodirectory' . '-' . $locale . '.mo');
|
|
| 3502 | + load_plugin_textdomain('geodirectory', false, plugin_basename(dirname(dirname(__FILE__))) . '/geodirectory-languages');
|
|
| 3503 | + |
|
| 3504 | + /** |
|
| 3505 | + * Define language constants. |
|
| 3506 | + * |
|
| 3507 | + * @since 1.0.0 |
|
| 3508 | + */ |
|
| 3509 | + require_once(geodir_plugin_path() . '/language.php'); |
|
| 3510 | + |
|
| 3511 | + $language_file = geodir_plugin_path() . '/db-language.php'; |
|
| 3512 | + |
|
| 3513 | + // Load language string file if not created yet |
|
| 3514 | + if (!file_exists($language_file)) {
|
|
| 3515 | + geodirectory_load_db_language(); |
|
| 3516 | + } |
|
| 3503 | 3517 | |
| 3504 | - /** |
|
| 3505 | - * Define language constants. |
|
| 3506 | - * |
|
| 3507 | - * @since 1.0.0 |
|
| 3508 | - */ |
|
| 3509 | - require_once(geodir_plugin_path() . '/language.php'); |
|
| 3510 | - |
|
| 3511 | - $language_file = geodir_plugin_path() . '/db-language.php'; |
|
| 3512 | - |
|
| 3513 | - // Load language string file if not created yet |
|
| 3514 | - if (!file_exists($language_file)) {
|
|
| 3515 | - geodirectory_load_db_language(); |
|
| 3516 | - } |
|
| 3517 | - |
|
| 3518 | - if (file_exists($language_file)) {
|
|
| 3519 | - /** |
|
| 3520 | - * Language strings from database. |
|
| 3521 | - * |
|
| 3522 | - * @since 1.4.2 |
|
| 3523 | - */ |
|
| 3524 | - try {
|
|
| 3525 | - require_once($language_file); |
|
| 3526 | - } catch(Exception $e) {
|
|
| 3527 | - error_log('Language Error: ' . $e->getMessage());
|
|
| 3528 | - } |
|
| 3529 | - } |
|
| 3518 | + if (file_exists($language_file)) {
|
|
| 3519 | + /** |
|
| 3520 | + * Language strings from database. |
|
| 3521 | + * |
|
| 3522 | + * @since 1.4.2 |
|
| 3523 | + */ |
|
| 3524 | + try {
|
|
| 3525 | + require_once($language_file); |
|
| 3526 | + } catch(Exception $e) {
|
|
| 3527 | + error_log('Language Error: ' . $e->getMessage());
|
|
| 3528 | + } |
|
| 3529 | + } |
|
| 3530 | 3530 | } |
| 3531 | 3531 | |
| 3532 | 3532 | /** |
@@ -3540,66 +3540,66 @@ discard block |
||
| 3540 | 3540 | * @return bool True if file created otherwise false |
| 3541 | 3541 | */ |
| 3542 | 3542 | function geodirectory_load_db_language() {
|
| 3543 | - global $wp_filesystem; |
|
| 3544 | - if( empty( $wp_filesystem ) ) {
|
|
| 3545 | - require_once( ABSPATH .'/wp-admin/includes/file.php' ); |
|
| 3546 | - WP_Filesystem(); |
|
| 3547 | - global $wp_filesystem; |
|
| 3548 | - } |
|
| 3549 | - |
|
| 3550 | - $language_file = geodir_plugin_path() . '/db-language.php'; |
|
| 3551 | - |
|
| 3552 | - if(is_file($language_file) && !is_writable($language_file)) |
|
| 3553 | - return false; // Not possible to create. |
|
| 3554 | - |
|
| 3555 | - if(!is_file($language_file) && !is_writable(dirname($language_file))) |
|
| 3556 | - return false; // Not possible to create. |
|
| 3557 | - |
|
| 3558 | - $contents_strings = array(); |
|
| 3543 | + global $wp_filesystem; |
|
| 3544 | + if( empty( $wp_filesystem ) ) {
|
|
| 3545 | + require_once( ABSPATH .'/wp-admin/includes/file.php' ); |
|
| 3546 | + WP_Filesystem(); |
|
| 3547 | + global $wp_filesystem; |
|
| 3548 | + } |
|
| 3559 | 3549 | |
| 3560 | - /** |
|
| 3561 | - * Filter the language string from database to translate via po editor |
|
| 3562 | - * |
|
| 3563 | - * @since 1.4.2 |
|
| 3564 | - * |
|
| 3565 | - * @param array $contents_strings Array of strings. |
|
| 3566 | - */ |
|
| 3567 | - $contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
|
|
| 3568 | - |
|
| 3569 | - $contents_strings = array_unique($contents_strings); |
|
| 3570 | - |
|
| 3571 | - $contents_head = array(); |
|
| 3572 | - $contents_head[] = "<?php"; |
|
| 3573 | - $contents_head[] = "/**"; |
|
| 3574 | - $contents_head[] = " * Translate language string stored in database. Ex: Custom Fields"; |
|
| 3575 | - $contents_head[] = " *"; |
|
| 3576 | - $contents_head[] = " * @package GeoDirectory"; |
|
| 3577 | - $contents_head[] = " * @since 1.4.2"; |
|
| 3578 | - $contents_head[] = " */"; |
|
| 3579 | - $contents_head[] = ""; |
|
| 3580 | - $contents_head[] = "// Language keys"; |
|
| 3581 | - |
|
| 3582 | - $contents_foot = array(); |
|
| 3583 | - $contents_foot[] = ""; |
|
| 3584 | - $contents_foot[] = ""; |
|
| 3585 | - |
|
| 3586 | - $contents = implode(PHP_EOL, $contents_head); |
|
| 3587 | - |
|
| 3588 | - if (!empty($contents_strings)) {
|
|
| 3589 | - foreach ( $contents_strings as $string ) {
|
|
| 3590 | - if (is_scalar($string) && $string != '') {
|
|
| 3591 | - $string = str_replace("'", "\'", $string);
|
|
| 3592 | - $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
|
|
| 3593 | - } |
|
| 3594 | - } |
|
| 3595 | - } |
|
| 3550 | + $language_file = geodir_plugin_path() . '/db-language.php'; |
|
| 3551 | + |
|
| 3552 | + if(is_file($language_file) && !is_writable($language_file)) |
|
| 3553 | + return false; // Not possible to create. |
|
| 3554 | + |
|
| 3555 | + if(!is_file($language_file) && !is_writable(dirname($language_file))) |
|
| 3556 | + return false; // Not possible to create. |
|
| 3557 | + |
|
| 3558 | + $contents_strings = array(); |
|
| 3559 | + |
|
| 3560 | + /** |
|
| 3561 | + * Filter the language string from database to translate via po editor |
|
| 3562 | + * |
|
| 3563 | + * @since 1.4.2 |
|
| 3564 | + * |
|
| 3565 | + * @param array $contents_strings Array of strings. |
|
| 3566 | + */ |
|
| 3567 | + $contents_strings = apply_filters('geodir_load_db_language', $contents_strings);
|
|
| 3568 | + |
|
| 3569 | + $contents_strings = array_unique($contents_strings); |
|
| 3570 | + |
|
| 3571 | + $contents_head = array(); |
|
| 3572 | + $contents_head[] = "<?php"; |
|
| 3573 | + $contents_head[] = "/**"; |
|
| 3574 | + $contents_head[] = " * Translate language string stored in database. Ex: Custom Fields"; |
|
| 3575 | + $contents_head[] = " *"; |
|
| 3576 | + $contents_head[] = " * @package GeoDirectory"; |
|
| 3577 | + $contents_head[] = " * @since 1.4.2"; |
|
| 3578 | + $contents_head[] = " */"; |
|
| 3579 | + $contents_head[] = ""; |
|
| 3580 | + $contents_head[] = "// Language keys"; |
|
| 3581 | + |
|
| 3582 | + $contents_foot = array(); |
|
| 3583 | + $contents_foot[] = ""; |
|
| 3584 | + $contents_foot[] = ""; |
|
| 3585 | + |
|
| 3586 | + $contents = implode(PHP_EOL, $contents_head); |
|
| 3587 | + |
|
| 3588 | + if (!empty($contents_strings)) {
|
|
| 3589 | + foreach ( $contents_strings as $string ) {
|
|
| 3590 | + if (is_scalar($string) && $string != '') {
|
|
| 3591 | + $string = str_replace("'", "\'", $string);
|
|
| 3592 | + $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
|
|
| 3593 | + } |
|
| 3594 | + } |
|
| 3595 | + } |
|
| 3596 | 3596 | |
| 3597 | - $contents .= implode(PHP_EOL, $contents_foot); |
|
| 3597 | + $contents .= implode(PHP_EOL, $contents_foot); |
|
| 3598 | 3598 | |
| 3599 | - if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) |
|
| 3600 | - return false; // Failure; could not write file. |
|
| 3599 | + if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) |
|
| 3600 | + return false; // Failure; could not write file. |
|
| 3601 | 3601 | |
| 3602 | - return true; |
|
| 3602 | + return true; |
|
| 3603 | 3603 | } |
| 3604 | 3604 | |
| 3605 | 3605 | /** |
@@ -3615,31 +3615,31 @@ discard block |
||
| 3615 | 3615 | * @return array Translation texts. |
| 3616 | 3616 | */ |
| 3617 | 3617 | function geodir_load_custom_field_translation($translation_texts = array()) {
|
| 3618 | - global $wpdb; |
|
| 3618 | + global $wpdb; |
|
| 3619 | 3619 | |
| 3620 | - // Custom fields table |
|
| 3621 | - $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE; |
|
| 3622 | - $rows = $wpdb->get_results($sql); |
|
| 3620 | + // Custom fields table |
|
| 3621 | + $sql = "SELECT admin_title, admin_desc, site_title, clabels, required_msg, default_value, option_values FROM " . GEODIR_CUSTOM_FIELDS_TABLE; |
|
| 3622 | + $rows = $wpdb->get_results($sql); |
|
| 3623 | 3623 | |
| 3624 | - if (!empty($rows)) {
|
|
| 3625 | - foreach($rows as $row) {
|
|
| 3626 | - if (!empty($row->admin_title)) |
|
| 3627 | - $translation_texts[] = stripslashes_deep($row->admin_title); |
|
| 3624 | + if (!empty($rows)) {
|
|
| 3625 | + foreach($rows as $row) {
|
|
| 3626 | + if (!empty($row->admin_title)) |
|
| 3627 | + $translation_texts[] = stripslashes_deep($row->admin_title); |
|
| 3628 | 3628 | |
| 3629 | - if (!empty($row->admin_desc)) |
|
| 3630 | - $translation_texts[] = stripslashes_deep($row->admin_desc); |
|
| 3629 | + if (!empty($row->admin_desc)) |
|
| 3630 | + $translation_texts[] = stripslashes_deep($row->admin_desc); |
|
| 3631 | 3631 | |
| 3632 | - if (!empty($row->site_title)) |
|
| 3633 | - $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3632 | + if (!empty($row->site_title)) |
|
| 3633 | + $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3634 | 3634 | |
| 3635 | - if (!empty($row->clabels)) |
|
| 3636 | - $translation_texts[] = stripslashes_deep($row->clabels); |
|
| 3635 | + if (!empty($row->clabels)) |
|
| 3636 | + $translation_texts[] = stripslashes_deep($row->clabels); |
|
| 3637 | 3637 | |
| 3638 | - if (!empty($row->required_msg)) |
|
| 3639 | - $translation_texts[] = stripslashes_deep($row->required_msg); |
|
| 3638 | + if (!empty($row->required_msg)) |
|
| 3639 | + $translation_texts[] = stripslashes_deep($row->required_msg); |
|
| 3640 | 3640 | |
| 3641 | 3641 | if (!empty($row->default_value)) |
| 3642 | - $translation_texts[] = stripslashes_deep($row->default_value); |
|
| 3642 | + $translation_texts[] = stripslashes_deep($row->default_value); |
|
| 3643 | 3643 | |
| 3644 | 3644 | if (!empty($row->option_values)) {
|
| 3645 | 3645 | $option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values)); |
@@ -3652,25 +3652,25 @@ discard block |
||
| 3652 | 3652 | } |
| 3653 | 3653 | } |
| 3654 | 3654 | } |
| 3655 | - } |
|
| 3656 | - } |
|
| 3655 | + } |
|
| 3656 | + } |
|
| 3657 | 3657 | |
| 3658 | - // Custom sorting fields table |
|
| 3659 | - $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE; |
|
| 3660 | - $rows = $wpdb->get_results($sql); |
|
| 3658 | + // Custom sorting fields table |
|
| 3659 | + $sql = "SELECT site_title, asc_title, desc_title FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE; |
|
| 3660 | + $rows = $wpdb->get_results($sql); |
|
| 3661 | 3661 | |
| 3662 | - if (!empty($rows)) {
|
|
| 3663 | - foreach($rows as $row) {
|
|
| 3664 | - if (!empty($row->site_title)) |
|
| 3665 | - $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3662 | + if (!empty($rows)) {
|
|
| 3663 | + foreach($rows as $row) {
|
|
| 3664 | + if (!empty($row->site_title)) |
|
| 3665 | + $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3666 | 3666 | |
| 3667 | - if (!empty($row->asc_title)) |
|
| 3668 | - $translation_texts[] = stripslashes_deep($row->asc_title); |
|
| 3667 | + if (!empty($row->asc_title)) |
|
| 3668 | + $translation_texts[] = stripslashes_deep($row->asc_title); |
|
| 3669 | 3669 | |
| 3670 | - if (!empty($row->desc_title)) |
|
| 3671 | - $translation_texts[] = stripslashes_deep($row->desc_title); |
|
| 3672 | - } |
|
| 3673 | - } |
|
| 3670 | + if (!empty($row->desc_title)) |
|
| 3671 | + $translation_texts[] = stripslashes_deep($row->desc_title); |
|
| 3672 | + } |
|
| 3673 | + } |
|
| 3674 | 3674 | |
| 3675 | 3675 | // Advance search filter fields table |
| 3676 | 3676 | if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
|
@@ -3691,9 +3691,9 @@ discard block |
||
| 3691 | 3691 | } |
| 3692 | 3692 | } |
| 3693 | 3693 | |
| 3694 | - $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
| 3694 | + $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
| 3695 | 3695 | |
| 3696 | - return $translation_texts; |
|
| 3696 | + return $translation_texts; |
|
| 3697 | 3697 | } |
| 3698 | 3698 | |
| 3699 | 3699 | /** |
@@ -3705,71 +3705,71 @@ discard block |
||
| 3705 | 3705 | * @return array Array of mime types. |
| 3706 | 3706 | */ |
| 3707 | 3707 | function geodir_allowed_mime_types() {
|
| 3708 | - /** |
|
| 3709 | - * Filter the list of mime types and file extensions allowed for file upload. |
|
| 3710 | - * |
|
| 3711 | - * @since 1.4.7 |
|
| 3712 | - * @package GeoDirectory |
|
| 3713 | - * |
|
| 3714 | - * @param array $geodir_allowed_mime_types and file extensions. |
|
| 3715 | - */ |
|
| 3716 | - return apply_filters( 'geodir_allowed_mime_types', array( |
|
| 3717 | - 'Image' => array( // Image formats. |
|
| 3718 | - 'jpg' => 'image/jpeg', |
|
| 3719 | - 'jpe' => 'image/jpeg', |
|
| 3720 | - 'jpeg' => 'image/jpeg', |
|
| 3721 | - 'gif' => 'image/gif', |
|
| 3722 | - 'png' => 'image/png', |
|
| 3723 | - 'bmp' => 'image/bmp', |
|
| 3724 | - 'ico' => 'image/x-icon', |
|
| 3725 | - ), |
|
| 3726 | - 'Video' => array( // Video formats. |
|
| 3727 | - 'asf' => 'video/x-ms-asf', |
|
| 3728 | - 'avi' => 'video/avi', |
|
| 3729 | - 'flv' => 'video/x-flv', |
|
| 3730 | - 'mkv' => 'video/x-matroska', |
|
| 3731 | - 'mp4' => 'video/mp4', |
|
| 3732 | - 'mpeg' => 'video/mpeg', |
|
| 3733 | - 'mpg' => 'video/mpeg', |
|
| 3734 | - 'wmv' => 'video/x-ms-wmv', |
|
| 3735 | - '3gp' => 'video/3gpp', |
|
| 3736 | - ), |
|
| 3737 | - 'Audio' => array( // Audio formats. |
|
| 3738 | - 'ogg' => 'audio/ogg', |
|
| 3739 | - 'mp3' => 'audio/mpeg', |
|
| 3740 | - 'wav' => 'audio/wav', |
|
| 3741 | - 'wma' => 'audio/x-ms-wma', |
|
| 3742 | - ), |
|
| 3743 | - 'Text' => array( // Text formats. |
|
| 3744 | - 'css' => 'text/css', |
|
| 3745 | - 'csv' => 'text/csv', |
|
| 3746 | - 'htm' => 'text/html', |
|
| 3747 | - 'html' => 'text/html', |
|
| 3748 | - 'txt' => 'text/plain', |
|
| 3749 | - 'rtx' => 'text/richtext', |
|
| 3750 | - 'vtt' => 'text/vtt', |
|
| 3751 | - ), |
|
| 3752 | - 'Application' => array( // Application formats. |
|
| 3753 | - 'doc' => 'application/msword', |
|
| 3754 | - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', |
|
| 3755 | - 'exe' => 'application/x-msdownload', |
|
| 3756 | - 'js' => 'application/javascript', |
|
| 3757 | - 'odt' => 'application/vnd.oasis.opendocument.text', |
|
| 3758 | - 'pdf' => 'application/pdf', |
|
| 3759 | - 'pot' => 'application/vnd.ms-powerpoint', |
|
| 3760 | - 'ppt' => 'application/vnd.ms-powerpoint', |
|
| 3761 | - 'pptx' => 'application/vnd.ms-powerpoint', |
|
| 3762 | - 'psd' => 'application/octet-stream', |
|
| 3763 | - 'rar' => 'application/rar', |
|
| 3764 | - 'rtf' => 'application/rtf', |
|
| 3765 | - 'swf' => 'application/x-shockwave-flash', |
|
| 3766 | - 'tar' => 'application/x-tar', |
|
| 3767 | - 'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
|
| 3768 | - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
|
| 3769 | - 'zip' => 'application/zip', |
|
| 3770 | - ) |
|
| 3771 | - ) |
|
| 3772 | - ); |
|
| 3708 | + /** |
|
| 3709 | + * Filter the list of mime types and file extensions allowed for file upload. |
|
| 3710 | + * |
|
| 3711 | + * @since 1.4.7 |
|
| 3712 | + * @package GeoDirectory |
|
| 3713 | + * |
|
| 3714 | + * @param array $geodir_allowed_mime_types and file extensions. |
|
| 3715 | + */ |
|
| 3716 | + return apply_filters( 'geodir_allowed_mime_types', array( |
|
| 3717 | + 'Image' => array( // Image formats. |
|
| 3718 | + 'jpg' => 'image/jpeg', |
|
| 3719 | + 'jpe' => 'image/jpeg', |
|
| 3720 | + 'jpeg' => 'image/jpeg', |
|
| 3721 | + 'gif' => 'image/gif', |
|
| 3722 | + 'png' => 'image/png', |
|
| 3723 | + 'bmp' => 'image/bmp', |
|
| 3724 | + 'ico' => 'image/x-icon', |
|
| 3725 | + ), |
|
| 3726 | + 'Video' => array( // Video formats. |
|
| 3727 | + 'asf' => 'video/x-ms-asf', |
|
| 3728 | + 'avi' => 'video/avi', |
|
| 3729 | + 'flv' => 'video/x-flv', |
|
| 3730 | + 'mkv' => 'video/x-matroska', |
|
| 3731 | + 'mp4' => 'video/mp4', |
|
| 3732 | + 'mpeg' => 'video/mpeg', |
|
| 3733 | + 'mpg' => 'video/mpeg', |
|
| 3734 | + 'wmv' => 'video/x-ms-wmv', |
|
| 3735 | + '3gp' => 'video/3gpp', |
|
| 3736 | + ), |
|
| 3737 | + 'Audio' => array( // Audio formats. |
|
| 3738 | + 'ogg' => 'audio/ogg', |
|
| 3739 | + 'mp3' => 'audio/mpeg', |
|
| 3740 | + 'wav' => 'audio/wav', |
|
| 3741 | + 'wma' => 'audio/x-ms-wma', |
|
| 3742 | + ), |
|
| 3743 | + 'Text' => array( // Text formats. |
|
| 3744 | + 'css' => 'text/css', |
|
| 3745 | + 'csv' => 'text/csv', |
|
| 3746 | + 'htm' => 'text/html', |
|
| 3747 | + 'html' => 'text/html', |
|
| 3748 | + 'txt' => 'text/plain', |
|
| 3749 | + 'rtx' => 'text/richtext', |
|
| 3750 | + 'vtt' => 'text/vtt', |
|
| 3751 | + ), |
|
| 3752 | + 'Application' => array( // Application formats. |
|
| 3753 | + 'doc' => 'application/msword', |
|
| 3754 | + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', |
|
| 3755 | + 'exe' => 'application/x-msdownload', |
|
| 3756 | + 'js' => 'application/javascript', |
|
| 3757 | + 'odt' => 'application/vnd.oasis.opendocument.text', |
|
| 3758 | + 'pdf' => 'application/pdf', |
|
| 3759 | + 'pot' => 'application/vnd.ms-powerpoint', |
|
| 3760 | + 'ppt' => 'application/vnd.ms-powerpoint', |
|
| 3761 | + 'pptx' => 'application/vnd.ms-powerpoint', |
|
| 3762 | + 'psd' => 'application/octet-stream', |
|
| 3763 | + 'rar' => 'application/rar', |
|
| 3764 | + 'rtf' => 'application/rtf', |
|
| 3765 | + 'swf' => 'application/x-shockwave-flash', |
|
| 3766 | + 'tar' => 'application/x-tar', |
|
| 3767 | + 'xls' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
|
| 3768 | + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', |
|
| 3769 | + 'zip' => 'application/zip', |
|
| 3770 | + ) |
|
| 3771 | + ) |
|
| 3772 | + ); |
|
| 3773 | 3773 | } |
| 3774 | 3774 | |
| 3775 | 3775 | /** |
@@ -3781,21 +3781,21 @@ discard block |
||
| 3781 | 3781 | * @return string User display name. |
| 3782 | 3782 | */ |
| 3783 | 3783 | function geodir_get_client_name($user_id) {
|
| 3784 | - $client_name = ''; |
|
| 3784 | + $client_name = ''; |
|
| 3785 | 3785 | |
| 3786 | - $user_data = get_userdata($user_id); |
|
| 3786 | + $user_data = get_userdata($user_id); |
|
| 3787 | 3787 | |
| 3788 | - if (!empty($user_data)) {
|
|
| 3789 | - if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
|
|
| 3790 | - $client_name = trim($user_data->display_name); |
|
| 3791 | - } else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
|
|
| 3792 | - $client_name = trim($user_data->user_nicename); |
|
| 3793 | - } else {
|
|
| 3794 | - $client_name = trim($user_data->user_login); |
|
| 3795 | - } |
|
| 3796 | - } |
|
| 3788 | + if (!empty($user_data)) {
|
|
| 3789 | + if (isset($user_data->display_name) && trim($user_data->display_name) != '') {
|
|
| 3790 | + $client_name = trim($user_data->display_name); |
|
| 3791 | + } else if (isset($user_data->user_nicename) && trim($user_data->user_nicename) != '') {
|
|
| 3792 | + $client_name = trim($user_data->user_nicename); |
|
| 3793 | + } else {
|
|
| 3794 | + $client_name = trim($user_data->user_login); |
|
| 3795 | + } |
|
| 3796 | + } |
|
| 3797 | 3797 | |
| 3798 | - return $client_name; |
|
| 3798 | + return $client_name; |
|
| 3799 | 3799 | } |
| 3800 | 3800 | |
| 3801 | 3801 | |
@@ -3810,125 +3810,125 @@ discard block |
||
| 3810 | 3810 | */ |
| 3811 | 3811 | function geodir_wpseo_replacements($vars){
|
| 3812 | 3812 | |
| 3813 | - global $wp; |
|
| 3814 | - $title = ''; |
|
| 3815 | - // location variables |
|
| 3816 | - $gd_post_type = geodir_get_current_posttype(); |
|
| 3817 | - $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 3818 | - /** |
|
| 3819 | - * Filter the title variables location variables array |
|
| 3820 | - * |
|
| 3821 | - * @since 1.5.5 |
|
| 3822 | - * @package GeoDirectory |
|
| 3823 | - * @param array $location_array The array of location variables. |
|
| 3824 | - * @param array $vars The page title variables. |
|
| 3825 | - */ |
|
| 3826 | - $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
|
|
| 3827 | - $location_titles = array(); |
|
| 3828 | - if(get_query_var( 'gd_country_full' )){
|
|
| 3829 | - if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
|
|
| 3830 | - if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
|
|
| 3831 | - if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
|
|
| 3832 | - } |
|
| 3833 | - $location_single = ''; |
|
| 3834 | - $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
| 3835 | - $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
| 3836 | - $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
| 3837 | - |
|
| 3838 | - $gd_country_actual = $gd_region_actual = $gd_city_actual = ''; |
|
| 3839 | - |
|
| 3840 | - if (function_exists('get_actual_location_name')) {
|
|
| 3841 | - $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
|
|
| 3842 | - $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
|
|
| 3843 | - $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
|
|
| 3844 | - } |
|
| 3845 | - |
|
| 3846 | - if ($gd_city != '') {
|
|
| 3847 | - if ($gd_city_actual != '') {
|
|
| 3848 | - $gd_city = $gd_city_actual; |
|
| 3849 | - } else {
|
|
| 3850 | - $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
|
|
| 3851 | - $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
|
|
| 3852 | - $gd_city = __(geodir_ucwords($gd_city), 'geodirectory'); |
|
| 3853 | - } |
|
| 3854 | - $location_single = $gd_city; |
|
| 3855 | - |
|
| 3856 | - } else if ($gd_region != '') {
|
|
| 3857 | - if ($gd_region_actual != '') {
|
|
| 3858 | - $gd_region = $gd_region_actual; |
|
| 3859 | - } else {
|
|
| 3860 | - $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
|
|
| 3861 | - $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
|
|
| 3862 | - $gd_region = __(geodir_ucwords($gd_region), 'geodirectory'); |
|
| 3863 | - } |
|
| 3813 | + global $wp; |
|
| 3814 | + $title = ''; |
|
| 3815 | + // location variables |
|
| 3816 | + $gd_post_type = geodir_get_current_posttype(); |
|
| 3817 | + $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 3818 | + /** |
|
| 3819 | + * Filter the title variables location variables array |
|
| 3820 | + * |
|
| 3821 | + * @since 1.5.5 |
|
| 3822 | + * @package GeoDirectory |
|
| 3823 | + * @param array $location_array The array of location variables. |
|
| 3824 | + * @param array $vars The page title variables. |
|
| 3825 | + */ |
|
| 3826 | + $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
|
|
| 3827 | + $location_titles = array(); |
|
| 3828 | + if(get_query_var( 'gd_country_full' )){
|
|
| 3829 | + if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
|
|
| 3830 | + if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
|
|
| 3831 | + if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
|
|
| 3832 | + } |
|
| 3833 | + $location_single = ''; |
|
| 3834 | + $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
| 3835 | + $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
| 3836 | + $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
| 3864 | 3837 | |
| 3865 | - $location_single = $gd_region; |
|
| 3866 | - } else if ($gd_country != '') {
|
|
| 3867 | - if ($gd_country_actual != '') {
|
|
| 3868 | - $gd_country = $gd_country_actual; |
|
| 3869 | - } else {
|
|
| 3870 | - $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
|
|
| 3871 | - $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
|
|
| 3872 | - $gd_country = __(geodir_ucwords($gd_country), 'geodirectory'); |
|
| 3873 | - } |
|
| 3838 | + $gd_country_actual = $gd_region_actual = $gd_city_actual = ''; |
|
| 3874 | 3839 | |
| 3875 | - $location_single = $gd_country; |
|
| 3876 | - } |
|
| 3840 | + if (function_exists('get_actual_location_name')) {
|
|
| 3841 | + $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
|
|
| 3842 | + $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
|
|
| 3843 | + $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
|
|
| 3844 | + } |
|
| 3877 | 3845 | |
| 3878 | - if (!empty($location_array)) {
|
|
| 3846 | + if ($gd_city != '') {
|
|
| 3847 | + if ($gd_city_actual != '') {
|
|
| 3848 | + $gd_city = $gd_city_actual; |
|
| 3849 | + } else {
|
|
| 3850 | + $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
|
|
| 3851 | + $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
|
|
| 3852 | + $gd_city = __(geodir_ucwords($gd_city), 'geodirectory'); |
|
| 3853 | + } |
|
| 3854 | + $location_single = $gd_city; |
|
| 3855 | + |
|
| 3856 | + } else if ($gd_region != '') {
|
|
| 3857 | + if ($gd_region_actual != '') {
|
|
| 3858 | + $gd_region = $gd_region_actual; |
|
| 3859 | + } else {
|
|
| 3860 | + $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
|
|
| 3861 | + $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
|
|
| 3862 | + $gd_region = __(geodir_ucwords($gd_region), 'geodirectory'); |
|
| 3863 | + } |
|
| 3879 | 3864 | |
| 3880 | - $actual_location_name = function_exists('get_actual_location_name') ? true : false;
|
|
| 3881 | - $location_array = array_reverse($location_array); |
|
| 3865 | + $location_single = $gd_region; |
|
| 3866 | + } else if ($gd_country != '') {
|
|
| 3867 | + if ($gd_country_actual != '') {
|
|
| 3868 | + $gd_country = $gd_country_actual; |
|
| 3869 | + } else {
|
|
| 3870 | + $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
|
|
| 3871 | + $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
|
|
| 3872 | + $gd_country = __(geodir_ucwords($gd_country), 'geodirectory'); |
|
| 3873 | + } |
|
| 3882 | 3874 | |
| 3883 | - foreach ($location_array as $location_type => $location) {
|
|
| 3884 | - $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
|
|
| 3885 | - $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
|
|
| 3875 | + $location_single = $gd_country; |
|
| 3876 | + } |
|
| 3886 | 3877 | |
| 3887 | - $location_name = geodir_ucwords($gd_location_link_text); |
|
| 3888 | - $location_name = __($location_name, 'geodirectory'); |
|
| 3878 | + if (!empty($location_array)) {
|
|
| 3889 | 3879 | |
| 3890 | - if ($actual_location_name) {
|
|
| 3891 | - $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type; |
|
| 3892 | - $location_name = get_actual_location_name($location_type, $location, true); |
|
| 3893 | - } |
|
| 3880 | + $actual_location_name = function_exists('get_actual_location_name') ? true : false;
|
|
| 3881 | + $location_array = array_reverse($location_array); |
|
| 3894 | 3882 | |
| 3895 | - $location_titles[] = $location_name; |
|
| 3896 | - } |
|
| 3897 | - if (!empty($location_titles)) {
|
|
| 3898 | - $location_titles = array_unique($location_titles); |
|
| 3899 | - } |
|
| 3900 | - } |
|
| 3883 | + foreach ($location_array as $location_type => $location) {
|
|
| 3884 | + $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
|
|
| 3885 | + $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
|
|
| 3901 | 3886 | |
| 3887 | + $location_name = geodir_ucwords($gd_location_link_text); |
|
| 3888 | + $location_name = __($location_name, 'geodirectory'); |
|
| 3902 | 3889 | |
| 3903 | - if(!empty($location_titles)) {
|
|
| 3904 | - $vars['%%location%%'] = implode(", ", $location_titles);
|
|
| 3905 | - } |
|
| 3890 | + if ($actual_location_name) {
|
|
| 3891 | + $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type; |
|
| 3892 | + $location_name = get_actual_location_name($location_type, $location, true); |
|
| 3893 | + } |
|
| 3894 | + |
|
| 3895 | + $location_titles[] = $location_name; |
|
| 3896 | + } |
|
| 3897 | + if (!empty($location_titles)) {
|
|
| 3898 | + $location_titles = array_unique($location_titles); |
|
| 3899 | + } |
|
| 3900 | + } |
|
| 3906 | 3901 | |
| 3907 | 3902 | |
| 3908 | - if(!empty($location_titles)) {
|
|
| 3909 | - $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
|
|
| 3910 | - } |
|
| 3903 | + if(!empty($location_titles)) {
|
|
| 3904 | + $vars['%%location%%'] = implode(", ", $location_titles);
|
|
| 3905 | + } |
|
| 3911 | 3906 | |
| 3912 | 3907 | |
| 3908 | + if(!empty($location_titles)) {
|
|
| 3909 | + $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
|
|
| 3910 | + } |
|
| 3913 | 3911 | |
| 3914 | - if($location_single) {
|
|
| 3915 | - $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
|
|
| 3916 | - } |
|
| 3917 | 3912 | |
| 3918 | 3913 | |
| 3919 | - if($location_single) {
|
|
| 3920 | - $vars['%%location_single%%'] = $location_single; |
|
| 3921 | - } |
|
| 3914 | + if($location_single) {
|
|
| 3915 | + $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
|
|
| 3916 | + } |
|
| 3922 | 3917 | |
| 3923 | - /** |
|
| 3924 | - * Filter the title variables after standard ones have been filtered for wpseo. |
|
| 3925 | - * |
|
| 3926 | - * @since 1.5.7 |
|
| 3927 | - * @package GeoDirectory |
|
| 3928 | - * @param string $vars The title with variables. |
|
| 3929 | - * @param array $location_array The array of location variables. |
|
| 3930 | - */ |
|
| 3931 | - return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
|
|
| 3918 | + |
|
| 3919 | + if($location_single) {
|
|
| 3920 | + $vars['%%location_single%%'] = $location_single; |
|
| 3921 | + } |
|
| 3922 | + |
|
| 3923 | + /** |
|
| 3924 | + * Filter the title variables after standard ones have been filtered for wpseo. |
|
| 3925 | + * |
|
| 3926 | + * @since 1.5.7 |
|
| 3927 | + * @package GeoDirectory |
|
| 3928 | + * @param string $vars The title with variables. |
|
| 3929 | + * @param array $location_array The array of location variables. |
|
| 3930 | + */ |
|
| 3931 | + return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
|
|
| 3932 | 3932 | } |
| 3933 | 3933 | |
| 3934 | 3934 | |
@@ -3938,10 +3938,10 @@ discard block |
||
| 3938 | 3938 | function geodir_filter_title_variables($title, $gd_page, $sep=''){
|
| 3939 | 3939 | |
| 3940 | 3940 | |
| 3941 | - if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
|
|
| 3942 | - global $post; |
|
| 3943 | - //print_r($post); |
|
| 3944 | - /* |
|
| 3941 | + if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
|
|
| 3942 | + global $post; |
|
| 3943 | + //print_r($post); |
|
| 3944 | + /* |
|
| 3945 | 3945 | %%date%% Replaced with the date of the post/page |
| 3946 | 3946 | %%title%% Replaced with the title of the post/page |
| 3947 | 3947 | %%sitename%% The site's name |
@@ -3968,134 +3968,134 @@ discard block |
||
| 3968 | 3968 | %%pagenumber%% Replaced with the current page number |
| 3969 | 3969 | */ |
| 3970 | 3970 | |
| 3971 | - if ($sep == '') {
|
|
| 3972 | - /** |
|
| 3973 | - * Filter the page title separator. |
|
| 3974 | - * |
|
| 3975 | - * @since 1.0.0 |
|
| 3976 | - * @package GeoDirectory |
|
| 3977 | - * @param string $sep The separator, default: `|`. |
|
| 3978 | - */ |
|
| 3979 | - $sep = apply_filters('geodir_page_title_separator', '|');
|
|
| 3980 | - } |
|
| 3981 | - |
|
| 3982 | - |
|
| 3983 | - if(strpos($title,'%%title%%') !== false){
|
|
| 3984 | - $title = str_replace("%%title%%",$post->post_title,$title);
|
|
| 3985 | - } |
|
| 3986 | - |
|
| 3987 | - if(strpos($title,'%%sitename%%') !== false){
|
|
| 3988 | - $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
|
|
| 3989 | - } |
|
| 3990 | - |
|
| 3991 | - if(strpos($title,'%%sitedesc%%') !== false){
|
|
| 3992 | - $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
|
|
| 3993 | - } |
|
| 3994 | - |
|
| 3995 | - if(strpos($title,'%%excerpt%%') !== false){
|
|
| 3996 | - $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
|
|
| 3997 | - } |
|
| 3998 | - |
|
| 3999 | - if(strpos($title,'%%pt_single%%') !== false){
|
|
| 4000 | - $single_name = ''; |
|
| 4001 | - if($gd_page=='search' || $gd_page=='author'){
|
|
| 4002 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 4003 | - $spt = esc_attr($_REQUEST['stype']); |
|
| 4004 | - if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
|
| 4005 | - $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
|
| 4006 | - } |
|
| 4007 | - }elseif($gd_page=='add-listing'){
|
|
| 4008 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 4009 | - $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : ''; |
|
| 4010 | - if(!$spt && isset($_REQUEST['pid'])){
|
|
| 4011 | - $spt = get_post_type( $_REQUEST['pid'] ); |
|
| 4012 | - } |
|
| 4013 | - if(!$spt){$spt='gd_place';}
|
|
| 4014 | - if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
|
| 4015 | - $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
|
| 4016 | - } |
|
| 4017 | - } |
|
| 4018 | - elseif($post->post_type){
|
|
| 4019 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 4020 | - if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
|
|
| 4021 | - $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory'); |
|
| 4022 | - } |
|
| 3971 | + if ($sep == '') {
|
|
| 3972 | + /** |
|
| 3973 | + * Filter the page title separator. |
|
| 3974 | + * |
|
| 3975 | + * @since 1.0.0 |
|
| 3976 | + * @package GeoDirectory |
|
| 3977 | + * @param string $sep The separator, default: `|`. |
|
| 3978 | + */ |
|
| 3979 | + $sep = apply_filters('geodir_page_title_separator', '|');
|
|
| 3980 | + } |
|
| 4023 | 3981 | |
| 4024 | 3982 | |
| 4025 | - } |
|
| 4026 | - $title = str_replace("%%pt_single%%",$single_name,$title);
|
|
| 4027 | - } |
|
| 4028 | - |
|
| 4029 | - if(strpos($title,'%%pt_plural%%') !== false){
|
|
| 4030 | - $plural_name = ''; |
|
| 4031 | - if($gd_page=='search' || $gd_page=='author'){
|
|
| 4032 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 4033 | - $spt = esc_attr($_REQUEST['stype']); |
|
| 4034 | - if(isset($geodir_post_types[$spt]['labels']['name'])){
|
|
| 4035 | - $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
|
| 4036 | - } |
|
| 4037 | - }elseif($gd_page=='add-listing'){
|
|
| 4038 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 4039 | - $spt = sanitize_text_field($_REQUEST['listing_type']); |
|
| 4040 | - if(!$spt){$spt='gd_place';}
|
|
| 4041 | - if(isset($geodir_post_types[$spt]['labels']['name'])){
|
|
| 4042 | - $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
|
| 4043 | - } |
|
| 4044 | - } |
|
| 4045 | - elseif(isset($post->post_type) && $post->post_type){
|
|
| 4046 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 4047 | - if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
|
|
| 4048 | - $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory'); |
|
| 4049 | - } |
|
| 3983 | + if(strpos($title,'%%title%%') !== false){
|
|
| 3984 | + $title = str_replace("%%title%%",$post->post_title,$title);
|
|
| 3985 | + } |
|
| 4050 | 3986 | |
| 4051 | - } |
|
| 4052 | - $title = str_replace("%%pt_plural%%",$plural_name,$title);
|
|
| 4053 | - } |
|
| 3987 | + if(strpos($title,'%%sitename%%') !== false){
|
|
| 3988 | + $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
|
|
| 3989 | + } |
|
| 3990 | + |
|
| 3991 | + if(strpos($title,'%%sitedesc%%') !== false){
|
|
| 3992 | + $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
|
|
| 3993 | + } |
|
| 4054 | 3994 | |
| 3995 | + if(strpos($title,'%%excerpt%%') !== false){
|
|
| 3996 | + $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
|
|
| 3997 | + } |
|
| 4055 | 3998 | |
| 3999 | + if(strpos($title,'%%pt_single%%') !== false){
|
|
| 4000 | + $single_name = ''; |
|
| 4001 | + if($gd_page=='search' || $gd_page=='author'){
|
|
| 4002 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 4003 | + $spt = esc_attr($_REQUEST['stype']); |
|
| 4004 | + if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
|
| 4005 | + $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
|
| 4006 | + } |
|
| 4007 | + }elseif($gd_page=='add-listing'){
|
|
| 4008 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 4009 | + $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : ''; |
|
| 4010 | + if(!$spt && isset($_REQUEST['pid'])){
|
|
| 4011 | + $spt = get_post_type( $_REQUEST['pid'] ); |
|
| 4012 | + } |
|
| 4013 | + if(!$spt){$spt='gd_place';}
|
|
| 4014 | + if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
|
| 4015 | + $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
|
| 4016 | + } |
|
| 4017 | + } |
|
| 4018 | + elseif($post->post_type){
|
|
| 4019 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 4020 | + if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
|
|
| 4021 | + $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory'); |
|
| 4022 | + } |
|
| 4056 | 4023 | |
| 4057 | - if(strpos($title,'%%category%%') !== false){
|
|
| 4058 | - $cat_name = ''; |
|
| 4059 | 4024 | |
| 4060 | - if($gd_page=='detail') {
|
|
| 4061 | - if ($post->default_category) {
|
|
| 4062 | - $cat = get_term($post->default_category, $post->post_type . 'category'); |
|
| 4063 | - $cat_name = (isset($cat->name)) ? $cat->name : ''; |
|
| 4064 | - } |
|
| 4065 | - }elseif($gd_page=='listing'){
|
|
| 4066 | - $queried_object = get_queried_object(); |
|
| 4067 | - if(isset($queried_object->name)){
|
|
| 4068 | - $cat_name = $queried_object->name; |
|
| 4069 | - } |
|
| 4070 | - } |
|
| 4071 | - $title = str_replace("%%category%%",$cat_name,$title);
|
|
| 4072 | - } |
|
| 4073 | - |
|
| 4074 | - if(strpos($title,'%%tag%%') !== false){
|
|
| 4075 | - $cat_name = ''; |
|
| 4076 | - |
|
| 4077 | - if($gd_page=='detail') {
|
|
| 4078 | - if ($post->default_category) {
|
|
| 4079 | - $cat = get_term($post->default_category, $post->post_type . 'category'); |
|
| 4080 | - $cat_name = (isset($cat->name)) ? $cat->name : ''; |
|
| 4081 | - } |
|
| 4082 | - }elseif($gd_page=='listing'){
|
|
| 4083 | - $queried_object = get_queried_object(); |
|
| 4084 | - if(isset($queried_object->name)){
|
|
| 4085 | - $cat_name = $queried_object->name; |
|
| 4086 | - } |
|
| 4087 | - } |
|
| 4088 | - $title = str_replace("%%tag%%",$cat_name,$title);
|
|
| 4089 | - } |
|
| 4025 | + } |
|
| 4026 | + $title = str_replace("%%pt_single%%",$single_name,$title);
|
|
| 4027 | + } |
|
| 4028 | + |
|
| 4029 | + if(strpos($title,'%%pt_plural%%') !== false){
|
|
| 4030 | + $plural_name = ''; |
|
| 4031 | + if($gd_page=='search' || $gd_page=='author'){
|
|
| 4032 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 4033 | + $spt = esc_attr($_REQUEST['stype']); |
|
| 4034 | + if(isset($geodir_post_types[$spt]['labels']['name'])){
|
|
| 4035 | + $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
|
| 4036 | + } |
|
| 4037 | + }elseif($gd_page=='add-listing'){
|
|
| 4038 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 4039 | + $spt = sanitize_text_field($_REQUEST['listing_type']); |
|
| 4040 | + if(!$spt){$spt='gd_place';}
|
|
| 4041 | + if(isset($geodir_post_types[$spt]['labels']['name'])){
|
|
| 4042 | + $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
|
| 4043 | + } |
|
| 4044 | + } |
|
| 4045 | + elseif(isset($post->post_type) && $post->post_type){
|
|
| 4046 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 4047 | + if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
|
|
| 4048 | + $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory'); |
|
| 4049 | + } |
|
| 4050 | + |
|
| 4051 | + } |
|
| 4052 | + $title = str_replace("%%pt_plural%%",$plural_name,$title);
|
|
| 4053 | + } |
|
| 4054 | + |
|
| 4055 | + |
|
| 4056 | + |
|
| 4057 | + if(strpos($title,'%%category%%') !== false){
|
|
| 4058 | + $cat_name = ''; |
|
| 4059 | + |
|
| 4060 | + if($gd_page=='detail') {
|
|
| 4061 | + if ($post->default_category) {
|
|
| 4062 | + $cat = get_term($post->default_category, $post->post_type . 'category'); |
|
| 4063 | + $cat_name = (isset($cat->name)) ? $cat->name : ''; |
|
| 4064 | + } |
|
| 4065 | + }elseif($gd_page=='listing'){
|
|
| 4066 | + $queried_object = get_queried_object(); |
|
| 4067 | + if(isset($queried_object->name)){
|
|
| 4068 | + $cat_name = $queried_object->name; |
|
| 4069 | + } |
|
| 4070 | + } |
|
| 4071 | + $title = str_replace("%%category%%",$cat_name,$title);
|
|
| 4072 | + } |
|
| 4073 | + |
|
| 4074 | + if(strpos($title,'%%tag%%') !== false){
|
|
| 4075 | + $cat_name = ''; |
|
| 4076 | + |
|
| 4077 | + if($gd_page=='detail') {
|
|
| 4078 | + if ($post->default_category) {
|
|
| 4079 | + $cat = get_term($post->default_category, $post->post_type . 'category'); |
|
| 4080 | + $cat_name = (isset($cat->name)) ? $cat->name : ''; |
|
| 4081 | + } |
|
| 4082 | + }elseif($gd_page=='listing'){
|
|
| 4083 | + $queried_object = get_queried_object(); |
|
| 4084 | + if(isset($queried_object->name)){
|
|
| 4085 | + $cat_name = $queried_object->name; |
|
| 4086 | + } |
|
| 4087 | + } |
|
| 4088 | + $title = str_replace("%%tag%%",$cat_name,$title);
|
|
| 4089 | + } |
|
| 4090 | 4090 | |
| 4091 | 4091 | |
| 4092 | 4092 | |
| 4093 | - if(strpos($title,'%%id%%') !== false){
|
|
| 4094 | - $ID = (isset($post->ID)) ? $post->ID : ''; |
|
| 4095 | - $title = str_replace("%%id%%",$ID,$title);
|
|
| 4096 | - } |
|
| 4093 | + if(strpos($title,'%%id%%') !== false){
|
|
| 4094 | + $ID = (isset($post->ID)) ? $post->ID : ''; |
|
| 4095 | + $title = str_replace("%%id%%",$ID,$title);
|
|
| 4096 | + } |
|
| 4097 | 4097 | |
| 4098 | - /* |
|
| 4098 | + /* |
|
| 4099 | 4099 | if(strpos($title,'') !== false){
|
| 4100 | 4100 | $title = str_replace("",,$title);
|
| 4101 | 4101 | } |
@@ -4105,174 +4105,174 @@ discard block |
||
| 4105 | 4105 | } |
| 4106 | 4106 | */ |
| 4107 | 4107 | |
| 4108 | - if(strpos($title,'%%sep%%') !== false){
|
|
| 4109 | - $title = str_replace("%%sep%%",$sep,$title);
|
|
| 4110 | - } |
|
| 4111 | - |
|
| 4112 | - |
|
| 4113 | - global $wp; |
|
| 4114 | - // location variables |
|
| 4115 | - $gd_post_type = geodir_get_current_posttype(); |
|
| 4116 | - $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 4117 | - /** |
|
| 4118 | - * Filter the title variables location variables array |
|
| 4119 | - * |
|
| 4120 | - * @since 1.5.5 |
|
| 4121 | - * @package GeoDirectory |
|
| 4122 | - * @param array $location_array The array of location variables. |
|
| 4123 | - * @param string $title The title with variables.. |
|
| 4124 | - * @param string $gd_page The page being filtered. |
|
| 4125 | - * @param string $sep The separator, default: `|`. |
|
| 4126 | - */ |
|
| 4127 | - $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
|
|
| 4128 | - $location_titles = array(); |
|
| 4129 | - if($gd_page=='location' && get_query_var( 'gd_country_full' )){
|
|
| 4130 | - if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
|
|
| 4131 | - if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
|
|
| 4132 | - if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
|
|
| 4133 | - } |
|
| 4134 | - $location_single = ''; |
|
| 4135 | - $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
| 4136 | - $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
| 4137 | - $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
| 4138 | - |
|
| 4139 | - $gd_country_actual = $gd_region_actual = $gd_city_actual = ''; |
|
| 4140 | - |
|
| 4141 | - if (function_exists('get_actual_location_name')) {
|
|
| 4142 | - $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
|
|
| 4143 | - $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
|
|
| 4144 | - $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
|
|
| 4145 | - } |
|
| 4146 | - |
|
| 4147 | - if ($gd_city != '') {
|
|
| 4148 | - if ($gd_city_actual != '') {
|
|
| 4149 | - $gd_city = $gd_city_actual; |
|
| 4150 | - } else {
|
|
| 4151 | - $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
|
|
| 4152 | - $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
|
|
| 4153 | - $gd_city = __(geodir_ucwords($gd_city), 'geodirectory'); |
|
| 4154 | - } |
|
| 4155 | - $location_single = $gd_city; |
|
| 4156 | - |
|
| 4157 | - } else if ($gd_region != '') {
|
|
| 4158 | - if ($gd_region_actual != '') {
|
|
| 4159 | - $gd_region = $gd_region_actual; |
|
| 4160 | - } else {
|
|
| 4161 | - $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
|
|
| 4162 | - $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
|
|
| 4163 | - $gd_region = __(geodir_ucwords($gd_region), 'geodirectory'); |
|
| 4164 | - } |
|
| 4108 | + if(strpos($title,'%%sep%%') !== false){
|
|
| 4109 | + $title = str_replace("%%sep%%",$sep,$title);
|
|
| 4110 | + } |
|
| 4165 | 4111 | |
| 4166 | - $location_single = $gd_region; |
|
| 4167 | - } else if ($gd_country != '') {
|
|
| 4168 | - if ($gd_country_actual != '') {
|
|
| 4169 | - $gd_country = $gd_country_actual; |
|
| 4170 | - } else {
|
|
| 4171 | - $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
|
|
| 4172 | - $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
|
|
| 4173 | - $gd_country = __(geodir_ucwords($gd_country), 'geodirectory'); |
|
| 4174 | - } |
|
| 4175 | 4112 | |
| 4176 | - $location_single = $gd_country; |
|
| 4177 | - } |
|
| 4113 | + global $wp; |
|
| 4114 | + // location variables |
|
| 4115 | + $gd_post_type = geodir_get_current_posttype(); |
|
| 4116 | + $location_array = geodir_get_current_location_terms('query_vars', $gd_post_type);
|
|
| 4117 | + /** |
|
| 4118 | + * Filter the title variables location variables array |
|
| 4119 | + * |
|
| 4120 | + * @since 1.5.5 |
|
| 4121 | + * @package GeoDirectory |
|
| 4122 | + * @param array $location_array The array of location variables. |
|
| 4123 | + * @param string $title The title with variables.. |
|
| 4124 | + * @param string $gd_page The page being filtered. |
|
| 4125 | + * @param string $sep The separator, default: `|`. |
|
| 4126 | + */ |
|
| 4127 | + $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
|
|
| 4128 | + $location_titles = array(); |
|
| 4129 | + if($gd_page=='location' && get_query_var( 'gd_country_full' )){
|
|
| 4130 | + if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
|
|
| 4131 | + if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
|
|
| 4132 | + if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
|
|
| 4133 | + } |
|
| 4134 | + $location_single = ''; |
|
| 4135 | + $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
|
| 4136 | + $gd_region = (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') ? $wp->query_vars['gd_region'] : ''; |
|
| 4137 | + $gd_city = (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') ? $wp->query_vars['gd_city'] : ''; |
|
| 4178 | 4138 | |
| 4179 | - if (!empty($location_array)) {
|
|
| 4139 | + $gd_country_actual = $gd_region_actual = $gd_city_actual = ''; |
|
| 4180 | 4140 | |
| 4181 | - $actual_location_name = function_exists('get_actual_location_name') ? true : false;
|
|
| 4182 | - $location_array = array_reverse($location_array); |
|
| 4141 | + if (function_exists('get_actual_location_name')) {
|
|
| 4142 | + $gd_country_actual = $gd_country != '' ? get_actual_location_name('country', $gd_country, true) : $gd_country;
|
|
| 4143 | + $gd_region_actual = $gd_region != '' ? get_actual_location_name('region', $gd_region) : $gd_region;
|
|
| 4144 | + $gd_city_actual = $gd_city != '' ? get_actual_location_name('city', $gd_city) : $gd_city;
|
|
| 4145 | + } |
|
| 4183 | 4146 | |
| 4184 | - foreach ($location_array as $location_type => $location) {
|
|
| 4185 | - $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
|
|
| 4186 | - $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
|
|
| 4147 | + if ($gd_city != '') {
|
|
| 4148 | + if ($gd_city_actual != '') {
|
|
| 4149 | + $gd_city = $gd_city_actual; |
|
| 4150 | + } else {
|
|
| 4151 | + $gd_city = preg_replace('/-(\d+)$/', '', $gd_city);
|
|
| 4152 | + $gd_city = preg_replace('/[_-]/', ' ', $gd_city);
|
|
| 4153 | + $gd_city = __(geodir_ucwords($gd_city), 'geodirectory'); |
|
| 4154 | + } |
|
| 4155 | + $location_single = $gd_city; |
|
| 4156 | + |
|
| 4157 | + } else if ($gd_region != '') {
|
|
| 4158 | + if ($gd_region_actual != '') {
|
|
| 4159 | + $gd_region = $gd_region_actual; |
|
| 4160 | + } else {
|
|
| 4161 | + $gd_region = preg_replace('/-(\d+)$/', '', $gd_region);
|
|
| 4162 | + $gd_region = preg_replace('/[_-]/', ' ', $gd_region);
|
|
| 4163 | + $gd_region = __(geodir_ucwords($gd_region), 'geodirectory'); |
|
| 4164 | + } |
|
| 4187 | 4165 | |
| 4188 | - $location_name = geodir_ucwords($gd_location_link_text); |
|
| 4189 | - $location_name = __($location_name, 'geodirectory'); |
|
| 4166 | + $location_single = $gd_region; |
|
| 4167 | + } else if ($gd_country != '') {
|
|
| 4168 | + if ($gd_country_actual != '') {
|
|
| 4169 | + $gd_country = $gd_country_actual; |
|
| 4170 | + } else {
|
|
| 4171 | + $gd_country = preg_replace('/-(\d+)$/', '', $gd_country);
|
|
| 4172 | + $gd_country = preg_replace('/[_-]/', ' ', $gd_country);
|
|
| 4173 | + $gd_country = __(geodir_ucwords($gd_country), 'geodirectory'); |
|
| 4174 | + } |
|
| 4190 | 4175 | |
| 4191 | - if ($actual_location_name) {
|
|
| 4192 | - $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type; |
|
| 4193 | - $location_name = get_actual_location_name($location_type, $location, true); |
|
| 4194 | - } |
|
| 4176 | + $location_single = $gd_country; |
|
| 4177 | + } |
|
| 4195 | 4178 | |
| 4196 | - $location_titles[] = $location_name; |
|
| 4197 | - } |
|
| 4198 | - if (!empty($location_titles)) {
|
|
| 4199 | - $location_titles = array_unique($location_titles); |
|
| 4200 | - } |
|
| 4201 | - } |
|
| 4179 | + if (!empty($location_array)) {
|
|
| 4202 | 4180 | |
| 4181 | + $actual_location_name = function_exists('get_actual_location_name') ? true : false;
|
|
| 4182 | + $location_array = array_reverse($location_array); |
|
| 4203 | 4183 | |
| 4204 | - if(strpos($title,'%%location%%') !== false){
|
|
| 4205 | - $location = ''; |
|
| 4206 | - if($location_titles) {
|
|
| 4207 | - $location = implode(", ", $location_titles);
|
|
| 4208 | - } |
|
| 4209 | - $title = str_replace("%%location%%",$location,$title);
|
|
| 4210 | - } |
|
| 4184 | + foreach ($location_array as $location_type => $location) {
|
|
| 4185 | + $gd_location_link_text = preg_replace('/-(\d+)$/', '', $location);
|
|
| 4186 | + $gd_location_link_text = preg_replace('/[_-]/', ' ', $gd_location_link_text);
|
|
| 4211 | 4187 | |
| 4212 | - if(strpos($title,'%%in_location%%') !== false){
|
|
| 4213 | - $location = ''; |
|
| 4214 | - if($location_titles) {
|
|
| 4215 | - $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
|
|
| 4216 | - } |
|
| 4217 | - $title = str_replace("%%in_location%%",$location,$title);
|
|
| 4218 | - } |
|
| 4188 | + $location_name = geodir_ucwords($gd_location_link_text); |
|
| 4189 | + $location_name = __($location_name, 'geodirectory'); |
|
| 4219 | 4190 | |
| 4220 | - if(strpos($title,'%%in_location_single%%') !== false){
|
|
| 4221 | - if($location_single) {
|
|
| 4222 | - $location_single = __('in', 'geodirectory') . ' ' .$location_single;
|
|
| 4223 | - } |
|
| 4224 | - $title = str_replace("%%in_location_single%%",$location_single,$title);
|
|
| 4225 | - } |
|
| 4191 | + if ($actual_location_name) {
|
|
| 4192 | + $location_type = strpos($location_type, 'gd_') === 0 ? substr($location_type, 3) : $location_type; |
|
| 4193 | + $location_name = get_actual_location_name($location_type, $location, true); |
|
| 4194 | + } |
|
| 4226 | 4195 | |
| 4227 | - if(strpos($title,'%%location_single%%') !== false){
|
|
| 4228 | - $title = str_replace("%%location_single%%",$location_single,$title);
|
|
| 4229 | - } |
|
| 4196 | + $location_titles[] = $location_name; |
|
| 4197 | + } |
|
| 4198 | + if (!empty($location_titles)) {
|
|
| 4199 | + $location_titles = array_unique($location_titles); |
|
| 4200 | + } |
|
| 4201 | + } |
|
| 4230 | 4202 | |
| 4231 | 4203 | |
| 4232 | - if(strpos($title,'%%search_term%%') !== false){
|
|
| 4233 | - $search_term = ''; |
|
| 4234 | - if(isset($_REQUEST['s'])){
|
|
| 4235 | - $search_term = esc_attr($_REQUEST['s']); |
|
| 4236 | - } |
|
| 4237 | - $title = str_replace("%%search_term%%",$search_term,$title);
|
|
| 4238 | - } |
|
| 4204 | + if(strpos($title,'%%location%%') !== false){
|
|
| 4205 | + $location = ''; |
|
| 4206 | + if($location_titles) {
|
|
| 4207 | + $location = implode(", ", $location_titles);
|
|
| 4208 | + } |
|
| 4209 | + $title = str_replace("%%location%%",$location,$title);
|
|
| 4210 | + } |
|
| 4239 | 4211 | |
| 4240 | - if(strpos($title,'%%search_near%%') !== false){
|
|
| 4241 | - $search_term = ''; |
|
| 4242 | - if(isset($_REQUEST['snear'])){
|
|
| 4243 | - $search_term = esc_attr($_REQUEST['snear']); |
|
| 4244 | - } |
|
| 4245 | - $title = str_replace("%%search_near%%",$search_term,$title);
|
|
| 4246 | - } |
|
| 4247 | - |
|
| 4248 | - if(strpos($title,'%%name%%') !== false){
|
|
| 4249 | - $author_name = ''; |
|
| 4250 | - if($author_name = get_the_author()){}
|
|
| 4251 | - else{
|
|
| 4252 | - $queried_object = get_queried_object(); |
|
| 4253 | - if(isset($queried_object->data->user_nicename)){
|
|
| 4254 | - $author_name = $queried_object->data->user_nicename; |
|
| 4255 | - } |
|
| 4256 | - } |
|
| 4257 | - $title = str_replace("%%name%%",$author_name,$title);
|
|
| 4258 | - } |
|
| 4259 | - |
|
| 4260 | - $title = wptexturize( $title ); |
|
| 4261 | - $title = convert_chars( $title ); |
|
| 4262 | - $title = esc_html( $title ); |
|
| 4263 | - |
|
| 4264 | - /** |
|
| 4265 | - * Filter the title variables after standard ones have been filtered. |
|
| 4266 | - * |
|
| 4267 | - * @since 1.5.7 |
|
| 4268 | - * @package GeoDirectory |
|
| 4269 | - * @param string $title The title with variables. |
|
| 4270 | - * @param array $location_array The array of location variables. |
|
| 4271 | - * @param string $gd_page The page being filtered. |
|
| 4272 | - * @param string $sep The separator, default: `|`. |
|
| 4273 | - */ |
|
| 4212 | + if(strpos($title,'%%in_location%%') !== false){
|
|
| 4213 | + $location = ''; |
|
| 4214 | + if($location_titles) {
|
|
| 4215 | + $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
|
|
| 4216 | + } |
|
| 4217 | + $title = str_replace("%%in_location%%",$location,$title);
|
|
| 4218 | + } |
|
| 4219 | + |
|
| 4220 | + if(strpos($title,'%%in_location_single%%') !== false){
|
|
| 4221 | + if($location_single) {
|
|
| 4222 | + $location_single = __('in', 'geodirectory') . ' ' .$location_single;
|
|
| 4223 | + } |
|
| 4224 | + $title = str_replace("%%in_location_single%%",$location_single,$title);
|
|
| 4225 | + } |
|
| 4226 | + |
|
| 4227 | + if(strpos($title,'%%location_single%%') !== false){
|
|
| 4228 | + $title = str_replace("%%location_single%%",$location_single,$title);
|
|
| 4229 | + } |
|
| 4230 | + |
|
| 4231 | + |
|
| 4232 | + if(strpos($title,'%%search_term%%') !== false){
|
|
| 4233 | + $search_term = ''; |
|
| 4234 | + if(isset($_REQUEST['s'])){
|
|
| 4235 | + $search_term = esc_attr($_REQUEST['s']); |
|
| 4236 | + } |
|
| 4237 | + $title = str_replace("%%search_term%%",$search_term,$title);
|
|
| 4238 | + } |
|
| 4239 | + |
|
| 4240 | + if(strpos($title,'%%search_near%%') !== false){
|
|
| 4241 | + $search_term = ''; |
|
| 4242 | + if(isset($_REQUEST['snear'])){
|
|
| 4243 | + $search_term = esc_attr($_REQUEST['snear']); |
|
| 4244 | + } |
|
| 4245 | + $title = str_replace("%%search_near%%",$search_term,$title);
|
|
| 4246 | + } |
|
| 4247 | + |
|
| 4248 | + if(strpos($title,'%%name%%') !== false){
|
|
| 4249 | + $author_name = ''; |
|
| 4250 | + if($author_name = get_the_author()){}
|
|
| 4251 | + else{
|
|
| 4252 | + $queried_object = get_queried_object(); |
|
| 4253 | + if(isset($queried_object->data->user_nicename)){
|
|
| 4254 | + $author_name = $queried_object->data->user_nicename; |
|
| 4255 | + } |
|
| 4256 | + } |
|
| 4257 | + $title = str_replace("%%name%%",$author_name,$title);
|
|
| 4258 | + } |
|
| 4274 | 4259 | |
| 4275 | - return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
|
|
| 4260 | + $title = wptexturize( $title ); |
|
| 4261 | + $title = convert_chars( $title ); |
|
| 4262 | + $title = esc_html( $title ); |
|
| 4263 | + |
|
| 4264 | + /** |
|
| 4265 | + * Filter the title variables after standard ones have been filtered. |
|
| 4266 | + * |
|
| 4267 | + * @since 1.5.7 |
|
| 4268 | + * @package GeoDirectory |
|
| 4269 | + * @param string $title The title with variables. |
|
| 4270 | + * @param array $location_array The array of location variables. |
|
| 4271 | + * @param string $gd_page The page being filtered. |
|
| 4272 | + * @param string $sep The separator, default: `|`. |
|
| 4273 | + */ |
|
| 4274 | + |
|
| 4275 | + return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
|
|
| 4276 | 4276 | } |
| 4277 | 4277 | |
| 4278 | 4278 | /** |
@@ -4285,65 +4285,65 @@ discard block |
||
| 4285 | 4285 | * @return array Translation texts. |
| 4286 | 4286 | */ |
| 4287 | 4287 | function geodir_load_cpt_text_translation($translation_texts = array()) {
|
| 4288 | - $gd_post_types = geodir_get_posttypes('array');
|
|
| 4289 | - |
|
| 4290 | - if (!empty($gd_post_types)) {
|
|
| 4291 | - foreach ($gd_post_types as $post_type => $cpt_info) {
|
|
| 4292 | - $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : ''; |
|
| 4293 | - $description = isset($cpt_info['description']) ? $cpt_info['description'] : ''; |
|
| 4294 | - $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : ''; |
|
| 4295 | - |
|
| 4296 | - if (!empty($labels)) {
|
|
| 4297 | - if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) |
|
| 4298 | - $translation_texts[] = $labels['name']; |
|
| 4299 | - if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) |
|
| 4300 | - $translation_texts[] = $labels['singular_name']; |
|
| 4301 | - if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) |
|
| 4302 | - $translation_texts[] = $labels['add_new']; |
|
| 4303 | - if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) |
|
| 4304 | - $translation_texts[] = $labels['add_new_item']; |
|
| 4305 | - if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) |
|
| 4306 | - $translation_texts[] = $labels['edit_item']; |
|
| 4307 | - if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) |
|
| 4308 | - $translation_texts[] = $labels['new_item']; |
|
| 4309 | - if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) |
|
| 4310 | - $translation_texts[] = $labels['view_item']; |
|
| 4311 | - if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) |
|
| 4312 | - $translation_texts[] = $labels['search_items']; |
|
| 4313 | - if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) |
|
| 4314 | - $translation_texts[] = $labels['not_found']; |
|
| 4315 | - if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) |
|
| 4316 | - $translation_texts[] = $labels['not_found_in_trash']; |
|
| 4317 | - if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) |
|
| 4318 | - $translation_texts[] = $labels['label_post_profile']; |
|
| 4319 | - if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) |
|
| 4320 | - $translation_texts[] = $labels['label_post_info']; |
|
| 4321 | - if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) |
|
| 4322 | - $translation_texts[] = $labels['label_post_images']; |
|
| 4323 | - if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) |
|
| 4324 | - $translation_texts[] = $labels['label_post_map']; |
|
| 4325 | - if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) |
|
| 4326 | - $translation_texts[] = $labels['label_reviews']; |
|
| 4327 | - if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) |
|
| 4328 | - $translation_texts[] = $labels['label_related_listing']; |
|
| 4329 | - } |
|
| 4330 | - |
|
| 4331 | - if ($description != '' && !in_array($description, $translation_texts)) {
|
|
| 4332 | - $translation_texts[] = normalize_whitespace($description); |
|
| 4333 | - } |
|
| 4334 | - |
|
| 4335 | - if (!empty($seo)) {
|
|
| 4336 | - if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) |
|
| 4337 | - $translation_texts[] = normalize_whitespace($seo['meta_keyword']); |
|
| 4338 | - |
|
| 4339 | - if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) |
|
| 4340 | - $translation_texts[] = normalize_whitespace($seo['meta_description']); |
|
| 4341 | - } |
|
| 4342 | - } |
|
| 4343 | - } |
|
| 4344 | - $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
| 4288 | + $gd_post_types = geodir_get_posttypes('array');
|
|
| 4289 | + |
|
| 4290 | + if (!empty($gd_post_types)) {
|
|
| 4291 | + foreach ($gd_post_types as $post_type => $cpt_info) {
|
|
| 4292 | + $labels = isset($cpt_info['labels']) ? $cpt_info['labels'] : ''; |
|
| 4293 | + $description = isset($cpt_info['description']) ? $cpt_info['description'] : ''; |
|
| 4294 | + $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : ''; |
|
| 4295 | + |
|
| 4296 | + if (!empty($labels)) {
|
|
| 4297 | + if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) |
|
| 4298 | + $translation_texts[] = $labels['name']; |
|
| 4299 | + if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) |
|
| 4300 | + $translation_texts[] = $labels['singular_name']; |
|
| 4301 | + if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) |
|
| 4302 | + $translation_texts[] = $labels['add_new']; |
|
| 4303 | + if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) |
|
| 4304 | + $translation_texts[] = $labels['add_new_item']; |
|
| 4305 | + if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) |
|
| 4306 | + $translation_texts[] = $labels['edit_item']; |
|
| 4307 | + if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) |
|
| 4308 | + $translation_texts[] = $labels['new_item']; |
|
| 4309 | + if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) |
|
| 4310 | + $translation_texts[] = $labels['view_item']; |
|
| 4311 | + if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) |
|
| 4312 | + $translation_texts[] = $labels['search_items']; |
|
| 4313 | + if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) |
|
| 4314 | + $translation_texts[] = $labels['not_found']; |
|
| 4315 | + if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) |
|
| 4316 | + $translation_texts[] = $labels['not_found_in_trash']; |
|
| 4317 | + if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) |
|
| 4318 | + $translation_texts[] = $labels['label_post_profile']; |
|
| 4319 | + if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) |
|
| 4320 | + $translation_texts[] = $labels['label_post_info']; |
|
| 4321 | + if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) |
|
| 4322 | + $translation_texts[] = $labels['label_post_images']; |
|
| 4323 | + if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) |
|
| 4324 | + $translation_texts[] = $labels['label_post_map']; |
|
| 4325 | + if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) |
|
| 4326 | + $translation_texts[] = $labels['label_reviews']; |
|
| 4327 | + if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) |
|
| 4328 | + $translation_texts[] = $labels['label_related_listing']; |
|
| 4329 | + } |
|
| 4345 | 4330 | |
| 4346 | - return $translation_texts; |
|
| 4331 | + if ($description != '' && !in_array($description, $translation_texts)) {
|
|
| 4332 | + $translation_texts[] = normalize_whitespace($description); |
|
| 4333 | + } |
|
| 4334 | + |
|
| 4335 | + if (!empty($seo)) {
|
|
| 4336 | + if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) |
|
| 4337 | + $translation_texts[] = normalize_whitespace($seo['meta_keyword']); |
|
| 4338 | + |
|
| 4339 | + if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) |
|
| 4340 | + $translation_texts[] = normalize_whitespace($seo['meta_description']); |
|
| 4341 | + } |
|
| 4342 | + } |
|
| 4343 | + } |
|
| 4344 | + $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
|
| 4345 | + |
|
| 4346 | + return $translation_texts; |
|
| 4347 | 4347 | } |
| 4348 | 4348 | |
| 4349 | 4349 | /** |
@@ -4356,25 +4356,25 @@ discard block |
||
| 4356 | 4356 | * @return array Location terms. |
| 4357 | 4357 | */ |
| 4358 | 4358 | function geodir_remove_location_terms($location_terms = array()) {
|
| 4359 | - $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 4360 | - |
|
| 4361 | - if (!empty($location_terms) && $location_manager) {
|
|
| 4362 | - $hide_country_part = get_option('geodir_location_hide_country_part');
|
|
| 4363 | - $hide_region_part = get_option('geodir_location_hide_region_part');
|
|
| 4364 | - |
|
| 4365 | - if ($hide_region_part && $hide_country_part) {
|
|
| 4366 | - if (isset($location_terms['gd_country'])) |
|
| 4367 | - unset($location_terms['gd_country']); |
|
| 4368 | - if (isset($location_terms['gd_region'])) |
|
| 4369 | - unset($location_terms['gd_region']); |
|
| 4370 | - } else if ($hide_region_part && !$hide_country_part) {
|
|
| 4371 | - if (isset($location_terms['gd_region'])) |
|
| 4372 | - unset($location_terms['gd_region']); |
|
| 4373 | - } else if (!$hide_region_part && $hide_country_part) {
|
|
| 4374 | - if (isset($location_terms['gd_country'])) |
|
| 4375 | - unset($location_terms['gd_country']); |
|
| 4376 | - } |
|
| 4377 | - } |
|
| 4359 | + $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
|
| 4360 | + |
|
| 4361 | + if (!empty($location_terms) && $location_manager) {
|
|
| 4362 | + $hide_country_part = get_option('geodir_location_hide_country_part');
|
|
| 4363 | + $hide_region_part = get_option('geodir_location_hide_region_part');
|
|
| 4364 | + |
|
| 4365 | + if ($hide_region_part && $hide_country_part) {
|
|
| 4366 | + if (isset($location_terms['gd_country'])) |
|
| 4367 | + unset($location_terms['gd_country']); |
|
| 4368 | + if (isset($location_terms['gd_region'])) |
|
| 4369 | + unset($location_terms['gd_region']); |
|
| 4370 | + } else if ($hide_region_part && !$hide_country_part) {
|
|
| 4371 | + if (isset($location_terms['gd_region'])) |
|
| 4372 | + unset($location_terms['gd_region']); |
|
| 4373 | + } else if (!$hide_region_part && $hide_country_part) {
|
|
| 4374 | + if (isset($location_terms['gd_country'])) |
|
| 4375 | + unset($location_terms['gd_country']); |
|
| 4376 | + } |
|
| 4377 | + } |
|
| 4378 | 4378 | |
| 4379 | - return $location_terms; |
|
| 4379 | + return $location_terms; |
|
| 4380 | 4380 | } |
| 4381 | 4381 | \ No newline at end of file |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Functions that are called via ajax. |
|
| 4 | - * |
|
| 5 | - * @since 1.0.0 |
|
| 6 | - * @package GeoDirectory |
|
| 7 | - */ |
|
| 3 | + * Functions that are called via ajax. |
|
| 4 | + * |
|
| 5 | + * @since 1.0.0 |
|
| 6 | + * @package GeoDirectory |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | /** |
@@ -16,22 +16,22 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | function geodir_on_wp_loaded() |
| 18 | 18 | {
|
| 19 | - /** |
|
| 20 | - * Called on the wp_loaded WP hook and used to send the send inquiry and send to friend forms. |
|
| 21 | - * |
|
| 22 | - * @since 1.0.0 |
|
| 23 | - */ |
|
| 24 | - do_action('giodir_handle_request_plugins_loaded');
|
|
| 25 | - global $wpdb; |
|
| 19 | + /** |
|
| 20 | + * Called on the wp_loaded WP hook and used to send the send inquiry and send to friend forms. |
|
| 21 | + * |
|
| 22 | + * @since 1.0.0 |
|
| 23 | + */ |
|
| 24 | + do_action('giodir_handle_request_plugins_loaded');
|
|
| 25 | + global $wpdb; |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | - if (isset($_POST['sendact']) && $_POST['sendact'] == 'send_inqury') {
|
|
| 29 | - geodir_send_inquiry($_REQUEST); // function in custom_functions.php |
|
| 28 | + if (isset($_POST['sendact']) && $_POST['sendact'] == 'send_inqury') {
|
|
| 29 | + geodir_send_inquiry($_REQUEST); // function in custom_functions.php |
|
| 30 | 30 | |
| 31 | - } elseif (isset($_POST['sendact']) && $_POST['sendact'] == 'email_frnd') {
|
|
| 32 | - geodir_send_friend($_REQUEST); // function in custom_functions.php |
|
| 31 | + } elseif (isset($_POST['sendact']) && $_POST['sendact'] == 'email_frnd') {
|
|
| 32 | + geodir_send_friend($_REQUEST); // function in custom_functions.php |
|
| 33 | 33 | |
| 34 | - } |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | } |
| 37 | 37 | |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | function geodir_on_wp() |
| 46 | 46 | {
|
| 47 | - if(geodir_is_page('login')) {
|
|
| 48 | - geodir_user_signup(); |
|
| 49 | - } |
|
| 47 | + if(geodir_is_page('login')) {
|
|
| 48 | + geodir_user_signup(); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | } |
| 52 | 52 | |
@@ -59,47 +59,47 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function geodir_on_init() |
| 61 | 61 | {
|
| 62 | - /** |
|
| 63 | - * Called on the wp_init WP hook at the start of the geodir_on_init() function. |
|
| 64 | - * |
|
| 65 | - * @since 1.0.0 |
|
| 66 | - */ |
|
| 67 | - do_action('giodir_handle_request');
|
|
| 68 | - global $wpdb; |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - |
|
| 73 | - if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && !current_user_can('manage_options')) {
|
|
| 74 | - show_admin_bar(false); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - if (isset($_REQUEST['ptype']) && $_REQUEST['ptype'] == 'get_markers') {
|
|
| 79 | - /** |
|
| 80 | - * Contains map marker functions. |
|
| 81 | - * |
|
| 82 | - * @since 1.0.0 |
|
| 83 | - * @package GeoDirectory |
|
| 84 | - */ |
|
| 85 | - include_once(geodir_plugin_path() . '/geodirectory-functions/map-functions/get_markers.php'); |
|
| 86 | - die; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - if (isset($_REQUEST['ptype']) && $_REQUEST['ptype'] == 'ga') {
|
|
| 90 | - if (isset($_REQUEST['ga_start'])) {
|
|
| 91 | - $ga_start = $_REQUEST['ga_start']; |
|
| 92 | - } else {
|
|
| 93 | - $ga_start = ''; |
|
| 94 | - } |
|
| 95 | - if (isset($_REQUEST['ga_end'])) {
|
|
| 96 | - $ga_end = $_REQUEST['ga_end']; |
|
| 97 | - } else {
|
|
| 98 | - $ga_end = ''; |
|
| 99 | - } |
|
| 100 | - geodir_getGoogleAnalytics($_REQUEST['ga_page'], $ga_start, $ga_end); |
|
| 101 | - die; |
|
| 102 | - } |
|
| 62 | + /** |
|
| 63 | + * Called on the wp_init WP hook at the start of the geodir_on_init() function. |
|
| 64 | + * |
|
| 65 | + * @since 1.0.0 |
|
| 66 | + */ |
|
| 67 | + do_action('giodir_handle_request');
|
|
| 68 | + global $wpdb; |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + |
|
| 73 | + if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && !current_user_can('manage_options')) {
|
|
| 74 | + show_admin_bar(false); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + if (isset($_REQUEST['ptype']) && $_REQUEST['ptype'] == 'get_markers') {
|
|
| 79 | + /** |
|
| 80 | + * Contains map marker functions. |
|
| 81 | + * |
|
| 82 | + * @since 1.0.0 |
|
| 83 | + * @package GeoDirectory |
|
| 84 | + */ |
|
| 85 | + include_once(geodir_plugin_path() . '/geodirectory-functions/map-functions/get_markers.php'); |
|
| 86 | + die; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + if (isset($_REQUEST['ptype']) && $_REQUEST['ptype'] == 'ga') {
|
|
| 90 | + if (isset($_REQUEST['ga_start'])) {
|
|
| 91 | + $ga_start = $_REQUEST['ga_start']; |
|
| 92 | + } else {
|
|
| 93 | + $ga_start = ''; |
|
| 94 | + } |
|
| 95 | + if (isset($_REQUEST['ga_end'])) {
|
|
| 96 | + $ga_end = $_REQUEST['ga_end']; |
|
| 97 | + } else {
|
|
| 98 | + $ga_end = ''; |
|
| 99 | + } |
|
| 100 | + geodir_getGoogleAnalytics($_REQUEST['ga_page'], $ga_start, $ga_end); |
|
| 101 | + die; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | } |
@@ -118,241 +118,241 @@ discard block |
||
| 118 | 118 | * @todo check if nonce is required here and if so add one. |
| 119 | 119 | */ |
| 120 | 120 | function geodir_ajax_handler() {
|
| 121 | - global $wpdb, $gd_session; |
|
| 121 | + global $wpdb, $gd_session; |
|
| 122 | 122 | |
| 123 | - if (isset($_REQUEST['gd_listing_view']) && $_REQUEST['gd_listing_view'] != '') {
|
|
| 123 | + if (isset($_REQUEST['gd_listing_view']) && $_REQUEST['gd_listing_view'] != '') {
|
|
| 124 | 124 | $gd_session->set('gd_listing_view', $_REQUEST['gd_listing_view']);
|
| 125 | - echo '1'; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'category_ajax') {
|
|
| 129 | - if (isset($_REQUEST['main_catid']) && isset($_REQUEST['cat_tax']) && isset($_REQUEST['exclude'])) |
|
| 130 | - geodir_addpost_categories_html($_REQUEST['cat_tax'], $_REQUEST['main_catid'], '', '', '', $_REQUEST['exclude']); |
|
| 131 | - else if (isset($_REQUEST['catpid']) && isset($_REQUEST['cat_tax'])) |
|
| 132 | - geodir_editpost_categories_html($_REQUEST['cat_tax'], $_REQUEST['catpid']); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - if ((isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'admin_ajax') || isset($_REQUEST['create_field']) || isset($_REQUEST['sort_create_field'])) {
|
|
| 136 | - if (current_user_can('manage_options')) {
|
|
| 137 | - /** |
|
| 138 | - * Contains admin ajax handling functions. |
|
| 139 | - * |
|
| 140 | - * @since 1.0.0 |
|
| 141 | - * @package GeoDirectory |
|
| 142 | - */ |
|
| 143 | - include_once(geodir_plugin_path() . '/geodirectory-admin/geodir_admin_ajax.php'); |
|
| 144 | - } else {
|
|
| 145 | - wp_redirect(geodir_login_url()); |
|
| 146 | - exit(); |
|
| 147 | - } |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - if (isset($_REQUEST['geodir_autofill']) && $_REQUEST['geodir_autofill'] != '' && isset($_REQUEST['_wpnonce'])) {
|
|
| 151 | - if (current_user_can('manage_options')) {
|
|
| 152 | - switch ($_REQUEST['geodir_autofill']): |
|
| 153 | - case "geodir_dummy_delete" : |
|
| 154 | - if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir_dummy_posts_delete_noncename')) |
|
| 155 | - return; |
|
| 156 | - |
|
| 157 | - if (isset($_REQUEST['posttype'])) |
|
| 158 | - /** |
|
| 159 | - * Used to delete the dummy post data per post type. |
|
| 160 | - * |
|
| 161 | - * Uses dynamic hook, geodir_delete_dummy_posts_$_REQUEST['posttype']. |
|
| 162 | - * |
|
| 163 | - * @since 1.0.0 |
|
| 164 | - */ |
|
| 165 | - do_action('geodir_delete_dummy_posts_' . $_REQUEST['posttype']);
|
|
| 166 | - break; |
|
| 167 | - case "geodir_dummy_insert" : |
|
| 168 | - if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir_dummy_posts_insert_noncename')) |
|
| 169 | - return; |
|
| 170 | - |
|
| 171 | - global $dummy_post_index, $city_bound_lat1, $city_bound_lng1, $city_bound_lat2, $city_bound_lng2; |
|
| 172 | - $dummy_post_index = $_REQUEST['insert_dummy_post_index']; |
|
| 173 | - $city_bound_lat1 = $_REQUEST['city_bound_lat1']; |
|
| 174 | - $city_bound_lng1 = $_REQUEST['city_bound_lng1']; |
|
| 175 | - $city_bound_lat2 = $_REQUEST['city_bound_lat2']; |
|
| 176 | - $city_bound_lng2 = $_REQUEST['city_bound_lng2']; |
|
| 177 | - |
|
| 178 | - if (isset($_REQUEST['posttype'])) |
|
| 179 | - /** |
|
| 180 | - * Used to insert the dummy post data per post type. |
|
| 181 | - * |
|
| 182 | - * Uses dynamic hook, geodir_insert_dummy_posts_$_REQUEST['posttype']. |
|
| 183 | - * |
|
| 184 | - * @since 1.0.0 |
|
| 185 | - */ |
|
| 186 | - do_action('geodir_insert_dummy_posts_' . $_REQUEST['posttype']);
|
|
| 187 | - |
|
| 188 | - break; |
|
| 189 | - endswitch; |
|
| 190 | - } else {
|
|
| 191 | - wp_redirect(geodir_login_url()); |
|
| 192 | - exit(); |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - if (isset($_REQUEST['popuptype']) && $_REQUEST['popuptype'] != '' && isset($_REQUEST['post_id']) && $_REQUEST['post_id'] != '') {
|
|
| 197 | - |
|
| 198 | - if ($_REQUEST['popuptype'] == 'b_send_inquiry' || $_REQUEST['popuptype'] == 'b_sendtofriend') |
|
| 199 | - require_once(geodir_plugin_path() . '/geodirectory-templates/popup-forms.php'); |
|
| 200 | - |
|
| 201 | - exit; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - /*if(isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'filter_ajax'){
|
|
| 125 | + echo '1'; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'category_ajax') {
|
|
| 129 | + if (isset($_REQUEST['main_catid']) && isset($_REQUEST['cat_tax']) && isset($_REQUEST['exclude'])) |
|
| 130 | + geodir_addpost_categories_html($_REQUEST['cat_tax'], $_REQUEST['main_catid'], '', '', '', $_REQUEST['exclude']); |
|
| 131 | + else if (isset($_REQUEST['catpid']) && isset($_REQUEST['cat_tax'])) |
|
| 132 | + geodir_editpost_categories_html($_REQUEST['cat_tax'], $_REQUEST['catpid']); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + if ((isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'admin_ajax') || isset($_REQUEST['create_field']) || isset($_REQUEST['sort_create_field'])) {
|
|
| 136 | + if (current_user_can('manage_options')) {
|
|
| 137 | + /** |
|
| 138 | + * Contains admin ajax handling functions. |
|
| 139 | + * |
|
| 140 | + * @since 1.0.0 |
|
| 141 | + * @package GeoDirectory |
|
| 142 | + */ |
|
| 143 | + include_once(geodir_plugin_path() . '/geodirectory-admin/geodir_admin_ajax.php'); |
|
| 144 | + } else {
|
|
| 145 | + wp_redirect(geodir_login_url()); |
|
| 146 | + exit(); |
|
| 147 | + } |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + if (isset($_REQUEST['geodir_autofill']) && $_REQUEST['geodir_autofill'] != '' && isset($_REQUEST['_wpnonce'])) {
|
|
| 151 | + if (current_user_can('manage_options')) {
|
|
| 152 | + switch ($_REQUEST['geodir_autofill']): |
|
| 153 | + case "geodir_dummy_delete" : |
|
| 154 | + if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir_dummy_posts_delete_noncename')) |
|
| 155 | + return; |
|
| 156 | + |
|
| 157 | + if (isset($_REQUEST['posttype'])) |
|
| 158 | + /** |
|
| 159 | + * Used to delete the dummy post data per post type. |
|
| 160 | + * |
|
| 161 | + * Uses dynamic hook, geodir_delete_dummy_posts_$_REQUEST['posttype']. |
|
| 162 | + * |
|
| 163 | + * @since 1.0.0 |
|
| 164 | + */ |
|
| 165 | + do_action('geodir_delete_dummy_posts_' . $_REQUEST['posttype']);
|
|
| 166 | + break; |
|
| 167 | + case "geodir_dummy_insert" : |
|
| 168 | + if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir_dummy_posts_insert_noncename')) |
|
| 169 | + return; |
|
| 170 | + |
|
| 171 | + global $dummy_post_index, $city_bound_lat1, $city_bound_lng1, $city_bound_lat2, $city_bound_lng2; |
|
| 172 | + $dummy_post_index = $_REQUEST['insert_dummy_post_index']; |
|
| 173 | + $city_bound_lat1 = $_REQUEST['city_bound_lat1']; |
|
| 174 | + $city_bound_lng1 = $_REQUEST['city_bound_lng1']; |
|
| 175 | + $city_bound_lat2 = $_REQUEST['city_bound_lat2']; |
|
| 176 | + $city_bound_lng2 = $_REQUEST['city_bound_lng2']; |
|
| 177 | + |
|
| 178 | + if (isset($_REQUEST['posttype'])) |
|
| 179 | + /** |
|
| 180 | + * Used to insert the dummy post data per post type. |
|
| 181 | + * |
|
| 182 | + * Uses dynamic hook, geodir_insert_dummy_posts_$_REQUEST['posttype']. |
|
| 183 | + * |
|
| 184 | + * @since 1.0.0 |
|
| 185 | + */ |
|
| 186 | + do_action('geodir_insert_dummy_posts_' . $_REQUEST['posttype']);
|
|
| 187 | + |
|
| 188 | + break; |
|
| 189 | + endswitch; |
|
| 190 | + } else {
|
|
| 191 | + wp_redirect(geodir_login_url()); |
|
| 192 | + exit(); |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + if (isset($_REQUEST['popuptype']) && $_REQUEST['popuptype'] != '' && isset($_REQUEST['post_id']) && $_REQUEST['post_id'] != '') {
|
|
| 197 | + |
|
| 198 | + if ($_REQUEST['popuptype'] == 'b_send_inquiry' || $_REQUEST['popuptype'] == 'b_sendtofriend') |
|
| 199 | + require_once(geodir_plugin_path() . '/geodirectory-templates/popup-forms.php'); |
|
| 200 | + |
|
| 201 | + exit; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + /*if(isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'filter_ajax'){
|
|
| 205 | 205 | include_once ( geodir_plugin_path() . '/geodirectory-templates/advance-search-form.php'); |
| 206 | 206 | }*/ |
| 207 | 207 | |
| 208 | - if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'map_ajax') {
|
|
| 209 | - /** |
|
| 210 | - * Contains map marker functions. |
|
| 211 | - * |
|
| 212 | - * @since 1.0.0 |
|
| 213 | - * @package GeoDirectory |
|
| 214 | - */ |
|
| 215 | - include_once(geodir_plugin_path() . '/geodirectory-functions/map-functions/get_markers.php'); |
|
| 216 | - } |
|
| 217 | - |
|
| 218 | - if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'favorite') {
|
|
| 219 | - if (is_user_logged_in()) {
|
|
| 220 | - switch ($_REQUEST['ajax_action']): |
|
| 221 | - case "add" : |
|
| 222 | - geodir_add_to_favorite((int)$_REQUEST['pid']); |
|
| 223 | - break; |
|
| 224 | - case "remove" : |
|
| 225 | - geodir_remove_from_favorite((int)$_REQUEST['pid']); |
|
| 226 | - break; |
|
| 227 | - endswitch; |
|
| 228 | - } else {
|
|
| 229 | - wp_redirect(geodir_login_url()); |
|
| 230 | - exit(); |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'add_listing') {
|
|
| 235 | - |
|
| 236 | - $is_current_user_owner = true; |
|
| 237 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 238 | - $is_current_user_owner = geodir_listing_belong_to_current_user((int)$_REQUEST['pid']); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - $request = $gd_session->get('listing');
|
|
| 242 | - |
|
| 243 | - if (is_user_logged_in() && $is_current_user_owner) {
|
|
| 244 | - |
|
| 245 | - switch ($_REQUEST['ajax_action']): |
|
| 246 | - case "add": |
|
| 247 | - case "update": |
|
| 248 | - |
|
| 249 | - if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') {
|
|
| 250 | - $last_id = geodir_save_listing(); |
|
| 251 | - |
|
| 252 | - if ($last_id) {
|
|
| 253 | - //$redirect_to = get_permalink( $last_id ); |
|
| 254 | - $redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id));
|
|
| 255 | - |
|
| 256 | - } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 257 | - $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
| 258 | - $redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false);
|
|
| 259 | - } else |
|
| 260 | - $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
| 261 | - |
|
| 262 | - wp_redirect($redirect_to); |
|
| 263 | - } else {
|
|
| 264 | - $gd_session->un_set('listing');
|
|
| 265 | - wp_redirect(home_url()); |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - break; |
|
| 269 | - case "cancel" : |
|
| 270 | - |
|
| 271 | - $gd_session->un_set('listing');
|
|
| 272 | - |
|
| 273 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && get_permalink($_REQUEST['pid'])) |
|
| 274 | - wp_redirect(get_permalink($_REQUEST['pid'])); |
|
| 275 | - else {
|
|
| 276 | - geodir_remove_temp_images(); |
|
| 277 | - wp_redirect(geodir_getlink(get_permalink(geodir_add_listing_page_id()), array('listing_type' => $_REQUEST['listing_type'])));
|
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - break; |
|
| 281 | - |
|
| 282 | - case "publish" : |
|
| 283 | - |
|
| 284 | - if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') {
|
|
| 285 | - |
|
| 286 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 287 | - $new_post = array(); |
|
| 288 | - $new_post['ID'] = $_REQUEST['pid']; |
|
| 289 | - |
|
| 290 | - $lastid = wp_update_post($new_post); |
|
| 291 | - |
|
| 292 | - $gd_session->un_set('listing');
|
|
| 293 | - wp_redirect(get_permalink($lastid)); |
|
| 294 | - } else {
|
|
| 295 | - $last_id = geodir_save_listing(); |
|
| 296 | - |
|
| 297 | - if ($last_id) {
|
|
| 298 | - //$redirect_to = get_permalink( $last_id ); |
|
| 299 | - $redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id));
|
|
| 300 | - } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 301 | - $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
| 302 | - $redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false);
|
|
| 303 | - } else |
|
| 304 | - $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
| 305 | - |
|
| 306 | - $gd_session->un_set('listing');
|
|
| 307 | - wp_redirect($redirect_to); |
|
| 308 | - } |
|
| 309 | - } else {
|
|
| 310 | - $gd_session->un_set('listing');
|
|
| 311 | - wp_redirect(home_url()); |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - break; |
|
| 315 | - case "delete" : |
|
| 316 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 317 | - global $current_user; |
|
| 318 | - get_currentuserinfo(); |
|
| 319 | - |
|
| 320 | - if (get_option('geodir_disable_perm_delete')) {
|
|
| 321 | - $lastid = wp_trash_post($_REQUEST['pid']); |
|
| 322 | - } else {
|
|
| 323 | - $lastid = wp_delete_post($_REQUEST['pid']); |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - if ($lastid && !is_wp_error($lastid)) |
|
| 327 | - wp_redirect($_SERVER['HTTP_REFERER']); |
|
| 328 | - |
|
| 329 | - //wp_redirect( geodir_getlink(get_author_posts_url($current_user->ID),array('geodir_dashbord'=>'true','stype'=>$post_type ),false) );
|
|
| 330 | - } |
|
| 331 | - break; |
|
| 332 | - endswitch; |
|
| 333 | - |
|
| 334 | - $gd_session->un_set('listing');
|
|
| 335 | - } else {
|
|
| 336 | - $gd_session->un_set('listing');
|
|
| 337 | - wp_redirect(geodir_login_url()); |
|
| 338 | - exit(); |
|
| 339 | - } |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'user_login') {
|
|
| 343 | - /** |
|
| 344 | - * Contains registration and login functions. |
|
| 345 | - * @todo Fix the file path. |
|
| 346 | - * |
|
| 347 | - * @since 1.0.0 |
|
| 348 | - * @package GeoDirectory |
|
| 349 | - */ |
|
| 350 | - include_once(geodir_plugin_path() . '/geodirectory-functions/geodirectory_reg.php'); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - |
|
| 354 | - if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'geodir_get_term_list') {
|
|
| 355 | - $terms_o = get_terms(sanitize_text_field($_REQUEST['term'])); |
|
| 208 | + if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'map_ajax') {
|
|
| 209 | + /** |
|
| 210 | + * Contains map marker functions. |
|
| 211 | + * |
|
| 212 | + * @since 1.0.0 |
|
| 213 | + * @package GeoDirectory |
|
| 214 | + */ |
|
| 215 | + include_once(geodir_plugin_path() . '/geodirectory-functions/map-functions/get_markers.php'); |
|
| 216 | + } |
|
| 217 | + |
|
| 218 | + if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'favorite') {
|
|
| 219 | + if (is_user_logged_in()) {
|
|
| 220 | + switch ($_REQUEST['ajax_action']): |
|
| 221 | + case "add" : |
|
| 222 | + geodir_add_to_favorite((int)$_REQUEST['pid']); |
|
| 223 | + break; |
|
| 224 | + case "remove" : |
|
| 225 | + geodir_remove_from_favorite((int)$_REQUEST['pid']); |
|
| 226 | + break; |
|
| 227 | + endswitch; |
|
| 228 | + } else {
|
|
| 229 | + wp_redirect(geodir_login_url()); |
|
| 230 | + exit(); |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'add_listing') {
|
|
| 235 | + |
|
| 236 | + $is_current_user_owner = true; |
|
| 237 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 238 | + $is_current_user_owner = geodir_listing_belong_to_current_user((int)$_REQUEST['pid']); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + $request = $gd_session->get('listing');
|
|
| 242 | + |
|
| 243 | + if (is_user_logged_in() && $is_current_user_owner) {
|
|
| 244 | + |
|
| 245 | + switch ($_REQUEST['ajax_action']): |
|
| 246 | + case "add": |
|
| 247 | + case "update": |
|
| 248 | + |
|
| 249 | + if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') {
|
|
| 250 | + $last_id = geodir_save_listing(); |
|
| 251 | + |
|
| 252 | + if ($last_id) {
|
|
| 253 | + //$redirect_to = get_permalink( $last_id ); |
|
| 254 | + $redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id));
|
|
| 255 | + |
|
| 256 | + } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 257 | + $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
| 258 | + $redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false);
|
|
| 259 | + } else |
|
| 260 | + $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
| 261 | + |
|
| 262 | + wp_redirect($redirect_to); |
|
| 263 | + } else {
|
|
| 264 | + $gd_session->un_set('listing');
|
|
| 265 | + wp_redirect(home_url()); |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + break; |
|
| 269 | + case "cancel" : |
|
| 270 | + |
|
| 271 | + $gd_session->un_set('listing');
|
|
| 272 | + |
|
| 273 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && get_permalink($_REQUEST['pid'])) |
|
| 274 | + wp_redirect(get_permalink($_REQUEST['pid'])); |
|
| 275 | + else {
|
|
| 276 | + geodir_remove_temp_images(); |
|
| 277 | + wp_redirect(geodir_getlink(get_permalink(geodir_add_listing_page_id()), array('listing_type' => $_REQUEST['listing_type'])));
|
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + break; |
|
| 281 | + |
|
| 282 | + case "publish" : |
|
| 283 | + |
|
| 284 | + if (isset($request['geodir_spamblocker']) && $request['geodir_spamblocker'] == '64' && isset($request['geodir_filled_by_spam_bot']) && $request['geodir_filled_by_spam_bot'] == '') {
|
|
| 285 | + |
|
| 286 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 287 | + $new_post = array(); |
|
| 288 | + $new_post['ID'] = $_REQUEST['pid']; |
|
| 289 | + |
|
| 290 | + $lastid = wp_update_post($new_post); |
|
| 291 | + |
|
| 292 | + $gd_session->un_set('listing');
|
|
| 293 | + wp_redirect(get_permalink($lastid)); |
|
| 294 | + } else {
|
|
| 295 | + $last_id = geodir_save_listing(); |
|
| 296 | + |
|
| 297 | + if ($last_id) {
|
|
| 298 | + //$redirect_to = get_permalink( $last_id ); |
|
| 299 | + $redirect_to = geodir_getlink(get_permalink(geodir_success_page_id()), array('pid' => $last_id));
|
|
| 300 | + } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 301 | + $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
| 302 | + $redirect_to = geodir_getlink($redirect_to, array('pid' => $post->pid), false);
|
|
| 303 | + } else |
|
| 304 | + $redirect_to = get_permalink(geodir_add_listing_page_id()); |
|
| 305 | + |
|
| 306 | + $gd_session->un_set('listing');
|
|
| 307 | + wp_redirect($redirect_to); |
|
| 308 | + } |
|
| 309 | + } else {
|
|
| 310 | + $gd_session->un_set('listing');
|
|
| 311 | + wp_redirect(home_url()); |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + break; |
|
| 315 | + case "delete" : |
|
| 316 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 317 | + global $current_user; |
|
| 318 | + get_currentuserinfo(); |
|
| 319 | + |
|
| 320 | + if (get_option('geodir_disable_perm_delete')) {
|
|
| 321 | + $lastid = wp_trash_post($_REQUEST['pid']); |
|
| 322 | + } else {
|
|
| 323 | + $lastid = wp_delete_post($_REQUEST['pid']); |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + if ($lastid && !is_wp_error($lastid)) |
|
| 327 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
| 328 | + |
|
| 329 | + //wp_redirect( geodir_getlink(get_author_posts_url($current_user->ID),array('geodir_dashbord'=>'true','stype'=>$post_type ),false) );
|
|
| 330 | + } |
|
| 331 | + break; |
|
| 332 | + endswitch; |
|
| 333 | + |
|
| 334 | + $gd_session->un_set('listing');
|
|
| 335 | + } else {
|
|
| 336 | + $gd_session->un_set('listing');
|
|
| 337 | + wp_redirect(geodir_login_url()); |
|
| 338 | + exit(); |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + if (isset($_REQUEST['geodir_ajax']) && $_REQUEST['geodir_ajax'] == 'user_login') {
|
|
| 343 | + /** |
|
| 344 | + * Contains registration and login functions. |
|
| 345 | + * @todo Fix the file path. |
|
| 346 | + * |
|
| 347 | + * @since 1.0.0 |
|
| 348 | + * @package GeoDirectory |
|
| 349 | + */ |
|
| 350 | + include_once(geodir_plugin_path() . '/geodirectory-functions/geodirectory_reg.php'); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + |
|
| 354 | + if (isset($_REQUEST['ajax_action']) && $_REQUEST['ajax_action'] == 'geodir_get_term_list') {
|
|
| 355 | + $terms_o = get_terms(sanitize_text_field($_REQUEST['term'])); |
|
| 356 | 356 | |
| 357 | 357 | // Skip terms which has no listing |
| 358 | 358 | if (!empty($terms_o)) {
|
@@ -366,11 +366,11 @@ discard block |
||
| 366 | 366 | $terms_o = $filter_terms; |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - $terms = geodir_sort_terms($terms_o, 'count'); |
|
| 370 | - geodir_helper_cat_list_output($terms, intval($_REQUEST['limit'])); |
|
| 371 | - exit(); |
|
| 369 | + $terms = geodir_sort_terms($terms_o, 'count'); |
|
| 370 | + geodir_helper_cat_list_output($terms, intval($_REQUEST['limit'])); |
|
| 371 | + exit(); |
|
| 372 | 372 | |
| 373 | - } |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | - gd_die(); |
|
| 375 | + gd_die(); |
|
| 376 | 376 | } |
@@ -13,11 +13,11 @@ discard block |
||
| 13 | 13 | * @since 1.4.6 |
| 14 | 14 | * @return int|null Return the page ID if present or null if not. |
| 15 | 15 | */ |
| 16 | -function geodir_add_listing_page_id(){ |
|
| 16 | +function geodir_add_listing_page_id() { |
|
| 17 | 17 | $gd_page_id = get_option('geodir_add_listing_page'); |
| 18 | 18 | |
| 19 | 19 | if (function_exists('icl_object_id')) { |
| 20 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 20 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | return $gd_page_id; |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | * @since 1.4.6 |
| 31 | 31 | * @return int|null Return the page ID if present or null if not. |
| 32 | 32 | */ |
| 33 | -function geodir_preview_page_id(){ |
|
| 33 | +function geodir_preview_page_id() { |
|
| 34 | 34 | $gd_page_id = get_option('geodir_preview_page'); |
| 35 | 35 | |
| 36 | 36 | if (function_exists('icl_object_id')) { |
| 37 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 37 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | return $gd_page_id; |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | * @since 1.4.6 |
| 48 | 48 | * @return int|null Return the page ID if present or null if not. |
| 49 | 49 | */ |
| 50 | -function geodir_success_page_id(){ |
|
| 50 | +function geodir_success_page_id() { |
|
| 51 | 51 | $gd_page_id = get_option('geodir_success_page'); |
| 52 | 52 | |
| 53 | 53 | if (function_exists('icl_object_id')) { |
| 54 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 54 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | return $gd_page_id; |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | * @since 1.4.6 |
| 65 | 65 | * @return int|null Return the page ID if present or null if not. |
| 66 | 66 | */ |
| 67 | -function geodir_location_page_id(){ |
|
| 67 | +function geodir_location_page_id() { |
|
| 68 | 68 | $gd_page_id = get_option('geodir_location_page'); |
| 69 | 69 | |
| 70 | 70 | if (function_exists('icl_object_id')) { |
| 71 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 71 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | return $gd_page_id; |
@@ -81,11 +81,11 @@ discard block |
||
| 81 | 81 | * @since 1.5.4 |
| 82 | 82 | * @return int|null Return the page ID if present or null if not. |
| 83 | 83 | */ |
| 84 | -function geodir_home_page_id(){ |
|
| 84 | +function geodir_home_page_id() { |
|
| 85 | 85 | $gd_page_id = get_option('geodir_home_page'); |
| 86 | 86 | |
| 87 | 87 | if (function_exists('icl_object_id')) { |
| 88 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 88 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | return $gd_page_id; |
@@ -98,11 +98,11 @@ discard block |
||
| 98 | 98 | * @since 1.5.3 |
| 99 | 99 | * @return int|null Return the page ID if present or null if not. |
| 100 | 100 | */ |
| 101 | -function geodir_info_page_id(){ |
|
| 101 | +function geodir_info_page_id() { |
|
| 102 | 102 | $gd_page_id = get_option('geodir_info_page'); |
| 103 | 103 | |
| 104 | 104 | if (function_exists('icl_object_id')) { |
| 105 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 105 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | return $gd_page_id; |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | * @since 1.5.3 |
| 116 | 116 | * @return int|null Return the page ID if present or null if not. |
| 117 | 117 | */ |
| 118 | -function geodir_login_page_id(){ |
|
| 118 | +function geodir_login_page_id() { |
|
| 119 | 119 | $gd_page_id = get_option('geodir_login_page'); |
| 120 | 120 | |
| 121 | 121 | if (function_exists('icl_object_id')) { |
| 122 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 122 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | return $gd_page_id; |
@@ -133,11 +133,11 @@ discard block |
||
| 133 | 133 | * @since 1.5.3 |
| 134 | 134 | * @return int|null Return the page ID if present or null if not. |
| 135 | 135 | */ |
| 136 | -function geodir_login_url($args=array()){ |
|
| 136 | +function geodir_login_url($args = array()) { |
|
| 137 | 137 | $gd_page_id = get_option('geodir_login_page'); |
| 138 | 138 | |
| 139 | 139 | if (function_exists('icl_object_id')) { |
| 140 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 140 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | if (function_exists('geodir_location_geo_home_link')) { |
@@ -148,17 +148,17 @@ discard block |
||
| 148 | 148 | add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - if($gd_page_id){ |
|
| 151 | + if ($gd_page_id) { |
|
| 152 | 152 | $post = get_post($gd_page_id); |
| 153 | 153 | $slug = $post->post_name; |
| 154 | 154 | //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
| 155 | - $login_url = trailingslashit($home_url)."$slug/"; |
|
| 156 | - }else{ |
|
| 157 | - $login_url = trailingslashit($home_url)."?geodir_signup=true"; |
|
| 155 | + $login_url = trailingslashit($home_url) . "$slug/"; |
|
| 156 | + } else { |
|
| 157 | + $login_url = trailingslashit($home_url) . "?geodir_signup=true"; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if($args){ |
|
| 161 | - $login_url = add_query_arg($args,$login_url ); |
|
| 160 | + if ($args) { |
|
| 161 | + $login_url = add_query_arg($args, $login_url); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | /** |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | * @param array $args The array of query args used. |
| 173 | 173 | * @param int $gd_page_id The page id of the GD login page. |
| 174 | 174 | */ |
| 175 | - return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id); |
|
| 175 | + return apply_filters('geodir_login_url', $login_url, $args, $gd_page_id); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -182,11 +182,11 @@ discard block |
||
| 182 | 182 | * @since 1.5.4 |
| 183 | 183 | * @return string Info page url. |
| 184 | 184 | */ |
| 185 | -function geodir_info_url($args=array()){ |
|
| 185 | +function geodir_info_url($args = array()) { |
|
| 186 | 186 | $gd_page_id = get_option('geodir_info_page'); |
| 187 | 187 | |
| 188 | 188 | if (function_exists('icl_object_id')) { |
| 189 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 189 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | if (function_exists('geodir_location_geo_home_link')) { |
@@ -197,17 +197,17 @@ discard block |
||
| 197 | 197 | add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if($gd_page_id){ |
|
| 200 | + if ($gd_page_id) { |
|
| 201 | 201 | $post = get_post($gd_page_id); |
| 202 | 202 | $slug = $post->post_name; |
| 203 | 203 | //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
| 204 | - $info_url = trailingslashit($home_url)."$slug/"; |
|
| 205 | - }else{ |
|
| 204 | + $info_url = trailingslashit($home_url) . "$slug/"; |
|
| 205 | + } else { |
|
| 206 | 206 | $info_url = trailingslashit($home_url); |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - if($args){ |
|
| 210 | - $info_url = add_query_arg($args,$info_url ); |
|
| 209 | + if ($args) { |
|
| 210 | + $info_url = add_query_arg($args, $info_url); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | return $info_url; |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | * @param string $charset Character set to use for conversion. |
| 226 | 226 | * @return string Returns converted string. |
| 227 | 227 | */ |
| 228 | -function geodir_ucwords($string, $charset='UTF-8') { |
|
| 228 | +function geodir_ucwords($string, $charset = 'UTF-8') { |
|
| 229 | 229 | if (function_exists('mb_convert_case')) { |
| 230 | 230 | return mb_convert_case($string, MB_CASE_TITLE, $charset); |
| 231 | 231 | } else { |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | * @param string $charset Character set to use for conversion. |
| 246 | 246 | * @return string Returns converted string. |
| 247 | 247 | */ |
| 248 | -function geodir_strtolower($string, $charset='UTF-8') { |
|
| 248 | +function geodir_strtolower($string, $charset = 'UTF-8') { |
|
| 249 | 249 | if (function_exists('mb_convert_case')) { |
| 250 | 250 | return mb_convert_case($string, MB_CASE_LOWER, $charset); |
| 251 | 251 | } else { |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * @param string $charset Character set to use for conversion. |
| 266 | 266 | * @return string Returns converted string. |
| 267 | 267 | */ |
| 268 | -function geodir_strtoupper($string, $charset='UTF-8') { |
|
| 268 | +function geodir_strtoupper($string, $charset = 'UTF-8') { |
|
| 269 | 269 | if (function_exists('mb_convert_case')) { |
| 270 | 270 | return mb_convert_case($string, MB_CASE_UPPER, $charset); |
| 271 | 271 | } else { |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | $url = trim($parts[0]); |
| 298 | 298 | if ($formatted && $url != '') { |
| 299 | - $url = str_replace( ' ', '%20', $url ); |
|
| 299 | + $url = str_replace(' ', '%20', $url); |
|
| 300 | 300 | $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\[\]\\x80-\\xff]|i', '', $url); |
| 301 | 301 | |
| 302 | 302 | if (0 !== stripos($url, 'mailto:')) { |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | |
| 307 | 307 | $url = str_replace(';//', '://', $url); |
| 308 | 308 | |
| 309 | - if (strpos($url, ':') === false && ! in_array($url[0], array('/', '#', '?')) && !preg_match('/^[a-z0-9-]+?\.php/i', $url)) { |
|
| 309 | + if (strpos($url, ':') === false && !in_array($url[0], array('/', '#', '?')) && !preg_match('/^[a-z0-9-]+?\.php/i', $url)) { |
|
| 310 | 310 | $url = 'http://' . $url; |
| 311 | 311 | } |
| 312 | 312 | |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | * @package GeoDirectory |
| 450 | 450 | */ |
| 451 | 451 | function _gd_die_handler() { |
| 452 | - if ( defined( 'GD_TESTING_MODE' ) ) { |
|
| 452 | + if (defined('GD_TESTING_MODE')) { |
|
| 453 | 453 | return '_gd_die_handler'; |
| 454 | 454 | } else { |
| 455 | 455 | die(); |
@@ -467,8 +467,8 @@ discard block |
||
| 467 | 467 | * @param string $title Optional. Error title. |
| 468 | 468 | * @param int $status Optional. Status code. |
| 469 | 469 | */ |
| 470 | -function gd_die( $message = '', $title = '', $status = 400 ) { |
|
| 471 | - add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 ); |
|
| 472 | - add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 ); |
|
| 473 | - wp_die( $message, $title, array( 'response' => $status )); |
|
| 470 | +function gd_die($message = '', $title = '', $status = 400) { |
|
| 471 | + add_filter('wp_die_ajax_handler', '_gd_die_handler', 10, 3); |
|
| 472 | + add_filter('wp_die_handler', '_gd_die_handler', 10, 3); |
|
| 473 | + wp_die($message, $title, array('response' => $status)); |
|
| 474 | 474 | } |
| 475 | 475 | \ No newline at end of file |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Helper functions, this file contains functions made to make a developer's life easier. |
|
| 4 | - * |
|
| 5 | - * @since 1.4.6 |
|
| 6 | - * @package GeoDirectory |
|
| 7 | - */ |
|
| 3 | + * Helper functions, this file contains functions made to make a developer's life easier. |
|
| 4 | + * |
|
| 5 | + * @since 1.4.6 |
|
| 6 | + * @package GeoDirectory |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Get the page ID of the add listing page. |
@@ -14,13 +14,13 @@ discard block |
||
| 14 | 14 | * @return int|null Return the page ID if present or null if not. |
| 15 | 15 | */ |
| 16 | 16 | function geodir_add_listing_page_id(){ |
| 17 | - $gd_page_id = get_option('geodir_add_listing_page'); |
|
| 17 | + $gd_page_id = get_option('geodir_add_listing_page'); |
|
| 18 | 18 | |
| 19 | - if (function_exists('icl_object_id')) { |
|
| 20 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 21 | - } |
|
| 19 | + if (function_exists('icl_object_id')) { |
|
| 20 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - return $gd_page_id; |
|
| 23 | + return $gd_page_id; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | * @return int|null Return the page ID if present or null if not. |
| 32 | 32 | */ |
| 33 | 33 | function geodir_preview_page_id(){ |
| 34 | - $gd_page_id = get_option('geodir_preview_page'); |
|
| 34 | + $gd_page_id = get_option('geodir_preview_page'); |
|
| 35 | 35 | |
| 36 | - if (function_exists('icl_object_id')) { |
|
| 37 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 38 | - } |
|
| 36 | + if (function_exists('icl_object_id')) { |
|
| 37 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - return $gd_page_id; |
|
| 40 | + return $gd_page_id; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | /** |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | * @return int|null Return the page ID if present or null if not. |
| 49 | 49 | */ |
| 50 | 50 | function geodir_success_page_id(){ |
| 51 | - $gd_page_id = get_option('geodir_success_page'); |
|
| 51 | + $gd_page_id = get_option('geodir_success_page'); |
|
| 52 | 52 | |
| 53 | - if (function_exists('icl_object_id')) { |
|
| 54 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 55 | - } |
|
| 53 | + if (function_exists('icl_object_id')) { |
|
| 54 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - return $gd_page_id; |
|
| 57 | + return $gd_page_id; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -65,13 +65,13 @@ discard block |
||
| 65 | 65 | * @return int|null Return the page ID if present or null if not. |
| 66 | 66 | */ |
| 67 | 67 | function geodir_location_page_id(){ |
| 68 | - $gd_page_id = get_option('geodir_location_page'); |
|
| 68 | + $gd_page_id = get_option('geodir_location_page'); |
|
| 69 | 69 | |
| 70 | - if (function_exists('icl_object_id')) { |
|
| 71 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 72 | - } |
|
| 70 | + if (function_exists('icl_object_id')) { |
|
| 71 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - return $gd_page_id; |
|
| 74 | + return $gd_page_id; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | * @return int|null Return the page ID if present or null if not. |
| 83 | 83 | */ |
| 84 | 84 | function geodir_home_page_id(){ |
| 85 | - $gd_page_id = get_option('geodir_home_page'); |
|
| 85 | + $gd_page_id = get_option('geodir_home_page'); |
|
| 86 | 86 | |
| 87 | - if (function_exists('icl_object_id')) { |
|
| 88 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 89 | - } |
|
| 87 | + if (function_exists('icl_object_id')) { |
|
| 88 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - return $gd_page_id; |
|
| 91 | + return $gd_page_id; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -99,13 +99,13 @@ discard block |
||
| 99 | 99 | * @return int|null Return the page ID if present or null if not. |
| 100 | 100 | */ |
| 101 | 101 | function geodir_info_page_id(){ |
| 102 | - $gd_page_id = get_option('geodir_info_page'); |
|
| 102 | + $gd_page_id = get_option('geodir_info_page'); |
|
| 103 | 103 | |
| 104 | - if (function_exists('icl_object_id')) { |
|
| 105 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 106 | - } |
|
| 104 | + if (function_exists('icl_object_id')) { |
|
| 105 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - return $gd_page_id; |
|
| 108 | + return $gd_page_id; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /** |
@@ -116,13 +116,13 @@ discard block |
||
| 116 | 116 | * @return int|null Return the page ID if present or null if not. |
| 117 | 117 | */ |
| 118 | 118 | function geodir_login_page_id(){ |
| 119 | - $gd_page_id = get_option('geodir_login_page'); |
|
| 119 | + $gd_page_id = get_option('geodir_login_page'); |
|
| 120 | 120 | |
| 121 | - if (function_exists('icl_object_id')) { |
|
| 122 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 123 | - } |
|
| 121 | + if (function_exists('icl_object_id')) { |
|
| 122 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - return $gd_page_id; |
|
| 125 | + return $gd_page_id; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
@@ -134,45 +134,45 @@ discard block |
||
| 134 | 134 | * @return int|null Return the page ID if present or null if not. |
| 135 | 135 | */ |
| 136 | 136 | function geodir_login_url($args=array()){ |
| 137 | - $gd_page_id = get_option('geodir_login_page'); |
|
| 138 | - |
|
| 139 | - if (function_exists('icl_object_id')) { |
|
| 140 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - if (function_exists('geodir_location_geo_home_link')) { |
|
| 144 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
| 145 | - } |
|
| 146 | - $home_url = get_home_url(); |
|
| 147 | - if (function_exists('geodir_location_geo_home_link')) { |
|
| 148 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - if($gd_page_id){ |
|
| 152 | - $post = get_post($gd_page_id); |
|
| 153 | - $slug = $post->post_name; |
|
| 154 | - //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
|
| 155 | - $login_url = trailingslashit($home_url)."$slug/"; |
|
| 156 | - }else{ |
|
| 157 | - $login_url = trailingslashit($home_url)."?geodir_signup=true"; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - if($args){ |
|
| 161 | - $login_url = add_query_arg($args,$login_url ); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Filter the GeoDirectory login page url. |
|
| 166 | - * |
|
| 167 | - * This filter can be used to change the GeoDirectory page url. |
|
| 168 | - * |
|
| 169 | - * @since 1.5.3 |
|
| 170 | - * @package GeoDirectory |
|
| 171 | - * @param string $login_url The url of the login page. |
|
| 172 | - * @param array $args The array of query args used. |
|
| 173 | - * @param int $gd_page_id The page id of the GD login page. |
|
| 174 | - */ |
|
| 175 | - return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id); |
|
| 137 | + $gd_page_id = get_option('geodir_login_page'); |
|
| 138 | + |
|
| 139 | + if (function_exists('icl_object_id')) { |
|
| 140 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + if (function_exists('geodir_location_geo_home_link')) { |
|
| 144 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
| 145 | + } |
|
| 146 | + $home_url = get_home_url(); |
|
| 147 | + if (function_exists('geodir_location_geo_home_link')) { |
|
| 148 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + if($gd_page_id){ |
|
| 152 | + $post = get_post($gd_page_id); |
|
| 153 | + $slug = $post->post_name; |
|
| 154 | + //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
|
| 155 | + $login_url = trailingslashit($home_url)."$slug/"; |
|
| 156 | + }else{ |
|
| 157 | + $login_url = trailingslashit($home_url)."?geodir_signup=true"; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + if($args){ |
|
| 161 | + $login_url = add_query_arg($args,$login_url ); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Filter the GeoDirectory login page url. |
|
| 166 | + * |
|
| 167 | + * This filter can be used to change the GeoDirectory page url. |
|
| 168 | + * |
|
| 169 | + * @since 1.5.3 |
|
| 170 | + * @package GeoDirectory |
|
| 171 | + * @param string $login_url The url of the login page. |
|
| 172 | + * @param array $args The array of query args used. |
|
| 173 | + * @param int $gd_page_id The page id of the GD login page. |
|
| 174 | + */ |
|
| 175 | + return apply_filters('geodir_login_url',$login_url,$args,$gd_page_id); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | /** |
@@ -183,34 +183,34 @@ discard block |
||
| 183 | 183 | * @return string Info page url. |
| 184 | 184 | */ |
| 185 | 185 | function geodir_info_url($args=array()){ |
| 186 | - $gd_page_id = get_option('geodir_info_page'); |
|
| 187 | - |
|
| 188 | - if (function_exists('icl_object_id')) { |
|
| 189 | - $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - if (function_exists('geodir_location_geo_home_link')) { |
|
| 193 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
| 194 | - } |
|
| 195 | - $home_url = get_home_url(); |
|
| 196 | - if (function_exists('geodir_location_geo_home_link')) { |
|
| 197 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - if($gd_page_id){ |
|
| 201 | - $post = get_post($gd_page_id); |
|
| 202 | - $slug = $post->post_name; |
|
| 203 | - //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
|
| 204 | - $info_url = trailingslashit($home_url)."$slug/"; |
|
| 205 | - }else{ |
|
| 206 | - $info_url = trailingslashit($home_url); |
|
| 207 | - } |
|
| 208 | - |
|
| 209 | - if($args){ |
|
| 210 | - $info_url = add_query_arg($args,$info_url ); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - return $info_url; |
|
| 186 | + $gd_page_id = get_option('geodir_info_page'); |
|
| 187 | + |
|
| 188 | + if (function_exists('icl_object_id')) { |
|
| 189 | + $gd_page_id = icl_object_id($gd_page_id, 'page', true); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + if (function_exists('geodir_location_geo_home_link')) { |
|
| 193 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
| 194 | + } |
|
| 195 | + $home_url = get_home_url(); |
|
| 196 | + if (function_exists('geodir_location_geo_home_link')) { |
|
| 197 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + if($gd_page_id){ |
|
| 201 | + $post = get_post($gd_page_id); |
|
| 202 | + $slug = $post->post_name; |
|
| 203 | + //$login_url = get_permalink($gd_page_id );// get_permalink can only be user after theme-Setup hook, any earlier and it errors |
|
| 204 | + $info_url = trailingslashit($home_url)."$slug/"; |
|
| 205 | + }else{ |
|
| 206 | + $info_url = trailingslashit($home_url); |
|
| 207 | + } |
|
| 208 | + |
|
| 209 | + if($args){ |
|
| 210 | + $info_url = add_query_arg($args,$info_url ); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + return $info_url; |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -226,11 +226,11 @@ discard block |
||
| 226 | 226 | * @return string Returns converted string. |
| 227 | 227 | */ |
| 228 | 228 | function geodir_ucwords($string, $charset='UTF-8') { |
| 229 | - if (function_exists('mb_convert_case')) { |
|
| 230 | - return mb_convert_case($string, MB_CASE_TITLE, $charset); |
|
| 231 | - } else { |
|
| 232 | - return ucwords($string); |
|
| 233 | - } |
|
| 229 | + if (function_exists('mb_convert_case')) { |
|
| 230 | + return mb_convert_case($string, MB_CASE_TITLE, $charset); |
|
| 231 | + } else { |
|
| 232 | + return ucwords($string); |
|
| 233 | + } |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | /** |
@@ -246,11 +246,11 @@ discard block |
||
| 246 | 246 | * @return string Returns converted string. |
| 247 | 247 | */ |
| 248 | 248 | function geodir_strtolower($string, $charset='UTF-8') { |
| 249 | - if (function_exists('mb_convert_case')) { |
|
| 250 | - return mb_convert_case($string, MB_CASE_LOWER, $charset); |
|
| 251 | - } else { |
|
| 252 | - return strtolower($string); |
|
| 253 | - } |
|
| 249 | + if (function_exists('mb_convert_case')) { |
|
| 250 | + return mb_convert_case($string, MB_CASE_LOWER, $charset); |
|
| 251 | + } else { |
|
| 252 | + return strtolower($string); |
|
| 253 | + } |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -266,11 +266,11 @@ discard block |
||
| 266 | 266 | * @return string Returns converted string. |
| 267 | 267 | */ |
| 268 | 268 | function geodir_strtoupper($string, $charset='UTF-8') { |
| 269 | - if (function_exists('mb_convert_case')) { |
|
| 270 | - return mb_convert_case($string, MB_CASE_UPPER, $charset); |
|
| 271 | - } else { |
|
| 272 | - return strtoupper($string); |
|
| 273 | - } |
|
| 269 | + if (function_exists('mb_convert_case')) { |
|
| 270 | + return mb_convert_case($string, MB_CASE_UPPER, $charset); |
|
| 271 | + } else { |
|
| 272 | + return strtoupper($string); |
|
| 273 | + } |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
@@ -449,11 +449,11 @@ discard block |
||
| 449 | 449 | * @package GeoDirectory |
| 450 | 450 | */ |
| 451 | 451 | function _gd_die_handler() { |
| 452 | - if ( defined( 'GD_TESTING_MODE' ) ) { |
|
| 453 | - return '_gd_die_handler'; |
|
| 454 | - } else { |
|
| 455 | - die(); |
|
| 456 | - } |
|
| 452 | + if ( defined( 'GD_TESTING_MODE' ) ) { |
|
| 453 | + return '_gd_die_handler'; |
|
| 454 | + } else { |
|
| 455 | + die(); |
|
| 456 | + } |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | * @param int $status Optional. Status code. |
| 469 | 469 | */ |
| 470 | 470 | function gd_die( $message = '', $title = '', $status = 400 ) { |
| 471 | - add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 ); |
|
| 472 | - add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 ); |
|
| 473 | - wp_die( $message, $title, array( 'response' => $status )); |
|
| 471 | + add_filter( 'wp_die_ajax_handler', '_gd_die_handler', 10, 3 ); |
|
| 472 | + add_filter( 'wp_die_handler', '_gd_die_handler', 10, 3 ); |
|
| 473 | + wp_die( $message, $title, array( 'response' => $status )); |
|
| 474 | 474 | } |
| 475 | 475 | \ No newline at end of file |
@@ -64,6 +64,9 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | class WP_UnitTest_Factory_For_Post extends WP_UnitTest_Factory_For_Thing { |
| 66 | 66 | |
| 67 | + /** |
|
| 68 | + * @param WP_UnitTest_Factory $factory |
|
| 69 | + */ |
|
| 67 | 70 | function __construct( $factory = null ) { |
| 68 | 71 | parent::__construct( $factory ); |
| 69 | 72 | $this->default_generation_definitions = array( |
@@ -127,6 +130,9 @@ discard block |
||
| 127 | 130 | |
| 128 | 131 | class WP_UnitTest_Factory_For_User extends WP_UnitTest_Factory_For_Thing { |
| 129 | 132 | |
| 133 | + /** |
|
| 134 | + * @param WP_UnitTest_Factory $factory |
|
| 135 | + */ |
|
| 130 | 136 | function __construct( $factory = null ) { |
| 131 | 137 | parent::__construct( $factory ); |
| 132 | 138 | $this->default_generation_definitions = array( |
@@ -152,6 +158,9 @@ discard block |
||
| 152 | 158 | |
| 153 | 159 | class WP_UnitTest_Factory_For_Comment extends WP_UnitTest_Factory_For_Thing { |
| 154 | 160 | |
| 161 | + /** |
|
| 162 | + * @param WP_UnitTest_Factory $factory |
|
| 163 | + */ |
|
| 155 | 164 | function __construct( $factory = null ) { |
| 156 | 165 | parent::__construct( $factory ); |
| 157 | 166 | $this->default_generation_definitions = array( |
@@ -183,6 +192,9 @@ discard block |
||
| 183 | 192 | |
| 184 | 193 | class WP_UnitTest_Factory_For_Blog extends WP_UnitTest_Factory_For_Thing { |
| 185 | 194 | |
| 195 | + /** |
|
| 196 | + * @param WP_UnitTest_Factory $factory |
|
| 197 | + */ |
|
| 186 | 198 | function __construct( $factory = null ) { |
| 187 | 199 | global $current_site, $base; |
| 188 | 200 | parent::__construct( $factory ); |
@@ -219,6 +231,9 @@ discard block |
||
| 219 | 231 | |
| 220 | 232 | class WP_UnitTest_Factory_For_Network extends WP_UnitTest_Factory_For_Thing { |
| 221 | 233 | |
| 234 | + /** |
|
| 235 | + * @param WP_UnitTest_Factory $factory |
|
| 236 | + */ |
|
| 222 | 237 | function __construct( $factory = null ) { |
| 223 | 238 | parent::__construct( $factory ); |
| 224 | 239 | $this->default_generation_definitions = array( |
@@ -255,6 +270,10 @@ discard block |
||
| 255 | 270 | private $taxonomy; |
| 256 | 271 | const DEFAULT_TAXONOMY = 'post_tag'; |
| 257 | 272 | |
| 273 | + /** |
|
| 274 | + * @param WP_UnitTest_Factory $factory |
|
| 275 | + * @param string $taxonomy |
|
| 276 | + */ |
|
| 258 | 277 | function __construct( $factory = null, $taxonomy = null ) { |
| 259 | 278 | parent::__construct( $factory ); |
| 260 | 279 | $this->taxonomy = $taxonomy ? $taxonomy : self::DEFAULT_TAXONOMY; |
@@ -342,6 +361,9 @@ discard block |
||
| 342 | 361 | |
| 343 | 362 | abstract function get_object_by_id( $object_id ); |
| 344 | 363 | |
| 364 | + /** |
|
| 365 | + * @param integer $count |
|
| 366 | + */ |
|
| 345 | 367 | function create_many( $count, $args = array(), $generation_definitions = null ) { |
| 346 | 368 | $results = array(); |
| 347 | 369 | for ( $i = 0; $i < $count; $i++ ) { |
@@ -405,6 +427,9 @@ discard block |
||
| 405 | 427 | public $next; |
| 406 | 428 | public $template_string; |
| 407 | 429 | |
| 430 | + /** |
|
| 431 | + * @param integer $start |
|
| 432 | + */ |
|
| 408 | 433 | function __construct( $template_string = '%s', $start = null ) { |
| 409 | 434 | if ( $start ) { |
| 410 | 435 | $this->next = $start; |
@@ -48,78 +48,78 @@ discard block |
||
| 48 | 48 | public $network; |
| 49 | 49 | |
| 50 | 50 | function __construct() { |
| 51 | - $this->post = new WP_UnitTest_Factory_For_Post( $this ); |
|
| 52 | - $this->attachment = new WP_UnitTest_Factory_For_Attachment( $this ); |
|
| 53 | - $this->comment = new WP_UnitTest_Factory_For_Comment( $this ); |
|
| 54 | - $this->user = new WP_UnitTest_Factory_For_User( $this ); |
|
| 55 | - $this->term = new WP_UnitTest_Factory_For_Term( $this ); |
|
| 56 | - $this->category = new WP_UnitTest_Factory_For_Term( $this, 'category' ); |
|
| 57 | - $this->tag = new WP_UnitTest_Factory_For_Term( $this, 'post_tag' ); |
|
| 58 | - if ( is_multisite() ) { |
|
| 59 | - $this->blog = new WP_UnitTest_Factory_For_Blog( $this ); |
|
| 60 | - $this->network = new WP_UnitTest_Factory_For_Network( $this ); |
|
| 51 | + $this->post = new WP_UnitTest_Factory_For_Post($this); |
|
| 52 | + $this->attachment = new WP_UnitTest_Factory_For_Attachment($this); |
|
| 53 | + $this->comment = new WP_UnitTest_Factory_For_Comment($this); |
|
| 54 | + $this->user = new WP_UnitTest_Factory_For_User($this); |
|
| 55 | + $this->term = new WP_UnitTest_Factory_For_Term($this); |
|
| 56 | + $this->category = new WP_UnitTest_Factory_For_Term($this, 'category'); |
|
| 57 | + $this->tag = new WP_UnitTest_Factory_For_Term($this, 'post_tag'); |
|
| 58 | + if (is_multisite()) { |
|
| 59 | + $this->blog = new WP_UnitTest_Factory_For_Blog($this); |
|
| 60 | + $this->network = new WP_UnitTest_Factory_For_Network($this); |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | class WP_UnitTest_Factory_For_Post extends WP_UnitTest_Factory_For_Thing { |
| 66 | 66 | |
| 67 | - function __construct( $factory = null ) { |
|
| 68 | - parent::__construct( $factory ); |
|
| 67 | + function __construct($factory = null) { |
|
| 68 | + parent::__construct($factory); |
|
| 69 | 69 | $this->default_generation_definitions = array( |
| 70 | 70 | 'post_status' => 'publish', |
| 71 | - 'post_title' => new WP_UnitTest_Generator_Sequence( 'Post title %s' ), |
|
| 72 | - 'post_content' => new WP_UnitTest_Generator_Sequence( 'Post content %s' ), |
|
| 73 | - 'post_excerpt' => new WP_UnitTest_Generator_Sequence( 'Post excerpt %s' ), |
|
| 71 | + 'post_title' => new WP_UnitTest_Generator_Sequence('Post title %s'), |
|
| 72 | + 'post_content' => new WP_UnitTest_Generator_Sequence('Post content %s'), |
|
| 73 | + 'post_excerpt' => new WP_UnitTest_Generator_Sequence('Post excerpt %s'), |
|
| 74 | 74 | 'post_type' => 'post' |
| 75 | 75 | ); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - function create_object( $args ) { |
|
| 79 | - return wp_insert_post( $args ); |
|
| 78 | + function create_object($args) { |
|
| 79 | + return wp_insert_post($args); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - function update_object( $post_id, $fields ) { |
|
| 82 | + function update_object($post_id, $fields) { |
|
| 83 | 83 | $fields['ID'] = $post_id; |
| 84 | - return wp_update_post( $fields ); |
|
| 84 | + return wp_update_post($fields); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - function get_object_by_id( $post_id ) { |
|
| 88 | - return get_post( $post_id ); |
|
| 87 | + function get_object_by_id($post_id) { |
|
| 88 | + return get_post($post_id); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | class WP_UnitTest_Factory_For_Attachment extends WP_UnitTest_Factory_For_Post { |
| 93 | 93 | |
| 94 | - function create_object( $file, $parent = 0, $args = array() ) { |
|
| 95 | - return wp_insert_attachment( $args, $file, $parent ); |
|
| 94 | + function create_object($file, $parent = 0, $args = array()) { |
|
| 95 | + return wp_insert_attachment($args, $file, $parent); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - function create_upload_object( $file, $parent = 0 ) { |
|
| 98 | + function create_upload_object($file, $parent = 0) { |
|
| 99 | 99 | $contents = file_get_contents($file); |
| 100 | 100 | $upload = wp_upload_bits(basename($file), null, $contents); |
| 101 | 101 | |
| 102 | 102 | $type = ''; |
| 103 | - if ( ! empty($upload['type']) ) { |
|
| 103 | + if (!empty($upload['type'])) { |
|
| 104 | 104 | $type = $upload['type']; |
| 105 | 105 | } else { |
| 106 | - $mime = wp_check_filetype( $upload['file'] ); |
|
| 106 | + $mime = wp_check_filetype($upload['file']); |
|
| 107 | 107 | if ($mime) |
| 108 | 108 | $type = $mime['type']; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | $attachment = array( |
| 112 | - 'post_title' => basename( $upload['file'] ), |
|
| 112 | + 'post_title' => basename($upload['file']), |
|
| 113 | 113 | 'post_content' => '', |
| 114 | 114 | 'post_type' => 'attachment', |
| 115 | 115 | 'post_parent' => $parent, |
| 116 | 116 | 'post_mime_type' => $type, |
| 117 | - 'guid' => $upload[ 'url' ], |
|
| 117 | + 'guid' => $upload['url'], |
|
| 118 | 118 | ); |
| 119 | 119 | |
| 120 | 120 | // Save the data |
| 121 | - $id = wp_insert_attachment( $attachment, $upload[ 'file' ], $parent ); |
|
| 122 | - wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $upload['file'] ) ); |
|
| 121 | + $id = wp_insert_attachment($attachment, $upload['file'], $parent); |
|
| 122 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $upload['file'])); |
|
| 123 | 123 | |
| 124 | 124 | return $id; |
| 125 | 125 | } |
@@ -127,126 +127,126 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | class WP_UnitTest_Factory_For_User extends WP_UnitTest_Factory_For_Thing { |
| 129 | 129 | |
| 130 | - function __construct( $factory = null ) { |
|
| 131 | - parent::__construct( $factory ); |
|
| 130 | + function __construct($factory = null) { |
|
| 131 | + parent::__construct($factory); |
|
| 132 | 132 | $this->default_generation_definitions = array( |
| 133 | - 'user_login' => new WP_UnitTest_Generator_Sequence( 'User %s' ), |
|
| 133 | + 'user_login' => new WP_UnitTest_Generator_Sequence('User %s'), |
|
| 134 | 134 | 'user_pass' => 'password', |
| 135 | - 'user_email' => new WP_UnitTest_Generator_Sequence( 'user_%[email protected]' ), |
|
| 135 | + 'user_email' => new WP_UnitTest_Generator_Sequence('user_%[email protected]'), |
|
| 136 | 136 | ); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - function create_object( $args ) { |
|
| 140 | - return wp_insert_user( $args ); |
|
| 139 | + function create_object($args) { |
|
| 140 | + return wp_insert_user($args); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - function update_object( $user_id, $fields ) { |
|
| 143 | + function update_object($user_id, $fields) { |
|
| 144 | 144 | $fields['ID'] = $user_id; |
| 145 | - return wp_update_user( $fields ); |
|
| 145 | + return wp_update_user($fields); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - function get_object_by_id( $user_id ) { |
|
| 149 | - return new WP_User( $user_id ); |
|
| 148 | + function get_object_by_id($user_id) { |
|
| 149 | + return new WP_User($user_id); |
|
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | class WP_UnitTest_Factory_For_Comment extends WP_UnitTest_Factory_For_Thing { |
| 154 | 154 | |
| 155 | - function __construct( $factory = null ) { |
|
| 156 | - parent::__construct( $factory ); |
|
| 155 | + function __construct($factory = null) { |
|
| 156 | + parent::__construct($factory); |
|
| 157 | 157 | $this->default_generation_definitions = array( |
| 158 | - 'comment_author' => new WP_UnitTest_Generator_Sequence( 'Commenter %s' ), |
|
| 159 | - 'comment_author_url' => new WP_UnitTest_Generator_Sequence( 'http://example.com/%s/' ), |
|
| 158 | + 'comment_author' => new WP_UnitTest_Generator_Sequence('Commenter %s'), |
|
| 159 | + 'comment_author_url' => new WP_UnitTest_Generator_Sequence('http://example.com/%s/'), |
|
| 160 | 160 | 'comment_approved' => 1, |
| 161 | 161 | 'comment_content' => 'This is a comment' |
| 162 | 162 | ); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - function create_object( $args ) { |
|
| 166 | - return wp_insert_comment( $this->addslashes_deep( $args ) ); |
|
| 165 | + function create_object($args) { |
|
| 166 | + return wp_insert_comment($this->addslashes_deep($args)); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - function update_object( $comment_id, $fields ) { |
|
| 169 | + function update_object($comment_id, $fields) { |
|
| 170 | 170 | $fields['comment_ID'] = $comment_id; |
| 171 | - return wp_update_comment( $this->addslashes_deep( $fields ) ); |
|
| 171 | + return wp_update_comment($this->addslashes_deep($fields)); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - function create_post_comments( $post_id, $count = 1, $args = array(), $generation_definitions = null ) { |
|
| 174 | + function create_post_comments($post_id, $count = 1, $args = array(), $generation_definitions = null) { |
|
| 175 | 175 | $args['comment_post_ID'] = $post_id; |
| 176 | - return $this->create_many( $count, $args, $generation_definitions ); |
|
| 176 | + return $this->create_many($count, $args, $generation_definitions); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - function get_object_by_id( $comment_id ) { |
|
| 180 | - return get_comment( $comment_id ); |
|
| 179 | + function get_object_by_id($comment_id) { |
|
| 180 | + return get_comment($comment_id); |
|
| 181 | 181 | } |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | class WP_UnitTest_Factory_For_Blog extends WP_UnitTest_Factory_For_Thing { |
| 185 | 185 | |
| 186 | - function __construct( $factory = null ) { |
|
| 186 | + function __construct($factory = null) { |
|
| 187 | 187 | global $current_site, $base; |
| 188 | - parent::__construct( $factory ); |
|
| 188 | + parent::__construct($factory); |
|
| 189 | 189 | $this->default_generation_definitions = array( |
| 190 | 190 | 'domain' => $current_site->domain, |
| 191 | - 'path' => new WP_UnitTest_Generator_Sequence( $base . 'testpath%s' ), |
|
| 192 | - 'title' => new WP_UnitTest_Generator_Sequence( 'Site %s' ), |
|
| 191 | + 'path' => new WP_UnitTest_Generator_Sequence($base . 'testpath%s'), |
|
| 192 | + 'title' => new WP_UnitTest_Generator_Sequence('Site %s'), |
|
| 193 | 193 | 'site_id' => $current_site->id, |
| 194 | 194 | ); |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | - function create_object( $args ) { |
|
| 197 | + function create_object($args) { |
|
| 198 | 198 | global $wpdb; |
| 199 | - $meta = isset( $args['meta'] ) ? $args['meta'] : array(); |
|
| 200 | - $user_id = isset( $args['user_id'] ) ? $args['user_id'] : get_current_user_id(); |
|
| 199 | + $meta = isset($args['meta']) ? $args['meta'] : array(); |
|
| 200 | + $user_id = isset($args['user_id']) ? $args['user_id'] : get_current_user_id(); |
|
| 201 | 201 | // temp tables will trigger db errors when we attempt to reference them as new temp tables |
| 202 | 202 | $suppress = $wpdb->suppress_errors(); |
| 203 | - $blog = wpmu_create_blog( $args['domain'], $args['path'], $args['title'], $user_id, $meta, $args['site_id'] ); |
|
| 204 | - $wpdb->suppress_errors( $suppress ); |
|
| 203 | + $blog = wpmu_create_blog($args['domain'], $args['path'], $args['title'], $user_id, $meta, $args['site_id']); |
|
| 204 | + $wpdb->suppress_errors($suppress); |
|
| 205 | 205 | |
| 206 | 206 | // Tell WP we're done installing. |
| 207 | - wp_installing( false ); |
|
| 207 | + wp_installing(false); |
|
| 208 | 208 | |
| 209 | 209 | return $blog; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - function update_object( $blog_id, $fields ) {} |
|
| 212 | + function update_object($blog_id, $fields) {} |
|
| 213 | 213 | |
| 214 | - function get_object_by_id( $blog_id ) { |
|
| 215 | - return get_blog_details( $blog_id, false ); |
|
| 214 | + function get_object_by_id($blog_id) { |
|
| 215 | + return get_blog_details($blog_id, false); |
|
| 216 | 216 | } |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | |
| 220 | 220 | class WP_UnitTest_Factory_For_Network extends WP_UnitTest_Factory_For_Thing { |
| 221 | 221 | |
| 222 | - function __construct( $factory = null ) { |
|
| 223 | - parent::__construct( $factory ); |
|
| 222 | + function __construct($factory = null) { |
|
| 223 | + parent::__construct($factory); |
|
| 224 | 224 | $this->default_generation_definitions = array( |
| 225 | 225 | 'domain' => WP_TESTS_DOMAIN, |
| 226 | - 'title' => new WP_UnitTest_Generator_Sequence( 'Network %s' ), |
|
| 227 | - 'path' => new WP_UnitTest_Generator_Sequence( '/testpath%s/' ), |
|
| 228 | - 'network_id' => new WP_UnitTest_Generator_Sequence( '%s', 2 ), |
|
| 226 | + 'title' => new WP_UnitTest_Generator_Sequence('Network %s'), |
|
| 227 | + 'path' => new WP_UnitTest_Generator_Sequence('/testpath%s/'), |
|
| 228 | + 'network_id' => new WP_UnitTest_Generator_Sequence('%s', 2), |
|
| 229 | 229 | 'subdomain_install' => false, |
| 230 | 230 | ); |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | - function create_object( $args ) { |
|
| 233 | + function create_object($args) { |
|
| 234 | 234 | require_once ABSPATH . 'wp-admin/includes/upgrade.php'; |
| 235 | 235 | |
| 236 | - if ( ! isset( $args['user'] ) ) { |
|
| 236 | + if (!isset($args['user'])) { |
|
| 237 | 237 | $email = WP_TESTS_EMAIL; |
| 238 | 238 | } else { |
| 239 | - $email = get_userdata( $args['user'] )->user_email; |
|
| 239 | + $email = get_userdata($args['user'])->user_email; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - populate_network( $args['network_id'], $args['domain'], $email, $args['title'], $args['path'], $args['subdomain_install'] ); |
|
| 242 | + populate_network($args['network_id'], $args['domain'], $email, $args['title'], $args['path'], $args['subdomain_install']); |
|
| 243 | 243 | return $args['network_id']; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - function update_object( $network_id, $fields ) {} |
|
| 246 | + function update_object($network_id, $fields) {} |
|
| 247 | 247 | |
| 248 | - function get_object_by_id( $network_id ) { |
|
| 249 | - return wp_get_network( $network_id ); |
|
| 248 | + function get_object_by_id($network_id) { |
|
| 249 | + return wp_get_network($network_id); |
|
| 250 | 250 | } |
| 251 | 251 | } |
| 252 | 252 | |
@@ -255,44 +255,44 @@ discard block |
||
| 255 | 255 | private $taxonomy; |
| 256 | 256 | const DEFAULT_TAXONOMY = 'post_tag'; |
| 257 | 257 | |
| 258 | - function __construct( $factory = null, $taxonomy = null ) { |
|
| 259 | - parent::__construct( $factory ); |
|
| 258 | + function __construct($factory = null, $taxonomy = null) { |
|
| 259 | + parent::__construct($factory); |
|
| 260 | 260 | $this->taxonomy = $taxonomy ? $taxonomy : self::DEFAULT_TAXONOMY; |
| 261 | 261 | $this->default_generation_definitions = array( |
| 262 | - 'name' => new WP_UnitTest_Generator_Sequence( 'Term %s' ), |
|
| 262 | + 'name' => new WP_UnitTest_Generator_Sequence('Term %s'), |
|
| 263 | 263 | 'taxonomy' => $this->taxonomy, |
| 264 | - 'description' => new WP_UnitTest_Generator_Sequence( 'Term description %s' ), |
|
| 264 | + 'description' => new WP_UnitTest_Generator_Sequence('Term description %s'), |
|
| 265 | 265 | ); |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | - function create_object( $args ) { |
|
| 269 | - $args = array_merge( array( 'taxonomy' => $this->taxonomy ), $args ); |
|
| 270 | - $term_id_pair = wp_insert_term( $args['name'], $args['taxonomy'], $args ); |
|
| 271 | - if ( is_wp_error( $term_id_pair ) ) |
|
| 268 | + function create_object($args) { |
|
| 269 | + $args = array_merge(array('taxonomy' => $this->taxonomy), $args); |
|
| 270 | + $term_id_pair = wp_insert_term($args['name'], $args['taxonomy'], $args); |
|
| 271 | + if (is_wp_error($term_id_pair)) |
|
| 272 | 272 | return $term_id_pair; |
| 273 | 273 | return $term_id_pair['term_id']; |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | - function update_object( $term, $fields ) { |
|
| 277 | - $fields = array_merge( array( 'taxonomy' => $this->taxonomy ), $fields ); |
|
| 278 | - if ( is_object( $term ) ) |
|
| 276 | + function update_object($term, $fields) { |
|
| 277 | + $fields = array_merge(array('taxonomy' => $this->taxonomy), $fields); |
|
| 278 | + if (is_object($term)) |
|
| 279 | 279 | $taxonomy = $term->taxonomy; |
| 280 | - $term_id_pair = wp_update_term( $term, $taxonomy, $fields ); |
|
| 280 | + $term_id_pair = wp_update_term($term, $taxonomy, $fields); |
|
| 281 | 281 | return $term_id_pair['term_id']; |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - function add_post_terms( $post_id, $terms, $taxonomy, $append = true ) { |
|
| 285 | - return wp_set_post_terms( $post_id, $terms, $taxonomy, $append ); |
|
| 284 | + function add_post_terms($post_id, $terms, $taxonomy, $append = true) { |
|
| 285 | + return wp_set_post_terms($post_id, $terms, $taxonomy, $append); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - function create_and_get( $args = array(), $generation_definitions = null ) { |
|
| 289 | - $term_id = $this->create( $args, $generation_definitions ); |
|
| 290 | - $taxonomy = isset( $args['taxonomy'] ) ? $args['taxonomy'] : $this->taxonomy; |
|
| 291 | - return get_term( $term_id, $taxonomy ); |
|
| 288 | + function create_and_get($args = array(), $generation_definitions = null) { |
|
| 289 | + $term_id = $this->create($args, $generation_definitions); |
|
| 290 | + $taxonomy = isset($args['taxonomy']) ? $args['taxonomy'] : $this->taxonomy; |
|
| 291 | + return get_term($term_id, $taxonomy); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | - function get_object_by_id( $term_id ) { |
|
| 295 | - return get_term( $term_id, $this->taxonomy ); |
|
| 294 | + function get_object_by_id($term_id) { |
|
| 295 | + return get_term($term_id, $this->taxonomy); |
|
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | 298 | |
@@ -309,90 +309,90 @@ discard block |
||
| 309 | 309 | * can be generators -- an object with next() method. There are some default generators: {@link WP_UnitTest_Generator_Sequence}, |
| 310 | 310 | * {@link WP_UnitTest_Generator_Locale_Name}, {@link WP_UnitTest_Factory_Callback_After_Create}. |
| 311 | 311 | */ |
| 312 | - function __construct( $factory, $default_generation_definitions = array() ) { |
|
| 312 | + function __construct($factory, $default_generation_definitions = array()) { |
|
| 313 | 313 | $this->factory = $factory; |
| 314 | 314 | $this->default_generation_definitions = $default_generation_definitions; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - abstract function create_object( $args ); |
|
| 318 | - abstract function update_object( $object, $fields ); |
|
| 317 | + abstract function create_object($args); |
|
| 318 | + abstract function update_object($object, $fields); |
|
| 319 | 319 | |
| 320 | - function create( $args = array(), $generation_definitions = null ) { |
|
| 321 | - if ( is_null( $generation_definitions ) ) |
|
| 320 | + function create($args = array(), $generation_definitions = null) { |
|
| 321 | + if (is_null($generation_definitions)) |
|
| 322 | 322 | $generation_definitions = $this->default_generation_definitions; |
| 323 | 323 | |
| 324 | - $generated_args = $this->generate_args( $args, $generation_definitions, $callbacks ); |
|
| 325 | - $created = $this->create_object( $generated_args ); |
|
| 326 | - if ( !$created || is_wp_error( $created ) ) |
|
| 324 | + $generated_args = $this->generate_args($args, $generation_definitions, $callbacks); |
|
| 325 | + $created = $this->create_object($generated_args); |
|
| 326 | + if (!$created || is_wp_error($created)) |
|
| 327 | 327 | return $created; |
| 328 | 328 | |
| 329 | - if ( $callbacks ) { |
|
| 330 | - $updated_fields = $this->apply_callbacks( $callbacks, $created ); |
|
| 331 | - $save_result = $this->update_object( $created, $updated_fields ); |
|
| 332 | - if ( !$save_result || is_wp_error( $save_result ) ) |
|
| 329 | + if ($callbacks) { |
|
| 330 | + $updated_fields = $this->apply_callbacks($callbacks, $created); |
|
| 331 | + $save_result = $this->update_object($created, $updated_fields); |
|
| 332 | + if (!$save_result || is_wp_error($save_result)) |
|
| 333 | 333 | return $save_result; |
| 334 | 334 | } |
| 335 | 335 | return $created; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - function create_and_get( $args = array(), $generation_definitions = null ) { |
|
| 339 | - $object_id = $this->create( $args, $generation_definitions ); |
|
| 340 | - return $this->get_object_by_id( $object_id ); |
|
| 338 | + function create_and_get($args = array(), $generation_definitions = null) { |
|
| 339 | + $object_id = $this->create($args, $generation_definitions); |
|
| 340 | + return $this->get_object_by_id($object_id); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - abstract function get_object_by_id( $object_id ); |
|
| 343 | + abstract function get_object_by_id($object_id); |
|
| 344 | 344 | |
| 345 | - function create_many( $count, $args = array(), $generation_definitions = null ) { |
|
| 345 | + function create_many($count, $args = array(), $generation_definitions = null) { |
|
| 346 | 346 | $results = array(); |
| 347 | - for ( $i = 0; $i < $count; $i++ ) { |
|
| 348 | - $results[] = $this->create( $args, $generation_definitions ); |
|
| 347 | + for ($i = 0; $i < $count; $i++) { |
|
| 348 | + $results[] = $this->create($args, $generation_definitions); |
|
| 349 | 349 | } |
| 350 | 350 | return $results; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | - function generate_args( $args = array(), $generation_definitions = null, &$callbacks = null ) { |
|
| 353 | + function generate_args($args = array(), $generation_definitions = null, &$callbacks = null) { |
|
| 354 | 354 | $callbacks = array(); |
| 355 | - if ( is_null( $generation_definitions ) ) |
|
| 355 | + if (is_null($generation_definitions)) |
|
| 356 | 356 | $generation_definitions = $this->default_generation_definitions; |
| 357 | 357 | |
| 358 | - foreach( array_keys( $generation_definitions ) as $field_name ) { |
|
| 359 | - if ( !isset( $args[$field_name] ) ) { |
|
| 358 | + foreach (array_keys($generation_definitions) as $field_name) { |
|
| 359 | + if (!isset($args[$field_name])) { |
|
| 360 | 360 | $generator = $generation_definitions[$field_name]; |
| 361 | - if ( is_scalar( $generator ) ) |
|
| 361 | + if (is_scalar($generator)) |
|
| 362 | 362 | $args[$field_name] = $generator; |
| 363 | - elseif ( is_object( $generator ) && method_exists( $generator, 'call' ) ) { |
|
| 363 | + elseif (is_object($generator) && method_exists($generator, 'call')) { |
|
| 364 | 364 | $callbacks[$field_name] = $generator; |
| 365 | - } elseif ( is_object( $generator ) ) |
|
| 365 | + } elseif (is_object($generator)) |
|
| 366 | 366 | $args[$field_name] = $generator->next(); |
| 367 | 367 | else |
| 368 | - return new WP_Error( 'invalid_argument', 'Factory default value should be either a scalar or an generator object.' ); |
|
| 368 | + return new WP_Error('invalid_argument', 'Factory default value should be either a scalar or an generator object.'); |
|
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | return $args; |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | - function apply_callbacks( $callbacks, $created ) { |
|
| 374 | + function apply_callbacks($callbacks, $created) { |
|
| 375 | 375 | $updated_fields = array(); |
| 376 | - foreach( $callbacks as $field_name => $generator ) { |
|
| 377 | - $updated_fields[$field_name] = $generator->call( $created ); |
|
| 376 | + foreach ($callbacks as $field_name => $generator) { |
|
| 377 | + $updated_fields[$field_name] = $generator->call($created); |
|
| 378 | 378 | } |
| 379 | 379 | return $updated_fields; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - function callback( $function ) { |
|
| 383 | - return new WP_UnitTest_Factory_Callback_After_Create( $function ); |
|
| 382 | + function callback($function) { |
|
| 383 | + return new WP_UnitTest_Factory_Callback_After_Create($function); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | function addslashes_deep($value) { |
| 387 | - if ( is_array( $value ) ) { |
|
| 388 | - $value = array_map( array( $this, 'addslashes_deep' ), $value ); |
|
| 389 | - } elseif ( is_object( $value ) ) { |
|
| 390 | - $vars = get_object_vars( $value ); |
|
| 387 | + if (is_array($value)) { |
|
| 388 | + $value = array_map(array($this, 'addslashes_deep'), $value); |
|
| 389 | + } elseif (is_object($value)) { |
|
| 390 | + $vars = get_object_vars($value); |
|
| 391 | 391 | foreach ($vars as $key=>$data) { |
| 392 | - $value->{$key} = $this->addslashes_deep( $data ); |
|
| 392 | + $value->{$key} = $this->addslashes_deep($data); |
|
| 393 | 393 | } |
| 394 | - } elseif ( is_string( $value ) ) { |
|
| 395 | - $value = addslashes( $value ); |
|
| 394 | + } elseif (is_string($value)) { |
|
| 395 | + $value = addslashes($value); |
|
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | return $value; |
@@ -405,8 +405,8 @@ discard block |
||
| 405 | 405 | public $next; |
| 406 | 406 | public $template_string; |
| 407 | 407 | |
| 408 | - function __construct( $template_string = '%s', $start = null ) { |
|
| 409 | - if ( $start ) { |
|
| 408 | + function __construct($template_string = '%s', $start = null) { |
|
| 409 | + if ($start) { |
|
| 410 | 410 | $this->next = $start; |
| 411 | 411 | } else { |
| 412 | 412 | self::$incr++; |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | function next() { |
| 419 | - $generated = sprintf( $this->template_string , $this->next ); |
|
| 419 | + $generated = sprintf($this->template_string, $this->next); |
|
| 420 | 420 | $this->next++; |
| 421 | 421 | return $generated; |
| 422 | 422 | } |
@@ -425,11 +425,11 @@ discard block |
||
| 425 | 425 | class WP_UnitTest_Factory_Callback_After_Create { |
| 426 | 426 | var $callback; |
| 427 | 427 | |
| 428 | - function __construct( $callback ) { |
|
| 428 | + function __construct($callback) { |
|
| 429 | 429 | $this->callback = $callback; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | - function call( $object ) { |
|
| 433 | - return call_user_func( $this->callback, $object ); |
|
| 432 | + function call($object) { |
|
| 433 | + return call_user_func($this->callback, $object); |
|
| 434 | 434 | } |
| 435 | 435 | } |
@@ -104,8 +104,9 @@ discard block |
||
| 104 | 104 | $type = $upload['type']; |
| 105 | 105 | } else { |
| 106 | 106 | $mime = wp_check_filetype( $upload['file'] ); |
| 107 | - if ($mime) |
|
| 108 | - $type = $mime['type']; |
|
| 107 | + if ($mime) { |
|
| 108 | + $type = $mime['type']; |
|
| 109 | + } |
|
| 109 | 110 | } |
| 110 | 111 | |
| 111 | 112 | $attachment = array( |
@@ -268,15 +269,17 @@ discard block |
||
| 268 | 269 | function create_object( $args ) { |
| 269 | 270 | $args = array_merge( array( 'taxonomy' => $this->taxonomy ), $args ); |
| 270 | 271 | $term_id_pair = wp_insert_term( $args['name'], $args['taxonomy'], $args ); |
| 271 | - if ( is_wp_error( $term_id_pair ) ) |
|
| 272 | - return $term_id_pair; |
|
| 272 | + if ( is_wp_error( $term_id_pair ) ) { |
|
| 273 | + return $term_id_pair; |
|
| 274 | + } |
|
| 273 | 275 | return $term_id_pair['term_id']; |
| 274 | 276 | } |
| 275 | 277 | |
| 276 | 278 | function update_object( $term, $fields ) { |
| 277 | 279 | $fields = array_merge( array( 'taxonomy' => $this->taxonomy ), $fields ); |
| 278 | - if ( is_object( $term ) ) |
|
| 279 | - $taxonomy = $term->taxonomy; |
|
| 280 | + if ( is_object( $term ) ) { |
|
| 281 | + $taxonomy = $term->taxonomy; |
|
| 282 | + } |
|
| 280 | 283 | $term_id_pair = wp_update_term( $term, $taxonomy, $fields ); |
| 281 | 284 | return $term_id_pair['term_id']; |
| 282 | 285 | } |
@@ -318,19 +321,22 @@ discard block |
||
| 318 | 321 | abstract function update_object( $object, $fields ); |
| 319 | 322 | |
| 320 | 323 | function create( $args = array(), $generation_definitions = null ) { |
| 321 | - if ( is_null( $generation_definitions ) ) |
|
| 322 | - $generation_definitions = $this->default_generation_definitions; |
|
| 324 | + if ( is_null( $generation_definitions ) ) { |
|
| 325 | + $generation_definitions = $this->default_generation_definitions; |
|
| 326 | + } |
|
| 323 | 327 | |
| 324 | 328 | $generated_args = $this->generate_args( $args, $generation_definitions, $callbacks ); |
| 325 | 329 | $created = $this->create_object( $generated_args ); |
| 326 | - if ( !$created || is_wp_error( $created ) ) |
|
| 327 | - return $created; |
|
| 330 | + if ( !$created || is_wp_error( $created ) ) { |
|
| 331 | + return $created; |
|
| 332 | + } |
|
| 328 | 333 | |
| 329 | 334 | if ( $callbacks ) { |
| 330 | 335 | $updated_fields = $this->apply_callbacks( $callbacks, $created ); |
| 331 | 336 | $save_result = $this->update_object( $created, $updated_fields ); |
| 332 | - if ( !$save_result || is_wp_error( $save_result ) ) |
|
| 333 | - return $save_result; |
|
| 337 | + if ( !$save_result || is_wp_error( $save_result ) ) { |
|
| 338 | + return $save_result; |
|
| 339 | + } |
|
| 334 | 340 | } |
| 335 | 341 | return $created; |
| 336 | 342 | } |
@@ -352,20 +358,22 @@ discard block |
||
| 352 | 358 | |
| 353 | 359 | function generate_args( $args = array(), $generation_definitions = null, &$callbacks = null ) { |
| 354 | 360 | $callbacks = array(); |
| 355 | - if ( is_null( $generation_definitions ) ) |
|
| 356 | - $generation_definitions = $this->default_generation_definitions; |
|
| 361 | + if ( is_null( $generation_definitions ) ) { |
|
| 362 | + $generation_definitions = $this->default_generation_definitions; |
|
| 363 | + } |
|
| 357 | 364 | |
| 358 | 365 | foreach( array_keys( $generation_definitions ) as $field_name ) { |
| 359 | 366 | if ( !isset( $args[$field_name] ) ) { |
| 360 | 367 | $generator = $generation_definitions[$field_name]; |
| 361 | - if ( is_scalar( $generator ) ) |
|
| 362 | - $args[$field_name] = $generator; |
|
| 363 | - elseif ( is_object( $generator ) && method_exists( $generator, 'call' ) ) { |
|
| 368 | + if ( is_scalar( $generator ) ) { |
|
| 369 | + $args[$field_name] = $generator; |
|
| 370 | + } elseif ( is_object( $generator ) && method_exists( $generator, 'call' ) ) { |
|
| 364 | 371 | $callbacks[$field_name] = $generator; |
| 365 | - } elseif ( is_object( $generator ) ) |
|
| 366 | - $args[$field_name] = $generator->next(); |
|
| 367 | - else |
|
| 368 | - return new WP_Error( 'invalid_argument', 'Factory default value should be either a scalar or an generator object.' ); |
|
| 372 | + } elseif ( is_object( $generator ) ) { |
|
| 373 | + $args[$field_name] = $generator->next(); |
|
| 374 | + } else { |
|
| 375 | + return new WP_Error( 'invalid_argument', 'Factory default value should be either a scalar or an generator object.' ); |
|
| 376 | + } |
|
| 369 | 377 | } |
| 370 | 378 | } |
| 371 | 379 | return $args; |
@@ -10,6 +10,9 @@ discard block |
||
| 10 | 10 | return true; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | +/** |
|
| 14 | + * @param integer $priority |
|
| 15 | + */ |
|
| 13 | 16 | function _test_filter_build_unique_id($tag, $function, $priority) { |
| 14 | 17 | global $wp_filter; |
| 15 | 18 | static $filter_id_count = 0; |
@@ -92,6 +95,9 @@ discard block |
||
| 92 | 95 | return '_wp_die_handler'; |
| 93 | 96 | } |
| 94 | 97 | |
| 98 | +/** |
|
| 99 | + * @param string $title |
|
| 100 | + */ |
|
| 95 | 101 | function _wp_die_handler_txt( $message, $title, $args ) { |
| 96 | 102 | echo "\nwp_die called\n"; |
| 97 | 103 | echo "Message : $message\n"; |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | $idx = _test_filter_build_unique_id($tag, $function_to_add, $priority); |
| 8 | 8 | $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); |
| 9 | - unset( $merged_filters[ $tag ] ); |
|
| 9 | + unset($merged_filters[$tag]); |
|
| 10 | 10 | return true; |
| 11 | 11 | } |
| 12 | 12 | |
@@ -14,21 +14,21 @@ discard block |
||
| 14 | 14 | global $wp_filter; |
| 15 | 15 | static $filter_id_count = 0; |
| 16 | 16 | |
| 17 | - if ( is_string($function) ) |
|
| 17 | + if (is_string($function)) |
|
| 18 | 18 | return $function; |
| 19 | 19 | |
| 20 | - if ( is_object($function) ) { |
|
| 20 | + if (is_object($function)) { |
|
| 21 | 21 | // Closures are currently implemented as objects |
| 22 | - $function = array( $function, '' ); |
|
| 22 | + $function = array($function, ''); |
|
| 23 | 23 | } else { |
| 24 | 24 | $function = (array) $function; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if (is_object($function[0]) ) { |
|
| 27 | + if (is_object($function[0])) { |
|
| 28 | 28 | return spl_object_hash($function[0]) . $function[1]; |
| 29 | - } else if ( is_string($function[0]) ) { |
|
| 29 | + } else if (is_string($function[0])) { |
|
| 30 | 30 | // Static Calling |
| 31 | - return $function[0].$function[1]; |
|
| 31 | + return $function[0] . $function[1]; |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
@@ -38,31 +38,31 @@ discard block |
||
| 38 | 38 | $all_posts = $wpdb->get_col("SELECT ID from {$wpdb->posts}"); |
| 39 | 39 | if ($all_posts) { |
| 40 | 40 | foreach ($all_posts as $id) |
| 41 | - wp_delete_post( $id, true ); |
|
| 41 | + wp_delete_post($id, true); |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | class Basic_Object { |
| 46 | 46 | private $foo = 'bar'; |
| 47 | 47 | |
| 48 | - public function __get( $name ) { |
|
| 48 | + public function __get($name) { |
|
| 49 | 49 | return $this->$name; |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - public function __set( $name, $value ) { |
|
| 52 | + public function __set($name, $value) { |
|
| 53 | 53 | return $this->$name = $value; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public function __isset( $name ) { |
|
| 57 | - return isset( $this->$name ); |
|
| 56 | + public function __isset($name) { |
|
| 57 | + return isset($this->$name); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function __unset( $name ) { |
|
| 61 | - unset( $this->$name ); |
|
| 60 | + public function __unset($name) { |
|
| 61 | + unset($this->$name); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - public function __call( $name, $arguments ) { |
|
| 65 | - return call_user_func_array( array( $this, $name ), $arguments ); |
|
| 64 | + public function __call($name, $arguments) { |
|
| 65 | + return call_user_func_array(array($this, $name), $arguments); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | private function callMe() { |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | class Basic_Subclass extends Basic_Object {} |
| 74 | 74 | |
| 75 | -function _wp_die_handler( $message, $title = '', $args = array() ) { |
|
| 76 | - if ( !$GLOBALS['_wp_die_disabled'] ) { |
|
| 77 | - _wp_die_handler_txt( $message, $title, $args); |
|
| 75 | +function _wp_die_handler($message, $title = '', $args = array()) { |
|
| 76 | + if (!$GLOBALS['_wp_die_disabled']) { |
|
| 77 | + _wp_die_handler_txt($message, $title, $args); |
|
| 78 | 78 | } else { |
| 79 | 79 | //Ignore at our peril |
| 80 | 80 | } |
@@ -92,13 +92,13 @@ discard block |
||
| 92 | 92 | return '_wp_die_handler'; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | -function _wp_die_handler_txt( $message, $title, $args ) { |
|
| 95 | +function _wp_die_handler_txt($message, $title, $args) { |
|
| 96 | 96 | echo "\nwp_die called\n"; |
| 97 | 97 | echo "Message : $message\n"; |
| 98 | 98 | echo "Title : $title\n"; |
| 99 | - if ( ! empty( $args ) ) { |
|
| 99 | + if (!empty($args)) { |
|
| 100 | 100 | echo "Args: \n"; |
| 101 | - foreach( $args as $k => $v ){ |
|
| 101 | + foreach ($args as $k => $v) { |
|
| 102 | 102 | echo "\t $k : $v\n"; |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -113,5 +113,5 @@ discard block |
||
| 113 | 113 | * @since 4.2.0 |
| 114 | 114 | */ |
| 115 | 115 | function _set_default_permalink_structure_for_tests() { |
| 116 | - update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/' ); |
|
| 116 | + update_option('permalink_structure', '/%year%/%monthnum%/%day%/%postname%/'); |
|
| 117 | 117 | } |
@@ -14,8 +14,9 @@ discard block |
||
| 14 | 14 | global $wp_filter; |
| 15 | 15 | static $filter_id_count = 0; |
| 16 | 16 | |
| 17 | - if ( is_string($function) ) |
|
| 18 | - return $function; |
|
| 17 | + if ( is_string($function) ) { |
|
| 18 | + return $function; |
|
| 19 | + } |
|
| 19 | 20 | |
| 20 | 21 | if ( is_object($function) ) { |
| 21 | 22 | // Closures are currently implemented as objects |
@@ -37,8 +38,9 @@ discard block |
||
| 37 | 38 | |
| 38 | 39 | $all_posts = $wpdb->get_col("SELECT ID from {$wpdb->posts}"); |
| 39 | 40 | if ($all_posts) { |
| 40 | - foreach ($all_posts as $id) |
|
| 41 | - wp_delete_post( $id, true ); |
|
| 41 | + foreach ($all_posts as $id) { |
|
| 42 | + wp_delete_post( $id, true ); |
|
| 43 | + } |
|
| 42 | 44 | } |
| 43 | 45 | } |
| 44 | 46 | |
@@ -49,6 +49,7 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * "Bulk Loads" a filesystem into the internal virtual filesystem |
| 52 | + * @param string $paths |
|
| 52 | 53 | */ |
| 53 | 54 | function setfs( $paths ) { |
| 54 | 55 | if ( ! is_array($paths) ) |
@@ -144,6 +145,9 @@ discard block |
||
| 144 | 145 | return isset( $this->fs_map[ $file ] ) && $this->fs_map[ $file ]->is_file(); |
| 145 | 146 | } |
| 146 | 147 | |
| 148 | + /** |
|
| 149 | + * @param string $path |
|
| 150 | + */ |
|
| 147 | 151 | function is_dir( $path ) { |
| 148 | 152 | $path = trailingslashit( $path ); |
| 149 | 153 | |
@@ -20,13 +20,13 @@ discard block |
||
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | // Copy of core's function, but accepts a path. |
| 23 | - function abspath( $path = false ) { |
|
| 24 | - if ( ! $path ) |
|
| 23 | + function abspath($path = false) { |
|
| 24 | + if (!$path) |
|
| 25 | 25 | $path = ABSPATH; |
| 26 | - $folder = $this->find_folder( $path ); |
|
| 26 | + $folder = $this->find_folder($path); |
|
| 27 | 27 | |
| 28 | 28 | // Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare. |
| 29 | - if ( ! $folder && $this->is_dir('/wp-includes') ) |
|
| 29 | + if (!$folder && $this->is_dir('/wp-includes')) |
|
| 30 | 30 | $folder = '/'; |
| 31 | 31 | return $folder; |
| 32 | 32 | } |
@@ -37,35 +37,35 @@ discard block |
||
| 37 | 37 | * Sets initial filesystem environment and/or clears the current environment. |
| 38 | 38 | * Can also be passed the initial filesystem to be setup which is passed to self::setfs() |
| 39 | 39 | */ |
| 40 | - function init( $paths = '', $home_dir = '/' ) { |
|
| 41 | - $this->fs = new MockFS_Directory_Node( '/' ); |
|
| 40 | + function init($paths = '', $home_dir = '/') { |
|
| 41 | + $this->fs = new MockFS_Directory_Node('/'); |
|
| 42 | 42 | $this->fs_map = array( |
| 43 | 43 | '/' => $this->fs, |
| 44 | 44 | ); |
| 45 | 45 | $this->cache = array(); // Used by find_folder() and friends |
| 46 | - $this->cwd = isset( $this->fs_map[ $home_dir ] ) ? $this->fs_map[ $home_dir ] : '/'; |
|
| 47 | - $this->setfs( $paths ); |
|
| 46 | + $this->cwd = isset($this->fs_map[$home_dir]) ? $this->fs_map[$home_dir] : '/'; |
|
| 47 | + $this->setfs($paths); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * "Bulk Loads" a filesystem into the internal virtual filesystem |
| 52 | 52 | */ |
| 53 | - function setfs( $paths ) { |
|
| 54 | - if ( ! is_array($paths) ) |
|
| 55 | - $paths = explode( "\n", $paths ); |
|
| 53 | + function setfs($paths) { |
|
| 54 | + if (!is_array($paths)) |
|
| 55 | + $paths = explode("\n", $paths); |
|
| 56 | 56 | |
| 57 | - $paths = array_filter( array_map( 'trim', $paths ) ); |
|
| 57 | + $paths = array_filter(array_map('trim', $paths)); |
|
| 58 | 58 | |
| 59 | - foreach ( $paths as $path ) { |
|
| 59 | + foreach ($paths as $path) { |
|
| 60 | 60 | // Allow for comments |
| 61 | - if ( '#' == $path[0] ) |
|
| 61 | + if ('#' == $path[0]) |
|
| 62 | 62 | continue; |
| 63 | 63 | |
| 64 | 64 | // Directories |
| 65 | - if ( '/' == $path[ strlen($path) -1 ] ) |
|
| 66 | - $this->mkdir( $path ); |
|
| 65 | + if ('/' == $path[strlen($path) - 1]) |
|
| 66 | + $this->mkdir($path); |
|
| 67 | 67 | else // Files (with dummy content for now) |
| 68 | - $this->put_contents( $path, 'This is a test file' ); |
|
| 68 | + $this->put_contents($path, 'This is a test file'); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | } |
@@ -73,120 +73,120 @@ discard block |
||
| 73 | 73 | /** |
| 74 | 74 | * Locates a filesystem "node" |
| 75 | 75 | */ |
| 76 | - private function locate_node( $path ) { |
|
| 77 | - return isset( $this->fs_map[ $path ] ) ? $this->fs_map[ $path ] : false; |
|
| 76 | + private function locate_node($path) { |
|
| 77 | + return isset($this->fs_map[$path]) ? $this->fs_map[$path] : false; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Locates a filesystem node for the parent of the given item |
| 82 | 82 | */ |
| 83 | - private function locate_parent_node( $path ) { |
|
| 84 | - $dirname = str_replace( '\\', '/', dirname( $path ) ); |
|
| 85 | - return $this->locate_node( trailingslashit( $dirname ) ); |
|
| 83 | + private function locate_parent_node($path) { |
|
| 84 | + $dirname = str_replace('\\', '/', dirname($path)); |
|
| 85 | + return $this->locate_node(trailingslashit($dirname)); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // Here starteth the WP_Filesystem functions. |
| 89 | 89 | |
| 90 | - function mkdir( $path, /* Optional args are ignored */ $chmod = false, $chown = false, $chgrp = false ) { |
|
| 91 | - $path = trailingslashit( $path ); |
|
| 90 | + function mkdir($path, /* Optional args are ignored */ $chmod = false, $chown = false, $chgrp = false) { |
|
| 91 | + $path = trailingslashit($path); |
|
| 92 | 92 | |
| 93 | - $parent_node = $this->locate_parent_node( $path ); |
|
| 94 | - if ( ! $parent_node ) { |
|
| 95 | - $dirname = str_replace( '\\', '/', dirname( $path ) ); |
|
| 96 | - $this->mkdir( $dirname ); |
|
| 97 | - $parent_node = $this->locate_parent_node( $path ); |
|
| 98 | - if ( ! $parent_node ) |
|
| 93 | + $parent_node = $this->locate_parent_node($path); |
|
| 94 | + if (!$parent_node) { |
|
| 95 | + $dirname = str_replace('\\', '/', dirname($path)); |
|
| 96 | + $this->mkdir($dirname); |
|
| 97 | + $parent_node = $this->locate_parent_node($path); |
|
| 98 | + if (!$parent_node) |
|
| 99 | 99 | return false; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - $node = new MockFS_Directory_Node( $path ); |
|
| 102 | + $node = new MockFS_Directory_Node($path); |
|
| 103 | 103 | |
| 104 | - $parent_node->children[ $node->name ] = $node; |
|
| 105 | - $this->fs_map[ $path ] = $node; |
|
| 104 | + $parent_node->children[$node->name] = $node; |
|
| 105 | + $this->fs_map[$path] = $node; |
|
| 106 | 106 | |
| 107 | 107 | return true; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - function put_contents( $path, $contents = '', $mode = null ) { |
|
| 111 | - if ( ! $this->is_dir( dirname( $path ) ) ) |
|
| 112 | - $this->mkdir( dirname( $path ) ); |
|
| 110 | + function put_contents($path, $contents = '', $mode = null) { |
|
| 111 | + if (!$this->is_dir(dirname($path))) |
|
| 112 | + $this->mkdir(dirname($path)); |
|
| 113 | 113 | |
| 114 | - $parent = $this->locate_parent_node( $path ); |
|
| 115 | - $new_file = new MockFS_File_Node( $path, $contents ); |
|
| 114 | + $parent = $this->locate_parent_node($path); |
|
| 115 | + $new_file = new MockFS_File_Node($path, $contents); |
|
| 116 | 116 | |
| 117 | - $parent->children[ $new_file->name ] = $new_file; |
|
| 118 | - $this->fs_map[ $path ] = $new_file; |
|
| 117 | + $parent->children[$new_file->name] = $new_file; |
|
| 118 | + $this->fs_map[$path] = $new_file; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - function get_contents( $file ) { |
|
| 122 | - if ( ! $this->is_file( $file ) ) |
|
| 121 | + function get_contents($file) { |
|
| 122 | + if (!$this->is_file($file)) |
|
| 123 | 123 | return false; |
| 124 | - return $this->fs_map[ $file ]->contents; |
|
| 124 | + return $this->fs_map[$file]->contents; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | function cwd() { |
| 128 | 128 | return $this->cwd->path; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - function chdir( $path ) { |
|
| 132 | - if ( ! isset( $this->fs_map[ $path ] ) ) |
|
| 131 | + function chdir($path) { |
|
| 132 | + if (!isset($this->fs_map[$path])) |
|
| 133 | 133 | return false; |
| 134 | 134 | |
| 135 | - $this->cwd = $this->fs_map[ $path ]; |
|
| 135 | + $this->cwd = $this->fs_map[$path]; |
|
| 136 | 136 | return true; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - function exists( $path ) { |
|
| 140 | - return isset( $this->fs_map[ $path ] ) || isset( $this->fs_map[ trailingslashit( $path ) ] ); |
|
| 139 | + function exists($path) { |
|
| 140 | + return isset($this->fs_map[$path]) || isset($this->fs_map[trailingslashit($path)]); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - function is_file( $file ) { |
|
| 144 | - return isset( $this->fs_map[ $file ] ) && $this->fs_map[ $file ]->is_file(); |
|
| 143 | + function is_file($file) { |
|
| 144 | + return isset($this->fs_map[$file]) && $this->fs_map[$file]->is_file(); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - function is_dir( $path ) { |
|
| 148 | - $path = trailingslashit( $path ); |
|
| 147 | + function is_dir($path) { |
|
| 148 | + $path = trailingslashit($path); |
|
| 149 | 149 | |
| 150 | - return isset( $this->fs_map[ $path ] ) && $this->fs_map[ $path ]->is_dir(); |
|
| 150 | + return isset($this->fs_map[$path]) && $this->fs_map[$path]->is_dir(); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - function dirlist( $path = '.', $include_hidden = true, $recursive = false ) { |
|
| 153 | + function dirlist($path = '.', $include_hidden = true, $recursive = false) { |
|
| 154 | 154 | |
| 155 | - if ( empty( $path ) || '.' == $path ) |
|
| 155 | + if (empty($path) || '.' == $path) |
|
| 156 | 156 | $path = $this->cwd(); |
| 157 | 157 | |
| 158 | - if ( ! $this->exists( $path ) ) |
|
| 158 | + if (!$this->exists($path)) |
|
| 159 | 159 | return false; |
| 160 | 160 | |
| 161 | 161 | $limit_file = false; |
| 162 | - if ( $this->is_file( $path ) ) { |
|
| 163 | - $limit_file = $this->locate_node( $path )->name; |
|
| 164 | - $path = dirname( $path ) . '/'; |
|
| 162 | + if ($this->is_file($path)) { |
|
| 163 | + $limit_file = $this->locate_node($path)->name; |
|
| 164 | + $path = dirname($path) . '/'; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | $ret = array(); |
| 168 | - foreach ( $this->fs_map[ $path ]->children as $entry ) { |
|
| 169 | - if ( '.' == $entry->name || '..' == $entry->name ) |
|
| 168 | + foreach ($this->fs_map[$path]->children as $entry) { |
|
| 169 | + if ('.' == $entry->name || '..' == $entry->name) |
|
| 170 | 170 | continue; |
| 171 | 171 | |
| 172 | - if ( ! $include_hidden && '.' == $entry->name ) |
|
| 172 | + if (!$include_hidden && '.' == $entry->name) |
|
| 173 | 173 | continue; |
| 174 | 174 | |
| 175 | - if ( $limit_file && $entry->name != $limit_file ) |
|
| 175 | + if ($limit_file && $entry->name != $limit_file) |
|
| 176 | 176 | continue; |
| 177 | 177 | |
| 178 | 178 | $struc = array(); |
| 179 | 179 | $struc['name'] = $entry->name; |
| 180 | 180 | $struc['type'] = $entry->type; |
| 181 | 181 | |
| 182 | - if ( 'd' == $struc['type'] ) { |
|
| 183 | - if ( $recursive ) |
|
| 184 | - $struc['files'] = $this->dirlist( trailingslashit( $path ) . trailingslashit( $struc['name'] ), $include_hidden, $recursive ); |
|
| 182 | + if ('d' == $struc['type']) { |
|
| 183 | + if ($recursive) |
|
| 184 | + $struc['files'] = $this->dirlist(trailingslashit($path) . trailingslashit($struc['name']), $include_hidden, $recursive); |
|
| 185 | 185 | else |
| 186 | 186 | $struc['files'] = array(); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - $ret[ $entry->name ] = $struc; |
|
| 189 | + $ret[$entry->name] = $struc; |
|
| 190 | 190 | } |
| 191 | 191 | return $ret; |
| 192 | 192 | } |
@@ -198,9 +198,9 @@ discard block |
||
| 198 | 198 | public $type; // The type of the entry 'f' for file, 'd' for Directory |
| 199 | 199 | public $path; // The full path to the entry. |
| 200 | 200 | |
| 201 | - function __construct( $path ) { |
|
| 201 | + function __construct($path) { |
|
| 202 | 202 | $this->path = $path; |
| 203 | - $this->name = basename( $path ); |
|
| 203 | + $this->name = basename($path); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | function is_file() { |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | public $type = 'f'; |
| 222 | 222 | public $contents = ''; // The contents of the file |
| 223 | 223 | |
| 224 | - function __construct( $path, $contents = '' ) { |
|
| 225 | - parent::__construct( $path ); |
|
| 224 | + function __construct($path, $contents = '') { |
|
| 225 | + parent::__construct($path); |
|
| 226 | 226 | $this->contents = $contents; |
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | \ No newline at end of file |
@@ -21,13 +21,15 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | // Copy of core's function, but accepts a path. |
| 23 | 23 | function abspath( $path = false ) { |
| 24 | - if ( ! $path ) |
|
| 25 | - $path = ABSPATH; |
|
| 24 | + if ( ! $path ) { |
|
| 25 | + $path = ABSPATH; |
|
| 26 | + } |
|
| 26 | 27 | $folder = $this->find_folder( $path ); |
| 27 | 28 | |
| 28 | 29 | // Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare. |
| 29 | - if ( ! $folder && $this->is_dir('/wp-includes') ) |
|
| 30 | - $folder = '/'; |
|
| 30 | + if ( ! $folder && $this->is_dir('/wp-includes') ) { |
|
| 31 | + $folder = '/'; |
|
| 32 | + } |
|
| 31 | 33 | return $folder; |
| 32 | 34 | } |
| 33 | 35 | |
@@ -51,21 +53,25 @@ discard block |
||
| 51 | 53 | * "Bulk Loads" a filesystem into the internal virtual filesystem |
| 52 | 54 | */ |
| 53 | 55 | function setfs( $paths ) { |
| 54 | - if ( ! is_array($paths) ) |
|
| 55 | - $paths = explode( "\n", $paths ); |
|
| 56 | + if ( ! is_array($paths) ) { |
|
| 57 | + $paths = explode( "\n", $paths ); |
|
| 58 | + } |
|
| 56 | 59 | |
| 57 | 60 | $paths = array_filter( array_map( 'trim', $paths ) ); |
| 58 | 61 | |
| 59 | 62 | foreach ( $paths as $path ) { |
| 60 | 63 | // Allow for comments |
| 61 | - if ( '#' == $path[0] ) |
|
| 62 | - continue; |
|
| 64 | + if ( '#' == $path[0] ) { |
|
| 65 | + continue; |
|
| 66 | + } |
|
| 63 | 67 | |
| 64 | 68 | // Directories |
| 65 | - if ( '/' == $path[ strlen($path) -1 ] ) |
|
| 66 | - $this->mkdir( $path ); |
|
| 67 | - else // Files (with dummy content for now) |
|
| 69 | + if ( '/' == $path[ strlen($path) -1 ] ) { |
|
| 70 | + $this->mkdir( $path ); |
|
| 71 | + } else { |
|
| 72 | + // Files (with dummy content for now) |
|
| 68 | 73 | $this->put_contents( $path, 'This is a test file' ); |
| 74 | + } |
|
| 69 | 75 | } |
| 70 | 76 | |
| 71 | 77 | } |
@@ -95,8 +101,9 @@ discard block |
||
| 95 | 101 | $dirname = str_replace( '\\', '/', dirname( $path ) ); |
| 96 | 102 | $this->mkdir( $dirname ); |
| 97 | 103 | $parent_node = $this->locate_parent_node( $path ); |
| 98 | - if ( ! $parent_node ) |
|
| 99 | - return false; |
|
| 104 | + if ( ! $parent_node ) { |
|
| 105 | + return false; |
|
| 106 | + } |
|
| 100 | 107 | } |
| 101 | 108 | |
| 102 | 109 | $node = new MockFS_Directory_Node( $path ); |
@@ -108,8 +115,9 @@ discard block |
||
| 108 | 115 | } |
| 109 | 116 | |
| 110 | 117 | function put_contents( $path, $contents = '', $mode = null ) { |
| 111 | - if ( ! $this->is_dir( dirname( $path ) ) ) |
|
| 112 | - $this->mkdir( dirname( $path ) ); |
|
| 118 | + if ( ! $this->is_dir( dirname( $path ) ) ) { |
|
| 119 | + $this->mkdir( dirname( $path ) ); |
|
| 120 | + } |
|
| 113 | 121 | |
| 114 | 122 | $parent = $this->locate_parent_node( $path ); |
| 115 | 123 | $new_file = new MockFS_File_Node( $path, $contents ); |
@@ -119,8 +127,9 @@ discard block |
||
| 119 | 127 | } |
| 120 | 128 | |
| 121 | 129 | function get_contents( $file ) { |
| 122 | - if ( ! $this->is_file( $file ) ) |
|
| 123 | - return false; |
|
| 130 | + if ( ! $this->is_file( $file ) ) { |
|
| 131 | + return false; |
|
| 132 | + } |
|
| 124 | 133 | return $this->fs_map[ $file ]->contents; |
| 125 | 134 | } |
| 126 | 135 | |
@@ -129,8 +138,9 @@ discard block |
||
| 129 | 138 | } |
| 130 | 139 | |
| 131 | 140 | function chdir( $path ) { |
| 132 | - if ( ! isset( $this->fs_map[ $path ] ) ) |
|
| 133 | - return false; |
|
| 141 | + if ( ! isset( $this->fs_map[ $path ] ) ) { |
|
| 142 | + return false; |
|
| 143 | + } |
|
| 134 | 144 | |
| 135 | 145 | $this->cwd = $this->fs_map[ $path ]; |
| 136 | 146 | return true; |
@@ -152,11 +162,13 @@ discard block |
||
| 152 | 162 | |
| 153 | 163 | function dirlist( $path = '.', $include_hidden = true, $recursive = false ) { |
| 154 | 164 | |
| 155 | - if ( empty( $path ) || '.' == $path ) |
|
| 156 | - $path = $this->cwd(); |
|
| 165 | + if ( empty( $path ) || '.' == $path ) { |
|
| 166 | + $path = $this->cwd(); |
|
| 167 | + } |
|
| 157 | 168 | |
| 158 | - if ( ! $this->exists( $path ) ) |
|
| 159 | - return false; |
|
| 169 | + if ( ! $this->exists( $path ) ) { |
|
| 170 | + return false; |
|
| 171 | + } |
|
| 160 | 172 | |
| 161 | 173 | $limit_file = false; |
| 162 | 174 | if ( $this->is_file( $path ) ) { |
@@ -166,24 +178,28 @@ discard block |
||
| 166 | 178 | |
| 167 | 179 | $ret = array(); |
| 168 | 180 | foreach ( $this->fs_map[ $path ]->children as $entry ) { |
| 169 | - if ( '.' == $entry->name || '..' == $entry->name ) |
|
| 170 | - continue; |
|
| 181 | + if ( '.' == $entry->name || '..' == $entry->name ) { |
|
| 182 | + continue; |
|
| 183 | + } |
|
| 171 | 184 | |
| 172 | - if ( ! $include_hidden && '.' == $entry->name ) |
|
| 173 | - continue; |
|
| 185 | + if ( ! $include_hidden && '.' == $entry->name ) { |
|
| 186 | + continue; |
|
| 187 | + } |
|
| 174 | 188 | |
| 175 | - if ( $limit_file && $entry->name != $limit_file ) |
|
| 176 | - continue; |
|
| 189 | + if ( $limit_file && $entry->name != $limit_file ) { |
|
| 190 | + continue; |
|
| 191 | + } |
|
| 177 | 192 | |
| 178 | 193 | $struc = array(); |
| 179 | 194 | $struc['name'] = $entry->name; |
| 180 | 195 | $struc['type'] = $entry->type; |
| 181 | 196 | |
| 182 | 197 | if ( 'd' == $struc['type'] ) { |
| 183 | - if ( $recursive ) |
|
| 184 | - $struc['files'] = $this->dirlist( trailingslashit( $path ) . trailingslashit( $struc['name'] ), $include_hidden, $recursive ); |
|
| 185 | - else |
|
| 186 | - $struc['files'] = array(); |
|
| 198 | + if ( $recursive ) { |
|
| 199 | + $struc['files'] = $this->dirlist( trailingslashit( $path ) . trailingslashit( $struc['name'] ), $include_hidden, $recursive ); |
|
| 200 | + } else { |
|
| 201 | + $struc['files'] = array(); |
|
| 202 | + } |
|
| 187 | 203 | } |
| 188 | 204 | |
| 189 | 205 | $ret[ $entry->name ] = $struc; |