WordPress.org

Ready to get started?Download WordPress

Forums

NextGEN Gallery
Nextgen makes Alo-Easymail crash when sending newsletters (6 posts)

  1. leoloso
    Member
    Posted 11 months ago #

    Hi, I'm using NextGen latest version (1.9.12). There's a problem when sending a newsletter using Alo-Easymail, I have fixed the problem (quick and dirty, but it works alright), I hope a fix can be integrated back in the plugin.

    File: nggfunctions.php
    Problem: when executing shortcode [nggallery] in a newsletter using Alo Easymail it crashes, because $nggRewrite is null

    Solution: whenever $nggRewrite->get_permalink is called, check if it is null. If so, call function hack_get_permalink instead:

    ($nggRewrite ? $nggRewrite->get_permalink($args) : hack_get_permalink($args))

    function hack_get_permalink( $args ) {
    	global $wp_rewrite, $wp_query;
    
    	// taken from is_frontpage plugin, required for static homepage
    	$show_on_front = get_option('show_on_front');
    	$page_on_front = get_option('page_on_front');
    
    	//TODO: Watch out for ticket http://trac.wordpress.org/ticket/6627
    	$hack_options = get_option('ngg_options');
    	if ($wp_rewrite->using_permalinks() && $hack_options['usePermalinks'] ) {
    		$post = &get_post(get_the_ID());
    
    		// If the album is not set before get it from the wp_query ($_GET)
    		if ( !isset ($args['album'] ) )
    			$album = get_query_var('album');
    		if ( !empty( $album ) )
    			$args ['album'] = $album;
    
    		$gallery = get_query_var('gallery');
    		if ( !empty( $gallery ) )
    			$args ['gallery'] = $gallery;
    
    		$gallerytag = get_query_var('gallerytag');
    		if ( !empty( $gallerytag ) )
    			$args ['gallerytag'] = $gallerytag;
    
    		/** urlconstructor =  post url | slug | tags | [nav] | [show]
    			tags : 	album, gallery 	-> /album-([0-9]+)/gallery-([0-9]+)/
    					pid 			-> /image/([0-9]+)/
    					gallerytag		-> /tags/([^/]+)/
    			nav	 : 	nggpage			-> /page-([0-9]+)/
    			show : 	show=slide		-> /slideshow/
    					show=gallery	-> /images/
    		**/
    
    		// 1. Post / Page url + main slug
    		$url = trailingslashit ( get_permalink ($post->ID) ) . $this->slug;
    		//TODO: For static home pages generate the link to the selected page, still doesn't work
    		if (($show_on_front == 'page') && ($page_on_front == get_the_ID()))
    			$url = trailingslashit ( $post->guid ) . $this->slug;
    
    		// 2. Album, pid or tags
    		if (isset ($args['album']) && ($args['gallery'] == false) )
    			$url .= '/' . $args['album'];
    		elseif  (isset ($args['album']) && isset ($args['gallery']) )
    			$url .= '/' . $args['album'] . '/' . $args['gallery'];
    
    		if  (isset ($args['gallerytag']))
    			$url .= '/tags/' . $args['gallerytag'];
    
    		if  (isset ($args['pid']))
    			$url .= '/image/' . $args['pid'];			
    
    		// 3. Navigation
    		if  (isset ($args['nggpage']) && ($args['nggpage']) )
    			$url .= '/page-' . $args['nggpage'];
    		elseif (isset ($args['nggpage']) && ($args['nggpage'] === false) && ( count($args) == 1 ) )
    			$url = trailingslashit ( get_permalink ($post->ID) ); // special case instead of showing page-1, we show the clean url
    
    		// 4. Show images or Slideshow
    		if  (isset ($args['show']))
    			$url .= ( $args['show'] == 'slide' ) ? '/slideshow' : '/images';
    
    		return apply_filters('ngg_get_permalink', $url, $args);
    
    	} else {
    		// we need to add the page/post id at the start_page otherwise we don't know which gallery is clicked
    		if (is_home())
    			$args['pageid'] = get_the_ID();
    
    		if (($show_on_front == 'page') && ($page_on_front == get_the_ID()))
    			$args['page_id'] = get_the_ID();
    
    		if ( !is_singular() )
    			$query = htmlspecialchars( add_query_arg($args, get_permalink( get_the_ID() )) );
    		else
    			$query = htmlspecialchars( add_query_arg( $args ) );
    
    		return apply_filters('ngg_get_permalink', $query, $args);
    	}
    }

    Cheers,
    Leo

    http://wordpress.org/extend/plugins/nextgen-gallery/

  2. roos3342
    Member
    Posted 11 months ago #

    Leo,

    Thanks for the above code. I have added it to my NextGEN. I still have a problem tho when I have a single image inserted into a newsletter generated by ALO Easymail. Do you have any suggestions for that?

    I think a similar thing is happening with the [singlepic] shortcode but I'm not sure how to modify the code. Any help is GREATLY appreciated.

    Thanks!

  3. leoloso
    Member
    Posted 11 months ago #

    Hi, no I haven't checked on that issue, if it is the same problem that I fixed it is $nggRewrite being null, so make sure that you replace all occurrences of $nggRewrite->get_permalink (there are 9 in total) with the hack I added...

    if you do and it still fails, it must be another problem...

  4. roos3342
    Member
    Posted 11 months ago #

    Hey Leo,

    I'm not sure i follow what your saying. Are you saying in the functions file I should find all occurances of $nggRewrite and change it to get_permalink?

    Sorry, I'm a bit new to the coding part of this stuff and I'm just trying to work my way through it.

  5. leoloso
    Member
    Posted 11 months ago #

    each time it says:

    $nggRewrite->get_permalink($args)

    replace it with

    ($nggRewrite ? $nggRewrite->get_permalink($args) : hack_get_permalink($args))

    if the args to the get_permalink function are different, you must keep those. Example

    $nggRewrite->get_permalink(array('name' => 'hello'))

    replace it with

    ($nggRewrite ? $nggRewrite->get_permalink(array('name' => 'hello')) : hack_get_permalink(array('name' => 'hello')))

    and so on...

  6. roos3342
    Member
    Posted 11 months ago #

    Thanks Leo!

    I completed this, but I still have the same problem with single images. I will have to try to dig into it a bit more. The single image shortcode doesn't seem to have the nggRewrite function in it.

    My problem is, it doesn't send the test email (I get the red "x"). If I hit send now, it will tell me all have been sent successfully, but in reality, nothing gets sent.

    If I can figure it out, I will post here. If you happen to have the same problem and figure anything out, I'll keep monitoring this post.

    Thanks for your help so far!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.