From 8a66f0cc515829d5fe4354310be9ef30e50a1d41 Mon Sep 17 00:00:00 2001 From: Luca Tumedei Date: Fri, 19 Apr 2024 15:52:48 +0200 Subject: [PATCH 1/3] feat(airplane-mode) refactor plugin --- changelog.md | 4 ++ slic.bat | 2 +- slic.php | 2 +- src/commands/airplane-mode.php | 67 ++++++++++++++++++++++++++++------ src/slic.php | 15 ++++++++ 5 files changed, 76 insertions(+), 14 deletions(-) diff --git a/changelog.md b/changelog.md index 2aa35bb..b19b9ee 100644 --- a/changelog.md +++ b/changelog.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# [1.6.1] - 2024-04-19 +* Change - the `airplane-mode` command now installs the plugin in the must-use plugins directory instead of the plugins directory. +* Fixed - `.bat` file now uses the correct path to the `slic` executable on Windows. + # [1.6.0] - 2024-04-10 * Added - The `slic update-dump` command to update a dump file for the current project, with an optional WordPress version update, e.g. `slic update-dump tests/_data/dump.sql latest`. diff --git a/slic.bat b/slic.bat index 2385086..6844533 100644 --- a/slic.bat +++ b/slic.bat @@ -4,4 +4,4 @@ if "%PHP_PEAR_PHP_BIN%" neq "" ( set PHPBIN=%PHP_PEAR_PHP_BIN% ) else set PHPBIN=php -"%PHPBIN%" "slic" %* +"%PHPBIN%" "%~dp0\slic.php" %* diff --git a/slic.php b/slic.php index fe057b4..b15660a 100644 --- a/slic.php +++ b/slic.php @@ -34,7 +34,7 @@ ] ); $cli_name = 'slic'; -const CLI_VERSION = '1.6.0'; +const CLI_VERSION = '1.6.1'; // If the run-time option `-q`, for "quiet", is specified, then do not print the header. if ( in_array( '-q', $argv, true ) || ( in_array( 'exec', $argv, true ) && ! in_array( 'help', $argv, true ) ) ) { diff --git a/src/commands/airplane-mode.php b/src/commands/airplane-mode.php index 8960e2b..647de93 100644 --- a/src/commands/airplane-mode.php +++ b/src/commands/airplane-mode.php @@ -42,8 +42,19 @@ setup_id(); ensure_wordpress_ready(); -$ensure_airplane_mode_plugin = static function () { - $plugin_dir = slic_plugins_dir( 'airplane-mode' ); +$ensure_airplane_mode_plugin_present = static function () { + $mu_plugins_dir = slic_mu_plugins_dir(); + $plugin_dir = $mu_plugins_dir . DIRECTORY_SEPARATOR . 'airplane-mode'; + + if ( + ! is_dir( dirname( $mu_plugins_dir ) ) + && ! mkdir( $concurrentDirectory = dirname( $mu_plugins_dir ), 0755, true ) + && ! is_dir( $concurrentDirectory ) + ) { + echo magenta( "Failed to create mu-plugins directory {$mu_plugins_dir}." ); + exit( 1 ); + } + if ( ! is_dir( $plugin_dir ) ) { $cloned = process_realtime( 'git clone https://github.com/norcross/airplane-mode ' . $plugin_dir ); if ( $cloned !== 0 ) { @@ -51,19 +62,51 @@ exit( 1 ); } } + + if ( + is_file( $mu_plugins_dir . DIRECTORY_SEPARATOR . 'airplane-mode.php' ) + && ! unlink( $mu_plugins_dir . DIRECTORY_SEPARATOR . 'airplane-mode.php' ) + ) { + echo magenta( "Failed to remove the airplane-mode plugin." ); + exit( 1 ); + } + + $loader_code = <<< PHP + Date: Fri, 19 Apr 2024 17:14:45 +0200 Subject: [PATCH 2/3] fix(airplane-mode) ensure all blocks are on --- src/commands/airplane-mode.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/commands/airplane-mode.php b/src/commands/airplane-mode.php index 647de93..4c459f4 100644 --- a/src/commands/airplane-mode.php +++ b/src/commands/airplane-mode.php @@ -74,6 +74,9 @@ $loader_code = <<< PHP Date: Fri, 19 Apr 2024 17:33:17 +0200 Subject: [PATCH 3/3] doc(slic.php) remove @since annotation --- src/slic.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/slic.php b/src/slic.php index 38f2fc4..0fd5a1e 100644 --- a/src/slic.php +++ b/src/slic.php @@ -462,8 +462,6 @@ function slic_themes_dir( $path = '' ) { /** * Returns the absolute path to the current mu-plugins directory slic is using. * - * @since TBD - * * @param string $path An optional path to append to the current slic mu-plugins directory. * * @return string The absolute path to the current mu-plugins directory slic is using.