Skip to content

Commit

Permalink
Fix analyser
Browse files Browse the repository at this point in the history
  • Loading branch information
BTSmolders committed Dec 16, 2023
1 parent 602242a commit d224d32
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion phpstan.neon.dist → phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
includes:
- vendor/szepeviktor/phpstan-wordpress/extension.neon
parameters:
level: max
level: 1
inferPrivatePropertyTypeFromConstructor: true
scanFiles:
- vendor/php-stubs/wp-cli-stubs/wp-cli-stubs.php
Expand Down
8 changes: 8 additions & 0 deletions wordpress-readonly.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
add_filter(
'heartbeat_received',
function ($response) {
/** @var string $readonlyInfo */
$readonlyInfo = get_option(PIVVENIT_WORDPRESS_READONLY_INFO);
if (!$readonlyInfo) {
$readonlyInfo = new stdClass();
Expand All @@ -48,12 +49,15 @@ function () {
['wp-i18n']
);
wp_set_script_translations('pivvenit_wordpress_readonly_heartbeat', 'pivvenit-wordpress-readonly');

return true;
}
);

add_action(
'admin_notices',
function () {
/** @var string $readonlyInfo */
$readonlyInfo = get_option(PIVVENIT_WORDPRESS_READONLY_INFO);
if (!$readonlyInfo) {
return;
Expand All @@ -75,6 +79,7 @@ function () {
add_filter(
'wp_authenticate_user',
function ($user) {
/** @var string $readonlyInfo */
$readonlyInfo = get_option(PIVVENIT_WORDPRESS_READONLY_INFO);
if (!$readonlyInfo) {
return $user;
Expand All @@ -99,6 +104,7 @@ function ($user) {
add_action(
'plugins_loaded',
function () {
/** @var string $readonlyInfo */
$readonlyInfo = get_option(PIVVENIT_WORDPRESS_READONLY_INFO);
if (!$readonlyInfo) {
return;
Expand Down Expand Up @@ -137,6 +143,7 @@ function () {
$softReadonlyPeriod = new DateTime("now");
$readonlyInfo->status = 'prepare';
$readonlyInfo->id = $softReadonlyPeriod->getTimestamp();
/** @var string $readonlyInfo */
update_option(PIVVENIT_WORDPRESS_READONLY_INFO, json_encode($readonlyInfo));
$displayDate = $softReadonlyPeriod->format('Y-m-d H:i:s');
WP_CLI::success("[{$displayDate}] System is going in readonly mode in 60 seconds");
Expand All @@ -152,6 +159,7 @@ function () {
WP_CLI::add_command(
'readonly disable',
function () {
/** @var string $readonlyInfo */
$readonlyInfo = get_option(PIVVENIT_WORDPRESS_READONLY_INFO);
if (!$readonlyInfo) {
$readonlyInfo = new stdClass();
Expand Down

0 comments on commit d224d32

Please sign in to comment.