diff --git a/README.md b/README.md index 464144f5d419314080b55f10fa0ddaa2a692a4b7..7a2ca5903dd3addc37ef7f719e62bc4a6dcdbd3a 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 a5ebecb410e6c85577ffca3dae660f5ce4a35aa3..e6b2e07f009c3e62f3ea83ebe154317e702623a8 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 73f402997e8b5a4aac1cf389a654fc204d4c3ce5..7570f30510d65013e4f539879c6fbac9754cae09 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 50220c46cf6970970b43937d3a28517a7c6074c0..1b5103301317abb4ecde645f2a19d46fa2aa14ab 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 bf9e5f39d6fc3c9962346891a9d1f09366171881..a72a3eaec43b8a0b7e075b37efac188f3402e70e 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 de6e50d113d4a3216079797455cac6887d69e03b..82f6ac983b835f9455ed5a31a9265789dfd127bd 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; +}