WordPress.org

Plugin Directory

Changeset 1750323


Ignore:
Timestamp:
10/21/17 10:24:39 (2 months ago)
Author:
keesiemeijer
Message:

Version to 2.3.2

Location:
related-posts-by-taxonomy/trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • related-posts-by-taxonomy/trunk/includes/functions.php

    r1737638 r1750323  
    7171    } 
    7272 
    73     // Add current post ID to exclude. 
    74     $args['exclude_posts'][] = $post_id; 
    75     $args['exclude_posts']   = array_unique( $args['exclude_posts'] ); 
    76  
    77     // Post ids sql. 
    78     $post_ids_sql = "AND $wpdb->posts.ID"; 
    79     if ( count( $args['exclude_posts'] ) > 1 ) { 
     73    if ( ! $args['include_self'] ) { 
     74        // Add current post ID to exclude. 
     75        $args['exclude_posts'][] = $post_id; 
     76    } 
     77    $args['exclude_posts'] = array_unique( $args['exclude_posts'] ); 
     78 
     79    $post_ids_sql = ''; 
     80    if ( $args['exclude_posts'] ) { 
     81        // Post ids sql. 
     82        $post_ids_sql = "AND $wpdb->posts.ID"; 
    8083        $post_ids_sql .= ' NOT IN (' . implode( ', ', $args['exclude_posts'] ) . ')'; 
    81     } else { 
    82         $post_ids_sql .= " != $post_id"; 
    8384    } 
    8485 
     
    361362        'related' => true, 
    362363        'public_only' => false, 
     364        'include_self' => false, 
    363365    ); 
    364366} 
     
    511513    $args['post_thumbnail'] = (bool) filter_var( $args['post_thumbnail'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 
    512514    $args['public_only']    = (bool) filter_var( $args['public_only'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 
     515    $args['include_self']   = (bool) filter_var( $args['include_self'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 
    513516 
    514517    return $args; 
  • related-posts-by-taxonomy/trunk/includes/shortcode.php

    r1737638 r1750323  
    6565    $rpbt_args['type'] = 'shortcode'; 
    6666 
    67     $function_args = $rpbt_args; 
    68  
    69     /* restricted arguments */ 
    70     unset( $function_args['post_id'], $function_args['taxonomies'], $function_args['fields'] ); 
    71  
    72     $cache = $plugin->cache instanceof Related_Posts_By_Taxonomy_Cache; 
    73  
    74     if ( $cache && ( isset( $rpbt_args['cache'] ) && $rpbt_args['cache'] ) ) { 
    75         $related_posts = $plugin->cache->get_related_posts( $rpbt_args ); 
    76     } else { 
    77         /* get related posts */ 
    78         $related_posts = km_rpbt_related_posts_by_taxonomy( $rpbt_args['post_id'], $rpbt_args['taxonomies'], $function_args ); 
    79     } 
     67    $related_posts = km_rpbt_shortcode_get_related_posts( $rpbt_args, $plugin->cache ); 
    8068 
    8169    /* 
     
    10391} // end km_rpbt_related_posts_by_taxonomy_shortcode() 
    10492 
     93/** 
     94 * Get the related posts used by the shortcode. 
     95 * 
     96 * @since 2.3.2 
     97 * @param array  $rpbt_args Widget arguments. 
     98 * @param object $cache_obj This plugins cache object. Default null. 
     99 * @return array Array with related post objects. 
     100 */ 
     101function km_rpbt_shortcode_get_related_posts( $rpbt_args, $cache_obj = null ) { 
     102 
     103    /** 
     104     * Filter whether to use your own related posts. 
     105     * 
     106     * @param array Array with shortcode attributes. 
     107     */ 
     108    $related_posts = apply_filters( 'related_posts_by_taxonomy_pre_related_posts', '', $rpbt_args ); 
     109 
     110    if ( $related_posts && is_array( $related_posts ) ) { 
     111        return $related_posts; 
     112    } 
     113 
     114    $function_args = $rpbt_args; 
     115 
     116    /* restricted arguments */ 
     117    unset( $function_args['post_id'], $function_args['taxonomies'], $function_args['fields'] ); 
     118 
     119    $cache = $cache_obj instanceof Related_Posts_By_Taxonomy_Cache; 
     120    if ( $cache && ( isset( $rpbt_args['cache'] ) && $rpbt_args['cache'] ) ) { 
     121        $related_posts = $cache_obj->get_related_posts( $rpbt_args ); 
     122    } else { 
     123        /* get related posts */ 
     124        $related_posts = km_rpbt_related_posts_by_taxonomy( $rpbt_args['post_id'], $rpbt_args['taxonomies'], $function_args ); 
     125    } 
     126 
     127    return $related_posts; 
     128} 
    105129 
    106130/** 
     
    150174    return trim( $shortcode ); 
    151175} 
    152  
    153176 
    154177/** 
     
    189212    $atts['public_only']  = ( '' !== trim( $atts['public_only'] ) ) ? $atts['public_only'] : false; 
    190213    $atts['public_only']  = (bool) filter_var( $atts['public_only'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 
     214    $atts['include_self']  = ( '' !== trim( $atts['include_self'] ) ) ? $atts['include_self'] : false; 
     215    $atts['include_self']  = (bool) filter_var( $atts['include_self'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE ); 
    191216 
    192217    return $atts; 
  • related-posts-by-taxonomy/trunk/includes/widget.php

    r1724980 r1750323  
    131131        $i['type'] = 'widget'; 
    132132 
    133         $rpbt_args  = $function_args = $i; 
    134  
    135         /* restricted arguments */ 
    136         unset( $function_args['fields'], $function_args['post_id'], $function_args['taxonomies'] ); 
    137  
    138         $cache = $this->plugin->cache instanceof Related_Posts_By_Taxonomy_Cache; 
    139  
    140         if ( $cache && ( isset( $rpbt_args['cache'] ) && $rpbt_args['cache'] ) ) { 
    141             $related_posts = $this->plugin->cache->get_related_posts( $rpbt_args ); 
    142         } else { 
    143             /* get related posts */ 
    144             $related_posts = km_rpbt_related_posts_by_taxonomy( $rpbt_args['post_id'], $rpbt_args['taxonomies'], $function_args ); 
    145         } 
     133        $related_posts = $this->get_related_posts( $i ); 
    146134 
    147135        /* 
     
    153141 
    154142        if ( ! $hide_empty || ! empty( $related_posts ) ) { 
    155             $this->widget_output( $related_posts, $rpbt_args, $rpbt_widget_args ); 
     143            $this->widget_output( $related_posts, $i, $rpbt_widget_args ); 
    156144        } 
    157145 
     
    164152    } 
    165153 
     154    /** 
     155     * Get the related posts used by the widget. 
     156     * 
     157     * @since 2.3.2 
     158     * @param array $rpbt_args Widget arguments. 
     159     * @return array Array with related post objects. 
     160     */ 
     161    function get_related_posts( $rpbt_args ) { 
     162 
     163        /** 
     164         * Filter whether to use your own related posts. 
     165         * 
     166         * @since  2.3.2 
     167         * @param array Array with shortcode attributes. 
     168         */ 
     169        $related_posts = apply_filters( 'related_posts_by_taxonomy_pre_related_posts', '', $rpbt_args ); 
     170 
     171        if ( $related_posts && is_array( $related_posts ) ) { 
     172            return $related_posts; 
     173        } 
     174 
     175        $function_args = $rpbt_args; 
     176 
     177        /* restricted arguments */ 
     178        unset( $function_args['fields'], $function_args['post_id'], $function_args['taxonomies'] ); 
     179 
     180        $cache = $this->plugin->cache instanceof Related_Posts_By_Taxonomy_Cache; 
     181 
     182        if ( $cache && ( isset( $rpbt_args['cache'] ) && $rpbt_args['cache'] ) ) { 
     183            $related_posts = $this->plugin->cache->get_related_posts( $rpbt_args ); 
     184        } else { 
     185            /* get related posts */ 
     186            $related_posts = km_rpbt_related_posts_by_taxonomy( $rpbt_args['post_id'], $rpbt_args['taxonomies'], $function_args ); 
     187        } 
     188 
     189        return $related_posts; 
     190    } 
    166191 
    167192    /** 
  • related-posts-by-taxonomy/trunk/lang/related-posts-by-taxonomy.pot

    r1737638 r1750323  
    33msgid "" 
    44msgstr "" 
    5 "Project-Id-Version: Related Posts By Taxonomy 2.3.2-alpha\n" 
     5"Project-Id-Version: Related Posts By Taxonomy 2.3.2\n" 
    66"Report-Msgid-Bugs-To: " 
    77"https://wordpress.org/support/plugin/related-posts-by-taxonomy\n" 
    8 "POT-Creation-Date: 2017-09-28 10:14:09+00:00\n" 
     8"POT-Creation-Date: 2017-10-21 10:09:56+00:00\n" 
    99"MIME-Version: 1.0\n" 
    1010"Content-Type: text/plain; charset=utf-8\n" 
     
    6666msgstr "" 
    6767 
    68 #: includes/widget.php:266 
     68#: includes/widget.php:291 
    6969msgid "Oops, something went wrong" 
    7070msgstr "" 
    7171 
    72 #: includes/widget.php:280 
     72#: includes/widget.php:305 
    7373msgid "Title" 
    7474msgstr "" 
    7575 
    76 #: includes/widget.php:286 
     76#: includes/widget.php:311 
    7777msgid "Number of related posts to show" 
    7878msgstr "" 
    7979 
    80 #: includes/widget.php:289 
     80#: includes/widget.php:314 
    8181msgid "Use -1 to show all related posts." 
    8282msgstr "" 
    8383 
    84 #: includes/widget.php:296 
     84#: includes/widget.php:321 
    8585msgid "Randomize related posts." 
    8686msgstr "" 
    8787 
    88 #: includes/widget.php:299 
     88#: includes/widget.php:324 
    8989msgid "Taxonomies" 
    9090msgstr "" 
    9191 
    92 #: includes/widget.php:301 
     92#: includes/widget.php:326 
    9393msgid "Taxonomy" 
    9494msgstr "" 
    9595 
    96 #: includes/widget.php:304 
     96#: includes/widget.php:329 
    9797msgid "All Taxonomies" 
    9898msgstr "" 
    9999 
    100 #: includes/widget.php:311 
     100#: includes/widget.php:336 
    101101msgid "Post Types" 
    102102msgstr "" 
    103103 
    104 #: includes/widget.php:323 
     104#: includes/widget.php:348 
    105105msgid "Display" 
    106106msgstr "" 
    107107 
    108 #: includes/widget.php:327 
     108#: includes/widget.php:352 
    109109msgid "Format" 
    110110msgstr "" 
    111111 
    112 #: includes/widget.php:334 
     112#: includes/widget.php:359 
    113113msgid "Image Display" 
    114114msgstr "" 
    115115 
    116 #: includes/widget.php:338 
     116#: includes/widget.php:363 
    117117msgid "Image Size" 
    118118msgstr "" 
    119119 
    120 #: includes/widget.php:347 
     120#: includes/widget.php:372 
    121121msgid "Number of image columns" 
    122122msgstr "" 
    123123 
    124 #: includes/widget.php:357 
     124#: includes/widget.php:382 
    125125msgid "Link image captions to posts" 
    126126msgstr "" 
    127127 
    128 #: includes/widget.php:360 
     128#: includes/widget.php:385 
    129129msgid "Widget Display" 
    130130msgstr "" 
    131131 
    132 #: includes/widget.php:367 
     132#: includes/widget.php:392 
    133133msgid "Display this widget on single post pages only" 
    134134msgstr "" 
    135135 
    136 #: includes/widget.php:371 
     136#: includes/widget.php:396 
    137137msgid "Display related posts for post ID (optional)" 
    138138msgstr "" 
  • related-posts-by-taxonomy/trunk/readme.txt

    r1725261 r1750323  
    22Contributors: keesiemeijer 
    33Tags: posts,related,related posts,related thumbnails,similar,similar posts,widget,shortcode,taxonomy,taxonomies,post type,post types,category,categories,tag,tags,post thumbnail,post thumbnails,thumbnails,featured,featured image,image,images 
    4 Requires at least: 4.0 
     4Requires at least: 4.1 
    55Tested up to: 4.8 
    66Stable tag: 2.3.1 
     
    7878* Dutch   
    7979* French (by [Annie Stasse](http://www.artisanathai.fr))   
    80 * Spanish (by [msoravilla](http://www.ludobooks.com))  
    81 * Catalan (by [msoravilla](http://www.ludobooks.com))   
     80* Spanish (by [Ludobooks – Cuentos personalizados](http://www.ludobooks.com))  
     81* Catalan (by [Ludobooks – Cuentos personalizados](http://www.ludobooks.com))   
    8282* Polish (by [koda0601](http://rekolekcje.net.pl))   
    8383 
     
    117117 
    118118== Changelog == 
     119= 2.3.2 = 
     120* Enhancement 
     121    * Add public_only parameter to not display private related posts from the current author. 
     122    * Add include_self parameter to include the current post in the related posts. 
     123    * Add filter pre_related_posts to override the related posts query. 
     124* Bug fixes 
     125    * Fix duplicate gallery IDs breaking the column layout of WordPress galleries. Props: @sonamel 
     126 
    119127= 2.3.1 = 
    120128 
     
    137145    * Fix wrong results for cached custom post type related posts  
    138146 
    139 = 2.2.1 = 
    140  
    141 * Enhancement 
    142     * Add selective refresh to the widget for the customizer 
    143 * Bug fixes 
    144     * Fix deprecated notice (by removing PHP4 style constructor) when installing this plugin with PHP7. Props: @dima-stefantsov 
    145  
    146 = 2.2.0 = 
    147 * Enhancement 
    148     * Refactor of the persistant cache for consistent results when using the plugin filters 
    149     * Better data sanitation for taxonomies and comma separated values 
    150     * New PHPunit tests (GitHub only) 
    151  
    152 = 2.1.1 = 
    153 * Enhancement 
    154     * Add Spanish, Catalan and Polish translation files 
    155 * Bug fixes 
    156     * Fix minor regression bug with the hide empty filter. 
    157     * Fix minor bug where the wrong default post type was being used by the shortcode. 
    158  
    159 = 2.1.0 = 
    160 * Enhancement 
    161     * Optimised related posts query. 
    162     * All round better validation of function arguments. 
    163     * Persistent cache out of beta. Now fully functioning. 
    164     * Cached data will be deleted after deleting the plugin from the wp-admin 
    165     * New opt-in cache log in the toolbar. 
    166  
    167 = 2.0.1 = 
    168 * Enhancement 
    169     * New option for the widget to randomise the related posts. 
    170     * Refactored the query to get the related posts. 
    171     * Organized files in the new 'includes' directory. 
    172     * Added a new class for debugging (only loaded if needed, with a filter). 
    173     * New PHPUnit tests for the widget(GitHub only). 
    174     * Updated the widget constructor as it is deprecated with WP 4.3 
    175     * Added a new (beta) front end cache layer. 
    176  
    177 = 1.1 = 
    178 * Bug fixes 
    179     * Fixed a minor compatibility bug with the widget customizer. Settings were not saved properly when adding a new widget. 
    180  
    181 = 1.0 = 
    182 * Enhancement 
    183     * Using WordPress semantic versioning. 
    184     * New shortcode attributes before_shortcode and after_shortcode. 
    185     * Default h3 heading for the shortcode 'Related Posts' title 
    186     * Shortcode is wrapped in a div container 
    187     * New filter to add classes to gallery items. 
    188     * New action after displaying related posts. 
    189     * Better logic for the 'related' parameter. 
    190 * Bug fixes 
    191     * Applying 'the_title' filters for the shortcode caption. 
    192 = 0.4.1 = 
    193 Updated 'include_terms' logic to search for related posts with different taxonomy terms if 'related' is set. 
    194 Updated unit tests to be more reliable. 
    195 = 0.4 = 
    196 * Enhancement 
    197     * Added a new parameter 'related' to get posts with include_terms even if the current post doesn't have the included terms (unrelated).  
    198     * Used attribute aria-describedby in wp_get_attachment_image for accessibility (similar changes as in the WordPress 4.1 gallery). 
    199     * Added new filters related_posts_by_taxonomy_post_thumbnail_link and related_posts_by_taxonomy_rss_post_thumbnail_link. 
    200     * Removed extract() from all files (WordPress core best practices). 
    201     * Added Phpunit tests (in the github repository). 
    202  
    203 * Bug fixes 
    204     * Fixed a filter recursion bug for the shortcode if it's used in the WordPress the_content filter and the format is excerpts or posts. 
    205  
    206 * Notice 
    207     * Deprecated filters related_posts_by_taxonomy_post_thumbnail and related_posts_by_taxonomy_rss_post_thumbnail. 
    208  
    209 = 0.3.1 = 
    210 * New filters for the related posts query. 
    211 * Fixed minor bug when using spaces in post_types string in the short code. 
    212 * Added plugin icons introduced with WordPress 4.0 
    213  
    214 = 0.3 = 
    215 * Enhancement 
    216     * New parameters for the shortcode and widget: include_terms and caption. 
    217     * New support for html5 tags (set by themes) in the thumbnail gallery (same as in WordPress 3.9 gallery shortcode). 
    218     * Allow image columns to be set to zero (same as in WordPress gallery shortcode). 
    219     * New options for gallery captions. Use the post title (default), excerpt, attachment caption or attachment alt text for the caption.  
    220     * Reformatted code and new inline filter documentation is added to adhere to new WordPress coding standards. 
    221     * New filters for overriding images in the thumbnail gallery. 
    222  
    223 * Bug fixes 
    224     * Fixed bug where duplicate related posts where found for order="RAND". Props: [Mock](https://profiles.wordpress.org/mock). 
    225     * Fixed php notices coming from the Related_Posts_By_Taxonomy_Defaults class. 
    226  
    227 * Notice 
    228     * Removed backward compatibility for WordPress 3.4. 
    229     * The template used for display of the post thumbnails is updated. Review the changes made in the updated related-posts-thumbnails.php file if you're using it to display the thumbnails in your own theme. 
    230  
    231 = 0.2.1 = 
    232 * Added image sizes and columns for the widget and shortcode.  
    233 * Cleaned up of code base and speed improvements. 
    234 * Added a Dutch translation. 
    235 * Added a filter for the caption of post thumbnails. 
    236 * Added two filters for a future settings page for this plugin. (this will be a separate plugin) 
    237  
    238 = 0.2 = 
    239 * Added new feature to display related post thumbnails. 
    240 * Removed the docs that came with the plugin. 
    241 * some minor bug fixing for the shortcode. 
    242  
    243147== Upgrade Notice == 
    244148= 2.3.1 = 
    245 This update adds the ability to disable plugin features with a filter. 
     149This update adds the ability to include the current post in the related posts, and fixes a minor bug with the related galleries. See the changelog. 
  • related-posts-by-taxonomy/trunk/related-posts-by-taxonomy.php

    r1737638 r1750323  
    22/* 
    33Plugin Name: Related Posts By Taxonomy 
    4 Version: 2.3.2-alpha 
     4Version: 2.3.2 
    55Plugin URI: http://keesiemeijer.wordpress.com/related-posts-by-taxonomy/ 
    66Description: Display related posts as thumbnails, links, excerpts or as full posts with a widget or shortcode. Posts with the most terms in common will display at the top. 
Note: See TracChangeset for help on using the changeset viewer.