WordPress.org

Ready to get started?Download WordPress

Forums

Add Local Avatar
PHP Notice: Undefined index: in function generate_avatar_in_posts (1 post)

  1. Daiv Mowbray
    Member
    Posted 2 years ago #

    Great plugin, thanx.

    the function generate_avatar_in_posts() is doing a str_replace on the content although there are no matches. You should add a check to see if the preg_match_all returns empty before or not before doing an empty str_replace.

    presently the code is the following:

    preg_match_all("/<!-- avatar ([^>]+) -->/", $content, $matches);
    			// For each instance, let's try to parse it...
    			foreach($matches['1'] as $email) {
    				// Check if we should replace with an avatar or with 'nothing' (to protect email addresses from prying eyes/robots.
    				if(!get_option('show_avatars') || $this->avatar_options['in_posts'] != 'on') $replacement[$counter] = '';
    				else $replacement[$counter] = get_avatar($email, $this->avatar_options['size'], $this->avatar_options['default'], true);
    				$counter++;
    			}
    			// Replace...
    			for($i = 0; $i <= $counter; $i++) {
    				    $content = str_replace($matches[0][$i], $replacement[$i], $content);
    			}

    Solution for the user, you can disable this function if you do not use the hacked shortcode in your posts, by commenting out line 142:

    //add_filter('the_content', array(&$this, 'generate_avatar_in_posts'));

    I recommend that you do this, otherwise every post is being scanned looking for this:

    <!-- avatar anyone@email.com -->

    http://wordpress.org/extend/plugins/add-local-avatar/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic