Skip to content

Coding standards - #15

Open
spacedmonkey wants to merge 2 commits into
stuttter:masterfrom
spacedmonkey:code-standards
Open

Coding standards#15
spacedmonkey wants to merge 2 commits into
stuttter:masterfrom
spacedmonkey:code-standards

Conversation

@spacedmonkey

Copy link
Copy Markdown

So I want to use this pluigin on a VIP Go project, so I needed to run the code sniffing and linting that platform requires.

This PR, contains formatting done by running phpcbf --standard=WordPress-VIP . . Other issues were fixed by hand. I have also added some manaul ignores, mostly for accesing super globals.

@spacedmonkey

Copy link
Copy Markdown
Author

For reference there are two warnings I did not fix

FILE: /home/jonny/Documents/workspace/wp-term-images/includes/class-wp-term-meta-ui.php
---------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
---------------------------------------------------------------------------------------
 412 | WARNING | Detected usage of meta_key, possible slow query.
 459 | WARNING | Detected usage of meta_key, possible slow query.
---------------------------------------------------------------------------------------

$term_id = 0;
// @codingStandardsIgnoreStart
if ( isset( $_GET['tag_ID'] ) ) {
$term_id = (int) sanitize_text_field( wp_unslash( $_GET['tag_ID'] ) );

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manaul fix.

// Get the meta value
$value = $this->get_meta( $term_id );
$hidden = empty( $value )
? ' display: none; '

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to remove style attr becauseesc_attr is used later.

Comment thread includes/class-wp-term-meta-ui.php Outdated
}
// Bail if no taxonomy passed or not on the `meta_key` column
// @codingStandardsIgnoreStart
if ( empty( $_REQUEST['taxonomy'] ) || ( $this->meta_key !== $custom_column ) || ! empty( $empty ) ) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore because of use of super global

? $_POST[ $term_key ]
: '';
// @codingStandardsIgnoreStart
$post = sanitize_text_field( wp_unslash( $_POST[ $term_key ] ) );

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore + manual fix.

return false;
} ?>
// Bail if not the meta_key column on the `edit-tags` screen for a visible taxonomy
if ( ( $this->meta_key !== $column_name ) || ( 'edit-tags' !== $screen ) || ! in_array( $name, $this->taxonomies, true ) ) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added strict on in_array

@spacedmonkey spacedmonkey left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some comments to changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant