From b6264ea7ebbff116fe5ede4877db560f71b8c113 Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Fri, 8 Jul 2022 17:58:58 -0700 Subject: [PATCH] Rename --- README.md | 9 ++-- ...r-session-storage.php => class-plugin.php} | 19 ++----- languages/redis-user-session-storage.pot | 12 ++--- phpcs.xml | 2 +- readme.txt | 9 ++-- redis-user-session-storage.php | 53 ++++++++++++++++++- 6 files changed, 74 insertions(+), 30 deletions(-) rename inc/{class-redis-user-session-storage.php => class-plugin.php} (94%) diff --git a/README.md b/README.md index 464144f..7a2ca59 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ **Donate link:** https://ethitter.com/donate/ **Tags:** user sessions, session tokens, session storage **Requires at least:** 4.0 -**Tested up to:** 5.2 -**Stable tag:** 0.1 -**Requires PHP:** 5.3 +**Tested up to:** 6.0 +**Stable tag:** 0.2 +**Requires PHP:** 5.6 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -31,5 +31,8 @@ Specify `WP_REDIS_USER_SESSION_HOST`, `WP_REDIS_USER_SESSION_PORT`, and `WP_REDI ## Changelog ## +### 0.2 ### +* Rename plugin to `Redis Session Storage` and submit to WordPress.org plugins repository. + ### 0.1 ### * Initial public release diff --git a/inc/class-redis-user-session-storage.php b/inc/class-plugin.php similarity index 94% rename from inc/class-redis-user-session-storage.php rename to inc/class-plugin.php index a5ebecb..e6b2e07 100644 --- a/inc/class-redis-user-session-storage.php +++ b/inc/class-plugin.php @@ -7,12 +7,9 @@ namespace Redis_User_Session_Storage; -/** - * Don't load in contexts that lack the WP_Session_Tokens class - */ -if ( ! class_exists( 'WP_Session_Tokens' ) ) { - return; -} +use Redis; +use RedisException; +use WP_Session_Tokens; /** * Redis-based user sessions token manager. @@ -272,13 +269,3 @@ class Plugin extends WP_Session_Tokens { return $this->prefix . ':' . $this->user_id; } } - -/** - * Override Core's default usermeta-based token storage - * - * @return string - */ -function redis_user_session_storage() { - return Plugin::class; -} -add_filter( 'session_token_manager', 'redis_user_session_storage' ); diff --git a/languages/redis-user-session-storage.pot b/languages/redis-user-session-storage.pot index 73f4029..7570f30 100644 --- a/languages/redis-user-session-storage.pot +++ b/languages/redis-user-session-storage.pot @@ -1,11 +1,11 @@ # Copyright (C) 2022 Erick Hitter -# This file is distributed under the same license as the WP Redis User Session Storage package. +# This file is distributed under the same license as the Redis User Session Storage package. msgid "" msgstr "" -"Project-Id-Version: WP Redis User Session Storage 0.1\n" +"Project-Id-Version: Redis User Session Storage 0.2\n" "Report-Msgid-Bugs-To: " -"https://wordpress.org/support/plugin/wp-redis-user-session-storage\n" -"POT-Creation-Date: 2022-07-01 04:12:36+00:00\n" +"https://wordpress.org/support/plugin/redis-user-session-storage\n" +"POT-Creation-Date: 2022-07-09 00:58:27+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -26,11 +26,11 @@ msgstr "" "X-Generator: grunt-wp-i18n 1.0.3\n" #. Plugin Name of the plugin/theme -msgid "WP Redis User Session Storage" +msgid "Redis User Session Storage" msgstr "" #. Plugin URI of the plugin/theme -msgid "https://ethitter.com/plugins/wp-redis-user-session-storage/" +msgid "https://ethitter.com/plugins/redis-user-session-storage/" msgstr "" #. Description of the plugin/theme diff --git a/phpcs.xml b/phpcs.xml index 50220c4..1b51033 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -18,7 +18,7 @@ <!-- Rules: Check PHP version compatibility --> <!-- https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions --> - <config name="testVersion" value="5.3-"/> + <config name="testVersion" value="5.6-"/> <!-- https://github.com/PHPCompatibility/PHPCompatibilityWP --> <rule ref="PHPCompatibilityWP"/> diff --git a/readme.txt b/readme.txt index bf9e5f3..a72a3ea 100644 --- a/readme.txt +++ b/readme.txt @@ -3,9 +3,9 @@ Contributors: ethitter Donate link: https://ethitter.com/donate/ Tags: user sessions, session tokens, session storage Requires at least: 4.0 -Tested up to: 5.2 -Stable tag: 0.1 -Requires PHP: 5.3 +Tested up to: 6.0 +Stable tag: 0.2 +Requires PHP: 5.6 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -31,5 +31,8 @@ Specify `WP_REDIS_USER_SESSION_HOST`, `WP_REDIS_USER_SESSION_PORT`, and `WP_REDI == Changelog == += 0.2 = +* Rename plugin to `Redis Session Storage` and submit to WordPress.org plugins repository. + = 0.1 = * Initial public release diff --git a/redis-user-session-storage.php b/redis-user-session-storage.php index de6e50d..82f6ac9 100644 --- a/redis-user-session-storage.php +++ b/redis-user-session-storage.php @@ -24,4 +24,55 @@ * @package Redis_User_Session_Storage */ -require_once __DIR__ . '/inc/class-redis-user-session-storage.php'; +namespace Redis_User_Session_Storage; + +use Redis; +use WP_Redis_User_Session_Storage; +use WP_Session_Tokens; + +/** + * Load plugin when safe to do so, accounting for previous plugin name. + * + * WordPress.org no longer accepts plugins beginning with the `WP` prefix, so + * this was renamed to comply. + * + * @return void + */ +function load() { + if ( ! class_exists( Redis::class, false ) ) { + return; + } + + if ( ! class_exists( WP_Session_Tokens::class, false ) ) { + return; + } + + if ( class_exists( WP_Redis_User_Session_Storage::class, false ) ) { + // TODO: warn user to disable old plugin. + return; + } + + require_once __DIR__ . '/inc/class-plugin.php'; + + class_alias( + Plugin::class, + 'WP_Redis_User_Session_Storage', + false + ); + + add_filter( + 'session_token_manager', + __NAMESPACE__ . '\set_session_token_manager' + ); +} + +add_action( 'plugins_loaded', __NAMESPACE__ . '\load' ); + +/** + * Override Core's default usermeta-based token storage + * + * @return string + */ +function set_session_token_manager() { + return Plugin::class; +} -- GitLab