-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHPCS warning and error with refactoring #158
Conversation
Found following two issues in current stable version.
|
admin/class-fastcgi-purger.php
Outdated
|
||
$purge_urls = isset( $nginx_helper_admin->options['purge_url'] ) && ! empty( $nginx_helper_admin->options['purge_url'] ) ? | ||
explode( "\r\n", $nginx_helper_admin->options['purge_url'] ) : array(); | ||
|
||
// Allow plugins/themes to modify/extend urls. Pass urls array in first parameter, second says if wildcards are allowed | ||
// Allow plugins/themes to modify/extend urls. Pass urls array in first parameter, second says if wildcards are allowed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update this comment formate.
Also check where this 2nd value is useful because it seems we are always adding wildcard as false and apply_filter is not going to update it as it's 2nd paramter. Maybe we need to detect from somewhere that wildcard in url is supported or not.
// Allow plugins/themes to modify/extend urls. Pass urls array in first parameter, second says if wildcards are allowed. | |
/** | |
* Allow plugins/themes to modify/extend urls. | |
* | |
* @param array $purge_urls urls which needs to be purged. | |
* @param bool $wildcard If wildcard in url is allowed or not. default false. | |
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This filter is there in other places also, where wildcard is true.
admin/class-nginx-helper-admin.php
Outdated
} | ||
|
||
/** | ||
* Register the stylesheets for the admin area. | ||
* | ||
* @since 2.0.0 | ||
* | ||
* @param string $hook Hook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the variable what its used for, and then add comment don't just put a name like this. It's not hook.
* @param string $hook Hook. | |
* @param string $hook The current admin page. |
admin/class-nginx-helper-admin.php
Outdated
} | ||
|
||
/** | ||
* Register the JavaScript for the admin area. | ||
* | ||
* @since 2.0.0 | ||
* | ||
* @param string $hook Hook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for this as above.
admin/class-nginx-helper-admin.php
Outdated
foreach ( $rss_items as $item ) { | ||
?> | ||
<li role="listitem"> | ||
<a href='<?php echo esc_url( $item->get_permalink() ); ?>' title='<?php echo esc_attr_e( 'Posted ', 'nginx-helper' ) . esc_attr( $item->get_date( 'j F Y | g:i a' ) ); ?>'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use printf or sprintf ?
esc_url( $nginx_setting_link ) | ||
); | ||
printf( | ||
wp_kses( '%1$s (<a target="_blank" href="%2$s" title="%3$s">%4$s</a>)', array( 'strong' => array(), 'a' => array( 'href' => array(), 'title' => array() ) ) ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think escaping o/p of html code is make more sense her, not it's template/skeleton. Use wp_kses on sprintf o/p .
@@ -126,12 +156,18 @@ | |||
<input type="radio" value="get_request" id="purge_method_get_request" name="purge_method" <?php checked( $nginx_helper_settings['purge_method'], 'get_request' ); ?>> | |||
| |||
<?php | |||
_e( 'Using a GET request to <strong>PURGE/url</strong> (Default option)', 'nginx-helper' ); | |||
printf( | |||
wp_kses( '%1$s <strong>PURGE/url</strong> %2$s', array( 'strong' => array() ) ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for this as above. Escape final o/p.
?> | ||
<br /> | ||
<small> | ||
<?php | ||
_e( 'Uses the <strong><a href="https://github.com/FRiCKLE/ngx_cache_purge">ngx_cache_purge</a></strong> module. ', 'nginx-helper' ); | ||
printf( | ||
wp_kses( '%1$s <strong><a href="https://github.com/FRiCKLE/ngx_cache_purge">ngx_cache_purge</a></strong> %2$s.', array( 'strong' => array(), 'a' => array( 'href' => array() ) ) ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for this as above. Escape final o/p.
@@ -145,7 +181,10 @@ | |||
<br /> | |||
<small> | |||
<?php | |||
_e( 'Checks for matching cache file in <strong>RT_WP_NGINX_HELPER_CACHE_PATH</strong>. Does not require any other modules. Requires that the cache be stored on the same server as WordPress. You must also be using the default nginx cache options (levels=1:2) and (fastcgi_cache_key "$scheme$request_method$host$request_uri"). ', 'nginx-helper' ); | |||
printf( | |||
wp_kses( '%1$s<strong>RT_WP_NGINX_HELPER_CACHE_PATH</strong>. %2$s', array( 'strong' => array(), ) ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for this as above. Escape final o/p.
@@ -206,7 +272,10 @@ | |||
<input type="checkbox" value="1" id="purge_homepage_on_edit" name="purge_homepage_on_edit" <?php checked( $nginx_helper_settings['purge_homepage_on_edit'], 1 ); ?> /> | |||
| |||
<?php | |||
_e( 'when a <strong>post</strong> (or page/custom post) is <strong>modified</strong> or <strong>added</strong>.', 'nginx-helper' ); | |||
printf( | |||
wp_kses( '%1$s<strong>%2$s</strong>%3$s<strong>%4$s</strong>%5$s<strong>%6$s</strong>.', array( 'strong' => array(), ) ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for this as above. Escape final o/p.
Check for other places and update it.
@vaishaliagola27 Why did you resolve all comments before even pushing the changes? |
This PR contains below changes.
Below are some issues which need debugging.
Purging homepage http://nhtest.h1.rtdemo.in/ 2018-10-15 07:43:32 | ERROR | - Cache Not Found | http://nhtest.h1.rtdemo.in/