Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Redis User Session Storage
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WP Plugins
Redis User Session Storage
Commits
f3b96f7c
Commit
f3b96f7c
authored
2 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Add admin notice
parent
df370039
No related branches found
No related tags found
1 merge request
!5
Prepare plugin for WP.org
Pipeline
#5031
failed with stages
in 2 minutes and 5 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
languages/redis-user-session-storage.pot
+7
-1
7 additions, 1 deletion
languages/redis-user-session-storage.pot
redis-user-session-storage.php
+38
-19
38 additions, 19 deletions
redis-user-session-storage.php
with
45 additions
and
20 deletions
languages/redis-user-session-storage.pot
+
7
−
1
View file @
f3b96f7c
...
...
@@ -5,7 +5,7 @@ msgstr ""
"Project-Id-Version: Redis User Session Storage 0.2\n"
"Report-Msgid-Bugs-To: "
"https://wordpress.org/support/plugin/redis-user-session-storage\n"
"POT-Creation-Date: 2022-07-09 0
0:58:27
+00:00\n"
"POT-Creation-Date: 2022-07-09 0
3:01:34
+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
...
...
@@ -25,6 +25,12 @@ msgstr ""
"X-Textdomain-Support: yes\n"
"X-Generator: grunt-wp-i18n 1.0.3\n"
#: redis-user-session-storage.php:89
msgid ""
"%1$s: An outdated version of this plugin, %2$s, is active. Please "
"deactivate it to use the current version."
msgstr ""
#. Plugin Name of the plugin/theme
msgid "Redis User Session Storage"
msgstr ""
...
...
This diff is collapsed.
Click to expand it.
redis-user-session-storage.php
+
38
−
19
View file @
f3b96f7c
...
...
@@ -39,40 +39,59 @@ use WP_Session_Tokens;
* @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.
if
(
!
class_exists
(
Redis
::
class
,
false
)
||
!
class_exists
(
WP_Session_Tokens
::
class
,
false
)
)
{
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'
);
load
();
/**
* Override Core's default usermeta-based token storage.
*
* @param string $manager
* @return string
*/
function
set_session_token_manager
()
{
function
set_session_token_manager
(
$manager
)
{
if
(
class_exists
(
WP_Redis_User_Session_Storage
::
class
,
false
)
)
{
add_action
(
'admin_notices'
,
__NAMESPACE__
.
'\admin_notice'
);
return
$manager
;
}
return
Plugin
::
class
;
}
/**
* Show admin notice to certain users when older version is active.
*
* @return void
*/
function
admin_notice
()
{
if
(
!
current_user_can
(
'activate_plugins'
)
)
{
return
;
}
?>
<div
id=
"message"
class=
"error"
>
<p>
<?php
printf
(
__
(
'%1$s: An outdated version of this plugin, %2$s, is active. Please deactivate it to use the current version.'
,
'redis-user-session-storage'
),
'<strong>Redis User Session Storage</strong>'
,
'<em>WP Redis User Session Storage</em>'
);
?>
</p>
</div>
<?php
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment