-
Notifications
You must be signed in to change notification settings - Fork 116
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
WordPress VIP coding standards compliance #1111
Conversation
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 looks great @kidunot89!
Having reviewed the live-updates feature and the way it uses request variables I'm thinking if we should pull the feature from the current release or somehow reduce the amount of request variables we're passing to the JS side via JSON in DOM.
classes/class-admin.php
Outdated
// input var okay, CSRF okay | ||
'current_query_count' => count( $_GET ), // WPCS: CSRF ok. | ||
// input var okay, CSRF okay | ||
'current_page' => isset( $_GET['paged'] ) ? esc_js( $_GET['paged'] ) : '1', // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
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.
Should this be sanitized to an integer value?
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.
absint( wp_unslash( $_GET['paged] ) )
would probably be my preference here, but there are many ways to sanitize/escape this.
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 gotcha, I wasn't worried about the code and was just trying to silence the PHPCS warning.
classes/class-admin.php
Outdated
'current_query_count' => count( $_GET ), // WPCS: CSRF ok. | ||
// input var okay, CSRF okay | ||
'current_page' => isset( $_GET['paged'] ) ? esc_js( $_GET['paged'] ) : '1', // phpcs:ignore WordPress.Security.NonceVerification.Recommended | ||
'current_order' => isset( $_GET['order'] ) ? esc_js( $_GET['order'] ) : 'desc', // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
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.
Could we check that it's one of the allowed values of order
before setting it? Do we support anything apart from desc
and asc
?
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 agree, if there are only asc
and desc
we can do a check for one and manually set this instead of excepting any value.
39d8bcb
to
ee379e1
Compare
@@ -154,7 +154,7 @@ function ( $var ) { | |||
$result = $this->plugin->db->insert( $recordarr ); | |||
|
|||
// This is helpful in development environments: | |||
// error_log( $this->debug_backtrace( $recordarr ) ); | |||
// error_log( $this->debug_backtrace( $recordarr ) );. |
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.
Could we remove this completely?
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.
Looks good!
Looks like need to resolve the merge conflict. @kidunot89 could you do that, please? |
96dbebb
to
6458a3b
Compare
@@ -23,6 +23,6 @@ | |||
<exclude-pattern>*/ui/lib/*</exclude-pattern> | |||
<exclude-pattern>*/vendor/*</exclude-pattern> | |||
<exclude-pattern>*/build/*</exclude-pattern> | |||
<exclude-pattern>*/local/public/*</exclude-pattern> | |||
<exclude-pattern>*/local/*</exclude-pattern> |
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.
Since it only used is in development, I've added the whole local
directory to be ignored by PHPCS.
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.
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.
It would be nice to have all PHP files with consistent formatting even if they're used for development purposes.
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.
Looks good @kidunot89!
Could we please create issues for all instances of phpcs:ignore
to add the nonce checks?
Summary
Adds the VIP coding standards and clears up all the warnings from the PHPCS test.