WordPress.org

Forums

WP User Frontend
Improvements: fixed many bugs (7 posts)

  1. leoloso
    Member
    Posted 2 years ago #

    Hi, thanks for the great plugin!

    I use version 1.1 and there were few bugs that I have fixed. I share here all the files with changes:

    https://drive.google.com/folderview?id=0By_eYMNOB66pZUtaNHhwajB3NW8&usp=sharing

    Before each change, there's a comment where I explain what the bug is:
    // Hack GreenDrinks

    In some cases, it is not a bug fix but rather a customization that I need for my website. For instance: in the Dashboard, I also show a column Category, showing the Category the post belongs to. So instead of hardcoding this stuff (not everyone needs it), there could be a hook there so that users can implement their own customization.

    I hope all these bug fixes and improvements can be implemented back in your plugin

    Thanks,
    Leo

    http://wordpress.org/extend/plugins/wp-user-frontend/

  2. professor99
    Member
    Posted 2 years ago #

    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

  3. leoloso
    Member
    Posted 2 years ago #

    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

  4. leoloso
    Member
    Posted 2 years ago #

    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

  5. Ciprian
    Member
    Posted 2 years ago #

    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.

  6. Ciprian
    Member
    Posted 2 years ago #

    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.

  7. Tareq Hasan
    Member
    Plugin Author

    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP User Frontend
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.