Skip to content

Commit a4c1209

Browse files
miyanialkesh7lloc
andauthored
Suppress verified false-positive PHPCS/Plugin Check warnings, remove redundant textdomain load (#670)
* Remove discouraged load_plugin_textdomain() call, add missing docblock tags WordPress.org already auto-loads this plugin's bundled translations by matching the text domain to the plugin slug, so the manual load_plugin_textdomain() call flagged by the WordPress.org Plugin Check tool is unnecessary. Also add the @var/@PARAM docblock tags on Plugin.php flagged by PHPCS. * Suppress verified false-positive PHPCS/Plugin Check warnings Add justified phpcs:ignore comments for two categories of warnings verified as false positives or accepted risk during the Plugin Check review, so CI comes back clean instead of carrying unexplained warnings: - WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound (call sites): PHPCS cannot statically resolve a self::CONST value, but every constant used is already prefixed with "msls_". - WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in (call sites): admin-only or capability-checked, paginated queries where the excluded-ID set comes from TranslatedPostIdQuery, not attacker-controlled input. --------- Co-authored-by: Dennis Ploetner <re@lloc.de>
1 parent e4dd955 commit a4c1209

17 files changed

Lines changed: 31 additions & 36 deletions

File tree

includes/Admin/Admin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public function register(): void {
253253
*
254254
* @since 1.0
255255
*/
256-
do_action( self::MSLS_REGISTER_ACTION, __CLASS__ );
256+
do_action( self::MSLS_REGISTER_ACTION, __CLASS__ ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
257257
}
258258

259259
/**
@@ -357,7 +357,7 @@ protected function add_settings_fields( array $map, string $section ): int {
357357
*
358358
* @since 2.4.4
359359
*/
360-
do_action( self::MSLS_ACTION_PREFIX . $section, __CLASS__, $section );
360+
do_action( self::MSLS_ACTION_PREFIX . $section, __CLASS__, $section ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- MSLS_ACTION_PREFIX is already prefixed with "msls_".
361361

362362
return count( $map );
363363
}

includes/Admin/CustomFilter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public function execute_filter( \WP_Query $query ) {
8686
$sql_cache = SqlCacher::create( __CLASS__, __METHOD__ );
8787

8888
// Load post we need to exclude (they already have a translation) from search query.
89+
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in -- admin-only, paginated post-list screen; the excluded-ID set is bounded by TranslatedPostIdQuery, not attacker-controlled.
8990
$query->query_vars['post__not_in'] = ( new TranslatedPostIdQuery( $sql_cache ) )( $blog->get_language() );
9091

9192
return $query;

includes/Admin/Main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ protected function save( $object_id, $class_name ): void {
148148
*
149149
* @since 0.9.9
150150
*/
151-
do_action( self::MSLS_SAVE_ACTION, $object_id, $class_name );
151+
do_action( self::MSLS_SAVE_ACTION, $object_id, $class_name ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
152152

153153
return;
154154
}

includes/Admin/PostTag/Classic.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function add_input( string $taxonomy ): void {
4040
$this->the_input( null, $title_format, $item_format );
4141
echo '</div>';
4242

43-
do_action( self::MSLS_ADD_INPUT_ACTION, $taxonomy );
43+
do_action( self::MSLS_ADD_INPUT_ACTION, $taxonomy ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
4444
}
4545

4646
/**
@@ -72,7 +72,7 @@ public function edit_input( \WP_Term $tag, string $taxonomy ): void {
7272

7373
$this->the_input( $tag, $title_format, $item_format );
7474

75-
do_action( self::MSLS_EDIT_INPUT_ACTION, $tag, $taxonomy );
75+
do_action( self::MSLS_EDIT_INPUT_ACTION, $tag, $taxonomy ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
7676
}
7777

7878
/**

includes/Admin/PostTag/PostTag.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function add_input( string $taxonomy ): void {
144144
$this->the_input( null, $title_format, $item_format );
145145
echo '</div>';
146146

147-
do_action( self::MSLS_ADD_INPUT_ACTION, $taxonomy );
147+
do_action( self::MSLS_ADD_INPUT_ACTION, $taxonomy ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
148148
}
149149

150150
/**
@@ -179,7 +179,7 @@ public function edit_input( \WP_Term $tag, string $taxonomy ): void {
179179

180180
$this->the_input( $tag, $title_format, $item_format );
181181

182-
do_action( self::MSLS_EDIT_INPUT_ACTION, $tag, $taxonomy );
182+
do_action( self::MSLS_EDIT_INPUT_ACTION, $tag, $taxonomy ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
183183
}
184184

185185
/**

includes/Admin/TranslationPicker/Table.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ public function prepare_items(): void {
179179
'post_status' => array( 'publish', 'draft', 'pending', 'future' ),
180180
'posts_per_page' => $per_page,
181181
'paged' => $current_page,
182+
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in -- admin-only, paginated translation-picker list; excluded-ID set comes from TranslatedPostIdQuery, not attacker-controlled.
182183
'post__not_in' => $translated_ids,
183184
'orderby' => 'date',
184185
'order' => 'DESC',

includes/Blog/Blog.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ protected function get_permalink( OptionsInterface $options ) {
143143
switch_to_blog( $this->obj->userblog_id );
144144

145145
if ( $is_front_page || $options->has_value( $this->get_language() ) ) {
146-
$url = apply_filters( self::MSLS_GET_PERMALINK_HOOK, $options->get_permalink( $this->get_language() ), $this );
146+
$url = apply_filters( self::MSLS_GET_PERMALINK_HOOK, $options->get_permalink( $this->get_language() ), $this ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
147147
} elseif ( $is_posts_page ) {
148148
$page_for_posts = (int) get_option( 'page_for_posts' );
149149
if ( $page_for_posts > 0 ) {
150-
$url = apply_filters( self::MSLS_GET_PERMALINK_HOOK, (string) get_permalink( $page_for_posts ), $this );
150+
$url = apply_filters( self::MSLS_GET_PERMALINK_HOOK, (string) get_permalink( $page_for_posts ), $this ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
151151
}
152152
}
153153

@@ -201,7 +201,7 @@ public static function description( Blog $a, Blog $b ) {
201201
*/
202202
public function get_blavatar(): string {
203203
$blavatar_html = '<div class="blavatar"></div>';
204-
$show_site_icons = apply_filters( self::WP_ADMIN_BAR_SHOW_SITE_ICONS_HOOK, true );
204+
$show_site_icons = apply_filters( self::WP_ADMIN_BAR_SHOW_SITE_ICONS_HOOK, true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- intentionally reuses WordPress core's own "wp_admin_bar_show_site_icons" hook name, not a plugin-specific hook.
205205

206206
switch_to_blog( $this->obj->userblog_id );
207207

includes/Component/Input/Select.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct( string $key, array $arr, ?string $selected = null )
3636
* @return string
3737
*/
3838
public function render(): string {
39-
$name = apply_filters( self::RENDER_FILTER, 'msls[' . $this->key . ']' );
39+
$name = apply_filters( self::RENDER_FILTER, 'msls[' . $this->key . ']' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
4040

4141
return sprintf(
4242
'<select id="%1$s" name="%2$s">%3$s</select>',

includes/ContentImport/ContentImporter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ public function import_content( ImportCoordinates $import_coordinates, array $po
296296
*
297297
* @param ImportCoordinates $import_coordinates
298298
*/
299-
do_action( self::MSLS_BEFORE_IMPORT_ACTION, $import_coordinates );
299+
do_action( self::MSLS_BEFORE_IMPORT_ACTION, $import_coordinates ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
300300

301301
/**
302302
* Filters the data before the import runs.
@@ -357,7 +357,7 @@ public function import_content( ImportCoordinates $import_coordinates, array $po
357357
*
358358
* @since TBD
359359
*/
360-
do_action( self::MSLS_AFTER_IMPORT_ACTION, $import_coordinates, $logger, $relations );
360+
do_action( self::MSLS_AFTER_IMPORT_ACTION, $import_coordinates, $logger, $relations ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
361361

362362
/**
363363
* Filters the data after the import ran.

includes/Frontend/Map/HrefLang.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ public function get( string $language ): string {
6666
*
6767
* @since 0.9.9
6868
*/
69-
return (string) apply_filters( self::MSLS_HEAD_HREFLANG_HOOK, $language );
69+
return (string) apply_filters( self::MSLS_HEAD_HREFLANG_HOOK, $language ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
7070
}
7171
}

0 commit comments

Comments
 (0)