| @@ -49,13 +49,13 @@ | ||
| 49 | 49 | </h4> | 
| 50 | 50 | <?php | 
| 51 | 51 |      if (isset($_REQUEST['emsg']) && $_REQUEST['emsg'] == 'fw') {
 | 
| 52 | - echo "<p class=\"error_msg\"> " . INVALID_USER_FPW_MSG . " </p>"; | |
| 52 | + echo "<p class=\"error_msg\"> ".INVALID_USER_FPW_MSG." </p>"; | |
| 53 | 53 |      } elseif (isset($_REQUEST['logemsg']) && $_REQUEST['logemsg'] == 1) {
 | 
| 54 | - echo "<p class=\"error_msg\"> " . INVALID_USER_PW_MSG . " </p>"; | |
| 54 | + echo "<p class=\"error_msg\"> ".INVALID_USER_PW_MSG." </p>"; | |
| 55 | 55 | } | 
| 56 | 56 | |
| 57 | 57 | if (isset($_REQUEST['checkemail']) && $_REQUEST['checkemail'] == 'confirm') | 
| 58 | - echo '<p class="sucess_msg">' . PW_SEND_CONFIRM_MSG . '</p>'; | |
| 58 | + echo '<p class="sucess_msg">'.PW_SEND_CONFIRM_MSG.'</p>'; | |
| 59 | 59 | |
| 60 | 60 | ?> | 
| 61 | 61 | <form name="cus_loginform" id="cus_loginform" action="<?php echo esc_url(geodir_curPageURL()); ?>" | 
| @@ -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('forgot' => 1, '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('forgot' => 1, '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 | 
| @@ -22,7 +22,7 @@ discard block | ||
| 22 | 22 |          if ($redirect) {
 | 
| 23 | 23 | ?> | 
| 24 | 24 | <script type="text/javascript"> | 
| 25 | - window.location.href = '<?php echo geodir_login_url();?>'; | |
| 25 | + window.location.href = '<?php echo geodir_login_url(); ?>'; | |
| 26 | 26 | </script> | 
| 27 | 27 | <?php | 
| 28 | 28 | } else | 
| @@ -47,7 +47,7 @@ discard block | ||
| 47 | 47 |              wp_redirect(preg_replace('|^http://|', 'https://', $_SERVER['REQUEST_URI']));
 | 
| 48 | 48 | exit(); | 
| 49 | 49 |          } else {
 | 
| 50 | -            wp_redirect('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
 | |
| 50 | +            wp_redirect('https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
 | |
| 51 | 51 | exit(); | 
| 52 | 52 | } | 
| 53 | 53 | } | 
| @@ -60,7 +60,7 @@ discard block | ||
| 60 | 60 | * @param string $message Login message. | 
| 61 | 61 | */ | 
| 62 | 62 |      $message = apply_filters('login_message', $message);
 | 
| 63 | - if (!empty($message)) echo $message . "\n"; | |
| 63 | + if (!empty($message)) echo $message."\n"; | |
| 64 | 64 | |
| 65 | 65 | } | 
| 66 | 66 | |
| @@ -208,9 +208,9 @@ discard block | ||
| 208 | 208 | |
| 209 | 209 | wp_set_password($new_pass, $user->ID); | 
| 210 | 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>";
 | |
| 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 | 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 | 215 |      //$message .= '<p>Thank You,<br> '.get_option('blogname').'</p>';
 | 
| 216 | 216 | $user_email = $user_data->user_email; | 
| @@ -236,7 +236,7 @@ discard block | ||
| 236 | 236 | */ | 
| 237 | 237 |      $message = apply_filters('password_reset_message', $message, $new_pass);
 | 
| 238 | 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 | |
| 239 | + geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID); ///forgot password email | |
| 240 | 240 | |
| 241 | 241 | return true; | 
| 242 | 242 | } | 
| @@ -390,13 +390,13 @@ discard block | ||
| 390 | 390 | ///////REGISTRATION EMAIL START////// | 
| 391 | 391 | $fromEmail = geodir_get_site_email_id(); | 
| 392 | 392 | $fromEmailName = get_site_emailName(); | 
| 393 | -        $message = __('<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>
 | |
| 394 | -<p>' . __('Username:', 'geodirectory') . ' ' . $user_login . '</p>
 | |
| 395 | -<p>' . __('Password:', 'geodirectory') . ' ' . $user_pass . '</p>');
 | |
| 393 | +        $message = __('<p><b>'.__('Your login Information :', 'geodirectory').'</b></p>
 | |
| 394 | +<p>' . __('Username:', 'geodirectory').' '.$user_login.'</p>
 | |
| 395 | +<p>' . __('Password:', 'geodirectory').' '.$user_pass.'</p>');
 | |
| 396 | 396 | |
| 397 | 397 | /////////////customer email////////////// | 
| 398 | 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 | |
| 399 | + geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id); /// registration email | |
| 400 | 400 | //////REGISTRATION EMAIL END//////// | 
| 401 | 401 | } | 
| 402 | 402 | |
| @@ -427,7 +427,7 @@ discard block | ||
| 427 | 427 | $action = 'resetpass'; | 
| 428 | 428 | |
| 429 | 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))
 | |
| 430 | +    if (!in_array($action, array('logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'login')) && false === has_filter('login_form_'.$action))
 | |
| 431 | 431 | $action = 'login'; | 
| 432 | 432 | |
| 433 | 433 | nocache_headers(); | 
| @@ -437,8 +437,8 @@ discard block | ||
| 437 | 437 | $_SERVER['PHP_SELF'] = str_replace($_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF']); | 
| 438 | 438 | |
| 439 | 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']));
 | |
| 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 | 442 | } | 
| 443 | 443 | |
| 444 | 444 | //Set a cookie now to see if they are supported by the browser. | 
| @@ -453,7 +453,7 @@ discard block | ||
| 453 | 453 | * | 
| 454 | 454 | * @since 1.0.0 | 
| 455 | 455 | */ | 
| 456 | -    do_action('login_form_' . $action);
 | |
| 456 | +    do_action('login_form_'.$action);
 | |
| 457 | 457 | |
| 458 | 458 |      $http_post = ('POST' == $_SERVER['REQUEST_METHOD']);
 | 
| 459 | 459 | |
| @@ -493,7 +493,7 @@ discard block | ||
| 493 | 493 | * @since 1.0.0 | 
| 494 | 494 | */ | 
| 495 | 495 |          do_action('lost_password');
 | 
| 496 | - $message = '<div class="sucess_msg">' . ENTER_USER_EMAIL_NEW_PW_MSG . '</div>'; | |
| 496 | + $message = '<div class="sucess_msg">'.ENTER_USER_EMAIL_NEW_PW_MSG.'</div>'; | |
| 497 | 497 | $user_login = isset($_POST['user_login']) ? stripslashes($_POST['user_login']) : ''; | 
| 498 | 498 | |
| 499 | 499 | break; | 
| @@ -507,7 +507,7 @@ discard block | ||
| 507 | 507 | exit(); | 
| 508 | 508 | } | 
| 509 | 509 | |
| 510 | -            wp_redirect(geodir_login_url(array('error'=>'invalidkey','action'=>'lostpassword')));
 | |
| 510 | +            wp_redirect(geodir_login_url(array('error'=>'invalidkey', 'action'=>'lostpassword')));
 | |
| 511 | 511 | exit(); | 
| 512 | 512 | |
| 513 | 513 | break; | 
| @@ -682,7 +682,7 @@ discard block | ||
| 682 | 682 | |
| 683 | 683 |              if (is_wp_error($user)) {
 | 
| 684 | 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'); | |
| 685 | + wp_redirect($_SERVER['HTTP_REFERER'].'&emsg=1'); | |
| 686 | 686 | } | 
| 687 | 687 | } | 
| 688 | 688 |              if (!is_wp_error($user)) {
 | 
| @@ -710,7 +710,7 @@ discard block | ||
| 710 | 710 | |
| 711 | 711 | // Some parts of this script use the main login form to display a message | 
| 712 | 712 |              if (isset($_GET['loggedout']) && TRUE == $_GET['loggedout']) {
 | 
| 713 | - $successmsg = '<div class="sucess_msg">' . YOU_ARE_LOGED_OUT_MSG . '</div>'; | |
| 713 | + $successmsg = '<div class="sucess_msg">'.YOU_ARE_LOGED_OUT_MSG.'</div>'; | |
| 714 | 714 |              } elseif (isset($_GET['registration']) && 'disabled' == $_GET['registration']) {
 | 
| 715 | 715 | $successmsg = USER_REG_NOT_ALLOW_MSG; | 
| 716 | 716 |              } elseif (isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail']) {
 | 
| @@ -723,9 +723,9 @@ discard block | ||
| 723 | 723 | |
| 724 | 724 |              if ((isset($_POST['log']) && $_POST['log'] != '' && $errors) || ((!isset($_POST['log']) || $_POST['log'] == '') && isset($_REQUEST['testcookie']) && $_REQUEST['testcookie'])) {
 | 
| 725 | 725 |                  if (isset($_REQUEST['pagetype']) && $_REQUEST['pagetype'] != '') {
 | 
| 726 | - wp_redirect($_REQUEST['pagetype'] . '&emsg=1'); | |
| 726 | + wp_redirect($_REQUEST['pagetype'].'&emsg=1'); | |
| 727 | 727 |                  } else {
 | 
| 728 | -                    wp_redirect(geodir_login_url(array('logemsg'=>'1','redirect_to'=>urlencode($_REQUEST['redirect_to']))));
 | |
| 728 | +                    wp_redirect(geodir_login_url(array('logemsg'=>'1', 'redirect_to'=>urlencode($_REQUEST['redirect_to']))));
 | |
| 729 | 729 | } | 
| 730 | 730 | gd_die(); | 
| 731 | 731 | } | 
| @@ -24,12 +24,12 @@ discard block | ||
| 24 | 24 | */ | 
| 25 | 25 | |
| 26 | 26 | $config = array( | 
| 27 | - 'id' => 'demo_meta_box', // meta box id, unique per meta box | |
| 28 | -        'title' => __('Demo Meta Box', 'geodirectory'),                    // meta box title | |
| 29 | - 'pages' => geodir_get_taxonomies(), // taxonomy name, accept categories, post_tag and custom taxonomies | |
| 30 | - 'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional | |
| 31 | - 'fields' => array(), // list of meta fields (can be added by field arrays) | |
| 32 | - 'local_images' => false, // Use local or hosted images (meta box images for add/remove) | |
| 27 | + 'id' => 'demo_meta_box', // meta box id, unique per meta box | |
| 28 | +        'title' => __('Demo Meta Box', 'geodirectory'), // meta box title | |
| 29 | + 'pages' => geodir_get_taxonomies(), // taxonomy name, accept categories, post_tag and custom taxonomies | |
| 30 | + 'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional | |
| 31 | + 'fields' => array(), // list of meta fields (can be added by field arrays) | |
| 32 | + 'local_images' => false, // Use local or hosted images (meta box images for add/remove) | |
| 33 | 33 | 'use_with_theme' => true //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false). | 
| 34 | 34 | ); | 
| 35 | 35 | |
| @@ -38,18 +38,18 @@ discard block | ||
| 38 | 38 | * Initiate your meta box | 
| 39 | 39 | */ | 
| 40 | 40 | $my_meta = new Tax_Meta_Class($config); | 
| 41 | -    $my_meta->addWysiwyg($prefix . 'cat_top_desc', array('name' => __('Category Top Description', 'geodirectory'), 'desc' => __('This will appear at the top of the category listing.', 'geodirectory'))); | |
| 42 | -    $my_meta->addImage($prefix . 'cat_default_img', array('name' => __('Default Listing Image', 'geodirectory'), 'desc' => __('Choose a default "no image"', 'geodirectory'))); | |
| 43 | -    $my_meta->addImage($prefix . 'cat_icon', array('name' => __('Category Icon', 'geodirectory'), 'desc' => __('Choose a category icon', 'geodirectory'), 'validate_func' => '!empty')); | |
| 41 | +    $my_meta->addWysiwyg($prefix.'cat_top_desc', array('name' => __('Category Top Description', 'geodirectory'), 'desc' => __('This will appear at the top of the category listing.', 'geodirectory'))); | |
| 42 | +    $my_meta->addImage($prefix.'cat_default_img', array('name' => __('Default Listing Image', 'geodirectory'), 'desc' => __('Choose a default "no image"', 'geodirectory'))); | |
| 43 | +    $my_meta->addImage($prefix.'cat_icon', array('name' => __('Category Icon', 'geodirectory'), 'desc' => __('Choose a category icon', 'geodirectory'), 'validate_func' => '!empty')); | |
| 44 | 44 |      /*$my_meta->addCheckbox($prefix.'pointless',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory'),'style'=>'hidden'));*/// hidden setting to trick WPML | 
| 45 | 45 | |
| 46 | - $my_meta->addSelect($prefix . 'cat_schema', | |
| 46 | + $my_meta->addSelect($prefix.'cat_schema', | |
| 47 | 47 | /* | 
| 48 | 48 | * Allows you to add/filter the cat schema types. | 
| 49 | 49 | * | 
| 50 | 50 | * @since 1.5.7 | 
| 51 | 51 | */ | 
| 52 | -        apply_filters('geodir_cat_schemas',array( | |
| 52 | +        apply_filters('geodir_cat_schemas', array( | |
| 53 | 53 |              '' => __('Default (LocalBusiness)', 'geodirectory'), | 
| 54 | 54 | 'AccountingService' => 'AccountingService', | 
| 55 | 55 | 'Attorney' => 'Attorney', | 
| @@ -141,7 +141,7 @@ discard block | ||
| 141 | 141 | 'WholesaleStore' => 'WholesaleStore', | 
| 142 | 142 | 'Winery' => 'Winery' | 
| 143 | 143 | )), | 
| 144 | -        array('name' => __('Schema Type', 'geodirectory'), 'desc' => __('Select the Schema to use for this category', 'geodirectory') . "", 'std' => array('selectkey2'))); | |
| 144 | +        array('name' => __('Schema Type', 'geodirectory'), 'desc' => __('Select the Schema to use for this category', 'geodirectory')."", 'std' => array('selectkey2'))); | |
| 145 | 145 | |
| 146 | 146 |      /*$my_meta->addSelect($prefix.'cat_sort',array(''=>__('Default' , 'geodirectory'), | 
| 147 | 147 |      'random'=>__('Random','geodirectory'), | 
| @@ -179,8 +179,8 @@ discard block | ||
| 179 | 179 |  if (!empty($gd_taxonomies)) { | 
| 180 | 180 |      foreach ($gd_taxonomies as $gd_taxonomy) { | 
| 181 | 181 | |
| 182 | -        add_filter('manage_edit-' . $gd_taxonomy . '_columns', 'addCat_column', 10, 2); | |
| 183 | -        add_action('manage_' . $gd_taxonomy . '_custom_column', 'manage_category_custom_fields', 10, 3); | |
| 182 | +        add_filter('manage_edit-'.$gd_taxonomy.'_columns', 'addCat_column', 10, 2); | |
| 183 | +        add_action('manage_'.$gd_taxonomy.'_custom_column', 'manage_category_custom_fields', 10, 3); | |
| 184 | 184 | |
| 185 | 185 | } | 
| 186 | 186 | } | 
| @@ -214,9 +214,9 @@ discard block | ||
| 214 | 214 | |
| 215 | 215 | $file_info = pathinfo($term_icon_url['src']); | 
| 216 | 216 | |
| 217 | - if (isset($file_info['dirname'] ) && $file_info['dirname'] != '.' && $file_info['dirname'] != '..') | |
| 217 | + if (isset($file_info['dirname']) && $file_info['dirname'] != '.' && $file_info['dirname'] != '..') | |
| 218 | 218 | $sub_dir = $file_info['dirname']; | 
| 219 | -            else{$sub_dir = '';} | |
| 219 | +            else {$sub_dir = ''; } | |
| 220 | 220 | |
| 221 | 221 | $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs | 
| 222 | 222 | $uploads_baseurl = $uploads['baseurl']; | 
| @@ -226,10 +226,10 @@ discard block | ||
| 226 | 226 | |
| 227 | 227 | $sub_dir = str_replace($uploads_baseurl, '', $sub_dir); | 
| 228 | 228 | |
| 229 | - $uploads_url = $uploads_baseurl . $sub_dir; | |
| 229 | + $uploads_url = $uploads_baseurl.$sub_dir; | |
| 230 | 230 | |
| 231 | - $term_icon_url['src'] = $uploads_url . '/' . $file_name; | |
| 232 | - echo '<img src="' . $term_icon_url['src'] . '" />'; | |
| 231 | + $term_icon_url['src'] = $uploads_url.'/'.$file_name; | |
| 232 | + echo '<img src="'.$term_icon_url['src'].'" />'; | |
| 233 | 233 | |
| 234 | 234 | } | 
| 235 | 235 | } | 
| @@ -237,7 +237,7 @@ discard block | ||
| 237 | 237 |      if ($column_name == 'cat_default_img') { | 
| 238 | 238 | $cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img'); | 
| 239 | 239 | if ($cat_default_img != '') | 
| 240 | - echo '<img src="' . $cat_default_img['src'] . '" style="max-height:60px;max-width:60px;"/>'; | |
| 240 | + echo '<img src="'.$cat_default_img['src'].'" style="max-height:60px;max-width:60px;"/>'; | |
| 241 | 241 | |
| 242 | 242 | } | 
| 243 | 243 | } | 
| @@ -268,8 +268,8 @@ discard block | ||
| 268 | 268 |                              jQuery("#addtag iframe").contents().find("body").html(''); | 
| 269 | 269 |                              jQuery('#addtag [rel="ct_cat_default_img"]').removeClass('at-delete_image_button').addClass('at-upload_image_button'); | 
| 270 | 270 |                              jQuery('#addtag [rel="ct_cat_icon"]').removeClass('at-delete_image_button').addClass('at-upload_image_button'); | 
| 271 | -                            jQuery('#addtag [rel="ct_cat_default_img"]').val('<?php _e('Upload Image','geodirectory');?>'); | |
| 272 | -                            jQuery('#addtag [rel="ct_cat_icon"]').val('<?php _e('Upload Image','geodirectory');?>'); | |
| 271 | +                            jQuery('#addtag [rel="ct_cat_default_img"]').val('<?php _e('Upload Image', 'geodirectory'); ?>'); | |
| 272 | +                            jQuery('#addtag [rel="ct_cat_icon"]').val('<?php _e('Upload Image', 'geodirectory'); ?>'); | |
| 273 | 273 | } | 
| 274 | 274 | }, 1000); | 
| 275 | 275 | |
| @@ -11,139 +11,139 @@ discard block | ||
| 11 | 11 | //include the main class file | 
| 12 | 12 |  require_once("Tax-meta-class.php"); | 
| 13 | 13 |  if (is_admin()) { | 
| 14 | - /* | |
| 14 | + /* | |
| 15 | 15 | * prefix of meta keys, optional | 
| 16 | 16 | * use underscore (_) at the beginning to make keys hidden, for example $prefix = '_ba_'; | 
| 17 | 17 | * you also can make prefix empty to disable it | 
| 18 | 18 | * | 
| 19 | 19 | */ | 
| 20 | 20 | |
| 21 | - $prefix = 'ct_'; | |
| 22 | - /* | |
| 21 | + $prefix = 'ct_'; | |
| 22 | + /* | |
| 23 | 23 | * configure your meta box | 
| 24 | 24 | */ | 
| 25 | 25 | |
| 26 | - $config = array( | |
| 27 | - 'id' => 'demo_meta_box', // meta box id, unique per meta box | |
| 28 | -        'title' => __('Demo Meta Box', 'geodirectory'),                    // meta box title | |
| 29 | - 'pages' => geodir_get_taxonomies(), // taxonomy name, accept categories, post_tag and custom taxonomies | |
| 30 | - 'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional | |
| 31 | - 'fields' => array(), // list of meta fields (can be added by field arrays) | |
| 32 | - 'local_images' => false, // Use local or hosted images (meta box images for add/remove) | |
| 33 | - 'use_with_theme' => true //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false). | |
| 34 | - ); | |
| 26 | + $config = array( | |
| 27 | + 'id' => 'demo_meta_box', // meta box id, unique per meta box | |
| 28 | +		'title' => __('Demo Meta Box', 'geodirectory'),                    // meta box title | |
| 29 | + 'pages' => geodir_get_taxonomies(), // taxonomy name, accept categories, post_tag and custom taxonomies | |
| 30 | + 'context' => 'normal', // where the meta box appear: normal (default), advanced, side; optional | |
| 31 | + 'fields' => array(), // list of meta fields (can be added by field arrays) | |
| 32 | + 'local_images' => false, // Use local or hosted images (meta box images for add/remove) | |
| 33 | + 'use_with_theme' => true //change path if used with theme set to true, false for a plugin or anything else for a custom path(default false). | |
| 34 | + ); | |
| 35 | 35 | |
| 36 | 36 | |
| 37 | - /* | |
| 37 | + /* | |
| 38 | 38 | * Initiate your meta box | 
| 39 | 39 | */ | 
| 40 | - $my_meta = new Tax_Meta_Class($config); | |
| 41 | -    $my_meta->addWysiwyg($prefix . 'cat_top_desc', array('name' => __('Category Top Description', 'geodirectory'), 'desc' => __('This will appear at the top of the category listing.', 'geodirectory'))); | |
| 42 | -    $my_meta->addImage($prefix . 'cat_default_img', array('name' => __('Default Listing Image', 'geodirectory'), 'desc' => __('Choose a default "no image"', 'geodirectory'))); | |
| 43 | -    $my_meta->addImage($prefix . 'cat_icon', array('name' => __('Category Icon', 'geodirectory'), 'desc' => __('Choose a category icon', 'geodirectory'), 'validate_func' => '!empty')); | |
| 44 | -    /*$my_meta->addCheckbox($prefix.'pointless',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory'),'style'=>'hidden'));*/// hidden setting to trick WPML | |
| 45 | - | |
| 46 | - $my_meta->addSelect($prefix . 'cat_schema', | |
| 47 | - /* | |
| 40 | + $my_meta = new Tax_Meta_Class($config); | |
| 41 | +	$my_meta->addWysiwyg($prefix . 'cat_top_desc', array('name' => __('Category Top Description', 'geodirectory'), 'desc' => __('This will appear at the top of the category listing.', 'geodirectory'))); | |
| 42 | +	$my_meta->addImage($prefix . 'cat_default_img', array('name' => __('Default Listing Image', 'geodirectory'), 'desc' => __('Choose a default "no image"', 'geodirectory'))); | |
| 43 | +	$my_meta->addImage($prefix . 'cat_icon', array('name' => __('Category Icon', 'geodirectory'), 'desc' => __('Choose a category icon', 'geodirectory'), 'validate_func' => '!empty')); | |
| 44 | +	/*$my_meta->addCheckbox($prefix.'pointless',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory'),'style'=>'hidden'));*/// hidden setting to trick WPML | |
| 45 | + | |
| 46 | + $my_meta->addSelect($prefix . 'cat_schema', | |
| 47 | + /* | |
| 48 | 48 | * Allows you to add/filter the cat schema types. | 
| 49 | 49 | * | 
| 50 | 50 | * @since 1.5.7 | 
| 51 | 51 | */ | 
| 52 | -        apply_filters('geodir_cat_schemas',array( | |
| 53 | -            '' => __('Default (LocalBusiness)', 'geodirectory'), | |
| 54 | - 'AccountingService' => 'AccountingService', | |
| 55 | - 'Attorney' => 'Attorney', | |
| 56 | - 'AutoBodyShop' => 'AutoBodyShop', | |
| 57 | - 'AutoDealer' => 'AutoDealer', | |
| 58 | - 'AutoPartsStore' => 'AutoPartsStore', | |
| 59 | - 'AutoRental' => 'AutoRental', | |
| 60 | - 'AutoRepair' => 'AutoRepair', | |
| 61 | - 'AutoWash' => 'AutoWash', | |
| 62 | - 'Bakery' => 'Bakery', | |
| 63 | - 'BarOrPub' => 'BarOrPub', | |
| 64 | - 'BeautySalon' => 'BeautySalon', | |
| 65 | - 'BedAndBreakfast' => 'BedAndBreakfast', | |
| 66 | - 'BikeStore' => 'BikeStore', | |
| 67 | - 'BookStore' => 'BookStore', | |
| 68 | - 'CafeOrCoffeeShop' => 'CafeOrCoffeeShop', | |
| 69 | - 'ChildCare' => 'ChildCare', | |
| 70 | - 'ClothingStore' => 'ClothingStore', | |
| 71 | - 'ComputerStore' => 'ComputerStore', | |
| 72 | - 'DaySpa' => 'DaySpa', | |
| 73 | - 'Dentist' => 'Dentist', | |
| 74 | - 'DryCleaningOrLaundry' => 'DryCleaningOrLaundry', | |
| 75 | - 'Electrician' => 'Electrician', | |
| 76 | - 'ElectronicsStore' => 'ElectronicsStore', | |
| 77 | - 'EmergencyService' => 'EmergencyService', | |
| 78 | - 'EntertainmentBusiness' => 'EntertainmentBusiness', | |
| 79 | - 'Event' => 'Event', | |
| 80 | - 'EventVenue' => 'EventVenue', | |
| 81 | - 'ExerciseGym' => 'ExerciseGym', | |
| 82 | - 'FinancialService' => 'FinancialService', | |
| 83 | - 'Florist' => 'Florist', | |
| 84 | - 'FoodEstablishment' => 'FoodEstablishment', | |
| 85 | - 'FurnitureStore' => 'FurnitureStore', | |
| 86 | - 'GardenStore' => 'GardenStore', | |
| 87 | - 'GeneralContractor' => 'GeneralContractor', | |
| 88 | - 'GolfCourse' => 'GolfCourse', | |
| 89 | - 'HairSalon' => 'HairSalon', | |
| 90 | - 'HardwareStore' => 'HardwareStore', | |
| 91 | - 'HealthAndBeautyBusiness' => 'HealthAndBeautyBusiness', | |
| 92 | - 'HobbyShop' => 'HobbyShop', | |
| 93 | - 'HomeAndConstructionBusiness' => 'HomeAndConstructionBusiness', | |
| 94 | - 'HomeGoodsStore' => 'HomeGoodsStore', | |
| 95 | - 'Hospital' => 'Hospital', | |
| 96 | - 'Hotel' => 'Hotel', | |
| 97 | - 'HousePainter' => 'HousePainter', | |
| 98 | - 'HVACBusiness' => 'HVACBusiness', | |
| 99 | - 'InsuranceAgency' => 'InsuranceAgency', | |
| 100 | - 'JewelryStore' => 'JewelryStore', | |
| 101 | - 'LiquorStore' => 'LiquorStore', | |
| 102 | - 'Locksmith' => 'Locksmith', | |
| 103 | - 'LodgingBusiness' => 'LodgingBusiness', | |
| 104 | - 'MedicalClinic' => 'MedicalClinic', | |
| 105 | - 'MensClothingStore' => 'MensClothingStore', | |
| 106 | - 'MobilePhoneStore' => 'MobilePhoneStore', | |
| 107 | - 'Motel' => 'Motel', | |
| 108 | - 'MotorcycleDealer' => 'MotorcycleDealer', | |
| 109 | - 'MotorcycleRepair' => 'MotorcycleRepair', | |
| 110 | - 'MovingCompany' => 'MovingCompany', | |
| 111 | - 'MusicStore' => 'MusicStore', | |
| 112 | - 'NailSalon' => 'NailSalon', | |
| 113 | - 'NightClub' => 'NightClub', | |
| 114 | - 'Notary' => 'Notary', | |
| 115 | - 'OfficeEquipmentStore' => 'OfficeEquipmentStore', | |
| 116 | - 'Optician' => 'Optician', | |
| 117 | - 'PetStore' => 'PetStore', | |
| 118 | - 'Physician' => 'Physician', | |
| 119 | - 'Plumber' => 'Plumber', | |
| 120 | - 'ProfessionalService' => 'ProfessionalService', | |
| 121 | - 'RealEstateAgent' => 'RealEstateAgent', | |
| 122 | - 'Residence' => 'Residence', | |
| 123 | - 'Restaurant' => 'Restaurant', | |
| 124 | - 'RoofingContractor' => 'RoofingContractor', | |
| 125 | - 'RVPark' => 'RVPark', | |
| 126 | - 'School' => 'School', | |
| 127 | - 'SelfStorage' => 'SelfStorage', | |
| 128 | - 'ShoeStore' => 'ShoeStore', | |
| 129 | - 'SkiResort' => 'SkiResort', | |
| 130 | - 'SportingGoodsStore' => 'SportingGoodsStore', | |
| 131 | - 'SportsClub' => 'SportsClub', | |
| 132 | - 'Store' => 'Store', | |
| 133 | - 'TattooParlor' => 'TattooParlor', | |
| 134 | - 'Taxi' => 'Taxi', | |
| 135 | - 'TennisComplex' => 'TennisComplex', | |
| 136 | - 'TireShop' => 'TireShop', | |
| 137 | - 'TouristAttraction' => 'TouristAttraction', | |
| 138 | - 'ToyStore' => 'ToyStore', | |
| 139 | - 'TravelAgency' => 'TravelAgency', | |
| 140 | - 'VeterinaryCare' => 'VeterinaryCare', | |
| 141 | - 'WholesaleStore' => 'WholesaleStore', | |
| 142 | - 'Winery' => 'Winery' | |
| 143 | - )), | |
| 144 | -        array('name' => __('Schema Type', 'geodirectory'), 'desc' => __('Select the Schema to use for this category', 'geodirectory') . "", 'std' => array('selectkey2'))); | |
| 145 | - | |
| 146 | -    /*$my_meta->addSelect($prefix.'cat_sort',array(''=>__('Default' , 'geodirectory'), | |
| 52 | +		apply_filters('geodir_cat_schemas',array( | |
| 53 | +			'' => __('Default (LocalBusiness)', 'geodirectory'), | |
| 54 | + 'AccountingService' => 'AccountingService', | |
| 55 | + 'Attorney' => 'Attorney', | |
| 56 | + 'AutoBodyShop' => 'AutoBodyShop', | |
| 57 | + 'AutoDealer' => 'AutoDealer', | |
| 58 | + 'AutoPartsStore' => 'AutoPartsStore', | |
| 59 | + 'AutoRental' => 'AutoRental', | |
| 60 | + 'AutoRepair' => 'AutoRepair', | |
| 61 | + 'AutoWash' => 'AutoWash', | |
| 62 | + 'Bakery' => 'Bakery', | |
| 63 | + 'BarOrPub' => 'BarOrPub', | |
| 64 | + 'BeautySalon' => 'BeautySalon', | |
| 65 | + 'BedAndBreakfast' => 'BedAndBreakfast', | |
| 66 | + 'BikeStore' => 'BikeStore', | |
| 67 | + 'BookStore' => 'BookStore', | |
| 68 | + 'CafeOrCoffeeShop' => 'CafeOrCoffeeShop', | |
| 69 | + 'ChildCare' => 'ChildCare', | |
| 70 | + 'ClothingStore' => 'ClothingStore', | |
| 71 | + 'ComputerStore' => 'ComputerStore', | |
| 72 | + 'DaySpa' => 'DaySpa', | |
| 73 | + 'Dentist' => 'Dentist', | |
| 74 | + 'DryCleaningOrLaundry' => 'DryCleaningOrLaundry', | |
| 75 | + 'Electrician' => 'Electrician', | |
| 76 | + 'ElectronicsStore' => 'ElectronicsStore', | |
| 77 | + 'EmergencyService' => 'EmergencyService', | |
| 78 | + 'EntertainmentBusiness' => 'EntertainmentBusiness', | |
| 79 | + 'Event' => 'Event', | |
| 80 | + 'EventVenue' => 'EventVenue', | |
| 81 | + 'ExerciseGym' => 'ExerciseGym', | |
| 82 | + 'FinancialService' => 'FinancialService', | |
| 83 | + 'Florist' => 'Florist', | |
| 84 | + 'FoodEstablishment' => 'FoodEstablishment', | |
| 85 | + 'FurnitureStore' => 'FurnitureStore', | |
| 86 | + 'GardenStore' => 'GardenStore', | |
| 87 | + 'GeneralContractor' => 'GeneralContractor', | |
| 88 | + 'GolfCourse' => 'GolfCourse', | |
| 89 | + 'HairSalon' => 'HairSalon', | |
| 90 | + 'HardwareStore' => 'HardwareStore', | |
| 91 | + 'HealthAndBeautyBusiness' => 'HealthAndBeautyBusiness', | |
| 92 | + 'HobbyShop' => 'HobbyShop', | |
| 93 | + 'HomeAndConstructionBusiness' => 'HomeAndConstructionBusiness', | |
| 94 | + 'HomeGoodsStore' => 'HomeGoodsStore', | |
| 95 | + 'Hospital' => 'Hospital', | |
| 96 | + 'Hotel' => 'Hotel', | |
| 97 | + 'HousePainter' => 'HousePainter', | |
| 98 | + 'HVACBusiness' => 'HVACBusiness', | |
| 99 | + 'InsuranceAgency' => 'InsuranceAgency', | |
| 100 | + 'JewelryStore' => 'JewelryStore', | |
| 101 | + 'LiquorStore' => 'LiquorStore', | |
| 102 | + 'Locksmith' => 'Locksmith', | |
| 103 | + 'LodgingBusiness' => 'LodgingBusiness', | |
| 104 | + 'MedicalClinic' => 'MedicalClinic', | |
| 105 | + 'MensClothingStore' => 'MensClothingStore', | |
| 106 | + 'MobilePhoneStore' => 'MobilePhoneStore', | |
| 107 | + 'Motel' => 'Motel', | |
| 108 | + 'MotorcycleDealer' => 'MotorcycleDealer', | |
| 109 | + 'MotorcycleRepair' => 'MotorcycleRepair', | |
| 110 | + 'MovingCompany' => 'MovingCompany', | |
| 111 | + 'MusicStore' => 'MusicStore', | |
| 112 | + 'NailSalon' => 'NailSalon', | |
| 113 | + 'NightClub' => 'NightClub', | |
| 114 | + 'Notary' => 'Notary', | |
| 115 | + 'OfficeEquipmentStore' => 'OfficeEquipmentStore', | |
| 116 | + 'Optician' => 'Optician', | |
| 117 | + 'PetStore' => 'PetStore', | |
| 118 | + 'Physician' => 'Physician', | |
| 119 | + 'Plumber' => 'Plumber', | |
| 120 | + 'ProfessionalService' => 'ProfessionalService', | |
| 121 | + 'RealEstateAgent' => 'RealEstateAgent', | |
| 122 | + 'Residence' => 'Residence', | |
| 123 | + 'Restaurant' => 'Restaurant', | |
| 124 | + 'RoofingContractor' => 'RoofingContractor', | |
| 125 | + 'RVPark' => 'RVPark', | |
| 126 | + 'School' => 'School', | |
| 127 | + 'SelfStorage' => 'SelfStorage', | |
| 128 | + 'ShoeStore' => 'ShoeStore', | |
| 129 | + 'SkiResort' => 'SkiResort', | |
| 130 | + 'SportingGoodsStore' => 'SportingGoodsStore', | |
| 131 | + 'SportsClub' => 'SportsClub', | |
| 132 | + 'Store' => 'Store', | |
| 133 | + 'TattooParlor' => 'TattooParlor', | |
| 134 | + 'Taxi' => 'Taxi', | |
| 135 | + 'TennisComplex' => 'TennisComplex', | |
| 136 | + 'TireShop' => 'TireShop', | |
| 137 | + 'TouristAttraction' => 'TouristAttraction', | |
| 138 | + 'ToyStore' => 'ToyStore', | |
| 139 | + 'TravelAgency' => 'TravelAgency', | |
| 140 | + 'VeterinaryCare' => 'VeterinaryCare', | |
| 141 | + 'WholesaleStore' => 'WholesaleStore', | |
| 142 | + 'Winery' => 'Winery' | |
| 143 | + )), | |
| 144 | +		array('name' => __('Schema Type', 'geodirectory'), 'desc' => __('Select the Schema to use for this category', 'geodirectory') . "", 'std' => array('selectkey2'))); | |
| 145 | + | |
| 146 | +	/*$my_meta->addSelect($prefix.'cat_sort',array(''=>__('Default' , 'geodirectory'), | |
| 147 | 147 |      'random'=>__('Random','geodirectory'), | 
| 148 | 148 |      'az'=>__('Alphabetical' , 'geodirectory'), | 
| 149 | 149 |      'newest'=>__('Newest','geodirectory'), | 
| @@ -154,8 +154,8 @@ discard block | ||
| 154 | 154 |      'low_review'=>__('Lowest Reviews','geodirectory')), | 
| 155 | 155 |      array('name'=> __('Sort By','geodirectory'),'desc' => __('Select the default sort option.' ,'geodirectory'), 'std'=> array('selectkey2')));*/ | 
| 156 | 156 | |
| 157 | - // Show options for placecategories only | |
| 158 | -    /*	if(isset($_REQUEST['taxonomy']) && in_array($_REQUEST['taxonomy'],$config['pages']) ){ | |
| 157 | + // Show options for placecategories only | |
| 158 | +	/*	if(isset($_REQUEST['taxonomy']) && in_array($_REQUEST['taxonomy'],$config['pages']) ){ | |
| 159 | 159 | // Exclude sort options | 
| 160 | 160 |          $my_meta->addCheckbox($prefix.'cat_exclude_rating',array('name'=> __('<b>Exclude</b> Rating sort option','geodirectory'))); | 
| 161 | 161 |          $my_meta->addCheckbox($prefix.'cat_exclude_reviews',array('name'=> __('<b>Exclude</b> Reviews sort option','geodirectory'))); | 
| @@ -167,8 +167,8 @@ discard block | ||
| 167 | 167 | |
| 168 | 168 | }*/ | 
| 169 | 169 | |
| 170 | - //Finish Meta Box Declaration | |
| 171 | - $my_meta->Finish(); | |
| 170 | + //Finish Meta Box Declaration | |
| 171 | + $my_meta->Finish(); | |
| 172 | 172 | } | 
| 173 | 173 | |
| 174 | 174 | |
| @@ -177,82 +177,82 @@ discard block | ||
| 177 | 177 | ############################################################## | 
| 178 | 178 | $gd_taxonomies = geodir_get_taxonomies(); | 
| 179 | 179 |  if (!empty($gd_taxonomies)) { | 
| 180 | -    foreach ($gd_taxonomies as $gd_taxonomy) { | |
| 180 | +	foreach ($gd_taxonomies as $gd_taxonomy) { | |
| 181 | 181 | |
| 182 | -        add_filter('manage_edit-' . $gd_taxonomy . '_columns', 'addCat_column', 10, 2); | |
| 183 | -        add_action('manage_' . $gd_taxonomy . '_custom_column', 'manage_category_custom_fields', 10, 3); | |
| 182 | +		add_filter('manage_edit-' . $gd_taxonomy . '_columns', 'addCat_column', 10, 2); | |
| 183 | +		add_action('manage_' . $gd_taxonomy . '_custom_column', 'manage_category_custom_fields', 10, 3); | |
| 184 | 184 | |
| 185 | - } | |
| 185 | + } | |
| 186 | 186 | } | 
| 187 | 187 | |
| 188 | 188 | function addCat_column($columns) | 
| 189 | 189 |  { | 
| 190 | -    if (isset($columns['description']) && $posts = $columns['description']) { | |
| 191 | - unset($columns['description']); | |
| 192 | - } | |
| 193 | - | |
| 194 | - $columns['cat_icon'] = 'Icon'; | |
| 195 | -    $columns['cat_default_img'] = __('Default Image', 'geodirectory'); | |
| 196 | -    $columns['cat_ID_num'] = __('Cat ID', 'geodirectory'); | |
| 197 | - return $columns; | |
| 190 | +	if (isset($columns['description']) && $posts = $columns['description']) { | |
| 191 | + unset($columns['description']); | |
| 192 | + } | |
| 193 | + | |
| 194 | + $columns['cat_icon'] = 'Icon'; | |
| 195 | +	$columns['cat_default_img'] = __('Default Image', 'geodirectory'); | |
| 196 | +	$columns['cat_ID_num'] = __('Cat ID', 'geodirectory'); | |
| 197 | + return $columns; | |
| 198 | 198 | } | 
| 199 | 199 | |
| 200 | 200 | ############################################################# | 
| 201 | 201 | function manage_category_custom_fields($deprecated, $column_name, $term_id) | 
| 202 | 202 |  { | 
| 203 | - if ($column_name == 'cat_ID_num') | |
| 204 | - echo $term_id; | |
| 203 | + if ($column_name == 'cat_ID_num') | |
| 204 | + echo $term_id; | |
| 205 | 205 | |
| 206 | -    if ($column_name == 'cat_icon') { | |
| 207 | - $term_icon_url = get_tax_meta($term_id, 'ct_cat_icon'); | |
| 206 | +	if ($column_name == 'cat_icon') { | |
| 207 | + $term_icon_url = get_tax_meta($term_id, 'ct_cat_icon'); | |
| 208 | 208 | |
| 209 | -        if ($term_icon_url != '') { | |
| 209 | +		if ($term_icon_url != '') { | |
| 210 | 210 | |
| 211 | - $file_info = pathinfo($term_icon_url['src']); | |
| 211 | + $file_info = pathinfo($term_icon_url['src']); | |
| 212 | 212 | |
| 213 | - if (isset($file_info['dirname'] ) && $file_info['dirname'] != '.' && $file_info['dirname'] != '..') | |
| 214 | - $sub_dir = $file_info['dirname']; | |
| 215 | -            else{$sub_dir = '';} | |
| 213 | + if (isset($file_info['dirname'] ) && $file_info['dirname'] != '.' && $file_info['dirname'] != '..') | |
| 214 | + $sub_dir = $file_info['dirname']; | |
| 215 | +			else{$sub_dir = '';} | |
| 216 | 216 | |
| 217 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs | |
| 218 | - $uploads_baseurl = $uploads['baseurl']; | |
| 219 | - $uploads_path = $uploads['path']; | |
| 217 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs | |
| 218 | + $uploads_baseurl = $uploads['baseurl']; | |
| 219 | + $uploads_path = $uploads['path']; | |
| 220 | 220 | |
| 221 | - $file_name = $file_info['basename']; | |
| 221 | + $file_name = $file_info['basename']; | |
| 222 | 222 | |
| 223 | - $sub_dir = str_replace($uploads_baseurl, '', $sub_dir); | |
| 223 | + $sub_dir = str_replace($uploads_baseurl, '', $sub_dir); | |
| 224 | 224 | |
| 225 | - $uploads_url = $uploads_baseurl . $sub_dir; | |
| 225 | + $uploads_url = $uploads_baseurl . $sub_dir; | |
| 226 | 226 | |
| 227 | - $term_icon_url['src'] = $uploads_url . '/' . $file_name; | |
| 228 | - echo '<img src="' . $term_icon_url['src'] . '" />'; | |
| 227 | + $term_icon_url['src'] = $uploads_url . '/' . $file_name; | |
| 228 | + echo '<img src="' . $term_icon_url['src'] . '" />'; | |
| 229 | 229 | |
| 230 | - } | |
| 231 | - } | |
| 230 | + } | |
| 231 | + } | |
| 232 | 232 | |
| 233 | -    if ($column_name == 'cat_default_img') { | |
| 234 | - $cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img'); | |
| 235 | - if ($cat_default_img != '') | |
| 236 | - echo '<img src="' . $cat_default_img['src'] . '" style="max-height:60px;max-width:60px;"/>'; | |
| 233 | +	if ($column_name == 'cat_default_img') { | |
| 234 | + $cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img'); | |
| 235 | + if ($cat_default_img != '') | |
| 236 | + echo '<img src="' . $cat_default_img['src'] . '" style="max-height:60px;max-width:60px;"/>'; | |
| 237 | 237 | |
| 238 | - } | |
| 238 | + } | |
| 239 | 239 | } | 
| 240 | 240 | |
| 241 | 241 | function geodir_get_default_catimage($term_id, $post_type = 'gd_place') | 
| 242 | 242 |  { | 
| 243 | 243 | |
| 244 | - if ($cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img', '', $post_type)) | |
| 245 | - return $cat_default_img; | |
| 246 | - else | |
| 247 | - return false; | |
| 244 | + if ($cat_default_img = get_tax_meta($term_id, 'ct_cat_default_img', '', $post_type)) | |
| 245 | + return $cat_default_img; | |
| 246 | + else | |
| 247 | + return false; | |
| 248 | 248 | } | 
| 249 | 249 | |
| 250 | 250 | //Clear custom fields | 
| 251 | 251 |  add_action('in_admin_footer', 'geodir_tax_meta_clear_custom_field'); | 
| 252 | 252 | function geodir_tax_meta_clear_custom_field() | 
| 253 | 253 |  { | 
| 254 | - if (isset($_REQUEST['taxonomy']) && !empty($_REQUEST['taxonomy'])): | |
| 255 | - ?> | |
| 254 | + if (isset($_REQUEST['taxonomy']) && !empty($_REQUEST['taxonomy'])): | |
| 255 | + ?> | |
| 256 | 256 | <script type="text/javascript"> | 
| 257 | 257 |              jQuery(document).ready(function () { | 
| 258 | 258 |                  jQuery('#addtag #submit').click(function () { | 
| @@ -273,5 +273,5 @@ discard block | ||
| 273 | 273 | }); | 
| 274 | 274 | </script> | 
| 275 | 275 | <?php | 
| 276 | - endif; | |
| 276 | + endif; | |
| 277 | 277 | } | 
| @@ -113,7 +113,7 @@ discard block | ||
| 113 | 113 | $this->add_missed_values(); | 
| 114 | 114 | if (isset($meta_box['use_with_theme'])) | 
| 115 | 115 |                  if ($meta_box['use_with_theme'] === true) { | 
| 116 | - $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta'; | |
| 116 | + $this->SelfPath = get_stylesheet_directory_uri().'/library/cat-meta'; | |
| 117 | 117 |                  } elseif ($meta_box['use_with_theme'] === false) { | 
| 118 | 118 |                      $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); | 
| 119 | 119 |                  } else { | 
| @@ -262,7 +262,7 @@ discard block | ||
| 262 | 262 |                  $li = "<li id='item_{$attachment_id}'>"; | 
| 263 | 263 |                  $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />"; | 
| 264 | 264 |                  //$li 	.= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>"; | 
| 265 | -                $li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>"; | |
| 265 | +                $li .= "<a title='".__('Remove this image', 'geodirectory')."' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='".$this->SelfPath."/images/delete-16.png' alt='".__('Remove', 'geodirectory')."' /></a>"; | |
| 266 | 266 |                  $li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />"; | 
| 267 | 267 | $li .= "</li>"; | 
| 268 | 268 | $html .= $li; | 
| @@ -335,7 +335,7 @@ discard block | ||
| 335 | 335 | $attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0; | 
| 336 | 336 | $ok = false; | 
| 337 | 337 |              if (strpos($field_id, '[') === false) { | 
| 338 | -                check_admin_referer("at-delete-mupload_" . urldecode($field_id)); | |
| 338 | +                check_admin_referer("at-delete-mupload_".urldecode($field_id)); | |
| 339 | 339 | if ($term_id > 0) | 
| 340 | 340 | $this->delete_tax_meta($term_id, $field_id); | 
| 341 | 341 | //$ok = wp_delete_attachment( $attachment_id ); | 
| @@ -423,8 +423,8 @@ discard block | ||
| 423 | 423 | |
| 424 | 424 |              if ($this->has_field('date') && $this->is_edit_page()) { | 
| 425 | 425 | // Enqueu JQuery UI, use proper version. | 
| 426 | -                wp_enqueue_style('tmc-jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css'); | |
| 427 | -                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery')); | |
| 426 | +                wp_enqueue_style('tmc-jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/'.$this->get_jqueryui_ver().'/themes/base/jquery-ui.css'); | |
| 427 | +                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/'.$this->get_jqueryui_ver().'/jquery-ui.min.js', array('jquery')); | |
| 428 | 428 | } | 
| 429 | 429 | |
| 430 | 430 | } | 
| @@ -441,8 +441,8 @@ discard block | ||
| 441 | 441 |              if ($this->has_field('time') && $this->is_edit_page()) { | 
| 442 | 442 | |
| 443 | 443 | // Enqueu JQuery UI, use proper version. | 
| 444 | -                wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true); | |
| 445 | -                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true); | |
| 444 | +                wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/'.$this->get_jqueryui_ver().'/themes/base/jquery-ui.css', array(), false, true); | |
| 445 | +                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/'.$this->get_jqueryui_ver().'/jquery-ui.min.js', array('jquery'), false, true); | |
| 446 | 446 |                  wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true); | 
| 447 | 447 | |
| 448 | 448 | } | 
| @@ -462,13 +462,13 @@ discard block | ||
| 462 | 462 |              if (!empty($this->_meta_box['pages'])) { | 
| 463 | 463 |                  foreach ($this->_meta_box['pages'] as $page) { | 
| 464 | 464 | //add fields to edit form | 
| 465 | - add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form')); | |
| 465 | + add_action($page.'_edit_form_fields', array(&$this, 'show_edit_form')); | |
| 466 | 466 | //add fields to add new form | 
| 467 | - add_action($page . '_add_form_fields', array(&$this, 'show_new_form')); | |
| 467 | + add_action($page.'_add_form_fields', array(&$this, 'show_new_form')); | |
| 468 | 468 | // this saves the edit fields | 
| 469 | -                    add_action('edited_' . $page, array(&$this, 'save'), 10, 2); | |
| 469 | +                    add_action('edited_'.$page, array(&$this, 'save'), 10, 2); | |
| 470 | 470 | // this saves the add fields | 
| 471 | -                    add_action('created_' . $page, array(&$this, 'save'), 10, 2); | |
| 471 | +                    add_action('created_'.$page, array(&$this, 'save'), 10, 2); | |
| 472 | 472 | } | 
| 473 | 473 | } | 
| 474 | 474 | |
| @@ -517,13 +517,13 @@ discard block | ||
| 517 | 517 |                      $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); | 
| 518 | 518 | |
| 519 | 519 |                  if ($field['validate_func']) { | 
| 520 | - echo '<tr class="form-field form-required ' . $field['style'] . '">'; | |
| 520 | + echo '<tr class="form-field form-required '.$field['style'].'">'; | |
| 521 | 521 |                  } else { | 
| 522 | - echo '<tr class="form-field ' . $field['style'] . '">'; | |
| 522 | + echo '<tr class="form-field '.$field['style'].'">'; | |
| 523 | 523 | } | 
| 524 | 524 | |
| 525 | 525 | // Call Separated methods for displaying each type of field. | 
| 526 | - call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta); | |
| 526 | + call_user_func(array(&$this, 'show_field_'.$field['type']), $field, $meta); | |
| 527 | 527 | echo '</tr>'; | 
| 528 | 528 | } | 
| 529 | 529 | echo '</table>'; | 
| @@ -550,14 +550,14 @@ discard block | ||
| 550 | 550 |                  foreach ($meta as $me) { | 
| 551 | 551 | //for labling toggles | 
| 552 | 552 | $mmm = $me[$field['fields'][0]['id']]; | 
| 553 | - echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">'; | |
| 553 | + echo '<div class="at-repater-block">'.$mmm.'<br/><table class="repeater-table" style="display: none;">'; | |
| 554 | 554 |                      if ($field['inline']) { | 
| 555 | 555 | echo '<tr class="at-inline" VALIGN="top">'; | 
| 556 | 556 | } | 
| 557 | 557 |                      foreach ($field['fields'] as $f) { | 
| 558 | 558 | //reset var $id for repeater | 
| 559 | 559 | $id = ''; | 
| 560 | - $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']'; | |
| 560 | + $id = $field['id'].'['.$c.']['.$f['id'].']'; | |
| 561 | 561 | $m = $me[$f['id']]; | 
| 562 | 562 | $m = ($m !== '') ? $m : $f['std']; | 
| 563 | 563 |                          if ('image' != $f['type'] && $f['type'] != 'repeater') | 
| @@ -567,7 +567,7 @@ discard block | ||
| 567 | 567 |                          if (!$field['inline']) { | 
| 568 | 568 | echo '<tr>'; | 
| 569 | 569 | } | 
| 570 | - call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m); | |
| 570 | + call_user_func(array(&$this, 'show_field_'.$f['type']), $f, $m); | |
| 571 | 571 |                          if (!$field['inline']) { | 
| 572 | 572 | echo '</tr>'; | 
| 573 | 573 | } | 
| @@ -578,18 +578,18 @@ discard block | ||
| 578 | 578 | echo '</table> | 
| 579 | 579 | <span class="at-re-toggle"><img src="'; | 
| 580 | 580 |                      if ($this->_Local_images) { | 
| 581 | - echo $plugin_path . '/images/edit.png'; | |
| 581 | + echo $plugin_path.'/images/edit.png'; | |
| 582 | 582 |                      } else { | 
| 583 | 583 | echo 'http://i.imgur.com/ka0E2.png'; | 
| 584 | 584 | } | 
| 585 | 585 | echo '" alt="Edit" title="Edit"/></span> | 
| 586 | 586 | <img src="'; | 
| 587 | 587 |                      if ($this->_Local_images) { | 
| 588 | - echo $plugin_path . '/images/remove.png'; | |
| 588 | + echo $plugin_path.'/images/remove.png'; | |
| 589 | 589 |                      } else { | 
| 590 | 590 | echo 'http://i.imgur.com/g8Duj.png'; | 
| 591 | 591 | } | 
| 592 | -                    echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; | |
| 592 | +                    echo '" alt="'.__('Remove', 'geodirectory').'" title="'.__('Remove', 'geodirectory').'" id="remove-'.$field['id'].'"></div>'; | |
| 593 | 593 | $c = $c + 1; | 
| 594 | 594 | |
| 595 | 595 | } | 
| @@ -598,11 +598,11 @@ discard block | ||
| 598 | 598 | |
| 599 | 599 | echo '<img src="'; | 
| 600 | 600 |              if ($this->_Local_images) { | 
| 601 | - echo $plugin_path . '/images/add.png'; | |
| 601 | + echo $plugin_path.'/images/add.png'; | |
| 602 | 602 |              } else { | 
| 603 | 603 | echo 'http://i.imgur.com/w5Tuc.png'; | 
| 604 | 604 | } | 
| 605 | -            echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>'; | |
| 605 | +            echo '" alt="'.__('Add', 'geodirectory').'" title="'.__('Add', 'geodirectory').'" id="add-'.$field['id'].'"><br/></div>'; | |
| 606 | 606 | |
| 607 | 607 | //create all fields once more for js function and catch with object buffer | 
| 608 | 608 | ob_start(); | 
| @@ -613,12 +613,12 @@ discard block | ||
| 613 | 613 |              foreach ($field['fields'] as $f) { | 
| 614 | 614 | //reset var $id for repeater | 
| 615 | 615 | $id = ''; | 
| 616 | - $id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']'; | |
| 616 | + $id = $field['id'].'[CurrentCounter]['.$f['id'].']'; | |
| 617 | 617 | $f['id'] = $id; | 
| 618 | 618 |                  if (!$field['inline']) { | 
| 619 | 619 | echo '<tr>'; | 
| 620 | 620 | } | 
| 621 | - call_user_func(array(&$this, 'show_field_' . $f['type']), $f, ''); | |
| 621 | + call_user_func(array(&$this, 'show_field_'.$f['type']), $f, ''); | |
| 622 | 622 |                  if (!$field['inline']) { | 
| 623 | 623 | echo '</tr>'; | 
| 624 | 624 | } | 
| @@ -628,24 +628,24 @@ discard block | ||
| 628 | 628 | } | 
| 629 | 629 | echo '</table><img src="'; | 
| 630 | 630 |              if ($this->_Local_images) { | 
| 631 | - echo $plugin_path . '/images/remove.png'; | |
| 631 | + echo $plugin_path.'/images/remove.png'; | |
| 632 | 632 |              } else { | 
| 633 | 633 | echo 'http://i.imgur.com/g8Duj.png'; | 
| 634 | 634 | } | 
| 635 | -            echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; | |
| 636 | - $counter = 'countadd_' . $field['id']; | |
| 635 | +            echo '" alt="'.__('Remove', 'geodirectory').'" title="'.__('Remove', 'geodirectory').'" id="remove-'.$field['id'].'"></div>'; | |
| 636 | + $counter = 'countadd_'.$field['id']; | |
| 637 | 637 | $js_code = ob_get_clean(); | 
| 638 | 638 |              $js_code = str_replace("'", "\"", $js_code); | 
| 639 | -            $js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code); | |
| 639 | +            $js_code = str_replace("CurrentCounter", "' + ".$counter." + '", $js_code); | |
| 640 | 640 | echo '<script> | 
| 641 | 641 |  				jQuery(document).ready(function() { | 
| 642 | - var ' . $counter . ' = ' . $c . '; | |
| 643 | -					jQuery("#add-' . $field['id'] . '").live(\'click\', function() { | |
| 644 | - ' . $counter . ' = ' . $counter . ' + 1; | |
| 645 | - jQuery(this).before(\'' . $js_code . '\'); | |
| 642 | + var ' . $counter.' = '.$c.'; | |
| 643 | +					jQuery("#add-' . $field['id'].'").live(\'click\', function() { | |
| 644 | + ' . $counter.' = '.$counter.' + 1; | |
| 645 | + jQuery(this).before(\'' . $js_code.'\'); | |
| 646 | 646 | update_repeater_fields(); | 
| 647 | 647 | }); | 
| 648 | -        			jQuery("#remove-' . $field['id'] . '").live(\'click\', function() { | |
| 648 | +        			jQuery("#remove-' . $field['id'].'").live(\'click\', function() { | |
| 649 | 649 | jQuery(this).parent().remove(); | 
| 650 | 650 | }); | 
| 651 | 651 | }); | 
| @@ -772,7 +772,7 @@ discard block | ||
| 772 | 772 | public function show_field_paragraph($field) | 
| 773 | 773 |          { | 
| 774 | 774 | //$this->show_field_begin( $field, $meta ); | 
| 775 | - echo '<p>' . $field['value'] . '</p>'; | |
| 775 | + echo '<p>'.$field['value'].'</p>'; | |
| 776 | 776 | //$this->show_field_end( $field, $meta ); | 
| 777 | 777 | } | 
| 778 | 778 | |
| @@ -803,12 +803,12 @@ discard block | ||
| 803 | 803 |          { | 
| 804 | 804 | |
| 805 | 805 | if (!is_array($meta)) | 
| 806 | - $meta = (array)$meta; | |
| 806 | + $meta = (array) $meta; | |
| 807 | 807 | |
| 808 | 808 | $this->show_field_begin($field, $meta); | 
| 809 | -            echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">"; | |
| 809 | +            echo "<select class='at-select' name='{$field['id']}".($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'").">"; | |
| 810 | 810 |              foreach ($field['options'] as $key => $value) { | 
| 811 | -                echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>"; | |
| 811 | +                echo "<option value='{$key}'".selected(in_array($key, $meta), true, false).">{$value}</option>"; | |
| 812 | 812 | } | 
| 813 | 813 | echo "</select>"; | 
| 814 | 814 | $this->show_field_end($field, $meta); | 
| @@ -827,11 +827,11 @@ discard block | ||
| 827 | 827 |          { | 
| 828 | 828 | |
| 829 | 829 | if (!is_array($meta)) | 
| 830 | - $meta = (array)$meta; | |
| 830 | + $meta = (array) $meta; | |
| 831 | 831 | |
| 832 | 832 | $this->show_field_begin($field, $meta); | 
| 833 | 833 |              foreach ($field['options'] as $key => $value) { | 
| 834 | -                echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>"; | |
| 834 | +                echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'".checked(in_array($key, $meta), true, false)." /> <span class='at-radio-label'>{$value}</span>"; | |
| 835 | 835 | } | 
| 836 | 836 | $this->show_field_end($field, $meta); | 
| 837 | 837 | } | 
| @@ -848,7 +848,7 @@ discard block | ||
| 848 | 848 |          { | 
| 849 | 849 | |
| 850 | 850 | $this->show_field_begin($field, $meta); | 
| 851 | -            echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}"; | |
| 851 | +            echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'".checked(!empty($meta), true, false)." /> {$field['desc']}"; | |
| 852 | 852 | $this->show_field_end($field, $meta); | 
| 853 | 853 | } | 
| 854 | 854 | |
| @@ -890,18 +890,18 @@ discard block | ||
| 890 | 890 | global $post; | 
| 891 | 891 | |
| 892 | 892 | if (!is_array($meta)) | 
| 893 | - $meta = (array)$meta; | |
| 893 | + $meta = (array) $meta; | |
| 894 | 894 | |
| 895 | 895 | $this->show_field_begin($field, $meta); | 
| 896 | 896 |              echo "{$field['desc']}<br />"; | 
| 897 | 897 | |
| 898 | 898 |              if (!empty($meta)) { | 
| 899 | 899 |                  $nonce = wp_create_nonce('at_ajax_delete'); | 
| 900 | -                echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>'; | |
| 900 | +                echo '<div style="margin-bottom: 10px"><strong>'.__('Uploaded files', 'geodirectory').'</strong></div>'; | |
| 901 | 901 | echo '<ol class="at-upload">'; | 
| 902 | 902 |                  foreach ($meta as $att) { | 
| 903 | 903 | // if (wp_attachment_is_image($att)) continue; // what's image uploader for? | 
| 904 | -                    echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>"; | |
| 904 | +                    echo "<li>".wp_get_attachment_link($att, '', false, false, ' ')." (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>".__('Remove', 'geodirectory')."</a>)</li>"; | |
| 905 | 905 | } | 
| 906 | 906 | echo '</ol>'; | 
| 907 | 907 | } | 
| @@ -909,13 +909,13 @@ discard block | ||
| 909 | 909 | // show form upload | 
| 910 | 910 | |
| 911 | 911 | echo "<div class='at-file-upload-label'>"; | 
| 912 | -            echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>"; | |
| 912 | +            echo "<strong>".__('Upload new files', 'geodirectory')."</strong>"; | |
| 913 | 913 | echo "</div>"; | 
| 914 | 914 | echo "<div class='new-files'>"; | 
| 915 | 915 | echo "<div class='file-input'>"; | 
| 916 | 916 |              echo "<input type='file' name='{$field['id']}[]' />"; | 
| 917 | 917 | echo "</div><!-- End .file-input -->"; | 
| 918 | -            echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>"; | |
| 918 | +            echo "<a class='at-add-file button' href='#'>".__('Add more files', 'geodirectory')."</a>"; | |
| 919 | 919 | echo "</div><!-- End .new-files -->"; | 
| 920 | 920 | echo "</td>"; | 
| 921 | 921 | $this->show_field_end($field, $meta); | 
| @@ -932,7 +932,7 @@ discard block | ||
| 932 | 932 | public function show_field_image($field, $meta) | 
| 933 | 933 |          { | 
| 934 | 934 | $this->show_field_begin($field, $meta); | 
| 935 | -            $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false); | |
| 935 | +            $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_".$field['id'], false, false); | |
| 936 | 936 |              if (is_array($meta)) { | 
| 937 | 937 | if (isset($meta[0]) && is_array($meta[0])) | 
| 938 | 938 | $meta = $meta[0]; | 
| @@ -958,20 +958,20 @@ discard block | ||
| 958 | 958 | |
| 959 | 959 | $sub_dir = str_replace($uploads_baseurl, '', $sub_dir); | 
| 960 | 960 | |
| 961 | - $uploads_url = $uploads_baseurl . $sub_dir; | |
| 961 | + $uploads_url = $uploads_baseurl.$sub_dir; | |
| 962 | 962 | |
| 963 | - $meta['src'] = $uploads_url . '/' . $file_name; | |
| 963 | + $meta['src'] = $uploads_url.'/'.$file_name; | |
| 964 | 964 | |
| 965 | 965 | |
| 966 | - $html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>"; | |
| 967 | - $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />"; | |
| 968 | - $html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />"; | |
| 969 | -                $html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />"; | |
| 966 | + $html .= "<span class='mupload_img_holder'><img src='".$meta['src']."' style='max-height: 150px;max-width: 150px;' /></span>"; | |
| 967 | + $html .= "<input type='hidden' name='".$field['id']."[id]' id='".$field['id']."[id]' value='".$meta['id']."' />"; | |
| 968 | + $html .= "<input type='hidden' class='".$field['id']."[src]' name='".$field['id']."[src]' id='".$field['id']."[src]' value='".$meta['src']."' />"; | |
| 969 | +                $html .= "<input class='at-delete_image_button' type='button' rel='".$field['id']."' value='".__('Remove Image', 'geodirectory')."' />"; | |
| 970 | 970 |              } else { | 
| 971 | 971 | $html .= "<span class='mupload_img_holder'></span>"; | 
| 972 | - $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />"; | |
| 973 | - $html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />"; | |
| 974 | -                $html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />"; | |
| 972 | + $html .= "<input type='hidden' name='".$field['id']."[id]' id='".$field['id']."[id]' value='' />"; | |
| 973 | + $html .= "<input class='".$field['id']."[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='".$field['id']."[src]' id='".$field['id']."[src]' value='' />"; | |
| 974 | +                $html .= "<input class='at-upload_image_button' type='button' rel='".$field['id']."' value='".__('Upload Image', 'geodirectory')."' />"; | |
| 975 | 975 | } | 
| 976 | 976 | echo $html; | 
| 977 | 977 | $this->show_field_end($field, $meta); | 
| @@ -995,7 +995,7 @@ discard block | ||
| 995 | 995 | |
| 996 | 996 |              echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />"; | 
| 997 | 997 |              //	echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>"; | 
| 998 | -            echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>"; | |
| 998 | +            echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='".__('Select a color', 'geodirectory')."'/>"; | |
| 999 | 999 |              echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>"; | 
| 1000 | 1000 | $this->show_field_end($field, $meta); | 
| 1001 | 1001 | |
| @@ -1013,14 +1013,14 @@ discard block | ||
| 1013 | 1013 |          { | 
| 1014 | 1014 | |
| 1015 | 1015 | if (!is_array($meta)) | 
| 1016 | - $meta = (array)$meta; | |
| 1016 | + $meta = (array) $meta; | |
| 1017 | 1017 | |
| 1018 | 1018 | $this->show_field_begin($field, $meta); | 
| 1019 | 1019 | |
| 1020 | 1020 | $html = array(); | 
| 1021 | 1021 | |
| 1022 | 1022 |              foreach ($field['options'] as $key => $value) { | 
| 1023 | -                $html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}"; | |
| 1023 | +                $html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'".checked(in_array($key, $meta), true, false)." /> {$value}"; | |
| 1024 | 1024 | } | 
| 1025 | 1025 | |
| 1026 | 1026 |              echo implode('<br />', $html); | 
| @@ -1073,7 +1073,7 @@ discard block | ||
| 1073 | 1073 |          { | 
| 1074 | 1074 | global $post; | 
| 1075 | 1075 | |
| 1076 | - if (!is_array($meta)) $meta = (array)$meta; | |
| 1076 | + if (!is_array($meta)) $meta = (array) $meta; | |
| 1077 | 1077 | $this->show_field_begin($field, $meta); | 
| 1078 | 1078 | $options = $field['options']; | 
| 1079 | 1079 | $posts = get_posts($options['args']); | 
| @@ -1081,13 +1081,13 @@ discard block | ||
| 1081 | 1081 | // checkbox_list | 
| 1082 | 1082 |              if ('checkbox_list' == $options['type']) { | 
| 1083 | 1083 |                  foreach ($posts as $p) { | 
| 1084 | -                    echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>"; | |
| 1084 | +                    echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'".checked(in_array($p->ID, $meta), true, false)." /> $p->post_title<br/>"; | |
| 1085 | 1085 | } | 
| 1086 | 1086 | } // select | 
| 1087 | 1087 |              else { | 
| 1088 | -                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; | |
| 1088 | +                echo "<select name='{$field['id']}".($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'").">"; | |
| 1089 | 1089 |                  foreach ($posts as $p) { | 
| 1090 | - echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>"; | |
| 1090 | + echo "<option value='$p->ID'".selected(in_array($p->ID, $meta), true, false).">$p->post_title</option>"; | |
| 1091 | 1091 | } | 
| 1092 | 1092 | echo "</select>"; | 
| 1093 | 1093 | } | 
| @@ -1111,7 +1111,7 @@ discard block | ||
| 1111 | 1111 |          { | 
| 1112 | 1112 | global $post; | 
| 1113 | 1113 | |
| 1114 | - if (!is_array($meta)) $meta = (array)$meta; | |
| 1114 | + if (!is_array($meta)) $meta = (array) $meta; | |
| 1115 | 1115 | $this->show_field_begin($field, $meta); | 
| 1116 | 1116 | $options = $field['options']; | 
| 1117 | 1117 | $terms = get_terms($options['taxonomy'], $options['args']); | 
| @@ -1119,13 +1119,13 @@ discard block | ||
| 1119 | 1119 | // checkbox_list | 
| 1120 | 1120 |              if ('checkbox_list' == $options['type']) { | 
| 1121 | 1121 |                  foreach ($terms as $term) { | 
| 1122 | -                    echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>"; | |
| 1122 | +                    echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'".checked(in_array($term->slug, $meta), true, false)." /> $term->name<br/>"; | |
| 1123 | 1123 | } | 
| 1124 | 1124 | } // select | 
| 1125 | 1125 |              else { | 
| 1126 | -                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; | |
| 1126 | +                echo "<select name='{$field['id']}".($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'").">"; | |
| 1127 | 1127 |                  foreach ($terms as $term) { | 
| 1128 | - echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>"; | |
| 1128 | + echo "<option value='$term->slug'".selected(in_array($term->slug, $meta), true, false).">$term->name</option>"; | |
| 1129 | 1129 | } | 
| 1130 | 1130 | echo "</select>"; | 
| 1131 | 1131 | } | 
| @@ -1181,7 +1181,7 @@ discard block | ||
| 1181 | 1181 | |
| 1182 | 1182 | //$old_filename = $upload_dir['path'].'/'.$old_filename; | 
| 1183 | 1183 | |
| 1184 | - $new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png'; | |
| 1184 | + $new_filename = $upload_dir['path'].'/'.'cat_icon_'.$term_id.'.png'; | |
| 1185 | 1185 | |
| 1186 | 1186 | /*rename($old_filename, $new_filename); | 
| 1187 | 1187 | |
| @@ -1223,9 +1223,9 @@ discard block | ||
| 1223 | 1223 |                  if ($type != "paragraph") { | 
| 1224 | 1224 | |
| 1225 | 1225 | // Call defined method to save meta value, if there's no methods, call common one. | 
| 1226 | - $save_func = 'save_field_' . $type; | |
| 1226 | + $save_func = 'save_field_'.$type; | |
| 1227 | 1227 |                      if (method_exists($this, $save_func)) { | 
| 1228 | - call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new); | |
| 1228 | + call_user_func(array(&$this, 'save_field_'.$type), $term_id, $field, $old, $new); | |
| 1229 | 1229 |                      } else { | 
| 1230 | 1230 | $this->save_field($term_id, $field, $old, $new); | 
| 1231 | 1231 | } | 
| @@ -1370,7 +1370,7 @@ discard block | ||
| 1370 | 1370 |                  if (!is_wp_error($id)) { | 
| 1371 | 1371 | |
| 1372 | 1372 | wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); | 
| 1373 | - add_post_meta($term_id, $name, $id, false); // save file's url in meta fields | |
| 1373 | + add_post_meta($term_id, $name, $id, false); // save file's url in meta fields | |
| 1374 | 1374 | |
| 1375 | 1375 | } // End if | 
| 1376 | 1376 | |
| @@ -1415,7 +1415,7 @@ discard block | ||
| 1415 | 1415 |                  if (!is_wp_error($id)) { | 
| 1416 | 1416 | |
| 1417 | 1417 | wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); | 
| 1418 | - return $id; // return file's url in meta fields | |
| 1418 | + return $id; // return file's url in meta fields | |
| 1419 | 1419 | } // End if | 
| 1420 | 1420 | } // End foreach | 
| 1421 | 1421 | } | 
| @@ -1430,9 +1430,9 @@ discard block | ||
| 1430 | 1430 |          { | 
| 1431 | 1431 | |
| 1432 | 1432 | // Default values for meta box | 
| 1433 | -            $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box); | |
| 1433 | +            $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array) $this->_meta_box); | |
| 1434 | 1434 | |
| 1435 | -            if(is_array($this->_fields)) { | |
| 1435 | +            if (is_array($this->_fields)) { | |
| 1436 | 1436 | // Default values for fields | 
| 1437 | 1437 |                  foreach ($this->_fields as &$field) { | 
| 1438 | 1438 |                      $multiple = in_array($field['type'], array('checkbox_list', 'file', 'image')); | 
| @@ -1452,7 +1452,7 @@ discard block | ||
| 1452 | 1452 | */ | 
| 1453 | 1453 | public function has_field($type) | 
| 1454 | 1454 |          { | 
| 1455 | -            if(is_array($this->_fields)) { | |
| 1455 | +            if (is_array($this->_fields)) { | |
| 1456 | 1456 |                  foreach ($this->_fields as $field) { | 
| 1457 | 1457 | if ($type == $field['type']) | 
| 1458 | 1458 | return true; | 
| @@ -2020,12 +2020,12 @@ discard block | ||
| 2020 | 2020 | $post_type = $taxObject->object_type[0]; | 
| 2021 | 2021 | } | 
| 2022 | 2022 | |
| 2023 | -            if($post_type=='post'){$post_type='';} | |
| 2024 | -            if($post_type){$post_type = $post_type.'_';} | |
| 2023 | +            if ($post_type == 'post') {$post_type = ''; } | |
| 2024 | +            if ($post_type) {$post_type = $post_type.'_'; } | |
| 2025 | 2025 | |
| 2026 | 2026 | $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; | 
| 2027 | 2027 | |
| 2028 | -            $m = get_option('tax_meta_' . $post_type  . $t_id); | |
| 2028 | +            $m = get_option('tax_meta_'.$post_type.$t_id); | |
| 2029 | 2029 |              if (isset($m[$key])) { | 
| 2030 | 2030 | return $m[$key]; | 
| 2031 | 2031 |              } else { | 
| @@ -2042,15 +2042,15 @@ discard block | ||
| 2042 | 2042 | $post_type = $taxObject->object_type[0]; | 
| 2043 | 2043 | } | 
| 2044 | 2044 | |
| 2045 | -            if($post_type=='post'){$post_type='';} | |
| 2046 | -            if($post_type){$post_type = $post_type.'_';} | |
| 2045 | +            if ($post_type == 'post') {$post_type = ''; } | |
| 2046 | +            if ($post_type) {$post_type = $post_type.'_'; } | |
| 2047 | 2047 | |
| 2048 | -            $m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2048 | +            $m = get_option('tax_meta_'.$post_type.$term_id); | |
| 2049 | 2049 | |
| 2050 | 2050 |              if (isset($m[$key])) { | 
| 2051 | 2051 | unset($m[$key]); | 
| 2052 | 2052 | } | 
| 2053 | -            update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2053 | +            update_option('tax_meta_'.$post_type.$term_id, $m); | |
| 2054 | 2054 | } | 
| 2055 | 2055 | |
| 2056 | 2056 | //update meta | 
| @@ -2062,13 +2062,13 @@ discard block | ||
| 2062 | 2062 | $post_type = $taxObject->object_type[0]; | 
| 2063 | 2063 | } | 
| 2064 | 2064 | |
| 2065 | -            if($post_type=='post'){$post_type='';} | |
| 2066 | -            if($post_type){$post_type = $post_type.'_';} | |
| 2065 | +            if ($post_type == 'post') {$post_type = ''; } | |
| 2066 | +            if ($post_type) {$post_type = $post_type.'_'; } | |
| 2067 | 2067 | |
| 2068 | -            $m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2068 | +            $m = get_option('tax_meta_'.$post_type.$term_id); | |
| 2069 | 2069 | |
| 2070 | 2070 | $m[$key] = $value; | 
| 2071 | -            update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2071 | +            update_option('tax_meta_'.$post_type.$term_id, $m); | |
| 2072 | 2072 | |
| 2073 | 2073 | /** | 
| 2074 | 2074 | * Called after the tax meta is updated. | 
| @@ -2103,12 +2103,12 @@ discard block | ||
| 2103 | 2103 | $post_type = $taxObject->object_type[0]; | 
| 2104 | 2104 | } | 
| 2105 | 2105 | |
| 2106 | -        if($post_type=='post'){$post_type='';} | |
| 2107 | -        if($post_type){$post_type = $post_type.'_';} | |
| 2106 | +        if ($post_type == 'post') {$post_type = ''; } | |
| 2107 | +        if ($post_type) {$post_type = $post_type.'_'; } | |
| 2108 | 2108 | |
| 2109 | 2109 | $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; | 
| 2110 | 2110 | |
| 2111 | -        $m = get_option('tax_meta_' . $post_type  . $t_id); | |
| 2111 | +        $m = get_option('tax_meta_'.$post_type.$t_id); | |
| 2112 | 2112 |          if (isset($m[$key])) { | 
| 2113 | 2113 | return $m[$key]; | 
| 2114 | 2114 |          } else { | 
| @@ -2125,15 +2125,15 @@ discard block | ||
| 2125 | 2125 | $taxObject = get_taxonomy($_REQUEST['taxonomy']); | 
| 2126 | 2126 | $post_type = $taxObject->object_type[0]; | 
| 2127 | 2127 | |
| 2128 | -        if($post_type=='post'){$post_type='';} | |
| 2129 | -        if($post_type){$post_type = $post_type.'_';} | |
| 2128 | +        if ($post_type == 'post') {$post_type = ''; } | |
| 2129 | +        if ($post_type) {$post_type = $post_type.'_'; } | |
| 2130 | 2130 | |
| 2131 | -        $m = get_option('tax_meta_' . $post_type . $term_id); | |
| 2131 | +        $m = get_option('tax_meta_'.$post_type.$term_id); | |
| 2132 | 2132 | |
| 2133 | 2133 |          if (isset($m[$key])) { | 
| 2134 | 2134 | unset($m[$key]); | 
| 2135 | 2135 | } | 
| 2136 | -        update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2136 | +        update_option('tax_meta_'.$post_type.$term_id, $m); | |
| 2137 | 2137 | } | 
| 2138 | 2138 | } | 
| 2139 | 2139 | |
| @@ -2147,13 +2147,13 @@ discard block | ||
| 2147 | 2147 | $post_type = $taxObject->object_type[0]; | 
| 2148 | 2148 | } | 
| 2149 | 2149 | |
| 2150 | -        if($post_type=='post'){$post_type='';} | |
| 2151 | -        if($post_type){$post_type = $post_type.'_';} | |
| 2150 | +        if ($post_type == 'post') {$post_type = ''; } | |
| 2151 | +        if ($post_type) {$post_type = $post_type.'_'; } | |
| 2152 | 2152 | |
| 2153 | -        $m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2153 | +        $m = get_option('tax_meta_'.$post_type.$term_id); | |
| 2154 | 2154 | |
| 2155 | 2155 | $m[$key] = $value; | 
| 2156 | -        update_option('tax_meta_' . $post_type . $term_id, $m); | |
| 2156 | +        update_option('tax_meta_'.$post_type.$term_id, $m); | |
| 2157 | 2157 | |
| 2158 | 2158 | /** This action is documented in geodirectory-functions/cat-meta-functions/Tax-meta-class.php */ | 
| 2159 | 2159 |          do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); | 
| @@ -28,260 +28,260 @@ discard block | ||
| 28 | 28 | |
| 29 | 29 |  if (!class_exists('Tax_Meta_Class')) : | 
| 30 | 30 | |
| 31 | - /** | |
| 32 | - * All Types Meta Box class. | |
| 33 | - * | |
| 34 | - * @package All Types Meta Box | |
| 35 | - * @since 1.0 | |
| 36 | - * | |
| 37 | - * @todo Nothing. | |
| 38 | - */ | |
| 39 | - | |
| 40 | - | |
| 41 | - class Tax_Meta_Class | |
| 42 | -    { | |
| 43 | - | |
| 44 | - /** | |
| 45 | - * Holds meta box object | |
| 46 | - * | |
| 47 | - * @var object | |
| 48 | - * @access protected | |
| 49 | - */ | |
| 50 | - protected $_meta_box; | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * Holds meta box fields. | |
| 54 | - * | |
| 55 | - * @var array | |
| 56 | - * @access protected | |
| 57 | - */ | |
| 58 | - protected $_prefix; | |
| 59 | - | |
| 60 | - /** | |
| 61 | - * Holds Prefix for meta box fields. | |
| 62 | - * | |
| 63 | - * @var array | |
| 64 | - * @access protected | |
| 65 | - */ | |
| 66 | - protected $_fields; | |
| 67 | - | |
| 68 | - /** | |
| 69 | - * Use local images. | |
| 70 | - * | |
| 71 | - * @var bool | |
| 72 | - * @access protected | |
| 73 | - */ | |
| 74 | - protected $_Local_images; | |
| 75 | - | |
| 76 | - /** | |
| 77 | - * What form is this? edit or new term. | |
| 78 | - * | |
| 79 | - * @var string | |
| 80 | - * @access protected | |
| 81 | - * $since 1.0 | |
| 82 | - */ | |
| 83 | - protected $_form_type; | |
| 84 | - /** | |
| 85 | - * SelfPath to allow themes as well as plugins. | |
| 86 | - * | |
| 87 | - * @var string | |
| 88 | - * @access protected | |
| 89 | - * $since 1.0 | |
| 90 | - */ | |
| 91 | - protected $SelfPath; | |
| 92 | - | |
| 93 | - /** | |
| 94 | - * Constructor | |
| 95 | - * | |
| 96 | - * @since 1.0 | |
| 97 | - * @access public | |
| 98 | - * | |
| 99 | - * @param array $meta_box | |
| 100 | - */ | |
| 101 | - public function __construct($meta_box) | |
| 102 | -        { | |
| 103 | - | |
| 104 | - // If we are not in admin area exit. | |
| 105 | - if (!is_admin()) | |
| 106 | - return; | |
| 107 | - | |
| 108 | - // Assign meta box values to local variables and add it's missed values. | |
| 109 | - $this->_meta_box = $meta_box; | |
| 110 | - $this->_prefix = (isset($meta_box['prefix'])) ? $meta_box['prefix'] : ''; | |
| 111 | - $this->_fields = &$this->_meta_box['fields']; | |
| 112 | - $this->_Local_images = (isset($meta_box['local_images'])) ? true : false; | |
| 113 | - $this->add_missed_values(); | |
| 114 | - if (isset($meta_box['use_with_theme'])) | |
| 115 | -                if ($meta_box['use_with_theme'] === true) { | |
| 116 | - $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta'; | |
| 117 | -                } elseif ($meta_box['use_with_theme'] === false) { | |
| 118 | -                    $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); | |
| 119 | -                } else { | |
| 120 | - $this->SelfPath = $meta_box['use_with_theme']; | |
| 121 | - } | |
| 122 | -            else { | |
| 123 | -                $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); | |
| 124 | - } | |
| 125 | - | |
| 126 | - | |
| 127 | - // Add Actions | |
| 128 | -            add_action('admin_init', array(&$this, 'add')); | |
| 129 | - | |
| 130 | - // Check for special fields and add needed actions for them. | |
| 131 | - $this->check_field_upload(); | |
| 132 | - $this->check_field_color(); | |
| 133 | - $this->check_field_date(); | |
| 134 | - $this->check_field_time(); | |
| 135 | - | |
| 136 | - // Load common js, css files | |
| 137 | - // Must enqueue for all pages as we need js for the media upload, too. | |
| 138 | -            add_action('admin_print_styles', array(&$this, 'load_scripts_styles')); | |
| 139 | - | |
| 140 | - } | |
| 141 | - | |
| 142 | - /** | |
| 143 | - * Load all Javascript and CSS | |
| 144 | - * | |
| 145 | - * @since 1.0 | |
| 146 | - * @access public | |
| 147 | - */ | |
| 148 | - public function load_scripts_styles() | |
| 149 | -        { | |
| 150 | - | |
| 151 | - // Get Plugin Path | |
| 152 | - $plugin_path = $this->SelfPath; | |
| 153 | - //only load styles and js when needed | |
| 154 | - /* | |
| 31 | + /** | |
| 32 | + * All Types Meta Box class. | |
| 33 | + * | |
| 34 | + * @package All Types Meta Box | |
| 35 | + * @since 1.0 | |
| 36 | + * | |
| 37 | + * @todo Nothing. | |
| 38 | + */ | |
| 39 | + | |
| 40 | + | |
| 41 | + class Tax_Meta_Class | |
| 42 | +	{ | |
| 43 | + | |
| 44 | + /** | |
| 45 | + * Holds meta box object | |
| 46 | + * | |
| 47 | + * @var object | |
| 48 | + * @access protected | |
| 49 | + */ | |
| 50 | + protected $_meta_box; | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * Holds meta box fields. | |
| 54 | + * | |
| 55 | + * @var array | |
| 56 | + * @access protected | |
| 57 | + */ | |
| 58 | + protected $_prefix; | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Holds Prefix for meta box fields. | |
| 62 | + * | |
| 63 | + * @var array | |
| 64 | + * @access protected | |
| 65 | + */ | |
| 66 | + protected $_fields; | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * Use local images. | |
| 70 | + * | |
| 71 | + * @var bool | |
| 72 | + * @access protected | |
| 73 | + */ | |
| 74 | + protected $_Local_images; | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * What form is this? edit or new term. | |
| 78 | + * | |
| 79 | + * @var string | |
| 80 | + * @access protected | |
| 81 | + * $since 1.0 | |
| 82 | + */ | |
| 83 | + protected $_form_type; | |
| 84 | + /** | |
| 85 | + * SelfPath to allow themes as well as plugins. | |
| 86 | + * | |
| 87 | + * @var string | |
| 88 | + * @access protected | |
| 89 | + * $since 1.0 | |
| 90 | + */ | |
| 91 | + protected $SelfPath; | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * Constructor | |
| 95 | + * | |
| 96 | + * @since 1.0 | |
| 97 | + * @access public | |
| 98 | + * | |
| 99 | + * @param array $meta_box | |
| 100 | + */ | |
| 101 | + public function __construct($meta_box) | |
| 102 | +		{ | |
| 103 | + | |
| 104 | + // If we are not in admin area exit. | |
| 105 | + if (!is_admin()) | |
| 106 | + return; | |
| 107 | + | |
| 108 | + // Assign meta box values to local variables and add it's missed values. | |
| 109 | + $this->_meta_box = $meta_box; | |
| 110 | + $this->_prefix = (isset($meta_box['prefix'])) ? $meta_box['prefix'] : ''; | |
| 111 | + $this->_fields = &$this->_meta_box['fields']; | |
| 112 | + $this->_Local_images = (isset($meta_box['local_images'])) ? true : false; | |
| 113 | + $this->add_missed_values(); | |
| 114 | + if (isset($meta_box['use_with_theme'])) | |
| 115 | +				if ($meta_box['use_with_theme'] === true) { | |
| 116 | + $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta'; | |
| 117 | +				} elseif ($meta_box['use_with_theme'] === false) { | |
| 118 | +					$this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); | |
| 119 | +				} else { | |
| 120 | + $this->SelfPath = $meta_box['use_with_theme']; | |
| 121 | + } | |
| 122 | +			else { | |
| 123 | +				$this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); | |
| 124 | + } | |
| 125 | + | |
| 126 | + | |
| 127 | + // Add Actions | |
| 128 | +			add_action('admin_init', array(&$this, 'add')); | |
| 129 | + | |
| 130 | + // Check for special fields and add needed actions for them. | |
| 131 | + $this->check_field_upload(); | |
| 132 | + $this->check_field_color(); | |
| 133 | + $this->check_field_date(); | |
| 134 | + $this->check_field_time(); | |
| 135 | + | |
| 136 | + // Load common js, css files | |
| 137 | + // Must enqueue for all pages as we need js for the media upload, too. | |
| 138 | +			add_action('admin_print_styles', array(&$this, 'load_scripts_styles')); | |
| 139 | + | |
| 140 | + } | |
| 141 | + | |
| 142 | + /** | |
| 143 | + * Load all Javascript and CSS | |
| 144 | + * | |
| 145 | + * @since 1.0 | |
| 146 | + * @access public | |
| 147 | + */ | |
| 148 | + public function load_scripts_styles() | |
| 149 | +		{ | |
| 150 | + | |
| 151 | + // Get Plugin Path | |
| 152 | + $plugin_path = $this->SelfPath; | |
| 153 | + //only load styles and js when needed | |
| 154 | + /* | |
| 155 | 155 | * since 1.0 | 
| 156 | 156 | */ | 
| 157 | - $taxnow = isset($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : ''; | |
| 158 | - | |
| 159 | -            if (!empty($this->_meta_box['pages'])) { | |
| 160 | -                if (in_array($taxnow, $this->_meta_box['pages'])) { | |
| 161 | - // Enqueue Meta Box Style | |
| 162 | - //wp_enqueue_style( 'tax-meta-clss', $plugin_path . '/css/Tax-meta-class.css' ); | |
| 163 | - // Enqueue Meta Box Scripts | |
| 164 | - //wp_enqueue_script( 'tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array( 'jquery' ), null, true ); | |
| 165 | - | |
| 166 | - } | |
| 167 | - } | |
| 168 | - | |
| 169 | - } | |
| 170 | - | |
| 171 | - /** | |
| 172 | - * Check the Field Upload, Add needed Actions | |
| 173 | - * | |
| 174 | - * @since 1.0 | |
| 175 | - * @access public | |
| 176 | - */ | |
| 177 | - public function enqueue_tax_meta_scripts() | |
| 178 | -        { | |
| 179 | - // Make upload feature work event when custom post type doesn't support 'editor' | |
| 180 | -            wp_enqueue_script('media-upload'); | |
| 181 | -            wp_enqueue_script('thickbox'); | |
| 182 | - add_thickbox(); | |
| 183 | -            wp_enqueue_script('jquery-ui-core'); | |
| 184 | -            wp_enqueue_script('jquery-ui-sortable'); | |
| 185 | - | |
| 186 | - | |
| 187 | - } | |
| 188 | - | |
| 189 | - public function check_field_upload() | |
| 190 | -        { | |
| 191 | - | |
| 192 | - // Check if the field is an image or file. If not, return. | |
| 193 | -            if (!$this->has_field('image') && !$this->has_field('file')) | |
| 194 | - return; | |
| 195 | - | |
| 196 | - | |
| 197 | -            add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100); | |
| 198 | - | |
| 199 | - // Add data encoding type for file uploading. | |
| 200 | -            add_action('post_edit_form_tag', array(&$this, 'add_enctype')); | |
| 201 | - | |
| 202 | - | |
| 203 | - // Add filters for media upload. | |
| 204 | -            add_filter('media_upload_gallery', array(&$this, 'insert_images')); | |
| 205 | -            add_filter('media_upload_library', array(&$this, 'insert_images')); | |
| 206 | -            add_filter('media_upload_image', array(&$this, 'insert_images')); | |
| 207 | - | |
| 208 | - // Delete all attachments when delete custom post type. | |
| 209 | -            add_action('wp_ajax_at_delete_file', array(&$this, 'delete_file')); | |
| 210 | -            add_action('wp_ajax_at_reorder_images', array(&$this, 'reorder_images')); | |
| 211 | - // Delete file via Ajax | |
| 212 | -            add_action('wp_ajax_at_delete_mupload', array($this, 'wp_ajax_delete_image')); | |
| 213 | - } | |
| 214 | - | |
| 215 | - /** | |
| 216 | - * Add data encoding type for file uploading | |
| 217 | - * | |
| 218 | - * @since 1.0 | |
| 219 | - * @access public | |
| 220 | - */ | |
| 221 | - public function add_enctype() | |
| 222 | -        { | |
| 223 | - echo ' enctype="multipart/form-data"'; | |
| 224 | - } | |
| 225 | - | |
| 226 | - /** | |
| 227 | - * Process images added to meta field. | |
| 228 | - * | |
| 229 | - * Modified from Faster Image Insert plugin. | |
| 230 | - * | |
| 231 | - * @return void | |
| 232 | - * @author Cory Crowley | |
| 233 | - */ | |
| 234 | - public function insert_images() | |
| 235 | -        { | |
| 236 | - | |
| 237 | - // If post variables are empty, return. | |
| 238 | - if (!isset($_POST['at-insert']) || empty($_POST['attachments'])) | |
| 239 | - return; | |
| 240 | - | |
| 241 | - // Security Check | |
| 242 | -            check_admin_referer('media-form'); | |
| 243 | - | |
| 244 | - // Create Security Nonce | |
| 245 | -            $nonce = wp_create_nonce('at_ajax_delete'); | |
| 246 | - | |
| 247 | - // Get Post Id and Field Id | |
| 248 | - $term_id = $_POST['post_id']; | |
| 249 | - $id = $_POST['field_id']; | |
| 250 | - | |
| 251 | - // Modify the insertion string | |
| 252 | - $html = ''; | |
| 253 | -            foreach ($_POST['attachments'] as $attachment_id => $attachment) { | |
| 254 | - | |
| 255 | - // Strip Slashes | |
| 256 | - $attachment = stripslashes_deep($attachment); | |
| 257 | - | |
| 258 | - // If not selected or url is empty, continue in loop. | |
| 259 | - if (empty($attachment['selected']) || empty($attachment['url'])) | |
| 260 | - continue; | |
| 261 | - | |
| 262 | -                $li = "<li id='item_{$attachment_id}'>"; | |
| 263 | -                $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />"; | |
| 264 | -                //$li 	.= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>"; | |
| 265 | -                $li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>"; | |
| 266 | -                $li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />"; | |
| 267 | - $li .= "</li>"; | |
| 268 | - $html .= $li; | |
| 269 | - | |
| 270 | - } // End For Each | |
| 271 | - | |
| 272 | - return media_send_to_editor($html); | |
| 273 | - | |
| 274 | - } | |
| 275 | - | |
| 276 | - /** | |
| 277 | - * Delete attachments associated with the post. | |
| 278 | - * | |
| 279 | - * @since 1.0 | |
| 280 | - * @access public | |
| 281 | - * | |
| 282 | - * @param int|string $term_id The term ID. | |
| 283 | - */ | |
| 284 | -        /*public function delete_attachments( $term_id ) { | |
| 157 | + $taxnow = isset($_REQUEST['taxonomy']) ? $_REQUEST['taxonomy'] : ''; | |
| 158 | + | |
| 159 | +			if (!empty($this->_meta_box['pages'])) { | |
| 160 | +				if (in_array($taxnow, $this->_meta_box['pages'])) { | |
| 161 | + // Enqueue Meta Box Style | |
| 162 | + //wp_enqueue_style( 'tax-meta-clss', $plugin_path . '/css/Tax-meta-class.css' ); | |
| 163 | + // Enqueue Meta Box Scripts | |
| 164 | + //wp_enqueue_script( 'tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array( 'jquery' ), null, true ); | |
| 165 | + | |
| 166 | + } | |
| 167 | + } | |
| 168 | + | |
| 169 | + } | |
| 170 | + | |
| 171 | + /** | |
| 172 | + * Check the Field Upload, Add needed Actions | |
| 173 | + * | |
| 174 | + * @since 1.0 | |
| 175 | + * @access public | |
| 176 | + */ | |
| 177 | + public function enqueue_tax_meta_scripts() | |
| 178 | +		{ | |
| 179 | + // Make upload feature work event when custom post type doesn't support 'editor' | |
| 180 | +			wp_enqueue_script('media-upload'); | |
| 181 | +			wp_enqueue_script('thickbox'); | |
| 182 | + add_thickbox(); | |
| 183 | +			wp_enqueue_script('jquery-ui-core'); | |
| 184 | +			wp_enqueue_script('jquery-ui-sortable'); | |
| 185 | + | |
| 186 | + | |
| 187 | + } | |
| 188 | + | |
| 189 | + public function check_field_upload() | |
| 190 | +		{ | |
| 191 | + | |
| 192 | + // Check if the field is an image or file. If not, return. | |
| 193 | +			if (!$this->has_field('image') && !$this->has_field('file')) | |
| 194 | + return; | |
| 195 | + | |
| 196 | + | |
| 197 | +			add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100); | |
| 198 | + | |
| 199 | + // Add data encoding type for file uploading. | |
| 200 | +			add_action('post_edit_form_tag', array(&$this, 'add_enctype')); | |
| 201 | + | |
| 202 | + | |
| 203 | + // Add filters for media upload. | |
| 204 | +			add_filter('media_upload_gallery', array(&$this, 'insert_images')); | |
| 205 | +			add_filter('media_upload_library', array(&$this, 'insert_images')); | |
| 206 | +			add_filter('media_upload_image', array(&$this, 'insert_images')); | |
| 207 | + | |
| 208 | + // Delete all attachments when delete custom post type. | |
| 209 | +			add_action('wp_ajax_at_delete_file', array(&$this, 'delete_file')); | |
| 210 | +			add_action('wp_ajax_at_reorder_images', array(&$this, 'reorder_images')); | |
| 211 | + // Delete file via Ajax | |
| 212 | +			add_action('wp_ajax_at_delete_mupload', array($this, 'wp_ajax_delete_image')); | |
| 213 | + } | |
| 214 | + | |
| 215 | + /** | |
| 216 | + * Add data encoding type for file uploading | |
| 217 | + * | |
| 218 | + * @since 1.0 | |
| 219 | + * @access public | |
| 220 | + */ | |
| 221 | + public function add_enctype() | |
| 222 | +		{ | |
| 223 | + echo ' enctype="multipart/form-data"'; | |
| 224 | + } | |
| 225 | + | |
| 226 | + /** | |
| 227 | + * Process images added to meta field. | |
| 228 | + * | |
| 229 | + * Modified from Faster Image Insert plugin. | |
| 230 | + * | |
| 231 | + * @return void | |
| 232 | + * @author Cory Crowley | |
| 233 | + */ | |
| 234 | + public function insert_images() | |
| 235 | +		{ | |
| 236 | + | |
| 237 | + // If post variables are empty, return. | |
| 238 | + if (!isset($_POST['at-insert']) || empty($_POST['attachments'])) | |
| 239 | + return; | |
| 240 | + | |
| 241 | + // Security Check | |
| 242 | +			check_admin_referer('media-form'); | |
| 243 | + | |
| 244 | + // Create Security Nonce | |
| 245 | +			$nonce = wp_create_nonce('at_ajax_delete'); | |
| 246 | + | |
| 247 | + // Get Post Id and Field Id | |
| 248 | + $term_id = $_POST['post_id']; | |
| 249 | + $id = $_POST['field_id']; | |
| 250 | + | |
| 251 | + // Modify the insertion string | |
| 252 | + $html = ''; | |
| 253 | +			foreach ($_POST['attachments'] as $attachment_id => $attachment) { | |
| 254 | + | |
| 255 | + // Strip Slashes | |
| 256 | + $attachment = stripslashes_deep($attachment); | |
| 257 | + | |
| 258 | + // If not selected or url is empty, continue in loop. | |
| 259 | + if (empty($attachment['selected']) || empty($attachment['url'])) | |
| 260 | + continue; | |
| 261 | + | |
| 262 | +				$li = "<li id='item_{$attachment_id}'>"; | |
| 263 | +				$li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />"; | |
| 264 | +				//$li 	.= "<a title='" . __( 'Delete this image' ) . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'>" . __( 'Delete' ) . "</a>"; | |
| 265 | +				$li .= "<a title='" . __('Remove this image', 'geodirectory') . "' class='at-delete-file' href='#' rel='{$nonce}|{$term_id}|{$id}|{$attachment_id}'><img src='" . $this->SelfPath . "/images/delete-16.png' alt='" . __('Remove', 'geodirectory') . "' /></a>"; | |
| 266 | +				$li .= "<input type='hidden' name='{$id}[]' value='{$attachment_id}' />"; | |
| 267 | + $li .= "</li>"; | |
| 268 | + $html .= $li; | |
| 269 | + | |
| 270 | + } // End For Each | |
| 271 | + | |
| 272 | + return media_send_to_editor($html); | |
| 273 | + | |
| 274 | + } | |
| 275 | + | |
| 276 | + /** | |
| 277 | + * Delete attachments associated with the post. | |
| 278 | + * | |
| 279 | + * @since 1.0 | |
| 280 | + * @access public | |
| 281 | + * | |
| 282 | + * @param int|string $term_id The term ID. | |
| 283 | + */ | |
| 284 | +		/*public function delete_attachments( $term_id ) { | |
| 285 | 285 | |
| 286 | 286 | // Get Attachments | 
| 287 | 287 | $attachments = get_posts( array( 'numberposts' => -1, 'post_type' => 'attachment', 'post_parent' => $term_id ) ); | 
| @@ -295,349 +295,349 @@ discard block | ||
| 295 | 295 | |
| 296 | 296 | }*/ | 
| 297 | 297 | |
| 298 | - /** | |
| 299 | - * Ajax callback for deleting files. | |
| 300 | - * | |
| 301 | - * Modified from a function used by "Verve Meta Boxes" plugin ( http://goo.gl/aw64H ) | |
| 302 | - * | |
| 303 | - * @since 1.0 | |
| 304 | - * @access public | |
| 305 | - */ | |
| 306 | - public function delete_file() | |
| 307 | -        { | |
| 308 | - | |
| 309 | - | |
| 310 | - // If data is not set, die. | |
| 311 | - if (!isset($_POST['data'])) | |
| 312 | - die(); | |
| 313 | - | |
| 314 | -            list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']); | |
| 315 | - | |
| 316 | - if (!wp_verify_nonce($nonce, 'at_ajax_delete')) | |
| 317 | -                die('1'); | |
| 318 | - | |
| 319 | - $this->delete_tax_meta($term_id, $key, $attach_id); | |
| 320 | - | |
| 321 | -            die('0'); | |
| 322 | - | |
| 323 | - } | |
| 324 | - | |
| 325 | - /** | |
| 326 | - * Ajax callback for deleting files. | |
| 327 | - * Modified from a function used by "Verve Meta Boxes" plugin (http://goo.gl/LzYSq) | |
| 328 | - * @since 1.0 | |
| 329 | - * @access public | |
| 330 | - */ | |
| 331 | - public function wp_ajax_delete_image() | |
| 332 | -        { | |
| 333 | - $term_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0; | |
| 334 | - $field_id = isset($_GET['field_id']) ? $_GET['field_id'] : 0; | |
| 335 | - $attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0; | |
| 336 | - $ok = false; | |
| 337 | -            if (strpos($field_id, '[') === false) { | |
| 338 | -                check_admin_referer("at-delete-mupload_" . urldecode($field_id)); | |
| 339 | - if ($term_id > 0) | |
| 340 | - $this->delete_tax_meta($term_id, $field_id); | |
| 341 | - //$ok = wp_delete_attachment( $attachment_id ); | |
| 342 | - $ok = 1; | |
| 343 | -            } else { | |
| 344 | -                $f = explode('[', urldecode($field_id)); | |
| 345 | - $f_fiexed = array(); | |
| 346 | -                foreach ($f as $k => $v) { | |
| 347 | -                    $f[$k] = str_replace(']', '', $v); | |
| 348 | - } | |
| 349 | - $saved = $this->get_tax_meta($term_id, $f[0], true); | |
| 350 | -                if (isset($saved[$f[1]][$f[2]])) { | |
| 351 | - unset($saved[$f[1]][$f[2]]); | |
| 352 | - if ($term_id > 0) | |
| 353 | - update_post_meta($term_id, $f[0], $saved); | |
| 354 | - //$ok = wp_delete_attachment( $attachment_id ); | |
| 355 | - $ok = 1; | |
| 356 | - } | |
| 357 | - } | |
| 358 | - | |
| 359 | - | |
| 360 | -            if ($ok) { | |
| 361 | -                echo json_encode(array('status' => 'success')); | |
| 362 | - die(); | |
| 363 | -            } else { | |
| 364 | -                echo json_encode(array('message' => __('Cannot delete file. Something\'s wrong.', 'geodirectory'))); | |
| 365 | - die(); | |
| 366 | - } | |
| 367 | - } | |
| 368 | - | |
| 369 | - /** | |
| 370 | - * Ajax callback for reordering Images. | |
| 371 | - * | |
| 372 | - * @since 1.0 | |
| 373 | - * @access public | |
| 374 | - */ | |
| 375 | - public function reorder_images() | |
| 376 | -        { | |
| 377 | - | |
| 378 | - if (!isset($_POST['data'])) | |
| 379 | - die(); | |
| 380 | - | |
| 381 | -            list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']); | |
| 382 | - | |
| 383 | - if (!wp_verify_nonce($nonce, 'at_ajax_reorder')) | |
| 384 | -                die('1'); | |
| 385 | - | |
| 386 | - parse_str($order, $items); | |
| 387 | - $items = $items['item']; | |
| 388 | - $order = 1; | |
| 389 | -            foreach ($items as $item) { | |
| 390 | -                wp_update_post(array('ID' => $item, 'post_parent' => $term_id, 'menu_order' => $order)); | |
| 391 | - $order++; | |
| 392 | - } | |
| 393 | - | |
| 394 | -            die('0'); | |
| 395 | - | |
| 396 | - } | |
| 397 | - | |
| 398 | - /** | |
| 399 | - * Check Field Color | |
| 400 | - * | |
| 401 | - * @since 1.0 | |
| 402 | - * @access public | |
| 403 | - */ | |
| 404 | - public function check_field_color() | |
| 405 | -        { | |
| 406 | - | |
| 407 | -            if ($this->has_field('color') && $this->is_edit_page()) { | |
| 408 | - // Enqueu built-in script and style for color picker. | |
| 409 | -                wp_enqueue_style('farbtastic'); | |
| 410 | -                wp_enqueue_script('farbtastic'); | |
| 411 | - } | |
| 412 | - | |
| 413 | - } | |
| 414 | - | |
| 415 | - /** | |
| 416 | - * Check Field Date | |
| 417 | - * | |
| 418 | - * @since 1.0 | |
| 419 | - * @access public | |
| 420 | - */ | |
| 421 | - public function check_field_date() | |
| 422 | -        { | |
| 423 | - | |
| 424 | -            if ($this->has_field('date') && $this->is_edit_page()) { | |
| 425 | - // Enqueu JQuery UI, use proper version. | |
| 426 | -                wp_enqueue_style('tmc-jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css'); | |
| 427 | -                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery')); | |
| 428 | - } | |
| 429 | - | |
| 430 | - } | |
| 431 | - | |
| 432 | - /** | |
| 433 | - * Check Field Time | |
| 434 | - * | |
| 435 | - * @since 1.0 | |
| 436 | - * @access public | |
| 437 | - */ | |
| 438 | - public function check_field_time() | |
| 439 | -        { | |
| 440 | - | |
| 441 | -            if ($this->has_field('time') && $this->is_edit_page()) { | |
| 442 | - | |
| 443 | - // Enqueu JQuery UI, use proper version. | |
| 444 | -                wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true); | |
| 445 | -                wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true); | |
| 446 | -                wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true); | |
| 447 | - | |
| 448 | - } | |
| 449 | - | |
| 450 | - } | |
| 451 | - | |
| 452 | - /** | |
| 453 | - * Add Meta Box for multiple post types. | |
| 454 | - * | |
| 455 | - * @since 1.0 | |
| 456 | - * @access public | |
| 457 | - */ | |
| 458 | - public function add() | |
| 459 | -        { | |
| 460 | - | |
| 461 | - // Loop through array | |
| 462 | -            if (!empty($this->_meta_box['pages'])) { | |
| 463 | -                foreach ($this->_meta_box['pages'] as $page) { | |
| 464 | - //add fields to edit form | |
| 465 | - add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form')); | |
| 466 | - //add fields to add new form | |
| 467 | - add_action($page . '_add_form_fields', array(&$this, 'show_new_form')); | |
| 468 | - // this saves the edit fields | |
| 469 | -                    add_action('edited_' . $page, array(&$this, 'save'), 10, 2); | |
| 470 | - // this saves the add fields | |
| 471 | -                    add_action('created_' . $page, array(&$this, 'save'), 10, 2); | |
| 472 | - } | |
| 473 | - } | |
| 474 | - | |
| 475 | - } | |
| 476 | - | |
| 477 | - /** | |
| 478 | - * Callback function to show fields on add new taxonomy term form. | |
| 479 | - * | |
| 480 | - * @since 1.0 | |
| 481 | - * @access public | |
| 482 | - */ | |
| 483 | - public function show_new_form($term_id) | |
| 484 | -        { | |
| 485 | - $this->_form_type = 'new'; | |
| 486 | - $this->show($term_id); | |
| 487 | - } | |
| 488 | - | |
| 489 | - /** | |
| 490 | - * Callback function to show fields on term edit form. | |
| 491 | - * | |
| 492 | - * @since 1.0 | |
| 493 | - * @access public | |
| 494 | - */ | |
| 495 | - public function show_edit_form($term_id) | |
| 496 | -        { | |
| 497 | - $this->_form_type = 'edit'; | |
| 498 | - $this->show($term_id); | |
| 499 | - } | |
| 500 | - | |
| 501 | - | |
| 502 | - /** | |
| 503 | - * Callback function to show fields in meta box. | |
| 504 | - * | |
| 505 | - * @since 1.0 | |
| 506 | - * @access public | |
| 507 | - */ | |
| 508 | - public function show($term_id) | |
| 509 | -        { | |
| 510 | - | |
| 511 | - wp_nonce_field(basename(__FILE__), 'tax_meta_class_nonce'); | |
| 512 | - | |
| 513 | -            foreach ($this->_fields as $field) { | |
| 514 | - $meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']); | |
| 515 | - $meta = ($meta !== '') ? $meta : $field['std']; | |
| 516 | -                if ('image' != $field['type'] && $field['type'] != 'repeater') | |
| 517 | -                    $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); | |
| 518 | - | |
| 519 | -                if ($field['validate_func']) { | |
| 520 | - echo '<tr class="form-field form-required ' . $field['style'] . '">'; | |
| 521 | -                } else { | |
| 522 | - echo '<tr class="form-field ' . $field['style'] . '">'; | |
| 523 | - } | |
| 524 | - | |
| 525 | - // Call Separated methods for displaying each type of field. | |
| 526 | - call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta); | |
| 527 | - echo '</tr>'; | |
| 528 | - } | |
| 529 | - echo '</table>'; | |
| 530 | - } | |
| 531 | - | |
| 532 | - /** | |
| 533 | - * Show Repeater Fields. | |
| 534 | - * | |
| 535 | - * @param string $field | |
| 536 | - * @param string $meta | |
| 537 | - * @since 1.0 | |
| 538 | - * @access public | |
| 539 | - */ | |
| 540 | - public function show_field_repeater($field, $meta) | |
| 541 | -        { | |
| 542 | - // Get Plugin Path | |
| 543 | - $plugin_path = $this->SelfPath; | |
| 544 | - $this->show_field_begin($field, $meta); | |
| 545 | -            echo "<div class='at-repeat' id='{$field['id']}'>"; | |
| 546 | - | |
| 547 | - $c = 0; | |
| 548 | - | |
| 549 | -            if (count($meta) > 0 && is_array($meta)) { | |
| 550 | -                foreach ($meta as $me) { | |
| 551 | - //for labling toggles | |
| 552 | - $mmm = $me[$field['fields'][0]['id']]; | |
| 553 | - echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">'; | |
| 554 | -                    if ($field['inline']) { | |
| 555 | - echo '<tr class="at-inline" VALIGN="top">'; | |
| 556 | - } | |
| 557 | -                    foreach ($field['fields'] as $f) { | |
| 558 | - //reset var $id for repeater | |
| 559 | - $id = ''; | |
| 560 | - $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']'; | |
| 561 | - $m = $me[$f['id']]; | |
| 562 | - $m = ($m !== '') ? $m : $f['std']; | |
| 563 | -                        if ('image' != $f['type'] && $f['type'] != 'repeater') | |
| 564 | -                            $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m); | |
| 565 | - //set new id for field in array format | |
| 566 | - $f['id'] = $id; | |
| 567 | -                        if (!$field['inline']) { | |
| 568 | - echo '<tr>'; | |
| 569 | - } | |
| 570 | - call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m); | |
| 571 | -                        if (!$field['inline']) { | |
| 572 | - echo '</tr>'; | |
| 573 | - } | |
| 574 | - } | |
| 575 | -                    if ($field['inline']) { | |
| 576 | - echo '</tr>'; | |
| 577 | - } | |
| 578 | - echo '</table> | |
| 298 | + /** | |
| 299 | + * Ajax callback for deleting files. | |
| 300 | + * | |
| 301 | + * Modified from a function used by "Verve Meta Boxes" plugin ( http://goo.gl/aw64H ) | |
| 302 | + * | |
| 303 | + * @since 1.0 | |
| 304 | + * @access public | |
| 305 | + */ | |
| 306 | + public function delete_file() | |
| 307 | +		{ | |
| 308 | + | |
| 309 | + | |
| 310 | + // If data is not set, die. | |
| 311 | + if (!isset($_POST['data'])) | |
| 312 | + die(); | |
| 313 | + | |
| 314 | +			list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']); | |
| 315 | + | |
| 316 | + if (!wp_verify_nonce($nonce, 'at_ajax_delete')) | |
| 317 | +				die('1'); | |
| 318 | + | |
| 319 | + $this->delete_tax_meta($term_id, $key, $attach_id); | |
| 320 | + | |
| 321 | +			die('0'); | |
| 322 | + | |
| 323 | + } | |
| 324 | + | |
| 325 | + /** | |
| 326 | + * Ajax callback for deleting files. | |
| 327 | + * Modified from a function used by "Verve Meta Boxes" plugin (http://goo.gl/LzYSq) | |
| 328 | + * @since 1.0 | |
| 329 | + * @access public | |
| 330 | + */ | |
| 331 | + public function wp_ajax_delete_image() | |
| 332 | +		{ | |
| 333 | + $term_id = isset($_GET['post_id']) ? intval($_GET['post_id']) : 0; | |
| 334 | + $field_id = isset($_GET['field_id']) ? $_GET['field_id'] : 0; | |
| 335 | + $attachment_id = isset($_GET['attachment_id']) ? intval($_GET['attachment_id']) : 0; | |
| 336 | + $ok = false; | |
| 337 | +			if (strpos($field_id, '[') === false) { | |
| 338 | +				check_admin_referer("at-delete-mupload_" . urldecode($field_id)); | |
| 339 | + if ($term_id > 0) | |
| 340 | + $this->delete_tax_meta($term_id, $field_id); | |
| 341 | + //$ok = wp_delete_attachment( $attachment_id ); | |
| 342 | + $ok = 1; | |
| 343 | +			} else { | |
| 344 | +				$f = explode('[', urldecode($field_id)); | |
| 345 | + $f_fiexed = array(); | |
| 346 | +				foreach ($f as $k => $v) { | |
| 347 | +					$f[$k] = str_replace(']', '', $v); | |
| 348 | + } | |
| 349 | + $saved = $this->get_tax_meta($term_id, $f[0], true); | |
| 350 | +				if (isset($saved[$f[1]][$f[2]])) { | |
| 351 | + unset($saved[$f[1]][$f[2]]); | |
| 352 | + if ($term_id > 0) | |
| 353 | + update_post_meta($term_id, $f[0], $saved); | |
| 354 | + //$ok = wp_delete_attachment( $attachment_id ); | |
| 355 | + $ok = 1; | |
| 356 | + } | |
| 357 | + } | |
| 358 | + | |
| 359 | + | |
| 360 | +			if ($ok) { | |
| 361 | +				echo json_encode(array('status' => 'success')); | |
| 362 | + die(); | |
| 363 | +			} else { | |
| 364 | +				echo json_encode(array('message' => __('Cannot delete file. Something\'s wrong.', 'geodirectory'))); | |
| 365 | + die(); | |
| 366 | + } | |
| 367 | + } | |
| 368 | + | |
| 369 | + /** | |
| 370 | + * Ajax callback for reordering Images. | |
| 371 | + * | |
| 372 | + * @since 1.0 | |
| 373 | + * @access public | |
| 374 | + */ | |
| 375 | + public function reorder_images() | |
| 376 | +		{ | |
| 377 | + | |
| 378 | + if (!isset($_POST['data'])) | |
| 379 | + die(); | |
| 380 | + | |
| 381 | +			list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']); | |
| 382 | + | |
| 383 | + if (!wp_verify_nonce($nonce, 'at_ajax_reorder')) | |
| 384 | +				die('1'); | |
| 385 | + | |
| 386 | + parse_str($order, $items); | |
| 387 | + $items = $items['item']; | |
| 388 | + $order = 1; | |
| 389 | +			foreach ($items as $item) { | |
| 390 | +				wp_update_post(array('ID' => $item, 'post_parent' => $term_id, 'menu_order' => $order)); | |
| 391 | + $order++; | |
| 392 | + } | |
| 393 | + | |
| 394 | +			die('0'); | |
| 395 | + | |
| 396 | + } | |
| 397 | + | |
| 398 | + /** | |
| 399 | + * Check Field Color | |
| 400 | + * | |
| 401 | + * @since 1.0 | |
| 402 | + * @access public | |
| 403 | + */ | |
| 404 | + public function check_field_color() | |
| 405 | +		{ | |
| 406 | + | |
| 407 | +			if ($this->has_field('color') && $this->is_edit_page()) { | |
| 408 | + // Enqueu built-in script and style for color picker. | |
| 409 | +				wp_enqueue_style('farbtastic'); | |
| 410 | +				wp_enqueue_script('farbtastic'); | |
| 411 | + } | |
| 412 | + | |
| 413 | + } | |
| 414 | + | |
| 415 | + /** | |
| 416 | + * Check Field Date | |
| 417 | + * | |
| 418 | + * @since 1.0 | |
| 419 | + * @access public | |
| 420 | + */ | |
| 421 | + public function check_field_date() | |
| 422 | +		{ | |
| 423 | + | |
| 424 | +			if ($this->has_field('date') && $this->is_edit_page()) { | |
| 425 | + // Enqueu JQuery UI, use proper version. | |
| 426 | +				wp_enqueue_style('tmc-jquery-ui-css', 'http://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css'); | |
| 427 | +				wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery')); | |
| 428 | + } | |
| 429 | + | |
| 430 | + } | |
| 431 | + | |
| 432 | + /** | |
| 433 | + * Check Field Time | |
| 434 | + * | |
| 435 | + * @since 1.0 | |
| 436 | + * @access public | |
| 437 | + */ | |
| 438 | + public function check_field_time() | |
| 439 | +		{ | |
| 440 | + | |
| 441 | +			if ($this->has_field('time') && $this->is_edit_page()) { | |
| 442 | + | |
| 443 | + // Enqueu JQuery UI, use proper version. | |
| 444 | +				wp_enqueue_style('tmc-jquery-ui-css', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/themes/base/jquery-ui.css', array(), false, true); | |
| 445 | +				wp_enqueue_script('tmc-jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $this->get_jqueryui_ver() . '/jquery-ui.min.js', array('jquery'), false, true); | |
| 446 | +				wp_enqueue_script('at-timepicker', 'https://github.com/trentrichardson/jQuery-Timepicker-Addon/raw/master/jquery-ui-timepicker-addon.js', array('tmc-jquery-ui'), false, true); | |
| 447 | + | |
| 448 | + } | |
| 449 | + | |
| 450 | + } | |
| 451 | + | |
| 452 | + /** | |
| 453 | + * Add Meta Box for multiple post types. | |
| 454 | + * | |
| 455 | + * @since 1.0 | |
| 456 | + * @access public | |
| 457 | + */ | |
| 458 | + public function add() | |
| 459 | +		{ | |
| 460 | + | |
| 461 | + // Loop through array | |
| 462 | +			if (!empty($this->_meta_box['pages'])) { | |
| 463 | +				foreach ($this->_meta_box['pages'] as $page) { | |
| 464 | + //add fields to edit form | |
| 465 | + add_action($page . '_edit_form_fields', array(&$this, 'show_edit_form')); | |
| 466 | + //add fields to add new form | |
| 467 | + add_action($page . '_add_form_fields', array(&$this, 'show_new_form')); | |
| 468 | + // this saves the edit fields | |
| 469 | +					add_action('edited_' . $page, array(&$this, 'save'), 10, 2); | |
| 470 | + // this saves the add fields | |
| 471 | +					add_action('created_' . $page, array(&$this, 'save'), 10, 2); | |
| 472 | + } | |
| 473 | + } | |
| 474 | + | |
| 475 | + } | |
| 476 | + | |
| 477 | + /** | |
| 478 | + * Callback function to show fields on add new taxonomy term form. | |
| 479 | + * | |
| 480 | + * @since 1.0 | |
| 481 | + * @access public | |
| 482 | + */ | |
| 483 | + public function show_new_form($term_id) | |
| 484 | +		{ | |
| 485 | + $this->_form_type = 'new'; | |
| 486 | + $this->show($term_id); | |
| 487 | + } | |
| 488 | + | |
| 489 | + /** | |
| 490 | + * Callback function to show fields on term edit form. | |
| 491 | + * | |
| 492 | + * @since 1.0 | |
| 493 | + * @access public | |
| 494 | + */ | |
| 495 | + public function show_edit_form($term_id) | |
| 496 | +		{ | |
| 497 | + $this->_form_type = 'edit'; | |
| 498 | + $this->show($term_id); | |
| 499 | + } | |
| 500 | + | |
| 501 | + | |
| 502 | + /** | |
| 503 | + * Callback function to show fields in meta box. | |
| 504 | + * | |
| 505 | + * @since 1.0 | |
| 506 | + * @access public | |
| 507 | + */ | |
| 508 | + public function show($term_id) | |
| 509 | +		{ | |
| 510 | + | |
| 511 | + wp_nonce_field(basename(__FILE__), 'tax_meta_class_nonce'); | |
| 512 | + | |
| 513 | +			foreach ($this->_fields as $field) { | |
| 514 | + $meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']); | |
| 515 | + $meta = ($meta !== '') ? $meta : $field['std']; | |
| 516 | +				if ('image' != $field['type'] && $field['type'] != 'repeater') | |
| 517 | +					$meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); | |
| 518 | + | |
| 519 | +				if ($field['validate_func']) { | |
| 520 | + echo '<tr class="form-field form-required ' . $field['style'] . '">'; | |
| 521 | +				} else { | |
| 522 | + echo '<tr class="form-field ' . $field['style'] . '">'; | |
| 523 | + } | |
| 524 | + | |
| 525 | + // Call Separated methods for displaying each type of field. | |
| 526 | + call_user_func(array(&$this, 'show_field_' . $field['type']), $field, $meta); | |
| 527 | + echo '</tr>'; | |
| 528 | + } | |
| 529 | + echo '</table>'; | |
| 530 | + } | |
| 531 | + | |
| 532 | + /** | |
| 533 | + * Show Repeater Fields. | |
| 534 | + * | |
| 535 | + * @param string $field | |
| 536 | + * @param string $meta | |
| 537 | + * @since 1.0 | |
| 538 | + * @access public | |
| 539 | + */ | |
| 540 | + public function show_field_repeater($field, $meta) | |
| 541 | +		{ | |
| 542 | + // Get Plugin Path | |
| 543 | + $plugin_path = $this->SelfPath; | |
| 544 | + $this->show_field_begin($field, $meta); | |
| 545 | +			echo "<div class='at-repeat' id='{$field['id']}'>"; | |
| 546 | + | |
| 547 | + $c = 0; | |
| 548 | + | |
| 549 | +			if (count($meta) > 0 && is_array($meta)) { | |
| 550 | +				foreach ($meta as $me) { | |
| 551 | + //for labling toggles | |
| 552 | + $mmm = $me[$field['fields'][0]['id']]; | |
| 553 | + echo '<div class="at-repater-block">' . $mmm . '<br/><table class="repeater-table" style="display: none;">'; | |
| 554 | +					if ($field['inline']) { | |
| 555 | + echo '<tr class="at-inline" VALIGN="top">'; | |
| 556 | + } | |
| 557 | +					foreach ($field['fields'] as $f) { | |
| 558 | + //reset var $id for repeater | |
| 559 | + $id = ''; | |
| 560 | + $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']'; | |
| 561 | + $m = $me[$f['id']]; | |
| 562 | + $m = ($m !== '') ? $m : $f['std']; | |
| 563 | +						if ('image' != $f['type'] && $f['type'] != 'repeater') | |
| 564 | +							$m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m); | |
| 565 | + //set new id for field in array format | |
| 566 | + $f['id'] = $id; | |
| 567 | +						if (!$field['inline']) { | |
| 568 | + echo '<tr>'; | |
| 569 | + } | |
| 570 | + call_user_func(array(&$this, 'show_field_' . $f['type']), $f, $m); | |
| 571 | +						if (!$field['inline']) { | |
| 572 | + echo '</tr>'; | |
| 573 | + } | |
| 574 | + } | |
| 575 | +					if ($field['inline']) { | |
| 576 | + echo '</tr>'; | |
| 577 | + } | |
| 578 | + echo '</table> | |
| 579 | 579 | <span class="at-re-toggle"><img src="'; | 
| 580 | -                    if ($this->_Local_images) { | |
| 581 | - echo $plugin_path . '/images/edit.png'; | |
| 582 | -                    } else { | |
| 583 | - echo 'http://i.imgur.com/ka0E2.png'; | |
| 584 | - } | |
| 585 | - echo '" alt="Edit" title="Edit"/></span> | |
| 580 | +					if ($this->_Local_images) { | |
| 581 | + echo $plugin_path . '/images/edit.png'; | |
| 582 | +					} else { | |
| 583 | + echo 'http://i.imgur.com/ka0E2.png'; | |
| 584 | + } | |
| 585 | + echo '" alt="Edit" title="Edit"/></span> | |
| 586 | 586 | <img src="'; | 
| 587 | -                    if ($this->_Local_images) { | |
| 588 | - echo $plugin_path . '/images/remove.png'; | |
| 589 | -                    } else { | |
| 590 | - echo 'http://i.imgur.com/g8Duj.png'; | |
| 591 | - } | |
| 592 | -                    echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; | |
| 593 | - $c = $c + 1; | |
| 594 | - | |
| 595 | - } | |
| 596 | - $this->show_field_end($field, $meta); | |
| 597 | - } | |
| 598 | - | |
| 599 | - echo '<img src="'; | |
| 600 | -            if ($this->_Local_images) { | |
| 601 | - echo $plugin_path . '/images/add.png'; | |
| 602 | -            } else { | |
| 603 | - echo 'http://i.imgur.com/w5Tuc.png'; | |
| 604 | - } | |
| 605 | -            echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>'; | |
| 606 | - | |
| 607 | - //create all fields once more for js function and catch with object buffer | |
| 608 | - ob_start(); | |
| 609 | - echo '<div class="at-repater-block"><table class="repeater-table">'; | |
| 610 | -            if ($field['inline']) { | |
| 611 | - echo '<tr class="at-inline" VALIGN="top">'; | |
| 612 | - } | |
| 613 | -            foreach ($field['fields'] as $f) { | |
| 614 | - //reset var $id for repeater | |
| 615 | - $id = ''; | |
| 616 | - $id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']'; | |
| 617 | - $f['id'] = $id; | |
| 618 | -                if (!$field['inline']) { | |
| 619 | - echo '<tr>'; | |
| 620 | - } | |
| 621 | - call_user_func(array(&$this, 'show_field_' . $f['type']), $f, ''); | |
| 622 | -                if (!$field['inline']) { | |
| 623 | - echo '</tr>'; | |
| 624 | - } | |
| 625 | - } | |
| 626 | -            if ($field['inline']) { | |
| 627 | - echo '</tr>'; | |
| 628 | - } | |
| 629 | - echo '</table><img src="'; | |
| 630 | -            if ($this->_Local_images) { | |
| 631 | - echo $plugin_path . '/images/remove.png'; | |
| 632 | -            } else { | |
| 633 | - echo 'http://i.imgur.com/g8Duj.png'; | |
| 634 | - } | |
| 635 | -            echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; | |
| 636 | - $counter = 'countadd_' . $field['id']; | |
| 637 | - $js_code = ob_get_clean(); | |
| 638 | -            $js_code = str_replace("'", "\"", $js_code); | |
| 639 | -            $js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code); | |
| 640 | - echo '<script> | |
| 587 | +					if ($this->_Local_images) { | |
| 588 | + echo $plugin_path . '/images/remove.png'; | |
| 589 | +					} else { | |
| 590 | + echo 'http://i.imgur.com/g8Duj.png'; | |
| 591 | + } | |
| 592 | +					echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; | |
| 593 | + $c = $c + 1; | |
| 594 | + | |
| 595 | + } | |
| 596 | + $this->show_field_end($field, $meta); | |
| 597 | + } | |
| 598 | + | |
| 599 | + echo '<img src="'; | |
| 600 | +			if ($this->_Local_images) { | |
| 601 | + echo $plugin_path . '/images/add.png'; | |
| 602 | +			} else { | |
| 603 | + echo 'http://i.imgur.com/w5Tuc.png'; | |
| 604 | + } | |
| 605 | +			echo '" alt="' . __('Add', 'geodirectory') . '" title="' . __('Add', 'geodirectory') . '" id="add-' . $field['id'] . '"><br/></div>'; | |
| 606 | + | |
| 607 | + //create all fields once more for js function and catch with object buffer | |
| 608 | + ob_start(); | |
| 609 | + echo '<div class="at-repater-block"><table class="repeater-table">'; | |
| 610 | +			if ($field['inline']) { | |
| 611 | + echo '<tr class="at-inline" VALIGN="top">'; | |
| 612 | + } | |
| 613 | +			foreach ($field['fields'] as $f) { | |
| 614 | + //reset var $id for repeater | |
| 615 | + $id = ''; | |
| 616 | + $id = $field['id'] . '[CurrentCounter][' . $f['id'] . ']'; | |
| 617 | + $f['id'] = $id; | |
| 618 | +				if (!$field['inline']) { | |
| 619 | + echo '<tr>'; | |
| 620 | + } | |
| 621 | + call_user_func(array(&$this, 'show_field_' . $f['type']), $f, ''); | |
| 622 | +				if (!$field['inline']) { | |
| 623 | + echo '</tr>'; | |
| 624 | + } | |
| 625 | + } | |
| 626 | +			if ($field['inline']) { | |
| 627 | + echo '</tr>'; | |
| 628 | + } | |
| 629 | + echo '</table><img src="'; | |
| 630 | +			if ($this->_Local_images) { | |
| 631 | + echo $plugin_path . '/images/remove.png'; | |
| 632 | +			} else { | |
| 633 | + echo 'http://i.imgur.com/g8Duj.png'; | |
| 634 | + } | |
| 635 | +			echo '" alt="' . __('Remove', 'geodirectory') . '" title="' . __('Remove', 'geodirectory') . '" id="remove-' . $field['id'] . '"></div>'; | |
| 636 | + $counter = 'countadd_' . $field['id']; | |
| 637 | + $js_code = ob_get_clean(); | |
| 638 | +			$js_code = str_replace("'", "\"", $js_code); | |
| 639 | +			$js_code = str_replace("CurrentCounter", "' + " . $counter . " + '", $js_code); | |
| 640 | + echo '<script> | |
| 641 | 641 |  				jQuery(document).ready(function() { | 
| 642 | 642 | var ' . $counter . ' = ' . $c . '; | 
| 643 | 643 |  					jQuery("#add-' . $field['id'] . '").live(\'click\', function() { | 
| @@ -650,7 +650,7 @@ discard block | ||
| 650 | 650 | }); | 
| 651 | 651 | }); | 
| 652 | 652 | </script>'; | 
| 653 | - echo '<br/><style> | |
| 653 | + echo '<br/><style> | |
| 654 | 654 |  .at-inline{line-height: 1 !important;} | 
| 655 | 655 |  .at-inline .at-field{border: 0px !important;} | 
| 656 | 656 |  .at-inline .at-label{margin: 0 0 1px !important;} | 
| @@ -658,532 +658,532 @@ discard block | ||
| 658 | 658 |  .at-inline .at-textarea{width: 100px; height: 75px;} | 
| 659 | 659 |  .at-repater-block{background-color: #FFFFFF;border: 1px solid;margin: 2px;} | 
| 660 | 660 | </style>'; | 
| 661 | - $this->show_field_end($field, $meta); | |
| 662 | - } | |
| 663 | - | |
| 664 | - /** | |
| 665 | - * Begin Field. | |
| 666 | - * | |
| 667 | - * @param string $field | |
| 668 | - * @param string $meta | |
| 669 | - * @since 1.0 | |
| 670 | - * @access public | |
| 671 | - */ | |
| 672 | - public function show_field_begin($field, $meta) | |
| 673 | -        { | |
| 674 | -            if (isset($field['group'])) { | |
| 675 | -                if ($field['group'] == "start") { | |
| 676 | - echo "<td class='at-field'>"; | |
| 677 | - } | |
| 678 | -            } else { | |
| 679 | -                if ($this->_form_type == 'edit') { | |
| 680 | - echo '<th valign="top" scope="row">'; | |
| 681 | -                } else { | |
| 682 | -                    if ($field['validate_func']) { | |
| 683 | - echo '<td><div class="form-field form-required">'; | |
| 684 | -                    } else { | |
| 685 | - echo '<td><div class="form-field">'; | |
| 686 | - } | |
| 687 | - } | |
| 688 | - } | |
| 689 | -            if ($field['name'] != '' || $field['name'] != FALSE) { | |
| 690 | - //echo "<div class='at-label'>"; | |
| 691 | -                echo "<label for='{$field['id']}'>{$field['name']}</label>"; | |
| 692 | - //echo "</div>"; | |
| 693 | - } | |
| 694 | -            if ($this->_form_type == 'edit') { | |
| 695 | - echo '</th><td>'; | |
| 696 | - } | |
| 697 | - } | |
| 698 | - | |
| 699 | - /** | |
| 700 | - * End Field. | |
| 701 | - * | |
| 702 | - * @param string $field | |
| 703 | - * @param string $meta | |
| 704 | - * @since 1.0 | |
| 705 | - * @access public | |
| 706 | - */ | |
| 707 | - public function show_field_end($field, $meta = NULL, $group = false) | |
| 708 | -        { | |
| 709 | -            if (isset($field['group'])) { | |
| 710 | -                if ($group == 'end') { | |
| 711 | -                    if ($field['desc'] != '') { | |
| 712 | -                        echo "<p class='desc-field'>{$field['desc']}</p></td>"; | |
| 713 | -                    } else { | |
| 714 | - echo "</td>"; | |
| 715 | - } | |
| 716 | -                } else { | |
| 717 | -                    if ($field['desc'] != '') { | |
| 718 | -                        echo "<p class='desc-field'>{$field['desc']}</p><br/>"; | |
| 719 | -                    } else { | |
| 720 | - echo '<br/>'; | |
| 721 | - } | |
| 722 | - } | |
| 723 | -            } else { | |
| 724 | -                if ($field['desc'] != '') { | |
| 725 | -                    echo "<p class='desc-field'>{$field['desc']}</p>"; | |
| 726 | - } | |
| 727 | -                if ($this->_form_type == 'edit') { | |
| 728 | - echo '<td>'; | |
| 729 | -                } else { | |
| 730 | - echo '<td></div>'; | |
| 731 | - } | |
| 732 | - } | |
| 733 | - } | |
| 734 | - | |
| 735 | - /** | |
| 736 | - * Show Field Text. | |
| 737 | - * | |
| 738 | - * @param string $field | |
| 739 | - * @param string $meta | |
| 740 | - * @since 1.0 | |
| 741 | - * @access public | |
| 742 | - */ | |
| 743 | - public function show_field_text($field, $meta) | |
| 744 | -        { | |
| 745 | - $this->show_field_begin($field, $meta); | |
| 746 | -            echo "<input type='text' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='30' />"; | |
| 747 | - $this->show_field_end($field, $meta); | |
| 748 | - } | |
| 749 | - | |
| 750 | - /** | |
| 751 | - * Show Field hidden. | |
| 752 | - * | |
| 753 | - * @param string $field | |
| 754 | - * @param string|mixed $meta | |
| 755 | - * @since 0.1.3 | |
| 756 | - * @access public | |
| 757 | - */ | |
| 758 | - public function show_field_hidden($field, $meta) | |
| 759 | -        { | |
| 760 | - //$this->show_field_begin( $field, $meta ); | |
| 761 | -            echo "<input type='hidden' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}'/>"; | |
| 762 | - //$this->show_field_end( $field, $meta ); | |
| 763 | - } | |
| 764 | - | |
| 765 | - /** | |
| 766 | - * Show Field Paragraph. | |
| 767 | - * | |
| 768 | - * @param string $field | |
| 769 | - * @since 0.1.3 | |
| 770 | - * @access public | |
| 771 | - */ | |
| 772 | - public function show_field_paragraph($field) | |
| 773 | -        { | |
| 774 | - //$this->show_field_begin( $field, $meta ); | |
| 775 | - echo '<p>' . $field['value'] . '</p>'; | |
| 776 | - //$this->show_field_end( $field, $meta ); | |
| 777 | - } | |
| 778 | - | |
| 779 | - /** | |
| 780 | - * Show Field Textarea. | |
| 781 | - * | |
| 782 | - * @param string $field | |
| 783 | - * @param string $meta | |
| 784 | - * @since 1.0 | |
| 785 | - * @access public | |
| 786 | - */ | |
| 787 | - public function show_field_textarea($field, $meta) | |
| 788 | -        { | |
| 789 | - $this->show_field_begin($field, $meta); | |
| 790 | -            echo "<textarea class='at-textarea large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>"; | |
| 791 | - $this->show_field_end($field, $meta); | |
| 792 | - } | |
| 793 | - | |
| 794 | - /** | |
| 795 | - * Show Field Select. | |
| 796 | - * | |
| 797 | - * @param string $field | |
| 798 | - * @param string $meta | |
| 799 | - * @since 1.0 | |
| 800 | - * @access public | |
| 801 | - */ | |
| 802 | - public function show_field_select($field, $meta) | |
| 803 | -        { | |
| 804 | - | |
| 805 | - if (!is_array($meta)) | |
| 806 | - $meta = (array)$meta; | |
| 807 | - | |
| 808 | - $this->show_field_begin($field, $meta); | |
| 809 | -            echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">"; | |
| 810 | -            foreach ($field['options'] as $key => $value) { | |
| 811 | -                echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>"; | |
| 812 | - } | |
| 813 | - echo "</select>"; | |
| 814 | - $this->show_field_end($field, $meta); | |
| 815 | - | |
| 816 | - } | |
| 817 | - | |
| 818 | - /** | |
| 819 | - * Show Radio Field. | |
| 820 | - * | |
| 821 | - * @param string $field | |
| 822 | - * @param string $meta | |
| 823 | - * @since 1.0 | |
| 824 | - * @access public | |
| 825 | - */ | |
| 826 | - public function show_field_radio($field, $meta) | |
| 827 | -        { | |
| 828 | - | |
| 829 | - if (!is_array($meta)) | |
| 830 | - $meta = (array)$meta; | |
| 831 | - | |
| 832 | - $this->show_field_begin($field, $meta); | |
| 833 | -            foreach ($field['options'] as $key => $value) { | |
| 834 | -                echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>"; | |
| 835 | - } | |
| 836 | - $this->show_field_end($field, $meta); | |
| 837 | - } | |
| 838 | - | |
| 839 | - /** | |
| 840 | - * Show Checkbox Field. | |
| 841 | - * | |
| 842 | - * @param string $field | |
| 843 | - * @param string $meta | |
| 844 | - * @since 1.0 | |
| 845 | - * @access public | |
| 846 | - */ | |
| 847 | - public function show_field_checkbox($field, $meta) | |
| 848 | -        { | |
| 849 | - | |
| 850 | - $this->show_field_begin($field, $meta); | |
| 851 | -            echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}"; | |
| 852 | - $this->show_field_end($field, $meta); | |
| 853 | - } | |
| 854 | - | |
| 855 | - /** | |
| 856 | - * Show Wysiwig Field. | |
| 857 | - * | |
| 858 | - * @param string $field | |
| 859 | - * @param string $meta | |
| 860 | - * @since 1.0 | |
| 861 | - * @access public | |
| 862 | - */ | |
| 863 | - public function show_field_wysiwyg($field, $meta) | |
| 864 | -        { | |
| 865 | - $this->show_field_begin($field, $meta); | |
| 866 | - // Add TinyMCE script for WP version < 3.3 | |
| 867 | - global $wp_version; | |
| 868 | - | |
| 869 | -            if (version_compare($wp_version, '3.2.1') < 1) { | |
| 870 | -                echo "<textarea class='at-wysiwyg theEditor large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>"; | |
| 871 | -            } else { | |
| 872 | - // Use new wp_editor() since WP 3.3 | |
| 873 | -                wp_editor(stripslashes(html_entity_decode($meta)), $field['id'], array('editor_class' => 'at-wysiwyg')); | |
| 874 | - } | |
| 875 | - $this->show_field_end($field, $meta); | |
| 876 | - } | |
| 877 | - | |
| 878 | - /** | |
| 879 | - * Show File Field. | |
| 880 | - * | |
| 881 | - * @global object $post The current post object. | |
| 882 | - * @param string $field | |
| 883 | - * @param string $meta | |
| 884 | - * @since 1.0 | |
| 885 | - * @access public | |
| 886 | - */ | |
| 887 | - public function show_field_file($field, $meta) | |
| 888 | -        { | |
| 889 | - | |
| 890 | - global $post; | |
| 891 | - | |
| 892 | - if (!is_array($meta)) | |
| 893 | - $meta = (array)$meta; | |
| 894 | - | |
| 895 | - $this->show_field_begin($field, $meta); | |
| 896 | -            echo "{$field['desc']}<br />"; | |
| 897 | - | |
| 898 | -            if (!empty($meta)) { | |
| 899 | -                $nonce = wp_create_nonce('at_ajax_delete'); | |
| 900 | -                echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>'; | |
| 901 | - echo '<ol class="at-upload">'; | |
| 902 | -                foreach ($meta as $att) { | |
| 903 | - // if (wp_attachment_is_image($att)) continue; // what's image uploader for? | |
| 904 | -                    echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>"; | |
| 905 | - } | |
| 906 | - echo '</ol>'; | |
| 907 | - } | |
| 908 | - | |
| 909 | - // show form upload | |
| 910 | - | |
| 911 | - echo "<div class='at-file-upload-label'>"; | |
| 912 | -            echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>"; | |
| 913 | - echo "</div>"; | |
| 914 | - echo "<div class='new-files'>"; | |
| 915 | - echo "<div class='file-input'>"; | |
| 916 | -            echo "<input type='file' name='{$field['id']}[]' />"; | |
| 917 | - echo "</div><!-- End .file-input -->"; | |
| 918 | -            echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>"; | |
| 919 | - echo "</div><!-- End .new-files -->"; | |
| 920 | - echo "</td>"; | |
| 921 | - $this->show_field_end($field, $meta); | |
| 922 | - } | |
| 923 | - | |
| 924 | - /** | |
| 925 | - * Show Image Field. | |
| 926 | - * | |
| 927 | - * @param array $field | |
| 928 | - * @param array $meta | |
| 929 | - * @since 1.0 | |
| 930 | - * @access public | |
| 931 | - */ | |
| 932 | - public function show_field_image($field, $meta) | |
| 933 | -        { | |
| 934 | - $this->show_field_begin($field, $meta); | |
| 935 | -            $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false); | |
| 936 | -            if (is_array($meta)) { | |
| 937 | - if (isset($meta[0]) && is_array($meta[0])) | |
| 938 | - $meta = $meta[0]; | |
| 939 | - } | |
| 940 | - | |
| 941 | - $uploads = wp_upload_dir(); | |
| 942 | -            if (is_array($meta) && isset($meta['src']) && $meta['src'] != '') { | |
| 943 | - | |
| 944 | - $file_info = pathinfo($meta['src']); | |
| 945 | - | |
| 946 | - //print_r($meta); | |
| 947 | - //print_r($uploads); | |
| 948 | - //print_r($file_info); | |
| 949 | - | |
| 950 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') | |
| 951 | - $sub_dir = $file_info['dirname']; | |
| 952 | - | |
| 953 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs | |
| 954 | - $uploads_baseurl = $uploads['baseurl']; | |
| 955 | - $uploads_path = $uploads['path']; | |
| 956 | - | |
| 957 | - $file_name = $file_info['basename']; | |
| 958 | - | |
| 959 | - $sub_dir = str_replace($uploads_baseurl, '', $sub_dir); | |
| 960 | - | |
| 961 | - $uploads_url = $uploads_baseurl . $sub_dir; | |
| 962 | - | |
| 963 | - $meta['src'] = $uploads_url . '/' . $file_name; | |
| 964 | - | |
| 965 | - | |
| 966 | - $html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>"; | |
| 967 | - $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />"; | |
| 968 | - $html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />"; | |
| 969 | -                $html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />"; | |
| 970 | -            } else { | |
| 971 | - $html .= "<span class='mupload_img_holder'></span>"; | |
| 972 | - $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />"; | |
| 973 | - $html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />"; | |
| 974 | -                $html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />"; | |
| 975 | - } | |
| 976 | - echo $html; | |
| 977 | - $this->show_field_end($field, $meta); | |
| 978 | - } | |
| 979 | - | |
| 980 | - /** | |
| 981 | - * Show Color Field. | |
| 982 | - * | |
| 983 | - * @param string $field | |
| 984 | - * @param string $meta | |
| 985 | - * @since 1.0 | |
| 986 | - * @access public | |
| 987 | - */ | |
| 988 | - public function show_field_color($field, $meta) | |
| 989 | -        { | |
| 990 | - | |
| 991 | - if (empty($meta)) | |
| 992 | - $meta = '#'; | |
| 993 | - | |
| 994 | - $this->show_field_begin($field, $meta); | |
| 995 | - | |
| 996 | -            echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />"; | |
| 997 | -            //	echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>"; | |
| 998 | -            echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>"; | |
| 999 | -            echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>"; | |
| 1000 | - $this->show_field_end($field, $meta); | |
| 1001 | - | |
| 1002 | - } | |
| 1003 | - | |
| 1004 | - /** | |
| 1005 | - * Show Checkbox List Field | |
| 1006 | - * | |
| 1007 | - * @param string $field | |
| 1008 | - * @param string $meta | |
| 1009 | - * @since 1.0 | |
| 1010 | - * @access public | |
| 1011 | - */ | |
| 1012 | - public function show_field_checkbox_list($field, $meta) | |
| 1013 | -        { | |
| 1014 | - | |
| 1015 | - if (!is_array($meta)) | |
| 1016 | - $meta = (array)$meta; | |
| 1017 | - | |
| 1018 | - $this->show_field_begin($field, $meta); | |
| 1019 | - | |
| 1020 | - $html = array(); | |
| 1021 | - | |
| 1022 | -            foreach ($field['options'] as $key => $value) { | |
| 1023 | -                $html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}"; | |
| 1024 | - } | |
| 1025 | - | |
| 1026 | -            echo implode('<br />', $html); | |
| 1027 | - | |
| 1028 | - $this->show_field_end($field, $meta); | |
| 1029 | - | |
| 1030 | - } | |
| 1031 | - | |
| 1032 | - /** | |
| 1033 | - * Show Date Field. | |
| 1034 | - * | |
| 1035 | - * @param string $field | |
| 1036 | - * @param string $meta | |
| 1037 | - * @since 1.0 | |
| 1038 | - * @access public | |
| 1039 | - */ | |
| 1040 | - public function show_field_date($field, $meta) | |
| 1041 | -        { | |
| 1042 | - $this->show_field_begin($field, $meta); | |
| 1043 | -            echo "<input type='text' class='at-date' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />"; | |
| 1044 | - $this->show_field_end($field, $meta); | |
| 1045 | - } | |
| 1046 | - | |
| 1047 | - /** | |
| 1048 | - * Show time field. | |
| 1049 | - * | |
| 1050 | - * @param string $field | |
| 1051 | - * @param string $meta | |
| 1052 | - * @since 1.0 | |
| 1053 | - * @access public | |
| 1054 | - */ | |
| 1055 | - public function show_field_time($field, $meta) | |
| 1056 | -        { | |
| 1057 | - $this->show_field_begin($field, $meta); | |
| 1058 | -            echo "<input type='text' class='at-time' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />"; | |
| 1059 | - $this->show_field_end($field, $meta); | |
| 1060 | - } | |
| 1061 | - | |
| 1062 | - /** | |
| 1063 | - * Show Posts field. | |
| 1064 | - * used creating a posts/pages/custom types checkboxlist or a select dropdown | |
| 1065 | - * | |
| 1066 | - * @global object $post The current post object. | |
| 1067 | - * @param string $field | |
| 1068 | - * @param string $meta | |
| 1069 | - * @since 1.0 | |
| 1070 | - * @access public | |
| 1071 | - */ | |
| 1072 | - public function show_field_posts($field, $meta) | |
| 1073 | -        { | |
| 1074 | - global $post; | |
| 1075 | - | |
| 1076 | - if (!is_array($meta)) $meta = (array)$meta; | |
| 1077 | - $this->show_field_begin($field, $meta); | |
| 1078 | - $options = $field['options']; | |
| 1079 | - $posts = get_posts($options['args']); | |
| 1080 | - | |
| 1081 | - // checkbox_list | |
| 1082 | -            if ('checkbox_list' == $options['type']) { | |
| 1083 | -                foreach ($posts as $p) { | |
| 1084 | -                    echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>"; | |
| 1085 | - } | |
| 1086 | - } // select | |
| 1087 | -            else { | |
| 1088 | -                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; | |
| 1089 | -                foreach ($posts as $p) { | |
| 1090 | - echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>"; | |
| 1091 | - } | |
| 1092 | - echo "</select>"; | |
| 1093 | - } | |
| 1094 | - | |
| 1095 | - $this->show_field_end($field, $meta); | |
| 1096 | - } | |
| 1097 | - | |
| 1098 | - /** | |
| 1099 | - * Show Taxonomy field. | |
| 1100 | - * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown | |
| 1101 | - * | |
| 1102 | - * @global object $post The current post object. | |
| 1103 | - * @param string $field | |
| 1104 | - * @param string $meta | |
| 1105 | - * @since 1.0 | |
| 1106 | - * @access public | |
| 1107 | - * | |
| 1108 | - * @uses get_terms() | |
| 1109 | - */ | |
| 1110 | - public function show_field_taxonomy($field, $meta) | |
| 1111 | -        { | |
| 1112 | - global $post; | |
| 1113 | - | |
| 1114 | - if (!is_array($meta)) $meta = (array)$meta; | |
| 1115 | - $this->show_field_begin($field, $meta); | |
| 1116 | - $options = $field['options']; | |
| 1117 | - $terms = get_terms($options['taxonomy'], $options['args']); | |
| 1118 | - | |
| 1119 | - // checkbox_list | |
| 1120 | -            if ('checkbox_list' == $options['type']) { | |
| 1121 | -                foreach ($terms as $term) { | |
| 1122 | -                    echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>"; | |
| 1123 | - } | |
| 1124 | - } // select | |
| 1125 | -            else { | |
| 1126 | -                echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; | |
| 1127 | -                foreach ($terms as $term) { | |
| 1128 | - echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>"; | |
| 1129 | - } | |
| 1130 | - echo "</select>"; | |
| 1131 | - } | |
| 1132 | - | |
| 1133 | - $this->show_field_end($field, $meta); | |
| 1134 | - } | |
| 1135 | - | |
| 1136 | - /** | |
| 1137 | - * Save Data from Metabox | |
| 1138 | - * | |
| 1139 | - * @param string $term_id The term ID. | |
| 1140 | - * @since 1.0 | |
| 1141 | - * @access public | |
| 1142 | - * @return string | |
| 1143 | - */ | |
| 1144 | - public function save($term_id) | |
| 1145 | -        { | |
| 1146 | - | |
| 1147 | - $taxnow = ''; | |
| 1148 | - if (isset($_POST['taxonomy'])) | |
| 1149 | - $taxnow = $_POST['taxonomy']; | |
| 1150 | - | |
| 1151 | - if (!isset($term_id) // Check Revision | |
| 1152 | - || (!in_array($taxnow, $this->_meta_box['pages'])) // Check if current taxonomy type is supported. | |
| 1153 | - || (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce')) // Check nonce - Security | |
| 1154 | -                || (!current_user_can('manage_categories')) | |
| 1155 | - ) // Check permission | |
| 1156 | -            { | |
| 1157 | - return $term_id; | |
| 1158 | - } | |
| 1159 | - | |
| 1160 | - | |
| 1161 | -            foreach ($this->_fields as $field) { | |
| 1162 | - | |
| 1163 | - $name = $field['id']; | |
| 1164 | - $type = $field['type']; | |
| 1165 | - $old = $this->get_tax_meta($term_id, $name, !$field['multiple']); | |
| 1166 | - $new = (isset($_POST[$name])) ? $_POST[$name] : (($field['multiple']) ? array() : ''); | |
| 1167 | - | |
| 1168 | - // Validate meta value | |
| 1169 | -                if (class_exists('Tax_Meta_Validate') && method_exists('Tax_Meta_Validate', $field['validate_func'])) { | |
| 1170 | -                    $new = call_user_func(array('Tax_Meta_Validate', $field['validate_func']), $new); | |
| 1171 | - } | |
| 1172 | - | |
| 1173 | - | |
| 1174 | -                if ($name == 'ct_cat_icon') { | |
| 1175 | - | |
| 1176 | - $upload_dir = wp_upload_dir(); | |
| 1177 | - | |
| 1178 | -                    $image_name_arr = explode('/', $new['src']); | |
| 1179 | - //$old_filename = end($image_name_arr); | |
| 1180 | -                    //$img_name_arr = explode('.',$old_filename); | |
| 1181 | - | |
| 1182 | - //$old_filename = $upload_dir['path'].'/'.$old_filename; | |
| 1183 | - | |
| 1184 | - $new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png'; | |
| 1185 | - | |
| 1186 | - /*rename($old_filename, $new_filename); | |
| 661 | + $this->show_field_end($field, $meta); | |
| 662 | + } | |
| 663 | + | |
| 664 | + /** | |
| 665 | + * Begin Field. | |
| 666 | + * | |
| 667 | + * @param string $field | |
| 668 | + * @param string $meta | |
| 669 | + * @since 1.0 | |
| 670 | + * @access public | |
| 671 | + */ | |
| 672 | + public function show_field_begin($field, $meta) | |
| 673 | +		{ | |
| 674 | +			if (isset($field['group'])) { | |
| 675 | +				if ($field['group'] == "start") { | |
| 676 | + echo "<td class='at-field'>"; | |
| 677 | + } | |
| 678 | +			} else { | |
| 679 | +				if ($this->_form_type == 'edit') { | |
| 680 | + echo '<th valign="top" scope="row">'; | |
| 681 | +				} else { | |
| 682 | +					if ($field['validate_func']) { | |
| 683 | + echo '<td><div class="form-field form-required">'; | |
| 684 | +					} else { | |
| 685 | + echo '<td><div class="form-field">'; | |
| 686 | + } | |
| 687 | + } | |
| 688 | + } | |
| 689 | +			if ($field['name'] != '' || $field['name'] != FALSE) { | |
| 690 | + //echo "<div class='at-label'>"; | |
| 691 | +				echo "<label for='{$field['id']}'>{$field['name']}</label>"; | |
| 692 | + //echo "</div>"; | |
| 693 | + } | |
| 694 | +			if ($this->_form_type == 'edit') { | |
| 695 | + echo '</th><td>'; | |
| 696 | + } | |
| 697 | + } | |
| 698 | + | |
| 699 | + /** | |
| 700 | + * End Field. | |
| 701 | + * | |
| 702 | + * @param string $field | |
| 703 | + * @param string $meta | |
| 704 | + * @since 1.0 | |
| 705 | + * @access public | |
| 706 | + */ | |
| 707 | + public function show_field_end($field, $meta = NULL, $group = false) | |
| 708 | +		{ | |
| 709 | +			if (isset($field['group'])) { | |
| 710 | +				if ($group == 'end') { | |
| 711 | +					if ($field['desc'] != '') { | |
| 712 | +						echo "<p class='desc-field'>{$field['desc']}</p></td>"; | |
| 713 | +					} else { | |
| 714 | + echo "</td>"; | |
| 715 | + } | |
| 716 | +				} else { | |
| 717 | +					if ($field['desc'] != '') { | |
| 718 | +						echo "<p class='desc-field'>{$field['desc']}</p><br/>"; | |
| 719 | +					} else { | |
| 720 | + echo '<br/>'; | |
| 721 | + } | |
| 722 | + } | |
| 723 | +			} else { | |
| 724 | +				if ($field['desc'] != '') { | |
| 725 | +					echo "<p class='desc-field'>{$field['desc']}</p>"; | |
| 726 | + } | |
| 727 | +				if ($this->_form_type == 'edit') { | |
| 728 | + echo '<td>'; | |
| 729 | +				} else { | |
| 730 | + echo '<td></div>'; | |
| 731 | + } | |
| 732 | + } | |
| 733 | + } | |
| 734 | + | |
| 735 | + /** | |
| 736 | + * Show Field Text. | |
| 737 | + * | |
| 738 | + * @param string $field | |
| 739 | + * @param string $meta | |
| 740 | + * @since 1.0 | |
| 741 | + * @access public | |
| 742 | + */ | |
| 743 | + public function show_field_text($field, $meta) | |
| 744 | +		{ | |
| 745 | + $this->show_field_begin($field, $meta); | |
| 746 | +			echo "<input type='text' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='30' />"; | |
| 747 | + $this->show_field_end($field, $meta); | |
| 748 | + } | |
| 749 | + | |
| 750 | + /** | |
| 751 | + * Show Field hidden. | |
| 752 | + * | |
| 753 | + * @param string $field | |
| 754 | + * @param string|mixed $meta | |
| 755 | + * @since 0.1.3 | |
| 756 | + * @access public | |
| 757 | + */ | |
| 758 | + public function show_field_hidden($field, $meta) | |
| 759 | +		{ | |
| 760 | + //$this->show_field_begin( $field, $meta ); | |
| 761 | +			echo "<input type='hidden' class='at-text' name='{$field['id']}' id='{$field['id']}' value='{$meta}'/>"; | |
| 762 | + //$this->show_field_end( $field, $meta ); | |
| 763 | + } | |
| 764 | + | |
| 765 | + /** | |
| 766 | + * Show Field Paragraph. | |
| 767 | + * | |
| 768 | + * @param string $field | |
| 769 | + * @since 0.1.3 | |
| 770 | + * @access public | |
| 771 | + */ | |
| 772 | + public function show_field_paragraph($field) | |
| 773 | +		{ | |
| 774 | + //$this->show_field_begin( $field, $meta ); | |
| 775 | + echo '<p>' . $field['value'] . '</p>'; | |
| 776 | + //$this->show_field_end( $field, $meta ); | |
| 777 | + } | |
| 778 | + | |
| 779 | + /** | |
| 780 | + * Show Field Textarea. | |
| 781 | + * | |
| 782 | + * @param string $field | |
| 783 | + * @param string $meta | |
| 784 | + * @since 1.0 | |
| 785 | + * @access public | |
| 786 | + */ | |
| 787 | + public function show_field_textarea($field, $meta) | |
| 788 | +		{ | |
| 789 | + $this->show_field_begin($field, $meta); | |
| 790 | +			echo "<textarea class='at-textarea large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>"; | |
| 791 | + $this->show_field_end($field, $meta); | |
| 792 | + } | |
| 793 | + | |
| 794 | + /** | |
| 795 | + * Show Field Select. | |
| 796 | + * | |
| 797 | + * @param string $field | |
| 798 | + * @param string $meta | |
| 799 | + * @since 1.0 | |
| 800 | + * @access public | |
| 801 | + */ | |
| 802 | + public function show_field_select($field, $meta) | |
| 803 | +		{ | |
| 804 | + | |
| 805 | + if (!is_array($meta)) | |
| 806 | + $meta = (array)$meta; | |
| 807 | + | |
| 808 | + $this->show_field_begin($field, $meta); | |
| 809 | +			echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">"; | |
| 810 | +			foreach ($field['options'] as $key => $value) { | |
| 811 | +				echo "<option value='{$key}'" . selected(in_array($key, $meta), true, false) . ">{$value}</option>"; | |
| 812 | + } | |
| 813 | + echo "</select>"; | |
| 814 | + $this->show_field_end($field, $meta); | |
| 815 | + | |
| 816 | + } | |
| 817 | + | |
| 818 | + /** | |
| 819 | + * Show Radio Field. | |
| 820 | + * | |
| 821 | + * @param string $field | |
| 822 | + * @param string $meta | |
| 823 | + * @since 1.0 | |
| 824 | + * @access public | |
| 825 | + */ | |
| 826 | + public function show_field_radio($field, $meta) | |
| 827 | +		{ | |
| 828 | + | |
| 829 | + if (!is_array($meta)) | |
| 830 | + $meta = (array)$meta; | |
| 831 | + | |
| 832 | + $this->show_field_begin($field, $meta); | |
| 833 | +			foreach ($field['options'] as $key => $value) { | |
| 834 | +				echo "<input type='radio' class='at-radio' name='{$field['id']}' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> <span class='at-radio-label'>{$value}</span>"; | |
| 835 | + } | |
| 836 | + $this->show_field_end($field, $meta); | |
| 837 | + } | |
| 838 | + | |
| 839 | + /** | |
| 840 | + * Show Checkbox Field. | |
| 841 | + * | |
| 842 | + * @param string $field | |
| 843 | + * @param string $meta | |
| 844 | + * @since 1.0 | |
| 845 | + * @access public | |
| 846 | + */ | |
| 847 | + public function show_field_checkbox($field, $meta) | |
| 848 | +		{ | |
| 849 | + | |
| 850 | + $this->show_field_begin($field, $meta); | |
| 851 | +			echo "<input type='checkbox' class='rw-checkbox' name='{$field['id']}' id='{$field['id']}'" . checked(!empty($meta), true, false) . " /> {$field['desc']}"; | |
| 852 | + $this->show_field_end($field, $meta); | |
| 853 | + } | |
| 854 | + | |
| 855 | + /** | |
| 856 | + * Show Wysiwig Field. | |
| 857 | + * | |
| 858 | + * @param string $field | |
| 859 | + * @param string $meta | |
| 860 | + * @since 1.0 | |
| 861 | + * @access public | |
| 862 | + */ | |
| 863 | + public function show_field_wysiwyg($field, $meta) | |
| 864 | +		{ | |
| 865 | + $this->show_field_begin($field, $meta); | |
| 866 | + // Add TinyMCE script for WP version < 3.3 | |
| 867 | + global $wp_version; | |
| 868 | + | |
| 869 | +			if (version_compare($wp_version, '3.2.1') < 1) { | |
| 870 | +				echo "<textarea class='at-wysiwyg theEditor large-text' name='{$field['id']}' id='{$field['id']}' cols='60' rows='10'>{$meta}</textarea>"; | |
| 871 | +			} else { | |
| 872 | + // Use new wp_editor() since WP 3.3 | |
| 873 | +				wp_editor(stripslashes(html_entity_decode($meta)), $field['id'], array('editor_class' => 'at-wysiwyg')); | |
| 874 | + } | |
| 875 | + $this->show_field_end($field, $meta); | |
| 876 | + } | |
| 877 | + | |
| 878 | + /** | |
| 879 | + * Show File Field. | |
| 880 | + * | |
| 881 | + * @global object $post The current post object. | |
| 882 | + * @param string $field | |
| 883 | + * @param string $meta | |
| 884 | + * @since 1.0 | |
| 885 | + * @access public | |
| 886 | + */ | |
| 887 | + public function show_field_file($field, $meta) | |
| 888 | +		{ | |
| 889 | + | |
| 890 | + global $post; | |
| 891 | + | |
| 892 | + if (!is_array($meta)) | |
| 893 | + $meta = (array)$meta; | |
| 894 | + | |
| 895 | + $this->show_field_begin($field, $meta); | |
| 896 | +			echo "{$field['desc']}<br />"; | |
| 897 | + | |
| 898 | +			if (!empty($meta)) { | |
| 899 | +				$nonce = wp_create_nonce('at_ajax_delete'); | |
| 900 | +				echo '<div style="margin-bottom: 10px"><strong>' . __('Uploaded files', 'geodirectory') . '</strong></div>'; | |
| 901 | + echo '<ol class="at-upload">'; | |
| 902 | +				foreach ($meta as $att) { | |
| 903 | + // if (wp_attachment_is_image($att)) continue; // what's image uploader for? | |
| 904 | +					echo "<li>" . wp_get_attachment_link($att, '', false, false, ' ') . " (<a class='at-delete-file' href='#' rel='{$nonce}|{$post->ID}|{$field['id']}|{$att}'>" . __('Remove', 'geodirectory') . "</a>)</li>"; | |
| 905 | + } | |
| 906 | + echo '</ol>'; | |
| 907 | + } | |
| 908 | + | |
| 909 | + // show form upload | |
| 910 | + | |
| 911 | + echo "<div class='at-file-upload-label'>"; | |
| 912 | +			echo "<strong>" . __('Upload new files', 'geodirectory') . "</strong>"; | |
| 913 | + echo "</div>"; | |
| 914 | + echo "<div class='new-files'>"; | |
| 915 | + echo "<div class='file-input'>"; | |
| 916 | +			echo "<input type='file' name='{$field['id']}[]' />"; | |
| 917 | + echo "</div><!-- End .file-input -->"; | |
| 918 | +			echo "<a class='at-add-file button' href='#'>" . __('Add more files', 'geodirectory') . "</a>"; | |
| 919 | + echo "</div><!-- End .new-files -->"; | |
| 920 | + echo "</td>"; | |
| 921 | + $this->show_field_end($field, $meta); | |
| 922 | + } | |
| 923 | + | |
| 924 | + /** | |
| 925 | + * Show Image Field. | |
| 926 | + * | |
| 927 | + * @param array $field | |
| 928 | + * @param array $meta | |
| 929 | + * @since 1.0 | |
| 930 | + * @access public | |
| 931 | + */ | |
| 932 | + public function show_field_image($field, $meta) | |
| 933 | +		{ | |
| 934 | + $this->show_field_begin($field, $meta); | |
| 935 | +			$html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false); | |
| 936 | +			if (is_array($meta)) { | |
| 937 | + if (isset($meta[0]) && is_array($meta[0])) | |
| 938 | + $meta = $meta[0]; | |
| 939 | + } | |
| 940 | + | |
| 941 | + $uploads = wp_upload_dir(); | |
| 942 | +			if (is_array($meta) && isset($meta['src']) && $meta['src'] != '') { | |
| 943 | + | |
| 944 | + $file_info = pathinfo($meta['src']); | |
| 945 | + | |
| 946 | + //print_r($meta); | |
| 947 | + //print_r($uploads); | |
| 948 | + //print_r($file_info); | |
| 949 | + | |
| 950 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') | |
| 951 | + $sub_dir = $file_info['dirname']; | |
| 952 | + | |
| 953 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs | |
| 954 | + $uploads_baseurl = $uploads['baseurl']; | |
| 955 | + $uploads_path = $uploads['path']; | |
| 956 | + | |
| 957 | + $file_name = $file_info['basename']; | |
| 958 | + | |
| 959 | + $sub_dir = str_replace($uploads_baseurl, '', $sub_dir); | |
| 960 | + | |
| 961 | + $uploads_url = $uploads_baseurl . $sub_dir; | |
| 962 | + | |
| 963 | + $meta['src'] = $uploads_url . '/' . $file_name; | |
| 964 | + | |
| 965 | + | |
| 966 | + $html .= "<span class='mupload_img_holder'><img src='" . $meta['src'] . "' style='max-height: 150px;max-width: 150px;' /></span>"; | |
| 967 | + $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='" . $meta['id'] . "' />"; | |
| 968 | + $html .= "<input type='hidden' class='" . $field['id'] . "[src]' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='" . $meta['src'] . "' />"; | |
| 969 | +				$html .= "<input class='at-delete_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Remove Image', 'geodirectory') . "' />"; | |
| 970 | +			} else { | |
| 971 | + $html .= "<span class='mupload_img_holder'></span>"; | |
| 972 | + $html .= "<input type='hidden' name='" . $field['id'] . "[id]' id='" . $field['id'] . "[id]' value='' />"; | |
| 973 | + $html .= "<input class='" . $field['id'] . "[src]' style='position:absolute;left:-500px;width:50px;' type='text' name='" . $field['id'] . "[src]' id='" . $field['id'] . "[src]' value='' />"; | |
| 974 | +				$html .= "<input class='at-upload_image_button' type='button' rel='" . $field['id'] . "' value='" . __('Upload Image', 'geodirectory') . "' />"; | |
| 975 | + } | |
| 976 | + echo $html; | |
| 977 | + $this->show_field_end($field, $meta); | |
| 978 | + } | |
| 979 | + | |
| 980 | + /** | |
| 981 | + * Show Color Field. | |
| 982 | + * | |
| 983 | + * @param string $field | |
| 984 | + * @param string $meta | |
| 985 | + * @since 1.0 | |
| 986 | + * @access public | |
| 987 | + */ | |
| 988 | + public function show_field_color($field, $meta) | |
| 989 | +		{ | |
| 990 | + | |
| 991 | + if (empty($meta)) | |
| 992 | + $meta = '#'; | |
| 993 | + | |
| 994 | + $this->show_field_begin($field, $meta); | |
| 995 | + | |
| 996 | +			echo "<input class='at-color' type='text' name='{$field['id']}' id='{$field['id']}' value='{$meta}' size='8' />"; | |
| 997 | +			//	echo "<a href='#' class='at-color-select button' rel='{$field['id']}'>" . __( 'Select a color' ) . "</a>"; | |
| 998 | +			echo "<input type='button' class='at-color-select button' rel='{$field['id']}' value='" . __('Select a color', 'geodirectory') . "'/>"; | |
| 999 | +			echo "<div style='display:none' class='at-color-picker' rel='{$field['id']}'></div>"; | |
| 1000 | + $this->show_field_end($field, $meta); | |
| 1001 | + | |
| 1002 | + } | |
| 1003 | + | |
| 1004 | + /** | |
| 1005 | + * Show Checkbox List Field | |
| 1006 | + * | |
| 1007 | + * @param string $field | |
| 1008 | + * @param string $meta | |
| 1009 | + * @since 1.0 | |
| 1010 | + * @access public | |
| 1011 | + */ | |
| 1012 | + public function show_field_checkbox_list($field, $meta) | |
| 1013 | +		{ | |
| 1014 | + | |
| 1015 | + if (!is_array($meta)) | |
| 1016 | + $meta = (array)$meta; | |
| 1017 | + | |
| 1018 | + $this->show_field_begin($field, $meta); | |
| 1019 | + | |
| 1020 | + $html = array(); | |
| 1021 | + | |
| 1022 | +			foreach ($field['options'] as $key => $value) { | |
| 1023 | +				$html[] = "<input type='checkbox' class='at-checkbox_list' name='{$field['id']}[]' value='{$key}'" . checked(in_array($key, $meta), true, false) . " /> {$value}"; | |
| 1024 | + } | |
| 1025 | + | |
| 1026 | +			echo implode('<br />', $html); | |
| 1027 | + | |
| 1028 | + $this->show_field_end($field, $meta); | |
| 1029 | + | |
| 1030 | + } | |
| 1031 | + | |
| 1032 | + /** | |
| 1033 | + * Show Date Field. | |
| 1034 | + * | |
| 1035 | + * @param string $field | |
| 1036 | + * @param string $meta | |
| 1037 | + * @since 1.0 | |
| 1038 | + * @access public | |
| 1039 | + */ | |
| 1040 | + public function show_field_date($field, $meta) | |
| 1041 | +		{ | |
| 1042 | + $this->show_field_begin($field, $meta); | |
| 1043 | +			echo "<input type='text' class='at-date' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />"; | |
| 1044 | + $this->show_field_end($field, $meta); | |
| 1045 | + } | |
| 1046 | + | |
| 1047 | + /** | |
| 1048 | + * Show time field. | |
| 1049 | + * | |
| 1050 | + * @param string $field | |
| 1051 | + * @param string $meta | |
| 1052 | + * @since 1.0 | |
| 1053 | + * @access public | |
| 1054 | + */ | |
| 1055 | + public function show_field_time($field, $meta) | |
| 1056 | +		{ | |
| 1057 | + $this->show_field_begin($field, $meta); | |
| 1058 | +			echo "<input type='text' class='at-time' name='{$field['id']}' id='{$field['id']}' rel='{$field['format']}' value='{$meta}' size='30' />"; | |
| 1059 | + $this->show_field_end($field, $meta); | |
| 1060 | + } | |
| 1061 | + | |
| 1062 | + /** | |
| 1063 | + * Show Posts field. | |
| 1064 | + * used creating a posts/pages/custom types checkboxlist or a select dropdown | |
| 1065 | + * | |
| 1066 | + * @global object $post The current post object. | |
| 1067 | + * @param string $field | |
| 1068 | + * @param string $meta | |
| 1069 | + * @since 1.0 | |
| 1070 | + * @access public | |
| 1071 | + */ | |
| 1072 | + public function show_field_posts($field, $meta) | |
| 1073 | +		{ | |
| 1074 | + global $post; | |
| 1075 | + | |
| 1076 | + if (!is_array($meta)) $meta = (array)$meta; | |
| 1077 | + $this->show_field_begin($field, $meta); | |
| 1078 | + $options = $field['options']; | |
| 1079 | + $posts = get_posts($options['args']); | |
| 1080 | + | |
| 1081 | + // checkbox_list | |
| 1082 | +			if ('checkbox_list' == $options['type']) { | |
| 1083 | +				foreach ($posts as $p) { | |
| 1084 | +					echo "<input type='checkbox' name='{$field['id']}[]' value='$p->ID'" . checked(in_array($p->ID, $meta), true, false) . " /> $p->post_title<br/>"; | |
| 1085 | + } | |
| 1086 | + } // select | |
| 1087 | +			else { | |
| 1088 | +				echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; | |
| 1089 | +				foreach ($posts as $p) { | |
| 1090 | + echo "<option value='$p->ID'" . selected(in_array($p->ID, $meta), true, false) . ">$p->post_title</option>"; | |
| 1091 | + } | |
| 1092 | + echo "</select>"; | |
| 1093 | + } | |
| 1094 | + | |
| 1095 | + $this->show_field_end($field, $meta); | |
| 1096 | + } | |
| 1097 | + | |
| 1098 | + /** | |
| 1099 | + * Show Taxonomy field. | |
| 1100 | + * used creating a category/tags/custom taxonomy checkboxlist or a select dropdown | |
| 1101 | + * | |
| 1102 | + * @global object $post The current post object. | |
| 1103 | + * @param string $field | |
| 1104 | + * @param string $meta | |
| 1105 | + * @since 1.0 | |
| 1106 | + * @access public | |
| 1107 | + * | |
| 1108 | + * @uses get_terms() | |
| 1109 | + */ | |
| 1110 | + public function show_field_taxonomy($field, $meta) | |
| 1111 | +		{ | |
| 1112 | + global $post; | |
| 1113 | + | |
| 1114 | + if (!is_array($meta)) $meta = (array)$meta; | |
| 1115 | + $this->show_field_begin($field, $meta); | |
| 1116 | + $options = $field['options']; | |
| 1117 | + $terms = get_terms($options['taxonomy'], $options['args']); | |
| 1118 | + | |
| 1119 | + // checkbox_list | |
| 1120 | +			if ('checkbox_list' == $options['type']) { | |
| 1121 | +				foreach ($terms as $term) { | |
| 1122 | +					echo "<input type='checkbox' name='{$field['id']}[]' value='$term->slug'" . checked(in_array($term->slug, $meta), true, false) . " /> $term->name<br/>"; | |
| 1123 | + } | |
| 1124 | + } // select | |
| 1125 | +			else { | |
| 1126 | +				echo "<select name='{$field['id']}" . ($field['multiple'] ? "[]' multiple='multiple' style='height:auto'" : "'") . ">"; | |
| 1127 | +				foreach ($terms as $term) { | |
| 1128 | + echo "<option value='$term->slug'" . selected(in_array($term->slug, $meta), true, false) . ">$term->name</option>"; | |
| 1129 | + } | |
| 1130 | + echo "</select>"; | |
| 1131 | + } | |
| 1132 | + | |
| 1133 | + $this->show_field_end($field, $meta); | |
| 1134 | + } | |
| 1135 | + | |
| 1136 | + /** | |
| 1137 | + * Save Data from Metabox | |
| 1138 | + * | |
| 1139 | + * @param string $term_id The term ID. | |
| 1140 | + * @since 1.0 | |
| 1141 | + * @access public | |
| 1142 | + * @return string | |
| 1143 | + */ | |
| 1144 | + public function save($term_id) | |
| 1145 | +		{ | |
| 1146 | + | |
| 1147 | + $taxnow = ''; | |
| 1148 | + if (isset($_POST['taxonomy'])) | |
| 1149 | + $taxnow = $_POST['taxonomy']; | |
| 1150 | + | |
| 1151 | + if (!isset($term_id) // Check Revision | |
| 1152 | + || (!in_array($taxnow, $this->_meta_box['pages'])) // Check if current taxonomy type is supported. | |
| 1153 | + || (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce')) // Check nonce - Security | |
| 1154 | +				|| (!current_user_can('manage_categories')) | |
| 1155 | + ) // Check permission | |
| 1156 | +			{ | |
| 1157 | + return $term_id; | |
| 1158 | + } | |
| 1159 | + | |
| 1160 | + | |
| 1161 | +			foreach ($this->_fields as $field) { | |
| 1162 | + | |
| 1163 | + $name = $field['id']; | |
| 1164 | + $type = $field['type']; | |
| 1165 | + $old = $this->get_tax_meta($term_id, $name, !$field['multiple']); | |
| 1166 | + $new = (isset($_POST[$name])) ? $_POST[$name] : (($field['multiple']) ? array() : ''); | |
| 1167 | + | |
| 1168 | + // Validate meta value | |
| 1169 | +				if (class_exists('Tax_Meta_Validate') && method_exists('Tax_Meta_Validate', $field['validate_func'])) { | |
| 1170 | +					$new = call_user_func(array('Tax_Meta_Validate', $field['validate_func']), $new); | |
| 1171 | + } | |
| 1172 | + | |
| 1173 | + | |
| 1174 | +				if ($name == 'ct_cat_icon') { | |
| 1175 | + | |
| 1176 | + $upload_dir = wp_upload_dir(); | |
| 1177 | + | |
| 1178 | +					$image_name_arr = explode('/', $new['src']); | |
| 1179 | + //$old_filename = end($image_name_arr); | |
| 1180 | +					//$img_name_arr = explode('.',$old_filename); | |
| 1181 | + | |
| 1182 | + //$old_filename = $upload_dir['path'].'/'.$old_filename; | |
| 1183 | + | |
| 1184 | + $new_filename = $upload_dir['path'] . '/' . 'cat_icon_' . $term_id . '.png'; | |
| 1185 | + | |
| 1186 | + /*rename($old_filename, $new_filename); | |
| 1187 | 1187 | |
| 1188 | 1188 | //subdir | 
| 1189 | 1189 | $new['src'] = $upload_dir['url'].'/'.'cat_icon_'.$term_id.'.png'; | 
| @@ -1191,7 +1191,7 @@ discard block | ||
| 1191 | 1191 | update_attached_file( $new['id'], $new['src'] );*/ | 
| 1192 | 1192 | |
| 1193 | 1193 | |
| 1194 | - /* | |
| 1194 | + /* | |
| 1195 | 1195 | |
| 1196 | 1196 | $new['src'] = $upload_dir['url'].'/'.'cat_icon_'.$term_id.'.png'; | 
| 1197 | 1197 | |
| @@ -1216,67 +1216,67 @@ discard block | ||
| 1216 | 1216 | $attach_id = wp_insert_attachment( $attachment, $filename);*/ | 
| 1217 | 1217 | |
| 1218 | 1218 | |
| 1219 | - } | |
| 1220 | - | |
| 1221 | - | |
| 1222 | - //skip on Paragraph field | |
| 1223 | -                if ($type != "paragraph") { | |
| 1224 | - | |
| 1225 | - // Call defined method to save meta value, if there's no methods, call common one. | |
| 1226 | - $save_func = 'save_field_' . $type; | |
| 1227 | -                    if (method_exists($this, $save_func)) { | |
| 1228 | - call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new); | |
| 1229 | -                    } else { | |
| 1230 | - $this->save_field($term_id, $field, $old, $new); | |
| 1231 | - } | |
| 1232 | - } | |
| 1233 | - | |
| 1234 | - } // End foreach | |
| 1235 | - | |
| 1236 | - } | |
| 1237 | - | |
| 1238 | - /** | |
| 1239 | - * Common function for saving fields. | |
| 1240 | - * | |
| 1241 | - * @param string $term_id The term ID. | |
| 1242 | - * @param string $field | |
| 1243 | - * @param string $old | |
| 1244 | - * @param string|mixed $new | |
| 1245 | - * @since 1.0 | |
| 1246 | - * @access public | |
| 1247 | - */ | |
| 1248 | - public function save_field($term_id, $field, $old, $new) | |
| 1249 | -        { | |
| 1250 | - $name = $field['id']; | |
| 1251 | - $this->delete_tax_meta($term_id, $name); | |
| 1252 | - if ($new === '' || $new === array()) | |
| 1253 | - return; | |
| 1254 | - | |
| 1255 | - $this->update_tax_meta($term_id, $name, $new); | |
| 1256 | - } | |
| 1257 | - | |
| 1258 | - /** | |
| 1259 | - * function for saving image field. | |
| 1260 | - * | |
| 1261 | - * @param string $term_id The term ID. | |
| 1262 | - * @param string $field | |
| 1263 | - * @param string $old | |
| 1264 | - * @param string|mixed $new | |
| 1265 | - * @since 1.0 | |
| 1266 | - * @access public | |
| 1267 | - */ | |
| 1268 | - public function save_field_image($term_id, $field, $old, $new) | |
| 1269 | -        { | |
| 1270 | - $name = $field['id']; | |
| 1271 | - | |
| 1272 | - $this->delete_tax_meta($term_id, $name); | |
| 1273 | - if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') | |
| 1274 | - return; | |
| 1275 | - | |
| 1276 | - $this->update_tax_meta($term_id, $name, $new); | |
| 1277 | - } | |
| 1278 | - | |
| 1279 | - /* | |
| 1219 | + } | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + //skip on Paragraph field | |
| 1223 | +				if ($type != "paragraph") { | |
| 1224 | + | |
| 1225 | + // Call defined method to save meta value, if there's no methods, call common one. | |
| 1226 | + $save_func = 'save_field_' . $type; | |
| 1227 | +					if (method_exists($this, $save_func)) { | |
| 1228 | + call_user_func(array(&$this, 'save_field_' . $type), $term_id, $field, $old, $new); | |
| 1229 | +					} else { | |
| 1230 | + $this->save_field($term_id, $field, $old, $new); | |
| 1231 | + } | |
| 1232 | + } | |
| 1233 | + | |
| 1234 | + } // End foreach | |
| 1235 | + | |
| 1236 | + } | |
| 1237 | + | |
| 1238 | + /** | |
| 1239 | + * Common function for saving fields. | |
| 1240 | + * | |
| 1241 | + * @param string $term_id The term ID. | |
| 1242 | + * @param string $field | |
| 1243 | + * @param string $old | |
| 1244 | + * @param string|mixed $new | |
| 1245 | + * @since 1.0 | |
| 1246 | + * @access public | |
| 1247 | + */ | |
| 1248 | + public function save_field($term_id, $field, $old, $new) | |
| 1249 | +		{ | |
| 1250 | + $name = $field['id']; | |
| 1251 | + $this->delete_tax_meta($term_id, $name); | |
| 1252 | + if ($new === '' || $new === array()) | |
| 1253 | + return; | |
| 1254 | + | |
| 1255 | + $this->update_tax_meta($term_id, $name, $new); | |
| 1256 | + } | |
| 1257 | + | |
| 1258 | + /** | |
| 1259 | + * function for saving image field. | |
| 1260 | + * | |
| 1261 | + * @param string $term_id The term ID. | |
| 1262 | + * @param string $field | |
| 1263 | + * @param string $old | |
| 1264 | + * @param string|mixed $new | |
| 1265 | + * @since 1.0 | |
| 1266 | + * @access public | |
| 1267 | + */ | |
| 1268 | + public function save_field_image($term_id, $field, $old, $new) | |
| 1269 | +		{ | |
| 1270 | + $name = $field['id']; | |
| 1271 | + | |
| 1272 | + $this->delete_tax_meta($term_id, $name); | |
| 1273 | + if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') | |
| 1274 | + return; | |
| 1275 | + | |
| 1276 | + $this->update_tax_meta($term_id, $name, $new); | |
| 1277 | + } | |
| 1278 | + | |
| 1279 | + /* | |
| 1280 | 1280 | * Save Wysiwyg Field. | 
| 1281 | 1281 | * | 
| 1282 | 1282 | * @param string $term_id The term ID. | 
| @@ -1286,806 +1286,806 @@ discard block | ||
| 1286 | 1286 | * @since 1.0 | 
| 1287 | 1287 | * @access public | 
| 1288 | 1288 | */ | 
| 1289 | - public function save_field_wysiwyg($term_id, $field, $old, $new) | |
| 1290 | -        { | |
| 1291 | - $this->save_field($term_id, $field, $old, $new); | |
| 1292 | - } | |
| 1293 | - | |
| 1294 | - /** | |
| 1295 | - * Save repeater Fields. | |
| 1296 | - * | |
| 1297 | - * @param string $term_id The term ID. | |
| 1298 | - * @param string $field | |
| 1299 | - * @param string|mixed $old | |
| 1300 | - * @param string|mixed $new | |
| 1301 | - * @since 1.0 | |
| 1302 | - * @access public | |
| 1303 | - */ | |
| 1304 | - public function save_field_repeater($term_id, $field, $old, $new) | |
| 1305 | -        { | |
| 1306 | -            if (is_array($new) && count($new) > 0) { | |
| 1307 | -                foreach ($new as $n) { | |
| 1308 | -                    foreach ($field['fields'] as $f) { | |
| 1309 | - $type = $f['type']; | |
| 1310 | -                        switch ($type) { | |
| 1311 | - case 'wysiwyg': | |
| 1312 | - $n[$f['id']] = wpautop($n[$f['id']]); | |
| 1313 | - break; | |
| 1314 | - case 'file': | |
| 1315 | - $n[$f['id']] = $this->save_field_file_repeater($term_id, $f, '', $n[$f['id']]); | |
| 1316 | - break; | |
| 1317 | - default: | |
| 1318 | - break; | |
| 1319 | - } | |
| 1320 | - } | |
| 1321 | - if (!$this->is_array_empty($n)) | |
| 1322 | - $temp[] = $n; | |
| 1323 | - } | |
| 1324 | -                if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) { | |
| 1325 | - $this->update_tax_meta($term_id, $field['id'], $temp); | |
| 1326 | -                } else { | |
| 1327 | - // remove old meta if exists | |
| 1328 | - delete_post_meta($term_id, $field['id']); | |
| 1329 | - } | |
| 1330 | -            } else { | |
| 1331 | - // remove old meta if exists | |
| 1332 | - delete_post_meta($term_id, $field['id']); | |
| 1333 | - } | |
| 1334 | - } | |
| 1335 | - | |
| 1336 | - /** | |
| 1337 | - * Save File Field. | |
| 1338 | - * | |
| 1339 | - * @param string $term_id The term ID. | |
| 1340 | - * @param string $field | |
| 1341 | - * @param string $old | |
| 1342 | - * @param string $new | |
| 1343 | - * @since 1.0 | |
| 1344 | - * @access public | |
| 1345 | - */ | |
| 1346 | - public function save_field_file($term_id, $field, $old, $new) | |
| 1347 | -        { | |
| 1348 | - | |
| 1349 | - $name = $field['id']; | |
| 1350 | - if (empty($_FILES[$name])) | |
| 1351 | - return; | |
| 1352 | - $this->fix_file_array($_FILES[$name]); | |
| 1353 | -            foreach ($_FILES[$name] as $position => $fileitem) { | |
| 1354 | - | |
| 1355 | -                $file = wp_handle_upload($fileitem, array('test_form' => false)); | |
| 1356 | - if (empty($file['file'])) | |
| 1357 | - continue; | |
| 1358 | - $filename = $file['file']; | |
| 1359 | - | |
| 1360 | - $attachment = array( | |
| 1361 | - 'post_mime_type' => $file['type'], | |
| 1362 | - 'guid' => $file['url'], | |
| 1363 | - 'post_parent' => $term_id, | |
| 1364 | -                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), | |
| 1365 | - 'post_content' => '' | |
| 1366 | - ); | |
| 1367 | - | |
| 1368 | - $id = wp_insert_attachment($attachment, $filename, $term_id); | |
| 1369 | - | |
| 1370 | -                if (!is_wp_error($id)) { | |
| 1371 | - | |
| 1372 | - wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); | |
| 1373 | - add_post_meta($term_id, $name, $id, false); // save file's url in meta fields | |
| 1374 | - | |
| 1375 | - } // End if | |
| 1376 | - | |
| 1377 | - } // End foreach | |
| 1378 | - | |
| 1379 | - } | |
| 1380 | - | |
| 1381 | - /** | |
| 1382 | - * Save repeater File Field. | |
| 1383 | - * @param string $term_id The term ID. | |
| 1384 | - * @param string $field | |
| 1385 | - * @param string $old | |
| 1386 | - * @param string $new | |
| 1387 | - * @since 1.0 | |
| 1388 | - * @access public | |
| 1389 | - * @return int|void | |
| 1390 | - */ | |
| 1391 | - public function save_field_file_repeater($term_id, $field, $old, $new) | |
| 1392 | -        { | |
| 1393 | - | |
| 1394 | - $name = $field['id']; | |
| 1395 | - if (empty($_FILES[$name])) | |
| 1396 | - return; | |
| 1397 | - $this->fix_file_array($_FILES[$name]); | |
| 1398 | -            foreach ($_FILES[$name] as $position => $fileitem) { | |
| 1399 | - | |
| 1400 | -                $file = wp_handle_upload($fileitem, array('test_form' => false)); | |
| 1401 | - if (empty($file['file'])) | |
| 1402 | - continue; | |
| 1403 | - $filename = $file['file']; | |
| 1404 | - | |
| 1405 | - $attachment = array( | |
| 1406 | - 'post_mime_type' => $file['type'], | |
| 1407 | - 'guid' => $file['url'], | |
| 1408 | - 'post_parent' => $term_id, | |
| 1409 | -                    'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), | |
| 1410 | - 'post_content' => '' | |
| 1411 | - ); | |
| 1412 | - | |
| 1413 | - $id = wp_insert_attachment($attachment, $filename); | |
| 1414 | - | |
| 1415 | -                if (!is_wp_error($id)) { | |
| 1416 | - | |
| 1417 | - wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); | |
| 1418 | - return $id; // return file's url in meta fields | |
| 1419 | - } // End if | |
| 1420 | - } // End foreach | |
| 1421 | - } | |
| 1422 | - | |
| 1423 | - /** | |
| 1424 | - * Add missed values for meta box. | |
| 1425 | - * | |
| 1426 | - * @since 1.0 | |
| 1427 | - * @access public | |
| 1428 | - */ | |
| 1429 | - public function add_missed_values() | |
| 1430 | -        { | |
| 1431 | - | |
| 1432 | - // Default values for meta box | |
| 1433 | -            $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box); | |
| 1434 | - | |
| 1435 | -            if(is_array($this->_fields)) { | |
| 1436 | - // Default values for fields | |
| 1437 | -                foreach ($this->_fields as &$field) { | |
| 1438 | -                    $multiple = in_array($field['type'], array('checkbox_list', 'file', 'image')); | |
| 1439 | - $std = $multiple ? array() : ''; | |
| 1440 | -                    $format = 'date' == $field['type'] ? 'yy-mm-dd' : ('time' == $field['type'] ? 'hh:mm' : ''); | |
| 1441 | -                    $field = array_merge(array('multiple' => $multiple, 'std' => $std, 'desc' => '', 'format' => $format, 'validate_func' => ''), $field); | |
| 1442 | - } // End foreach | |
| 1443 | - } | |
| 1444 | - } | |
| 1445 | - | |
| 1446 | - /** | |
| 1447 | - * Check if field with $type exists. | |
| 1448 | - * | |
| 1449 | - * @param string $type | |
| 1450 | - * @since 1.0 | |
| 1451 | - * @access public | |
| 1452 | - */ | |
| 1453 | - public function has_field($type) | |
| 1454 | -        { | |
| 1455 | -            if(is_array($this->_fields)) { | |
| 1456 | -                foreach ($this->_fields as $field) { | |
| 1457 | - if ($type == $field['type']) | |
| 1458 | - return true; | |
| 1459 | - } | |
| 1460 | - } | |
| 1461 | - return false; | |
| 1462 | - } | |
| 1463 | - | |
| 1464 | - /** | |
| 1465 | - * Check if current page is edit page. | |
| 1466 | - * | |
| 1467 | - * @since 1.0 | |
| 1468 | - * @access public | |
| 1469 | - */ | |
| 1470 | - public function is_edit_page() | |
| 1471 | -        { | |
| 1472 | - global $pagenow; | |
| 1473 | - return ($pagenow == 'edit-tags.php' || $pagenow == 'term.php'); | |
| 1474 | - } | |
| 1475 | - | |
| 1476 | - /** | |
| 1477 | - * Fixes the odd indexing of multiple file uploads. | |
| 1478 | - * | |
| 1479 | - * Goes from the format: | |
| 1480 | - * $_FILES['field']['key']['index'] | |
| 1481 | - * to | |
| 1482 | - * The More standard and appropriate: | |
| 1483 | - * $_FILES['field']['index']['key'] | |
| 1484 | - * | |
| 1485 | - * @param string $files | |
| 1486 | - * @since 1.0 | |
| 1487 | - * @access public | |
| 1488 | - */ | |
| 1489 | - public function fix_file_array(&$files) | |
| 1490 | -        { | |
| 1491 | - | |
| 1492 | - $output = array(); | |
| 1493 | - | |
| 1494 | -            foreach ($files as $key => $list) { | |
| 1495 | -                foreach ($list as $index => $value) { | |
| 1496 | - $output[$index][$key] = $value; | |
| 1497 | - } | |
| 1498 | - } | |
| 1499 | - | |
| 1500 | - return $files = $output; | |
| 1501 | - | |
| 1502 | - } | |
| 1503 | - | |
| 1504 | - /** | |
| 1505 | - * Get proper JQuery UI version. | |
| 1506 | - * | |
| 1507 | - * Used in order to not conflict with WP Admin Scripts. | |
| 1508 | - * | |
| 1509 | - * @since 1.0 | |
| 1510 | - * @access public | |
| 1511 | - */ | |
| 1512 | - public function get_jqueryui_ver() | |
| 1513 | -        { | |
| 1514 | - | |
| 1515 | - global $wp_version; | |
| 1516 | - | |
| 1517 | -            if (version_compare($wp_version, '3.1', '>=')) { | |
| 1518 | - return '1.8.10'; | |
| 1519 | - } | |
| 1520 | - | |
| 1521 | - return '1.7.3'; | |
| 1522 | - | |
| 1523 | - } | |
| 1524 | - | |
| 1525 | - /** | |
| 1526 | - * Add Field to meta box (generic function) | |
| 1527 | - * @author Ohad Raz | |
| 1528 | - * @since 1.0 | |
| 1529 | - * @access public | |
| 1530 | - * @param $id string field id, i.e. the meta key | |
| 1531 | - * @param $args mixed|array | |
| 1532 | - */ | |
| 1533 | - public function addField($id, $args) | |
| 1534 | -        { | |
| 1535 | -            $new_field = array('id' => $id, 'std' => '', 'desc' => '', 'style' => ''); | |
| 1536 | - $new_field = array_merge($new_field, $args); | |
| 1537 | - $this->_fields[] = $new_field; | |
| 1538 | - } | |
| 1539 | - | |
| 1540 | - | |
| 1541 | - /** | |
| 1542 | - * Add Text Field to meta box | |
| 1543 | - * @author Ohad Raz | |
| 1544 | - * @since 1.0 | |
| 1545 | - * @access public | |
| 1546 | - * @param $id string field id, i.e. the meta key | |
| 1547 | - * @param $args mixed|array | |
| 1548 | - * 'name' => // field name/label string optional | |
| 1549 | - * 'desc' => // field description, string optional | |
| 1550 | - * 'std' => // default value, string optional | |
| 1551 | - * 'style' => // custom style for field, string optional | |
| 1552 | - * 'validate_func' => // validate function, string optional | |
| 1553 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1554 | - */ | |
| 1555 | - public function addText($id, $args, $repeater = false) | |
| 1556 | -        { | |
| 1557 | -            $new_field = array('type' => 'text', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory')); | |
| 1558 | - $new_field = array_merge($new_field, $args); | |
| 1559 | -            if (false === $repeater) { | |
| 1560 | - $this->_fields[] = $new_field; | |
| 1561 | -            } else { | |
| 1562 | - return $new_field; | |
| 1563 | - } | |
| 1564 | - } | |
| 1565 | - | |
| 1566 | - /** | |
| 1567 | - * Add Hidden Field to meta box | |
| 1568 | - * @author Ohad Raz | |
| 1569 | - * @since 0.1.3 | |
| 1570 | - * @access public | |
| 1571 | - * @param $id string field id, i.e. the meta key | |
| 1572 | - * @param $args mixed|array | |
| 1573 | - * 'name' => // field name/label string optional | |
| 1574 | - * 'desc' => // field description, string optional | |
| 1575 | - * 'std' => // default value, string optional | |
| 1576 | - * 'style' => // custom style for field, string optional | |
| 1577 | - * 'validate_func' => // validate function, string optional | |
| 1578 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1579 | - */ | |
| 1580 | - public function addHidden($id, $args, $repeater = false) | |
| 1581 | -        { | |
| 1582 | -            $new_field = array('type' => 'hidden', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory')); | |
| 1583 | - $new_field = array_merge($new_field, $args); | |
| 1584 | -            if (false === $repeater) { | |
| 1585 | - $this->_fields[] = $new_field; | |
| 1586 | -            } else { | |
| 1587 | - return $new_field; | |
| 1588 | - } | |
| 1589 | - } | |
| 1590 | - | |
| 1591 | - /** | |
| 1592 | - * Add Paragraph to meta box | |
| 1593 | - * @author Ohad Raz | |
| 1594 | - * @since 0.1.3 | |
| 1595 | - * @access public | |
| 1596 | - * @param $id string field id, i.e. the meta key | |
| 1597 | - * @param $value paragraph html | |
| 1598 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1599 | - */ | |
| 1600 | - public function addParagraph($id, $args, $repeater = false) | |
| 1601 | -        { | |
| 1602 | -            $new_field = array('type' => 'paragraph', 'id' => $id, 'value' => '', 'style' => ''); | |
| 1603 | - $new_field = array_merge($new_field, $args); | |
| 1604 | -            if (false === $repeater) { | |
| 1605 | - $this->_fields[] = $new_field; | |
| 1606 | -            } else { | |
| 1607 | - return $new_field; | |
| 1608 | - } | |
| 1609 | - } | |
| 1610 | - | |
| 1611 | - /** | |
| 1612 | - * Add Checkbox Field to meta box | |
| 1613 | - * @author Ohad Raz | |
| 1614 | - * @since 1.0 | |
| 1615 | - * @access public | |
| 1616 | - * @param $id string field id, i.e. the meta key | |
| 1617 | - * @param $args mixed|array | |
| 1618 | - * 'name' => // field name/label string optional | |
| 1619 | - * 'desc' => // field description, string optional | |
| 1620 | - * 'std' => // default value, string optional | |
| 1621 | - * 'validate_func' => // validate function, string optional | |
| 1622 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1623 | - */ | |
| 1624 | - public function addCheckbox($id, $args, $repeater = false) | |
| 1625 | -        { | |
| 1626 | -            $new_field = array('type' => 'checkbox', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox Field', 'geodirectory')); | |
| 1627 | - $new_field = array_merge($new_field, $args); | |
| 1628 | -            if (false === $repeater) { | |
| 1629 | - $this->_fields[] = $new_field; | |
| 1630 | -            } else { | |
| 1631 | - return $new_field; | |
| 1632 | - } | |
| 1633 | - } | |
| 1634 | - | |
| 1635 | - /** | |
| 1636 | - * Add CheckboxList Field to meta box | |
| 1637 | - * @author Ohad Raz | |
| 1638 | - * @since 1.0 | |
| 1639 | - * @access public | |
| 1640 | - * @param $id string field id, i.e. the meta key | |
| 1641 | - * @param $options (array) array of key => value pairs for select options | |
| 1642 | - * @param $args mixed|array | |
| 1643 | - * 'name' => // field name/label string optional | |
| 1644 | - * 'desc' => // field description, string optional | |
| 1645 | - * 'std' => // default value, string optional | |
| 1646 | - * 'validate_func' => // validate function, string optional | |
| 1647 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1648 | - * | |
| 1649 | - * @return : remember to call: $checkbox_list = $this->get_tax_meta(get_the_ID(), 'meta_name', false); | |
| 1650 | - * which means the last param as false to get the values in an array | |
| 1651 | - */ | |
| 1652 | - public function addCheckboxList($id, $options, $args, $repeater = false) | |
| 1653 | -        { | |
| 1654 | -            $new_field = array('type' => 'checkbox_list', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox List Field', 'geodirectory')); | |
| 1655 | - $new_field = array_merge($new_field, $args); | |
| 1656 | -            if (false === $repeater) { | |
| 1657 | - $this->_fields[] = $new_field; | |
| 1658 | -            } else { | |
| 1659 | - return $new_field; | |
| 1660 | - } | |
| 1661 | - } | |
| 1662 | - | |
| 1663 | - /** | |
| 1664 | - * Add Textarea Field to meta box | |
| 1665 | - * @author Ohad Raz | |
| 1666 | - * @since 1.0 | |
| 1667 | - * @access public | |
| 1668 | - * @param $id string field id, i.e. the meta key | |
| 1669 | - * @param $args mixed|array | |
| 1670 | - * 'name' => // field name/label string optional | |
| 1671 | - * 'desc' => // field description, string optional | |
| 1672 | - * 'std' => // default value, string optional | |
| 1673 | - * 'style' => // custom style for field, string optional | |
| 1674 | - * 'validate_func' => // validate function, string optional | |
| 1675 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1676 | - */ | |
| 1677 | - public function addTextarea($id, $args, $repeater = false) | |
| 1678 | -        { | |
| 1679 | -            $new_field = array('type' => 'textarea', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Textarea Field', 'geodirectory')); | |
| 1680 | - $new_field = array_merge($new_field, $args); | |
| 1681 | -            if (false === $repeater) { | |
| 1682 | - $this->_fields[] = $new_field; | |
| 1683 | -            } else { | |
| 1684 | - return $new_field; | |
| 1685 | - } | |
| 1686 | - } | |
| 1687 | - | |
| 1688 | - /** | |
| 1689 | - * Add Select Field to meta box | |
| 1690 | - * @author Ohad Raz | |
| 1691 | - * @since 1.0 | |
| 1692 | - * @access public | |
| 1693 | - * @param $id string field id, i.e. the meta key | |
| 1694 | - * @param $options (array) array of key => value pairs for select options | |
| 1695 | - * @param $args mixed|array | |
| 1696 | - * 'name' => // field name/label string optional | |
| 1697 | - * 'desc' => // field description, string optional | |
| 1698 | - * 'std' => // default value, (array) optional | |
| 1699 | - * 'multiple' => // select multiple values, optional. Default is false. | |
| 1700 | - * 'validate_func' => // validate function, string optional | |
| 1701 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1702 | - */ | |
| 1703 | - public function addSelect($id, $options, $args, $repeater = false) | |
| 1704 | -        { | |
| 1705 | -            $new_field = array('type' => 'select', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Select Field', 'geodirectory'), 'multiple' => false, 'options' => $options); | |
| 1706 | - $new_field = array_merge($new_field, $args); | |
| 1707 | -            if (false === $repeater) { | |
| 1708 | - $this->_fields[] = $new_field; | |
| 1709 | -            } else { | |
| 1710 | - return $new_field; | |
| 1711 | - } | |
| 1712 | - } | |
| 1713 | - | |
| 1714 | - | |
| 1715 | - /** | |
| 1716 | - * Add Radio Field to meta box | |
| 1717 | - * @author Ohad Raz | |
| 1718 | - * @since 1.0 | |
| 1719 | - * @access public | |
| 1720 | - * @param $id string field id, i.e. the meta key | |
| 1721 | - * @param $options (array) array of key => value pairs for radio options | |
| 1722 | - * @param $args mixed|array | |
| 1723 | - * 'name' => // field name/label string optional | |
| 1724 | - * 'desc' => // field description, string optional | |
| 1725 | - * 'std' => // default value, string optional | |
| 1726 | - * 'validate_func' => // validate function, string optional | |
| 1727 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1728 | - */ | |
| 1729 | - public function addRadio($id, $options, $args, $repeater = false) | |
| 1730 | -        { | |
| 1731 | -            $new_field = array('type' => 'radio', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Radio Field', 'geodirectory'), 'options' => $options); | |
| 1732 | - $new_field = array_merge($new_field, $args); | |
| 1733 | -            if (false === $repeater) { | |
| 1734 | - $this->_fields[] = $new_field; | |
| 1735 | -            } else { | |
| 1736 | - return $new_field; | |
| 1737 | - } | |
| 1738 | - } | |
| 1739 | - | |
| 1740 | - /** | |
| 1741 | - * Add Date Field to meta box | |
| 1742 | - * @author Ohad Raz | |
| 1743 | - * @since 1.0 | |
| 1744 | - * @access public | |
| 1745 | - * @param $id string field id, i.e. the meta key | |
| 1746 | - * @param $args mixed|array | |
| 1747 | - * 'name' => // field name/label string optional | |
| 1748 | - * 'desc' => // field description, string optional | |
| 1749 | - * 'std' => // default value, string optional | |
| 1750 | - * 'validate_func' => // validate function, string optional | |
| 1751 | - * 'format' => // date format, default yy-mm-dd. Optional. Default "'d MM, yy'" See more formats here: http://goo.gl/Wcwxn | |
| 1752 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1753 | - */ | |
| 1754 | - public function addDate($id, $args, $repeater = false) | |
| 1755 | -        { | |
| 1756 | -            $new_field = array('type' => 'date', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'yy-mm-dd', 'name' => __('Date Field', 'geodirectory')); | |
| 1757 | - $new_field = array_merge($new_field, $args); | |
| 1758 | -            if (false === $repeater) { | |
| 1759 | - $this->_fields[] = $new_field; | |
| 1760 | -            } else { | |
| 1761 | - return $new_field; | |
| 1762 | - } | |
| 1763 | - } | |
| 1764 | - | |
| 1765 | - /** | |
| 1766 | - * Add Time Field to meta box | |
| 1767 | - * @author Ohad Raz | |
| 1768 | - * @since 1.0 | |
| 1769 | - * @access public | |
| 1770 | - * @param $id string- field id, i.e. the meta key | |
| 1771 | - * @param $args mixed|array | |
| 1772 | - * 'name' => // field name/label string optional | |
| 1773 | - * 'desc' => // field description, string optional | |
| 1774 | - * 'std' => // default value, string optional | |
| 1775 | - * 'validate_func' => // validate function, string optional | |
| 1776 | - * 'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX | |
| 1777 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1778 | - */ | |
| 1779 | - public function addTime($id, $args, $repeater = false) | |
| 1780 | -        { | |
| 1781 | -            $new_field = array('type' => 'time', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'hh:mm', 'name' => __('Time Field', 'geodirectory')); | |
| 1782 | - $new_field = array_merge($new_field, $args); | |
| 1783 | -            if (false === $repeater) { | |
| 1784 | - $this->_fields[] = $new_field; | |
| 1785 | -            } else { | |
| 1786 | - return $new_field; | |
| 1787 | - } | |
| 1788 | - } | |
| 1789 | - | |
| 1790 | - /** | |
| 1791 | - * Add Color Field to meta box | |
| 1792 | - * @author Ohad Raz | |
| 1793 | - * @since 1.0 | |
| 1794 | - * @access public | |
| 1795 | - * @param $id string field id, i.e. the meta key | |
| 1796 | - * @param $args mixed|array | |
| 1797 | - * 'name' => // field name/label string optional | |
| 1798 | - * 'desc' => // field description, string optional | |
| 1799 | - * 'std' => // default value, string optional | |
| 1800 | - * 'validate_func' => // validate function, string optional | |
| 1801 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1802 | - */ | |
| 1803 | - public function addColor($id, $args, $repeater = false) | |
| 1804 | -        { | |
| 1805 | -            $new_field = array('type' => 'color', 'id' => $id, 'std' => '', 'desc' => '', 'name' => __('ColorPicker Field', 'geodirectory')); | |
| 1806 | - $new_field = array_merge($new_field, $args); | |
| 1807 | -            if (false === $repeater) { | |
| 1808 | - $this->_fields[] = $new_field; | |
| 1809 | -            } else { | |
| 1810 | - return $new_field; | |
| 1811 | - } | |
| 1812 | - } | |
| 1813 | - | |
| 1814 | - /** | |
| 1815 | - * Add Image Field to meta box | |
| 1816 | - * @author Ohad Raz | |
| 1817 | - * @since 1.0 | |
| 1818 | - * @access public | |
| 1819 | - * @param $id string field id, i.e. the meta key | |
| 1820 | - * @param $args mixed|array | |
| 1821 | - * 'name' => // field name/label string optional | |
| 1822 | - * 'desc' => // field description, string optional | |
| 1823 | - * 'validate_func' => // validate function, string optional | |
| 1824 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1825 | - */ | |
| 1826 | - public function addImage($id, $args, $repeater = false) | |
| 1827 | -        { | |
| 1828 | -            $new_field = array('type' => 'image', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('Image Field', 'geodirectory')); | |
| 1829 | - $new_field = array_merge($new_field, $args); | |
| 1830 | - | |
| 1831 | -            if (false === $repeater) { | |
| 1832 | - $this->_fields[] = $new_field; | |
| 1833 | -            } else { | |
| 1834 | - return $new_field; | |
| 1835 | - } | |
| 1836 | - } | |
| 1837 | - | |
| 1838 | - /** | |
| 1839 | - * Add File Field to meta box | |
| 1840 | - * @author Ohad Raz | |
| 1841 | - * @since 1.0 | |
| 1842 | - * @access public | |
| 1843 | - * @param $id string field id, i.e. the meta key | |
| 1844 | - * @param $args mixed|array | |
| 1845 | - * 'name' => // field name/label string optional | |
| 1846 | - * 'desc' => // field description, string optional | |
| 1847 | - * 'validate_func' => // validate function, string optional | |
| 1848 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1849 | - */ | |
| 1850 | - public function addFile($id, $args, $repeater = false) | |
| 1851 | -        { | |
| 1852 | -            $new_field = array('type' => 'file', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('File Field', 'geodirectory')); | |
| 1853 | - $new_field = array_merge($new_field, $args); | |
| 1854 | -            if (false === $repeater) { | |
| 1855 | - $this->_fields[] = $new_field; | |
| 1856 | -            } else { | |
| 1857 | - return $new_field; | |
| 1858 | - } | |
| 1859 | - } | |
| 1860 | - | |
| 1861 | - /** | |
| 1862 | - * Add WYSIWYG Field to meta box | |
| 1863 | - * @author Ohad Raz | |
| 1864 | - * @since 1.0 | |
| 1865 | - * @access public | |
| 1866 | - * @param $id string field id, i.e. the meta key | |
| 1867 | - * @param $args mixed|array | |
| 1868 | - * 'name' => // field name/label string optional | |
| 1869 | - * 'desc' => // field description, string optional | |
| 1870 | - * 'std' => // default value, string optional | |
| 1871 | - * 'style' => // custom style for field, string optional Default 'width: 300px; height: 400px' | |
| 1872 | - * 'validate_func' => // validate function, string optional | |
| 1873 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1874 | - */ | |
| 1875 | - public function addWysiwyg($id, $args, $repeater = false) | |
| 1876 | -        { | |
| 1877 | -            $new_field = array('type' => 'wysiwyg', 'id' => $id, 'std' => '', 'desc' => '', 'style' => 'width: 300px; height: 400px', 'name' => __('WYSIWYG Editor Field', 'geodirectory')); | |
| 1878 | - $new_field = array_merge($new_field, $args); | |
| 1879 | -            if (false === $repeater) { | |
| 1880 | - $this->_fields[] = $new_field; | |
| 1881 | -            } else { | |
| 1882 | - return $new_field; | |
| 1883 | - } | |
| 1884 | - } | |
| 1885 | - | |
| 1886 | - /** | |
| 1887 | - * Add Taxonomy Field to meta box | |
| 1888 | - * @author Ohad Raz | |
| 1889 | - * @since 1.0 | |
| 1890 | - * @access public | |
| 1891 | - * @param $id string field id, i.e. the meta key | |
| 1892 | - * @param $options mixed|array options of taxonomy field | |
| 1893 | - * 'taxonomy' => // taxonomy name can be category,post_tag or any custom taxonomy default is category | |
| 1894 | - * 'type' => // how to show taxonomy? 'select' (default) or 'checkbox_list' | |
| 1895 | -         * 'args' =>  // arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false) | |
| 1896 | - * @param $args mixed|array | |
| 1897 | - * 'name' => // field name/label string optional | |
| 1898 | - * 'desc' => // field description, string optional | |
| 1899 | - * 'std' => // default value, string optional | |
| 1900 | - * 'validate_func' => // validate function, string optional | |
| 1901 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1902 | - */ | |
| 1903 | - public function addTaxonomy($id, $options, $args, $repeater = false) | |
| 1904 | -        { | |
| 1905 | -            $q = array('hide_empty' => 0); | |
| 1906 | - $tax = 'category'; | |
| 1907 | - $type = 'select'; | |
| 1908 | - $temp = array($tax, $type, $q); | |
| 1909 | - $options = array_merge($temp, $options); | |
| 1910 | -            $new_field = array('type' => 'taxonomy', 'id' => $id, 'desc' => '', 'name' => __('Taxonomy Field', 'geodirectory'), 'options' => $options); | |
| 1911 | - $new_field = array_merge($new_field, $args); | |
| 1912 | -            if (false === $repeater) { | |
| 1913 | - $this->_fields[] = $new_field; | |
| 1914 | -            } else { | |
| 1915 | - return $new_field; | |
| 1916 | - } | |
| 1917 | - } | |
| 1918 | - | |
| 1919 | - /** | |
| 1920 | - * Add posts Field to meta box | |
| 1921 | - * @author Ohad Raz | |
| 1922 | - * @since 1.0 | |
| 1923 | - * @access public | |
| 1924 | - * @param $id string field id, i.e. the meta key | |
| 1925 | - * @param $options mixed|array options of taxonomy field | |
| 1926 | - * 'post_type' => // post type name, 'post' (default) 'page' or any custom post type | |
| 1927 | - * 'type' => // how to show posts? 'select' (default) or 'checkbox_list' | |
| 1928 | -         * 'args' =>  // arguments to query posts, see http://goo.gl/is0yK default ('posts_per_page' => -1) | |
| 1929 | - * @param $args mixed|array | |
| 1930 | - * 'name' => // field name/label string optional | |
| 1931 | - * 'desc' => // field description, string optional | |
| 1932 | - * 'std' => // default value, string optional | |
| 1933 | - * 'validate_func' => // validate function, string optional | |
| 1934 | - * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1935 | - */ | |
| 1936 | - public function addPosts($id, $options, $args, $repeater = false) | |
| 1937 | -        { | |
| 1938 | -            $q = array('posts_per_page' => -1); | |
| 1939 | -            $temp = array('post_type' => 'post', 'type' => 'select', 'args' => $q); | |
| 1940 | - $options = array_merge($temp, $options); | |
| 1941 | -            $new_field = array('type' => 'posts', 'id' => $id, 'desc' => '', 'name' => __('Posts Field', 'geodirectory'), 'options' => $options); | |
| 1942 | - $new_field = array_merge($new_field, $args); | |
| 1943 | -            if (false === $repeater) { | |
| 1944 | - $this->_fields[] = $new_field; | |
| 1945 | -            } else { | |
| 1946 | - return $new_field; | |
| 1947 | - } | |
| 1948 | - } | |
| 1949 | - | |
| 1950 | - /** | |
| 1951 | - * Add repeater Field Block to meta box | |
| 1952 | - * @author Ohad Raz | |
| 1953 | - * @since 1.0 | |
| 1954 | - * @access public | |
| 1955 | - * @param $id string field id, i.e. the meta key | |
| 1956 | - * @param $args mixed|array | |
| 1957 | - * 'name' => // field name/label string optional | |
| 1958 | - * 'desc' => // field description, string optional | |
| 1959 | - * 'std' => // default value, string optional | |
| 1960 | - * 'style' => // custom style for field, string optional | |
| 1961 | - * 'validate_func' => // validate function, string optional | |
| 1962 | - * 'fields' => //fields to repeater | |
| 1963 | - */ | |
| 1964 | - public function addRepeaterBlock($id, $args) | |
| 1965 | -        { | |
| 1966 | -            $new_field = array('type' => 'repeater', 'id' => $id, 'name' => __('Reapeater Field', 'geodirectory'), 'fields' => array(), 'inline' => false); | |
| 1967 | - $new_field = array_merge($new_field, $args); | |
| 1968 | - $this->_fields[] = $new_field; | |
| 1969 | - } | |
| 1970 | - | |
| 1971 | - | |
| 1972 | - /** | |
| 1973 | - * Finish Declaration of Meta Box | |
| 1974 | - * @author Ohad Raz | |
| 1975 | - * @since 1.0 | |
| 1976 | - * @access public | |
| 1977 | - */ | |
| 1978 | - public function Finish() | |
| 1979 | -        { | |
| 1980 | - $this->add_missed_values(); | |
| 1981 | - $this->check_field_upload(); | |
| 1982 | - $this->check_field_color(); | |
| 1983 | - $this->check_field_date(); | |
| 1984 | - $this->check_field_time(); | |
| 1985 | - } | |
| 1986 | - | |
| 1987 | - /** | |
| 1988 | - * Helper function to check for empty arrays | |
| 1989 | - * @author Ohad Raz | |
| 1990 | - * @since 1.0 | |
| 1991 | - * @access public | |
| 1992 | - * @param $args mixed|array | |
| 1993 | - */ | |
| 1994 | - public function is_array_empty($array) | |
| 1995 | -        { | |
| 1996 | - if (!is_array($array)) | |
| 1997 | - return true; | |
| 1998 | - | |
| 1999 | -            foreach ($array as $a) { | |
| 2000 | -                if (is_array($a)) { | |
| 2001 | -                    foreach ($a as $sub_a) { | |
| 2002 | - if (!empty($sub_a) && $sub_a != '') | |
| 2003 | - return false; | |
| 2004 | - } | |
| 2005 | -                } else { | |
| 2006 | - if (!empty($a) && $a != '') | |
| 2007 | - return false; | |
| 2008 | - } | |
| 2009 | - } | |
| 2010 | - return true; | |
| 2011 | - } | |
| 2012 | - | |
| 2013 | - | |
| 2014 | - //get term meta field | |
| 2015 | - public function get_tax_meta($term_id, $key, $multi = false, $post_type = '') | |
| 2016 | -        { | |
| 2017 | - | |
| 2018 | -            if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2019 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2020 | - $post_type = $taxObject->object_type[0]; | |
| 2021 | - } | |
| 2022 | - | |
| 2023 | -            if($post_type=='post'){$post_type='';} | |
| 2024 | -            if($post_type){$post_type = $post_type.'_';} | |
| 2025 | - | |
| 2026 | - $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; | |
| 2027 | - | |
| 2028 | -            $m = get_option('tax_meta_' . $post_type  . $t_id); | |
| 2029 | -            if (isset($m[$key])) { | |
| 2030 | - return $m[$key]; | |
| 2031 | -            } else { | |
| 2032 | - return ''; | |
| 2033 | - } | |
| 2034 | - } | |
| 2035 | - | |
| 2036 | - //delete meta | |
| 2037 | - public function delete_tax_meta($term_id, $key, $post_type = '') | |
| 2038 | -        { | |
| 2039 | - | |
| 2040 | -            if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2041 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2042 | - $post_type = $taxObject->object_type[0]; | |
| 2043 | - } | |
| 2044 | - | |
| 2045 | -            if($post_type=='post'){$post_type='';} | |
| 2046 | -            if($post_type){$post_type = $post_type.'_';} | |
| 2047 | - | |
| 2048 | -            $m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2049 | - | |
| 2050 | -            if (isset($m[$key])) { | |
| 2051 | - unset($m[$key]); | |
| 2052 | - } | |
| 2053 | -            update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2054 | - } | |
| 2055 | - | |
| 2056 | - //update meta | |
| 2057 | - public function update_tax_meta($term_id, $key, $value, $post_type = '') | |
| 2058 | -        { | |
| 2059 | - | |
| 2060 | -            if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2061 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2062 | - $post_type = $taxObject->object_type[0]; | |
| 2063 | - } | |
| 2064 | - | |
| 2065 | -            if($post_type=='post'){$post_type='';} | |
| 2066 | -            if($post_type){$post_type = $post_type.'_';} | |
| 2067 | - | |
| 2068 | -            $m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2069 | - | |
| 2070 | - $m[$key] = $value; | |
| 2071 | -            update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2072 | - | |
| 2073 | - /** | |
| 2074 | - * Called after the tax meta is updated. | |
| 2075 | - * | |
| 2076 | - * Used to update things after a GD category is saved. | |
| 2077 | - * | |
| 2078 | - * @since 1.0.0 | |
| 2079 | - * @param bool $false False. | |
| 2080 | - * @param bool $true True. | |
| 2081 | - * @param int $term_id The term id being updated. | |
| 2082 | - * @param string $post_type The post type of the cat being updated. | |
| 2083 | - */ | |
| 2084 | -            do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); | |
| 2085 | - } | |
| 2086 | - | |
| 2087 | - | |
| 2088 | - } // End Class | |
| 1289 | + public function save_field_wysiwyg($term_id, $field, $old, $new) | |
| 1290 | +		{ | |
| 1291 | + $this->save_field($term_id, $field, $old, $new); | |
| 1292 | + } | |
| 1293 | + | |
| 1294 | + /** | |
| 1295 | + * Save repeater Fields. | |
| 1296 | + * | |
| 1297 | + * @param string $term_id The term ID. | |
| 1298 | + * @param string $field | |
| 1299 | + * @param string|mixed $old | |
| 1300 | + * @param string|mixed $new | |
| 1301 | + * @since 1.0 | |
| 1302 | + * @access public | |
| 1303 | + */ | |
| 1304 | + public function save_field_repeater($term_id, $field, $old, $new) | |
| 1305 | +		{ | |
| 1306 | +			if (is_array($new) && count($new) > 0) { | |
| 1307 | +				foreach ($new as $n) { | |
| 1308 | +					foreach ($field['fields'] as $f) { | |
| 1309 | + $type = $f['type']; | |
| 1310 | +						switch ($type) { | |
| 1311 | + case 'wysiwyg': | |
| 1312 | + $n[$f['id']] = wpautop($n[$f['id']]); | |
| 1313 | + break; | |
| 1314 | + case 'file': | |
| 1315 | + $n[$f['id']] = $this->save_field_file_repeater($term_id, $f, '', $n[$f['id']]); | |
| 1316 | + break; | |
| 1317 | + default: | |
| 1318 | + break; | |
| 1319 | + } | |
| 1320 | + } | |
| 1321 | + if (!$this->is_array_empty($n)) | |
| 1322 | + $temp[] = $n; | |
| 1323 | + } | |
| 1324 | +				if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) { | |
| 1325 | + $this->update_tax_meta($term_id, $field['id'], $temp); | |
| 1326 | +				} else { | |
| 1327 | + // remove old meta if exists | |
| 1328 | + delete_post_meta($term_id, $field['id']); | |
| 1329 | + } | |
| 1330 | +			} else { | |
| 1331 | + // remove old meta if exists | |
| 1332 | + delete_post_meta($term_id, $field['id']); | |
| 1333 | + } | |
| 1334 | + } | |
| 1335 | + | |
| 1336 | + /** | |
| 1337 | + * Save File Field. | |
| 1338 | + * | |
| 1339 | + * @param string $term_id The term ID. | |
| 1340 | + * @param string $field | |
| 1341 | + * @param string $old | |
| 1342 | + * @param string $new | |
| 1343 | + * @since 1.0 | |
| 1344 | + * @access public | |
| 1345 | + */ | |
| 1346 | + public function save_field_file($term_id, $field, $old, $new) | |
| 1347 | +		{ | |
| 1348 | + | |
| 1349 | + $name = $field['id']; | |
| 1350 | + if (empty($_FILES[$name])) | |
| 1351 | + return; | |
| 1352 | + $this->fix_file_array($_FILES[$name]); | |
| 1353 | +			foreach ($_FILES[$name] as $position => $fileitem) { | |
| 1354 | + | |
| 1355 | +				$file = wp_handle_upload($fileitem, array('test_form' => false)); | |
| 1356 | + if (empty($file['file'])) | |
| 1357 | + continue; | |
| 1358 | + $filename = $file['file']; | |
| 1359 | + | |
| 1360 | + $attachment = array( | |
| 1361 | + 'post_mime_type' => $file['type'], | |
| 1362 | + 'guid' => $file['url'], | |
| 1363 | + 'post_parent' => $term_id, | |
| 1364 | +					'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), | |
| 1365 | + 'post_content' => '' | |
| 1366 | + ); | |
| 1367 | + | |
| 1368 | + $id = wp_insert_attachment($attachment, $filename, $term_id); | |
| 1369 | + | |
| 1370 | +				if (!is_wp_error($id)) { | |
| 1371 | + | |
| 1372 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); | |
| 1373 | + add_post_meta($term_id, $name, $id, false); // save file's url in meta fields | |
| 1374 | + | |
| 1375 | + } // End if | |
| 1376 | + | |
| 1377 | + } // End foreach | |
| 1378 | + | |
| 1379 | + } | |
| 1380 | + | |
| 1381 | + /** | |
| 1382 | + * Save repeater File Field. | |
| 1383 | + * @param string $term_id The term ID. | |
| 1384 | + * @param string $field | |
| 1385 | + * @param string $old | |
| 1386 | + * @param string $new | |
| 1387 | + * @since 1.0 | |
| 1388 | + * @access public | |
| 1389 | + * @return int|void | |
| 1390 | + */ | |
| 1391 | + public function save_field_file_repeater($term_id, $field, $old, $new) | |
| 1392 | +		{ | |
| 1393 | + | |
| 1394 | + $name = $field['id']; | |
| 1395 | + if (empty($_FILES[$name])) | |
| 1396 | + return; | |
| 1397 | + $this->fix_file_array($_FILES[$name]); | |
| 1398 | +			foreach ($_FILES[$name] as $position => $fileitem) { | |
| 1399 | + | |
| 1400 | +				$file = wp_handle_upload($fileitem, array('test_form' => false)); | |
| 1401 | + if (empty($file['file'])) | |
| 1402 | + continue; | |
| 1403 | + $filename = $file['file']; | |
| 1404 | + | |
| 1405 | + $attachment = array( | |
| 1406 | + 'post_mime_type' => $file['type'], | |
| 1407 | + 'guid' => $file['url'], | |
| 1408 | + 'post_parent' => $term_id, | |
| 1409 | +					'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)), | |
| 1410 | + 'post_content' => '' | |
| 1411 | + ); | |
| 1412 | + | |
| 1413 | + $id = wp_insert_attachment($attachment, $filename); | |
| 1414 | + | |
| 1415 | +				if (!is_wp_error($id)) { | |
| 1416 | + | |
| 1417 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); | |
| 1418 | + return $id; // return file's url in meta fields | |
| 1419 | + } // End if | |
| 1420 | + } // End foreach | |
| 1421 | + } | |
| 1422 | + | |
| 1423 | + /** | |
| 1424 | + * Add missed values for meta box. | |
| 1425 | + * | |
| 1426 | + * @since 1.0 | |
| 1427 | + * @access public | |
| 1428 | + */ | |
| 1429 | + public function add_missed_values() | |
| 1430 | +		{ | |
| 1431 | + | |
| 1432 | + // Default values for meta box | |
| 1433 | +			$this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box); | |
| 1434 | + | |
| 1435 | +			if(is_array($this->_fields)) { | |
| 1436 | + // Default values for fields | |
| 1437 | +				foreach ($this->_fields as &$field) { | |
| 1438 | +					$multiple = in_array($field['type'], array('checkbox_list', 'file', 'image')); | |
| 1439 | + $std = $multiple ? array() : ''; | |
| 1440 | +					$format = 'date' == $field['type'] ? 'yy-mm-dd' : ('time' == $field['type'] ? 'hh:mm' : ''); | |
| 1441 | +					$field = array_merge(array('multiple' => $multiple, 'std' => $std, 'desc' => '', 'format' => $format, 'validate_func' => ''), $field); | |
| 1442 | + } // End foreach | |
| 1443 | + } | |
| 1444 | + } | |
| 1445 | + | |
| 1446 | + /** | |
| 1447 | + * Check if field with $type exists. | |
| 1448 | + * | |
| 1449 | + * @param string $type | |
| 1450 | + * @since 1.0 | |
| 1451 | + * @access public | |
| 1452 | + */ | |
| 1453 | + public function has_field($type) | |
| 1454 | +		{ | |
| 1455 | +			if(is_array($this->_fields)) { | |
| 1456 | +				foreach ($this->_fields as $field) { | |
| 1457 | + if ($type == $field['type']) | |
| 1458 | + return true; | |
| 1459 | + } | |
| 1460 | + } | |
| 1461 | + return false; | |
| 1462 | + } | |
| 1463 | + | |
| 1464 | + /** | |
| 1465 | + * Check if current page is edit page. | |
| 1466 | + * | |
| 1467 | + * @since 1.0 | |
| 1468 | + * @access public | |
| 1469 | + */ | |
| 1470 | + public function is_edit_page() | |
| 1471 | +		{ | |
| 1472 | + global $pagenow; | |
| 1473 | + return ($pagenow == 'edit-tags.php' || $pagenow == 'term.php'); | |
| 1474 | + } | |
| 1475 | + | |
| 1476 | + /** | |
| 1477 | + * Fixes the odd indexing of multiple file uploads. | |
| 1478 | + * | |
| 1479 | + * Goes from the format: | |
| 1480 | + * $_FILES['field']['key']['index'] | |
| 1481 | + * to | |
| 1482 | + * The More standard and appropriate: | |
| 1483 | + * $_FILES['field']['index']['key'] | |
| 1484 | + * | |
| 1485 | + * @param string $files | |
| 1486 | + * @since 1.0 | |
| 1487 | + * @access public | |
| 1488 | + */ | |
| 1489 | + public function fix_file_array(&$files) | |
| 1490 | +		{ | |
| 1491 | + | |
| 1492 | + $output = array(); | |
| 1493 | + | |
| 1494 | +			foreach ($files as $key => $list) { | |
| 1495 | +				foreach ($list as $index => $value) { | |
| 1496 | + $output[$index][$key] = $value; | |
| 1497 | + } | |
| 1498 | + } | |
| 1499 | + | |
| 1500 | + return $files = $output; | |
| 1501 | + | |
| 1502 | + } | |
| 1503 | + | |
| 1504 | + /** | |
| 1505 | + * Get proper JQuery UI version. | |
| 1506 | + * | |
| 1507 | + * Used in order to not conflict with WP Admin Scripts. | |
| 1508 | + * | |
| 1509 | + * @since 1.0 | |
| 1510 | + * @access public | |
| 1511 | + */ | |
| 1512 | + public function get_jqueryui_ver() | |
| 1513 | +		{ | |
| 1514 | + | |
| 1515 | + global $wp_version; | |
| 1516 | + | |
| 1517 | +			if (version_compare($wp_version, '3.1', '>=')) { | |
| 1518 | + return '1.8.10'; | |
| 1519 | + } | |
| 1520 | + | |
| 1521 | + return '1.7.3'; | |
| 1522 | + | |
| 1523 | + } | |
| 1524 | + | |
| 1525 | + /** | |
| 1526 | + * Add Field to meta box (generic function) | |
| 1527 | + * @author Ohad Raz | |
| 1528 | + * @since 1.0 | |
| 1529 | + * @access public | |
| 1530 | + * @param $id string field id, i.e. the meta key | |
| 1531 | + * @param $args mixed|array | |
| 1532 | + */ | |
| 1533 | + public function addField($id, $args) | |
| 1534 | +		{ | |
| 1535 | +			$new_field = array('id' => $id, 'std' => '', 'desc' => '', 'style' => ''); | |
| 1536 | + $new_field = array_merge($new_field, $args); | |
| 1537 | + $this->_fields[] = $new_field; | |
| 1538 | + } | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + /** | |
| 1542 | + * Add Text Field to meta box | |
| 1543 | + * @author Ohad Raz | |
| 1544 | + * @since 1.0 | |
| 1545 | + * @access public | |
| 1546 | + * @param $id string field id, i.e. the meta key | |
| 1547 | + * @param $args mixed|array | |
| 1548 | + * 'name' => // field name/label string optional | |
| 1549 | + * 'desc' => // field description, string optional | |
| 1550 | + * 'std' => // default value, string optional | |
| 1551 | + * 'style' => // custom style for field, string optional | |
| 1552 | + * 'validate_func' => // validate function, string optional | |
| 1553 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1554 | + */ | |
| 1555 | + public function addText($id, $args, $repeater = false) | |
| 1556 | +		{ | |
| 1557 | +			$new_field = array('type' => 'text', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory')); | |
| 1558 | + $new_field = array_merge($new_field, $args); | |
| 1559 | +			if (false === $repeater) { | |
| 1560 | + $this->_fields[] = $new_field; | |
| 1561 | +			} else { | |
| 1562 | + return $new_field; | |
| 1563 | + } | |
| 1564 | + } | |
| 1565 | + | |
| 1566 | + /** | |
| 1567 | + * Add Hidden Field to meta box | |
| 1568 | + * @author Ohad Raz | |
| 1569 | + * @since 0.1.3 | |
| 1570 | + * @access public | |
| 1571 | + * @param $id string field id, i.e. the meta key | |
| 1572 | + * @param $args mixed|array | |
| 1573 | + * 'name' => // field name/label string optional | |
| 1574 | + * 'desc' => // field description, string optional | |
| 1575 | + * 'std' => // default value, string optional | |
| 1576 | + * 'style' => // custom style for field, string optional | |
| 1577 | + * 'validate_func' => // validate function, string optional | |
| 1578 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1579 | + */ | |
| 1580 | + public function addHidden($id, $args, $repeater = false) | |
| 1581 | +		{ | |
| 1582 | +			$new_field = array('type' => 'hidden', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Text Field', 'geodirectory')); | |
| 1583 | + $new_field = array_merge($new_field, $args); | |
| 1584 | +			if (false === $repeater) { | |
| 1585 | + $this->_fields[] = $new_field; | |
| 1586 | +			} else { | |
| 1587 | + return $new_field; | |
| 1588 | + } | |
| 1589 | + } | |
| 1590 | + | |
| 1591 | + /** | |
| 1592 | + * Add Paragraph to meta box | |
| 1593 | + * @author Ohad Raz | |
| 1594 | + * @since 0.1.3 | |
| 1595 | + * @access public | |
| 1596 | + * @param $id string field id, i.e. the meta key | |
| 1597 | + * @param $value paragraph html | |
| 1598 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1599 | + */ | |
| 1600 | + public function addParagraph($id, $args, $repeater = false) | |
| 1601 | +		{ | |
| 1602 | +			$new_field = array('type' => 'paragraph', 'id' => $id, 'value' => '', 'style' => ''); | |
| 1603 | + $new_field = array_merge($new_field, $args); | |
| 1604 | +			if (false === $repeater) { | |
| 1605 | + $this->_fields[] = $new_field; | |
| 1606 | +			} else { | |
| 1607 | + return $new_field; | |
| 1608 | + } | |
| 1609 | + } | |
| 1610 | + | |
| 1611 | + /** | |
| 1612 | + * Add Checkbox Field to meta box | |
| 1613 | + * @author Ohad Raz | |
| 1614 | + * @since 1.0 | |
| 1615 | + * @access public | |
| 1616 | + * @param $id string field id, i.e. the meta key | |
| 1617 | + * @param $args mixed|array | |
| 1618 | + * 'name' => // field name/label string optional | |
| 1619 | + * 'desc' => // field description, string optional | |
| 1620 | + * 'std' => // default value, string optional | |
| 1621 | + * 'validate_func' => // validate function, string optional | |
| 1622 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1623 | + */ | |
| 1624 | + public function addCheckbox($id, $args, $repeater = false) | |
| 1625 | +		{ | |
| 1626 | +			$new_field = array('type' => 'checkbox', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox Field', 'geodirectory')); | |
| 1627 | + $new_field = array_merge($new_field, $args); | |
| 1628 | +			if (false === $repeater) { | |
| 1629 | + $this->_fields[] = $new_field; | |
| 1630 | +			} else { | |
| 1631 | + return $new_field; | |
| 1632 | + } | |
| 1633 | + } | |
| 1634 | + | |
| 1635 | + /** | |
| 1636 | + * Add CheckboxList Field to meta box | |
| 1637 | + * @author Ohad Raz | |
| 1638 | + * @since 1.0 | |
| 1639 | + * @access public | |
| 1640 | + * @param $id string field id, i.e. the meta key | |
| 1641 | + * @param $options (array) array of key => value pairs for select options | |
| 1642 | + * @param $args mixed|array | |
| 1643 | + * 'name' => // field name/label string optional | |
| 1644 | + * 'desc' => // field description, string optional | |
| 1645 | + * 'std' => // default value, string optional | |
| 1646 | + * 'validate_func' => // validate function, string optional | |
| 1647 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1648 | + * | |
| 1649 | + * @return : remember to call: $checkbox_list = $this->get_tax_meta(get_the_ID(), 'meta_name', false); | |
| 1650 | + * which means the last param as false to get the values in an array | |
| 1651 | + */ | |
| 1652 | + public function addCheckboxList($id, $options, $args, $repeater = false) | |
| 1653 | +		{ | |
| 1654 | +			$new_field = array('type' => 'checkbox_list', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Checkbox List Field', 'geodirectory')); | |
| 1655 | + $new_field = array_merge($new_field, $args); | |
| 1656 | +			if (false === $repeater) { | |
| 1657 | + $this->_fields[] = $new_field; | |
| 1658 | +			} else { | |
| 1659 | + return $new_field; | |
| 1660 | + } | |
| 1661 | + } | |
| 1662 | + | |
| 1663 | + /** | |
| 1664 | + * Add Textarea Field to meta box | |
| 1665 | + * @author Ohad Raz | |
| 1666 | + * @since 1.0 | |
| 1667 | + * @access public | |
| 1668 | + * @param $id string field id, i.e. the meta key | |
| 1669 | + * @param $args mixed|array | |
| 1670 | + * 'name' => // field name/label string optional | |
| 1671 | + * 'desc' => // field description, string optional | |
| 1672 | + * 'std' => // default value, string optional | |
| 1673 | + * 'style' => // custom style for field, string optional | |
| 1674 | + * 'validate_func' => // validate function, string optional | |
| 1675 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1676 | + */ | |
| 1677 | + public function addTextarea($id, $args, $repeater = false) | |
| 1678 | +		{ | |
| 1679 | +			$new_field = array('type' => 'textarea', 'id' => $id, 'std' => '', 'desc' => '', 'style' => '', 'name' => __('Textarea Field', 'geodirectory')); | |
| 1680 | + $new_field = array_merge($new_field, $args); | |
| 1681 | +			if (false === $repeater) { | |
| 1682 | + $this->_fields[] = $new_field; | |
| 1683 | +			} else { | |
| 1684 | + return $new_field; | |
| 1685 | + } | |
| 1686 | + } | |
| 1687 | + | |
| 1688 | + /** | |
| 1689 | + * Add Select Field to meta box | |
| 1690 | + * @author Ohad Raz | |
| 1691 | + * @since 1.0 | |
| 1692 | + * @access public | |
| 1693 | + * @param $id string field id, i.e. the meta key | |
| 1694 | + * @param $options (array) array of key => value pairs for select options | |
| 1695 | + * @param $args mixed|array | |
| 1696 | + * 'name' => // field name/label string optional | |
| 1697 | + * 'desc' => // field description, string optional | |
| 1698 | + * 'std' => // default value, (array) optional | |
| 1699 | + * 'multiple' => // select multiple values, optional. Default is false. | |
| 1700 | + * 'validate_func' => // validate function, string optional | |
| 1701 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1702 | + */ | |
| 1703 | + public function addSelect($id, $options, $args, $repeater = false) | |
| 1704 | +		{ | |
| 1705 | +			$new_field = array('type' => 'select', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Select Field', 'geodirectory'), 'multiple' => false, 'options' => $options); | |
| 1706 | + $new_field = array_merge($new_field, $args); | |
| 1707 | +			if (false === $repeater) { | |
| 1708 | + $this->_fields[] = $new_field; | |
| 1709 | +			} else { | |
| 1710 | + return $new_field; | |
| 1711 | + } | |
| 1712 | + } | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + /** | |
| 1716 | + * Add Radio Field to meta box | |
| 1717 | + * @author Ohad Raz | |
| 1718 | + * @since 1.0 | |
| 1719 | + * @access public | |
| 1720 | + * @param $id string field id, i.e. the meta key | |
| 1721 | + * @param $options (array) array of key => value pairs for radio options | |
| 1722 | + * @param $args mixed|array | |
| 1723 | + * 'name' => // field name/label string optional | |
| 1724 | + * 'desc' => // field description, string optional | |
| 1725 | + * 'std' => // default value, string optional | |
| 1726 | + * 'validate_func' => // validate function, string optional | |
| 1727 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1728 | + */ | |
| 1729 | + public function addRadio($id, $options, $args, $repeater = false) | |
| 1730 | +		{ | |
| 1731 | +			$new_field = array('type' => 'radio', 'id' => $id, 'std' => array(), 'desc' => '', 'style' => '', 'name' => __('Radio Field', 'geodirectory'), 'options' => $options); | |
| 1732 | + $new_field = array_merge($new_field, $args); | |
| 1733 | +			if (false === $repeater) { | |
| 1734 | + $this->_fields[] = $new_field; | |
| 1735 | +			} else { | |
| 1736 | + return $new_field; | |
| 1737 | + } | |
| 1738 | + } | |
| 1739 | + | |
| 1740 | + /** | |
| 1741 | + * Add Date Field to meta box | |
| 1742 | + * @author Ohad Raz | |
| 1743 | + * @since 1.0 | |
| 1744 | + * @access public | |
| 1745 | + * @param $id string field id, i.e. the meta key | |
| 1746 | + * @param $args mixed|array | |
| 1747 | + * 'name' => // field name/label string optional | |
| 1748 | + * 'desc' => // field description, string optional | |
| 1749 | + * 'std' => // default value, string optional | |
| 1750 | + * 'validate_func' => // validate function, string optional | |
| 1751 | + * 'format' => // date format, default yy-mm-dd. Optional. Default "'d MM, yy'" See more formats here: http://goo.gl/Wcwxn | |
| 1752 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1753 | + */ | |
| 1754 | + public function addDate($id, $args, $repeater = false) | |
| 1755 | +		{ | |
| 1756 | +			$new_field = array('type' => 'date', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'yy-mm-dd', 'name' => __('Date Field', 'geodirectory')); | |
| 1757 | + $new_field = array_merge($new_field, $args); | |
| 1758 | +			if (false === $repeater) { | |
| 1759 | + $this->_fields[] = $new_field; | |
| 1760 | +			} else { | |
| 1761 | + return $new_field; | |
| 1762 | + } | |
| 1763 | + } | |
| 1764 | + | |
| 1765 | + /** | |
| 1766 | + * Add Time Field to meta box | |
| 1767 | + * @author Ohad Raz | |
| 1768 | + * @since 1.0 | |
| 1769 | + * @access public | |
| 1770 | + * @param $id string- field id, i.e. the meta key | |
| 1771 | + * @param $args mixed|array | |
| 1772 | + * 'name' => // field name/label string optional | |
| 1773 | + * 'desc' => // field description, string optional | |
| 1774 | + * 'std' => // default value, string optional | |
| 1775 | + * 'validate_func' => // validate function, string optional | |
| 1776 | + * 'format' => // time format, default hh:mm. Optional. See more formats here: http://goo.gl/83woX | |
| 1777 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1778 | + */ | |
| 1779 | + public function addTime($id, $args, $repeater = false) | |
| 1780 | +		{ | |
| 1781 | +			$new_field = array('type' => 'time', 'id' => $id, 'std' => '', 'desc' => '', 'format' => 'hh:mm', 'name' => __('Time Field', 'geodirectory')); | |
| 1782 | + $new_field = array_merge($new_field, $args); | |
| 1783 | +			if (false === $repeater) { | |
| 1784 | + $this->_fields[] = $new_field; | |
| 1785 | +			} else { | |
| 1786 | + return $new_field; | |
| 1787 | + } | |
| 1788 | + } | |
| 1789 | + | |
| 1790 | + /** | |
| 1791 | + * Add Color Field to meta box | |
| 1792 | + * @author Ohad Raz | |
| 1793 | + * @since 1.0 | |
| 1794 | + * @access public | |
| 1795 | + * @param $id string field id, i.e. the meta key | |
| 1796 | + * @param $args mixed|array | |
| 1797 | + * 'name' => // field name/label string optional | |
| 1798 | + * 'desc' => // field description, string optional | |
| 1799 | + * 'std' => // default value, string optional | |
| 1800 | + * 'validate_func' => // validate function, string optional | |
| 1801 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1802 | + */ | |
| 1803 | + public function addColor($id, $args, $repeater = false) | |
| 1804 | +		{ | |
| 1805 | +			$new_field = array('type' => 'color', 'id' => $id, 'std' => '', 'desc' => '', 'name' => __('ColorPicker Field', 'geodirectory')); | |
| 1806 | + $new_field = array_merge($new_field, $args); | |
| 1807 | +			if (false === $repeater) { | |
| 1808 | + $this->_fields[] = $new_field; | |
| 1809 | +			} else { | |
| 1810 | + return $new_field; | |
| 1811 | + } | |
| 1812 | + } | |
| 1813 | + | |
| 1814 | + /** | |
| 1815 | + * Add Image Field to meta box | |
| 1816 | + * @author Ohad Raz | |
| 1817 | + * @since 1.0 | |
| 1818 | + * @access public | |
| 1819 | + * @param $id string field id, i.e. the meta key | |
| 1820 | + * @param $args mixed|array | |
| 1821 | + * 'name' => // field name/label string optional | |
| 1822 | + * 'desc' => // field description, string optional | |
| 1823 | + * 'validate_func' => // validate function, string optional | |
| 1824 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1825 | + */ | |
| 1826 | + public function addImage($id, $args, $repeater = false) | |
| 1827 | +		{ | |
| 1828 | +			$new_field = array('type' => 'image', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('Image Field', 'geodirectory')); | |
| 1829 | + $new_field = array_merge($new_field, $args); | |
| 1830 | + | |
| 1831 | +			if (false === $repeater) { | |
| 1832 | + $this->_fields[] = $new_field; | |
| 1833 | +			} else { | |
| 1834 | + return $new_field; | |
| 1835 | + } | |
| 1836 | + } | |
| 1837 | + | |
| 1838 | + /** | |
| 1839 | + * Add File Field to meta box | |
| 1840 | + * @author Ohad Raz | |
| 1841 | + * @since 1.0 | |
| 1842 | + * @access public | |
| 1843 | + * @param $id string field id, i.e. the meta key | |
| 1844 | + * @param $args mixed|array | |
| 1845 | + * 'name' => // field name/label string optional | |
| 1846 | + * 'desc' => // field description, string optional | |
| 1847 | + * 'validate_func' => // validate function, string optional | |
| 1848 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1849 | + */ | |
| 1850 | + public function addFile($id, $args, $repeater = false) | |
| 1851 | +		{ | |
| 1852 | +			$new_field = array('type' => 'file', 'id' => $id, 'desc' => '', 'style' => '', 'name' => __('File Field', 'geodirectory')); | |
| 1853 | + $new_field = array_merge($new_field, $args); | |
| 1854 | +			if (false === $repeater) { | |
| 1855 | + $this->_fields[] = $new_field; | |
| 1856 | +			} else { | |
| 1857 | + return $new_field; | |
| 1858 | + } | |
| 1859 | + } | |
| 1860 | + | |
| 1861 | + /** | |
| 1862 | + * Add WYSIWYG Field to meta box | |
| 1863 | + * @author Ohad Raz | |
| 1864 | + * @since 1.0 | |
| 1865 | + * @access public | |
| 1866 | + * @param $id string field id, i.e. the meta key | |
| 1867 | + * @param $args mixed|array | |
| 1868 | + * 'name' => // field name/label string optional | |
| 1869 | + * 'desc' => // field description, string optional | |
| 1870 | + * 'std' => // default value, string optional | |
| 1871 | + * 'style' => // custom style for field, string optional Default 'width: 300px; height: 400px' | |
| 1872 | + * 'validate_func' => // validate function, string optional | |
| 1873 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1874 | + */ | |
| 1875 | + public function addWysiwyg($id, $args, $repeater = false) | |
| 1876 | +		{ | |
| 1877 | +			$new_field = array('type' => 'wysiwyg', 'id' => $id, 'std' => '', 'desc' => '', 'style' => 'width: 300px; height: 400px', 'name' => __('WYSIWYG Editor Field', 'geodirectory')); | |
| 1878 | + $new_field = array_merge($new_field, $args); | |
| 1879 | +			if (false === $repeater) { | |
| 1880 | + $this->_fields[] = $new_field; | |
| 1881 | +			} else { | |
| 1882 | + return $new_field; | |
| 1883 | + } | |
| 1884 | + } | |
| 1885 | + | |
| 1886 | + /** | |
| 1887 | + * Add Taxonomy Field to meta box | |
| 1888 | + * @author Ohad Raz | |
| 1889 | + * @since 1.0 | |
| 1890 | + * @access public | |
| 1891 | + * @param $id string field id, i.e. the meta key | |
| 1892 | + * @param $options mixed|array options of taxonomy field | |
| 1893 | + * 'taxonomy' => // taxonomy name can be category,post_tag or any custom taxonomy default is category | |
| 1894 | + * 'type' => // how to show taxonomy? 'select' (default) or 'checkbox_list' | |
| 1895 | +		 * 'args' =>  // arguments to query taxonomy, see http://goo.gl/uAANN default ('hide_empty' => false) | |
| 1896 | + * @param $args mixed|array | |
| 1897 | + * 'name' => // field name/label string optional | |
| 1898 | + * 'desc' => // field description, string optional | |
| 1899 | + * 'std' => // default value, string optional | |
| 1900 | + * 'validate_func' => // validate function, string optional | |
| 1901 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1902 | + */ | |
| 1903 | + public function addTaxonomy($id, $options, $args, $repeater = false) | |
| 1904 | +		{ | |
| 1905 | +			$q = array('hide_empty' => 0); | |
| 1906 | + $tax = 'category'; | |
| 1907 | + $type = 'select'; | |
| 1908 | + $temp = array($tax, $type, $q); | |
| 1909 | + $options = array_merge($temp, $options); | |
| 1910 | +			$new_field = array('type' => 'taxonomy', 'id' => $id, 'desc' => '', 'name' => __('Taxonomy Field', 'geodirectory'), 'options' => $options); | |
| 1911 | + $new_field = array_merge($new_field, $args); | |
| 1912 | +			if (false === $repeater) { | |
| 1913 | + $this->_fields[] = $new_field; | |
| 1914 | +			} else { | |
| 1915 | + return $new_field; | |
| 1916 | + } | |
| 1917 | + } | |
| 1918 | + | |
| 1919 | + /** | |
| 1920 | + * Add posts Field to meta box | |
| 1921 | + * @author Ohad Raz | |
| 1922 | + * @since 1.0 | |
| 1923 | + * @access public | |
| 1924 | + * @param $id string field id, i.e. the meta key | |
| 1925 | + * @param $options mixed|array options of taxonomy field | |
| 1926 | + * 'post_type' => // post type name, 'post' (default) 'page' or any custom post type | |
| 1927 | + * 'type' => // how to show posts? 'select' (default) or 'checkbox_list' | |
| 1928 | +		 * 'args' =>  // arguments to query posts, see http://goo.gl/is0yK default ('posts_per_page' => -1) | |
| 1929 | + * @param $args mixed|array | |
| 1930 | + * 'name' => // field name/label string optional | |
| 1931 | + * 'desc' => // field description, string optional | |
| 1932 | + * 'std' => // default value, string optional | |
| 1933 | + * 'validate_func' => // validate function, string optional | |
| 1934 | + * @param $repeater bool is this a field inside a repeatr? true|false(default) | |
| 1935 | + */ | |
| 1936 | + public function addPosts($id, $options, $args, $repeater = false) | |
| 1937 | +		{ | |
| 1938 | +			$q = array('posts_per_page' => -1); | |
| 1939 | +			$temp = array('post_type' => 'post', 'type' => 'select', 'args' => $q); | |
| 1940 | + $options = array_merge($temp, $options); | |
| 1941 | +			$new_field = array('type' => 'posts', 'id' => $id, 'desc' => '', 'name' => __('Posts Field', 'geodirectory'), 'options' => $options); | |
| 1942 | + $new_field = array_merge($new_field, $args); | |
| 1943 | +			if (false === $repeater) { | |
| 1944 | + $this->_fields[] = $new_field; | |
| 1945 | +			} else { | |
| 1946 | + return $new_field; | |
| 1947 | + } | |
| 1948 | + } | |
| 1949 | + | |
| 1950 | + /** | |
| 1951 | + * Add repeater Field Block to meta box | |
| 1952 | + * @author Ohad Raz | |
| 1953 | + * @since 1.0 | |
| 1954 | + * @access public | |
| 1955 | + * @param $id string field id, i.e. the meta key | |
| 1956 | + * @param $args mixed|array | |
| 1957 | + * 'name' => // field name/label string optional | |
| 1958 | + * 'desc' => // field description, string optional | |
| 1959 | + * 'std' => // default value, string optional | |
| 1960 | + * 'style' => // custom style for field, string optional | |
| 1961 | + * 'validate_func' => // validate function, string optional | |
| 1962 | + * 'fields' => //fields to repeater | |
| 1963 | + */ | |
| 1964 | + public function addRepeaterBlock($id, $args) | |
| 1965 | +		{ | |
| 1966 | +			$new_field = array('type' => 'repeater', 'id' => $id, 'name' => __('Reapeater Field', 'geodirectory'), 'fields' => array(), 'inline' => false); | |
| 1967 | + $new_field = array_merge($new_field, $args); | |
| 1968 | + $this->_fields[] = $new_field; | |
| 1969 | + } | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + /** | |
| 1973 | + * Finish Declaration of Meta Box | |
| 1974 | + * @author Ohad Raz | |
| 1975 | + * @since 1.0 | |
| 1976 | + * @access public | |
| 1977 | + */ | |
| 1978 | + public function Finish() | |
| 1979 | +		{ | |
| 1980 | + $this->add_missed_values(); | |
| 1981 | + $this->check_field_upload(); | |
| 1982 | + $this->check_field_color(); | |
| 1983 | + $this->check_field_date(); | |
| 1984 | + $this->check_field_time(); | |
| 1985 | + } | |
| 1986 | + | |
| 1987 | + /** | |
| 1988 | + * Helper function to check for empty arrays | |
| 1989 | + * @author Ohad Raz | |
| 1990 | + * @since 1.0 | |
| 1991 | + * @access public | |
| 1992 | + * @param $args mixed|array | |
| 1993 | + */ | |
| 1994 | + public function is_array_empty($array) | |
| 1995 | +		{ | |
| 1996 | + if (!is_array($array)) | |
| 1997 | + return true; | |
| 1998 | + | |
| 1999 | +			foreach ($array as $a) { | |
| 2000 | +				if (is_array($a)) { | |
| 2001 | +					foreach ($a as $sub_a) { | |
| 2002 | + if (!empty($sub_a) && $sub_a != '') | |
| 2003 | + return false; | |
| 2004 | + } | |
| 2005 | +				} else { | |
| 2006 | + if (!empty($a) && $a != '') | |
| 2007 | + return false; | |
| 2008 | + } | |
| 2009 | + } | |
| 2010 | + return true; | |
| 2011 | + } | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + //get term meta field | |
| 2015 | + public function get_tax_meta($term_id, $key, $multi = false, $post_type = '') | |
| 2016 | +		{ | |
| 2017 | + | |
| 2018 | +			if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2019 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2020 | + $post_type = $taxObject->object_type[0]; | |
| 2021 | + } | |
| 2022 | + | |
| 2023 | +			if($post_type=='post'){$post_type='';} | |
| 2024 | +			if($post_type){$post_type = $post_type.'_';} | |
| 2025 | + | |
| 2026 | + $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; | |
| 2027 | + | |
| 2028 | +			$m = get_option('tax_meta_' . $post_type  . $t_id); | |
| 2029 | +			if (isset($m[$key])) { | |
| 2030 | + return $m[$key]; | |
| 2031 | +			} else { | |
| 2032 | + return ''; | |
| 2033 | + } | |
| 2034 | + } | |
| 2035 | + | |
| 2036 | + //delete meta | |
| 2037 | + public function delete_tax_meta($term_id, $key, $post_type = '') | |
| 2038 | +		{ | |
| 2039 | + | |
| 2040 | +			if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2041 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2042 | + $post_type = $taxObject->object_type[0]; | |
| 2043 | + } | |
| 2044 | + | |
| 2045 | +			if($post_type=='post'){$post_type='';} | |
| 2046 | +			if($post_type){$post_type = $post_type.'_';} | |
| 2047 | + | |
| 2048 | +			$m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2049 | + | |
| 2050 | +			if (isset($m[$key])) { | |
| 2051 | + unset($m[$key]); | |
| 2052 | + } | |
| 2053 | +			update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2054 | + } | |
| 2055 | + | |
| 2056 | + //update meta | |
| 2057 | + public function update_tax_meta($term_id, $key, $value, $post_type = '') | |
| 2058 | +		{ | |
| 2059 | + | |
| 2060 | +			if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2061 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2062 | + $post_type = $taxObject->object_type[0]; | |
| 2063 | + } | |
| 2064 | + | |
| 2065 | +			if($post_type=='post'){$post_type='';} | |
| 2066 | +			if($post_type){$post_type = $post_type.'_';} | |
| 2067 | + | |
| 2068 | +			$m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2069 | + | |
| 2070 | + $m[$key] = $value; | |
| 2071 | +			update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2072 | + | |
| 2073 | + /** | |
| 2074 | + * Called after the tax meta is updated. | |
| 2075 | + * | |
| 2076 | + * Used to update things after a GD category is saved. | |
| 2077 | + * | |
| 2078 | + * @since 1.0.0 | |
| 2079 | + * @param bool $false False. | |
| 2080 | + * @param bool $true True. | |
| 2081 | + * @param int $term_id The term id being updated. | |
| 2082 | + * @param string $post_type The post type of the cat being updated. | |
| 2083 | + */ | |
| 2084 | +			do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); | |
| 2085 | + } | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + } // End Class | |
| 2089 | 2089 | |
| 2090 | 2090 | endif; // End Check Class Exists | 
| 2091 | 2091 | |
| @@ -2095,67 +2095,67 @@ discard block | ||
| 2095 | 2095 | |
| 2096 | 2096 | //get term meta field | 
| 2097 | 2097 |  if (!function_exists('get_tax_meta')) { | 
| 2098 | - function get_tax_meta($term_id, $key, $multi = false, $post_type = '') | |
| 2099 | -    { | |
| 2100 | - | |
| 2101 | -        if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2102 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2103 | - $post_type = $taxObject->object_type[0]; | |
| 2104 | - } | |
| 2105 | - | |
| 2106 | -        if($post_type=='post'){$post_type='';} | |
| 2107 | -        if($post_type){$post_type = $post_type.'_';} | |
| 2108 | - | |
| 2109 | - $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; | |
| 2110 | - | |
| 2111 | -        $m = get_option('tax_meta_' . $post_type  . $t_id); | |
| 2112 | -        if (isset($m[$key])) { | |
| 2113 | - return $m[$key]; | |
| 2114 | -        } else { | |
| 2115 | - return ''; | |
| 2116 | - } | |
| 2117 | - } | |
| 2098 | + function get_tax_meta($term_id, $key, $multi = false, $post_type = '') | |
| 2099 | +	{ | |
| 2100 | + | |
| 2101 | +		if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2102 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2103 | + $post_type = $taxObject->object_type[0]; | |
| 2104 | + } | |
| 2105 | + | |
| 2106 | +		if($post_type=='post'){$post_type='';} | |
| 2107 | +		if($post_type){$post_type = $post_type.'_';} | |
| 2108 | + | |
| 2109 | + $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; | |
| 2110 | + | |
| 2111 | +		$m = get_option('tax_meta_' . $post_type  . $t_id); | |
| 2112 | +		if (isset($m[$key])) { | |
| 2113 | + return $m[$key]; | |
| 2114 | +		} else { | |
| 2115 | + return ''; | |
| 2116 | + } | |
| 2117 | + } | |
| 2118 | 2118 | } | 
| 2119 | 2119 | |
| 2120 | 2120 | //delete meta | 
| 2121 | 2121 |  if (!function_exists('delete_tax_meta')) { | 
| 2122 | - function delete_tax_meta($term_id, $key) | |
| 2123 | -    { | |
| 2122 | + function delete_tax_meta($term_id, $key) | |
| 2123 | +	{ | |
| 2124 | 2124 | |
| 2125 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2126 | - $post_type = $taxObject->object_type[0]; | |
| 2125 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2126 | + $post_type = $taxObject->object_type[0]; | |
| 2127 | 2127 | |
| 2128 | -        if($post_type=='post'){$post_type='';} | |
| 2129 | -        if($post_type){$post_type = $post_type.'_';} | |
| 2128 | +		if($post_type=='post'){$post_type='';} | |
| 2129 | +		if($post_type){$post_type = $post_type.'_';} | |
| 2130 | 2130 | |
| 2131 | -        $m = get_option('tax_meta_' . $post_type . $term_id); | |
| 2131 | +		$m = get_option('tax_meta_' . $post_type . $term_id); | |
| 2132 | 2132 | |
| 2133 | -        if (isset($m[$key])) { | |
| 2134 | - unset($m[$key]); | |
| 2135 | - } | |
| 2136 | -        update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2137 | - } | |
| 2133 | +		if (isset($m[$key])) { | |
| 2134 | + unset($m[$key]); | |
| 2135 | + } | |
| 2136 | +		update_option('tax_meta_' . $post_type  . $term_id, $m); | |
| 2137 | + } | |
| 2138 | 2138 | } | 
| 2139 | 2139 | |
| 2140 | 2140 | //update meta | 
| 2141 | 2141 |  if (!function_exists('update_tax_meta')) { | 
| 2142 | - function update_tax_meta($term_id, $key, $value, $post_type = '') | |
| 2143 | -    { | |
| 2142 | + function update_tax_meta($term_id, $key, $value, $post_type = '') | |
| 2143 | +	{ | |
| 2144 | 2144 | |
| 2145 | -        if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2146 | - $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2147 | - $post_type = $taxObject->object_type[0]; | |
| 2148 | - } | |
| 2145 | +		if (empty($post_type) && isset($_REQUEST['taxonomy'])) { | |
| 2146 | + $taxObject = get_taxonomy($_REQUEST['taxonomy']); | |
| 2147 | + $post_type = $taxObject->object_type[0]; | |
| 2148 | + } | |
| 2149 | 2149 | |
| 2150 | -        if($post_type=='post'){$post_type='';} | |
| 2151 | -        if($post_type){$post_type = $post_type.'_';} | |
| 2150 | +		if($post_type=='post'){$post_type='';} | |
| 2151 | +		if($post_type){$post_type = $post_type.'_';} | |
| 2152 | 2152 | |
| 2153 | -        $m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2153 | +		$m = get_option('tax_meta_' . $post_type  . $term_id); | |
| 2154 | 2154 | |
| 2155 | - $m[$key] = $value; | |
| 2156 | -        update_option('tax_meta_' . $post_type . $term_id, $m); | |
| 2155 | + $m[$key] = $value; | |
| 2156 | +		update_option('tax_meta_' . $post_type . $term_id, $m); | |
| 2157 | 2157 | |
| 2158 | - /** This action is documented in geodirectory-functions/cat-meta-functions/Tax-meta-class.php */ | |
| 2159 | -        do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); | |
| 2160 | - } | |
| 2158 | + /** This action is documented in geodirectory-functions/cat-meta-functions/Tax-meta-class.php */ | |
| 2159 | +		do_action('gd_tax_meta_updated', false, true, $term_id, $post_type); | |
| 2160 | + } | |
| 2161 | 2161 | } | 
| 2162 | 2162 | \ No newline at end of file | 
| @@ -10,33 +10,33 @@ discard block | ||
| 10 | 10 | |
| 11 | 11 |  add_action('admin_init', 'geodir_admin_init');
 | 
| 12 | 12 |  if (!function_exists('geodir_admin_init')) {
 | 
| 13 | - /** | |
| 14 | - * Adds GD setting pages in admin. | |
| 15 | - * | |
| 16 | - * @since 1.0.0 | |
| 17 | - * @package GeoDirectory | |
| 18 | - * @global string $current_tab The current settings tab name. | |
| 19 | - */ | |
| 20 | - function geodir_admin_init() | |
| 21 | -    {
 | |
| 22 | - | |
| 23 | - if (is_admin()): | |
| 24 | - global $current_tab; | |
| 25 | - geodir_redirect_to_admin_panel_on_installed(); | |
| 26 | - $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings'; | |
| 27 | - if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests | |
| 28 | - geodir_handle_option_form_submit($current_tab); // located in admin function.php | |
| 29 | - /** | |
| 30 | - * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area. | |
| 31 | - * | |
| 32 | - * @since 1.0.0 | |
| 33 | - */ | |
| 34 | -            do_action('admin_panel_init');
 | |
| 35 | -            add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
 | |
| 36 | - | |
| 37 | - | |
| 38 | - endif; | |
| 39 | - } | |
| 13 | + /** | |
| 14 | + * Adds GD setting pages in admin. | |
| 15 | + * | |
| 16 | + * @since 1.0.0 | |
| 17 | + * @package GeoDirectory | |
| 18 | + * @global string $current_tab The current settings tab name. | |
| 19 | + */ | |
| 20 | + function geodir_admin_init() | |
| 21 | +	{
 | |
| 22 | + | |
| 23 | + if (is_admin()): | |
| 24 | + global $current_tab; | |
| 25 | + geodir_redirect_to_admin_panel_on_installed(); | |
| 26 | + $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings'; | |
| 27 | + if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests | |
| 28 | + geodir_handle_option_form_submit($current_tab); // located in admin function.php | |
| 29 | + /** | |
| 30 | + * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area. | |
| 31 | + * | |
| 32 | + * @since 1.0.0 | |
| 33 | + */ | |
| 34 | +			do_action('admin_panel_init');
 | |
| 35 | +			add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
 | |
| 36 | + | |
| 37 | + | |
| 38 | + endif; | |
| 39 | + } | |
| 40 | 40 | } | 
| 41 | 41 | |
| 42 | 42 | /** | 
| @@ -47,10 +47,10 @@ discard block | ||
| 47 | 47 | */ | 
| 48 | 48 | function geodir_redirect_to_admin_panel_on_installed() | 
| 49 | 49 |  {
 | 
| 50 | -    if (get_option('geodir_installation_redirect', false)) {
 | |
| 51 | -        delete_option('geodir_installation_redirect');
 | |
| 52 | -        wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
 | |
| 53 | - } | |
| 50 | +	if (get_option('geodir_installation_redirect', false)) {
 | |
| 51 | +		delete_option('geodir_installation_redirect');
 | |
| 52 | +		wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
 | |
| 53 | + } | |
| 54 | 54 | } | 
| 55 | 55 | |
| 56 | 56 | /** | 
| @@ -62,7 +62,7 @@ discard block | ||
| 62 | 62 | */ | 
| 63 | 63 | function geodir_get_admin_option_form($current_tab) | 
| 64 | 64 |  {
 | 
| 65 | - geodir_admin_option_form($current_tab);// defined in admin template tags.php | |
| 65 | + geodir_admin_option_form($current_tab);// defined in admin template tags.php | |
| 66 | 66 | } | 
| 67 | 67 | |
| 68 | 68 | |
| @@ -84,18 +84,18 @@ discard block | ||
| 84 | 84 | */ | 
| 85 | 85 | function geodir_conditional_admin_script_load() | 
| 86 | 86 |  {
 | 
| 87 | - global $pagenow; | |
| 87 | + global $pagenow; | |
| 88 | 88 | |
| 89 | 89 | // Get the current post type | 
| 90 | 90 | $post_type = geodir_admin_current_post_type(); | 
| 91 | 91 | $geodir_post_types = geodir_get_posttypes(); | 
| 92 | 92 | |
| 93 | 93 |  	if ((isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') || (($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') && $post_type && in_array($post_type, $geodir_post_types)) || ($pagenow == 'edit-tags.php' || $pagenow == 'term.php' || $pagenow == 'edit-comments.php' || $pagenow == 'comment.php')) {
 | 
| 94 | -        add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
 | |
| 95 | -        add_action('admin_enqueue_scripts', 'geodir_admin_styles');
 | |
| 96 | - } | |
| 94 | +		add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
 | |
| 95 | +		add_action('admin_enqueue_scripts', 'geodir_admin_styles');
 | |
| 96 | + } | |
| 97 | 97 | |
| 98 | -    add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
 | |
| 98 | +	add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
 | |
| 99 | 99 | |
| 100 | 100 | } | 
| 101 | 101 | |
| @@ -129,12 +129,12 @@ discard block | ||
| 129 | 129 | */ | 
| 130 | 130 | function create_default_admin_main_nav() | 
| 131 | 131 |  {
 | 
| 132 | -    add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
 | |
| 133 | -    add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
 | |
| 134 | -    add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
 | |
| 135 | -    add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
 | |
| 136 | -    add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
 | |
| 137 | -    //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
 | |
| 132 | +	add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
 | |
| 133 | +	add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
 | |
| 134 | +	add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
 | |
| 135 | +	add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
 | |
| 136 | +	add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
 | |
| 137 | +	//add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
 | |
| 138 | 138 | |
| 139 | 139 | } | 
| 140 | 140 | |
| @@ -147,16 +147,16 @@ discard block | ||
| 147 | 147 | */ | 
| 148 | 148 | function geodir_admin_list_columns() | 
| 149 | 149 |  {
 | 
| 150 | -    if ($post_types = geodir_get_posttypes()) {
 | |
| 150 | +	if ($post_types = geodir_get_posttypes()) {
 | |
| 151 | 151 | |
| 152 | - foreach ($post_types as $post_type): | |
| 153 | -            add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
 | |
| 154 | - //Filter-Payment-Manager to show Package | |
| 155 | -            add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
 | |
| 152 | + foreach ($post_types as $post_type): | |
| 153 | +			add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
 | |
| 154 | + //Filter-Payment-Manager to show Package | |
| 155 | +			add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
 | |
| 156 | 156 | |
| 157 | -            add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
 | |
| 158 | - endforeach; | |
| 159 | - } | |
| 157 | +			add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
 | |
| 158 | + endforeach; | |
| 159 | + } | |
| 160 | 160 | } | 
| 161 | 161 | |
| 162 | 162 | /** | 
| @@ -169,15 +169,15 @@ discard block | ||
| 169 | 169 | */ | 
| 170 | 170 | function geodir_default_admin_main_tabs($tabs) | 
| 171 | 171 |  {
 | 
| 172 | - return $tabs = array( | |
| 173 | -        'general_settings' => array('label' => __('General', 'geodirectory')),
 | |
| 174 | -        'design_settings' => array('label' => __('Design', 'geodirectory')),
 | |
| 175 | -        'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
 | |
| 176 | -        'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
 | |
| 177 | -        'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
 | |
| 178 | -        'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
 | |
| 179 | - | |
| 180 | - ); | |
| 172 | + return $tabs = array( | |
| 173 | +		'general_settings' => array('label' => __('General', 'geodirectory')),
 | |
| 174 | +		'design_settings' => array('label' => __('Design', 'geodirectory')),
 | |
| 175 | +		'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
 | |
| 176 | +		'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
 | |
| 177 | +		'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
 | |
| 178 | +		'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
 | |
| 179 | + | |
| 180 | + ); | |
| 181 | 181 | } | 
| 182 | 182 | |
| 183 | 183 |  add_action('do_meta_boxes', 'geodir_remove_image_box');
 | 
| @@ -190,16 +190,16 @@ discard block | ||
| 190 | 190 | */ | 
| 191 | 191 | function geodir_remove_image_box() | 
| 192 | 192 |  {
 | 
| 193 | - global $post; | |
| 193 | + global $post; | |
| 194 | 194 | |
| 195 | - $geodir_posttypes = geodir_get_posttypes(); | |
| 195 | + $geodir_posttypes = geodir_get_posttypes(); | |
| 196 | 196 | |
| 197 | - if (isset($post) && in_array($post->post_type, $geodir_posttypes)): | |
| 197 | + if (isset($post) && in_array($post->post_type, $geodir_posttypes)): | |
| 198 | 198 | |
| 199 | -        remove_meta_box('postimagediv', $post->post_type, 'side');
 | |
| 200 | -        remove_meta_box('revisionsdiv', $post->post_type, 'normal');
 | |
| 199 | +		remove_meta_box('postimagediv', $post->post_type, 'side');
 | |
| 200 | +		remove_meta_box('revisionsdiv', $post->post_type, 'normal');
 | |
| 201 | 201 | |
| 202 | - endif; | |
| 202 | + endif; | |
| 203 | 203 | |
| 204 | 204 | } | 
| 205 | 205 | |
| @@ -214,26 +214,26 @@ discard block | ||
| 214 | 214 | */ | 
| 215 | 215 | function geodir_meta_box_add() | 
| 216 | 216 |  {
 | 
| 217 | - global $post; | |
| 217 | + global $post; | |
| 218 | 218 | |
| 219 | -    $geodir_post_types = geodir_get_posttypes('array');
 | |
| 220 | - $geodir_posttypes = array_keys($geodir_post_types); | |
| 219 | +	$geodir_post_types = geodir_get_posttypes('array');
 | |
| 220 | + $geodir_posttypes = array_keys($geodir_post_types); | |
| 221 | 221 | |
| 222 | - if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)): | |
| 222 | + if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)): | |
| 223 | 223 | |
| 224 | - $geodir_posttype = $post->post_type; | |
| 225 | - $post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']); | |
| 224 | + $geodir_posttype = $post->post_type; | |
| 225 | + $post_typename = geodir_ucwords($geodir_post_types[$geodir_posttype]['labels']['singular_name']); | |
| 226 | 226 | |
| 227 | - // Filter-Payment-Manager | |
| 227 | + // Filter-Payment-Manager | |
| 228 | 228 | |
| 229 | -        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
 | |
| 229 | +		add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
 | |
| 230 | 230 | |
| 231 | -        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
 | |
| 231 | +		add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
 | |
| 232 | 232 | |
| 233 | - // no need of this box as all fields moved to main information box | |
| 234 | -        //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
 | |
| 233 | + // no need of this box as all fields moved to main information box | |
| 234 | +		//add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
 | |
| 235 | 235 | |
| 236 | - endif; | |
| 236 | + endif; | |
| 237 | 237 | |
| 238 | 238 | } | 
| 239 | 239 | |
| @@ -257,23 +257,23 @@ discard block | ||
| 257 | 257 | function geodir_hide_post_taxonomy_meta_boxes() | 
| 258 | 258 |  {
 | 
| 259 | 259 | |
| 260 | -    $geodir_post_types = get_option('geodir_post_types');
 | |
| 260 | +	$geodir_post_types = get_option('geodir_post_types');
 | |
| 261 | 261 | |
| 262 | -    if (!empty($geodir_post_types)) {
 | |
| 263 | -        foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
 | |
| 262 | +	if (!empty($geodir_post_types)) {
 | |
| 263 | +		foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
 | |
| 264 | 264 | |
| 265 | - $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); | |
| 265 | + $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); | |
| 266 | 266 | |
| 267 | -            if(!empty($gd_taxonomy)) {
 | |
| 268 | -                foreach ($gd_taxonomy as $tax) {
 | |
| 267 | +			if(!empty($gd_taxonomy)) {
 | |
| 268 | +				foreach ($gd_taxonomy as $tax) {
 | |
| 269 | 269 | |
| 270 | - remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); | |
| 270 | + remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); | |
| 271 | 271 | |
| 272 | - } | |
| 273 | - } | |
| 272 | + } | |
| 273 | + } | |
| 274 | 274 | |
| 275 | - } | |
| 276 | - } | |
| 275 | + } | |
| 276 | + } | |
| 277 | 277 | } | 
| 278 | 278 | |
| 279 | 279 |  add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict');
 | 
| @@ -287,12 +287,12 @@ discard block | ||
| 287 | 287 | */ | 
| 288 | 288 | function geodir_add_listing_map_restrict($map_restirct) | 
| 289 | 289 |  {
 | 
| 290 | -    if (is_admin()) {
 | |
| 291 | -        if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
 | |
| 292 | - $map_restirct = false; | |
| 293 | - } | |
| 294 | - } | |
| 295 | - return $map_restirct; | |
| 290 | +	if (is_admin()) {
 | |
| 291 | +		if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
 | |
| 292 | + $map_restirct = false; | |
| 293 | + } | |
| 294 | + } | |
| 295 | + return $map_restirct; | |
| 296 | 296 | } | 
| 297 | 297 | |
| 298 | 298 | |
| @@ -311,16 +311,16 @@ discard block | ||
| 311 | 311 | function geodir_enable_editor_on_notifications($notification) | 
| 312 | 312 |  {
 | 
| 313 | 313 | |
| 314 | -    if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
 | |
| 314 | +	if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
 | |
| 315 | 315 | |
| 316 | -        foreach ($notification as $key => $value) {
 | |
| 317 | - if ($value['type'] == 'textarea') | |
| 318 | - $notification[$key]['type'] = 'editor'; | |
| 319 | - } | |
| 316 | +		foreach ($notification as $key => $value) {
 | |
| 317 | + if ($value['type'] == 'textarea') | |
| 318 | + $notification[$key]['type'] = 'editor'; | |
| 319 | + } | |
| 320 | 320 | |
| 321 | - } | |
| 321 | + } | |
| 322 | 322 | |
| 323 | - return $notification; | |
| 323 | + return $notification; | |
| 324 | 324 | } | 
| 325 | 325 | |
| 326 | 326 | |
| @@ -337,16 +337,16 @@ discard block | ||
| 337 | 337 | function geodir_enable_editor_on_design_settings($design_setting) | 
| 338 | 338 |  {
 | 
| 339 | 339 | |
| 340 | -    if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
 | |
| 340 | +	if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
 | |
| 341 | 341 | |
| 342 | -        foreach ($design_setting as $key => $value) {
 | |
| 343 | - if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') | |
| 344 | - $design_setting[$key]['type'] = 'editor'; | |
| 345 | - } | |
| 342 | +		foreach ($design_setting as $key => $value) {
 | |
| 343 | + if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') | |
| 344 | + $design_setting[$key]['type'] = 'editor'; | |
| 345 | + } | |
| 346 | 346 | |
| 347 | - } | |
| 347 | + } | |
| 348 | 348 | |
| 349 | - return $design_setting; | |
| 349 | + return $design_setting; | |
| 350 | 350 | } | 
| 351 | 351 | |
| 352 | 352 | /* ----------- START MANAGE CUSTOM FIELDS ---------------- */ | 
| @@ -367,16 +367,16 @@ discard block | ||
| 367 | 367 | function geodir_manage_available_fields($sub_tab) | 
| 368 | 368 |  {
 | 
| 369 | 369 | |
| 370 | -    switch ($sub_tab) {
 | |
| 371 | - case 'custom_fields': | |
| 372 | - geodir_custom_available_fields(); | |
| 373 | - break; | |
| 370 | +	switch ($sub_tab) {
 | |
| 371 | + case 'custom_fields': | |
| 372 | + geodir_custom_available_fields(); | |
| 373 | + break; | |
| 374 | 374 | |
| 375 | - case 'sorting_options': | |
| 376 | - geodir_sorting_options_available_fields(); | |
| 377 | - break; | |
| 375 | + case 'sorting_options': | |
| 376 | + geodir_sorting_options_available_fields(); | |
| 377 | + break; | |
| 378 | 378 | |
| 379 | - } | |
| 379 | + } | |
| 380 | 380 | } | 
| 381 | 381 | |
| 382 | 382 | |
| @@ -392,16 +392,16 @@ discard block | ||
| 392 | 392 | function geodir_manage_selected_fields($sub_tab) | 
| 393 | 393 |  {
 | 
| 394 | 394 | |
| 395 | -    switch ($sub_tab) {
 | |
| 396 | - case 'custom_fields': | |
| 397 | - geodir_custom_selected_fields(); | |
| 398 | - break; | |
| 395 | +	switch ($sub_tab) {
 | |
| 396 | + case 'custom_fields': | |
| 397 | + geodir_custom_selected_fields(); | |
| 398 | + break; | |
| 399 | 399 | |
| 400 | - case 'sorting_options': | |
| 401 | - geodir_sorting_options_selected_fields(); | |
| 402 | - break; | |
| 400 | + case 'sorting_options': | |
| 401 | + geodir_sorting_options_selected_fields(); | |
| 402 | + break; | |
| 403 | 403 | |
| 404 | - } | |
| 404 | + } | |
| 405 | 405 | } | 
| 406 | 406 | |
| 407 | 407 | /** | 
| @@ -413,27 +413,27 @@ discard block | ||
| 413 | 413 | */ | 
| 414 | 414 | function geodir_sorting_options_available_fields() | 
| 415 | 415 |  {
 | 
| 416 | - global $wpdb; | |
| 417 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 418 | - ?> | |
| 416 | + global $wpdb; | |
| 417 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 418 | + ?> | |
| 419 | 419 | <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> | 
| 420 | 420 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> | 
| 421 | 421 | <ul> | 
| 422 | 422 | <?php | 
| 423 | - $sort_options = geodir_get_custom_sort_options($listing_type); | |
| 423 | + $sort_options = geodir_get_custom_sort_options($listing_type); | |
| 424 | 424 | |
| 425 | -        foreach ($sort_options as $key => $val) {
 | |
| 426 | - $val = stripslashes_deep($val); // strip slashes | |
| 427 | - | |
| 428 | - $check_html_variable = $wpdb->get_var( | |
| 429 | - $wpdb->prepare( | |
| 430 | - "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", | |
| 431 | - array($val['htmlvar_name'], $listing_type, $val['field_type']) | |
| 432 | - ) | |
| 433 | - ); | |
| 425 | +		foreach ($sort_options as $key => $val) {
 | |
| 426 | + $val = stripslashes_deep($val); // strip slashes | |
| 427 | + | |
| 428 | + $check_html_variable = $wpdb->get_var( | |
| 429 | + $wpdb->prepare( | |
| 430 | + "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", | |
| 431 | + array($val['htmlvar_name'], $listing_type, $val['field_type']) | |
| 432 | + ) | |
| 433 | + ); | |
| 434 | 434 | |
| 435 | - $display = $check_html_variable ? ' style="display:none;"' : ''; | |
| 436 | - ?> | |
| 435 | + $display = $check_html_variable ? ' style="display:none;"' : ''; | |
| 436 | + ?> | |
| 437 | 437 | <li <?php echo $display;?>> | 
| 438 | 438 | <a id="gt-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" | 
| 439 | 439 | title="<?php echo $val['site_title'];?>" | 
| @@ -441,8 +441,8 @@ discard block | ||
| 441 | 441 | href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory');?></a> | 
| 442 | 442 | </li> | 
| 443 | 443 | <?php | 
| 444 | - } | |
| 445 | - ?> | |
| 444 | + } | |
| 445 | + ?> | |
| 446 | 446 | </ul> | 
| 447 | 447 | <?php | 
| 448 | 448 | } | 
| @@ -456,28 +456,28 @@ discard block | ||
| 456 | 456 | */ | 
| 457 | 457 | function geodir_sorting_options_selected_fields() | 
| 458 | 458 |  {
 | 
| 459 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 460 | - ?> | |
| 459 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 460 | + ?> | |
| 461 | 461 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> | 
| 462 | 462 | <ul class="core"> | 
| 463 | 463 | <?php | 
| 464 | - global $wpdb; | |
| 464 | + global $wpdb; | |
| 465 | 465 | |
| 466 | -        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
 | |
| 466 | +		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
 | |
| 467 | 467 | |
| 468 | -        if (!empty($fields)) {
 | |
| 469 | -            foreach ($fields as $field) {
 | |
| 470 | - //$result_str = $field->id; | |
| 471 | - $result_str = $field; | |
| 472 | - $field_type = $field->field_type; | |
| 473 | - $field_ins_upd = 'display'; | |
| 468 | +		if (!empty($fields)) {
 | |
| 469 | +			foreach ($fields as $field) {
 | |
| 470 | + //$result_str = $field->id; | |
| 471 | + $result_str = $field; | |
| 472 | + $field_type = $field->field_type; | |
| 473 | + $field_ins_upd = 'display'; | |
| 474 | 474 | |
| 475 | - $default = false; | |
| 475 | + $default = false; | |
| 476 | 476 | |
| 477 | - geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default); | |
| 478 | - } | |
| 479 | - } | |
| 480 | - ?> | |
| 477 | + geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default); | |
| 478 | + } | |
| 479 | + } | |
| 480 | + ?> | |
| 481 | 481 | </ul> | 
| 482 | 482 | <?php | 
| 483 | 483 | } | 
| @@ -490,8 +490,8 @@ discard block | ||
| 490 | 490 | */ | 
| 491 | 491 | function geodir_custom_available_fields() | 
| 492 | 492 |  {
 | 
| 493 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 494 | - ?> | |
| 493 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 494 | + ?> | |
| 495 | 495 | <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> | 
| 496 | 496 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> | 
| 497 | 497 | <ul class="full"> | 
| @@ -542,25 +542,25 @@ discard block | ||
| 542 | 542 | */ | 
| 543 | 543 | function geodir_custom_selected_fields() | 
| 544 | 544 |  {
 | 
| 545 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 546 | - ?> | |
| 545 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | |
| 546 | + ?> | |
| 547 | 547 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> | 
| 548 | 548 | <ul class="core"> | 
| 549 | 549 | <?php | 
| 550 | - global $wpdb; | |
| 551 | -        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
 | |
| 552 | - | |
| 553 | -        if (!empty($fields)) {
 | |
| 554 | -            foreach ($fields as $field) {
 | |
| 555 | - //$result_str = $field->id; | |
| 556 | - $result_str = $field; | |
| 557 | - $field_type = $field->field_type; | |
| 558 | - $field_ins_upd = 'display'; | |
| 559 | - | |
| 560 | - geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd); | |
| 561 | - } | |
| 562 | - } | |
| 563 | - ?></ul> | |
| 550 | + global $wpdb; | |
| 551 | +		$fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
 | |
| 552 | + | |
| 553 | +		if (!empty($fields)) {
 | |
| 554 | +			foreach ($fields as $field) {
 | |
| 555 | + //$result_str = $field->id; | |
| 556 | + $result_str = $field; | |
| 557 | + $field_type = $field->field_type; | |
| 558 | + $field_ins_upd = 'display'; | |
| 559 | + | |
| 560 | + geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd); | |
| 561 | + } | |
| 562 | + } | |
| 563 | + ?></ul> | |
| 564 | 564 | <?php | 
| 565 | 565 | |
| 566 | 566 | } | 
| @@ -579,16 +579,16 @@ discard block | ||
| 579 | 579 | function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type) | 
| 580 | 580 |  {
 | 
| 581 | 581 | |
| 582 | -    switch ($sub_tab) {
 | |
| 583 | - case 'custom_fields': | |
| 584 | -            $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 585 | - break; | |
| 582 | +	switch ($sub_tab) {
 | |
| 583 | + case 'custom_fields': | |
| 584 | +			$heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 585 | + break; | |
| 586 | 586 | |
| 587 | - case 'sorting_options': | |
| 588 | -            $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 589 | - break; | |
| 590 | - } | |
| 591 | - return $heading; | |
| 587 | + case 'sorting_options': | |
| 588 | +			$heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 589 | + break; | |
| 590 | + } | |
| 591 | + return $heading; | |
| 592 | 592 | } | 
| 593 | 593 | |
| 594 | 594 | |
| @@ -606,16 +606,16 @@ discard block | ||
| 606 | 606 | function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type) | 
| 607 | 607 |  {
 | 
| 608 | 608 | |
| 609 | -    switch ($sub_tab) {
 | |
| 610 | - case 'custom_fields': | |
| 611 | -            $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 612 | - break; | |
| 609 | +	switch ($sub_tab) {
 | |
| 610 | + case 'custom_fields': | |
| 611 | +			$heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 612 | + break; | |
| 613 | 613 | |
| 614 | - case 'sorting_options': | |
| 615 | -            $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 616 | - break; | |
| 617 | - } | |
| 618 | - return $heading; | |
| 614 | + case 'sorting_options': | |
| 615 | +			$heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 616 | + break; | |
| 617 | + } | |
| 618 | + return $heading; | |
| 619 | 619 | } | 
| 620 | 620 | |
| 621 | 621 | |
| @@ -633,16 +633,16 @@ discard block | ||
| 633 | 633 | function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type) | 
| 634 | 634 |  {
 | 
| 635 | 635 | |
| 636 | -    switch ($sub_tab) {
 | |
| 637 | - case 'custom_fields': | |
| 638 | -            $note = sprintf(__('Click on any box below to add a field of that type on add %s listing form. You must be use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type));;
 | |
| 639 | - break; | |
| 636 | +	switch ($sub_tab) {
 | |
| 637 | + case 'custom_fields': | |
| 638 | +			$note = sprintf(__('Click on any box below to add a field of that type on add %s listing form. You must be use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type));;
 | |
| 639 | + break; | |
| 640 | 640 | |
| 641 | - case 'sorting_options': | |
| 642 | -            $note = sprintf(__('Click on any box below to make it appear in sorting option dropdown on %s listing and search results.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 643 | - break; | |
| 644 | - } | |
| 645 | - return $note; | |
| 641 | + case 'sorting_options': | |
| 642 | +			$note = sprintf(__('Click on any box below to make it appear in sorting option dropdown on %s listing and search results.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 643 | + break; | |
| 644 | + } | |
| 645 | + return $note; | |
| 646 | 646 | } | 
| 647 | 647 | |
| 648 | 648 | |
| @@ -660,16 +660,16 @@ discard block | ||
| 660 | 660 | function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type) | 
| 661 | 661 |  {
 | 
| 662 | 662 | |
| 663 | -    switch ($sub_tab) {
 | |
| 664 | - case 'custom_fields': | |
| 665 | -            $heading = sprintf(__('List of fields those will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 666 | - break; | |
| 663 | +	switch ($sub_tab) {
 | |
| 664 | + case 'custom_fields': | |
| 665 | +			$heading = sprintf(__('List of fields those will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 666 | + break; | |
| 667 | 667 | |
| 668 | - case 'sorting_options': | |
| 669 | -            $heading = sprintf(__('List of fields those will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 670 | - break; | |
| 671 | - } | |
| 672 | - return $heading; | |
| 668 | + case 'sorting_options': | |
| 669 | +			$heading = sprintf(__('List of fields those will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 670 | + break; | |
| 671 | + } | |
| 672 | + return $heading; | |
| 673 | 673 | } | 
| 674 | 674 | |
| 675 | 675 | |
| @@ -687,16 +687,16 @@ discard block | ||
| 687 | 687 | function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type) | 
| 688 | 688 |  {
 | 
| 689 | 689 | |
| 690 | -    switch ($sub_tab) {
 | |
| 691 | - case 'custom_fields': | |
| 692 | -            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type));;
 | |
| 693 | - break; | |
| 690 | +	switch ($sub_tab) {
 | |
| 691 | + case 'custom_fields': | |
| 692 | +			$note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type));;
 | |
| 693 | + break; | |
| 694 | 694 | |
| 695 | - case 'sorting_options': | |
| 696 | -            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 697 | - break; | |
| 698 | - } | |
| 699 | - return $note; | |
| 695 | + case 'sorting_options': | |
| 696 | +			$note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type));
 | |
| 697 | + break; | |
| 698 | + } | |
| 699 | + return $note; | |
| 700 | 700 | } | 
| 701 | 701 | |
| 702 | 702 | |
| @@ -712,16 +712,16 @@ discard block | ||
| 712 | 712 | */ | 
| 713 | 713 | function geodir_remove_unnecessary_fields() | 
| 714 | 714 |  {
 | 
| 715 | - global $wpdb, $plugin_prefix; | |
| 715 | + global $wpdb, $plugin_prefix; | |
| 716 | 716 | |
| 717 | -    if (!get_option('geodir_remove_unnecessary_fields')) {
 | |
| 717 | +	if (!get_option('geodir_remove_unnecessary_fields')) {
 | |
| 718 | 718 | |
| 719 | -        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
 | |
| 720 | -            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
 | |
| 719 | +		if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
 | |
| 720 | +			$wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
 | |
| 721 | 721 | |
| 722 | -        update_option('geodir_remove_unnecessary_fields', '1');
 | |
| 722 | +		update_option('geodir_remove_unnecessary_fields', '1');
 | |
| 723 | 723 | |
| 724 | - } | |
| 724 | + } | |
| 725 | 725 | |
| 726 | 726 | } | 
| 727 | 727 | |
| @@ -739,25 +739,25 @@ discard block | ||
| 739 | 739 | */ | 
| 740 | 740 | function geodir_admin_ajax_handler() | 
| 741 | 741 |  {
 | 
| 742 | -    if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
 | |
| 743 | - $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action']; | |
| 744 | -        switch ($geodir_admin_ajax_action) {
 | |
| 745 | - case 'diagnosis' : | |
| 746 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') | |
| 747 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | |
| 748 | -                call_user_func('geodir_diagnose_' . $diagnose_this);
 | |
| 749 | - exit(); | |
| 750 | - break; | |
| 751 | - | |
| 752 | - case 'diagnosis-fix' : | |
| 753 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') | |
| 754 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | |
| 755 | -                call_user_func('geodir_diagnose_' . $diagnose_this);
 | |
| 756 | - exit(); | |
| 757 | - break; | |
| 758 | - } | |
| 759 | - } | |
| 760 | - exit(); | |
| 742 | +	if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
 | |
| 743 | + $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action']; | |
| 744 | +		switch ($geodir_admin_ajax_action) {
 | |
| 745 | + case 'diagnosis' : | |
| 746 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') | |
| 747 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | |
| 748 | +				call_user_func('geodir_diagnose_' . $diagnose_this);
 | |
| 749 | + exit(); | |
| 750 | + break; | |
| 751 | + | |
| 752 | + case 'diagnosis-fix' : | |
| 753 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') | |
| 754 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | |
| 755 | +				call_user_func('geodir_diagnose_' . $diagnose_this);
 | |
| 756 | + exit(); | |
| 757 | + break; | |
| 758 | + } | |
| 759 | + } | |
| 760 | + exit(); | |
| 761 | 761 | } | 
| 762 | 762 | |
| 763 | 763 | |
| @@ -775,127 +775,127 @@ discard block | ||
| 775 | 775 | */ | 
| 776 | 776 | function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix) | 
| 777 | 777 |  {
 | 
| 778 | - global $wpdb; | |
| 779 | - //$filter_arr['output_str'] .='###'.$table.'###'; | |
| 780 | -    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
 | |
| 781 | -        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
 | |
| 782 | - $filter_arr['is_error_during_diagnose'] = true; | |
| 783 | - | |
| 784 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
 | |
| 785 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 786 | - $filter_arr['is_error_during_diagnose'] = true; | |
| 787 | -        $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
 | |
| 788 | - $filter_arr['is_error_during_diagnose'] = true; | |
| 789 | - | |
| 790 | -        if ($fix) {
 | |
| 791 | -            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
 | |
| 792 | -            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
 | |
| 793 | - | |
| 794 | -            if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
 | |
| 795 | -                //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
 | |
| 796 | - | |
| 797 | -                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
 | |
| 798 | - | |
| 799 | -                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
 | |
| 800 | -                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
 | |
| 801 | -                } else {
 | |
| 802 | -                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 803 | - } | |
| 804 | - | |
| 805 | -            } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
 | |
| 806 | - | |
| 807 | -                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
 | |
| 808 | -                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
 | |
| 809 | - | |
| 810 | -                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 811 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
 | |
| 812 | -                } else {
 | |
| 813 | -                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 814 | - } | |
| 815 | - | |
| 816 | -            } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
 | |
| 817 | - | |
| 818 | -                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
 | |
| 819 | - | |
| 820 | -                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
 | |
| 821 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
 | |
| 822 | -                } else {
 | |
| 823 | -                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 824 | - } | |
| 825 | - | |
| 826 | - } | |
| 827 | - | |
| 828 | - } | |
| 829 | - | |
| 830 | - | |
| 831 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
 | |
| 832 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 833 | - $filter_arr['is_error_during_diagnose'] = true; | |
| 834 | - | |
| 835 | -        if ($fix) {
 | |
| 836 | -            if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
 | |
| 837 | -                if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
 | |
| 838 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
 | |
| 839 | -                } else {
 | |
| 840 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
 | |
| 841 | - } | |
| 842 | - | |
| 843 | -            } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
 | |
| 844 | -                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
 | |
| 845 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
 | |
| 846 | -                } else {
 | |
| 847 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
 | |
| 848 | - } | |
| 849 | -                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 850 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 851 | -                } else {
 | |
| 852 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 853 | - } | |
| 854 | -            } else {// else rename the original table to _ms_bak
 | |
| 855 | -                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 856 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
 | |
| 857 | -                } else {
 | |
| 858 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
 | |
| 859 | - } | |
| 860 | - } | |
| 861 | - } | |
| 862 | - | |
| 863 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
 | |
| 864 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 865 | - $filter_arr['is_error_during_diagnose'] = true; | |
| 866 | - | |
| 867 | -        if ($fix) {
 | |
| 868 | - // if original table exists but new does not, rename | |
| 869 | -            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 870 | -                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 871 | -            } else {
 | |
| 872 | -                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 873 | - } | |
| 874 | - | |
| 875 | - } | |
| 876 | - | |
| 877 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
 | |
| 878 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 879 | - $filter_arr['is_error_during_diagnose'] = true; | |
| 880 | - | |
| 881 | -        if ($fix) {
 | |
| 882 | - // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run; | |
| 883 | -            delete_option('geodirlocation_db_version');
 | |
| 884 | -            delete_option('geodirevents_db_version');
 | |
| 885 | -            delete_option('geodir_reviewrating_db_version');
 | |
| 886 | -            delete_option('gdevents_db_version');
 | |
| 887 | -            delete_option('geodirectory_db_version');
 | |
| 888 | -            delete_option('geodirclaim_db_version');
 | |
| 889 | -            delete_option('geodir_custom_posts_db_version');
 | |
| 890 | -            delete_option('geodir_reviewratings_db_version');
 | |
| 891 | -            delete_option('geodiradvancesearch_db_version');
 | |
| 892 | -            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
 | |
| 893 | - } | |
| 894 | - | |
| 895 | -    } else {
 | |
| 896 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 897 | - } | |
| 898 | - return $filter_arr; | |
| 778 | + global $wpdb; | |
| 779 | + //$filter_arr['output_str'] .='###'.$table.'###'; | |
| 780 | +	if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
 | |
| 781 | +		$filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
 | |
| 782 | + $filter_arr['is_error_during_diagnose'] = true; | |
| 783 | + | |
| 784 | +	} elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
 | |
| 785 | +		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 786 | + $filter_arr['is_error_during_diagnose'] = true; | |
| 787 | +		$filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
 | |
| 788 | + $filter_arr['is_error_during_diagnose'] = true; | |
| 789 | + | |
| 790 | +		if ($fix) {
 | |
| 791 | +			$ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
 | |
| 792 | +			$new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
 | |
| 793 | + | |
| 794 | +			if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
 | |
| 795 | +				//$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
 | |
| 796 | + | |
| 797 | +				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
 | |
| 798 | + | |
| 799 | +				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
 | |
| 800 | +					$filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
 | |
| 801 | +				} else {
 | |
| 802 | +					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 803 | + } | |
| 804 | + | |
| 805 | +			} elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
 | |
| 806 | + | |
| 807 | +				$wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
 | |
| 808 | +				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
 | |
| 809 | + | |
| 810 | +				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 811 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
 | |
| 812 | +				} else {
 | |
| 813 | +					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 814 | + } | |
| 815 | + | |
| 816 | +			} elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
 | |
| 817 | + | |
| 818 | +				$wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
 | |
| 819 | + | |
| 820 | +				if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
 | |
| 821 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
 | |
| 822 | +				} else {
 | |
| 823 | +					$filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 824 | + } | |
| 825 | + | |
| 826 | + } | |
| 827 | + | |
| 828 | + } | |
| 829 | + | |
| 830 | + | |
| 831 | +	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
 | |
| 832 | +		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 833 | + $filter_arr['is_error_during_diagnose'] = true; | |
| 834 | + | |
| 835 | +		if ($fix) {
 | |
| 836 | +			if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
 | |
| 837 | +				if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
 | |
| 838 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
 | |
| 839 | +				} else {
 | |
| 840 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
 | |
| 841 | + } | |
| 842 | + | |
| 843 | +			} elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
 | |
| 844 | +				if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
 | |
| 845 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
 | |
| 846 | +				} else {
 | |
| 847 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
 | |
| 848 | + } | |
| 849 | +				if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 850 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 851 | +				} else {
 | |
| 852 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 853 | + } | |
| 854 | +			} else {// else rename the original table to _ms_bak
 | |
| 855 | +				if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 856 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
 | |
| 857 | +				} else {
 | |
| 858 | +					$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
 | |
| 859 | + } | |
| 860 | + } | |
| 861 | + } | |
| 862 | + | |
| 863 | +	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
 | |
| 864 | +		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 865 | + $filter_arr['is_error_during_diagnose'] = true; | |
| 866 | + | |
| 867 | +		if ($fix) {
 | |
| 868 | + // if original table exists but new does not, rename | |
| 869 | +			if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 870 | +				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 871 | +			} else {
 | |
| 872 | +				$filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 873 | + } | |
| 874 | + | |
| 875 | + } | |
| 876 | + | |
| 877 | +	} elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
 | |
| 878 | +		$filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 879 | + $filter_arr['is_error_during_diagnose'] = true; | |
| 880 | + | |
| 881 | +		if ($fix) {
 | |
| 882 | + // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run; | |
| 883 | +			delete_option('geodirlocation_db_version');
 | |
| 884 | +			delete_option('geodirevents_db_version');
 | |
| 885 | +			delete_option('geodir_reviewrating_db_version');
 | |
| 886 | +			delete_option('gdevents_db_version');
 | |
| 887 | +			delete_option('geodirectory_db_version');
 | |
| 888 | +			delete_option('geodirclaim_db_version');
 | |
| 889 | +			delete_option('geodir_custom_posts_db_version');
 | |
| 890 | +			delete_option('geodir_reviewratings_db_version');
 | |
| 891 | +			delete_option('geodiradvancesearch_db_version');
 | |
| 892 | +			$filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
 | |
| 893 | + } | |
| 894 | + | |
| 895 | +	} else {
 | |
| 896 | +		$filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 897 | + } | |
| 898 | + return $filter_arr; | |
| 899 | 899 | } | 
| 900 | 900 | |
| 901 | 901 | |
| @@ -909,53 +909,53 @@ discard block | ||
| 909 | 909 | */ | 
| 910 | 910 | function geodir_diagnose_tags_sync() | 
| 911 | 911 |  {
 | 
| 912 | - global $wpdb, $plugin_prefix; | |
| 913 | - $fix = isset($_POST['fix']) ? true : false; | |
| 914 | - | |
| 915 | -    //if($fix){echo 'true';}else{echo 'false';}
 | |
| 916 | - $is_error_during_diagnose = false; | |
| 917 | - $output_str = ''; | |
| 918 | - | |
| 919 | - | |
| 920 | - $all_postypes = geodir_get_posttypes(); | |
| 921 | - | |
| 922 | -    if (!empty($all_postypes)) {
 | |
| 923 | -        foreach ($all_postypes as $key) {
 | |
| 924 | - // update each GD CPT | |
| 925 | -            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
 | |
| 926 | - | |
| 927 | -            if (!empty($posts)) {
 | |
| 928 | - | |
| 929 | -                foreach ($posts as $p) {
 | |
| 930 | - $p->post_type = $key; | |
| 931 | -                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
 | |
| 932 | -                    if (empty($raw_tags)) {
 | |
| 933 | - $post_tags = ''; | |
| 934 | -                    } else {
 | |
| 935 | -                        $post_tags = implode(",", $raw_tags);
 | |
| 936 | - } | |
| 937 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; | |
| 938 | -                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
 | |
| 939 | - | |
| 940 | - } | |
| 941 | -                $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
 | |
| 942 | - } | |
| 943 | - | |
| 944 | - } | |
| 945 | - | |
| 946 | - } | |
| 947 | - | |
| 948 | -    if ($is_error_during_diagnose) {
 | |
| 949 | - $info_div_class = "geodir_problem_info"; | |
| 950 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 951 | -    } else {
 | |
| 952 | - $info_div_class = "geodir_noproblem_info"; | |
| 953 | - $fix_button_txt = ''; | |
| 954 | - } | |
| 955 | - echo "<ul class='$info_div_class'>"; | |
| 956 | - echo $output_str; | |
| 957 | - echo $fix_button_txt; | |
| 958 | - echo "</ul>"; | |
| 912 | + global $wpdb, $plugin_prefix; | |
| 913 | + $fix = isset($_POST['fix']) ? true : false; | |
| 914 | + | |
| 915 | +	//if($fix){echo 'true';}else{echo 'false';}
 | |
| 916 | + $is_error_during_diagnose = false; | |
| 917 | + $output_str = ''; | |
| 918 | + | |
| 919 | + | |
| 920 | + $all_postypes = geodir_get_posttypes(); | |
| 921 | + | |
| 922 | +	if (!empty($all_postypes)) {
 | |
| 923 | +		foreach ($all_postypes as $key) {
 | |
| 924 | + // update each GD CPT | |
| 925 | +			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
 | |
| 926 | + | |
| 927 | +			if (!empty($posts)) {
 | |
| 928 | + | |
| 929 | +				foreach ($posts as $p) {
 | |
| 930 | + $p->post_type = $key; | |
| 931 | +					$raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
 | |
| 932 | +					if (empty($raw_tags)) {
 | |
| 933 | + $post_tags = ''; | |
| 934 | +					} else {
 | |
| 935 | +						$post_tags = implode(",", $raw_tags);
 | |
| 936 | + } | |
| 937 | + $tablename = $plugin_prefix . $p->post_type . '_detail'; | |
| 938 | +					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
 | |
| 939 | + | |
| 940 | + } | |
| 941 | +				$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
 | |
| 942 | + } | |
| 943 | + | |
| 944 | + } | |
| 945 | + | |
| 946 | + } | |
| 947 | + | |
| 948 | +	if ($is_error_during_diagnose) {
 | |
| 949 | + $info_div_class = "geodir_problem_info"; | |
| 950 | +		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 951 | +	} else {
 | |
| 952 | + $info_div_class = "geodir_noproblem_info"; | |
| 953 | + $fix_button_txt = ''; | |
| 954 | + } | |
| 955 | + echo "<ul class='$info_div_class'>"; | |
| 956 | + echo $output_str; | |
| 957 | + echo $fix_button_txt; | |
| 958 | + echo "</ul>"; | |
| 959 | 959 | |
| 960 | 960 | } | 
| 961 | 961 | |
| @@ -971,75 +971,75 @@ discard block | ||
| 971 | 971 | */ | 
| 972 | 972 | function geodir_diagnose_cats_sync() | 
| 973 | 973 |  {
 | 
| 974 | - global $wpdb, $plugin_prefix; | |
| 975 | - $fix = isset($_POST['fix']) ? true : false; | |
| 974 | + global $wpdb, $plugin_prefix; | |
| 975 | + $fix = isset($_POST['fix']) ? true : false; | |
| 976 | 976 | |
| 977 | -    //if($fix){echo 'true';}else{echo 'false';}
 | |
| 978 | - $is_error_during_diagnose = false; | |
| 979 | - $output_str = ''; | |
| 977 | +	//if($fix){echo 'true';}else{echo 'false';}
 | |
| 978 | + $is_error_during_diagnose = false; | |
| 979 | + $output_str = ''; | |
| 980 | 980 | |
| 981 | 981 | |
| 982 | - $all_postypes = geodir_get_posttypes(); | |
| 982 | + $all_postypes = geodir_get_posttypes(); | |
| 983 | 983 | |
| 984 | -    if (!empty($all_postypes)) {
 | |
| 985 | -        foreach ($all_postypes as $key) {
 | |
| 986 | - // update each GD CTP | |
| 987 | -            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
 | |
| 984 | +	if (!empty($all_postypes)) {
 | |
| 985 | +		foreach ($all_postypes as $key) {
 | |
| 986 | + // update each GD CTP | |
| 987 | +			$posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
 | |
| 988 | 988 | |
| 989 | -            if (!empty($posts)) {
 | |
| 989 | +			if (!empty($posts)) {
 | |
| 990 | 990 | |
| 991 | -                foreach ($posts as $p) {
 | |
| 992 | - $p->post_type = $key; | |
| 993 | -                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
 | |
| 991 | +				foreach ($posts as $p) {
 | |
| 992 | + $p->post_type = $key; | |
| 993 | +					$raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
 | |
| 994 | 994 | |
| 995 | -                    if (empty($raw_cats)) {
 | |
| 996 | - $post_categories = get_post_meta($p->post_id, 'post_categories', true); | |
| 995 | +					if (empty($raw_cats)) {
 | |
| 996 | + $post_categories = get_post_meta($p->post_id, 'post_categories', true); | |
| 997 | 997 | |
| 998 | -                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
 | |
| 999 | -                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
 | |
| 1000 | -                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
 | |
| 1001 | -                                if (is_numeric($cat_part)) {
 | |
| 1002 | - $raw_cats[] = (int)$cat_part; | |
| 1003 | - } | |
| 1004 | - } | |
| 998 | +						if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
 | |
| 999 | +							$post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
 | |
| 1000 | +							foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
 | |
| 1001 | +								if (is_numeric($cat_part)) {
 | |
| 1002 | + $raw_cats[] = (int)$cat_part; | |
| 1003 | + } | |
| 1004 | + } | |
| 1005 | 1005 | |
| 1006 | - } | |
| 1006 | + } | |
| 1007 | 1007 | |
| 1008 | -                        if (!empty($raw_cats)) {
 | |
| 1009 | - $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); | |
| 1008 | +						if (!empty($raw_cats)) {
 | |
| 1009 | + $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); | |
| 1010 | 1010 | |
| 1011 | - } | |
| 1011 | + } | |
| 1012 | 1012 | |
| 1013 | - } | |
| 1013 | + } | |
| 1014 | 1014 | |
| 1015 | 1015 | |
| 1016 | -                    if (empty($raw_cats)) {
 | |
| 1017 | - $post_cats = ''; | |
| 1018 | -                    } else {
 | |
| 1019 | -                        $post_cats = ',' . implode(",", $raw_cats) . ',';
 | |
| 1020 | - } | |
| 1021 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; | |
| 1022 | -                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
 | |
| 1023 | - } | |
| 1016 | +					if (empty($raw_cats)) {
 | |
| 1017 | + $post_cats = ''; | |
| 1018 | +					} else {
 | |
| 1019 | +						$post_cats = ',' . implode(",", $raw_cats) . ',';
 | |
| 1020 | + } | |
| 1021 | + $tablename = $plugin_prefix . $p->post_type . '_detail'; | |
| 1022 | +					$wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
 | |
| 1023 | + } | |
| 1024 | 1024 | |
| 1025 | - } | |
| 1026 | -            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
 | |
| 1025 | + } | |
| 1026 | +			$output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
 | |
| 1027 | 1027 | |
| 1028 | - } | |
| 1028 | + } | |
| 1029 | 1029 | |
| 1030 | - } | |
| 1030 | + } | |
| 1031 | 1031 | |
| 1032 | -    if ($is_error_during_diagnose) {
 | |
| 1033 | - $info_div_class = "geodir_problem_info"; | |
| 1034 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1035 | -    } else {
 | |
| 1036 | - $info_div_class = "geodir_noproblem_info"; | |
| 1037 | - $fix_button_txt = ''; | |
| 1038 | - } | |
| 1039 | - echo "<ul class='$info_div_class'>"; | |
| 1040 | - echo $output_str; | |
| 1041 | - echo $fix_button_txt; | |
| 1042 | - echo "</ul>"; | |
| 1032 | +	if ($is_error_during_diagnose) {
 | |
| 1033 | + $info_div_class = "geodir_problem_info"; | |
| 1034 | +		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1035 | +	} else {
 | |
| 1036 | + $info_div_class = "geodir_noproblem_info"; | |
| 1037 | + $fix_button_txt = ''; | |
| 1038 | + } | |
| 1039 | + echo "<ul class='$info_div_class'>"; | |
| 1040 | + echo $output_str; | |
| 1041 | + echo $fix_button_txt; | |
| 1042 | + echo "</ul>"; | |
| 1043 | 1043 | |
| 1044 | 1044 | } | 
| 1045 | 1045 | |
| @@ -1053,61 +1053,61 @@ discard block | ||
| 1053 | 1053 | */ | 
| 1054 | 1054 | function geodir_diagnose_version_clear() | 
| 1055 | 1055 |  {
 | 
| 1056 | - global $wpdb, $plugin_prefix; | |
| 1057 | - $fix = isset($_POST['fix']) ? true : false; | |
| 1058 | - | |
| 1059 | -    //if($fix){echo 'true';}else{echo 'false';}
 | |
| 1060 | - $is_error_during_diagnose = false; | |
| 1061 | - $output_str = ''; | |
| 1062 | - | |
| 1063 | - | |
| 1064 | -    $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
 | |
| 1065 | - 'Payment Manager' => 'geodir_payments_db_version', | |
| 1066 | - 'GeoDirectory Framework' => 'gdf_db_version', | |
| 1067 | - 'Advanced Search' => 'geodiradvancesearch_db_version', | |
| 1068 | - 'Review Rating Manager' => 'geodir_reviewratings_db_version', | |
| 1069 | - 'Claim Manager' => 'geodirclaim_db_version', | |
| 1070 | - 'CPT Manager' => 'geodir_custom_posts_db_version', | |
| 1071 | - 'Location Manager' => 'geodirlocation_db_version', | |
| 1072 | - 'Payment Manager' => 'geodir_payments_db_version', | |
| 1073 | - 'Events Manager' => 'geodirevents_db_version', | |
| 1074 | - ); | |
| 1075 | - | |
| 1076 | - /** | |
| 1077 | - * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers. | |
| 1078 | - * | |
| 1079 | - * @since 1.0.0 | |
| 1080 | -     * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
 | |
| 1081 | - */ | |
| 1082 | -    $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
 | |
| 1083 | - | |
| 1084 | -    if (!empty($ver_arr)) {
 | |
| 1085 | -        foreach ($ver_arr as $key => $val) {
 | |
| 1086 | -            if (delete_option($val)) {
 | |
| 1087 | -                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
 | |
| 1088 | -            } else {
 | |
| 1089 | -                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
 | |
| 1090 | - } | |
| 1091 | - | |
| 1092 | - } | |
| 1093 | - | |
| 1094 | -        if ($output_str) {
 | |
| 1095 | -            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
 | |
| 1096 | - } | |
| 1097 | - | |
| 1098 | - } | |
| 1099 | - | |
| 1100 | -    if ($is_error_during_diagnose) {
 | |
| 1101 | - $info_div_class = "geodir_problem_info"; | |
| 1102 | - $fix_button_txt = ""; | |
| 1103 | -    } else {
 | |
| 1104 | - $info_div_class = "geodir_noproblem_info"; | |
| 1105 | - $fix_button_txt = ''; | |
| 1106 | - } | |
| 1107 | - echo "<ul class='$info_div_class'>"; | |
| 1108 | - echo $output_str; | |
| 1109 | - echo $fix_button_txt; | |
| 1110 | - echo "</ul>"; | |
| 1056 | + global $wpdb, $plugin_prefix; | |
| 1057 | + $fix = isset($_POST['fix']) ? true : false; | |
| 1058 | + | |
| 1059 | +	//if($fix){echo 'true';}else{echo 'false';}
 | |
| 1060 | + $is_error_during_diagnose = false; | |
| 1061 | + $output_str = ''; | |
| 1062 | + | |
| 1063 | + | |
| 1064 | +	$gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
 | |
| 1065 | + 'Payment Manager' => 'geodir_payments_db_version', | |
| 1066 | + 'GeoDirectory Framework' => 'gdf_db_version', | |
| 1067 | + 'Advanced Search' => 'geodiradvancesearch_db_version', | |
| 1068 | + 'Review Rating Manager' => 'geodir_reviewratings_db_version', | |
| 1069 | + 'Claim Manager' => 'geodirclaim_db_version', | |
| 1070 | + 'CPT Manager' => 'geodir_custom_posts_db_version', | |
| 1071 | + 'Location Manager' => 'geodirlocation_db_version', | |
| 1072 | + 'Payment Manager' => 'geodir_payments_db_version', | |
| 1073 | + 'Events Manager' => 'geodirevents_db_version', | |
| 1074 | + ); | |
| 1075 | + | |
| 1076 | + /** | |
| 1077 | + * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers. | |
| 1078 | + * | |
| 1079 | + * @since 1.0.0 | |
| 1080 | +	 * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
 | |
| 1081 | + */ | |
| 1082 | +	$ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
 | |
| 1083 | + | |
| 1084 | +	if (!empty($ver_arr)) {
 | |
| 1085 | +		foreach ($ver_arr as $key => $val) {
 | |
| 1086 | +			if (delete_option($val)) {
 | |
| 1087 | +				$output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
 | |
| 1088 | +			} else {
 | |
| 1089 | +				$output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
 | |
| 1090 | + } | |
| 1091 | + | |
| 1092 | + } | |
| 1093 | + | |
| 1094 | +		if ($output_str) {
 | |
| 1095 | +			$output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
 | |
| 1096 | + } | |
| 1097 | + | |
| 1098 | + } | |
| 1099 | + | |
| 1100 | +	if ($is_error_during_diagnose) {
 | |
| 1101 | + $info_div_class = "geodir_problem_info"; | |
| 1102 | + $fix_button_txt = ""; | |
| 1103 | +	} else {
 | |
| 1104 | + $info_div_class = "geodir_noproblem_info"; | |
| 1105 | + $fix_button_txt = ''; | |
| 1106 | + } | |
| 1107 | + echo "<ul class='$info_div_class'>"; | |
| 1108 | + echo $output_str; | |
| 1109 | + echo $fix_button_txt; | |
| 1110 | + echo "</ul>"; | |
| 1111 | 1111 | |
| 1112 | 1112 | } | 
| 1113 | 1113 | |
| @@ -1121,59 +1121,59 @@ discard block | ||
| 1121 | 1121 | */ | 
| 1122 | 1122 | function geodir_diagnose_ratings() | 
| 1123 | 1123 |  {
 | 
| 1124 | - global $wpdb; | |
| 1125 | - $fix = isset($_POST['fix']) ? true : false; | |
| 1126 | - | |
| 1127 | -    //if($fix){echo 'true';}else{echo 'false';}
 | |
| 1128 | - $is_error_during_diagnose = false; | |
| 1129 | - $output_str = ''; | |
| 1130 | - | |
| 1131 | - // check review locations | |
| 1132 | -    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
 | |
| 1133 | -        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
 | |
| 1134 | - $is_error_during_diagnose = true; | |
| 1135 | - | |
| 1136 | -        if ($fix) {
 | |
| 1137 | -            if (geodir_fix_review_location()) {
 | |
| 1138 | -                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
 | |
| 1139 | -            } else {
 | |
| 1140 | -                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1141 | - } | |
| 1142 | - } | |
| 1143 | - | |
| 1144 | -    } else {
 | |
| 1145 | -        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
 | |
| 1146 | - } | |
| 1147 | - | |
| 1148 | - // check review content | |
| 1149 | -    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
 | |
| 1150 | -        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
 | |
| 1151 | - $is_error_during_diagnose = true; | |
| 1152 | - | |
| 1153 | -        if ($fix) {
 | |
| 1154 | -            if (geodir_fix_review_content()) {
 | |
| 1155 | -                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
 | |
| 1156 | -            } else {
 | |
| 1157 | -                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1158 | - } | |
| 1159 | - } | |
| 1160 | - | |
| 1161 | -    } else {
 | |
| 1162 | -        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
 | |
| 1163 | - } | |
| 1164 | - | |
| 1165 | - | |
| 1166 | -    if ($is_error_during_diagnose) {
 | |
| 1167 | - $info_div_class = "geodir_problem_info"; | |
| 1168 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1169 | -    } else {
 | |
| 1170 | - $info_div_class = "geodir_noproblem_info"; | |
| 1171 | - $fix_button_txt = ''; | |
| 1172 | - } | |
| 1173 | - echo "<ul class='$info_div_class'>"; | |
| 1174 | - echo $output_str; | |
| 1175 | - echo $fix_button_txt; | |
| 1176 | - echo "</ul>"; | |
| 1124 | + global $wpdb; | |
| 1125 | + $fix = isset($_POST['fix']) ? true : false; | |
| 1126 | + | |
| 1127 | +	//if($fix){echo 'true';}else{echo 'false';}
 | |
| 1128 | + $is_error_during_diagnose = false; | |
| 1129 | + $output_str = ''; | |
| 1130 | + | |
| 1131 | + // check review locations | |
| 1132 | +	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
 | |
| 1133 | +		$output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
 | |
| 1134 | + $is_error_during_diagnose = true; | |
| 1135 | + | |
| 1136 | +		if ($fix) {
 | |
| 1137 | +			if (geodir_fix_review_location()) {
 | |
| 1138 | +				$output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
 | |
| 1139 | +			} else {
 | |
| 1140 | +				$output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1141 | + } | |
| 1142 | + } | |
| 1143 | + | |
| 1144 | +	} else {
 | |
| 1145 | +		$output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
 | |
| 1146 | + } | |
| 1147 | + | |
| 1148 | + // check review content | |
| 1149 | +	if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
 | |
| 1150 | +		$output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
 | |
| 1151 | + $is_error_during_diagnose = true; | |
| 1152 | + | |
| 1153 | +		if ($fix) {
 | |
| 1154 | +			if (geodir_fix_review_content()) {
 | |
| 1155 | +				$output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
 | |
| 1156 | +			} else {
 | |
| 1157 | +				$output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1158 | + } | |
| 1159 | + } | |
| 1160 | + | |
| 1161 | +	} else {
 | |
| 1162 | +		$output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
 | |
| 1163 | + } | |
| 1164 | + | |
| 1165 | + | |
| 1166 | +	if ($is_error_during_diagnose) {
 | |
| 1167 | + $info_div_class = "geodir_problem_info"; | |
| 1168 | +		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1169 | +	} else {
 | |
| 1170 | + $info_div_class = "geodir_noproblem_info"; | |
| 1171 | + $fix_button_txt = ''; | |
| 1172 | + } | |
| 1173 | + echo "<ul class='$info_div_class'>"; | |
| 1174 | + echo $output_str; | |
| 1175 | + echo $fix_button_txt; | |
| 1176 | + echo "</ul>"; | |
| 1177 | 1177 | |
| 1178 | 1178 | } | 
| 1179 | 1179 | |
| @@ -1187,57 +1187,57 @@ discard block | ||
| 1187 | 1187 | */ | 
| 1188 | 1188 | function geodir_diagnose_multisite_conversion() | 
| 1189 | 1189 |  {
 | 
| 1190 | - global $wpdb; | |
| 1191 | - $fix = isset($_POST['fix']) ? true : false; | |
| 1192 | -    //if($fix){echo 'true';}else{echo 'false';}
 | |
| 1193 | - $is_error_during_diagnose = false; | |
| 1194 | - $output_str = ''; | |
| 1195 | - | |
| 1196 | - $filter_arr = array(); | |
| 1197 | - $filter_arr['output_str'] = $output_str; | |
| 1198 | - $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose; | |
| 1199 | -    $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
 | |
| 1200 | -        'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
 | |
| 1201 | -        'geodir_post_icon' => __('Post icon', 'geodirectory'),
 | |
| 1202 | -        'geodir_attachments' => __('Attachments', 'geodirectory'),
 | |
| 1203 | -        'geodir_post_review' => __('Reviews', 'geodirectory'),
 | |
| 1204 | -        'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
 | |
| 1205 | -        'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
 | |
| 1206 | - ); | |
| 1207 | - | |
| 1208 | - // allow other addons to hook in and add their checks | |
| 1209 | - | |
| 1210 | - /** | |
| 1211 | - * Filter the array of tables. | |
| 1212 | - * | |
| 1213 | - * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks. | |
| 1214 | - * | |
| 1215 | - * @since 1.0.0 | |
| 1216 | -     * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
 | |
| 1217 | - */ | |
| 1218 | -    $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
 | |
| 1219 | - | |
| 1220 | -    foreach ($table_arr as $table => $table_name) {
 | |
| 1221 | - // Diagnose table | |
| 1222 | - $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix); | |
| 1223 | - } | |
| 1224 | - | |
| 1225 | - | |
| 1226 | - $output_str = $filter_arr['output_str']; | |
| 1227 | - $is_error_during_diagnose = $filter_arr['is_error_during_diagnose']; | |
| 1228 | - | |
| 1229 | - | |
| 1230 | -    if ($is_error_during_diagnose) {
 | |
| 1231 | - $info_div_class = "geodir_problem_info"; | |
| 1232 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
 | |
| 1233 | -    } else {
 | |
| 1234 | - $info_div_class = "geodir_noproblem_info"; | |
| 1235 | - $fix_button_txt = ''; | |
| 1236 | - } | |
| 1237 | - echo "<ul class='$info_div_class'>"; | |
| 1238 | - echo $output_str; | |
| 1239 | - echo $fix_button_txt; | |
| 1240 | - echo "</ul>"; | |
| 1190 | + global $wpdb; | |
| 1191 | + $fix = isset($_POST['fix']) ? true : false; | |
| 1192 | +	//if($fix){echo 'true';}else{echo 'false';}
 | |
| 1193 | + $is_error_during_diagnose = false; | |
| 1194 | + $output_str = ''; | |
| 1195 | + | |
| 1196 | + $filter_arr = array(); | |
| 1197 | + $filter_arr['output_str'] = $output_str; | |
| 1198 | + $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose; | |
| 1199 | +	$table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
 | |
| 1200 | +		'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
 | |
| 1201 | +		'geodir_post_icon' => __('Post icon', 'geodirectory'),
 | |
| 1202 | +		'geodir_attachments' => __('Attachments', 'geodirectory'),
 | |
| 1203 | +		'geodir_post_review' => __('Reviews', 'geodirectory'),
 | |
| 1204 | +		'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
 | |
| 1205 | +		'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
 | |
| 1206 | + ); | |
| 1207 | + | |
| 1208 | + // allow other addons to hook in and add their checks | |
| 1209 | + | |
| 1210 | + /** | |
| 1211 | + * Filter the array of tables. | |
| 1212 | + * | |
| 1213 | + * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks. | |
| 1214 | + * | |
| 1215 | + * @since 1.0.0 | |
| 1216 | +	 * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
 | |
| 1217 | + */ | |
| 1218 | +	$table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
 | |
| 1219 | + | |
| 1220 | +	foreach ($table_arr as $table => $table_name) {
 | |
| 1221 | + // Diagnose table | |
| 1222 | + $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix); | |
| 1223 | + } | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + $output_str = $filter_arr['output_str']; | |
| 1227 | + $is_error_during_diagnose = $filter_arr['is_error_during_diagnose']; | |
| 1228 | + | |
| 1229 | + | |
| 1230 | +	if ($is_error_during_diagnose) {
 | |
| 1231 | + $info_div_class = "geodir_problem_info"; | |
| 1232 | +		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
 | |
| 1233 | +	} else {
 | |
| 1234 | + $info_div_class = "geodir_noproblem_info"; | |
| 1235 | + $fix_button_txt = ''; | |
| 1236 | + } | |
| 1237 | + echo "<ul class='$info_div_class'>"; | |
| 1238 | + echo $output_str; | |
| 1239 | + echo $fix_button_txt; | |
| 1240 | + echo "</ul>"; | |
| 1241 | 1241 | } | 
| 1242 | 1242 | |
| 1243 | 1243 | /** | 
| @@ -1255,39 +1255,39 @@ discard block | ||
| 1255 | 1255 | */ | 
| 1256 | 1256 | function geodir_fix_virtual_page($slug, $page_title, $old_id, $option) | 
| 1257 | 1257 |  {
 | 
| 1258 | - global $wpdb, $current_user; | |
| 1259 | - | |
| 1260 | -    if (!empty($old_id)) {
 | |
| 1261 | - wp_delete_post($old_id, true); | |
| 1262 | - }//delete post if already there | |
| 1263 | -    else {
 | |
| 1264 | - $page_found = $wpdb->get_var( | |
| 1265 | - $wpdb->prepare( | |
| 1266 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", | |
| 1267 | - array($slug) | |
| 1268 | - ) | |
| 1269 | - ); | |
| 1270 | - wp_delete_post($page_found, true); | |
| 1271 | - | |
| 1272 | - } | |
| 1273 | - | |
| 1274 | - $page_data = array( | |
| 1275 | - 'post_status' => 'publish', | |
| 1276 | - 'post_type' => 'page', | |
| 1277 | - 'post_author' => $current_user->ID, | |
| 1278 | - 'post_name' => $slug, | |
| 1279 | - 'post_title' => $page_title, | |
| 1280 | - 'post_content' => '', | |
| 1281 | - 'post_parent' => 0, | |
| 1282 | - 'comment_status' => 'closed' | |
| 1283 | - ); | |
| 1284 | - $page_id = wp_insert_post($page_data); | |
| 1285 | - update_option($option, $page_id); | |
| 1286 | -    if ($page_id) {
 | |
| 1287 | - return true; | |
| 1288 | -    } else {
 | |
| 1289 | - return false; | |
| 1290 | - } | |
| 1258 | + global $wpdb, $current_user; | |
| 1259 | + | |
| 1260 | +	if (!empty($old_id)) {
 | |
| 1261 | + wp_delete_post($old_id, true); | |
| 1262 | + }//delete post if already there | |
| 1263 | +	else {
 | |
| 1264 | + $page_found = $wpdb->get_var( | |
| 1265 | + $wpdb->prepare( | |
| 1266 | + "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", | |
| 1267 | + array($slug) | |
| 1268 | + ) | |
| 1269 | + ); | |
| 1270 | + wp_delete_post($page_found, true); | |
| 1271 | + | |
| 1272 | + } | |
| 1273 | + | |
| 1274 | + $page_data = array( | |
| 1275 | + 'post_status' => 'publish', | |
| 1276 | + 'post_type' => 'page', | |
| 1277 | + 'post_author' => $current_user->ID, | |
| 1278 | + 'post_name' => $slug, | |
| 1279 | + 'post_title' => $page_title, | |
| 1280 | + 'post_content' => '', | |
| 1281 | + 'post_parent' => 0, | |
| 1282 | + 'comment_status' => 'closed' | |
| 1283 | + ); | |
| 1284 | + $page_id = wp_insert_post($page_data); | |
| 1285 | + update_option($option, $page_id); | |
| 1286 | +	if ($page_id) {
 | |
| 1287 | + return true; | |
| 1288 | +	} else {
 | |
| 1289 | + return false; | |
| 1290 | + } | |
| 1291 | 1291 | } | 
| 1292 | 1292 | |
| 1293 | 1293 | /** | 
| @@ -1299,212 +1299,212 @@ discard block | ||
| 1299 | 1299 | */ | 
| 1300 | 1300 | function geodir_diagnose_default_pages() | 
| 1301 | 1301 |  {
 | 
| 1302 | - global $wpdb; | |
| 1303 | - $is_error_during_diagnose = false; | |
| 1304 | - $output_str = ''; | |
| 1305 | - $fix = isset($_POST['fix']) ? true : false; | |
| 1306 | - | |
| 1307 | - ////////////////////////////////// | |
| 1308 | - /* Diagnose GD Home Page Starts */ | |
| 1309 | - ////////////////////////////////// | |
| 1310 | -    $option_value = get_option('geodir_home_page');
 | |
| 1311 | - $page = get_post($option_value); | |
| 1312 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1313 | - | |
| 1314 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1315 | -        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1316 | -    else {
 | |
| 1317 | - $is_error_during_diagnose = true; | |
| 1318 | -        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1319 | -        if ($fix) {
 | |
| 1320 | -            if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
 | |
| 1321 | -                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1322 | -            } else {
 | |
| 1323 | -                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1324 | - } | |
| 1325 | - } | |
| 1326 | - } | |
| 1327 | - | |
| 1328 | - //////////////////////////////// | |
| 1329 | - /* Diagnose GD Home Page Ends */ | |
| 1330 | - //////////////////////////////// | |
| 1331 | - | |
| 1332 | - ////////////////////////////////// | |
| 1333 | - /* Diagnose Add Listing Page Starts */ | |
| 1334 | - ////////////////////////////////// | |
| 1335 | -    $option_value = get_option('geodir_add_listing_page');
 | |
| 1336 | - $page = get_post($option_value); | |
| 1337 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1338 | - | |
| 1339 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1340 | -        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1341 | -    else {
 | |
| 1342 | - $is_error_during_diagnose = true; | |
| 1343 | -        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1344 | -        if ($fix) {
 | |
| 1345 | -            if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
 | |
| 1346 | -                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1347 | -            } else {
 | |
| 1348 | -                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1349 | - } | |
| 1350 | - } | |
| 1351 | - } | |
| 1352 | - | |
| 1353 | - //////////////////////////////// | |
| 1354 | - /* Diagnose Add Listing Page Ends */ | |
| 1355 | - //////////////////////////////// | |
| 1356 | - | |
| 1357 | - | |
| 1358 | - ////////////////////////////////// | |
| 1359 | - /* Diagnose Listing Preview Page Starts */ | |
| 1360 | - ////////////////////////////////// | |
| 1361 | -    $option_value = get_option('geodir_preview_page');
 | |
| 1362 | - $page = get_post($option_value); | |
| 1363 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1364 | - | |
| 1365 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1366 | -        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1367 | -    else {
 | |
| 1368 | - $is_error_during_diagnose = true; | |
| 1369 | -        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1370 | -        if ($fix) {
 | |
| 1371 | -            if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
 | |
| 1372 | -                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1373 | -            } else {
 | |
| 1374 | -                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1375 | - } | |
| 1376 | - } | |
| 1377 | - } | |
| 1378 | - | |
| 1379 | - //////////////////////////////// | |
| 1380 | - /* Diagnose Listing Preview Page Ends */ | |
| 1381 | - //////////////////////////////// | |
| 1382 | - | |
| 1383 | - ////////////////////////////////// | |
| 1384 | - /* Diagnose Listing Success Page Starts */ | |
| 1385 | - ////////////////////////////////// | |
| 1386 | -    $option_value = get_option('geodir_success_page');
 | |
| 1387 | - $page = get_post($option_value); | |
| 1388 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1389 | - | |
| 1390 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1391 | -        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1392 | -    else {
 | |
| 1393 | - $is_error_during_diagnose = true; | |
| 1394 | -        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1395 | -        if ($fix) {
 | |
| 1396 | -            if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
 | |
| 1397 | -                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1398 | -            } else {
 | |
| 1399 | -                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1400 | - } | |
| 1401 | - } | |
| 1402 | - } | |
| 1403 | - | |
| 1404 | - //////////////////////////////// | |
| 1405 | - /* Diagnose Listing Sucess Page Ends */ | |
| 1406 | - //////////////////////////////// | |
| 1407 | - | |
| 1408 | - ////////////////////////////////// | |
| 1409 | - /* Diagnose Info Page Starts */ | |
| 1410 | - ////////////////////////////////// | |
| 1411 | -    $option_value = get_option('geodir_info_page');
 | |
| 1412 | - $page = get_post($option_value); | |
| 1413 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1414 | - | |
| 1415 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1416 | -        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1417 | -    else {
 | |
| 1418 | - $is_error_during_diagnose = true; | |
| 1419 | -        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1420 | -        if ($fix) {
 | |
| 1421 | -            if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
 | |
| 1422 | -                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1423 | -            } else {
 | |
| 1424 | -                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1425 | - } | |
| 1426 | - } | |
| 1427 | - } | |
| 1428 | - | |
| 1429 | - //////////////////////////////// | |
| 1430 | - /* Diagnose Info Page Ends */ | |
| 1431 | - //////////////////////////////// | |
| 1432 | - | |
| 1433 | - ////////////////////////////////// | |
| 1434 | - /* Diagnose Login Page Starts */ | |
| 1435 | - ////////////////////////////////// | |
| 1436 | -    $option_value = get_option('geodir_login_page');
 | |
| 1437 | - $page = get_post($option_value); | |
| 1438 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1439 | - | |
| 1440 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1441 | -        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1442 | -    else {
 | |
| 1443 | - $is_error_during_diagnose = true; | |
| 1444 | -        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1445 | -        if ($fix) {
 | |
| 1446 | -            if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
 | |
| 1447 | -                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1448 | -            } else {
 | |
| 1449 | -                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1450 | - } | |
| 1451 | - } | |
| 1452 | - } | |
| 1453 | - | |
| 1454 | - //////////////////////////////// | |
| 1455 | - /* Diagnose Info Page Ends */ | |
| 1456 | - //////////////////////////////// | |
| 1457 | - | |
| 1458 | - ////////////////////////////////// | |
| 1459 | - /* Diagnose Location Page Starts */ | |
| 1460 | - ////////////////////////////////// | |
| 1461 | -    $option_value = get_option('geodir_location_page');
 | |
| 1462 | - $page = get_post($option_value); | |
| 1463 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1464 | - | |
| 1465 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1466 | -        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1467 | -    else {
 | |
| 1468 | - $is_error_during_diagnose = true; | |
| 1469 | -        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1470 | -        if ($fix) {
 | |
| 1471 | -            if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
 | |
| 1472 | -                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1473 | -            } else {
 | |
| 1474 | -                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1475 | - } | |
| 1476 | - } | |
| 1477 | - } | |
| 1478 | - | |
| 1479 | - //////////////////////////////// | |
| 1480 | - /* Diagnose Location Page Ends */ | |
| 1481 | - //////////////////////////////// | |
| 1482 | - | |
| 1483 | -    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
 | |
| 1484 | - /** | |
| 1485 | - * This action is called at the end of the GD Tools page check function. | |
| 1486 | - * | |
| 1487 | - * @since 1.5.2 | |
| 1488 | - */ | |
| 1489 | -    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
 | |
| 1490 | - | |
| 1491 | - $output_str = $page_chk_arr['output_str']; | |
| 1492 | - $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; | |
| 1493 | - | |
| 1494 | -    if ($is_error_during_diagnose) {
 | |
| 1495 | -        if ($fix) {
 | |
| 1496 | - flush_rewrite_rules(); | |
| 1497 | - } | |
| 1498 | - $info_div_class = "geodir_problem_info"; | |
| 1499 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
 | |
| 1500 | -    } else {
 | |
| 1501 | - $info_div_class = "geodir_noproblem_info"; | |
| 1502 | - $fix_button_txt = ''; | |
| 1503 | - } | |
| 1504 | - echo "<ul class='$info_div_class'>"; | |
| 1505 | - echo $output_str; | |
| 1506 | - echo $fix_button_txt; | |
| 1507 | - echo "</ul>"; | |
| 1302 | + global $wpdb; | |
| 1303 | + $is_error_during_diagnose = false; | |
| 1304 | + $output_str = ''; | |
| 1305 | + $fix = isset($_POST['fix']) ? true : false; | |
| 1306 | + | |
| 1307 | + ////////////////////////////////// | |
| 1308 | + /* Diagnose GD Home Page Starts */ | |
| 1309 | + ////////////////////////////////// | |
| 1310 | +	$option_value = get_option('geodir_home_page');
 | |
| 1311 | + $page = get_post($option_value); | |
| 1312 | +	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1313 | + | |
| 1314 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1315 | +		$output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1316 | +	else {
 | |
| 1317 | + $is_error_during_diagnose = true; | |
| 1318 | +		$output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1319 | +		if ($fix) {
 | |
| 1320 | +			if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
 | |
| 1321 | +				$output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1322 | +			} else {
 | |
| 1323 | +				$output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1324 | + } | |
| 1325 | + } | |
| 1326 | + } | |
| 1327 | + | |
| 1328 | + //////////////////////////////// | |
| 1329 | + /* Diagnose GD Home Page Ends */ | |
| 1330 | + //////////////////////////////// | |
| 1331 | + | |
| 1332 | + ////////////////////////////////// | |
| 1333 | + /* Diagnose Add Listing Page Starts */ | |
| 1334 | + ////////////////////////////////// | |
| 1335 | +	$option_value = get_option('geodir_add_listing_page');
 | |
| 1336 | + $page = get_post($option_value); | |
| 1337 | +	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1338 | + | |
| 1339 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1340 | +		$output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1341 | +	else {
 | |
| 1342 | + $is_error_during_diagnose = true; | |
| 1343 | +		$output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1344 | +		if ($fix) {
 | |
| 1345 | +			if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
 | |
| 1346 | +				$output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1347 | +			} else {
 | |
| 1348 | +				$output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1349 | + } | |
| 1350 | + } | |
| 1351 | + } | |
| 1352 | + | |
| 1353 | + //////////////////////////////// | |
| 1354 | + /* Diagnose Add Listing Page Ends */ | |
| 1355 | + //////////////////////////////// | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + ////////////////////////////////// | |
| 1359 | + /* Diagnose Listing Preview Page Starts */ | |
| 1360 | + ////////////////////////////////// | |
| 1361 | +	$option_value = get_option('geodir_preview_page');
 | |
| 1362 | + $page = get_post($option_value); | |
| 1363 | +	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1364 | + | |
| 1365 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1366 | +		$output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1367 | +	else {
 | |
| 1368 | + $is_error_during_diagnose = true; | |
| 1369 | +		$output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1370 | +		if ($fix) {
 | |
| 1371 | +			if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
 | |
| 1372 | +				$output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1373 | +			} else {
 | |
| 1374 | +				$output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1375 | + } | |
| 1376 | + } | |
| 1377 | + } | |
| 1378 | + | |
| 1379 | + //////////////////////////////// | |
| 1380 | + /* Diagnose Listing Preview Page Ends */ | |
| 1381 | + //////////////////////////////// | |
| 1382 | + | |
| 1383 | + ////////////////////////////////// | |
| 1384 | + /* Diagnose Listing Success Page Starts */ | |
| 1385 | + ////////////////////////////////// | |
| 1386 | +	$option_value = get_option('geodir_success_page');
 | |
| 1387 | + $page = get_post($option_value); | |
| 1388 | +	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1389 | + | |
| 1390 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1391 | +		$output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1392 | +	else {
 | |
| 1393 | + $is_error_during_diagnose = true; | |
| 1394 | +		$output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1395 | +		if ($fix) {
 | |
| 1396 | +			if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
 | |
| 1397 | +				$output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1398 | +			} else {
 | |
| 1399 | +				$output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1400 | + } | |
| 1401 | + } | |
| 1402 | + } | |
| 1403 | + | |
| 1404 | + //////////////////////////////// | |
| 1405 | + /* Diagnose Listing Sucess Page Ends */ | |
| 1406 | + //////////////////////////////// | |
| 1407 | + | |
| 1408 | + ////////////////////////////////// | |
| 1409 | + /* Diagnose Info Page Starts */ | |
| 1410 | + ////////////////////////////////// | |
| 1411 | +	$option_value = get_option('geodir_info_page');
 | |
| 1412 | + $page = get_post($option_value); | |
| 1413 | +	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1414 | + | |
| 1415 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1416 | +		$output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1417 | +	else {
 | |
| 1418 | + $is_error_during_diagnose = true; | |
| 1419 | +		$output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1420 | +		if ($fix) {
 | |
| 1421 | +			if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
 | |
| 1422 | +				$output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1423 | +			} else {
 | |
| 1424 | +				$output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1425 | + } | |
| 1426 | + } | |
| 1427 | + } | |
| 1428 | + | |
| 1429 | + //////////////////////////////// | |
| 1430 | + /* Diagnose Info Page Ends */ | |
| 1431 | + //////////////////////////////// | |
| 1432 | + | |
| 1433 | + ////////////////////////////////// | |
| 1434 | + /* Diagnose Login Page Starts */ | |
| 1435 | + ////////////////////////////////// | |
| 1436 | +	$option_value = get_option('geodir_login_page');
 | |
| 1437 | + $page = get_post($option_value); | |
| 1438 | +	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1439 | + | |
| 1440 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1441 | +		$output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1442 | +	else {
 | |
| 1443 | + $is_error_during_diagnose = true; | |
| 1444 | +		$output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1445 | +		if ($fix) {
 | |
| 1446 | +			if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
 | |
| 1447 | +				$output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1448 | +			} else {
 | |
| 1449 | +				$output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1450 | + } | |
| 1451 | + } | |
| 1452 | + } | |
| 1453 | + | |
| 1454 | + //////////////////////////////// | |
| 1455 | + /* Diagnose Info Page Ends */ | |
| 1456 | + //////////////////////////////// | |
| 1457 | + | |
| 1458 | + ////////////////////////////////// | |
| 1459 | + /* Diagnose Location Page Starts */ | |
| 1460 | + ////////////////////////////////// | |
| 1461 | +	$option_value = get_option('geodir_location_page');
 | |
| 1462 | + $page = get_post($option_value); | |
| 1463 | +	if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1464 | + | |
| 1465 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1466 | +		$output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1467 | +	else {
 | |
| 1468 | + $is_error_during_diagnose = true; | |
| 1469 | +		$output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1470 | +		if ($fix) {
 | |
| 1471 | +			if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
 | |
| 1472 | +				$output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1473 | +			} else {
 | |
| 1474 | +				$output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1475 | + } | |
| 1476 | + } | |
| 1477 | + } | |
| 1478 | + | |
| 1479 | + //////////////////////////////// | |
| 1480 | + /* Diagnose Location Page Ends */ | |
| 1481 | + //////////////////////////////// | |
| 1482 | + | |
| 1483 | +	$page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
 | |
| 1484 | + /** | |
| 1485 | + * This action is called at the end of the GD Tools page check function. | |
| 1486 | + * | |
| 1487 | + * @since 1.5.2 | |
| 1488 | + */ | |
| 1489 | +	$page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
 | |
| 1490 | + | |
| 1491 | + $output_str = $page_chk_arr['output_str']; | |
| 1492 | + $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; | |
| 1493 | + | |
| 1494 | +	if ($is_error_during_diagnose) {
 | |
| 1495 | +		if ($fix) {
 | |
| 1496 | + flush_rewrite_rules(); | |
| 1497 | + } | |
| 1498 | + $info_div_class = "geodir_problem_info"; | |
| 1499 | +		$fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
 | |
| 1500 | +	} else {
 | |
| 1501 | + $info_div_class = "geodir_noproblem_info"; | |
| 1502 | + $fix_button_txt = ''; | |
| 1503 | + } | |
| 1504 | + echo "<ul class='$info_div_class'>"; | |
| 1505 | + echo $output_str; | |
| 1506 | + echo $fix_button_txt; | |
| 1507 | + echo "</ul>"; | |
| 1508 | 1508 | |
| 1509 | 1509 | } | 
| 1510 | 1510 | |
| @@ -1516,25 +1516,25 @@ discard block | ||
| 1516 | 1516 | * @global object $wpdb WordPress Database object. | 
| 1517 | 1517 | */ | 
| 1518 | 1518 |  function geodir_diagnose_load_db_language() {
 | 
| 1519 | - global $wpdb; | |
| 1519 | + global $wpdb; | |
| 1520 | 1520 | |
| 1521 | 1521 | $is_error_during_diagnose = geodirectory_load_db_language(); | 
| 1522 | 1522 | |
| 1523 | - $output_str = ''; | |
| 1523 | + $output_str = ''; | |
| 1524 | 1524 | |
| 1525 | -    if ($is_error_during_diagnose) {
 | |
| 1526 | -        $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
 | |
| 1525 | +	if ($is_error_during_diagnose) {
 | |
| 1526 | +		$output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
 | |
| 1527 | 1527 | $info_div_class = "geodir_problem_info"; | 
| 1528 | -    } else {
 | |
| 1529 | -        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
 | |
| 1528 | +	} else {
 | |
| 1529 | +		$output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
 | |
| 1530 | 1530 | $info_div_class = "geodir_noproblem_info"; | 
| 1531 | - $fix_button_txt = ''; | |
| 1532 | - } | |
| 1531 | + $fix_button_txt = ''; | |
| 1532 | + } | |
| 1533 | 1533 | |
| 1534 | 1534 | echo "<ul class='$info_div_class'>"; | 
| 1535 | - echo $output_str; | |
| 1536 | - echo $fix_button_txt; | |
| 1537 | - echo "</ul>"; | |
| 1535 | + echo $output_str; | |
| 1536 | + echo $fix_button_txt; | |
| 1537 | + echo "</ul>"; | |
| 1538 | 1538 | |
| 1539 | 1539 | } | 
| 1540 | 1540 | |
| @@ -1565,23 +1565,23 @@ discard block | ||
| 1565 | 1565 | */ | 
| 1566 | 1566 | function geodir_posts_clauses_request($clauses) | 
| 1567 | 1567 |  {
 | 
| 1568 | - global $wpdb, $wp_query, $plugin_prefix; | |
| 1568 | + global $wpdb, $wp_query, $plugin_prefix; | |
| 1569 | 1569 | |
| 1570 | -    if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
 | |
| 1571 | - $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; | |
| 1570 | +	if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
 | |
| 1571 | + $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; | |
| 1572 | 1572 | |
| 1573 | - $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; | |
| 1574 | - $clauses['join'] = $join; | |
| 1573 | + $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; | |
| 1574 | + $clauses['join'] = $join; | |
| 1575 | 1575 | |
| 1576 | - $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; | |
| 1577 | - $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire'; | |
| 1578 | - $clauses['fields'] = $fields; | |
| 1576 | + $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; | |
| 1577 | + $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire'; | |
| 1578 | + $clauses['fields'] = $fields; | |
| 1579 | 1579 | |
| 1580 | - $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; | |
| 1581 | - $orderby = 'gd_expire ' . $order; | |
| 1582 | - $clauses['orderby'] = $orderby; | |
| 1583 | - } | |
| 1584 | - return $clauses; | |
| 1580 | + $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; | |
| 1581 | + $orderby = 'gd_expire ' . $order; | |
| 1582 | + $clauses['orderby'] = $orderby; | |
| 1583 | + } | |
| 1584 | + return $clauses; | |
| 1585 | 1585 | } | 
| 1586 | 1586 | |
| 1587 | 1587 | |
| @@ -1602,7 +1602,7 @@ discard block | ||
| 1602 | 1602 | */ | 
| 1603 | 1603 | function gd_theme_switch_compat_check() | 
| 1604 | 1604 |  {
 | 
| 1605 | - gd_set_theme_compat(); | |
| 1605 | + gd_set_theme_compat(); | |
| 1606 | 1606 | } | 
| 1607 | 1607 | |
| 1608 | 1608 | /** | 
| @@ -1615,27 +1615,27 @@ discard block | ||
| 1615 | 1615 | */ | 
| 1616 | 1616 | function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") | 
| 1617 | 1617 |  {
 | 
| 1618 | -    if (function_exists('str_getcsv')) {
 | |
| 1619 | - $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape); | |
| 1620 | -    } else {
 | |
| 1621 | - global $current_user; | |
| 1622 | - $upload_dir = wp_upload_dir(); | |
| 1623 | - | |
| 1624 | - $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; | |
| 1625 | - $handle = fopen($file, 'w'); | |
| 1626 | - | |
| 1627 | - fwrite($handle, $input); | |
| 1628 | - fclose($handle); | |
| 1629 | - | |
| 1630 | - $handle = fopen($file, 'rt'); | |
| 1631 | -        if (PHP_VERSION >= '5.3.0') {
 | |
| 1632 | - $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape); | |
| 1633 | -        } else {
 | |
| 1634 | - $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure); | |
| 1635 | - } | |
| 1636 | - fclose($handle); | |
| 1637 | - } | |
| 1638 | - return $fgetcsv; | |
| 1618 | +	if (function_exists('str_getcsv')) {
 | |
| 1619 | + $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape); | |
| 1620 | +	} else {
 | |
| 1621 | + global $current_user; | |
| 1622 | + $upload_dir = wp_upload_dir(); | |
| 1623 | + | |
| 1624 | + $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; | |
| 1625 | + $handle = fopen($file, 'w'); | |
| 1626 | + | |
| 1627 | + fwrite($handle, $input); | |
| 1628 | + fclose($handle); | |
| 1629 | + | |
| 1630 | + $handle = fopen($file, 'rt'); | |
| 1631 | +		if (PHP_VERSION >= '5.3.0') {
 | |
| 1632 | + $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape); | |
| 1633 | +		} else {
 | |
| 1634 | + $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure); | |
| 1635 | + } | |
| 1636 | + fclose($handle); | |
| 1637 | + } | |
| 1638 | + return $fgetcsv; | |
| 1639 | 1639 | } | 
| 1640 | 1640 | |
| 1641 | 1641 |  add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv');
 | 
| @@ -1650,375 +1650,375 @@ discard block | ||
| 1650 | 1650 | */ | 
| 1651 | 1651 | function geodir_ajax_import_csv() | 
| 1652 | 1652 |  {
 | 
| 1653 | - error_reporting(0); // hide error to get clean json response | |
| 1653 | + error_reporting(0); // hide error to get clean json response | |
| 1654 | 1654 | |
| 1655 | - global $wpdb, $plugin_prefix, $current_user; | |
| 1656 | - $uploads = wp_upload_dir(); | |
| 1657 | -    ini_set('auto_detect_line_endings', true);
 | |
| 1655 | + global $wpdb, $plugin_prefix, $current_user; | |
| 1656 | + $uploads = wp_upload_dir(); | |
| 1657 | +	ini_set('auto_detect_line_endings', true);
 | |
| 1658 | 1658 | |
| 1659 | 1659 | $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. | 
| 1660 | 1660 | |
| 1661 | - $task = isset($_POST['task']) ? $_POST['task'] : ''; | |
| 1662 | - $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL; | |
| 1663 | - $filename = $uploadedFile; | |
| 1664 | - | |
| 1665 | - $uploads = wp_upload_dir(); | |
| 1666 | - $uploads_dir = $uploads['path']; | |
| 1667 | -    $image_name_arr = explode('/', $filename);
 | |
| 1668 | - $filename = end($image_name_arr); | |
| 1669 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; | |
| 1670 | - $return = array(); | |
| 1671 | - $return['file'] = $uploadedFile; | |
| 1672 | -    $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
 | |
| 1673 | - | |
| 1674 | -    if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
 | |
| 1675 | - $wp_filetype = wp_check_filetype_and_ext($target_path, $filename); | |
| 1676 | - | |
| 1677 | -        if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
 | |
| 1678 | - $return['error'] = NULL; | |
| 1679 | - | |
| 1680 | - $return['rows'] = 0; | |
| 1681 | - | |
| 1682 | - | |
| 1683 | - | |
| 1684 | -                if (($handle = fopen($target_path, "r")) !== FALSE) {
 | |
| 1685 | -                    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
 | |
| 1686 | -                        if(is_array($data) && !empty($data)) {
 | |
| 1687 | -                            $file[] = '"' . implode('","', $data) . '"';
 | |
| 1688 | - } | |
| 1689 | - } | |
| 1690 | - fclose($handle); | |
| 1691 | - $file = $file; | |
| 1692 | - } | |
| 1693 | - | |
| 1694 | - | |
| 1695 | - | |
| 1696 | - $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; | |
| 1697 | - | |
| 1698 | - | |
| 1699 | -            if (!$return['rows'] > 0) {
 | |
| 1700 | -                $return['error'] = __('No data found in csv file.', 'geodirectory');
 | |
| 1701 | - } | |
| 1702 | - } | |
| 1703 | - } | |
| 1704 | -    if ($task == 'prepare' || !empty($return['error'])) {
 | |
| 1705 | - echo json_encode($return); | |
| 1706 | - exit; | |
| 1707 | - } | |
| 1708 | - | |
| 1709 | - $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL; | |
| 1710 | - $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1; | |
| 1711 | - $count = $importlimit; | |
| 1712 | - $requested_limit = $importlimit; | |
| 1713 | - $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0; | |
| 1714 | - | |
| 1715 | -    if ($count < $totRecords) {
 | |
| 1716 | - $count = $tmpCnt + $count; | |
| 1717 | -        if ($count > $totRecords) {
 | |
| 1718 | - $count = $totRecords; | |
| 1719 | - } | |
| 1720 | -    } else {
 | |
| 1721 | - $count = $totRecords; | |
| 1722 | - } | |
| 1723 | - | |
| 1724 | - $total_records = 0; | |
| 1725 | - $rowcount = 0; | |
| 1726 | - $address_invalid = 0; | |
| 1727 | - $blank_address = 0; | |
| 1728 | - $upload_files = 0; | |
| 1729 | - $invalid_post_type = 0; | |
| 1730 | - $invalid_title = 0; | |
| 1731 | - $customKeyarray = array(); | |
| 1732 | - $gd_post_info = array(); | |
| 1733 | - $post_location = array(); | |
| 1734 | - $countpost = 0; | |
| 1735 | - | |
| 1736 | -    if (!empty($file)) {
 | |
| 1737 | - $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL; | |
| 1738 | - $customKeyarray = $columns; | |
| 1739 | - | |
| 1740 | -        if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
 | |
| 1741 | - $return['error'] = CSV_INVAILD_FILE; | |
| 1742 | - echo json_encode($return); | |
| 1743 | - exit; | |
| 1744 | - } | |
| 1745 | - | |
| 1746 | -        for ($i = 1; $i <= $importlimit; $i++) {
 | |
| 1747 | - $current_index = $tmpCnt + $i; | |
| 1748 | -            if (isset($file[$current_index])) {
 | |
| 1749 | - $total_records++; | |
| 1750 | - | |
| 1751 | - $buffer = geodir_str_getcsv($file[$current_index]); | |
| 1752 | - $post_title = addslashes($buffer[0]); | |
| 1753 | - $current_post_author = $buffer[1]; | |
| 1754 | - $post_desc = addslashes($buffer[2]); | |
| 1755 | - $post_cat = array(); | |
| 1756 | - $catids_arr = array(); | |
| 1757 | - $post_cat = trim($buffer[3]); // comma seperated category name | |
| 1758 | - | |
| 1759 | -                if ($post_cat) {
 | |
| 1760 | -                    $post_cat_arr = explode(',', $post_cat);
 | |
| 1761 | - | |
| 1762 | -                    for ($c = 0; $c < count($post_cat_arr); $c++) {
 | |
| 1763 | - $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); | |
| 1764 | - | |
| 1765 | -                        if (!empty($buffer[5])) {
 | |
| 1766 | -                            if (in_array($buffer[5], geodir_get_posttypes())) {
 | |
| 1767 | - | |
| 1768 | - $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); | |
| 1769 | - | |
| 1770 | -                                if (get_term_by('name', $catid, $p_taxonomy[0])) {
 | |
| 1771 | -                                    $cat = get_term_by('name', $catid, $p_taxonomy[0]);
 | |
| 1772 | - $catids_arr[] = $cat->slug; | |
| 1773 | -                                } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
 | |
| 1774 | -                                    $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
 | |
| 1775 | - $catids_arr[] = $cat->slug; | |
| 1776 | -                                } else {
 | |
| 1777 | - $ret = wp_insert_term($catid, $p_taxonomy[0]); | |
| 1778 | -                                    if ($ret && !is_wp_error($ret)) {
 | |
| 1779 | -                                        if (get_term_by('name', $catid, $p_taxonomy[0])) {
 | |
| 1780 | -                                            $cat = get_term_by('name', $catid, $p_taxonomy[0]);
 | |
| 1781 | - $catids_arr[] = $cat->slug; | |
| 1782 | -                                        } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
 | |
| 1783 | -                                            $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
 | |
| 1784 | - $catids_arr[] = $cat->slug; | |
| 1785 | - } | |
| 1786 | - } | |
| 1787 | - } | |
| 1788 | - } | |
| 1789 | - } | |
| 1790 | - } | |
| 1791 | - } | |
| 1792 | - | |
| 1793 | -                if (!$catids_arr) {
 | |
| 1794 | - $catids_arr[] = 1; | |
| 1795 | - } | |
| 1796 | - | |
| 1797 | - $post_tags = trim($buffer[4]); // comma seperated tags | |
| 1798 | - | |
| 1799 | - $tag_arr = ''; | |
| 1800 | -                if ($post_tags) {
 | |
| 1801 | -                    $tag_arr = explode(',', $post_tags);
 | |
| 1802 | - } | |
| 1803 | - | |
| 1804 | - $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database | |
| 1805 | - | |
| 1806 | - $error = ''; | |
| 1807 | -                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
 | |
| 1808 | - $invalid_post_type++; | |
| 1809 | - continue; | |
| 1810 | - } | |
| 1811 | - | |
| 1812 | -                if ($post_title != '') {
 | |
| 1813 | - $menu_order = 0; | |
| 1814 | - $image_folder_name = 'uplaod/'; | |
| 1815 | - | |
| 1816 | - $image_names = array(); | |
| 1817 | - | |
| 1818 | -                    for ($c = 5; $c < count($customKeyarray); $c++) {
 | |
| 1819 | - $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); | |
| 1820 | - | |
| 1821 | -                        if ($customKeyarray[$c] == 'IMAGE') {
 | |
| 1822 | - $buffer[$c] = trim($buffer[$c]); | |
| 1823 | - | |
| 1824 | -                            if (!empty($buffer[$c])) {
 | |
| 1825 | - $image_names[] = $buffer[$c]; | |
| 1826 | - } | |
| 1827 | - } | |
| 1828 | - | |
| 1829 | -                        if ($customKeyarray[$c] == 'alive_days') {
 | |
| 1830 | -                            if ($buffer[$c] != '0' && $buffer[$c] != '') {
 | |
| 1831 | -                                $submitdata = date('Y-m-d');
 | |
| 1832 | - | |
| 1833 | -                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
 | |
| 1834 | -                            } else {
 | |
| 1835 | - $gd_post_info['expire_date'] = 'Never'; | |
| 1836 | - } | |
| 1837 | - } | |
| 1838 | - | |
| 1839 | -                        if ($customKeyarray[$c] == 'post_city') {
 | |
| 1840 | - $post_city = addslashes($buffer[$c]); | |
| 1841 | - } | |
| 1842 | - | |
| 1843 | -                        if ($customKeyarray[$c] == 'post_region') {
 | |
| 1844 | - $post_region = addslashes($buffer[$c]); | |
| 1845 | - } | |
| 1846 | - | |
| 1847 | -                        if ($customKeyarray[$c] == 'post_country') {
 | |
| 1848 | - $post_country = addslashes($buffer[$c]); | |
| 1849 | - } | |
| 1850 | - | |
| 1851 | -                        if ($customKeyarray[$c] == 'post_latitude') {
 | |
| 1852 | - $post_latitude = addslashes($buffer[$c]); | |
| 1853 | - } | |
| 1854 | - | |
| 1855 | -                        if ($customKeyarray[$c] == 'post_longitude') {
 | |
| 1856 | - $post_longitude = addslashes($buffer[$c]); | |
| 1857 | - } | |
| 1661 | + $task = isset($_POST['task']) ? $_POST['task'] : ''; | |
| 1662 | + $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL; | |
| 1663 | + $filename = $uploadedFile; | |
| 1664 | + | |
| 1665 | + $uploads = wp_upload_dir(); | |
| 1666 | + $uploads_dir = $uploads['path']; | |
| 1667 | +	$image_name_arr = explode('/', $filename);
 | |
| 1668 | + $filename = end($image_name_arr); | |
| 1669 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; | |
| 1670 | + $return = array(); | |
| 1671 | + $return['file'] = $uploadedFile; | |
| 1672 | +	$return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
 | |
| 1673 | + | |
| 1674 | +	if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
 | |
| 1675 | + $wp_filetype = wp_check_filetype_and_ext($target_path, $filename); | |
| 1676 | + | |
| 1677 | +		if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
 | |
| 1678 | + $return['error'] = NULL; | |
| 1679 | + | |
| 1680 | + $return['rows'] = 0; | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | +				if (($handle = fopen($target_path, "r")) !== FALSE) {
 | |
| 1685 | +					while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
 | |
| 1686 | +						if(is_array($data) && !empty($data)) {
 | |
| 1687 | +							$file[] = '"' . implode('","', $data) . '"';
 | |
| 1688 | + } | |
| 1689 | + } | |
| 1690 | + fclose($handle); | |
| 1691 | + $file = $file; | |
| 1692 | + } | |
| 1693 | + | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; | |
| 1697 | + | |
| 1698 | + | |
| 1699 | +			if (!$return['rows'] > 0) {
 | |
| 1700 | +				$return['error'] = __('No data found in csv file.', 'geodirectory');
 | |
| 1701 | + } | |
| 1702 | + } | |
| 1703 | + } | |
| 1704 | +	if ($task == 'prepare' || !empty($return['error'])) {
 | |
| 1705 | + echo json_encode($return); | |
| 1706 | + exit; | |
| 1707 | + } | |
| 1708 | + | |
| 1709 | + $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL; | |
| 1710 | + $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1; | |
| 1711 | + $count = $importlimit; | |
| 1712 | + $requested_limit = $importlimit; | |
| 1713 | + $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0; | |
| 1714 | + | |
| 1715 | +	if ($count < $totRecords) {
 | |
| 1716 | + $count = $tmpCnt + $count; | |
| 1717 | +		if ($count > $totRecords) {
 | |
| 1718 | + $count = $totRecords; | |
| 1719 | + } | |
| 1720 | +	} else {
 | |
| 1721 | + $count = $totRecords; | |
| 1722 | + } | |
| 1723 | + | |
| 1724 | + $total_records = 0; | |
| 1725 | + $rowcount = 0; | |
| 1726 | + $address_invalid = 0; | |
| 1727 | + $blank_address = 0; | |
| 1728 | + $upload_files = 0; | |
| 1729 | + $invalid_post_type = 0; | |
| 1730 | + $invalid_title = 0; | |
| 1731 | + $customKeyarray = array(); | |
| 1732 | + $gd_post_info = array(); | |
| 1733 | + $post_location = array(); | |
| 1734 | + $countpost = 0; | |
| 1735 | + | |
| 1736 | +	if (!empty($file)) {
 | |
| 1737 | + $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL; | |
| 1738 | + $customKeyarray = $columns; | |
| 1739 | + | |
| 1740 | +		if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
 | |
| 1741 | + $return['error'] = CSV_INVAILD_FILE; | |
| 1742 | + echo json_encode($return); | |
| 1743 | + exit; | |
| 1744 | + } | |
| 1745 | + | |
| 1746 | +		for ($i = 1; $i <= $importlimit; $i++) {
 | |
| 1747 | + $current_index = $tmpCnt + $i; | |
| 1748 | +			if (isset($file[$current_index])) {
 | |
| 1749 | + $total_records++; | |
| 1750 | + | |
| 1751 | + $buffer = geodir_str_getcsv($file[$current_index]); | |
| 1752 | + $post_title = addslashes($buffer[0]); | |
| 1753 | + $current_post_author = $buffer[1]; | |
| 1754 | + $post_desc = addslashes($buffer[2]); | |
| 1755 | + $post_cat = array(); | |
| 1756 | + $catids_arr = array(); | |
| 1757 | + $post_cat = trim($buffer[3]); // comma seperated category name | |
| 1758 | + | |
| 1759 | +				if ($post_cat) {
 | |
| 1760 | +					$post_cat_arr = explode(',', $post_cat);
 | |
| 1761 | + | |
| 1762 | +					for ($c = 0; $c < count($post_cat_arr); $c++) {
 | |
| 1763 | + $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); | |
| 1764 | + | |
| 1765 | +						if (!empty($buffer[5])) {
 | |
| 1766 | +							if (in_array($buffer[5], geodir_get_posttypes())) {
 | |
| 1767 | + | |
| 1768 | + $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); | |
| 1769 | + | |
| 1770 | +								if (get_term_by('name', $catid, $p_taxonomy[0])) {
 | |
| 1771 | +									$cat = get_term_by('name', $catid, $p_taxonomy[0]);
 | |
| 1772 | + $catids_arr[] = $cat->slug; | |
| 1773 | +								} else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
 | |
| 1774 | +									$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
 | |
| 1775 | + $catids_arr[] = $cat->slug; | |
| 1776 | +								} else {
 | |
| 1777 | + $ret = wp_insert_term($catid, $p_taxonomy[0]); | |
| 1778 | +									if ($ret && !is_wp_error($ret)) {
 | |
| 1779 | +										if (get_term_by('name', $catid, $p_taxonomy[0])) {
 | |
| 1780 | +											$cat = get_term_by('name', $catid, $p_taxonomy[0]);
 | |
| 1781 | + $catids_arr[] = $cat->slug; | |
| 1782 | +										} elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
 | |
| 1783 | +											$cat = get_term_by('slug', $catid, $p_taxonomy[0]);
 | |
| 1784 | + $catids_arr[] = $cat->slug; | |
| 1785 | + } | |
| 1786 | + } | |
| 1787 | + } | |
| 1788 | + } | |
| 1789 | + } | |
| 1790 | + } | |
| 1791 | + } | |
| 1792 | + | |
| 1793 | +				if (!$catids_arr) {
 | |
| 1794 | + $catids_arr[] = 1; | |
| 1795 | + } | |
| 1796 | + | |
| 1797 | + $post_tags = trim($buffer[4]); // comma seperated tags | |
| 1798 | + | |
| 1799 | + $tag_arr = ''; | |
| 1800 | +				if ($post_tags) {
 | |
| 1801 | +					$tag_arr = explode(',', $post_tags);
 | |
| 1802 | + } | |
| 1803 | + | |
| 1804 | + $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database | |
| 1805 | + | |
| 1806 | + $error = ''; | |
| 1807 | +				if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
 | |
| 1808 | + $invalid_post_type++; | |
| 1809 | + continue; | |
| 1810 | + } | |
| 1811 | + | |
| 1812 | +				if ($post_title != '') {
 | |
| 1813 | + $menu_order = 0; | |
| 1814 | + $image_folder_name = 'uplaod/'; | |
| 1815 | + | |
| 1816 | + $image_names = array(); | |
| 1817 | + | |
| 1818 | +					for ($c = 5; $c < count($customKeyarray); $c++) {
 | |
| 1819 | + $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); | |
| 1820 | + | |
| 1821 | +						if ($customKeyarray[$c] == 'IMAGE') {
 | |
| 1822 | + $buffer[$c] = trim($buffer[$c]); | |
| 1823 | + | |
| 1824 | +							if (!empty($buffer[$c])) {
 | |
| 1825 | + $image_names[] = $buffer[$c]; | |
| 1826 | + } | |
| 1827 | + } | |
| 1828 | + | |
| 1829 | +						if ($customKeyarray[$c] == 'alive_days') {
 | |
| 1830 | +							if ($buffer[$c] != '0' && $buffer[$c] != '') {
 | |
| 1831 | +								$submitdata = date('Y-m-d');
 | |
| 1832 | + | |
| 1833 | +								$gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
 | |
| 1834 | +							} else {
 | |
| 1835 | + $gd_post_info['expire_date'] = 'Never'; | |
| 1836 | + } | |
| 1837 | + } | |
| 1838 | + | |
| 1839 | +						if ($customKeyarray[$c] == 'post_city') {
 | |
| 1840 | + $post_city = addslashes($buffer[$c]); | |
| 1841 | + } | |
| 1842 | + | |
| 1843 | +						if ($customKeyarray[$c] == 'post_region') {
 | |
| 1844 | + $post_region = addslashes($buffer[$c]); | |
| 1845 | + } | |
| 1846 | + | |
| 1847 | +						if ($customKeyarray[$c] == 'post_country') {
 | |
| 1848 | + $post_country = addslashes($buffer[$c]); | |
| 1849 | + } | |
| 1850 | + | |
| 1851 | +						if ($customKeyarray[$c] == 'post_latitude') {
 | |
| 1852 | + $post_latitude = addslashes($buffer[$c]); | |
| 1853 | + } | |
| 1854 | + | |
| 1855 | +						if ($customKeyarray[$c] == 'post_longitude') {
 | |
| 1856 | + $post_longitude = addslashes($buffer[$c]); | |
| 1857 | + } | |
| 1858 | 1858 | |
| 1859 | 1859 | // Post status | 
| 1860 | 1860 |  						if ($customKeyarray[$c] == 'post_status') {
 | 
| 1861 | - $post_status = sanitize_key( $buffer[$c] ); | |
| 1862 | - } | |
| 1863 | - } | |
| 1864 | - | |
| 1865 | - /* ================ before array create ============== */ | |
| 1866 | - $location_result = geodir_get_default_location(); | |
| 1867 | -                    if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
 | |
| 1868 | - $blank_address++; | |
| 1869 | - continue; | |
| 1870 | -                    } else if ($location_result->location_id == 0) {
 | |
| 1871 | -                        if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
 | |
| 1872 | - $address_invalid++; | |
| 1873 | - continue; | |
| 1874 | - } | |
| 1875 | - } | |
| 1861 | + $post_status = sanitize_key( $buffer[$c] ); | |
| 1862 | + } | |
| 1863 | + } | |
| 1864 | + | |
| 1865 | + /* ================ before array create ============== */ | |
| 1866 | + $location_result = geodir_get_default_location(); | |
| 1867 | +					if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
 | |
| 1868 | + $blank_address++; | |
| 1869 | + continue; | |
| 1870 | +					} else if ($location_result->location_id == 0) {
 | |
| 1871 | +						if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
 | |
| 1872 | + $address_invalid++; | |
| 1873 | + continue; | |
| 1874 | + } | |
| 1875 | + } | |
| 1876 | 1876 | |
| 1877 | 1877 | // Default post status | 
| 1878 | 1878 | $default_status = 'publish'; | 
| 1879 | 1879 | $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; | 
| 1880 | 1880 | $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; | 
| 1881 | 1881 | |
| 1882 | - $my_post['post_title'] = $post_title; | |
| 1883 | - $my_post['post_content'] = $post_desc; | |
| 1884 | - $my_post['post_type'] = addslashes($buffer[5]); | |
| 1885 | - $my_post['post_author'] = $current_post_author; | |
| 1886 | - $my_post['post_status'] = $post_status; | |
| 1887 | - $my_post['post_category'] = $catids_arr; | |
| 1888 | - $my_post['post_tags'] = $tag_arr; | |
| 1889 | - | |
| 1890 | - $gd_post_info['post_tags'] = $tag_arr; | |
| 1891 | - $gd_post_info['post_title'] = $post_title; | |
| 1892 | - $gd_post_info['post_status'] = $post_status; | |
| 1893 | - $gd_post_info['submit_time'] = time(); | |
| 1894 | - $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; | |
| 1895 | - | |
| 1896 | - $last_postid = wp_insert_post($my_post); | |
| 1897 | - $countpost++; | |
| 1898 | - | |
| 1899 | - // Check if we need to save post location as new location | |
| 1900 | -                    if ($location_result->location_id > 0) {
 | |
| 1901 | -                        if (isset($post_city) && isset($post_region)) {
 | |
| 1902 | - $request_info['post_location'] = array( | |
| 1903 | - 'city' => $post_city, | |
| 1904 | - 'region' => $post_region, | |
| 1905 | - 'country' => $post_country, | |
| 1906 | - 'geo_lat' => $post_latitude, | |
| 1907 | - 'geo_lng' => $post_longitude | |
| 1908 | - ); | |
| 1909 | - | |
| 1910 | - $post_location_info = $request_info['post_location']; | |
| 1911 | - if ($location_id = geodir_add_new_location($post_location_info)) | |
| 1912 | - $post_location_id = $location_id; | |
| 1913 | -                        } else {
 | |
| 1914 | - $post_location_id = 0; | |
| 1915 | - } | |
| 1916 | -                    } else {
 | |
| 1917 | - $post_location_id = 0; | |
| 1918 | - } | |
| 1919 | - | |
| 1920 | - /* ------- get default package info ----- */ | |
| 1921 | - $payment_info = array(); | |
| 1922 | - $package_info = array(); | |
| 1923 | - | |
| 1924 | - $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); | |
| 1925 | - $package_id = ''; | |
| 1926 | -                    if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
 | |
| 1927 | - $package_id = $gd_post_info['package_id']; | |
| 1928 | - } | |
| 1929 | - | |
| 1930 | -                    if (!empty($package_info)) {
 | |
| 1931 | - $payment_info['package_id'] = $package_info['pid']; | |
| 1932 | - | |
| 1933 | -                        if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
 | |
| 1934 | -                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
 | |
| 1935 | -                        } else {
 | |
| 1936 | - $payment_info['expire_date'] = 'Never'; | |
| 1937 | - } | |
| 1938 | - | |
| 1939 | - $gd_post_info = array_merge($gd_post_info, $payment_info); | |
| 1940 | - } | |
| 1941 | - | |
| 1942 | - $gd_post_info['post_location_id'] = $post_location_id; | |
| 1943 | - | |
| 1944 | - $post_type = get_post_type($last_postid); | |
| 1945 | - | |
| 1946 | - $table = $plugin_prefix . $post_type . '_detail'; | |
| 1947 | - | |
| 1948 | - geodir_save_post_info($last_postid, $gd_post_info); | |
| 1949 | - | |
| 1950 | -                    if (!empty($image_names)) {
 | |
| 1951 | - $upload_files++; | |
| 1952 | - $menu_order = 1; | |
| 1953 | - | |
| 1954 | -                        foreach ($image_names as $image_name) {
 | |
| 1955 | -                            $img_name_arr = explode('.', $image_name);
 | |
| 1956 | - | |
| 1957 | - $uploads = wp_upload_dir(); | |
| 1958 | - $sub_dir = $uploads['subdir']; | |
| 1959 | - | |
| 1960 | - $arr_file_type = wp_check_filetype($image_name); | |
| 1961 | - $uploaded_file_type = $arr_file_type['type']; | |
| 1962 | - | |
| 1963 | - $attachment = array(); | |
| 1964 | - $attachment['post_id'] = $last_postid; | |
| 1965 | - $attachment['title'] = $img_name_arr[0]; | |
| 1966 | - $attachment['content'] = ''; | |
| 1967 | - $attachment['file'] = $sub_dir . '/' . $image_name; | |
| 1968 | - $attachment['mime_type'] = $uploaded_file_type; | |
| 1969 | - $attachment['menu_order'] = $menu_order; | |
| 1970 | - $attachment['is_featured'] = 0; | |
| 1971 | - | |
| 1972 | - $attachment_set = ''; | |
| 1973 | - | |
| 1974 | -                            foreach ($attachment as $key => $val) {
 | |
| 1975 | - if ($val != '') | |
| 1976 | - $attachment_set .= $key . " = '" . $val . "', "; | |
| 1977 | - } | |
| 1978 | - $attachment_set = trim($attachment_set, ", "); | |
| 1979 | - | |
| 1980 | -                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
 | |
| 1981 | - | |
| 1982 | -                            if ($menu_order == 1) {
 | |
| 1983 | - $post_type = get_post_type($last_postid); | |
| 1984 | -                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
 | |
| 1985 | - } | |
| 1986 | - $menu_order++; | |
| 1987 | - } | |
| 1988 | - } | |
| 1989 | - | |
| 1990 | - $gd_post_info['package_id'] = $package_id; | |
| 1991 | - | |
| 1992 | - /** This action is documented in geodirectory-functions/post-functions.php */ | |
| 1993 | -                    do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
 | |
| 1994 | - | |
| 1995 | -                    if (!empty($buffer[5])) {
 | |
| 1996 | -                        if (in_array($buffer[5], geodir_get_posttypes())) {
 | |
| 1997 | - $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); | |
| 1998 | - wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); | |
| 1999 | - wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); | |
| 2000 | - | |
| 2001 | - $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; | |
| 2002 | - $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; | |
| 2003 | - geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); | |
| 2004 | - } | |
| 2005 | - } | |
| 2006 | -                } else {
 | |
| 2007 | - $invalid_title++; | |
| 2008 | - } | |
| 2009 | - } | |
| 2010 | - } | |
| 2011 | - } | |
| 2012 | - $return['rowcount'] = $countpost; | |
| 2013 | - $return['invalidcount'] = $address_invalid; | |
| 2014 | - $return['blank_address'] = $blank_address; | |
| 2015 | - $return['upload_files'] = $upload_files; | |
| 2016 | - $return['invalid_post_type'] = $invalid_post_type; | |
| 2017 | - $return['invalid_title'] = $invalid_title; | |
| 2018 | - $return['total_records'] = $total_records; | |
| 2019 | - | |
| 2020 | - echo json_encode($return); | |
| 2021 | - exit; | |
| 1882 | + $my_post['post_title'] = $post_title; | |
| 1883 | + $my_post['post_content'] = $post_desc; | |
| 1884 | + $my_post['post_type'] = addslashes($buffer[5]); | |
| 1885 | + $my_post['post_author'] = $current_post_author; | |
| 1886 | + $my_post['post_status'] = $post_status; | |
| 1887 | + $my_post['post_category'] = $catids_arr; | |
| 1888 | + $my_post['post_tags'] = $tag_arr; | |
| 1889 | + | |
| 1890 | + $gd_post_info['post_tags'] = $tag_arr; | |
| 1891 | + $gd_post_info['post_title'] = $post_title; | |
| 1892 | + $gd_post_info['post_status'] = $post_status; | |
| 1893 | + $gd_post_info['submit_time'] = time(); | |
| 1894 | + $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; | |
| 1895 | + | |
| 1896 | + $last_postid = wp_insert_post($my_post); | |
| 1897 | + $countpost++; | |
| 1898 | + | |
| 1899 | + // Check if we need to save post location as new location | |
| 1900 | +					if ($location_result->location_id > 0) {
 | |
| 1901 | +						if (isset($post_city) && isset($post_region)) {
 | |
| 1902 | + $request_info['post_location'] = array( | |
| 1903 | + 'city' => $post_city, | |
| 1904 | + 'region' => $post_region, | |
| 1905 | + 'country' => $post_country, | |
| 1906 | + 'geo_lat' => $post_latitude, | |
| 1907 | + 'geo_lng' => $post_longitude | |
| 1908 | + ); | |
| 1909 | + | |
| 1910 | + $post_location_info = $request_info['post_location']; | |
| 1911 | + if ($location_id = geodir_add_new_location($post_location_info)) | |
| 1912 | + $post_location_id = $location_id; | |
| 1913 | +						} else {
 | |
| 1914 | + $post_location_id = 0; | |
| 1915 | + } | |
| 1916 | +					} else {
 | |
| 1917 | + $post_location_id = 0; | |
| 1918 | + } | |
| 1919 | + | |
| 1920 | + /* ------- get default package info ----- */ | |
| 1921 | + $payment_info = array(); | |
| 1922 | + $package_info = array(); | |
| 1923 | + | |
| 1924 | + $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); | |
| 1925 | + $package_id = ''; | |
| 1926 | +					if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
 | |
| 1927 | + $package_id = $gd_post_info['package_id']; | |
| 1928 | + } | |
| 1929 | + | |
| 1930 | +					if (!empty($package_info)) {
 | |
| 1931 | + $payment_info['package_id'] = $package_info['pid']; | |
| 1932 | + | |
| 1933 | +						if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
 | |
| 1934 | +							$payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
 | |
| 1935 | +						} else {
 | |
| 1936 | + $payment_info['expire_date'] = 'Never'; | |
| 1937 | + } | |
| 1938 | + | |
| 1939 | + $gd_post_info = array_merge($gd_post_info, $payment_info); | |
| 1940 | + } | |
| 1941 | + | |
| 1942 | + $gd_post_info['post_location_id'] = $post_location_id; | |
| 1943 | + | |
| 1944 | + $post_type = get_post_type($last_postid); | |
| 1945 | + | |
| 1946 | + $table = $plugin_prefix . $post_type . '_detail'; | |
| 1947 | + | |
| 1948 | + geodir_save_post_info($last_postid, $gd_post_info); | |
| 1949 | + | |
| 1950 | +					if (!empty($image_names)) {
 | |
| 1951 | + $upload_files++; | |
| 1952 | + $menu_order = 1; | |
| 1953 | + | |
| 1954 | +						foreach ($image_names as $image_name) {
 | |
| 1955 | +							$img_name_arr = explode('.', $image_name);
 | |
| 1956 | + | |
| 1957 | + $uploads = wp_upload_dir(); | |
| 1958 | + $sub_dir = $uploads['subdir']; | |
| 1959 | + | |
| 1960 | + $arr_file_type = wp_check_filetype($image_name); | |
| 1961 | + $uploaded_file_type = $arr_file_type['type']; | |
| 1962 | + | |
| 1963 | + $attachment = array(); | |
| 1964 | + $attachment['post_id'] = $last_postid; | |
| 1965 | + $attachment['title'] = $img_name_arr[0]; | |
| 1966 | + $attachment['content'] = ''; | |
| 1967 | + $attachment['file'] = $sub_dir . '/' . $image_name; | |
| 1968 | + $attachment['mime_type'] = $uploaded_file_type; | |
| 1969 | + $attachment['menu_order'] = $menu_order; | |
| 1970 | + $attachment['is_featured'] = 0; | |
| 1971 | + | |
| 1972 | + $attachment_set = ''; | |
| 1973 | + | |
| 1974 | +							foreach ($attachment as $key => $val) {
 | |
| 1975 | + if ($val != '') | |
| 1976 | + $attachment_set .= $key . " = '" . $val . "', "; | |
| 1977 | + } | |
| 1978 | + $attachment_set = trim($attachment_set, ", "); | |
| 1979 | + | |
| 1980 | +							$wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
 | |
| 1981 | + | |
| 1982 | +							if ($menu_order == 1) {
 | |
| 1983 | + $post_type = get_post_type($last_postid); | |
| 1984 | +								$wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
 | |
| 1985 | + } | |
| 1986 | + $menu_order++; | |
| 1987 | + } | |
| 1988 | + } | |
| 1989 | + | |
| 1990 | + $gd_post_info['package_id'] = $package_id; | |
| 1991 | + | |
| 1992 | + /** This action is documented in geodirectory-functions/post-functions.php */ | |
| 1993 | +					do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
 | |
| 1994 | + | |
| 1995 | +					if (!empty($buffer[5])) {
 | |
| 1996 | +						if (in_array($buffer[5], geodir_get_posttypes())) {
 | |
| 1997 | + $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); | |
| 1998 | + wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); | |
| 1999 | + wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); | |
| 2000 | + | |
| 2001 | + $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; | |
| 2002 | + $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; | |
| 2003 | + geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); | |
| 2004 | + } | |
| 2005 | + } | |
| 2006 | +				} else {
 | |
| 2007 | + $invalid_title++; | |
| 2008 | + } | |
| 2009 | + } | |
| 2010 | + } | |
| 2011 | + } | |
| 2012 | + $return['rowcount'] = $countpost; | |
| 2013 | + $return['invalidcount'] = $address_invalid; | |
| 2014 | + $return['blank_address'] = $blank_address; | |
| 2015 | + $return['upload_files'] = $upload_files; | |
| 2016 | + $return['invalid_post_type'] = $invalid_post_type; | |
| 2017 | + $return['invalid_title'] = $invalid_title; | |
| 2018 | + $return['total_records'] = $total_records; | |
| 2019 | + | |
| 2020 | + echo json_encode($return); | |
| 2021 | + exit; | |
| 2022 | 2022 | } | 
| 2023 | 2023 | |
| 2024 | 2024 | // Add the tab in left sidebar menu fro import & export page. | 
| @@ -2038,9 +2038,9 @@ discard block | ||
| 2038 | 2038 | * @param $post object $post The post object of the post being saved. | 
| 2039 | 2039 | */ | 
| 2040 | 2040 |  function geodir_update_location_prefix($post_id,$post){
 | 
| 2041 | -    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
 | |
| 2042 | -        update_option('geodir_location_prefix',$post->post_name);
 | |
| 2043 | - } | |
| 2041 | +	if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
 | |
| 2042 | +		update_option('geodir_location_prefix',$post->post_name);
 | |
| 2043 | + } | |
| 2044 | 2044 | |
| 2045 | 2045 | } | 
| 2046 | 2046 | |
| @@ -2051,50 +2051,50 @@ discard block | ||
| 2051 | 2051 |  function geodir_ga_callback(){
 | 
| 2052 | 2052 | |
| 2053 | 2053 |  if(isset($_REQUEST['code']) && $_REQUEST['code']) {
 | 
| 2054 | - $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; | |
| 2055 | - $code = "code=".$_REQUEST['code']; | |
| 2056 | - $grant_type = "&grant_type=authorization_code"; | |
| 2057 | -    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
 | |
| 2058 | -    $client_id = "&client_id=".get_option('geodir_ga_client_id');
 | |
| 2059 | -    $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
 | |
| 2054 | + $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; | |
| 2055 | + $code = "code=".$_REQUEST['code']; | |
| 2056 | + $grant_type = "&grant_type=authorization_code"; | |
| 2057 | +	$redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
 | |
| 2058 | +	$client_id = "&client_id=".get_option('geodir_ga_client_id');
 | |
| 2059 | +	$client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
 | |
| 2060 | 2060 | |
| 2061 | - $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; | |
| 2061 | + $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; | |
| 2062 | 2062 | |
| 2063 | -    $response = wp_remote_post($auth_url, array('timeout' => 15));
 | |
| 2063 | +	$response = wp_remote_post($auth_url, array('timeout' => 15));
 | |
| 2064 | 2064 | |
| 2065 | - //print_r($response); | |
| 2065 | + //print_r($response); | |
| 2066 | 2066 | |
| 2067 | -    $error_msg =  __('Something went wrong','geodirectory');
 | |
| 2068 | -    if(!empty($response['response']['code']) && $response['response']['code']==200){
 | |
| 2067 | +	$error_msg =  __('Something went wrong','geodirectory');
 | |
| 2068 | +	if(!empty($response['response']['code']) && $response['response']['code']==200){
 | |
| 2069 | 2069 | |
| 2070 | - $parts = json_decode($response['body']); | |
| 2071 | - //print_r($parts); | |
| 2072 | -        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
 | |
| 2073 | -        else{
 | |
| 2070 | + $parts = json_decode($response['body']); | |
| 2071 | + //print_r($parts); | |
| 2072 | +		if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
 | |
| 2073 | +		else{
 | |
| 2074 | 2074 | |
| 2075 | -            update_option('gd_ga_access_token', $parts->access_token);
 | |
| 2076 | -            update_option('gd_ga_refresh_token', $parts->refresh_token);
 | |
| 2077 | - ?><script>window.close();</script><?php | |
| 2078 | - } | |
| 2075 | +			update_option('gd_ga_access_token', $parts->access_token);
 | |
| 2076 | +			update_option('gd_ga_refresh_token', $parts->refresh_token);
 | |
| 2077 | + ?><script>window.close();</script><?php | |
| 2078 | + } | |
| 2079 | 2079 | |
| 2080 | 2080 | |
| 2081 | - } | |
| 2082 | -    elseif(!empty($response['response']['code'])) {
 | |
| 2083 | - $parts = json_decode($response['body']); | |
| 2081 | + } | |
| 2082 | +	elseif(!empty($response['response']['code'])) {
 | |
| 2083 | + $parts = json_decode($response['body']); | |
| 2084 | 2084 | |
| 2085 | -        if(isset($parts->error)){
 | |
| 2086 | - echo $parts->error.": ".$parts->error_description;exit; | |
| 2087 | -        }else{
 | |
| 2088 | - echo $error_msg." - #2";exit; | |
| 2089 | - } | |
| 2085 | +		if(isset($parts->error)){
 | |
| 2086 | + echo $parts->error.": ".$parts->error_description;exit; | |
| 2087 | +		}else{
 | |
| 2088 | + echo $error_msg." - #2";exit; | |
| 2089 | + } | |
| 2090 | 2090 | |
| 2091 | -    }else{
 | |
| 2091 | +	}else{
 | |
| 2092 | 2092 | |
| 2093 | - echo $error_msg." - #3";exit; | |
| 2093 | + echo $error_msg." - #3";exit; | |
| 2094 | 2094 | |
| 2095 | - } | |
| 2095 | + } | |
| 2096 | 2096 | } | 
| 2097 | - exit; | |
| 2097 | + exit; | |
| 2098 | 2098 | } | 
| 2099 | 2099 | |
| 2100 | 2100 | add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 ); | 
| @@ -62,7 +62,7 @@ discard block | ||
| 62 | 62 | */ | 
| 63 | 63 | function geodir_get_admin_option_form($current_tab) | 
| 64 | 64 |  {
 | 
| 65 | - geodir_admin_option_form($current_tab);// defined in admin template tags.php | |
| 65 | + geodir_admin_option_form($current_tab); // defined in admin template tags.php | |
| 66 | 66 | } | 
| 67 | 67 | |
| 68 | 68 | |
| @@ -70,7 +70,7 @@ discard block | ||
| 70 | 70 |  add_action('geodir_update_options_compatibility_settings', 'geodir_update_options_compatibility_settings');
 | 
| 71 | 71 |  add_action('geodir_update_options_default_location_settings', 'geodir_location_form_submit');
 | 
| 72 | 72 |  add_action('geodir_before_admin_panel', 'geodir_before_admin_panel'); // this function is in admin_functions.php
 | 
| 73 | -add_action('geodir_before_update_options', 'geodir_before_update_options',10,2);
 | |
| 73 | +add_action('geodir_before_update_options', 'geodir_before_update_options', 10, 2);
 | |
| 74 | 74 | |
| 75 | 75 |  //add_action('geodir_before_admin_panel', 'geodir_autoinstall_admin_header');
 | 
| 76 | 76 | |
| @@ -226,9 +226,9 @@ discard block | ||
| 226 | 226 | |
| 227 | 227 | // Filter-Payment-Manager | 
| 228 | 228 | |
| 229 | -        add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
 | |
| 229 | +        add_meta_box('geodir_post_images', $post_typename.' '.__('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
 | |
| 230 | 230 | |
| 231 | -        add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
 | |
| 231 | +        add_meta_box('geodir_post_info', $post_typename.' '.__('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
 | |
| 232 | 232 | |
| 233 | 233 | // no need of this box as all fields moved to main information box | 
| 234 | 234 |          //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
 | 
| @@ -237,7 +237,7 @@ discard block | ||
| 237 | 237 | |
| 238 | 238 | } | 
| 239 | 239 | |
| 240 | -add_action('save_post', 'geodir_post_information_save',10,2);
 | |
| 240 | +add_action('save_post', 'geodir_post_information_save', 10, 2);
 | |
| 241 | 241 | |
| 242 | 242 | |
| 243 | 243 | |
| @@ -264,10 +264,10 @@ discard block | ||
| 264 | 264 | |
| 265 | 265 | $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); | 
| 266 | 266 | |
| 267 | -            if(!empty($gd_taxonomy)) {
 | |
| 267 | +            if (!empty($gd_taxonomy)) {
 | |
| 268 | 268 |                  foreach ($gd_taxonomy as $tax) {
 | 
| 269 | 269 | |
| 270 | - remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); | |
| 270 | + remove_meta_box($tax.'div', $geodir_post_type, 'normal'); | |
| 271 | 271 | |
| 272 | 272 | } | 
| 273 | 273 | } | 
| @@ -416,7 +416,7 @@ discard block | ||
| 416 | 416 | global $wpdb; | 
| 417 | 417 | $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | 
| 418 | 418 | ?> | 
| 419 | - <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> | |
| 419 | + <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/> | |
| 420 | 420 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> | 
| 421 | 421 | <ul> | 
| 422 | 422 | <?php | 
| @@ -427,18 +427,18 @@ discard block | ||
| 427 | 427 | |
| 428 | 428 | $check_html_variable = $wpdb->get_var( | 
| 429 | 429 | $wpdb->prepare( | 
| 430 | - "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", | |
| 430 | + "SELECT htmlvar_name FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", | |
| 431 | 431 | array($val['htmlvar_name'], $listing_type, $val['field_type']) | 
| 432 | 432 | ) | 
| 433 | 433 | ); | 
| 434 | 434 | |
| 435 | 435 | $display = $check_html_variable ? ' style="display:none;"' : ''; | 
| 436 | 436 | ?> | 
| 437 | - <li <?php echo $display;?>> | |
| 438 | - <a id="gt-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" | |
| 439 | - title="<?php echo $val['site_title'];?>" | |
| 440 | - class="gt-draggable-form-items gt-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" | |
| 441 | - href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory');?></a> | |
| 437 | + <li <?php echo $display; ?>> | |
| 438 | + <a id="gt-<?php echo $val['field_type']; ?>-_-<?php echo $val['htmlvar_name']; ?>" | |
| 439 | + title="<?php echo $val['site_title']; ?>" | |
| 440 | + class="gt-draggable-form-items gt-<?php echo $val['field_type']; ?> geodir-sort-<?php echo $val['htmlvar_name']; ?>" | |
| 441 | + href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory'); ?></a> | |
| 442 | 442 | </li> | 
| 443 | 443 | <?php | 
| 444 | 444 | } | 
| @@ -463,7 +463,7 @@ discard block | ||
| 463 | 463 | <?php | 
| 464 | 464 | global $wpdb; | 
| 465 | 465 | |
| 466 | -        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
 | |
| 466 | +        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
 | |
| 467 | 467 | |
| 468 | 468 |          if (!empty($fields)) {
 | 
| 469 | 469 |              foreach ($fields as $field) {
 | 
| @@ -492,39 +492,39 @@ discard block | ||
| 492 | 492 |  {
 | 
| 493 | 493 | $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; | 
| 494 | 494 | ?> | 
| 495 | - <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> | |
| 495 | + <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/> | |
| 496 | 496 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> | 
| 497 | 497 | <ul class="full"> | 
| 498 | -        <li><a id="gt-fieldset" class="gt-draggable-form-items gt-fieldset" href="javascript:void(0);"><?php _e('Fieldset', 'geodirectory');?></a></li>
 | |
| 498 | +        <li><a id="gt-fieldset" class="gt-draggable-form-items gt-fieldset" href="javascript:void(0);"><?php _e('Fieldset', 'geodirectory'); ?></a></li>
 | |
| 499 | 499 | </ul> | 
| 500 | 500 | <ul> | 
| 501 | 501 | <li><a id="gt-text" class="gt-draggable-form-items gt-text" | 
| 502 | -               href="javascript:void(0);"><b></b><?php _e('Text', 'geodirectory');?></a></li>
 | |
| 502 | +               href="javascript:void(0);"><b></b><?php _e('Text', 'geodirectory'); ?></a></li>
 | |
| 503 | 503 | <li><a id="gt-datepicker" class="gt-draggable-form-items gt-datepicker" | 
| 504 | -               href="javascript:void(0);"><b></b><?php _e('Date', 'geodirectory');?></a></li>
 | |
| 504 | +               href="javascript:void(0);"><b></b><?php _e('Date', 'geodirectory'); ?></a></li>
 | |
| 505 | 505 | <li><a id="gt-textarea" class="gt-draggable-form-items gt-textarea" | 
| 506 | -               href="javascript:void(0);"><b></b><?php _e('Textarea', 'geodirectory');?></a></li>
 | |
| 506 | +               href="javascript:void(0);"><b></b><?php _e('Textarea', 'geodirectory'); ?></a></li>
 | |
| 507 | 507 | <li><a id="gt-time" class="gt-draggable-form-items gt-time" | 
| 508 | -               href="javascript:void(0);"><b></b><?php _e('Time', 'geodirectory');?></a></li>
 | |
| 508 | +               href="javascript:void(0);"><b></b><?php _e('Time', 'geodirectory'); ?></a></li>
 | |
| 509 | 509 | <li><a id="gt-checkbox" class="gt-draggable-form-items gt-checkbox" | 
| 510 | -               href="javascript:void(0);"><b></b><?php _e('Checkbox', 'geodirectory');?></a></li>
 | |
| 510 | +               href="javascript:void(0);"><b></b><?php _e('Checkbox', 'geodirectory'); ?></a></li>
 | |
| 511 | 511 | <li><a id="gt-phone" class="gt-draggable-form-items gt-phone" | 
| 512 | -               href="javascript:void(0);"><b></b><?php _e('Phone', 'geodirectory');?></a></li>
 | |
| 512 | +               href="javascript:void(0);"><b></b><?php _e('Phone', 'geodirectory'); ?></a></li>
 | |
| 513 | 513 | <li><a id="gt-radio" class="gt-draggable-form-items gt-radio" | 
| 514 | -               href="javascript:void(0);"><b></b><?php _e('Radio', 'geodirectory');?></a></li>
 | |
| 514 | +               href="javascript:void(0);"><b></b><?php _e('Radio', 'geodirectory'); ?></a></li>
 | |
| 515 | 515 | <li><a id="gt-email" class="gt-draggable-form-items gt-email" | 
| 516 | -               href="javascript:void(0);"><b></b><?php _e('Email', 'geodirectory');?></a></li>
 | |
| 516 | +               href="javascript:void(0);"><b></b><?php _e('Email', 'geodirectory'); ?></a></li>
 | |
| 517 | 517 | <li><a id="gt-select" class="gt-draggable-form-items gt-select" | 
| 518 | -               href="javascript:void(0);"><b></b><?php _e('Select', 'geodirectory');?></a></li>
 | |
| 519 | -        <!--<li><a id="gt-taxonomy" class="gt-draggable-form-items gt-select" href="javascript:void(0);"><b></b><?php _e('Taxonomy', 'geodirectory');?></a></li>-->
 | |
| 518 | +               href="javascript:void(0);"><b></b><?php _e('Select', 'geodirectory'); ?></a></li>
 | |
| 519 | +        <!--<li><a id="gt-taxonomy" class="gt-draggable-form-items gt-select" href="javascript:void(0);"><b></b><?php _e('Taxonomy', 'geodirectory'); ?></a></li>-->
 | |
| 520 | 520 | <li><a id="gt-multiselect" class="gt-draggable-form-items gt-multiselect" | 
| 521 | -               href="javascript:void(0);"><b></b><?php _e('Multi Select', 'geodirectory');?></a></li>
 | |
| 521 | +               href="javascript:void(0);"><b></b><?php _e('Multi Select', 'geodirectory'); ?></a></li>
 | |
| 522 | 522 | <li><a id="gt-url" class="gt-draggable-form-items gt-url" | 
| 523 | -               href="javascript:void(0);"><b></b><?php _e('URL', 'geodirectory');?></a></li>
 | |
| 523 | +               href="javascript:void(0);"><b></b><?php _e('URL', 'geodirectory'); ?></a></li>
 | |
| 524 | 524 | <li><a id="gt-html" class="gt-draggable-form-items gt-html" | 
| 525 | -               href="javascript:void(0);"><b></b><?php _e('HTML', 'geodirectory');?></a></li>
 | |
| 525 | +               href="javascript:void(0);"><b></b><?php _e('HTML', 'geodirectory'); ?></a></li>
 | |
| 526 | 526 | <li><a id="gt-file" class="gt-draggable-form-items gt-file" | 
| 527 | -               href="javascript:void(0);"><b></b><?php _e('File Upload', 'geodirectory');?></a></li>
 | |
| 527 | +               href="javascript:void(0);"><b></b><?php _e('File Upload', 'geodirectory'); ?></a></li>
 | |
| 528 | 528 | |
| 529 | 529 | </ul> | 
| 530 | 530 | |
| @@ -548,7 +548,7 @@ discard block | ||
| 548 | 548 | <ul class="core"> | 
| 549 | 549 | <?php | 
| 550 | 550 | global $wpdb; | 
| 551 | -        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
 | |
| 551 | +        $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
 | |
| 552 | 552 | |
| 553 | 553 |          if (!empty($fields)) {
 | 
| 554 | 554 |              foreach ($fields as $field) {
 | 
| @@ -635,7 +635,7 @@ discard block | ||
| 635 | 635 | |
| 636 | 636 |      switch ($sub_tab) {
 | 
| 637 | 637 | case 'custom_fields': | 
| 638 | -            $note = sprintf(__('Click on any box below to add a field of that type on add %s listing form. You must be use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type));;
 | |
| 638 | +            $note = sprintf(__('Click on any box below to add a field of that type on add %s listing form. You must be use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type)); ;
 | |
| 639 | 639 | break; | 
| 640 | 640 | |
| 641 | 641 | case 'sorting_options': | 
| @@ -689,7 +689,7 @@ discard block | ||
| 689 | 689 | |
| 690 | 690 |      switch ($sub_tab) {
 | 
| 691 | 691 | case 'custom_fields': | 
| 692 | -            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type));;
 | |
| 692 | +            $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type)); ;
 | |
| 693 | 693 | break; | 
| 694 | 694 | |
| 695 | 695 | case 'sorting_options': | 
| @@ -716,8 +716,8 @@ discard block | ||
| 716 | 716 | |
| 717 | 717 |      if (!get_option('geodir_remove_unnecessary_fields')) {
 | 
| 718 | 718 | |
| 719 | -        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
 | |
| 720 | -            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
 | |
| 719 | +        if ($wpdb->get_var("SHOW COLUMNS FROM ".$plugin_prefix."gd_place_detail WHERE field = 'categories'"))
 | |
| 720 | +            $wpdb->query("ALTER TABLE `".$plugin_prefix."gd_place_detail` DROP `categories`");
 | |
| 721 | 721 | |
| 722 | 722 |          update_option('geodir_remove_unnecessary_fields', '1');
 | 
| 723 | 723 | |
| @@ -745,14 +745,14 @@ discard block | ||
| 745 | 745 | case 'diagnosis' : | 
| 746 | 746 | if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') | 
| 747 | 747 | $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | 
| 748 | -                call_user_func('geodir_diagnose_' . $diagnose_this);
 | |
| 748 | +                call_user_func('geodir_diagnose_'.$diagnose_this);
 | |
| 749 | 749 | exit(); | 
| 750 | 750 | break; | 
| 751 | 751 | |
| 752 | 752 | case 'diagnosis-fix' : | 
| 753 | 753 | if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') | 
| 754 | 754 | $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | 
| 755 | -                call_user_func('geodir_diagnose_' . $diagnose_this);
 | |
| 755 | +                call_user_func('geodir_diagnose_'.$diagnose_this);
 | |
| 756 | 756 | exit(); | 
| 757 | 757 | break; | 
| 758 | 758 | } | 
| @@ -777,50 +777,50 @@ discard block | ||
| 777 | 777 |  {
 | 
| 778 | 778 | global $wpdb; | 
| 779 | 779 | //$filter_arr['output_str'] .='###'.$table.'###'; | 
| 780 | -    if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
 | |
| 781 | -        $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
 | |
| 780 | +    if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0) {
 | |
| 781 | +        $filter_arr['output_str'] .= "<li>".__('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory')."</li>";
 | |
| 782 | 782 | $filter_arr['is_error_during_diagnose'] = true; | 
| 783 | 783 | |
| 784 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
 | |
| 785 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 784 | +    } elseif ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) {
 | |
| 785 | +        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name)."</li>";
 | |
| 786 | 786 | $filter_arr['is_error_during_diagnose'] = true; | 
| 787 | -        $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
 | |
| 787 | +        $filter_arr['output_str'] .= "<li>".__('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory')."</li>";
 | |
| 788 | 788 | $filter_arr['is_error_during_diagnose'] = true; | 
| 789 | 789 | |
| 790 | 790 |          if ($fix) {
 | 
| 791 | -            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
 | |
| 792 | -            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
 | |
| 791 | +            $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$table."_ms_bak"); // get backup table count
 | |
| 792 | +            $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."$table"); // get new table count
 | |
| 793 | 793 | |
| 794 | 794 |              if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
 | 
| 795 | 795 |                  //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
 | 
| 796 | 796 | |
| 797 | -                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
 | |
| 797 | +                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename bak table to new table
 | |
| 798 | 798 | |
| 799 | -                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
 | |
| 800 | -                    $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
 | |
| 799 | +                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) {
 | |
| 800 | +                    $filter_arr['output_str'] .= "<li>".__('-->FIXED: Renamed and backed up the tables', 'geodirectory')."</li>";
 | |
| 801 | 801 |                  } else {
 | 
| 802 | -                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 802 | +                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
 | |
| 803 | 803 | } | 
| 804 | 804 | |
| 805 | 805 |              } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
 | 
| 806 | 806 | |
| 807 | -                $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
 | |
| 808 | -                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
 | |
| 807 | +                $wpdb->query("RENAME TABLE ".$wpdb->prefix."$table TO ".$table."_ms_bak2"); // rename new table to bak2
 | |
| 808 | +                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$wpdb->prefix."$table"); // rename bak table to new table
 | |
| 809 | 809 | |
| 810 | -                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 811 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
 | |
| 810 | +                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 811 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table)."</li>";
 | |
| 812 | 812 |                  } else {
 | 
| 813 | -                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 813 | +                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
 | |
| 814 | 814 | } | 
| 815 | 815 | |
| 816 | 816 |              } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
 | 
| 817 | 817 | |
| 818 | -                $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
 | |
| 818 | +                $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename ms_bak table to ms_bak2
 | |
| 819 | 819 | |
| 820 | -                if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
 | |
| 821 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
 | |
| 820 | +                if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) {
 | |
| 821 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table)."</li>";
 | |
| 822 | 822 |                  } else {
 | 
| 823 | -                    $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
 | |
| 823 | +                    $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
 | |
| 824 | 824 | } | 
| 825 | 825 | |
| 826 | 826 | } | 
| @@ -828,54 +828,54 @@ discard block | ||
| 828 | 828 | } | 
| 829 | 829 | |
| 830 | 830 | |
| 831 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
 | |
| 832 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 831 | +    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) {
 | |
| 832 | +        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name)."</li>";
 | |
| 833 | 833 | $filter_arr['is_error_during_diagnose'] = true; | 
| 834 | 834 | |
| 835 | 835 |          if ($fix) {
 | 
| 836 | 836 |              if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
 | 
| 837 | 837 |                  if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
 | 
| 838 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
 | |
| 838 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table)."</li>";
 | |
| 839 | 839 |                  } else {
 | 
| 840 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
 | |
| 840 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table)."</li>";
 | |
| 841 | 841 | } | 
| 842 | 842 | |
| 843 | -            } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
 | |
| 844 | -                if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
 | |
| 845 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
 | |
| 843 | +            } elseif ($wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."$table") == 0) {// if main table is empty but original is not, delete main and rename original
 | |
| 844 | +                if ($wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."$table")) {
 | |
| 845 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix.$table)."</li>";
 | |
| 846 | 846 |                  } else {
 | 
| 847 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
 | |
| 847 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix.$table)."</li>";
 | |
| 848 | 848 | } | 
| 849 | -                if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 850 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 849 | +                if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 850 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
 | |
| 851 | 851 |                  } else {
 | 
| 852 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 852 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
 | |
| 853 | 853 | } | 
| 854 | 854 |              } else {// else rename the original table to _ms_bak
 | 
| 855 | -                if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 856 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
 | |
| 855 | +                if ($wpdb->query("RENAME TABLE $table TO ".$table."_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 856 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table."_ms_bak")."</li>";
 | |
| 857 | 857 |                  } else {
 | 
| 858 | -                    $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
 | |
| 858 | +                    $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table."_ms_bak")."</li>";
 | |
| 859 | 859 | } | 
| 860 | 860 | } | 
| 861 | 861 | } | 
| 862 | 862 | |
| 863 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
 | |
| 864 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 863 | +    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) {
 | |
| 864 | +        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name)."</li>";
 | |
| 865 | 865 | $filter_arr['is_error_during_diagnose'] = true; | 
| 866 | 866 | |
| 867 | 867 |          if ($fix) {
 | 
| 868 | 868 | // if original table exists but new does not, rename | 
| 869 | -            if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 870 | -                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 869 | +            if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
 | |
| 870 | +                $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
 | |
| 871 | 871 |              } else {
 | 
| 872 | -                $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
 | |
| 872 | +                $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
 | |
| 873 | 873 | } | 
| 874 | 874 | |
| 875 | 875 | } | 
| 876 | 876 | |
| 877 | -    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
 | |
| 878 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 877 | +    } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) {
 | |
| 878 | +        $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name)."</li>";
 | |
| 879 | 879 | $filter_arr['is_error_during_diagnose'] = true; | 
| 880 | 880 | |
| 881 | 881 |          if ($fix) {
 | 
| @@ -889,11 +889,11 @@ discard block | ||
| 889 | 889 |              delete_option('geodir_custom_posts_db_version');
 | 
| 890 | 890 |              delete_option('geodir_reviewratings_db_version');
 | 
| 891 | 891 |              delete_option('geodiradvancesearch_db_version');
 | 
| 892 | -            $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
 | |
| 892 | +            $filter_arr['output_str'] .= "<li>".__('-->TRY: Please refresh page to run table install functions', 'geodirectory')."</li>";
 | |
| 893 | 893 | } | 
| 894 | 894 | |
| 895 | 895 |      } else {
 | 
| 896 | -        $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
 | |
| 896 | +        $filter_arr['output_str'] .= "<li>".sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name)."</li>";
 | |
| 897 | 897 | } | 
| 898 | 898 | return $filter_arr; | 
| 899 | 899 | } | 
| @@ -922,23 +922,23 @@ discard block | ||
| 922 | 922 |      if (!empty($all_postypes)) {
 | 
| 923 | 923 |          foreach ($all_postypes as $key) {
 | 
| 924 | 924 | // update each GD CPT | 
| 925 | -            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
 | |
| 925 | +            $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail d");
 | |
| 926 | 926 | |
| 927 | 927 |              if (!empty($posts)) {
 | 
| 928 | 928 | |
| 929 | 929 |                  foreach ($posts as $p) {
 | 
| 930 | 930 | $p->post_type = $key; | 
| 931 | -                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
 | |
| 931 | +                    $raw_tags = wp_get_object_terms($p->post_id, $p->post_type.'_tags', array('fields' => 'names'));
 | |
| 932 | 932 |                      if (empty($raw_tags)) {
 | 
| 933 | 933 | $post_tags = ''; | 
| 934 | 934 |                      } else {
 | 
| 935 | 935 |                          $post_tags = implode(",", $raw_tags);
 | 
| 936 | 936 | } | 
| 937 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; | |
| 938 | -                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
 | |
| 937 | + $tablename = $plugin_prefix.$p->post_type.'_detail'; | |
| 938 | +                    $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
 | |
| 939 | 939 | |
| 940 | 940 | } | 
| 941 | -                $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
 | |
| 941 | +                $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>";
 | |
| 942 | 942 | } | 
| 943 | 943 | |
| 944 | 944 | } | 
| @@ -947,7 +947,7 @@ discard block | ||
| 947 | 947 | |
| 948 | 948 |      if ($is_error_during_diagnose) {
 | 
| 949 | 949 | $info_div_class = "geodir_problem_info"; | 
| 950 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 950 | +        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 951 | 951 |      } else {
 | 
| 952 | 952 | $info_div_class = "geodir_noproblem_info"; | 
| 953 | 953 | $fix_button_txt = ''; | 
| @@ -984,29 +984,29 @@ discard block | ||
| 984 | 984 |      if (!empty($all_postypes)) {
 | 
| 985 | 985 |          foreach ($all_postypes as $key) {
 | 
| 986 | 986 | // update each GD CTP | 
| 987 | -            $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
 | |
| 987 | +            $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail d WHERE d.".$key."category='' ");
 | |
| 988 | 988 | |
| 989 | 989 |              if (!empty($posts)) {
 | 
| 990 | 990 | |
| 991 | 991 |                  foreach ($posts as $p) {
 | 
| 992 | 992 | $p->post_type = $key; | 
| 993 | -                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
 | |
| 993 | +                    $raw_cats = wp_get_object_terms($p->post_id, $p->post_type.'category', array('fields' => 'ids'));
 | |
| 994 | 994 | |
| 995 | 995 |                      if (empty($raw_cats)) {
 | 
| 996 | 996 | $post_categories = get_post_meta($p->post_id, 'post_categories', true); | 
| 997 | 997 | |
| 998 | -                        if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
 | |
| 999 | -                            $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
 | |
| 1000 | -                            foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
 | |
| 998 | +                        if (!empty($post_categories) && !empty($post_categories[$p->post_type.'category'])) {
 | |
| 999 | +                            $post_categories[$p->post_type.'category'] = str_replace("d:", "", $post_categories[$p->post_type.'category']);
 | |
| 1000 | +                            foreach (explode(",", $post_categories[$p->post_type.'category']) as $cat_part) {
 | |
| 1001 | 1001 |                                  if (is_numeric($cat_part)) {
 | 
| 1002 | - $raw_cats[] = (int)$cat_part; | |
| 1002 | + $raw_cats[] = (int) $cat_part; | |
| 1003 | 1003 | } | 
| 1004 | 1004 | } | 
| 1005 | 1005 | |
| 1006 | 1006 | } | 
| 1007 | 1007 | |
| 1008 | 1008 |                          if (!empty($raw_cats)) {
 | 
| 1009 | - $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); | |
| 1009 | + $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type.'category'); | |
| 1010 | 1010 | |
| 1011 | 1011 | } | 
| 1012 | 1012 | |
| @@ -1016,14 +1016,14 @@ discard block | ||
| 1016 | 1016 |                      if (empty($raw_cats)) {
 | 
| 1017 | 1017 | $post_cats = ''; | 
| 1018 | 1018 |                      } else {
 | 
| 1019 | -                        $post_cats = ',' . implode(",", $raw_cats) . ',';
 | |
| 1019 | +                        $post_cats = ','.implode(",", $raw_cats).',';
 | |
| 1020 | 1020 | } | 
| 1021 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; | |
| 1022 | -                    $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
 | |
| 1021 | + $tablename = $plugin_prefix.$p->post_type.'_detail'; | |
| 1022 | +                    $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET ".$p->post_type."category=%s WHERE post_id =%d", $post_cats, $p->post_id));
 | |
| 1023 | 1023 | } | 
| 1024 | 1024 | |
| 1025 | 1025 | } | 
| 1026 | -            $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
 | |
| 1026 | +            $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>";
 | |
| 1027 | 1027 | |
| 1028 | 1028 | } | 
| 1029 | 1029 | |
| @@ -1031,7 +1031,7 @@ discard block | ||
| 1031 | 1031 | |
| 1032 | 1032 |      if ($is_error_during_diagnose) {
 | 
| 1033 | 1033 | $info_div_class = "geodir_problem_info"; | 
| 1034 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1034 | +        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1035 | 1035 |      } else {
 | 
| 1036 | 1036 | $info_div_class = "geodir_noproblem_info"; | 
| 1037 | 1037 | $fix_button_txt = ''; | 
| @@ -1084,15 +1084,15 @@ discard block | ||
| 1084 | 1084 |      if (!empty($ver_arr)) {
 | 
| 1085 | 1085 |          foreach ($ver_arr as $key => $val) {
 | 
| 1086 | 1086 |              if (delete_option($val)) {
 | 
| 1087 | -                $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
 | |
| 1087 | +                $output_str .= "<li>".$key.__(' Version: Deleted', 'geodirectory')."</li>";
 | |
| 1088 | 1088 |              } else {
 | 
| 1089 | -                $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
 | |
| 1089 | +                $output_str .= "<li>".$key.__(' Version: Not Found', 'geodirectory')."</li>";
 | |
| 1090 | 1090 | } | 
| 1091 | 1091 | |
| 1092 | 1092 | } | 
| 1093 | 1093 | |
| 1094 | 1094 |          if ($output_str) {
 | 
| 1095 | -            $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
 | |
| 1095 | +            $output_str .= "<li><strong>".__(' Upgrade/install scripts will run on next page reload.', 'geodirectory')."</strong></li>";
 | |
| 1096 | 1096 | } | 
| 1097 | 1097 | |
| 1098 | 1098 | } | 
| @@ -1129,43 +1129,43 @@ discard block | ||
| 1129 | 1129 | $output_str = ''; | 
| 1130 | 1130 | |
| 1131 | 1131 | // check review locations | 
| 1132 | -    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
 | |
| 1133 | -        $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
 | |
| 1132 | +    if ($wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
 | |
| 1133 | +        $output_str .= "<li>".__('Review locations missing or broken', 'geodirectory')."</li>";
 | |
| 1134 | 1134 | $is_error_during_diagnose = true; | 
| 1135 | 1135 | |
| 1136 | 1136 |          if ($fix) {
 | 
| 1137 | 1137 |              if (geodir_fix_review_location()) {
 | 
| 1138 | -                $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
 | |
| 1138 | +                $output_str .= "<li><strong>".__('-->FIXED: Review locations fixed', 'geodirectory')."</strong></li>";
 | |
| 1139 | 1139 |              } else {
 | 
| 1140 | -                $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1140 | +                $output_str .= "<li><strong>".__('-->FAILED: Review locations fix failed', 'geodirectory')."</strong></li>";
 | |
| 1141 | 1141 | } | 
| 1142 | 1142 | } | 
| 1143 | 1143 | |
| 1144 | 1144 |      } else {
 | 
| 1145 | -        $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
 | |
| 1145 | +        $output_str .= "<li>".__('Review locations ok', 'geodirectory')."</li>";
 | |
| 1146 | 1146 | } | 
| 1147 | 1147 | |
| 1148 | 1148 | // check review content | 
| 1149 | -    if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
 | |
| 1150 | -        $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
 | |
| 1149 | +    if ($wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_content IS NULL")) {
 | |
| 1150 | +        $output_str .= "<li>".__('Review content missing or broken', 'geodirectory')."</li>";
 | |
| 1151 | 1151 | $is_error_during_diagnose = true; | 
| 1152 | 1152 | |
| 1153 | 1153 |          if ($fix) {
 | 
| 1154 | 1154 |              if (geodir_fix_review_content()) {
 | 
| 1155 | -                $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
 | |
| 1155 | +                $output_str .= "<li><strong>".__('-->FIXED: Review content fixed', 'geodirectory')."</strong></li>";
 | |
| 1156 | 1156 |              } else {
 | 
| 1157 | -                $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1157 | +                $output_str .= "<li><strong>".__('-->FAILED: Review content fix failed', 'geodirectory')."</strong></li>";
 | |
| 1158 | 1158 | } | 
| 1159 | 1159 | } | 
| 1160 | 1160 | |
| 1161 | 1161 |      } else {
 | 
| 1162 | -        $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
 | |
| 1162 | +        $output_str .= "<li>".__('Review content ok', 'geodirectory')."</li>";
 | |
| 1163 | 1163 | } | 
| 1164 | 1164 | |
| 1165 | 1165 | |
| 1166 | 1166 |      if ($is_error_during_diagnose) {
 | 
| 1167 | 1167 | $info_div_class = "geodir_problem_info"; | 
| 1168 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1168 | +        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
 | |
| 1169 | 1169 |      } else {
 | 
| 1170 | 1170 | $info_div_class = "geodir_noproblem_info"; | 
| 1171 | 1171 | $fix_button_txt = ''; | 
| @@ -1229,7 +1229,7 @@ discard block | ||
| 1229 | 1229 | |
| 1230 | 1230 |      if ($is_error_during_diagnose) {
 | 
| 1231 | 1231 | $info_div_class = "geodir_problem_info"; | 
| 1232 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
 | |
| 1232 | +        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
 | |
| 1233 | 1233 |      } else {
 | 
| 1234 | 1234 | $info_div_class = "geodir_noproblem_info"; | 
| 1235 | 1235 | $fix_button_txt = ''; | 
| @@ -1263,7 +1263,7 @@ discard block | ||
| 1263 | 1263 |      else {
 | 
| 1264 | 1264 | $page_found = $wpdb->get_var( | 
| 1265 | 1265 | $wpdb->prepare( | 
| 1266 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", | |
| 1266 | + "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;", | |
| 1267 | 1267 | array($slug) | 
| 1268 | 1268 | ) | 
| 1269 | 1269 | ); | 
| @@ -1309,18 +1309,18 @@ discard block | ||
| 1309 | 1309 | ////////////////////////////////// | 
| 1310 | 1310 |      $option_value = get_option('geodir_home_page');
 | 
| 1311 | 1311 | $page = get_post($option_value); | 
| 1312 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1312 | +    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
 | |
| 1313 | 1313 | |
| 1314 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1315 | -        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1314 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') | |
| 1315 | +        $output_str .= "<li>".__('GD Home page exists with proper setting.', 'geodirectory')."</li>";
 | |
| 1316 | 1316 |      else {
 | 
| 1317 | 1317 | $is_error_during_diagnose = true; | 
| 1318 | -        $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1318 | +        $output_str .= "<li><strong>".__('GD Home page is missing.', 'geodirectory')."</strong></li>";
 | |
| 1319 | 1319 |          if ($fix) {
 | 
| 1320 | 1320 |              if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
 | 
| 1321 | -                $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1321 | +                $output_str .= "<li><strong>".__('-->FIXED: GD Home page fixed', 'geodirectory')."</strong></li>";
 | |
| 1322 | 1322 |              } else {
 | 
| 1323 | -                $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1323 | +                $output_str .= "<li><strong>".__('-->FAILED: GD Home page fix failed', 'geodirectory')."</strong></li>";
 | |
| 1324 | 1324 | } | 
| 1325 | 1325 | } | 
| 1326 | 1326 | } | 
| @@ -1334,18 +1334,18 @@ discard block | ||
| 1334 | 1334 | ////////////////////////////////// | 
| 1335 | 1335 |      $option_value = get_option('geodir_add_listing_page');
 | 
| 1336 | 1336 | $page = get_post($option_value); | 
| 1337 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1337 | +    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
 | |
| 1338 | 1338 | |
| 1339 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1340 | -        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1339 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') | |
| 1340 | +        $output_str .= "<li>".__('Add Listing page exists with proper setting.', 'geodirectory')."</li>";
 | |
| 1341 | 1341 |      else {
 | 
| 1342 | 1342 | $is_error_during_diagnose = true; | 
| 1343 | -        $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1343 | +        $output_str .= "<li><strong>".__('Add Listing page is missing.', 'geodirectory')."</strong></li>";
 | |
| 1344 | 1344 |          if ($fix) {
 | 
| 1345 | 1345 |              if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
 | 
| 1346 | -                $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1346 | +                $output_str .= "<li><strong>".__('-->FIXED: Add Listing page fixed', 'geodirectory')."</strong></li>";
 | |
| 1347 | 1347 |              } else {
 | 
| 1348 | -                $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1348 | +                $output_str .= "<li><strong>".__('-->FAILED: Add Listing page fix failed', 'geodirectory')."</strong></li>";
 | |
| 1349 | 1349 | } | 
| 1350 | 1350 | } | 
| 1351 | 1351 | } | 
| @@ -1360,18 +1360,18 @@ discard block | ||
| 1360 | 1360 | ////////////////////////////////// | 
| 1361 | 1361 |      $option_value = get_option('geodir_preview_page');
 | 
| 1362 | 1362 | $page = get_post($option_value); | 
| 1363 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1363 | +    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
 | |
| 1364 | 1364 | |
| 1365 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1366 | -        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1365 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') | |
| 1366 | +        $output_str .= "<li>".__('Listing Preview page exists with proper setting.', 'geodirectory')."</li>";
 | |
| 1367 | 1367 |      else {
 | 
| 1368 | 1368 | $is_error_during_diagnose = true; | 
| 1369 | -        $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1369 | +        $output_str .= "<li><strong>".__('Listing Preview page is missing.', 'geodirectory')."</strong></li>";
 | |
| 1370 | 1370 |          if ($fix) {
 | 
| 1371 | 1371 |              if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
 | 
| 1372 | -                $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1372 | +                $output_str .= "<li><strong>".__('-->FIXED: Listing Preview page fixed', 'geodirectory')."</strong></li>";
 | |
| 1373 | 1373 |              } else {
 | 
| 1374 | -                $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1374 | +                $output_str .= "<li><strong>".__('-->FAILED: Listing Preview page fix failed', 'geodirectory')."</strong></li>";
 | |
| 1375 | 1375 | } | 
| 1376 | 1376 | } | 
| 1377 | 1377 | } | 
| @@ -1385,18 +1385,18 @@ discard block | ||
| 1385 | 1385 | ////////////////////////////////// | 
| 1386 | 1386 |      $option_value = get_option('geodir_success_page');
 | 
| 1387 | 1387 | $page = get_post($option_value); | 
| 1388 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1388 | +    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
 | |
| 1389 | 1389 | |
| 1390 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1391 | -        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1390 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') | |
| 1391 | +        $output_str .= "<li>".__('Listing Success page exists with proper setting.', 'geodirectory')."</li>";
 | |
| 1392 | 1392 |      else {
 | 
| 1393 | 1393 | $is_error_during_diagnose = true; | 
| 1394 | -        $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1394 | +        $output_str .= "<li><strong>".__('Listing Success page is missing.', 'geodirectory')."</strong></li>";
 | |
| 1395 | 1395 |          if ($fix) {
 | 
| 1396 | 1396 |              if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
 | 
| 1397 | -                $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1397 | +                $output_str .= "<li><strong>".__('-->FIXED: Listing Success page fixed', 'geodirectory')."</strong></li>";
 | |
| 1398 | 1398 |              } else {
 | 
| 1399 | -                $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1399 | +                $output_str .= "<li><strong>".__('-->FAILED: Listing Success page fix failed', 'geodirectory')."</strong></li>";
 | |
| 1400 | 1400 | } | 
| 1401 | 1401 | } | 
| 1402 | 1402 | } | 
| @@ -1410,18 +1410,18 @@ discard block | ||
| 1410 | 1410 | ////////////////////////////////// | 
| 1411 | 1411 |      $option_value = get_option('geodir_info_page');
 | 
| 1412 | 1412 | $page = get_post($option_value); | 
| 1413 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1413 | +    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
 | |
| 1414 | 1414 | |
| 1415 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1416 | -        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1415 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') | |
| 1416 | +        $output_str .= "<li>".__('Info page exists with proper setting.', 'geodirectory')."</li>";
 | |
| 1417 | 1417 |      else {
 | 
| 1418 | 1418 | $is_error_during_diagnose = true; | 
| 1419 | -        $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1419 | +        $output_str .= "<li><strong>".__('Info page is missing.', 'geodirectory')."</strong></li>";
 | |
| 1420 | 1420 |          if ($fix) {
 | 
| 1421 | 1421 |              if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
 | 
| 1422 | -                $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1422 | +                $output_str .= "<li><strong>".__('-->FIXED: Info page fixed', 'geodirectory')."</strong></li>";
 | |
| 1423 | 1423 |              } else {
 | 
| 1424 | -                $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1424 | +                $output_str .= "<li><strong>".__('-->FAILED: Info page fix failed', 'geodirectory')."</strong></li>";
 | |
| 1425 | 1425 | } | 
| 1426 | 1426 | } | 
| 1427 | 1427 | } | 
| @@ -1435,18 +1435,18 @@ discard block | ||
| 1435 | 1435 | ////////////////////////////////// | 
| 1436 | 1436 |      $option_value = get_option('geodir_login_page');
 | 
| 1437 | 1437 | $page = get_post($option_value); | 
| 1438 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1438 | +    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
 | |
| 1439 | 1439 | |
| 1440 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1441 | -        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1440 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') | |
| 1441 | +        $output_str .= "<li>".__('Login page exists with proper setting.', 'geodirectory')."</li>";
 | |
| 1442 | 1442 |      else {
 | 
| 1443 | 1443 | $is_error_during_diagnose = true; | 
| 1444 | -        $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1444 | +        $output_str .= "<li><strong>".__('Login page is missing.', 'geodirectory')."</strong></li>";
 | |
| 1445 | 1445 |          if ($fix) {
 | 
| 1446 | 1446 |              if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
 | 
| 1447 | -                $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1447 | +                $output_str .= "<li><strong>".__('-->FIXED: Login page fixed', 'geodirectory')."</strong></li>";
 | |
| 1448 | 1448 |              } else {
 | 
| 1449 | -                $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1449 | +                $output_str .= "<li><strong>".__('-->FAILED: Login page fix failed', 'geodirectory')."</strong></li>";
 | |
| 1450 | 1450 | } | 
| 1451 | 1451 | } | 
| 1452 | 1452 | } | 
| @@ -1460,18 +1460,18 @@ discard block | ||
| 1460 | 1460 | ////////////////////////////////// | 
| 1461 | 1461 |      $option_value = get_option('geodir_location_page');
 | 
| 1462 | 1462 | $page = get_post($option_value); | 
| 1463 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1463 | +    if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
 | |
| 1464 | 1464 | |
| 1465 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1466 | -        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1465 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') | |
| 1466 | +        $output_str .= "<li>".__('Location page exists with proper setting.', 'geodirectory')."</li>";
 | |
| 1467 | 1467 |      else {
 | 
| 1468 | 1468 | $is_error_during_diagnose = true; | 
| 1469 | -        $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
 | |
| 1469 | +        $output_str .= "<li><strong>".__('Location page is missing.', 'geodirectory')."</strong></li>";
 | |
| 1470 | 1470 |          if ($fix) {
 | 
| 1471 | 1471 |              if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
 | 
| 1472 | -                $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
 | |
| 1472 | +                $output_str .= "<li><strong>".__('-->FIXED: Location page fixed', 'geodirectory')."</strong></li>";
 | |
| 1473 | 1473 |              } else {
 | 
| 1474 | -                $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
 | |
| 1474 | +                $output_str .= "<li><strong>".__('-->FAILED: Location page fix failed', 'geodirectory')."</strong></li>";
 | |
| 1475 | 1475 | } | 
| 1476 | 1476 | } | 
| 1477 | 1477 | } | 
| @@ -1480,13 +1480,13 @@ discard block | ||
| 1480 | 1480 | /* Diagnose Location Page Ends */ | 
| 1481 | 1481 | //////////////////////////////// | 
| 1482 | 1482 | |
| 1483 | -    $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
 | |
| 1483 | +    $page_chk_arr = array('output_str'=>$output_str, 'is_error_during_diagnose'=>$is_error_during_diagnose);
 | |
| 1484 | 1484 | /** | 
| 1485 | 1485 | * This action is called at the end of the GD Tools page check function. | 
| 1486 | 1486 | * | 
| 1487 | 1487 | * @since 1.5.2 | 
| 1488 | 1488 | */ | 
| 1489 | -    $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
 | |
| 1489 | +    $page_chk_arr = apply_filters('geodir_diagnose_default_pages', $page_chk_arr);
 | |
| 1490 | 1490 | |
| 1491 | 1491 | $output_str = $page_chk_arr['output_str']; | 
| 1492 | 1492 | $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; | 
| @@ -1496,7 +1496,7 @@ discard block | ||
| 1496 | 1496 | flush_rewrite_rules(); | 
| 1497 | 1497 | } | 
| 1498 | 1498 | $info_div_class = "geodir_problem_info"; | 
| 1499 | -        $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
 | |
| 1499 | +        $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
 | |
| 1500 | 1500 |      } else {
 | 
| 1501 | 1501 | $info_div_class = "geodir_noproblem_info"; | 
| 1502 | 1502 | $fix_button_txt = ''; | 
| @@ -1523,10 +1523,10 @@ discard block | ||
| 1523 | 1523 | $output_str = ''; | 
| 1524 | 1524 | |
| 1525 | 1525 |      if ($is_error_during_diagnose) {
 | 
| 1526 | -        $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
 | |
| 1526 | +        $output_str .= "<li>".__('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory').' '.geodir_plugin_path().'/db-language.php'."</li>";
 | |
| 1527 | 1527 | $info_div_class = "geodir_problem_info"; | 
| 1528 | 1528 |      } else {
 | 
| 1529 | -        $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
 | |
| 1529 | +        $output_str .= "<li>".__('Load custom fields in to file for translation: ok', 'geodirectory')."</li>";
 | |
| 1530 | 1530 | $info_div_class = "geodir_noproblem_info"; | 
| 1531 | 1531 | $fix_button_txt = ''; | 
| 1532 | 1532 | } | 
| @@ -1568,17 +1568,17 @@ discard block | ||
| 1568 | 1568 | global $wpdb, $wp_query, $plugin_prefix; | 
| 1569 | 1569 | |
| 1570 | 1570 |      if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
 | 
| 1571 | - $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; | |
| 1571 | + $table = $plugin_prefix.$wp_query->query_vars['post_type'].'_detail'; | |
| 1572 | 1572 | |
| 1573 | - $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; | |
| 1573 | + $join = $clauses['join'].' INNER JOIN '.$table.' AS gd_posts ON (gd_posts.post_id = '.$wpdb->posts.'.ID)'; | |
| 1574 | 1574 | $clauses['join'] = $join; | 
| 1575 | 1575 | |
| 1576 | - $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; | |
| 1576 | + $fields = $clauses['fields'] != '' ? $clauses['fields'].', ' : ''; | |
| 1577 | 1577 | $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire'; | 
| 1578 | 1578 | $clauses['fields'] = $fields; | 
| 1579 | 1579 | |
| 1580 | 1580 | $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; | 
| 1581 | - $orderby = 'gd_expire ' . $order; | |
| 1581 | + $orderby = 'gd_expire '.$order; | |
| 1582 | 1582 | $clauses['orderby'] = $orderby; | 
| 1583 | 1583 | } | 
| 1584 | 1584 | return $clauses; | 
| @@ -1621,7 +1621,7 @@ discard block | ||
| 1621 | 1621 | global $current_user; | 
| 1622 | 1622 | $upload_dir = wp_upload_dir(); | 
| 1623 | 1623 | |
| 1624 | - $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; | |
| 1624 | + $file = $upload_dir['path'].'/temp_'.$current_user->data->ID.'/geodir_tmp.csv'; | |
| 1625 | 1625 | $handle = fopen($file, 'w'); | 
| 1626 | 1626 | |
| 1627 | 1627 | fwrite($handle, $input); | 
| @@ -1666,7 +1666,7 @@ discard block | ||
| 1666 | 1666 | $uploads_dir = $uploads['path']; | 
| 1667 | 1667 |      $image_name_arr = explode('/', $filename);
 | 
| 1668 | 1668 | $filename = end($image_name_arr); | 
| 1669 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; | |
| 1669 | + $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename; | |
| 1670 | 1670 | $return = array(); | 
| 1671 | 1671 | $return['file'] = $uploadedFile; | 
| 1672 | 1672 |      $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
 | 
| @@ -1683,8 +1683,8 @@ discard block | ||
| 1683 | 1683 | |
| 1684 | 1684 |                  if (($handle = fopen($target_path, "r")) !== FALSE) {
 | 
| 1685 | 1685 |                      while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
 | 
| 1686 | -                        if(is_array($data) && !empty($data)) {
 | |
| 1687 | -                            $file[] = '"' . implode('","', $data) . '"';
 | |
| 1686 | +                        if (is_array($data) && !empty($data)) {
 | |
| 1687 | +                            $file[] = '"'.implode('","', $data).'"';
 | |
| 1688 | 1688 | } | 
| 1689 | 1689 | } | 
| 1690 | 1690 | fclose($handle); | 
| @@ -1801,10 +1801,10 @@ discard block | ||
| 1801 | 1801 |                      $tag_arr = explode(',', $post_tags);
 | 
| 1802 | 1802 | } | 
| 1803 | 1803 | |
| 1804 | - $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database | |
| 1804 | + $table = $plugin_prefix.$buffer[5].'_detail'; // check table in database | |
| 1805 | 1805 | |
| 1806 | 1806 | $error = ''; | 
| 1807 | -                if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
 | |
| 1807 | +                if ($wpdb->get_var("SHOW TABLES LIKE '".$table."'") != $table) {
 | |
| 1808 | 1808 | $invalid_post_type++; | 
| 1809 | 1809 | continue; | 
| 1810 | 1810 | } | 
| @@ -1830,7 +1830,7 @@ discard block | ||
| 1830 | 1830 |                              if ($buffer[$c] != '0' && $buffer[$c] != '') {
 | 
| 1831 | 1831 |                                  $submitdata = date('Y-m-d');
 | 
| 1832 | 1832 | |
| 1833 | -                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
 | |
| 1833 | +                                $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata."+".addslashes($buffer[$c])." days"));
 | |
| 1834 | 1834 |                              } else {
 | 
| 1835 | 1835 | $gd_post_info['expire_date'] = 'Never'; | 
| 1836 | 1836 | } | 
| @@ -1858,7 +1858,7 @@ discard block | ||
| 1858 | 1858 | |
| 1859 | 1859 | // Post status | 
| 1860 | 1860 |  						if ($customKeyarray[$c] == 'post_status') {
 | 
| 1861 | - $post_status = sanitize_key( $buffer[$c] ); | |
| 1861 | + $post_status = sanitize_key($buffer[$c]); | |
| 1862 | 1862 | } | 
| 1863 | 1863 | } | 
| 1864 | 1864 | |
| @@ -1876,8 +1876,8 @@ discard block | ||
| 1876 | 1876 | |
| 1877 | 1877 | // Default post status | 
| 1878 | 1878 | $default_status = 'publish'; | 
| 1879 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; | |
| 1880 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; | |
| 1879 | + $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status; | |
| 1880 | + $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status; | |
| 1881 | 1881 | |
| 1882 | 1882 | $my_post['post_title'] = $post_title; | 
| 1883 | 1883 | $my_post['post_content'] = $post_desc; | 
| @@ -1921,7 +1921,7 @@ discard block | ||
| 1921 | 1921 | $payment_info = array(); | 
| 1922 | 1922 | $package_info = array(); | 
| 1923 | 1923 | |
| 1924 | - $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); | |
| 1924 | + $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]); | |
| 1925 | 1925 | $package_id = ''; | 
| 1926 | 1926 |                      if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
 | 
| 1927 | 1927 | $package_id = $gd_post_info['package_id']; | 
| @@ -1931,7 +1931,7 @@ discard block | ||
| 1931 | 1931 | $payment_info['package_id'] = $package_info['pid']; | 
| 1932 | 1932 | |
| 1933 | 1933 |                          if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
 | 
| 1934 | -                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
 | |
| 1934 | +                            $payment_info['expire_date'] = date('Y-m-d', strtotime("+".$package_info['alive_days']." days"));
 | |
| 1935 | 1935 |                          } else {
 | 
| 1936 | 1936 | $payment_info['expire_date'] = 'Never'; | 
| 1937 | 1937 | } | 
| @@ -1943,7 +1943,7 @@ discard block | ||
| 1943 | 1943 | |
| 1944 | 1944 | $post_type = get_post_type($last_postid); | 
| 1945 | 1945 | |
| 1946 | - $table = $plugin_prefix . $post_type . '_detail'; | |
| 1946 | + $table = $plugin_prefix.$post_type.'_detail'; | |
| 1947 | 1947 | |
| 1948 | 1948 | geodir_save_post_info($last_postid, $gd_post_info); | 
| 1949 | 1949 | |
| @@ -1964,7 +1964,7 @@ discard block | ||
| 1964 | 1964 | $attachment['post_id'] = $last_postid; | 
| 1965 | 1965 | $attachment['title'] = $img_name_arr[0]; | 
| 1966 | 1966 | $attachment['content'] = ''; | 
| 1967 | - $attachment['file'] = $sub_dir . '/' . $image_name; | |
| 1967 | + $attachment['file'] = $sub_dir.'/'.$image_name; | |
| 1968 | 1968 | $attachment['mime_type'] = $uploaded_file_type; | 
| 1969 | 1969 | $attachment['menu_order'] = $menu_order; | 
| 1970 | 1970 | $attachment['is_featured'] = 0; | 
| @@ -1973,15 +1973,15 @@ discard block | ||
| 1973 | 1973 | |
| 1974 | 1974 |                              foreach ($attachment as $key => $val) {
 | 
| 1975 | 1975 | if ($val != '') | 
| 1976 | - $attachment_set .= $key . " = '" . $val . "', "; | |
| 1976 | + $attachment_set .= $key." = '".$val."', "; | |
| 1977 | 1977 | } | 
| 1978 | 1978 | $attachment_set = trim($attachment_set, ", "); | 
| 1979 | 1979 | |
| 1980 | -                            $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
 | |
| 1980 | +                            $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
 | |
| 1981 | 1981 | |
| 1982 | 1982 |                              if ($menu_order == 1) {
 | 
| 1983 | 1983 | $post_type = get_post_type($last_postid); | 
| 1984 | -                                $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
 | |
| 1984 | +                                $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($sub_dir.'/'.$image_name, $last_postid)));
 | |
| 1985 | 1985 | } | 
| 1986 | 1986 | $menu_order++; | 
| 1987 | 1987 | } | 
| @@ -2022,11 +2022,11 @@ discard block | ||
| 2022 | 2022 | } | 
| 2023 | 2023 | |
| 2024 | 2024 | // Add the tab in left sidebar menu fro import & export page. | 
| 2025 | -add_filter( 'geodir_settings_tabs_array', 'geodir_import_export_tab', 94 ); | |
| 2025 | +add_filter('geodir_settings_tabs_array', 'geodir_import_export_tab', 94);
 | |
| 2026 | 2026 | |
| 2027 | 2027 | // Handle ajax request for import/export. | 
| 2028 | -add_action( 'wp_ajax_geodir_import_export', 'geodir_ajax_import_export' ); | |
| 2029 | -add_action( 'wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export' ); | |
| 2028 | +add_action('wp_ajax_geodir_import_export', 'geodir_ajax_import_export');
 | |
| 2029 | +add_action('wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export');
 | |
| 2030 | 2030 | |
| 2031 | 2031 | |
| 2032 | 2032 | /** | 
| @@ -2037,40 +2037,40 @@ discard block | ||
| 2037 | 2037 | * @param $post_id int $post_id The post ID of the post being saved. | 
| 2038 | 2038 | * @param $post object $post The post object of the post being saved. | 
| 2039 | 2039 | */ | 
| 2040 | -function geodir_update_location_prefix($post_id,$post){
 | |
| 2041 | -    if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
 | |
| 2042 | -        update_option('geodir_location_prefix',$post->post_name);
 | |
| 2040 | +function geodir_update_location_prefix($post_id, $post) {
 | |
| 2041 | +    if ($post->post_type == 'page' && $post->post_name && $post_id == get_option('geodir_location_page')) {
 | |
| 2042 | +        update_option('geodir_location_prefix', $post->post_name);
 | |
| 2043 | 2043 | } | 
| 2044 | 2044 | |
| 2045 | 2045 | } | 
| 2046 | 2046 | |
| 2047 | -add_action('save_post', 'geodir_update_location_prefix',10,2);
 | |
| 2047 | +add_action('save_post', 'geodir_update_location_prefix', 10, 2);
 | |
| 2048 | 2048 | |
| 2049 | -add_action( 'wp_ajax_geodir_ga_callback', 'geodir_ga_callback' ); | |
| 2049 | +add_action('wp_ajax_geodir_ga_callback', 'geodir_ga_callback');
 | |
| 2050 | 2050 | |
| 2051 | -function geodir_ga_callback(){
 | |
| 2051 | +function geodir_ga_callback() {
 | |
| 2052 | 2052 | |
| 2053 | -if(isset($_REQUEST['code']) && $_REQUEST['code']) {
 | |
| 2053 | +if (isset($_REQUEST['code']) && $_REQUEST['code']) {
 | |
| 2054 | 2054 | $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; | 
| 2055 | 2055 | $code = "code=".$_REQUEST['code']; | 
| 2056 | 2056 | $grant_type = "&grant_type=authorization_code"; | 
| 2057 | -    $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
 | |
| 2057 | +    $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback";
 | |
| 2058 | 2058 |      $client_id = "&client_id=".get_option('geodir_ga_client_id');
 | 
| 2059 | 2059 |      $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
 | 
| 2060 | 2060 | |
| 2061 | - $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; | |
| 2061 | + $auth_url = $oAuthURL.$code.$redirect_uri.$grant_type.$client_id.$client_secret; | |
| 2062 | 2062 | |
| 2063 | 2063 |      $response = wp_remote_post($auth_url, array('timeout' => 15));
 | 
| 2064 | 2064 | |
| 2065 | 2065 | //print_r($response); | 
| 2066 | 2066 | |
| 2067 | -    $error_msg =  __('Something went wrong','geodirectory');
 | |
| 2068 | -    if(!empty($response['response']['code']) && $response['response']['code']==200){
 | |
| 2067 | +    $error_msg = __('Something went wrong', 'geodirectory');
 | |
| 2068 | +    if (!empty($response['response']['code']) && $response['response']['code'] == 200) {
 | |
| 2069 | 2069 | |
| 2070 | 2070 | $parts = json_decode($response['body']); | 
| 2071 | 2071 | //print_r($parts); | 
| 2072 | -        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
 | |
| 2073 | -        else{
 | |
| 2072 | +        if (!isset($parts->access_token)) {echo $error_msg." - #1"; exit; }
 | |
| 2073 | +        else {
 | |
| 2074 | 2074 | |
| 2075 | 2075 |              update_option('gd_ga_access_token', $parts->access_token);
 | 
| 2076 | 2076 |              update_option('gd_ga_refresh_token', $parts->refresh_token);
 | 
| @@ -2079,25 +2079,25 @@ discard block | ||
| 2079 | 2079 | |
| 2080 | 2080 | |
| 2081 | 2081 | } | 
| 2082 | -    elseif(!empty($response['response']['code'])) {
 | |
| 2082 | +    elseif (!empty($response['response']['code'])) {
 | |
| 2083 | 2083 | $parts = json_decode($response['body']); | 
| 2084 | 2084 | |
| 2085 | -        if(isset($parts->error)){
 | |
| 2086 | - echo $parts->error.": ".$parts->error_description;exit; | |
| 2087 | -        }else{
 | |
| 2088 | - echo $error_msg." - #2";exit; | |
| 2085 | +        if (isset($parts->error)) {
 | |
| 2086 | + echo $parts->error.": ".$parts->error_description; exit; | |
| 2087 | +        } else {
 | |
| 2088 | + echo $error_msg." - #2"; exit; | |
| 2089 | 2089 | } | 
| 2090 | 2090 | |
| 2091 | -    }else{
 | |
| 2091 | +    } else {
 | |
| 2092 | 2092 | |
| 2093 | - echo $error_msg." - #3";exit; | |
| 2093 | + echo $error_msg." - #3"; exit; | |
| 2094 | 2094 | |
| 2095 | 2095 | } | 
| 2096 | 2096 | } | 
| 2097 | 2097 | exit; | 
| 2098 | 2098 | } | 
| 2099 | 2099 | |
| 2100 | -add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 ); | |
| 2100 | +add_filter('icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4);
 | |
| 2101 | 2101 | |
| 2102 | 2102 |  if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
 | 
| 2103 | 2103 |  	add_action('geodir_before_admin_panel', 'geodir_wpml_permalink_setting_notice');
 | 
| @@ -24,8 +24,11 @@ discard block | ||
| 24 | 24 | global $current_tab; | 
| 25 | 25 | geodir_redirect_to_admin_panel_on_installed(); | 
| 26 | 26 | $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings'; | 
| 27 | - if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests | |
| 28 | - geodir_handle_option_form_submit($current_tab); // located in admin function.php | |
| 27 | +            if (!(isset($_REQUEST['action']))) { | |
| 28 | + // this will avoid Ajax requests | |
| 29 | + geodir_handle_option_form_submit($current_tab); | |
| 30 | + } | |
| 31 | + // located in admin function.php | |
| 29 | 32 | /** | 
| 30 | 33 | * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area. | 
| 31 | 34 | * | 
| @@ -314,8 +317,9 @@ discard block | ||
| 314 | 317 |      if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
 | 
| 315 | 318 | |
| 316 | 319 |          foreach ($notification as $key => $value) {
 | 
| 317 | - if ($value['type'] == 'textarea') | |
| 318 | - $notification[$key]['type'] = 'editor'; | |
| 320 | +            if ($value['type'] == 'textarea') { | |
| 321 | + $notification[$key]['type'] = 'editor'; | |
| 322 | + } | |
| 319 | 323 | } | 
| 320 | 324 | |
| 321 | 325 | } | 
| @@ -340,8 +344,9 @@ discard block | ||
| 340 | 344 |      if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
 | 
| 341 | 345 | |
| 342 | 346 |          foreach ($design_setting as $key => $value) {
 | 
| 343 | - if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') | |
| 344 | - $design_setting[$key]['type'] = 'editor'; | |
| 347 | +            if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') { | |
| 348 | + $design_setting[$key]['type'] = 'editor'; | |
| 349 | + } | |
| 345 | 350 | } | 
| 346 | 351 | |
| 347 | 352 | } | 
| @@ -716,8 +721,9 @@ discard block | ||
| 716 | 721 | |
| 717 | 722 |      if (!get_option('geodir_remove_unnecessary_fields')) {
 | 
| 718 | 723 | |
| 719 | -        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
 | |
| 720 | -            $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
 | |
| 724 | +        if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'")) { | |
| 725 | +                    $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`"); | |
| 726 | + } | |
| 721 | 727 | |
| 722 | 728 |          update_option('geodir_remove_unnecessary_fields', '1');
 | 
| 723 | 729 | |
| @@ -743,15 +749,17 @@ discard block | ||
| 743 | 749 | $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action']; | 
| 744 | 750 |          switch ($geodir_admin_ajax_action) {
 | 
| 745 | 751 | case 'diagnosis' : | 
| 746 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') | |
| 747 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | |
| 752 | +                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') { | |
| 753 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | |
| 754 | + } | |
| 748 | 755 |                  call_user_func('geodir_diagnose_' . $diagnose_this);
 | 
| 749 | 756 | exit(); | 
| 750 | 757 | break; | 
| 751 | 758 | |
| 752 | 759 | case 'diagnosis-fix' : | 
| 753 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') | |
| 754 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | |
| 760 | +                if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') { | |
| 761 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); | |
| 762 | + } | |
| 755 | 763 |                  call_user_func('geodir_diagnose_' . $diagnose_this);
 | 
| 756 | 764 | exit(); | 
| 757 | 765 | break; | 
| @@ -1309,11 +1317,11 @@ discard block | ||
| 1309 | 1317 | ////////////////////////////////// | 
| 1310 | 1318 |      $option_value = get_option('geodir_home_page');
 | 
| 1311 | 1319 | $page = get_post($option_value); | 
| 1312 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1320 | +    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
 | |
| 1313 | 1321 | |
| 1314 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1315 | -        $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1316 | -    else {
 | |
| 1322 | +    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { | |
| 1323 | +            $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>"; | |
| 1324 | +    } else {
 | |
| 1317 | 1325 | $is_error_during_diagnose = true; | 
| 1318 | 1326 |          $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
 | 
| 1319 | 1327 |          if ($fix) {
 | 
| @@ -1334,11 +1342,11 @@ discard block | ||
| 1334 | 1342 | ////////////////////////////////// | 
| 1335 | 1343 |      $option_value = get_option('geodir_add_listing_page');
 | 
| 1336 | 1344 | $page = get_post($option_value); | 
| 1337 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1345 | +    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
 | |
| 1338 | 1346 | |
| 1339 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1340 | -        $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1341 | -    else {
 | |
| 1347 | +    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { | |
| 1348 | +            $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>"; | |
| 1349 | +    } else {
 | |
| 1342 | 1350 | $is_error_during_diagnose = true; | 
| 1343 | 1351 |          $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
 | 
| 1344 | 1352 |          if ($fix) {
 | 
| @@ -1360,11 +1368,11 @@ discard block | ||
| 1360 | 1368 | ////////////////////////////////// | 
| 1361 | 1369 |      $option_value = get_option('geodir_preview_page');
 | 
| 1362 | 1370 | $page = get_post($option_value); | 
| 1363 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1371 | +    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
 | |
| 1364 | 1372 | |
| 1365 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1366 | -        $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1367 | -    else {
 | |
| 1373 | +    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { | |
| 1374 | +            $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>"; | |
| 1375 | +    } else {
 | |
| 1368 | 1376 | $is_error_during_diagnose = true; | 
| 1369 | 1377 |          $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
 | 
| 1370 | 1378 |          if ($fix) {
 | 
| @@ -1385,11 +1393,11 @@ discard block | ||
| 1385 | 1393 | ////////////////////////////////// | 
| 1386 | 1394 |      $option_value = get_option('geodir_success_page');
 | 
| 1387 | 1395 | $page = get_post($option_value); | 
| 1388 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1396 | +    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
 | |
| 1389 | 1397 | |
| 1390 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1391 | -        $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1392 | -    else {
 | |
| 1398 | +    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { | |
| 1399 | +            $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>"; | |
| 1400 | +    } else {
 | |
| 1393 | 1401 | $is_error_during_diagnose = true; | 
| 1394 | 1402 |          $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
 | 
| 1395 | 1403 |          if ($fix) {
 | 
| @@ -1410,11 +1418,11 @@ discard block | ||
| 1410 | 1418 | ////////////////////////////////// | 
| 1411 | 1419 |      $option_value = get_option('geodir_info_page');
 | 
| 1412 | 1420 | $page = get_post($option_value); | 
| 1413 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1421 | +    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
 | |
| 1414 | 1422 | |
| 1415 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1416 | -        $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1417 | -    else {
 | |
| 1423 | +    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { | |
| 1424 | +            $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>"; | |
| 1425 | +    } else {
 | |
| 1418 | 1426 | $is_error_during_diagnose = true; | 
| 1419 | 1427 |          $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
 | 
| 1420 | 1428 |          if ($fix) {
 | 
| @@ -1435,11 +1443,11 @@ discard block | ||
| 1435 | 1443 | ////////////////////////////////// | 
| 1436 | 1444 |      $option_value = get_option('geodir_login_page');
 | 
| 1437 | 1445 | $page = get_post($option_value); | 
| 1438 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1446 | +    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
 | |
| 1439 | 1447 | |
| 1440 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1441 | -        $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1442 | -    else {
 | |
| 1448 | +    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { | |
| 1449 | +            $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>"; | |
| 1450 | +    } else {
 | |
| 1443 | 1451 | $is_error_during_diagnose = true; | 
| 1444 | 1452 |          $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
 | 
| 1445 | 1453 |          if ($fix) {
 | 
| @@ -1460,11 +1468,11 @@ discard block | ||
| 1460 | 1468 | ////////////////////////////////// | 
| 1461 | 1469 |      $option_value = get_option('geodir_location_page');
 | 
| 1462 | 1470 | $page = get_post($option_value); | 
| 1463 | -    if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
 | |
| 1471 | +    if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
 | |
| 1464 | 1472 | |
| 1465 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') | |
| 1466 | -        $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
 | |
| 1467 | -    else {
 | |
| 1473 | +    if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { | |
| 1474 | +            $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>"; | |
| 1475 | +    } else {
 | |
| 1468 | 1476 | $is_error_during_diagnose = true; | 
| 1469 | 1477 |          $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
 | 
| 1470 | 1478 |          if ($fix) {
 | 
| @@ -1908,8 +1916,9 @@ discard block | ||
| 1908 | 1916 | ); | 
| 1909 | 1917 | |
| 1910 | 1918 | $post_location_info = $request_info['post_location']; | 
| 1911 | - if ($location_id = geodir_add_new_location($post_location_info)) | |
| 1912 | - $post_location_id = $location_id; | |
| 1919 | +                            if ($location_id = geodir_add_new_location($post_location_info)) { | |
| 1920 | + $post_location_id = $location_id; | |
| 1921 | + } | |
| 1913 | 1922 |                          } else {
 | 
| 1914 | 1923 | $post_location_id = 0; | 
| 1915 | 1924 | } | 
| @@ -1972,8 +1981,9 @@ discard block | ||
| 1972 | 1981 | $attachment_set = ''; | 
| 1973 | 1982 | |
| 1974 | 1983 |                              foreach ($attachment as $key => $val) {
 | 
| 1975 | - if ($val != '') | |
| 1976 | - $attachment_set .= $key . " = '" . $val . "', "; | |
| 1984 | +                                if ($val != '') { | |
| 1985 | + $attachment_set .= $key . " = '" . $val . "', "; | |
| 1986 | + } | |
| 1977 | 1987 | } | 
| 1978 | 1988 | $attachment_set = trim($attachment_set, ", "); | 
| 1979 | 1989 | |
| @@ -2069,8 +2079,7 @@ discard block | ||
| 2069 | 2079 | |
| 2070 | 2080 | $parts = json_decode($response['body']); | 
| 2071 | 2081 | //print_r($parts); | 
| 2072 | -        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
 | |
| 2073 | -        else{
 | |
| 2082 | +        if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} else{
 | |
| 2074 | 2083 | |
| 2075 | 2084 |              update_option('gd_ga_access_token', $parts->access_token);
 | 
| 2076 | 2085 |              update_option('gd_ga_refresh_token', $parts->refresh_token);
 | 
| @@ -2078,17 +2087,16 @@ discard block | ||
| 2078 | 2087 | } | 
| 2079 | 2088 | |
| 2080 | 2089 | |
| 2081 | - } | |
| 2082 | -    elseif(!empty($response['response']['code'])) {
 | |
| 2090 | +    } elseif(!empty($response['response']['code'])) {
 | |
| 2083 | 2091 | $parts = json_decode($response['body']); | 
| 2084 | 2092 | |
| 2085 | 2093 |          if(isset($parts->error)){
 | 
| 2086 | 2094 | echo $parts->error.": ".$parts->error_description;exit; | 
| 2087 | -        }else{
 | |
| 2095 | +        } else{
 | |
| 2088 | 2096 | echo $error_msg." - #2";exit; | 
| 2089 | 2097 | } | 
| 2090 | 2098 | |
| 2091 | -    }else{
 | |
| 2099 | +    } else{
 | |
| 2092 | 2100 | |
| 2093 | 2101 | echo $error_msg." - #3";exit; | 
| 2094 | 2102 | |