diff --git a/Gruntfile.js b/Gruntfile.js index 7a1e8fa771d008e2f8c6c371e6c52da97e1eb1d2..1d96d8e31eaa41a04c45ae6ccd500a7cc11fbd0b 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -9,7 +9,7 @@ module.exports = function( grunt ) { addtextdomain: { options: { - textdomain: 'wp_redis_user_session_storage', + textdomain: 'redis-user-session-storage', }, update_all_domains: { options: { @@ -32,8 +32,8 @@ module.exports = function( grunt ) { options: { domainPath: '/languages', exclude: [ '\.git/*', 'bin/*', 'node_modules/*', 'tests/*' ], - mainFile: 'wp-redis-user-session-storage.php', - potFilename: 'wp-redis-user-session-storage.pot', + mainFile: 'redis-user-session-storage.php', + potFilename: 'redis-user-session-storage.pot', potHeaders: { poedit: true, 'x-poedit-keywordslist': true diff --git a/composer.json b/composer.json index 0d2630636eceef236f01866e5379ca6b7b29e2a2..83e178436ae5beb2b51c024d51a7751c580a8316 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name" : "ethitter/wp-redis-user-session-storage", + "name" : "ethitter/redis-user-session-storage", "description" : "Store WordPress session tokens in Redis rather than the usermeta table. Requires the Redis PECL extension.", "homepage" : "https://ethitter.com/", "type" : "wordpress-plugin", diff --git a/inc/class-wp-redis-user-session-storage.php b/inc/class-redis-user-session-storage.php similarity index 95% rename from inc/class-wp-redis-user-session-storage.php rename to inc/class-redis-user-session-storage.php index d7c70a1966bd69731422222f631cac1622b01fac..a5ebecb410e6c85577ffca3dae660f5ce4a35aa3 100644 --- a/inc/class-wp-redis-user-session-storage.php +++ b/inc/class-redis-user-session-storage.php @@ -2,9 +2,11 @@ /** * Offload session storage to Redis. * - * @package WP_Redis_User_Session_Storage + * @package Redis_User_Session_Storage */ +namespace Redis_User_Session_Storage; + /** * Don't load in contexts that lack the WP_Session_Tokens class */ @@ -17,7 +19,7 @@ if ( ! class_exists( 'WP_Session_Tokens' ) ) { * * @since 0.1 */ -class WP_Redis_User_Session_Storage extends WP_Session_Tokens { +class Plugin extends WP_Session_Tokens { /** * Holds the Redis client. * @@ -276,7 +278,7 @@ class WP_Redis_User_Session_Storage extends WP_Session_Tokens { * * @return string */ -function wp_redis_user_session_storage() { - return 'WP_Redis_User_Session_Storage'; +function redis_user_session_storage() { + return Plugin::class; } -add_filter( 'session_token_manager', 'wp_redis_user_session_storage' ); +add_filter( 'session_token_manager', 'redis_user_session_storage' ); diff --git a/languages/wp-redis-user-session-storage.pot b/languages/redis-user-session-storage.pot similarity index 100% rename from languages/wp-redis-user-session-storage.pot rename to languages/redis-user-session-storage.pot diff --git a/package.json b/package.json index bac1b9e7fb18c8799e85e846730a56985b93d3a3..e4845f358ae1098a0f25a60a600cda856f0099d6 100755 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "wp-redis-user-session-storage", + "name": "redis-user-session-storage", "version": "0.1.0", "main": "Gruntfile.js", "author": "Erick Hitter", diff --git a/phpcs.xml b/phpcs.xml index 9a198a11bc5c5d73dac420379452204dc63d2582..50220c46cf6970970b43937d3a28517a7c6074c0 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -32,13 +32,13 @@ <rule ref="WordPress.NamingConventions.PrefixAllGlobals"> <properties> <!-- Value: replace the function, class, and variable prefixes used. Separate multiple prefixes with a comma. --> - <property name="prefixes" type="array" value="wp_redis_user_session_storage"/> + <property name="prefixes" type="array" value="redis_user_session_storage,wp_redis_user_session_storage"/> </properties> </rule> <rule ref="WordPress.WP.I18n"> <properties> <!-- Value: replace the text domain used. --> - <property name="text_domain" type="array" value="wp_redis_user_session_storage"/> + <property name="text_domain" type="array" value="redis-user-session-storage"/> </properties> </rule> <rule ref="WordPress.WhiteSpace.ControlStructureSpacing"> diff --git a/wp-redis-user-session-storage.php b/redis-user-session-storage.php similarity index 76% rename from wp-redis-user-session-storage.php rename to redis-user-session-storage.php index 789c3300dcab5b8a806fa42467e74b624d7a6a98..de6e50d113d4a3216079797455cac6887d69e03b 100644 --- a/wp-redis-user-session-storage.php +++ b/redis-user-session-storage.php @@ -1,15 +1,9 @@ <?php /** - * Load plugin. - * - * @package WP_Redis_User_Session_Storage - */ - -/** - * Plugin Name: WP Redis User Session Storage - * Plugin URI: https://ethitter.com/plugins/wp-redis-user-session-storage/ + * Plugin Name: Redis User Session Storage + * Plugin URI: https://ethitter.com/plugins/redis-user-session-storage/ * Description: Store WordPress session tokens in Redis rather than the usermeta table. Requires the Redis PECL extension. - * Version: 0.1 + * Version: 0.2 * Author: Erick Hitter * Author URI: https://ethitter.com/ * @@ -26,6 +20,8 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * @package Redis_User_Session_Storage */ -require_once __DIR__ . '/inc/class-wp-redis-user-session-storage.php'; +require_once __DIR__ . '/inc/class-redis-user-session-storage.php'; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index e32bcc744ed5f44da6dc87b495c196a48f87a56b..f838a17324fb9d11ace8eb00e2902b3cd4b8acfd 100755 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -5,39 +5,27 @@ * @package WP_Revisions_Control */ -$wp_redis_user_session_storage = getenv( 'WP_TESTS_DIR' ); +$redis_user_session_storage = getenv( 'WP_TESTS_DIR' ); -if ( ! $wp_redis_user_session_storage ) { - $wp_redis_user_session_storage = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib'; +if ( ! $redis_user_session_storage ) { + $redis_user_session_storage = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib'; } -if ( ! file_exists( $wp_redis_user_session_storage . '/includes/functions.php' ) ) { - echo "Could not find $wp_redis_user_session_storage/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // WPCS: XSS ok. +if ( ! file_exists( $redis_user_session_storage . '/includes/functions.php' ) ) { + echo "Could not find $redis_user_session_storage/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // WPCS: XSS ok. exit( 1 ); } // Give access to tests_add_filter() function. -require_once $wp_redis_user_session_storage . '/includes/functions.php'; - -/** - * Stub admin-only function not needed for testing. - */ -// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -if ( ! function_exists( 'post_revisions_meta_box' ) ) { - /** - * Stub for Core's revisions meta box. - */ - function post_revisions_meta_box() {} -} -// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound +require_once $redis_user_session_storage . '/includes/functions.php'; /** * Manually load the plugin being tested. */ -function wp_redis_user_session_storage_tests_manually_load_plugin() { - require dirname( dirname( __FILE__ ) ) . '/wp-redis-user-session-storage.php'; +function redis_user_session_storage_tests_manually_load_plugin() { + require dirname( dirname( __FILE__ ) ) . '/redis-user-session-storage.php'; } -tests_add_filter( 'muplugins_loaded', 'wp_redis_user_session_storage_tests_manually_load_plugin' ); +tests_add_filter( 'muplugins_loaded', 'redis_user_session_storage_tests_manually_load_plugin' ); // Start up the WP testing environment. -require $wp_redis_user_session_storage . '/includes/bootstrap.php'; +require $redis_user_session_storage . '/includes/bootstrap.php'; diff --git a/tests/test-sample.php b/tests/test-sample.php index ccdf95bc181e52eca521bf967e65133f03095a4b..c8f05ed5bd8bfe159a2d1b5efe3a96e2dbf30198 100755 --- a/tests/test-sample.php +++ b/tests/test-sample.php @@ -2,7 +2,7 @@ /** * Class SampleTest * - * @package WP_Redis_User_Session_Storage + * @package Redis_User_Session_Storage */ /**