• How can we use this plugin with native WP gallery.

    Something like: [add_voting][gallery][/add_voting]

    I changed, but without success:

    function add_voting_handler($atts, $content = null)
    	{
    		global $post;
    
    		$pattern        = '#(<a.[^>]*?>)?<img[^>]*src="([^"]*)"[^>/]*?/>(?(1)\s*</a>)#isU';
    
    		$content = preg_replace_callback($pattern, "get_image_votes", $content);
    
    		return $content;
    
    	}
    	add_shortcode('add_voting', 'add_voting_handler' );

    into

    function add_voting_handler($atts, $content = null)
    	{
    		global $post;
    
    		$pattern        = '#(<a.[^>]*?>)?<img[^>]*src="([^"]*)"[^>/]*?/>(?(1)\s*</a>)#isU';
    
    		$content = preg_replace_callback($pattern, "get_image_votes", $content);
    
    		return do_shortcode($content);
    
    	}
    	add_shortcode('add_voting', 'add_voting_handler' );

    https://www.ads-software.com/extend/plugins/like-photo/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author jfmitchell

    (@jfmitchell)

    Hi,

    I’ve posted version 1.2 of the plugin which fixes this problem. You weren’t far off with your suggestion. The way this shortcode works, any nested shortcodes need to be processed before it (so not the standard way).

    Hope you enjoy my plugin!

    jfmitchell

    How can i use this plugin, for all my uploaded images, without shortcode [add_vote][/add_vote]?
    What line of code need to edit?

    Thanks, and sorry for my english ??

    I find the solution.

    Change this:

    function add_voting_handler($atts, $content = null)
    {
     global $post;
     $pattern = '#(<a.[^>]*?>)?<img[^>]*src="([^"]*)"[^>/]*?/>(?(1)\s*</a>)#isU';
     //Process nested content first
     $content = do_shortcode($content);
     $content = preg_replace_callback($pattern, "get_image_votes", $content);
    
     return $content;
    
    }
    add_shortcode('add_voting', 'add_voting_handler' );

    Into this:

    function add_voting_handler($content)
    {
     global $post;
     $pattern  = '#(<a.[^>]*?>)?<img[^>]*src="([^"]*)"[^>/]*?/>(?(1)\s*</a>)#isU';
     $content = preg_replace_callback($pattern, "get_image_votes", $content);
     return $content;
    }
    add_filter('the_content','add_voting_handler',10,4);

    It works perfect for me.

    Now, all images in your posts will have the voting system, without using shortcodes.

    Hi,

    how can I get top 5 photos with most votes?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Like Photo] WP Gallery’ is closed to new replies.