From b2653938251f1583661af8b360db6ca55114c81d Mon Sep 17 00:00:00 2001 From: jonfalcon Date: Sat, 26 Mar 2016 10:19:21 -0700 Subject: [PATCH] Fix invalid image path --- core/um-filters-fields.php | 113 +++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 55 deletions(-) diff --git a/core/um-filters-fields.php b/core/um-filters-fields.php index dc2f59af..73303763 100644 --- a/core/um-filters-fields.php +++ b/core/um-filters-fields.php @@ -5,14 +5,14 @@ ***/ add_filter('um_edit_label_all_fields', 'um_edit_label_all_fields', 10, 2); function um_edit_label_all_fields( $label, $data ) { - + $asterisk = um_get_option('form_asterisk'); if ( $asterisk && isset( $data['required'] ) && $data['required'] == 1 ) $label = $label . '*'; - + return $label; } - + /*** *** @change birth date label in view ***/ @@ -21,24 +21,24 @@ $label = __('Age','ultimatemember'); return $label; } - + /*** *** @outputs a soundcloud track ***/ add_filter('um_profile_field_filter_hook__soundcloud_track', 'um_profile_field_filter_hook__soundcloud_track', 99, 2); function um_profile_field_filter_hook__soundcloud_track( $value, $data ) { - + if ( !is_numeric( $value ) ) { return __('Invalid soundcloud track ID','ultimatemember'); } - + $value = '
'; - + return $value; } - + /*** *** @outputs a youtube video ***/ @@ -50,7 +50,7 @@ '; return $value; } - + /*** *** @outputs a vimeo video ***/ @@ -62,7 +62,7 @@ '; return $value; } - + /*** *** @outputs a google map ***/ @@ -73,7 +73,7 @@ '; return $value; } - + /*** *** @user's registration date ***/ @@ -83,7 +83,7 @@ $value = sprintf(__('Joined %s','ultimatemember'), date_i18n('F d, Y', $value) ); return $value; } - + /*** *** @last login date ***/ @@ -92,7 +92,7 @@ $value = sprintf( __('Last login: %s','ultimatemember'), um_user_last_login( um_user('ID') ) ); return $value; } - + /*** *** @urls in description ***/ @@ -100,17 +100,17 @@ add_filter('um_profile_field_filter_hook__textarea', 'um_profile_field_filter_hook__description', 99, 2); function um_profile_field_filter_hook__description( $value, $data ) { global $ultimatemember; - + if ( isset( $data ) && isset( $data['html'] ) && $data['html'] == 1 ) return $value; - + $value = preg_replace('$(https?://[a-z0-9_./?=&#-]+)(?![^<>]*>)$i', ' $1 ', $value." "); $value = preg_replace('$(www\.[a-z0-9_./?=&#-]+)(?![^<>]*>)$i', '$1 ', $value." "); $value = wpautop($value); return $value; } - + /*** *** @time ***/ @@ -123,7 +123,7 @@ $value = str_replace('pm', 'p.m.', $value ); return $value; } - + /*** *** @date ***/ @@ -136,17 +136,17 @@ } else { $value = $ultimatemember->datetime->format( $value, $data['format'] ); } - + return $value; } - + /*** *** @file ***/ add_filter('um_profile_field_filter_hook__file', 'um_profile_field_filter_hook__file', 99, 2); function um_profile_field_filter_hook__file( $value, $data ) { global $ultimatemember; - + $uri = um_user_uploads_uri() . $value; $extension = pathinfo( $uri, PATHINFO_EXTENSION); @@ -162,28 +162,31 @@ '; } - + return $value; } - + /*** *** @image ***/ add_filter('um_profile_field_filter_hook__image', 'um_profile_field_filter_hook__image', 99, 2); function um_profile_field_filter_hook__image( $value, $data ) { - $uri = um_user_uploads_uri() . $value; $title = ( isset( $data['title'] ) ) ? $data['title'] : __('Untitled photo'); - - if ( file_exists( um_user_uploads_dir() . $value ) ) { + + // if value is an image tag + if( preg_match( '/\'.$title.''; + } else if ( file_exists( um_user_uploads_dir() . $value ) ) { $value = '
'.$title.'
'; } else { $value = ''; } - + return $value; } - + /*** *** @global ***/ @@ -197,8 +200,8 @@ $url_rel = ( isset( $data['url_rel'] ) ) ? 'rel="nofollow"' : ''; if( !strstr( $value, 'http' ) && !strstr( $value, '://' ) - && !strstr( $value, 'www.' ) - && !strstr( $value, '.com' ) + && !strstr( $value, 'www.' ) + && !strstr( $value, '.com' ) && !strstr( $value, '.net' ) && !strstr( $value, '.org' ) ) { @@ -209,58 +212,58 @@ if ( $data['validate'] == 'linkedin_url' ) $value = 'https://linkedin.com/' . $value; if ( $data['validate'] == 'skype' ) $value = $value; if ( $data['validate'] == 'googleplus_url' ) $value = 'https://plus.google.com/' . $value; - if ( $data['validate'] == 'instagram_url' ) $value = 'https://instagram.com/' . $value; + if ( $data['validate'] == 'instagram_url' ) $value = 'https://instagram.com/' . $value; } - + if ( isset( $data['validate'] ) && $data['validate'] == 'skype' ) { - + $value = $value; - + } else { - + if ( strpos($value, 'http://') !== 0 ) { $value = 'http://' . $value; } $data['url_target'] = ( isset( $data['url_target'] ) ) ? $data['url_target'] : '_blank'; $value = ''.$alt.''; - + } - + } - + if ( !is_array( $value ) ) { if ( is_email( $value ) ) $value = ''.$value.''; } else { $value = implode(', ', $value); } - + $value = str_replace('https://https://','https://',$value); $value = str_replace('http://https://','https://',$value); $value = $ultimatemember->shortcodes->emotize( $value ); return $value; } - + /*** *** @get form fields ***/ add_filter('um_get_form_fields', 'um_get_form_fields', 99); function um_get_form_fields( $array ) { - + global $ultimatemember; - + $form_id = (isset ( $ultimatemember->fields->set_id ) ) ? $ultimatemember->fields->set_id : null; $mode = (isset( $ultimatemember->fields->set_mode ) ) ? $ultimatemember->fields->set_mode : null; - + if ( $form_id && $mode ) { $array = $ultimatemember->query->get_attr('custom_fields', $form_id ); } else { $array = ''; } - + return $array; - + } /*** @@ -269,14 +272,14 @@ add_filter('um_get_custom_field_array', 'um_get_custom_field_array',99,2); function um_get_custom_field_array( $array, $fields ){ - + if( isset( $array['conditions'] ) ){ $found = 0; for( $a = 0; $a < count( $array['conditions'] ); $a++ ){ if( isset( $array['conditional_value'] ) || isset( $array['conditional_value'.$a] ) ){ - + if( isset( $array['conditions'] ) && ! empty( $array['conditions'] ) ){ - + $arr_conditions = array(); foreach ($array['conditions'] as $key => $value) { @@ -312,8 +315,8 @@ */ add_filter('um_profile_field_filter_hook__','um_force_utf8_fields',1,10); function um_force_utf8_fields( $value ){ - - if( ! um_get_option('um_force_utf8_strings') ) + + if( ! um_get_option('um_force_utf8_strings') ) return $value; $value = um_force_utf8_string( $value ); @@ -333,18 +336,18 @@ function um_is_selected_filter_value( $value ){ global $ultimatemember; - if( ! um_get_option('um_force_utf8_strings') ) + if( ! um_get_option('um_force_utf8_strings') ) return $value; $value = um_force_utf8_string( $value ); - + return $value; } /** * Filter select dropdown to use UTF-8 encoding - * @param array $options - * @param array $data + * @param array $options + * @param array $data * @return $options * @uses hook filter: um_select_dropdown_dynamic_options */ @@ -352,12 +355,12 @@ function um_select_dropdown_dynamic_options_to_utf8( $options, $data ){ global $ultimatemember; - if( ! um_get_option('um_force_utf8_strings') ) + if( ! um_get_option('um_force_utf8_strings') ) return $options; foreach ( $options as $key => $value ) { $options[ $key ] = um_force_utf8_string( $value ); - + } return $options;