Plugin Directory

Changeset 3349982


Ignore:
Timestamp:
08/25/2025 10:14:23 PM (5 months ago)
Author:
claudiosanches
Message:

Tagging version 3.2.15

Location:
restrict-content/tags/3.2.15
Files:
11 edited
1 copied

Legend:

Unmodified
Added
Removed
  • restrict-content/tags/3.2.15/composer.json

    r3283684 r3349982  
    11{
    22    "name": "restrictcontent/restrict-content",
    3     "version": "3.2.14.1",
     3    "version": "3.2.15",
    44    "type": "wordpress-plugin",
    55    "description": "A simple, yet powerful membership solution for WordPress.",
  • restrict-content/tags/3.2.15/core/includes/class-restrict-content.php

    r3283684 r3349982  
    2727     */
    2828    final class Restrict_Content_Pro {
    29         const VERSION = '3.5.45.1';
     29        const VERSION = '3.5.47';
    3030
    3131        /**
  • restrict-content/tags/3.2.15/core/includes/query-filters.php

    r3227065 r3349982  
    6666
    6767    if ( $hide_restricted_content ) {
    68         $premium_ids              = rcp_get_restricted_post_ids();
    69         $term_restricted_post_ids = rcp_get_post_ids_assigned_to_restricted_terms();
    70         $post_ids                 = array_unique( array_merge( $premium_ids, $term_restricted_post_ids ) );
    71 
    72         if ( $post_ids ) {
    73             $existing_not_in = is_array( $query->get( 'post__not_in' ) ) ? $query->get( 'post__not_in' ) : array();
    74             $post_ids        = array_unique( array_merge( $post_ids, $existing_not_in ) );
    75 
    76             $query->set( 'post__not_in', $post_ids );
    77         }
     68        // Use database-level filtering instead of post__not_in for better performance.
     69        add_filter( 'posts_where', 'rcp_filter_premium_posts_where', 10, 2 );
    7870    }
    7971}
    8072add_action( 'pre_get_posts', 'rcp_hide_premium_posts', 99999 );
     73
     74/**
     75 * Filters the WHERE clause to exclude premium posts at the database level.
     76 * This is more efficient than using post__not_in for sites with many posts.
     77 *
     78 * @since 3.5.47
     79 *
     80 * @param string   $where The WHERE clause of the query.
     81 * @param WP_Query $query The WP_Query instance.
     82 *
     83 * @return string Modified WHERE clause.
     84 */
     85function rcp_filter_premium_posts_where( $where, $query ) {
     86    global $wpdb;
     87
     88    // Add JOIN for meta tables if not already present.
     89    if (
     90        ! strpos( $where, 'INNER JOIN' )
     91        && ! strpos( $where, 'LEFT JOIN' )
     92    ) {
     93        $query->set(
     94            'meta_query',
     95            [
     96                'relation' => 'OR',
     97                [
     98                    'key'   => '_is_paid',
     99                    'value' => '1',
     100                ],
     101                [
     102                    'key' => 'rcp_subscription_level',
     103                ],
     104                [
     105                    'key'     => 'rcp_user_level',
     106                    'value'   => 'All',
     107                    'compare' => '!=',
     108                ],
     109                [
     110                    'key'     => 'rcp_access_level',
     111                    'value'   => 'None',
     112                    'compare' => '!=',
     113                ],
     114            ]
     115        );
     116    }
     117
     118    // Add WHERE clause to exclude posts with premium restrictions.
     119    $where .= " AND NOT EXISTS (
     120        SELECT 1 FROM {$wpdb->postmeta} pm
     121        WHERE pm.post_id = {$wpdb->posts}.ID
     122        AND (
     123            (pm.meta_key = '_is_paid' AND pm.meta_value = '1') OR
     124            (pm.meta_key = 'rcp_subscription_level' AND pm.meta_value != '') OR
     125            (pm.meta_key = 'rcp_user_level' AND pm.meta_value != 'All') OR
     126            (pm.meta_key = 'rcp_access_level' AND pm.meta_value != 'None')
     127        )
     128    )";
     129
     130    // Also exclude posts that are assigned to restricted taxonomy terms.
     131    $where .= " AND NOT EXISTS (
     132        SELECT 1 FROM {$wpdb->term_relationships} tr
     133        INNER JOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
     134        INNER JOIN {$wpdb->termmeta} tm ON tt.term_id = tm.term_id
     135        WHERE tr.object_id = {$wpdb->posts}.ID
     136        AND tm.meta_key = 'rcp_restricted_meta'
     137        AND tm.meta_value != ''
     138        AND tm.meta_value NOT LIKE '%s:13:\"access_level\";s:4:\"None\"%'
     139    )";
     140
     141    // Remove this filter to prevent it from affecting other queries.
     142    remove_filter( 'posts_where', 'rcp_filter_premium_posts_where', 10 );
     143
     144    return $where;
     145}
    81146
    82147/**
     
    117182    }
    118183
    119     if ( ! isset( $args['post__not_in'] ) ) {
    120         $args['post__not_in'] = [];
    121     }
    122 
    123     $args['post__not_in'] = array_unique(
    124         array_merge(
    125             (array) $args['post__not_in'],
    126             rcp_get_restricted_post_ids()
    127         )
     184    // Use database-level filtering instead of post__not_in for better performance.
     185    // Handle both post-level meta restrictions and term-based restrictions.
     186    $args['meta_query'] = [
     187        'relation' => 'AND',
     188        [
     189            'relation' => 'OR',
     190            [
     191                'key'     => '_is_paid',
     192                'value'   => '1',
     193                'compare' => '!=',
     194            ],
     195            [
     196                'key'     => '_is_paid',
     197                'compare' => 'NOT EXISTS',
     198            ],
     199        ],
     200        [
     201            'relation' => 'OR',
     202            [
     203                'key'     => 'rcp_subscription_level',
     204                'compare' => 'NOT EXISTS',
     205            ],
     206            [
     207                'key'     => 'rcp_subscription_level',
     208                'value'   => '',
     209                'compare' => '=',
     210            ],
     211        ],
     212        [
     213            'relation' => 'OR',
     214            [
     215                'key'     => 'rcp_user_level',
     216                'compare' => 'NOT EXISTS',
     217            ],
     218            [
     219                'key'     => 'rcp_user_level',
     220                'value'   => 'All',
     221                'compare' => '=',
     222            ],
     223        ],
     224        [
     225            'relation' => 'OR',
     226            [
     227                'key'     => 'rcp_access_level',
     228                'compare' => 'NOT EXISTS',
     229            ],
     230            [
     231                'key'     => 'rcp_access_level',
     232                'value'   => 'None',
     233                'compare' => '=',
     234            ],
     235        ],
     236    ];
     237
     238    // For REST API, we need to handle term-based restrictions differently since meta_query
     239    // doesn't support term relationships. We'll use a custom filter approach.
     240    add_filter( 'rest_post_query', 'rcp_filter_rest_api_restricted_posts', 10, 2 );
     241
     242    return $args;
     243}
     244
     245/**
     246 * Filters REST API queries to exclude posts assigned to restricted taxonomy terms.
     247 * This handles the term-based restrictions that can't be handled by meta_query alone.
     248 *
     249 * @since 3.5.47
     250 *
     251 * @param array<string, mixed> $args    The query arguments.
     252 * @param WP_REST_Request      $request The REST request object.
     253 *
     254 * @return array<string,mixed> Modified query arguments.
     255 */
     256function rcp_filter_rest_api_restricted_posts( $args, $request ) {
     257    global $wpdb;
     258
     259    // Get posts that are assigned to restricted terms.
     260    $restricted_term_post_ids = $wpdb->get_col(
     261        "SELECT DISTINCT tr.object_id
     262        FROM {$wpdb->term_relationships} tr
     263        INNER JOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
     264        INNER JOIN {$wpdb->termmeta} tm ON tt.term_id = tm.term_id
     265        WHERE tm.meta_key = 'rcp_restricted_meta'
     266        AND tm.meta_value != ''
     267        AND tm.meta_value NOT LIKE '%s:13:\"access_level\";s:4:\"None\"%'"
    128268    );
     269
     270    if ( ! empty( $restricted_term_post_ids ) ) {
     271        // Initialize post__not_in if it doesn't exist.
     272        if ( ! isset( $args['post__not_in'] ) ) {
     273            $args['post__not_in'] = [];
     274        } elseif ( is_array( $args['post__not_in'] ) ) {
     275            // Add term-restricted post IDs to the exclusion list.
     276            $args['post__not_in'] = array_unique(
     277                array_merge( $args['post__not_in'], $restricted_term_post_ids )
     278            );
     279        }
     280    }
     281
     282    // Remove this filter to prevent it from affecting other queries.
     283    remove_filter( 'rest_post_query', 'rcp_filter_rest_api_restricted_posts', 10 );
    129284
    130285    return $args;
  • restrict-content/tags/3.2.15/lang/restrict-content.pot

    r3283684 r3349982  
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Restrict Content 3.2.14.1\n"
     5"Project-Id-Version: Restrict Content 3.2.15\n"
    66"Report-Msgid-Bugs-To: http://ithemes.com/support/\n"
    7 "POT-Creation-Date: 2025-04-28 21:57:22+00:00\n"
     7"POT-Creation-Date: 2025-08-25 22:04:30+00:00\n"
    88"PO-Revision-Date: 2025-MO-DA HO:MI+ZONE\n"
    99"MIME-Version: 1.0\n"
  • restrict-content/tags/3.2.15/legacy/restrictcontent.php

    r3283684 r3349982  
    2222
    2323if ( ! defined( 'RC_PLUGIN_VERSION' ) ) {
    24     define( 'RC_PLUGIN_VERSION', '3.2.14.1' );
     24    define( 'RC_PLUGIN_VERSION', '3.2.15' );
    2525}
    2626
  • restrict-content/tags/3.2.15/package.json

    r3283684 r3349982  
    11{
    22  "name": "restrict-content",
    3   "version": "3.2.14.1",
     3  "version": "3.2.15",
    44  "description": "Set up a complete membership system for your WordPress site and deliver premium content to your members. Unlimited membership packages, membership management, discount codes, registration / login forms, and more.",
    55  "homepage": "https://restrictcontentpro.com/",
  • restrict-content/tags/3.2.15/readme.txt

    r3283684 r3349982  
    77Requires PHP: 7.4
    88Tested up to: 6.8
    9 Stable tag: 3.2.14.1
     9Stable tag: 3.2.15
    1010
    1111Restrict Content is a powerful WordPress membership plugin that gives you full control over who can and cannot view content on your WordPress site.
     
    258258== Changelog ==
    259259
     260= 3.2.15 =
     261* Tweak: Improved performance of restricted post queries.
     262
    260263= 3.2.14.1 =
    261264* Security: Added more safety checks to telemetry opt-ins/opt-outs.
  • restrict-content/tags/3.2.15/restrictcontent.php

    r3283684 r3349982  
    44 * Plugin URI: https://restrictcontentpro.com
    55 * Description: Set up a complete membership system for your WordPress site and deliver premium content to your members. Unlimited membership packages, membership management, discount codes, registration / login forms, and more.
    6  * Version: 3.2.14.1
     6 * Version: 3.2.15
    77 * Author: StellarWP
    88 * Author URI: https://stellarwp.com/
     
    1919define('RCP_ROOT', plugin_dir_path(__FILE__));
    2020define('RCP_WEB_ROOT', plugin_dir_url(__FILE__));
    21 define('RCF_VERSION', '3.2.14.1');
     21define('RCF_VERSION', '3.2.15');
    2222
    2323// Load Strauss autoload.
  • restrict-content/tags/3.2.15/vendor/autoload.php

    r3283684 r3349982  
    2323require_once __DIR__ . '/composer/autoload_real.php';
    2424
    25 return ComposerAutoloaderInitf0134d9d141ea683567d02f6dd907ba6::getLoader();
     25return ComposerAutoloaderInitc0eb550f43e123288eb31addcf85e62e::getLoader();
  • restrict-content/tags/3.2.15/vendor/composer/autoload_real.php

    r3283684 r3349982  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitf0134d9d141ea683567d02f6dd907ba6
     5class ComposerAutoloaderInitc0eb550f43e123288eb31addcf85e62e
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInitf0134d9d141ea683567d02f6dd907ba6', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitc0eb550f43e123288eb31addcf85e62e', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
    29         spl_autoload_unregister(array('ComposerAutoloaderInitf0134d9d141ea683567d02f6dd907ba6', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitc0eb550f43e123288eb31addcf85e62e', 'loadClassLoader'));
    3030
    3131        require __DIR__ . '/autoload_static.php';
    32         call_user_func(\Composer\Autoload\ComposerStaticInitf0134d9d141ea683567d02f6dd907ba6::getInitializer($loader));
     32        call_user_func(\Composer\Autoload\ComposerStaticInitc0eb550f43e123288eb31addcf85e62e::getInitializer($loader));
    3333
    3434        $loader->register(true);
  • restrict-content/tags/3.2.15/vendor/composer/autoload_static.php

    r3283684 r3349982  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitf0134d9d141ea683567d02f6dd907ba6
     7class ComposerStaticInitc0eb550f43e123288eb31addcf85e62e
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    6767    {
    6868        return \Closure::bind(function () use ($loader) {
    69             $loader->prefixLengthsPsr4 = ComposerStaticInitf0134d9d141ea683567d02f6dd907ba6::$prefixLengthsPsr4;
    70             $loader->prefixDirsPsr4 = ComposerStaticInitf0134d9d141ea683567d02f6dd907ba6::$prefixDirsPsr4;
    71             $loader->classMap = ComposerStaticInitf0134d9d141ea683567d02f6dd907ba6::$classMap;
     69            $loader->prefixLengthsPsr4 = ComposerStaticInitc0eb550f43e123288eb31addcf85e62e::$prefixLengthsPsr4;
     70            $loader->prefixDirsPsr4 = ComposerStaticInitc0eb550f43e123288eb31addcf85e62e::$prefixDirsPsr4;
     71            $loader->classMap = ComposerStaticInitc0eb550f43e123288eb31addcf85e62e::$classMap;
    7272
    7373        }, null, ClassLoader::class);
Note: See TracChangeset for help on using the changeset viewer.