Skip to content

Commit

Permalink
PHPCS: fix formatting of some ignore annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Dec 19, 2023
1 parent f7d315e commit be2a056
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion admin/class-product-upsell-notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function set_upgrade_notice() {
* @return void
*/
public function dismiss_notice_listener() {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are validating a nonce here.
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are validating a nonce here.
if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], 'dismiss-5star-upsell' ) ) {
return;
}
Expand Down
8 changes: 4 additions & 4 deletions admin/class-yoast-notification-center.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,9 @@ public function get_sorted_notifications() {
*/
public function ajax_get_notifications() {
$echo = false;
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form data.
// phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form data.
if ( isset( $_POST['version'] ) && is_string( $_POST['version'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are only comparing the variable in a condition.
// phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are only comparing the variable in a condition.
$echo = wp_unslash( $_POST['version'] ) === '2';
}

Expand Down Expand Up @@ -703,7 +703,7 @@ private static function get_user_input( $key ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized,WordPress.Security.NonceVerification.Missing -- Reason: We are not processing form information and only using this variable in a comparison.
$request_method = isset( $_SERVER['REQUEST_METHOD'] ) && is_string( $_SERVER['REQUEST_METHOD'] ) ? strtoupper( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) : '';
// phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: This function does not sanitize variables.
// phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing -- Reason: This function does not verify a nonce.
// phpcs:disable WordPress.Security.NonceVerification.Recommended,WordPress.Security.NonceVerification.Missing -- Reason: This function does not verify a nonce.
if ( $request_method === 'POST' ) {
if ( isset( $_POST[ $key ] ) && is_string( $_POST[ $key ] ) ) {
return wp_unslash( $_POST[ $key ] );
Expand All @@ -712,7 +712,7 @@ private static function get_user_input( $key ) {
elseif ( isset( $_GET[ $key ] ) && is_string( $_GET[ $key ] ) ) {
return wp_unslash( $_GET[ $key ] );
}
// phpcs:enable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
// phpcs:enable WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
return '';
}

Expand Down
2 changes: 1 addition & 1 deletion admin/class-yoast-plugin-conflict.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected function __construct() {

// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
if ( isset( $_GET['action'] ) && is_string( $_GET['action'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information and only comparing the variable in a condition.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information and only comparing the variable in a condition.
$action = wp_unslash( $_GET['action'] );
if ( $action === 'deactivate' ) {
$this->remove_deactivated_plugin();
Expand Down
8 changes: 4 additions & 4 deletions admin/import/plugins/class-import-aioseo-v4.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function meta_key_clone_replace( $replace_values ) {
// Now, we'll also loop through the replace_vars array, which holds the mappings between the AiOSEO variables and the Yoast variables.
// We'll replace all the AiOSEO variables in the temporary table with their Yoast equivalents.
foreach ( $this->replace_vars as $aioseo_variable => $yoast_variable ) {
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: We need this query and this is done at many other places as well, for example class-import-rankmath.
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: We need this query and this is done at many other places as well, for example class-import-rankmath.
$wpdb->query(
$wpdb->prepare(
'UPDATE tmp_meta_table SET meta_value = REPLACE( meta_value, %s, %s )',
Expand Down Expand Up @@ -184,7 +184,7 @@ protected function replace_custom_field_or_taxonomy_replace_vars( $unique_custom
$aioseo_variable = "#{$aioseo_prefix}-{$unique_custom_field_or_taxonomy}";
$yoast_variable = "%%{$yoast_prefix}_{$unique_custom_field_or_taxonomy}%%";

// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching
$wpdb->query(
$wpdb->prepare(
'UPDATE tmp_meta_table SET meta_value = REPLACE( meta_value, %s, %s )',
Expand All @@ -195,7 +195,7 @@ protected function replace_custom_field_or_taxonomy_replace_vars( $unique_custom
}
}

// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching

/**
* Retrieve all the meta values from the temporary meta table that contain
Expand All @@ -216,7 +216,7 @@ protected function get_meta_values_with_custom_field_or_taxonomy( $wpdb, $aioseo
);
}

// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
// phpcs:enable WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching

/**
* Detects whether there is AIOSEO data to import by looking whether the AIOSEO data have been cleaned up.
Expand Down
2 changes: 1 addition & 1 deletion admin/metabox/class-metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ protected function get_metabox_post() {

// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
if ( isset( $_GET['post'] ) && is_string( $_GET['post'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, Sanitization happens in the validate_int function.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, Sanitization happens in the validate_int function.
$post_id = (int) WPSEO_Utils::validate_int( wp_unslash( $_GET['post'] ) );

$this->post = get_post( $post_id );
Expand Down
8 changes: 4 additions & 4 deletions admin/taxonomy/class-taxonomy-columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function parse_column( $content, $column_name, $term_id ) {
* @return string|null The current taxonomy or null when it is not set.
*/
public function get_current_taxonomy() {
// phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
// phpcs:disable WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
if ( ! empty( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] === 'POST' ) {
if ( isset( $_POST['taxonomy'] ) && is_string( $_POST['taxonomy'] ) ) {
return sanitize_text_field( wp_unslash( $_POST['taxonomy'] ) );
Expand All @@ -134,7 +134,7 @@ public function get_current_taxonomy() {
elseif ( isset( $_GET['taxonomy'] ) && is_string( $_GET['taxonomy'] ) ) {
return sanitize_text_field( wp_unslash( $_GET['taxonomy'] ) );
}
// phpcs:enable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
// phpcs:enable WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended
return null;
}

Expand All @@ -144,7 +144,7 @@ public function get_current_taxonomy() {
* @return string|null
*/
private function get_taxonomy() {
// phpcs:disable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
// phpcs:disable WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
if ( wp_doing_ajax() ) {
if ( isset( $_POST['taxonomy'] ) && is_string( $_POST['taxonomy'] ) ) {
return sanitize_text_field( wp_unslash( $_POST['taxonomy'] ) );
Expand All @@ -153,7 +153,7 @@ private function get_taxonomy() {
elseif ( isset( $_GET['taxonomy'] ) && is_string( $_GET['taxonomy'] ) ) {
return sanitize_text_field( wp_unslash( $_GET['taxonomy'] ) );
}
// phpcs:enable WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended
// phpcs:enable WordPress.Security.NonceVerification.Missing,WordPress.Security.NonceVerification.Recommended
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions admin/taxonomy/class-taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function update_term( $term_id, $tt_id, $taxonomy ) {
foreach ( WPSEO_Taxonomy_Meta::$defaults_per_term as $key => $default ) {
// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: Nonce is already checked by WordPress before executing this action.
if ( isset( $_POST[ $key ] ) && is_string( $_POST[ $key ] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: $data is getting sanitized later.
// phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: $data is getting sanitized later.
$data = wp_unslash( $_POST[ $key ] );
$new_meta_data[ $key ] = ( $key !== 'wpseo_canonical' ) ? WPSEO_Utils::sanitize_text_field( $data ) : WPSEO_Utils::sanitize_url( $data );
}
Expand Down Expand Up @@ -401,7 +401,7 @@ private static function get_taxonomy() {
private static function get_tag_id() {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
if ( isset( $_GET['tag_ID'] ) && is_string( $_GET['tag_ID'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are casting to an integer.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are casting to an integer.
$tag_id = (int) wp_unslash( $_GET['tag_ID'] );
if ( $tag_id > 0 ) {
return $tag_id;
Expand Down
2 changes: 1 addition & 1 deletion admin/views/tabs/tool/wpseo-export.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/* translators: %1$s expands to Yoast SEO */
$submit_button_value = sprintf( __( 'Export your %1$s settings', 'wordpress-seo' ), 'Yoast SEO' );

// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: The nonce will be verified in WPSEO_Export below, We are only strictly comparing with '1'.
// phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: The nonce will be verified in WPSEO_Export below, We are only strictly comparing with '1'.
if ( isset( $_POST['do_export'] ) && wp_unslash( $_POST['do_export'] ) === '1' ) {
$export = new WPSEO_Export();
$export->export();
Expand Down
4 changes: 2 additions & 2 deletions inc/class-addon-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ public function expired_subscription_warning( $plugin_data ) {
'<a href="' . esc_url( WPSEO_Shortlinker::get( $addon_link ) ) . '">',
'</a>'
)
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is escaped above.
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output is escaped above.
. $sale_copy
. '</strong>';
}
Expand Down Expand Up @@ -730,7 +730,7 @@ protected function get_site_information_transient() {
$current_page = null;
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
if ( isset( $_GET['page'] ) && is_string( $_GET['page'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are only strictly comparing and thus no need to sanitize.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are only strictly comparing and thus no need to sanitize.
$current_page = wp_unslash( $_GET['page'] );
}

Expand Down
2 changes: 1 addition & 1 deletion inc/sitemaps/class-sitemaps.php
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ public static function get_last_modified_gmt( $post_types, $return_all = false )
ORDER BY date DESC
";

// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery -- They are prepared on the lines above and a direct query is required.
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared,WordPress.DB.DirectDatabaseQuery -- They are prepared on the lines above and a direct query is required.
foreach ( $wpdb->get_results( $sql ) as $obj ) {
$post_type_dates[ $obj->post_type ] = $obj->date;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/dependency-injection/container-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function register( $name, ContainerInterface $container ) {
self::$containers[ $name ] = $container;
}

// phpcs:disable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber -- PHPCS doesn't take into account exceptions thrown in called methods.
// phpcs:disable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber -- PHPCS doesn't take into account exceptions thrown in called methods.

/**
* Get an instance from a specific container.
Expand All @@ -53,7 +53,7 @@ public static function get( $name, $id, $invalid_behaviour = 1 ) {
return self::$containers[ $name ]->get( $id, $invalid_behaviour );
}

// phpcs:enable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber
// phpcs:enable Squiz.Commenting.FunctionCommentThrowTag.WrongNumber

/**
* Attempts to find a given service ID in all registered containers.
Expand Down
4 changes: 2 additions & 2 deletions src/conditionals/third-party/elementor-edit-conditional.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function is_met() {

// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
if ( isset( $_GET['action'] ) && \is_string( $_GET['action'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are only strictly comparing.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are only strictly comparing.
$get_action = \wp_unslash( $_GET['action'] );
if ( $pagenow === 'post.php' && $get_action === 'elementor' ) {
return true;
Expand All @@ -29,7 +29,7 @@ public function is_met() {

// phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reason: We are not processing form information.
if ( isset( $_POST['action'] ) && \is_string( $_POST['action'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are only strictly comparing.
// phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are only strictly comparing.
$post_action = \wp_unslash( $_POST['action'] );
return \wp_doing_ajax() && $post_action === 'wpseo_elementor_save';
}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/crawl-cleanup-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public function singular_url() {
}

// Fix reply to comment links, whoever decided this should be a GET variable?
// phpcs:ignore WordPress.Security -- We know this is scary.
// phpcs:ignore WordPress.Security -- We know this is scary.
if ( isset( $_SERVER['REQUEST_URI'] ) && \preg_match( '`(\?replytocom=[^&]+)`', \sanitize_text_field( $_SERVER['REQUEST_URI'] ), $matches ) ) {
$proper_url .= \str_replace( '?replytocom=', '#comment-', $matches[0] );
}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/current-page-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public function get_current_admin_page() {
public function is_yoast_seo_page() {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
if ( isset( $_GET['page'] ) && \is_string( $_GET['page'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are only using the variable in the strpos function.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are only using the variable in the strpos function.
$current_page = \wp_unslash( $_GET['page'] );
return \strpos( $current_page, 'wpseo_' ) === 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/pagination-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function get_page_number_from_query_loop() {
$key_query_loop = $this->get_key_query_loop();

if ( $key_query_loop ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.Recommended -- Validated in get_key_query_loop().
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated,WordPress.Security.NonceVerification.Recommended -- Validated in get_key_query_loop().
$page_number = (int) $_GET[ $key_query_loop ];
if ( $page_number > 1 ) {
return $page_number;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/wpdb-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct( wpdb $wpdb ) {
* @return bool Whether the table exists.
*/
public function table_exists( $table ) {
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Reason: There is no unescaped user input.
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Reason: There is no unescaped user input.
$table_exists = $this->wpdb->get_var( "SHOW TABLES LIKE '{$table}'" );
if ( \is_wp_error( $table_exists ) || \is_null( $table_exists ) ) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/integrations/admin/deactivated-premium-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function premium_deactivated_notice() {
) . '">',
'</a>'
);
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- Output escaped above.
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped -- Output escaped above.
echo new Notice_Presenter(
/* translators: 1: Yoast SEO Premium */
\sprintf( \__( 'Activate %1$s!', 'wordpress-seo' ), 'Yoast SEO Premium' ),
Expand All @@ -103,7 +103,7 @@ public function premium_deactivated_notice() {
true,
'yoast-premium-deactivated-notice'
);
// phpcs:enable
// phpcs:enable

// Enable permanently dismissing the notice.
echo "<script>
Expand Down
Loading

0 comments on commit be2a056

Please sign in to comment.