diff --git a/.github/ci/main.sh b/.github/ci/main.sh index 240d82b8..028db8d0 100644 --- a/.github/ci/main.sh +++ b/.github/ci/main.sh @@ -26,7 +26,7 @@ function start_services() { # Create, setup and populate learn.rtcamp.com base site with data function create_and_configure_site () { - ee site create $SITE_NAME --wp --php74 + ee site create $SITE_NAME --wp --php74 cd $SITE_ROOT/wp-content/plugins/ rm -rf nginx-helper ls @@ -36,7 +36,6 @@ function create_and_configure_site () { ls wp plugin activate nginx-helper --allow-root wp user create automation automation@example.com --role=administrator --user_pass=automation --allow-root - wp theme activate twentytwentyone --allow-root } @@ -96,4 +95,4 @@ function main() { run_playwright_tests } -main \ No newline at end of file +main diff --git a/admin/class-nginx-helper-admin.php b/admin/class-nginx-helper-admin.php index a024e318..588b67e1 100644 --- a/admin/class-nginx-helper-admin.php +++ b/admin/class-nginx-helper-admin.php @@ -53,7 +53,7 @@ class Nginx_Helper_Admin { * * @since 2.0.0 * @access public - * @var string $options Purge options. + * @var string[] $options Purge options. */ public $options; @@ -345,6 +345,27 @@ public function nginx_helper_settings_link( $links ) { } + /** + * Check if the nginx log is enabled. + * + * @since 2.2.4 + * @return boolean + */ + public function is_nginx_log_enabled() { + + $options = get_site_option( 'rt_wp_nginx_helper_options', array() ); + + if ( ! empty( $options['enable_log'] ) && 1 === (int) $options['enable_log'] ) { + return true; + } + + if ( defined( 'NGINX_HELPER_LOG' ) && true === NGINX_HELPER_LOG ) { + return true; + } + + return false; + } + /** * Retrieve the asset path. * @@ -732,10 +753,10 @@ public function purge_all() { } if ( 'purge' === $action ) { - + /** * Fire an action after the entire cache has been purged whatever caching type is used. - * + * * @since 2.2.2 */ do_action( 'rt_nginx_helper_after_purge_all' ); diff --git a/admin/class-purger.php b/admin/class-purger.php index ac54b8d0..ee07019e 100644 --- a/admin/class-purger.php +++ b/admin/class-purger.php @@ -529,7 +529,7 @@ public function log( $msg, $level = 'INFO' ) { global $nginx_helper_admin; - if ( ! $nginx_helper_admin->options['enable_log'] ) { + if ( ! $nginx_helper_admin->is_nginx_log_enabled() ) { return; } @@ -562,7 +562,7 @@ public function check_and_truncate_log_file() { global $nginx_helper_admin; - if ( ! $nginx_helper_admin->options['enable_log'] ) { + if ( ! $nginx_helper_admin->is_nginx_log_enabled() ) { return; } diff --git a/admin/css/nginx-helper-admin.css b/admin/css/nginx-helper-admin.css index 8d1b4b30..0a8856ba 100644 --- a/admin/css/nginx-helper-admin.css +++ b/admin/css/nginx-helper-admin.css @@ -98,3 +98,8 @@ form#purgeall .button-primary:focus { } .rt-purge_url { width: 100%; } + +.enable-logging-message { + font-size: 13px; + margin-left: 23px; +} diff --git a/admin/partials/nginx-helper-general-options.php b/admin/partials/nginx-helper-general-options.php index 87f2e32d..20ce88a3 100644 --- a/admin/partials/nginx-helper-general-options.php +++ b/admin/partials/nginx-helper-general-options.php @@ -539,9 +539,46 @@ - /> + + is_nginx_log_enabled(), true ); ?> + + /> @@ -626,7 +663,7 @@ -