erikltz
Forum Replies Created
-
“I’m sorry Da… Champ, I’m afraid I can’t do that” – ohh, well, I probably could but have many things in my project to attend to first so hope one of Your developers are actually interested in making a substantial optimization of Your plugin by using the code lines pasted above.
Regards,
Erik L.Out of curiosity I tried Your form, it looks like an email encoder plugin is not handling form input with email address correctly. The email input field:s value start with:
value=”<span id=”enkoder_0_53190297″>email hidden; JavaScript is required</span>..
and then include a JavaScript function hivelogic_enkoder_0_53190297. Either this plugin does not work with form fields containing an email address, or You have to use it differently to NOT destroy the value=”[email protected]” that was supposed to remain there.
Removing the timestamp could cause profile images not updating depending on cache settings in visitor browsers. I got around to modify the mentioned functions. It’s a general improvement of the code and it would be a good improvement in the main distribution for anyone displaying cover and avatar images…! ??
Note: I have pages listing groups of members with their profile photo that caused many lines in the web server log for each page view. I also accept rather large cover images that was fetched again for every page view. These are now fetched ONCE per visitor with the files time stamp – and ONCE again if image is updated. DRASTIC IMPROVEMENT! ??
Pasting complete code for two modified functions in includes/um-short-functions.php (didn’t touch the multisite thang) – not sure it will look good here though:
function um_get_cover_uri( $image, $attrs ) { $uri = false; $uri_common = false; $ext = '.' . pathinfo( $image, PATHINFO_EXTENSION ); $ratio = str_replace(':1','',UM()->options()->get( 'profile_cover_ratio' ) ); $height = round( $attrs / $ratio ); if ( is_multisite() ) { //multisite fix for old customers $multisite_fix_dir = UM()->uploader()->get_upload_base_dir(); $multisite_fix_url = UM()->uploader()->get_upload_base_url(); $multisite_fix_dir = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $multisite_fix_dir ); $multisite_fix_url = str_replace( '/sites/' . get_current_blog_id() . '/', '/', $multisite_fix_url ); if ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo{$ext}" ) ) { $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo{$ext}?" . current_time( 'timestamp' ); } if ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}{$ext}" ) ) { $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo-{$attrs}{$ext}?" . current_time( 'timestamp' ); }elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}x{$height}{$ext}" ) ) { $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo-{$attrs}x{$height}{$ext}?". current_time( 'timestamp' ); } } //*** BEGIN: Append time stamp of file rather than current time /EL 2021-01-05 $base_dir = UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR; $base_url = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/"; $fname = "cover_photo-{$attrs}{$ext}"; if( file_exists( $base_dir . $fname ) ) { $uri = $base_url . $fname; } else { $fname = "cover_photo-{$attrs}x{$height}{$ext}"; if ( file_exists( $base_dir . $fname ) ) { $uri = $base_url . $fname; } else { $fname = "cover_photo{$ext}"; if ( file_exists( $base_dir . $fname ) ) { $uri = $base_url . $fname; } } } if ( ! empty( $uri_common ) && empty( $uri ) ) { $uri = $uri_common; $fname=''; } // Append filemtime if fname is set, otherwise current time stamp $cache_time = ( $fname ? filemtime( $base_dir . $fname ) : current_time( 'timestamp' )); //*** END $uri .= "?{$cache_time}"; return $uri; } function um_get_avatar_uri( $image, $attrs ) { $uri = false; $uri_common = false; $find = false; $ext = '.' . pathinfo( $image, PATHINFO_EXTENSION ); if ( is_multisite() ) { //multisite fix for old customers $multisite_fix_dir = UM()->uploader()->get_upload_base_dir(); $multisite_fix_url = UM()->uploader()->get_upload_base_url(); $multisite_fix_dir = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $multisite_fix_dir ); $multisite_fix_url = str_replace( '/sites/' . get_current_blog_id() . '/', '/', $multisite_fix_url ); if ( $attrs == 'original' && file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) { $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo{$ext}"; } elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}x{$attrs}{$ext}" ) ) { $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$attrs}x{$attrs}{$ext}"; } elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}{$ext}" ) ) { $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$attrs}{$ext}"; } else { $sizes = UM()->options()->get( 'photo_thumb_sizes' ); if ( is_array( $sizes ) ) { $find = um_closest_num( $sizes, $attrs ); } if ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}x{$find}{$ext}" ) ) { $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$find}x{$find}{$ext}"; } elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}{$ext}" ) ) { $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$find}{$ext}"; } elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) { $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo{$ext}"; } } } //*** BEGIN: Append $base_dir = UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR; $base_url = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/"; $fname = "profile_photo{$ext}"; if ( $attrs == 'original' && file_exists( $base_dir . $fname ) ) { $uri = $base_url . $fname; } else { $fname = "profile_photo-{$attrs}x{$attrs}{$ext}"; if ( file_exists( $base_dir . $fname ) ) { $uri = $base_url . $fname; } else { $fname = "profile_photo-{$attrs}{$ext}"; if ( file_exists( $base_dir . $fname ) ) { $uri = $base_url . $fname; } else { $sizes = UM()->options()->get( 'photo_thumb_sizes' ); if ( is_array( $sizes ) ) { $find = um_closest_num( $sizes, $attrs ); } $fname = "profile_photo-{$find}x{$find}{$ext}"; if ( file_exists( $base_dir . $fname ) ) { $uri = $base_url . $fname; } else { $fname = "profile_photo-{$find}{$ext}"; if ( file_exists( $base_dir . $fname ) ) { $uri = $base_url . $fname; } else { $fname = "profile_photo{$ext}"; if ( file_exists( $base_dir . $fname ) ) { $uri = $base_url . $fname; } } } } } } if ( ! empty( $uri_common ) && empty( $uri ) ) { $uri = $uri_common; $fname=''; } /** * UM hook * * @type filter * @title um_filter_avatar_cache_time * @description Change Profile field value if it's empty * @input_vars * [{"var":"$timestamp","type":"timestamp","desc":"Avatar cache time"}, * {"var":"$user_id","type":"int","desc":"User ID"}] * @change_log * ["Since: 2.0"] * @usage add_filter( 'um_filter_avatar_cache_time', 'function_name', 10, 2 ); * @example * <?php * add_filter( 'um_filter_avatar_cache_time', 'my_avatar_cache_time', 10, 2 ); * function my_avatar_cache_time( $timestamp, $user_id ) { * // your code here * return $timestamp; * } * ?> */ if(0) { $cache_time = apply_filters( 'um_filter_avatar_cache_time', current_time( 'timestamp' ), um_user( 'ID' ) ); if ( ! empty( $cache_time ) ) { $uri .= "?{$cache_time}"; } } else { // Append filemtime if fname is set, otherwise current time stamp $cache_time = ( $fname ? filemtime( $base_dir . $fname ) : current_time( 'timestamp' )); $uri .= "?{$cache_time}"; } //*** END return $uri; }
Had the same error message (Fatal error: Call to undefined function wp_dashboard_setup() in /www/…/wp-admin/index.php) on a more oldish WordPress 2.6.3 using APC but no WP-Cache. Somehow the line
require_once(ABSPATH . 'wp-admin/includes/dashboard.php');
in wp-admin/index.php seems to fool APC. It’s simply not included?!? I changed it to:
require_once('includes/dashboard.php');
and then I can login without disabling APC. Seems to work so far – but I see a number of require_once with ABSPATH included so it’s strange, really strange…