Plugin Directory

Changeset 3447627


Ignore:
Timestamp:
01/27/2026 08:49:04 AM (2 months ago)
Author:
Molongui
Message:

5.2.8 (2026-01-27)

  • Fixed: Related posts in the author box now include all relevant posts.
  • Changed: Updated framework files to v3.4.2.
Location:
molongui-authorship/trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • molongui-authorship/trunk/README.txt

    r3443140 r3447627  
    253253
    254254<strong>Important</strong>: If you use a caching plugin, please clear your cache after updating any plugins.
     255
     256= 5.2.8 (2026-01-27) =
     257
     258* **Fixed**: Related posts in the author box now include all relevant posts.
     259* **Changed**: Updated framework files to v3.4.2.
    255260
    256261= 5.2.7 (2026-01-20) =
  • molongui-authorship/trunk/changelog.txt

    r3443140 r3447627  
    22
    33== Changelog ==
     4
     5= 5.2.8 (2026-01-27) =
     6
     7* **Fixed**: Related posts in the author box now include all relevant posts.
     8* **Changed**: Updated framework files to v3.4.2.
    49
    510= 5.2.7 (2026-01-20) =
  • molongui-authorship/trunk/common/utils/post.php

    r3443140 r3447627  
    359359        return $fallback;
    360360    }
     361    public static function sanitize_cat_query_args( $cat, $options = array() )
     362    {
     363        $mode = isset( $options['mode'] ) ? strtolower( trim( (string) $options['mode'] ) ) : 'in';
     364        if ( $mode !== 'and' )
     365        {
     366            $mode = 'in';
     367        }
     368
     369        $include = array();
     370        $exclude = array();
     371        if ( $cat === '' || $cat === null || $cat === false )
     372        {
     373            return array();
     374        }
     375        $tokens = array();
     376
     377        if ( is_array( $cat ) )
     378        {
     379            $tokens = $cat;
     380        }
     381        elseif ( is_string( $cat ) )
     382        {
     383            $cat = trim( $cat );
     384
     385            if ( $cat === '' )
     386            {
     387                return array();
     388            }
     389            $tokens = ( strpos( $cat, ',' ) !== false ) ? explode( ',', $cat ) : array( $cat );
     390        }
     391        elseif ( is_int( $cat ) || is_float( $cat ) )
     392        {
     393            $tokens = array( $cat );
     394        }
     395        else
     396        {
     397            return array();
     398        }
     399        foreach ( $tokens as $token )
     400        {
     401            if ( is_int( $token ) || is_float( $token ) )
     402            {
     403                $n = (int) $token;
     404            }
     405            elseif ( is_string( $token ) )
     406            {
     407                $token = trim( $token );
     408
     409                if ( $token === '' || ! is_numeric( $token ) )
     410                {
     411                    continue;
     412                }
     413
     414                $n = (int) $token;
     415            }
     416            else
     417            {
     418                continue;
     419            }
     420            if ( $n === 0 )
     421            {
     422                continue;
     423            }
     424            if ( $n < 0 )
     425            {
     426                $exclude[] = absint( $n );
     427            }
     428            else
     429            {
     430                $include[] = absint( $n );
     431            }
     432        }
     433        $include = array_values( array_unique( array_filter( $include ) ) );
     434        $exclude = array_values( array_unique( array_filter( $exclude ) ) );
     435        if ( empty( $include ) && empty( $exclude ) )
     436        {
     437            return array();
     438        }
     439        if ( count( $include ) === 1 && empty( $exclude ) )
     440        {
     441            return array( 'cat' => (int) $include[0] );
     442        }
     443
     444        if ( count( $exclude ) === 1 && empty( $include ) )
     445        {
     446            return array( 'cat' => -1 * (int) $exclude[0] );
     447        }
     448        $out = array();
     449
     450        if ( ! empty( $include ) )
     451        {
     452            $out_key = ( $mode === 'and' ) ? 'category__and' : 'category__in';
     453            $out[ $out_key ] = $include;
     454        }
     455
     456        if ( ! empty( $exclude ) )
     457        {
     458            $out['category__not_in'] = $exclude;
     459        }
     460
     461        return $out;
     462    }
    361463
    362464} // class
  • molongui-authorship/trunk/includes/author.php

    r3443140 r3447627  
    12321232        $defaults = array
    12331233        (
    1234             'cat'                 => 0,
     1234            'cat'                 => '',
    12351235            'fields'              => 'all',
    12361236            'ignore_sticky_posts' => true,
     
    12891289
    12901290        $posts_per_page = (int) $a['posts_per_page'];
    1291         if ( $posts_per_page < -1 )
     1291        if ( $posts_per_page <= -1 )
    12921292        {
    12931293            $posts_per_page = -1;
     
    13001300        }
    13011301
    1302         $cat = $a['cat'];
    1303         if ( $cat === '' || $cat === null )
    1304         {
    1305             $cat = 0;
    1306         }
    1307         else
    1308         {
    1309             $cat = absint( $cat );
    1310         }
     1302        $cat_args = Post::sanitize_cat_query_args( $a['cat'] );
    13111303
    13121304        $post__in = $a['post__in']; // accept array|string|int.
     
    14651457            'post__in'               => $post__in,
    14661458            'post__not_in'           => $post__not_in,
    1467             'cat'                    => $cat,
    14681459            'suppress_filters'       => false,
    14691460            'update_post_term_cache' => ( $fields === 'all' ), // if only IDs, don't waste time filling term cache
    14701461            'update_post_meta_cache' => ( $fields === 'all' ), // if only IDs, skip meta cache
    14711462        );
     1463        $q_args = array_merge( $q_args, $cat_args );
    14721464
    14731465        /*!
     
    14801472         */
    14811473        $q_args = apply_filters( 'molongui_authorship/author/get_posts/query_args', $q_args, $this );
    1482 
    14831474        $resolved = array
    14841475        (
    1485             'cat'                 => $cat,
    14861476            'fields'              => $fields,
    14871477            'ignore_sticky_posts' => $ignore_sticky_posts,
     
    15031493            'language'            => $a['language'],
    15041494        );
     1495        $resolved = array_merge( $resolved, $cat_args );
    15051496
    15061497        /*!
  • molongui-authorship/trunk/molongui-authorship.php

    r3443140 r3447627  
    1313 * Plugin URI:        https://www.molongui.com/wordpress-plugin-post-authors
    1414 * Description:       All-in-One Authorship Solution: Seamless Author Box, Guest Authors, and Co-Authors to enhance your site's authority, credibility, engagement, and SEO.
    15  * Version:           5.2.7
     15 * Version:           5.2.8
    1616 * Requires at least: 5.2
    1717 * Tested up to:      6.9
     
    4444final class MolonguiAuthorship
    4545{
    46     const VERSION = '5.2.7';
     46    const VERSION = '5.2.8';
    4747    use Singleton;
    4848    function __construct()
  • molongui-authorship/trunk/views/author-box/related/html-layout-1.php

    r3443140 r3447627  
    55$related_posts_ids = $profile->get_posts_ids( array
    66(
    7     'post_type'    => 'related',
    8     'post__not_in' => get_the_ID(),
     7    'post_type' => 'related',
    98) );
    109
  • molongui-authorship/trunk/views/author-box/related/html-layout-2.php

    r3443140 r3447627  
    55$related_posts_ids = $profile->get_posts_ids( array
    66(
    7     'post_type'    => 'related',
    8     'post__not_in' => get_the_ID(),
     7    'post_type' => 'related',
    98) );
    109
Note: See TracChangeset for help on using the changeset viewer.