• Resolved indyparker

    (@indyparker)


    Hi Hector,

    Hope you are keeping safe during these challenging times.

    After speaking to my developer and trying a few things, we need your help. Here is the problem.

    When I have the Ajax disabled, everything works great.

    http://prntscr.com/rxv42w

    However, due to the caching, I am now using, I have to switch this to enabled. We discussed this some time back as the only way to fix my issue.

    But as soon as I switch my ajax on, my display of your widgets is no longer following the correct layout.

    I use your widget in two places. 1. Homepage, 2. Sidebar – for my TRENDING sections.

    Ajaxify widget DISABLED (correct view)

    Homepage:
    http://prntscr.com/rxv5bl

    Post Sidebar:
    http://prntscr.com/rxv62q

    Ajaxify widget ENABLED (incorrect view)

    Homepage:
    http://prntscr.com/rxv6u1

    Post Sidebar:
    http://prntscr.com/rxva6g

    We have looked at this for the past week, and the plugin code does not seem to inherit theme changes or HTML markup or anything.

    It tries to display the same view from the homepage on the sidebar as well but vertically.

    My developer says this could be the issue but we need your help with this. It does not seem to honour our templates changes to the widget displays as it does with ajaxify off.

    widget.php

    http://prntscr.com/rxvba6

    We cannot work out why just switching on the ajaxify widget completely ruins the display but without it, the widgets both in homepage and sidebar work perfectly.

    The website URL is:
    http://bit.ly/db-home

    Example post:
    https://bit.ly/DB-brolnchs

    Please advise on how we can fix this. Your input is highly appreciated.

    Kind Regards,
    Indy

    • This topic was modified 6 years, 1 month ago by indyparker.
Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @indyparker,

    Hope you are keeping safe during these challenging times.

    I am, thanks. Hope you are doing OK over there as well.

    We cannot work out why just switching on the ajaxify widget completely ruins the display but without it, the widgets both in homepage and sidebar work perfectly.

    Yes, I remember you reporting this problem some time ago (link).

    Unfortunately -and as I pointed out back then- this issue falls outside the scope of support I offer here: I can’t provide support for custom work done by someone else (especially if there are no clear, detailed instructions on how to reproduce the issue myself.)

    Thread Starter indyparker

    (@indyparker)

    Hi Hector,

    Thanks for your reply.

    The problem can be easily replicated by switching the ajaxify widget to enable to disable.

    Then you can compare the widget displays and see how they differ.

    When ajaxify widget is enabled, even selecting one of your themes does not make a difference to the default display being shown.

    Please see example here:

    Display before:
    http://prntscr.com/rxx5rs

    Widget settings to use a theme:
    http://prntscr.com/rxx59s

    Display after:
    http://prntscr.com/rxx64q

    It is exactly the same. Nothing changes. Which means the widget seems to display a default look if ajaxify widget is enabled. And this applies to any changes we make to our theme view of the widget as well.

    So, I need to know how can the WPP widget reflect theme or display changes when made when ajaxify widget is enabled.

    I am willing to provide you with an admin login to help you see what is going on.

    Please advise.

    Indy

    Plugin Author Hector Cabrera

    (@hcabrera)

    The problem can be easily replicated by switching the ajaxify widget to enable to disable.

    Works fine for me with the stock designs bundled with the plugin. Enabling/disabling the Ajaxify Widget option has no effect on the layout of the widget.

    If this was a plugin bug there would be other users reporting the same problem, so far it’s only you guys. Your problem is being caused by your customizations, not by the plugin itself.

    (…) even selecting one of your themes does not make a difference to the default display being shown.

    That’s not how the Cardview Compact theme looks like out of the box. This is how it should look:

    Cardview Compact theme

    Your version is a customized one (which looks nice btw):

    • The category tag is being placed on the right, slightly off the thumbnail, and has a blueish background color.
    • There’s a number right after every post.

    I am willing to provide you with an admin login to help you see what is going on.

    Unfortunately -and for very good reasons- that’s not allowed here: Forum Guidelines.

    If your current developer is unable to figure out the reason why your custom design breaks when the Ajaxify Widget feature is enabled then you may want to consider hiring another developer for this job.

    Thread Starter indyparker

    (@indyparker)

    Hi Hector,

    Before looking for another developer, my current guy has been doing fixes for us for some time now. So, he is pretty familiar.

    He did say this:

    Regarding this code in your widget.php:
    http://prntscr.com/rxy2u5

    In the widget.php file this selector is not present

    This is why it is cannot apply it to any theme within the ‘else’ portion.

    When the “if” condition is true then this javascript is not working correctly.

    This “if” works when the ajax enabled to a true condition.

    Please can you check the above and tell me if this could be affecting our theme customisations not being reflected?

    Many thanks,
    Indy

    Plugin Author Hector Cabrera

    (@hcabrera)

    That JavaScript code is working as intended, otherwise -as I stated earlier- other plugin users would be reporting the same issues you’re having now.

    All that block of code does is it moves the HTML elements from the popular posts list into the Shadow DOM if the browser supports it, otherwise the script does nothing and leaves everything as is (hence the lack of an else condition there.) This is more or less explained here so please ask your developer to look into the documentation for more details.

    Thread Starter indyparker

    (@indyparker)

    Hi Hector,

    Okay many thanks for your info. I will get him to look into this.

    Stay Safe

    Regards,
    Indy

    Thread Starter indyparker

    (@indyparker)

    Hi Hector,

    Is there a wat to test or check using code (PHP) if the ajaxify widget is enabled or not?

    E.g.

    If ajaxify widget is enabled
    <do this>

    etc.

    Can you please advise how this code would look?

    Thanks
    Indy

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hi Indy,

    No, the plugin doesn’t provide a public API you could use for this. It’s a plugin functionality that’s not meant to be tempered with.

    Thread Starter indyparker

    (@indyparker)

    Hi Hector,

    Hope you are safe.

    Okay, thanks for explaining the reply to my previous question.

    I have found in my functions.php, the custom function which displays my homepage TRENDING using WPP. This is also being used to display WPP the sidebar currently (I think).

    I would like you to look at this and check to make sure we are not using any WPP functions which are not correct, deprecated or something that could be done better to make it work with the Ajaxify widget.

    	/*
    	 * Builds custom HTML
    	 *
    	 * With this function, it alters WPP's HTML output from my theme's functions.php.
    	 * This way, the modification is permanent even if the plugin gets updated.
    	 *
    	 * @param   array   $mostpopular
    	 * @param   array   $instance
    	 * @return  string
    	 */
    	function my_custom_popular_posts_html_list( $mostpopular, $instance ){
    		
    		if ( is_singular('post') ) {
    			 $output = '<div id="trendingList" class="new-post-list trend-overlay"> <ul>';	
    				// loop the array of popular posts objects				
    				foreach( $mostpopular as $popular ) {
    				//print_a($popular);
    			
    					$stats = ''; // placeholder for the stats tag
    			
    					// Category option checked
    					if ($instance['stats_tag']['category']) {
    						$post_cat = get_the_category($popular->id);
    						$post_cat = (isset($post_cat[0]))
    						  ? '<a href="' . get_category_link($post_cat[0]->term_id) . '">' . $post_cat[0]->cat_name . '</a>'
    						  : '';
    			
    						if ($post_cat != '') {
    							$stats = '<figcaption>' . sprintf(__('%s', 'wordpress-popular-posts'), $post_cat) . '</figcaption>';
    						}
    					}
    					
    					$terms = wp_get_post_terms( $popular->id, 'category' );
    					
    					foreach($terms as $term){
    						
    						if($term->parent == 0){
    							$slug = $term->slug;
    							$cat_name = $term->name;
    							break;
    							} 
    						
    					}
    					$postContent = get_post_field('post_content', $popular->id );
    					$word_count = bavotasan_word_count($postContent);
    					
    					$output .= '<li class="'.$slug.'-bg">';
    					$output .= '<figure class="full-width"><a href="' . get_the_permalink( $popular->id ) . '\" title="' . esc_attr( $popular->title ) . '">';
    					$output .= get_the_post_thumbnail( $popular->id, 'trending-thumb' );					
    					if($word_count < 350){
    						$output .= '<span class="quick-read-icon"></span>';
    					}
    					$output .= '</a>';
    					$output .= '<figcaption>' . $cat_name . '</figcaption>';
    					$output .= '</figure>';
    					$output .= '<h3 class="post-title"><a href="' . get_the_permalink( $popular->id ) . '" title="' . esc_attr( $popular->title ) . '">'. $popular->title .'</a></h3>';					
    					if( (check_shortcode('fvplayer', $popular->id)) || (check_shortcode('nggallery', $popular->id)) || (check_shortcode('ngg_displayed_gallery', $popular->id)) || (check_shortcode('mceItem', $popular->id)) || (check_shortcode('[audio', $popular->id)) ) {
    						$output .= '<div class="go-to-share less-spacing"><ul>';
    						if(check_shortcode('fvplayer', $popular->id)) {
    							$output .= '<li><a href="#fvplayer-0" title="View Video"><i class="fa fa-youtube-play"></i></a></li>';
    						}						
    						if(check_shortcode('ngg_displayed_gallery', $popular->id) || check_shortcode('mceItem', $popular->id) || check_shortcode('nggallery', $popular->id)) {
    							$output .= '<li><a href="#ngg-image-0" title="View Gallery"><i class="fa fa-camera"></i></a></li>';
    						}
    						if(check_shortcode('audio', $popular->id)) {
    							$output .= '<li><a href="#mep_0" title="View Video"><i class="fa fa-volume-up"></i></a></li>';
    						}
    						$output .= '</ul></div>';
    					}
    					
    					//$output .= $excerpt;
    					$output .= '</li>';					
    				}			
    				$output .= '</ul></div>';
    				
    		} else {
    		
    		    $output = '<section id="trending" class="flex">';	
    		    // loop the array of popular posts objects for homepage view or other pages using full width widget
    		    $trending_count = 01;
    	
    				
    		    foreach( $mostpopular as $popular ) {
    				
    	   
    		
    		        $stats = ''; // placeholder for the stats tag
    		
    		        // Category option checked
    		        if ($instance['stats_tag']['category']) {
    		            $post_cat = get_the_category($popular->id);
    		            $post_cat = (isset($post_cat[0]))
    		              ? '<a href="' . get_category_link($post_cat[0]->term_id) . '">' . $post_cat[0]->cat_name . '</a>'
    		              : '';
    		
    		            if ($post_cat != '') {
    		                $stats = '<figcaption>' . sprintf(__('%s', 'wordpress-popular-posts'), $post_cat) . '</figcaption>';
    		            }
    		        }
    		        
    				$terms = wp_get_post_terms( $popular->id, 'category' );	
    					
    				
    				
    				$cat_id = get_the_category($popular->id);
    				$child = get_category( $cat_id[0]->term_id );
    				
    				$category_slug ="";
    				$category_name = "";
    				
    				if( $child->parent == 0 )
    				{
    					$category_name = $child->name;
    					$category_slug = $child->slug;	
    				} else {
    					$parent_name = get_category($child->parent);
    					$category_name = $parent_name->name;	
    					$category_slug = $parent_name->slug;
    				}
    						
    				
    				$cat_name = $category_name;
    				
    				
    				foreach($terms as $term){
    				
    					if($term->parent == 0){
    						$slug = $term->slug;
    					} else {
    						$term = get_term_by( 'id', $term->parent, POST_CATEGORY);
    						
    						$slug = $term->slug;
    						$cat_name = $term->name;
    					}
    				}	
    				$postContent = get_post_field('post_content', $popular->id );
    				$word_count = bavotasan_word_count($postContent);
    					
    		        $output .= '<div class="col-1"><article class="trend-overlay '.$slug.' flex"><div class="content">';
    		        $output .= '<figure><a href="' . get_the_permalink( $popular->id ) . '" title="' . esc_attr( $popular->title ) . '">';
    		        $output .= get_the_post_thumbnail( $popular->id, 'home-trending-thumb' );
    				if($word_count < 350){
    						$output .= '<span class="quick-read-icon"></span>';
    					}
    		        $output .= '</a>';
    				
    				if(isset($cat_name))
    					$output .= '<figcaption>' . $cat_name.'</figcaption>';
    				else{
    					$output .= '';
    				}
    		        $output .= '</figure>';
    		        $output .= '<h3><a href="'.get_the_permalink( $popular->id ).'" title="'.esc_attr( $popular->title ).'">'. $popular->title . '</a></h3';
    		        //$output .= $excerpt;
    		        $output .= '</div><span class="number">'.str_pad($trending_count, 2, '0', STR_PAD_LEFT).'</span></article></div>';
    				$trending_count++;
    		    }
    		
    		    $output .= '</section>';
    		    
    		} //else
    		
    		return $output;
    	}	
    	add_filter( 'wpp_custom_html', 'my_custom_popular_posts_html_list', 5, 2 );
    

    Please advise what needs changing.

    Many thanks in advance.

    Regards,
    Indy

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hi Indy,

    At first glance I don’t see anything inherently wrong with the code. Personally I would have done things differently (and maybe less complicated?) but other than that nothing jumps out at me as problematic. Can’t say much more since I can’t test the code as is.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Marking as resolved due to inactivity.

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Widget Incorrectly Displays with Ajaxify widget Enabled’ is closed to new replies.