Changeset 3349982
- Timestamp:
- 08/25/2025 10:14:23 PM (5 months ago)
- Location:
- restrict-content/tags/3.2.15
- Files:
-
- 11 edited
- 1 copied
-
. (copied) (copied from restrict-content/trunk)
-
composer.json (modified) (1 diff)
-
core/includes/class-restrict-content.php (modified) (1 diff)
-
core/includes/query-filters.php (modified) (2 diffs)
-
lang/restrict-content.pot (modified) (1 diff)
-
legacy/restrictcontent.php (modified) (1 diff)
-
package.json (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
restrictcontent.php (modified) (2 diffs)
-
vendor/autoload.php (modified) (1 diff)
-
vendor/composer/autoload_real.php (modified) (2 diffs)
-
vendor/composer/autoload_static.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
restrict-content/tags/3.2.15/composer.json
r3283684 r3349982 1 1 { 2 2 "name": "restrictcontent/restrict-content", 3 "version": "3.2.1 4.1",3 "version": "3.2.15", 4 4 "type": "wordpress-plugin", 5 5 "description": "A simple, yet powerful membership solution for WordPress.", -
restrict-content/tags/3.2.15/core/includes/class-restrict-content.php
r3283684 r3349982 27 27 */ 28 28 final class Restrict_Content_Pro { 29 const VERSION = '3.5.4 5.1';29 const VERSION = '3.5.47'; 30 30 31 31 /** -
restrict-content/tags/3.2.15/core/includes/query-filters.php
r3227065 r3349982 66 66 67 67 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 ); 78 70 } 79 71 } 80 72 add_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 */ 85 function 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 } 81 146 82 147 /** … … 117 182 } 118 183 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 */ 256 function 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\"%'" 128 268 ); 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 ); 129 284 130 285 return $args; -
restrict-content/tags/3.2.15/lang/restrict-content.pot
r3283684 r3349982 3 3 msgid "" 4 4 msgstr "" 5 "Project-Id-Version: Restrict Content 3.2.1 4.1\n"5 "Project-Id-Version: Restrict Content 3.2.15\n" 6 6 "Report-Msgid-Bugs-To: http://ithemes.com/support/\n" 7 "POT-Creation-Date: 2025-0 4-28 21:57:22+00:00\n"7 "POT-Creation-Date: 2025-08-25 22:04:30+00:00\n" 8 8 "PO-Revision-Date: 2025-MO-DA HO:MI+ZONE\n" 9 9 "MIME-Version: 1.0\n" -
restrict-content/tags/3.2.15/legacy/restrictcontent.php
r3283684 r3349982 22 22 23 23 if ( ! defined( 'RC_PLUGIN_VERSION' ) ) { 24 define( 'RC_PLUGIN_VERSION', '3.2.1 4.1' );24 define( 'RC_PLUGIN_VERSION', '3.2.15' ); 25 25 } 26 26 -
restrict-content/tags/3.2.15/package.json
r3283684 r3349982 1 1 { 2 2 "name": "restrict-content", 3 "version": "3.2.1 4.1",3 "version": "3.2.15", 4 4 "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.", 5 5 "homepage": "https://restrictcontentpro.com/", -
restrict-content/tags/3.2.15/readme.txt
r3283684 r3349982 7 7 Requires PHP: 7.4 8 8 Tested up to: 6.8 9 Stable tag: 3.2.1 4.19 Stable tag: 3.2.15 10 10 11 11 Restrict Content is a powerful WordPress membership plugin that gives you full control over who can and cannot view content on your WordPress site. … … 258 258 == Changelog == 259 259 260 = 3.2.15 = 261 * Tweak: Improved performance of restricted post queries. 262 260 263 = 3.2.14.1 = 261 264 * Security: Added more safety checks to telemetry opt-ins/opt-outs. -
restrict-content/tags/3.2.15/restrictcontent.php
r3283684 r3349982 4 4 * Plugin URI: https://restrictcontentpro.com 5 5 * 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.1 4.16 * Version: 3.2.15 7 7 * Author: StellarWP 8 8 * Author URI: https://stellarwp.com/ … … 19 19 define('RCP_ROOT', plugin_dir_path(__FILE__)); 20 20 define('RCP_WEB_ROOT', plugin_dir_url(__FILE__)); 21 define('RCF_VERSION', '3.2.1 4.1');21 define('RCF_VERSION', '3.2.15'); 22 22 23 23 // Load Strauss autoload. -
restrict-content/tags/3.2.15/vendor/autoload.php
r3283684 r3349982 23 23 require_once __DIR__ . '/composer/autoload_real.php'; 24 24 25 return ComposerAutoloaderInit f0134d9d141ea683567d02f6dd907ba6::getLoader();25 return ComposerAutoloaderInitc0eb550f43e123288eb31addcf85e62e::getLoader(); -
restrict-content/tags/3.2.15/vendor/composer/autoload_real.php
r3283684 r3349982 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit f0134d9d141ea683567d02f6dd907ba65 class ComposerAutoloaderInitc0eb550f43e123288eb31addcf85e62e 6 6 { 7 7 private static $loader; … … 25 25 require __DIR__ . '/platform_check.php'; 26 26 27 spl_autoload_register(array('ComposerAutoloaderInit f0134d9d141ea683567d02f6dd907ba6', 'loadClassLoader'), true, true);27 spl_autoload_register(array('ComposerAutoloaderInitc0eb550f43e123288eb31addcf85e62e', 'loadClassLoader'), true, true); 28 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); 29 spl_autoload_unregister(array('ComposerAutoloaderInit f0134d9d141ea683567d02f6dd907ba6', 'loadClassLoader'));29 spl_autoload_unregister(array('ComposerAutoloaderInitc0eb550f43e123288eb31addcf85e62e', 'loadClassLoader')); 30 30 31 31 require __DIR__ . '/autoload_static.php'; 32 call_user_func(\Composer\Autoload\ComposerStaticInit f0134d9d141ea683567d02f6dd907ba6::getInitializer($loader));32 call_user_func(\Composer\Autoload\ComposerStaticInitc0eb550f43e123288eb31addcf85e62e::getInitializer($loader)); 33 33 34 34 $loader->register(true); -
restrict-content/tags/3.2.15/vendor/composer/autoload_static.php
r3283684 r3349982 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit f0134d9d141ea683567d02f6dd907ba67 class ComposerStaticInitc0eb550f43e123288eb31addcf85e62e 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 67 67 { 68 68 return \Closure::bind(function () use ($loader) { 69 $loader->prefixLengthsPsr4 = ComposerStaticInit f0134d9d141ea683567d02f6dd907ba6::$prefixLengthsPsr4;70 $loader->prefixDirsPsr4 = ComposerStaticInit f0134d9d141ea683567d02f6dd907ba6::$prefixDirsPsr4;71 $loader->classMap = ComposerStaticInit f0134d9d141ea683567d02f6dd907ba6::$classMap;69 $loader->prefixLengthsPsr4 = ComposerStaticInitc0eb550f43e123288eb31addcf85e62e::$prefixLengthsPsr4; 70 $loader->prefixDirsPsr4 = ComposerStaticInitc0eb550f43e123288eb31addcf85e62e::$prefixDirsPsr4; 71 $loader->classMap = ComposerStaticInitc0eb550f43e123288eb31addcf85e62e::$classMap; 72 72 73 73 }, null, ClassLoader::class);
Note: See TracChangeset
for help on using the changeset viewer.