Skip to content

Commit d894f3e

Browse files
authoredJan 18, 2024
Merge pull request #318 from rtCamp/develop
Develop to Master merge for v2.2.4 [Production]
2 parents 23f7b70 + ba46696 commit d894f3e

14 files changed

+259
-165
lines changed
 

‎.github/ci/main.sh

+3-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function start_services() {
2626
# Create, setup and populate learn.rtcamp.com base site with data
2727
function create_and_configure_site () {
2828

29-
ee site create $SITE_NAME --wp --php74
29+
ee site create $SITE_NAME --wp --php74
3030
cd $SITE_ROOT/wp-content/plugins/
3131
rm -rf nginx-helper
3232
ls
@@ -36,7 +36,6 @@ function create_and_configure_site () {
3636
ls
3737
wp plugin activate nginx-helper --allow-root
3838
wp user create automation automation@example.com --role=administrator --user_pass=automation --allow-root
39-
wp theme activate twentytwentyone --allow-root
4039
}
4140

4241

@@ -55,7 +54,7 @@ function build_package(){
5554
}
5655

5756
function install_playwright(){
58-
cd $GITHUB_WORKSPACE/tests/e2e-playwright
57+
cd $GITHUB_WORKSPACE/tests/e2e-playwright
5958
npx playwright install
6059
}
6160

@@ -96,4 +95,4 @@ function main() {
9695
run_playwright_tests
9796
}
9897

99-
main
98+
main

‎.github/workflows/e2e-test.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ name: End-to-End Tests
66
on:
77
# Triggers the workflow on push or pull request events but only for the main branch
88
push:
9-
branches:
9+
branches:
1010
- develop
1111
- master
12-
12+
1313
pull_request:
14-
branches:
14+
branches:
1515
- develop
1616
- master
1717

@@ -23,14 +23,14 @@ jobs:
2323
# The type of runner that the job will run on
2424
name: Playwright Tests
2525
runs-on: ubuntu-latest
26-
env:
26+
env:
2727
TESRESULT_TOKEN: ${{ secrets.TESRESULT_TOKEN }}
2828
TOKEN: ${{ secrets.GITHUB_TOKEN }}
2929
SHA: ${{ github.event.pull_request.head.sha }}
3030
COMMIT_SHA: ${{ github.sha }}
3131
PR_NUMBER: ${{ github.event.pull_request.number }}
3232
working-directory: ./tests/e2e-playwright
33-
33+
3434
# Steps represent a sequence of tasks that will be executed as part of the job
3535
steps:
3636
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it

‎README.md

+5
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ Please post your problem in [our free support forum](https://github.com/rtCamp/n
139139

140140
## Changelog ##
141141

142+
### 2.2.4 ###
143+
144+
* 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)
145+
* 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.
146+
142147
### 2.2.3 ###
143148

144149
* 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)

‎admin/class-nginx-helper-admin.php

+24-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Nginx_Helper_Admin {
5353
*
5454
* @since 2.0.0
5555
* @access public
56-
* @var string $options Purge options.
56+
* @var string[] $options Purge options.
5757
*/
5858
public $options;
5959

@@ -345,6 +345,27 @@ public function nginx_helper_settings_link( $links ) {
345345

346346
}
347347

348+
/**
349+
* Check if the nginx log is enabled.
350+
*
351+
* @since 2.2.4
352+
* @return boolean
353+
*/
354+
public function is_nginx_log_enabled() {
355+
356+
$options = get_site_option( 'rt_wp_nginx_helper_options', array() );
357+
358+
if ( ! empty( $options['enable_log'] ) && 1 === (int) $options['enable_log'] ) {
359+
return true;
360+
}
361+
362+
if ( defined( 'NGINX_HELPER_LOG' ) && true === NGINX_HELPER_LOG ) {
363+
return true;
364+
}
365+
366+
return false;
367+
}
368+
348369
/**
349370
* Retrieve the asset path.
350371
*
@@ -732,10 +753,10 @@ public function purge_all() {
732753
}
733754

734755
if ( 'purge' === $action ) {
735-
756+
736757
/**
737758
* Fire an action after the entire cache has been purged whatever caching type is used.
738-
*
759+
*
739760
* @since 2.2.2
740761
*/
741762
do_action( 'rt_nginx_helper_after_purge_all' );

‎admin/class-purger.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ public function log( $msg, $level = 'INFO' ) {
529529

530530
global $nginx_helper_admin;
531531

532-
if ( ! $nginx_helper_admin->options['enable_log'] ) {
532+
if ( ! $nginx_helper_admin->is_nginx_log_enabled() ) {
533533
return;
534534
}
535535

@@ -562,7 +562,7 @@ public function check_and_truncate_log_file() {
562562

563563
global $nginx_helper_admin;
564564

565-
if ( ! $nginx_helper_admin->options['enable_log'] ) {
565+
if ( ! $nginx_helper_admin->is_nginx_log_enabled() ) {
566566
return;
567567
}
568568

‎admin/css/nginx-helper-admin.css

+5
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,8 @@ form#purgeall .button-primary:focus {
9898
}
9999

100100
.rt-purge_url { width: 100%; }
101+
102+
.enable-logging-message {
103+
font-size: 13px;
104+
margin-left: 23px;
105+
}

‎admin/partials/nginx-helper-general-options.php

+39-2
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,46 @@
539539
<?php } ?>
540540
<tr valign="top">
541541
<td>
542-
<input type="checkbox" value="1" id="enable_log" name="enable_log"<?php checked( $nginx_helper_settings['enable_log'], 1 ); ?> />
542+
<?php
543+
$is_checkbox_enabled = false;
544+
if ( 1 === (int) $nginx_helper_settings['enable_log'] ) {
545+
$is_checkbox_enabled = true;
546+
}
547+
?>
548+
<input
549+
type="checkbox" value="1" id="enable_log" name="enable_log"
550+
<?php checked( $nginx_helper_admin->is_nginx_log_enabled(), true ); ?>
551+
<?php echo esc_attr( $is_checkbox_enabled ? '' : ' disabled ' ); ?>
552+
/>
543553
<label for="enable_log">
544554
<?php esc_html_e( 'Enable Logging', 'nginx-helper' ); ?>
555+
<?php
556+
if ( ! $is_checkbox_enabled ) {
557+
558+
$setting_message_detail = [
559+
'status' => __( 'disable', 'nginx-helper' ),
560+
'value' => 'false',
561+
];
562+
563+
if ( ! $nginx_helper_admin->is_nginx_log_enabled() ) {
564+
$setting_message_detail = [
565+
'status' => __( 'enable', 'nginx-helper' ),
566+
'value' => 'true',
567+
];
568+
}
569+
570+
printf(
571+
'<p class="enable-logging-message">(<b>%1$s:</b> %2$s %3$s %4$s <b>NGINX_HELPER_LOG</b> constant %5$s <b>%6$s</b> %7$s <b>wp-config.php</b>)</p>',
572+
esc_html__( 'NOTE', 'nginx-helper' ),
573+
esc_html__( 'To', 'nginx-helper' ),
574+
esc_html( $setting_message_detail['status'] ),
575+
esc_html__( 'the logging feature, you must define', 'nginx-helper' ),
576+
esc_html__( 'as', 'nginx-helper' ),
577+
esc_html( $setting_message_detail['value'] ),
578+
esc_html__( 'in your', 'nginx-helper' )
579+
);
580+
}
581+
?>
545582
</label>
546583
</td>
547584
</tr>
@@ -626,7 +663,7 @@
626663
<?php
627664
}
628665
?>
629-
<div class="postbox enable_log"<?php echo ( empty( $nginx_helper_settings['enable_log'] ) ) ? ' style="display: none;"' : ''; ?>>
666+
<div class="postbox enable_log"<?php echo ( ! $nginx_helper_admin->is_nginx_log_enabled() ) ? ' style="display: none;"' : ''; ?>>
630667
<h3 class="hndle">
631668
<span><?php esc_html_e( 'Logging Options', 'nginx-helper' ); ?></span>
632669
</h3>

‎includes/class-nginx-helper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Nginx_Helper {
7777
public function __construct() {
7878

7979
$this->plugin_name = 'nginx-helper';
80-
$this->version = '2.2.3';
80+
$this->version = '2.2.4';
8181
$this->minimum_wp = '3.0';
8282

8383
if ( ! $this->required_wp_version() ) {

‎languages/nginx-helper.mo

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.