• Hello, Thank you for your great plugin that I have been using for ages and it’s absolutely great that you have returned to support it.

    1. ERROR: There is a small issue with your plugin: id=thumbnailgridcontainer brings a lot of divs with the same id on a page that goes against html standard and when the page is processing by some code (AMP for example) it brings errors. As you use class=thumbnailgridcontainer in the same div element you can just to remove id=thumbnailgridcontainer at all, but correct .css file, please
    2. ERROR: wp_reset_query() is not necessary for the plugin because you create a new WP_Query object and don’t use query_posts() but it destroys the outer loop including the main loop. So if you just remove wp_reset_query(); just before $the_query = new WP_Query($atts); it’s perfect.
    3. ERROR: Opposite, after your Query (in the very end of the thumbnailgrid_function it would be nice to return globals to the outer loop values (return the outer loop like you did nothing with a Query), so wp_reset_postdata() is advisable by WP.
      In some cases plugin can be called out of any loop (from AJAX call, for example) but global $post was in use before plugin destroyed it. So, code like:
      global $post, $wp_query;
      if( ! empty( $wp_query->post) ) wp_reset_postdata();
      elseif( ! empty( $this->postid ) ) $post = get_post( $this->postid );

      resolves all cases
    4. IMPROVEMENT: your great plugin gives an amazing ability to choose where to insert scripts and styles: in the beginning of the page or in the end, but since quite a long versions ago WP allows to enqueue anywhere and it will be inserted immediately and once. So, if you enqueue scripts and styles as soon as the shortcode called, say in thumbnailgrid_function() it will be great for both: performance and rendering.
    5. IMPROVEMENT: There is a mess with ‘name’ and ‘postname’ WP_Query object artts especially when post_type=’any’. Actually they acts like aliases. I would duplicated them if one is omitted in the beginning of plugin’s function defaults(), like:
      if( ! isset( $atts[‘name’] ) && isset( $atts[‘pagename’] ) ) $atts[‘name’] = $atts[‘pagename’];
      if( ! isset( $atts[‘pagename’] ) && isset( $atts[‘name’] ) ) $atts[‘pagename’] = $atts[‘name’];
    6. IMPROVEMENT: $atts[‘post_type’] === ” looks like ‘any’ more than ‘post’ that follows from WP_Query. I would change it to ‘any’ in the beginning of plugin’s function defaults():
      ‘post_type’ => ‘any’,
      …..
      if( ” == $atts[‘post_type’] ) $atts[‘post_type’] = ‘any’;

    I have tested all these changes for many years and them work well.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author A. Jones

    (@nomadcoder)

    Hi there. Thank you so much. As you may know, this plugin is more than 10 years old. I am sure there are many potential improvements. Please feel free to send me your updated code and please consider becoming an additional plugin author. Shooflysolutions@gmail.com

    Thread Starter Alexander Guskov

    (@forcesail)

    Thank you I will send.

    Some errors more:
    1) Since php 8.3 all class property should be declared. You use a lot a properties created dynamicaly and PHP generate messages like:
    Creation of dynamic property thumbnailgrid::$postid is deprecated

    2) Are you sure that this code make sense?

            if (isset($atts['category']) && $atts['category'] && !$atts['cat'])
    $atts['cat'] = $atts['category'];
    //**********************PARSE OUT THE POST CATEGORY

    $tax_query = array();
    if (isset($atts['category']) && !isset($atts['cat'])) //check for category instead of cat
    $this->$atts['cat'] = $this->atts['category'];
    Plugin Author A. Jones

    (@nomadcoder)

    looks like duplicate code to me. I use visual code and it (The AI) does things like that sometimes.

    Thread Starter Alexander Guskov

    (@forcesail)

    Text editor for code writing is the best! 🙂
    AI is a rubbish all around

    I’ll send you my code tomorrow after check it with the 6.9 version of the plugin

    Plugin Author A. Jones

    (@nomadcoder)

    great! Please add your wp user name so you can directly update the plugin in the future.

    Thread Starter Alexander Guskov

    (@forcesail)

    I’m sorry Adrian, but it seems that I examined version 6.8 (I downloaded v.6.9 but it was v.6.8)

    Version 6.9 has too many errors: literals and sanitize functions doesn’t need and at least they works incorrectly. So the plugin almost doesn’t work at all.
    I found a quite good amount of errors and give up to force to work it. So I roll back to v.6.6.1 + my corrections.

    Plugin Author A. Jones

    (@nomadcoder)

    Fair enough. I had to update the plugin because it was pulled from the repository. If you feel like letting me know what the errors were I will fix them if I have time. Take care!

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

The topic ‘Some necessary code improvement’ is closed to new replies.