Hi Leoloso,
Big thanks for your effort in posting this and adding comments that make it easy to see what you did.
I will closely examine these in the next few days and see what I can incorporate in the development version.
Have you tried the development version yet? It’s a big improvement on Version 1.1.
Cheers
TheProfessor
Hi professor,
nops, unluckily I did these changes on version 1.1, so you’ll have to merge them back with version 1.2. However, if you have any doubt of what I did, please ask me, I’ll be happy to tell you what the problem was so you can fix it again
Cheers,
Leo
Hi, I found another problem:
in function enqueue_scripts(), in wpuf.php, I changed from:
if ( has_shortcode( 'wpuf_addpost' ) || has_shortcode( 'wpuf_edit' ) ) {
wp_enqueue_script( 'plupload-handlers' );
}
to
if (( has_shortcode( 'wpuf_addpost' ) || has_shortcode( 'wpuf_edit' )) && is_user_logged_in()) {
wp_enqueue_script( 'plupload-handlers' );
}
because if the user is not logged in, in the page to create (or edit) the post, plupload creates a javascript error:
Timestamp: 5/6/13 7:23:59 PM
Error: TypeError: o is null
Source File: http://localhost/wp-includes/js/plupload/plupload.js?ver=1.5.5
Line: 2
so then if the user is not logged in, now I don’t load that library anymore, no more problem
I’m using WordPress 3.6-beta3 and I get this error:
<strong>Fatal error:</strong> Cannot redeclare has_shortcode() (previously declared in \wp-includes\shortcodes.php:153) in \wp-content\plugins\wp-user-frontend\wpuf-functions.php on line 451
I tried to wrap the has_shortcode() in a function_exist() condition, but unfortunately, this functions is not used like the one in WordPress, so I get more warnings in the frontend.
I think I should either rename has_shortcode() to something else, or refactor it to be used just like the WordPress one.
WP User Frontend 1.2 has_shortcode() function:
/**
* check the current post for the existence of a short code
*
* @link http://wp.tutsplus.com/articles/quick-tip-improving-shortcodes-with-the-has_shortcode-function/
* @param string $shortcode
* @return boolean
*/
function has_shortcode( $shortcode = '', $post_id = false ) {
global $post;
if ( !$post ) {
return false;
}
$post_to_check = ( $post_id == false ) ? get_post( get_the_ID() ) : get_post( $post_id );
if ( !$post_to_check ) {
return false;
}
// false because we have to search through the post content first
$found = false;
// if no short code was provided, return false
if ( !$shortcode ) {
return $found;
}
// check the post content for the short code
if ( stripos( $post_to_check->post_content, '[' . $shortcode ) !== false ) {
// we have found the short code
$found = true;
}
return $found;
}
WordPress 3.6-beta has_shortcode() function:
/**
* Whether the passed content contains the specified shortcode
*
* <strong>@since 3.6.0</strong>
*
* @global array $shortcode_tags
* @param string $tag
* @return boolean
*/
function has_shortcode( $content, $tag ) {
if ( shortcode_exists( $tag ) ) {
preg_match_all( '/' . get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
if ( empty( $matches ) )
return false;
foreach ( $matches as $shortcode ) {
if ( $tag === $shortcode[2] )
return true;
}
}
return false;
}
Notice the @since 3.6.0 bit, so the plugin should be updated soon, as the WordPress 3.6 update will break hundreds of sites.
I’ve removed the has_shortcode() function on 1.2.2 and fixed the performance as it was slower when the number of users increases.