WordPress.org

Plugin Directory

Changeset 1761804


Ignore:
Timestamp:
11/09/17 12:02:52 (5 weeks ago)
Author:
keesiemeijer
Message:

Bump version to 2.4.0-alpha

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

Legend:

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

    r1724980 r1761804  
    367367                'link_caption'   => false, 
    368368                'caption'        => 'post_title', 
     369                'post_class'     => '', 
    369370            ); 
    370371 
  • related-posts-by-taxonomy/trunk/includes/functions-thumbnail.php

    r1737638 r1761804  
    151151    foreach ( (array) $related_posts as $related ) { 
    152152 
     153        $caption       = ''; 
    153154        $thumbnail_id  = get_post_thumbnail_id( $related->ID ); 
    154         $caption       = ''; 
    155155        $title         = apply_filters( 'the_title', $related->post_title, $related->ID ); 
    156156 
     
    158158            $caption = $title; 
    159159            if ( (bool) $args['link_caption'] ) { 
    160                 $caption = "<a href='" . get_permalink( $related->ID ) . "'>" . $caption . '</a>'; 
     160                $caption = km_rpbt_get_related_post_title_link( $related ); 
    161161            } 
    162162        } elseif ( 'post_excerpt' === $args['caption'] ) { 
     
    219219         * @param array  $args    Function arguments. 
    220220         */ 
    221         $itemclass = apply_filters( 'related_posts_by_taxonomy_gallery_item_class', 'gallery-item', $related, $args ); 
    222         $itemclass = trim( preg_replace( '/\s+/', ' ', (string) $itemclass ) ); 
    223         $itemclass = array_map( 'sanitize_html_class', explode( ' ', $itemclass ) ); 
    224         $itemclass = implode( ' ', $itemclass ); 
    225  
    226         $image_meta  = wp_get_attachment_metadata( $thumbnail_id ); 
     221        $itemclass  = apply_filters( 'related_posts_by_taxonomy_gallery_item_class', 'gallery-item', $related, $args ); 
     222        $itemclass  = km_rpbt_get_post_classes( $related, $itemclass ); 
     223        $image_meta = wp_get_attachment_metadata( $thumbnail_id ); 
    227224 
    228225        $orientation = ''; 
  • related-posts-by-taxonomy/trunk/includes/functions.php

    r1750323 r1761804  
    122122    if ( in_array( $fields, array_keys( $allowed_fields ) ) ) { 
    123123        $select_sql = "$wpdb->posts." . $allowed_fields[ $fields ]; 
     124        if ( 'ids' !== $fields ) { 
     125            $select_sql .= ", $wpdb->posts.ID"; 
     126        } 
    124127    } else { 
    125128        // Not an allowed field - return full post objects. 
     
    288291    if ( $results ) { 
    289292 
     293        /* Order the related posts */ 
    290294        if ( ! $order_by_rand && $args['related'] ) { 
    291295 
    292             /* add (termcount) score and key to results */ 
     296            /* Add the (termcount) score and key to results */ 
    293297            for ( $i = 0; $i < count( $results ); $i++ ) { 
    294298                $results[ $i ]->score = array( $results[ $i ]->termcount, $i ); 
    295299            } 
    296300 
    297             /* order related posts */ 
     301            /* Order the related posts */ 
    298302            uasort( $results, 'km_rpbt_related_posts_by_taxonomy_cmp' ); 
    299  
    300             /* add termcount to args so we can use it later */ 
    301             $termcount = wp_list_pluck( array_values( $results ), 'score' ); 
    302             foreach ( $termcount as $key => $count ) { 
    303                 $termcount[ $key ] = $count[0]; 
     303            $args['termcount'] = array(); 
     304        } 
     305 
     306        $results = array_values( $results ); 
     307 
     308        /* Move include_self post to the top of the stack */ 
     309        if ( $args['include_self'] && ! in_array( $post_id, $args['exclude_posts'] ) ) { 
     310            $search = wp_list_pluck( $results, 'ID' ); 
     311 
     312            if ( in_array( $post_id, $search ) ) { 
     313                if ( $post_id !== $search[0] ) { 
     314                    // Inclusive post is not at the top of the results. 
     315                    $inclusive_key = array_search( $post_id, $search ); 
     316                    $inclusive_post = $results[ $inclusive_key ]; 
     317                    unset( $results[ $inclusive_key ] ); 
     318                    array_unshift( $results , $inclusive_post ); 
     319                    $results = array_values( $results ); 
     320                } 
    304321            } 
    305             $args['termcount'] = $termcount; 
    306         } 
    307  
    308         $results = array_values( $results ); 
    309  
    310         if ( in_array( $fields, array_keys( $allowed_fields ) ) ) { 
    311             $results = wp_list_pluck( $results, $allowed_fields[ $fields ] ); 
    312         } 
    313  
     322        } 
     323 
     324        /* Get the number of related posts */ 
    314325        if ( -1 !== (int) $args['posts_per_page'] ) { 
    315326            $posts_per_page = absint( $args['posts_per_page'] ); 
    316327            $posts_per_page = ( $posts_per_page ) ? $posts_per_page : 5; 
    317328            $results = array_slice( $results, 0, $posts_per_page ); 
    318             if ( isset( $args['termcount'] ) && $args['termcount'] ) { 
    319                 $args['termcount'] = array_slice( $args['termcount'], 0, $posts_per_page ); 
     329        } 
     330 
     331        if ( in_array( $fields, array_keys( $allowed_fields ) ) ) { 
     332            /* Get the field used in the query */ 
     333            $results = wp_list_pluck( $results, $allowed_fields[ $fields ] ); 
     334        } else { 
     335            for ( $i = 0; $i < count( $results ); $i++ ) { 
     336                $results[ $i ]->rpbt_current    = $post_id; 
     337                $results[ $i ]->rpbt_post_class = ''; 
     338                if ( isset( $results[ $i ]->termcount ) ) { 
     339                    $args['termcount'][] = $results[ $i ]->termcount; 
     340                } 
    320341            } 
    321342        } 
     
    384405} 
    385406 
    386  
    387407/** 
    388408 * Returns array with validated post types. 
  • related-posts-by-taxonomy/trunk/includes/shortcode.php

    r1750323 r1761804  
    157157    $image_size = $rpbt_args['image_size']; // deprecated in version 0.3. 
    158158    $columns    = absint( $rpbt_args['columns'] ); // deprecated in version 0.3. 
     159 
     160    $related_posts = km_rpbt_add_post_classes( $related_posts, $rpbt_args ); 
    159161 
    160162    ob_start(); 
  • related-posts-by-taxonomy/trunk/includes/widget.php

    r1750323 r1761804  
    220220            echo $rpbt_widget_args['before_title'] . $rpbt_args['title'] . $rpbt_widget_args['after_title']; 
    221221        } 
     222 
     223        $related_posts = km_rpbt_add_post_classes( $related_posts, $rpbt_args ); 
    222224 
    223225        global $post; // Used for setup_postdata() in templates. 
  • related-posts-by-taxonomy/trunk/lang/related-posts-by-taxonomy.pot

    r1750323 r1761804  
    33msgid "" 
    44msgstr "" 
    5 "Project-Id-Version: Related Posts By Taxonomy 2.3.2\n" 
     5"Project-Id-Version: Related Posts By Taxonomy 2.4.0-alpha\n" 
    66"Report-Msgid-Bugs-To: " 
    77"https://wordpress.org/support/plugin/related-posts-by-taxonomy\n" 
    8 "POT-Creation-Date: 2017-10-21 10:09:56+00:00\n" 
     8"POT-Creation-Date: 2017-11-09 11:48:20+00:00\n" 
    99"MIME-Version: 1.0\n" 
    1010"Content-Type: text/plain; charset=utf-8\n" 
     
    6666msgstr "" 
    6767 
    68 #: includes/widget.php:291 
     68#: includes/widget.php:293 
    6969msgid "Oops, something went wrong" 
    7070msgstr "" 
    7171 
    72 #: includes/widget.php:305 
     72#: includes/widget.php:307 
    7373msgid "Title" 
    7474msgstr "" 
    7575 
    76 #: includes/widget.php:311 
     76#: includes/widget.php:313 
    7777msgid "Number of related posts to show" 
    7878msgstr "" 
    7979 
    80 #: includes/widget.php:314 
     80#: includes/widget.php:316 
    8181msgid "Use -1 to show all related posts." 
    8282msgstr "" 
    8383 
    84 #: includes/widget.php:321 
     84#: includes/widget.php:323 
    8585msgid "Randomize related posts." 
    8686msgstr "" 
    8787 
    88 #: includes/widget.php:324 
     88#: includes/widget.php:326 
    8989msgid "Taxonomies" 
    9090msgstr "" 
    9191 
    92 #: includes/widget.php:326 
     92#: includes/widget.php:328 
    9393msgid "Taxonomy" 
    9494msgstr "" 
    9595 
    96 #: includes/widget.php:329 
     96#: includes/widget.php:331 
    9797msgid "All Taxonomies" 
    9898msgstr "" 
    9999 
    100 #: includes/widget.php:336 
     100#: includes/widget.php:338 
    101101msgid "Post Types" 
    102102msgstr "" 
    103103 
    104 #: includes/widget.php:348 
     104#: includes/widget.php:350 
    105105msgid "Display" 
    106106msgstr "" 
    107107 
    108 #: includes/widget.php:352 
     108#: includes/widget.php:354 
    109109msgid "Format" 
    110110msgstr "" 
    111111 
    112 #: includes/widget.php:359 
     112#: includes/widget.php:361 
    113113msgid "Image Display" 
    114114msgstr "" 
    115115 
    116 #: includes/widget.php:363 
     116#: includes/widget.php:365 
    117117msgid "Image Size" 
    118118msgstr "" 
    119119 
    120 #: includes/widget.php:372 
     120#: includes/widget.php:374 
    121121msgid "Number of image columns" 
    122122msgstr "" 
    123123 
    124 #: includes/widget.php:382 
     124#: includes/widget.php:384 
    125125msgid "Link image captions to posts" 
    126126msgstr "" 
    127127 
    128 #: includes/widget.php:385 
     128#: includes/widget.php:387 
    129129msgid "Widget Display" 
    130130msgstr "" 
    131131 
    132 #: includes/widget.php:392 
     132#: includes/widget.php:394 
    133133msgid "Display this widget on single post pages only" 
    134134msgstr "" 
    135135 
    136 #: includes/widget.php:396 
     136#: includes/widget.php:398 
    137137msgid "Display related posts for post ID (optional)" 
    138138msgstr "" 
     
    174174msgstr "" 
    175175 
    176 #: templates/related-posts-excerpts.php:35 templates/related-posts-links.php:36 
    177 #: templates/related-posts-posts.php:35 
    178 #: templates/related-posts-thumbnails.php:56 
     176#: templates/related-posts-excerpts.php:44 templates/related-posts-links.php:44 
     177#: templates/related-posts-posts.php:44 
     178#: templates/related-posts-thumbnails.php:60 
    179179msgid "No related posts found" 
    180180msgstr "" 
  • related-posts-by-taxonomy/trunk/related-posts-by-taxonomy.php

    r1750323 r1761804  
    22/* 
    33Plugin Name: Related Posts By Taxonomy 
    4 Version: 2.3.2 
     4Version: 2.4.0-alpha 
    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. 
     
    5151        require_once RELATED_POSTS_BY_TAXONOMY_PLUGIN_DIR . 'includes/deprecated.php'; 
    5252 
     53        // Functions used in the templates. 
     54        require_once RELATED_POSTS_BY_TAXONOMY_PLUGIN_DIR . 'includes/template-tags.php'; 
     55 
    5356        // The widget. 
    5457        require_once RELATED_POSTS_BY_TAXONOMY_PLUGIN_DIR . 'includes/widget.php'; 
  • related-posts-by-taxonomy/trunk/templates/related-posts-excerpts.php

    r890556 r1761804  
    88 * Documentation: https://keesiemeijer.wordpress.com/related-posts-by-taxonomy/ 
    99 * 
     10 * Only edit this file after you've copied it to your (child) theme's related-post-plugin folder. 
     11 * See: https://keesiemeijer.wordpress.com/related-posts-by-taxonomy/templates/ 
     12 * 
    1013 * @package Related Posts by Taxonomy 
    1114 * @since 0.1 
     
    1619 * @var array $rpbt_args     Widget or shortcode arguments. 
    1720 */ 
     21 
    1822?> 
    1923 
     
    2529 
    2630<?php if ( $related_posts ) : ?> 
    27     <?php foreach ( $related_posts as $post ) : 
    28         setup_postdata( $post ); ?> 
    2931 
    30         <a href="<?php the_permalink() ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?></a> 
     32    <?php foreach ( $related_posts as $post ) : ?> 
     33        <?php 
     34            setup_postdata( $post ); 
     35            // In this loop you can use WordPress functions to display the related posts. 
     36        ?> 
     37 
     38        <?php km_rpbt_post_title_link( $post ); ?> 
    3139        <?php the_excerpt(); ?> 
    3240 
    3341    <?php endforeach; ?> 
     42 
    3443<?php else : ?> 
    35 <p><?php _e( 'No related posts found', 'related-posts-by-taxonomy' ); ?></p> 
     44    <p><?php _e( 'No related posts found', 'related-posts-by-taxonomy' ); ?></p> 
    3645<?php endif ?> 
    3746 
    3847<?php 
    3948/** 
    40  * note: wp_reset_postdata(); is used after this template by the widget and the shortcode 
     49 * Note: wp_reset_postdata(); is used after this template by the widget and the shortcode 
    4150 */ 
    4251?> 
  • related-posts-by-taxonomy/trunk/templates/related-posts-links.php

    r1112610 r1761804  
    88 * Documentation: https://keesiemeijer.wordpress.com/related-posts-by-taxonomy/ 
    99 * 
     10 * Only edit this file after you've copied it to your (child) theme's related-post-plugin folder. 
     11 * See: https://keesiemeijer.wordpress.com/related-posts-by-taxonomy/templates/ 
     12 * 
    1013 * @package Related Posts by Taxonomy 
    1114 * @since 0.1 
     
    1619 * @var array $rpbt_args     Widget or shortcode arguments. 
    1720 */ 
     21 
    1822?> 
    1923 
     
    2630<?php if ( $related_posts ) : ?> 
    2731 
    28 <ul> 
    29     <?php foreach ( $related_posts as $post ) : 
    30         setup_postdata( $post ); ?> 
    31         <li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr( get_the_title() ? get_the_title() : get_the_ID() ); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?></a></li> 
    32     <?php endforeach; ?> 
    33 </ul> 
     32    <ul> 
     33        <?php foreach ( $related_posts as $post ) : ?> 
     34            <?php 
     35                setup_postdata( $post ); 
     36                // In this loop you can use WordPress functions to display the related posts. 
     37            ?> 
     38 
     39            <li<?php km_rpbt_post_class( $post ); ?>><?php km_rpbt_post_title_link( $post ); ?></li> 
     40        <?php endforeach; ?> 
     41    </ul> 
    3442 
    3543<?php else : ?> 
    36 <p><?php _e( 'No related posts found', 'related-posts-by-taxonomy' ); ?></p> 
     44    <p><?php _e( 'No related posts found', 'related-posts-by-taxonomy' ); ?></p> 
    3745<?php endif ?> 
    3846 
    3947<?php 
    4048/** 
    41  * note: wp_reset_postdata(); is used after this template by the widget and the shortcode. 
     49 * Note: wp_reset_postdata(); is used after this template by the widget and the shortcode. 
    4250 */ 
    4351?> 
  • related-posts-by-taxonomy/trunk/templates/related-posts-posts.php

    r890556 r1761804  
    88 * Documentation: https://keesiemeijer.wordpress.com/related-posts-by-taxonomy/ 
    99 * 
     10 * Only edit this file after you've copied it to your (child) theme's related-post-plugin folder. 
     11 * See: https://keesiemeijer.wordpress.com/related-posts-by-taxonomy/templates/ 
     12 * 
    1013 * @package Related Posts by Taxonomy 
    1114 * @since 0.1 
     
    1619 * @var array $rpbt_args     Widget or shortcode arguments. 
    1720 */ 
     21 
    1822?> 
    1923 
     
    2529 
    2630<?php if ( $related_posts ) : ?> 
    27     <?php foreach ( $related_posts as $post ) : 
    28         setup_postdata( $post ); ?> 
    2931 
    30         <a href="<?php the_permalink() ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?></a> 
     32    <?php foreach ( $related_posts as $post ) : ?> 
     33        <?php 
     34            setup_postdata( $post ); 
     35            // In this loop you can use WordPress functions to display the related posts. 
     36        ?> 
     37 
     38        <?php km_rpbt_post_title_link( $post ); ?> 
    3139        <?php the_content(); ?> 
    3240 
    3341    <?php endforeach; ?> 
     42 
    3443<?php else : ?> 
    35 <p><?php _e( 'No related posts found', 'related-posts-by-taxonomy' ); ?></p> 
     44    <p><?php _e( 'No related posts found', 'related-posts-by-taxonomy' ); ?></p> 
    3645<?php endif ?> 
    3746 
    3847<?php 
    3948/** 
    40  * note: wp_reset_postdata(); is used after this template by the widget and the shortcode 
     49 * Note: wp_reset_postdata(); is used after this template by the widget and the shortcode 
    4150 */ 
    4251?> 
  • related-posts-by-taxonomy/trunk/templates/related-posts-thumbnails.php

    r1533305 r1761804  
    77 * plugin:        https://wordpress.org/plugins/related-posts-by-taxonomy 
    88 * Documentation: https://keesiemeijer.wordpress.com/related-posts-by-taxonomy/ 
     9 * 
     10 * Only edit this file after you've copied it to your (child) theme's related-post-plugin folder. 
     11 * See: https://keesiemeijer.wordpress.com/related-posts-by-taxonomy/templates/ 
    912 * 
    1013 * @package Related Posts by Taxonomy 
     
    2023 * @var string $columns       Columns.    (deprecated - use $rpbt_args['columns'] instead) 
    2124 */ 
     25 
    2226?> 
    2327 
     
    3034<?php if ( $related_posts ) : ?> 
    3135 
    32 <?php 
    33     /** 
    34     * Arguments for km_rpbt_related_posts_by_taxonomy_gallery() function. 
    35     * 
    36      * use the defaults 'itemtag', 'icontag', 'captiontag' 
    37     */ 
    38     $args = array( 
     36    <?php 
     37        /** 
     38        * Arguments for km_rpbt_related_posts_by_taxonomy_gallery() function. 
     39        * 
     40         * Here we use the defaults for 'itemtag', 'icontag', 'captiontag' 
     41        */ 
     42        $args = array( 
    3943 
    40         // 'itemtag'    => 'dl', 
    41         // 'icontag'    => 'dt', 
    42         // 'captiontag' => 'dd', 
    43          
    44         'id'           => $rpbt_args['post_id'], 
    45         'columns'      => $rpbt_args['columns'],    // zero or positive number 
    46         'size'         => $rpbt_args['image_size'], // 'thumbnail', 'medium', 'large', 'full' and custom sizes set by your theme 
    47         'caption'      => $rpbt_args['caption'],    // 'post_title', 'post_excerpt' 'attachment_caption', attachment_alt, or a custom string 
    48         'link_caption' => $rpbt_args['link_caption'], 
    49     ); 
     44            // 'itemtag'    => 'dl', 
     45            // 'icontag'    => 'dt', 
     46            // 'captiontag' => 'dd', 
    5047 
    51 // Plugin function in /includes/functions-thumbnail.php 
    52 echo km_rpbt_related_posts_by_taxonomy_gallery( $args, $related_posts ); 
    53 ?> 
     48            'id'           => $rpbt_args['post_id'], 
     49            'columns'      => $rpbt_args['columns'],    // zero or positive number 
     50            'size'         => $rpbt_args['image_size'], // 'thumbnail', 'medium', 'large', 'full' and custom sizes set by your theme 
     51            'caption'      => $rpbt_args['caption'],    // 'post_title', 'post_excerpt' 'attachment_caption', attachment_alt, or a custom string 
     52            'link_caption' => $rpbt_args['link_caption'], 
     53        ); 
     54 
     55        // Plugin function to display the galllery in /includes/functions-thumbnail.php 
     56        echo km_rpbt_related_posts_by_taxonomy_gallery( $args, $related_posts ); 
     57    ?> 
    5458 
    5559<?php else : ?> 
    56 <p><?php _e( 'No related posts found', 'related-posts-by-taxonomy' ); ?></p> 
     60    <p><?php _e( 'No related posts found', 'related-posts-by-taxonomy' ); ?></p> 
    5761<?php endif; ?> 
    5862 
    5963<?php 
    6064/** 
    61  * note: wp_reset_postdata(); is used after this template by the widget and the shortcode 
     65 * Note: wp_reset_postdata(); is used after this template by the widget and the shortcode 
    6266 */ 
    6367?> 
Note: See TracChangeset for help on using the changeset viewer.