| @@ -1,6 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) && PHP_SAPI !== 'cli' ) { exit; } | |
| 2 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | + // Composer autoloads this file, so CLI tooling loads it without WordPress. | |
| 4 | + if ( PHP_SAPI !== 'cli' ) { | |
| 5 | + exit; | |
| 6 | + } | |
| 7 | +} | |
| 3 | 8 | /** |
| 4 | 9 | * Get timezone list. |
| 5 | 10 | * |
| 6 | 11 | * @return array |
| @@ -785,8 +790,26 @@ | ||
| 785 | 790 | ); |
| 786 | 791 | |
| 787 | 792 | return $modules_list; |
| 788 | 793 | } |
| 794 | + } | |
| 795 | +} | |
| 796 | + | |
| 797 | +if ( ! function_exists( 'booktics_log' ) ) { | |
| 798 | + /** | |
| 799 | + * Write a debug line, but only when the site has debug logging switched on. | |
| 800 | + * | |
| 801 | + * @param string $message Message to log. | |
| 802 | + * | |
| 803 | + * @return void | |
| 804 | + */ | |
| 805 | + function booktics_log( $message ) { | |
| 806 | + if ( ! defined( 'WP_DEBUG_LOG' ) || ! WP_DEBUG_LOG ) { | |
| 807 | + return; | |
| 808 | + } | |
| 809 | + | |
| 810 | + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log -- Guarded above; this is the plugin's only debug sink. | |
| 811 | + error_log( 'Booktics: ' . $message ); | |
| 789 | 812 | } |
| 790 | 813 | } |
| 791 | 814 | |
| 792 | 815 | if ( ! function_exists( 'booktics_get_multisite_table_name' ) ) { |