Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wp-basic-requirements
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
wp-basic-requirements
Commits
d6c321ae
Commit
d6c321ae
authored
2 years ago
by
Grzegorz Rola
Browse files
Options
Downloads
Patches
Plain Diff
feature(transients): as autoloaded options
parent
97c47f4e
No related branches found
Tags
Tags containing commit
1 merge request
!42
Feature/transients
Pipeline
#213584
failed
2 years ago
Stage: tools
Stage: tests
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+4
-2
4 additions, 2 deletions
CHANGELOG.md
src/Basic_Requirement_Checker.php
+23
-18
23 additions, 18 deletions
src/Basic_Requirement_Checker.php
with
27 additions
and
20 deletions
CHANGELOG.md
+
4
−
2
View file @
d6c321ae
## [3.5.2] - 2023-02-10
## [3.6.0] - 2023-06-22
### Changed
### Changed
-
Plugin info transient changed to auto loaded option (expiration 0)
## [3.5.2] - 2023-02-10
### Changed
-
Removed arrows from user-facing messages.
-
Removed arrows from user-facing messages.
## [3.5.1] - 2022-08-30
## [3.5.1] - 2022-08-30
...
...
This diff is collapsed.
Click to expand it.
src/Basic_Requirement_Checker.php
+
23
−
18
View file @
d6c321ae
...
@@ -21,7 +21,8 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) {
...
@@ -21,7 +21,8 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) {
const
PLUGIN_INFO_FAKE_REQUIRED_MINIMUM_VERSION
=
'0.0'
;
const
PLUGIN_INFO_FAKE_REQUIRED_MINIMUM_VERSION
=
'0.0'
;
const
PLUGIN_INFO_APPEND_PLUGIN_DATA
=
'required_version'
;
const
PLUGIN_INFO_APPEND_PLUGIN_DATA
=
'required_version'
;
const
PLUGIN_INFO_TRANSIENT_NAME
=
'require_plugins_data'
;
const
PLUGIN_INFO_TRANSIENT_NAME
=
'require_plugins_data'
;
const
PLUGIN_INFO_TRANSIENT_EXPIRATION_TIME
=
16
;
const
EXPIRATION_TRANSIENT_NAME
=
'require_plugins_data_exp'
;
const
CACHE_TIME
=
300
;
/** @var string */
/** @var string */
protected
$plugin_name
;
protected
$plugin_name
;
...
@@ -324,6 +325,12 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) {
...
@@ -324,6 +325,12 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) {
* @return array In format [ 'plugindir/pluginfile.php' => ['Name' => 'Plugin Name', 'Version' => '1.0.1', ...], ]
* @return array In format [ 'plugindir/pluginfile.php' => ['Name' => 'Plugin Name', 'Version' => '1.0.1', ...], ]
*/
*/
private
static
function
retrieve_plugins_data_in_transient
()
{
private
static
function
retrieve_plugins_data_in_transient
()
{
$current_time
=
time
();
$plugins
=
get_transient
(
self
::
PLUGIN_INFO_TRANSIENT_NAME
);
$expiration_time
=
get_transient
(
self
::
EXPIRATION_TRANSIENT_NAME
);
$is_expired
=
!
$expiration_time
||
$current_time
>
$expiration_time
;
if
(
$plugins
===
false
||
$is_expired
)
{
static
$never_executed
=
true
;
static
$never_executed
=
true
;
if
(
$never_executed
)
{
if
(
$never_executed
)
{
$never_executed
=
false
;
$never_executed
=
false
;
...
@@ -337,16 +344,13 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) {
...
@@ -337,16 +344,13 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) {
}
);
}
);
}
}
$plugins
=
get_transient
(
self
::
PLUGIN_INFO_TRANSIENT_NAME
);
if
(
$plugins
===
false
)
{
if
(
!
function_exists
(
'get_plugins'
)
)
{
if
(
!
function_exists
(
'get_plugins'
)
)
{
require_once
ABSPATH
.
'/wp-admin/includes/plugin.php'
;
require_once
ABSPATH
.
'/wp-admin/includes/plugin.php'
;
}
}
$plugins
=
function_exists
(
'get_plugins'
)
?
get_plugins
()
:
array
();
$plugins
=
function_exists
(
'get_plugins'
)
?
get_plugins
()
:
array
();
set_transient
(
self
::
PLUGIN_INFO_TRANSIENT_NAME
,
$plugins
,
set_transient
(
self
::
PLUGIN_INFO_TRANSIENT_NAME
,
$plugins
,
0
);
self
::
PLUGIN_INFO_TRANSIENT_EXPIRATION
_TIME
);
set_transient
(
self
::
EXPIRATION_TRANSIENT_NAME
,
$current_time
+
self
::
CACHE
_TIME
,
0
);
}
}
return
$plugins
;
return
$plugins
;
...
@@ -615,6 +619,7 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) {
...
@@ -615,6 +619,7 @@ if ( ! class_exists( 'WPDesk_Basic_Requirement_Checker' ) ) {
*/
*/
public
function
handle_transient_delete_action
()
{
public
function
handle_transient_delete_action
()
{
delete_transient
(
self
::
PLUGIN_INFO_TRANSIENT_NAME
);
delete_transient
(
self
::
PLUGIN_INFO_TRANSIENT_NAME
);
delete_transient
(
self
::
EXPIRATION_TRANSIENT_NAME
);
}
}
/**
/**
...
...
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