diff --git a/.github/ci/main.sh b/.github/ci/main.sh index 240d82b8..c0d96fbc 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 } @@ -55,7 +54,7 @@ function build_package(){ } function install_playwright(){ - cd $GITHUB_WORKSPACE/tests/e2e-playwright + cd $GITHUB_WORKSPACE/tests/e2e-playwright npx playwright install } @@ -96,4 +95,4 @@ function main() { run_playwright_tests } -main \ No newline at end of file +main diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 6b8ef2b7..765f7a7a 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -6,12 +6,12 @@ name: End-to-End Tests on: # Triggers the workflow on push or pull request events but only for the main branch push: - branches: + branches: - develop - master - + pull_request: - branches: + branches: - develop - master @@ -23,14 +23,14 @@ jobs: # The type of runner that the job will run on name: Playwright Tests runs-on: ubuntu-latest - env: + env: TESRESULT_TOKEN: ${{ secrets.TESRESULT_TOKEN }} TOKEN: ${{ secrets.GITHUB_TOKEN }} SHA: ${{ github.event.pull_request.head.sha }} COMMIT_SHA: ${{ github.sha }} PR_NUMBER: ${{ github.event.pull_request.number }} working-directory: ./tests/e2e-playwright - + # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it diff --git a/README.md b/README.md index 1c710a93..567c605e 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,11 @@ Please post your problem in [our free support forum](https://github.com/rtCamp/n ## Changelog ## +### 2.2.4 ### + +* Introduces the capability to specify the `NGINX_HELPER_LOG` constant, allowing users to activate the logging feature. [#318](https://github.com/rtCamp/nginx-helper/pull/318) - by [Vishal Kakadiya](https://github.com/vishalkakadiya) +* Existing users employing the nginx-helper plugin with logging enabled will experience no disruptions. However, if logging is disabled, users must define the `NGINX_HELPER_LOG` constant to re-enable the logging feature. + ### 2.2.3 ### * Add the URL being purged as parameter in `rt_nginx_helper_purge_cached_file` hook. [#271](https://github.com/rtCamp/nginx-helper/pull/271) - by [Arafat Islam](https://github.com/arafatkn) 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 @@ -