Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions includes/Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function register(): void {
*
* @since 1.0
*/
do_action( self::MSLS_REGISTER_ACTION, __CLASS__ );
do_action( self::MSLS_REGISTER_ACTION, __CLASS__ ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
}

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

return count( $map );
}
Expand Down
1 change: 1 addition & 0 deletions includes/Admin/CustomFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public function execute_filter( \WP_Query $query ) {
$sql_cache = SqlCacher::create( __CLASS__, __METHOD__ );

// Load post we need to exclude (they already have a translation) from search query.
// 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.
$query->query_vars['post__not_in'] = ( new TranslatedPostIdQuery( $sql_cache ) )( $blog->get_language() );

return $query;
Expand Down
2 changes: 1 addition & 1 deletion includes/Admin/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ protected function save( $object_id, $class_name ): void {
*
* @since 0.9.9
*/
do_action( self::MSLS_SAVE_ACTION, $object_id, $class_name );
do_action( self::MSLS_SAVE_ACTION, $object_id, $class_name ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".

return;
}
Expand Down
4 changes: 2 additions & 2 deletions includes/Admin/PostTag/Classic.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function add_input( string $taxonomy ): void {
$this->the_input( null, $title_format, $item_format );
echo '</div>';

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

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

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

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

/**
Expand Down
4 changes: 2 additions & 2 deletions includes/Admin/PostTag/PostTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function add_input( string $taxonomy ): void {
$this->the_input( null, $title_format, $item_format );
echo '</div>';

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

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

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

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

/**
Expand Down
1 change: 1 addition & 0 deletions includes/Admin/TranslationPicker/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public function prepare_items(): void {
'post_status' => array( 'publish', 'draft', 'pending', 'future' ),
'posts_per_page' => $per_page,
'paged' => $current_page,
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in -- admin-only, paginated translation-picker list; excluded-ID set comes from TranslatedPostIdQuery, not attacker-controlled.
'post__not_in' => $translated_ids,
'orderby' => 'date',
'order' => 'DESC',
Expand Down
6 changes: 3 additions & 3 deletions includes/Blog/Blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ protected function get_permalink( OptionsInterface $options ) {
switch_to_blog( $this->obj->userblog_id );

if ( $is_front_page || $options->has_value( $this->get_language() ) ) {
$url = apply_filters( self::MSLS_GET_PERMALINK_HOOK, $options->get_permalink( $this->get_language() ), $this );
$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_".
} elseif ( $is_posts_page ) {
$page_for_posts = (int) get_option( 'page_for_posts' );
if ( $page_for_posts > 0 ) {
$url = apply_filters( self::MSLS_GET_PERMALINK_HOOK, (string) get_permalink( $page_for_posts ), $this );
$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_".
}
}

Expand Down Expand Up @@ -201,7 +201,7 @@ public static function description( Blog $a, Blog $b ) {
*/
public function get_blavatar(): string {
$blavatar_html = '<div class="blavatar"></div>';
$show_site_icons = apply_filters( self::WP_ADMIN_BAR_SHOW_SITE_ICONS_HOOK, true );
$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.

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

Expand Down
2 changes: 1 addition & 1 deletion includes/Component/Input/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct( string $key, array $arr, ?string $selected = null )
* @return string
*/
public function render(): string {
$name = apply_filters( self::RENDER_FILTER, 'msls[' . $this->key . ']' );
$name = apply_filters( self::RENDER_FILTER, 'msls[' . $this->key . ']' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".

return sprintf(
'<select id="%1$s" name="%2$s">%3$s</select>',
Expand Down
4 changes: 2 additions & 2 deletions includes/ContentImport/ContentImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public function import_content( ImportCoordinates $import_coordinates, array $po
*
* @param ImportCoordinates $import_coordinates
*/
do_action( self::MSLS_BEFORE_IMPORT_ACTION, $import_coordinates );
do_action( self::MSLS_BEFORE_IMPORT_ACTION, $import_coordinates ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".

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

/**
* Filters the data after the import ran.
Expand Down
2 changes: 1 addition & 1 deletion includes/Frontend/Map/HrefLang.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ public function get( string $language ): string {
*
* @since 0.9.9
*/
return (string) apply_filters( self::MSLS_HEAD_HREFLANG_HOOK, $language );
return (string) apply_filters( self::MSLS_HEAD_HREFLANG_HOOK, $language ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
}
}
12 changes: 6 additions & 6 deletions includes/Frontend/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function get( ?int $display, bool $filter = false, $exists = false ): arr
*
* @since 0.9.8
*/
$arr[] = (string) apply_filters( self::MSLS_GET_HOOK, $url, $link, $is_current_blog );
$arr[] = (string) apply_filters( self::MSLS_GET_HOOK, $url, $link, $is_current_blog ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
} else {
$arr[] = sprintf(
'<a href="%s" title="%s"%s>%s</a>',
Expand Down Expand Up @@ -127,7 +127,7 @@ public function get_alternate_links() {
$default = '';

foreach ( $blogs->get_objects() as $blog ) {
$url = apply_filters( self::MSLS_ALTERNATE_LINKS_HOOK, $blog->get_url( $options ), $blog );
$url = apply_filters( self::MSLS_ALTERNATE_LINKS_HOOK, $blog->get_url( $options ), $blog ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
if ( empty( $url ) ) {
continue;
}
Expand All @@ -143,10 +143,10 @@ public function get_alternate_links() {
}

if ( 1 === count( $arr ) ) {
return apply_filters( self::MSLS_ALTERNATE_LINKS_DEFAULT_HOOK, $default );
return apply_filters( self::MSLS_ALTERNATE_LINKS_DEFAULT_HOOK, $default ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
}

$arr = (array) apply_filters( self::MSLS_ALTERNATE_LINKS_ARR_HOOK, $arr );
$arr = (array) apply_filters( self::MSLS_ALTERNATE_LINKS_ARR_HOOK, $arr ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".

return implode( PHP_EOL, $arr );
}
Expand All @@ -159,7 +159,7 @@ public function get_alternate_links() {
public function __toString() {
$arr = $this->get( $this->options->display, false, isset( $this->options->only_with_translation ) );
if ( empty( $arr ) ) {
return apply_filters( self::MSLS_NO_TRANSLATION_FOUND_HOOK, '' );
return apply_filters( self::MSLS_NO_TRANSLATION_FOUND_HOOK, '' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
}

$tags = $this->get_tags();
Expand Down Expand Up @@ -190,7 +190,7 @@ public function get_tags(): array {
*
* @since 1.0
*/
$this->tags = (array) apply_filters( self::MSLS_GET_TAGS_HOOK, $this->tags );
$this->tags = (array) apply_filters( self::MSLS_GET_TAGS_HOOK, $this->tags ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
}

return $this->tags;
Expand Down
2 changes: 1 addition & 1 deletion includes/Frontend/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function widget( $args, $instance ) {
$content = msls_output()->__toString();
if ( '' === $content ) {
$text = __( 'No available translations found', 'multisite-language-switcher' );
$content = apply_filters( self::MSLS_ALTERNATIVE_CONTENT_HOOK, $text );
$content = apply_filters( self::MSLS_ALTERNATIVE_CONTENT_HOOK, $text ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
}

echo wp_kses(
Expand Down
2 changes: 1 addition & 1 deletion includes/Options/Post/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function get_postlink( $language ) {

$post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', Options::MSLS_GET_POSTLINK_HOOK );

return apply_filters( Options::MSLS_GET_POSTLINK_HOOK, $post_link, $this );
return apply_filters( Options::MSLS_GET_POSTLINK_HOOK, $post_link, $this ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/Options/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function get_postlink( $language ) {
if ( ! empty( $post_link ) ) {
$post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', Options::MSLS_GET_POSTLINK_HOOK );

return apply_filters( Options::MSLS_GET_POSTLINK_HOOK, $post_link, $this );
return apply_filters( Options::MSLS_GET_POSTLINK_HOOK, $post_link, $this ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
}
}

Expand Down
2 changes: 1 addition & 1 deletion includes/Options/Tax/Tax.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function get_postlink( $language ) {

$post_link = apply_filters_deprecated( 'check_url', array( $post_link, $this ), '2.7.1', Options::MSLS_GET_POSTLINK_HOOK );

return apply_filters( Options::MSLS_GET_POSTLINK_HOOK, $post_link, $this );
return apply_filters( Options::MSLS_GET_POSTLINK_HOOK, $post_link, $this ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound -- constant value is already prefixed with "msls_".
}

public function get_permalink( string $language ): string {
Expand Down
16 changes: 4 additions & 12 deletions includes/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ class Plugin {

/**
* Injected Options object
*
* @var Options
*/
protected Options $options;

/**
* MslsPlugin constructor.
*
* @param Options $options Options object.
*/
public function __construct( Options $options ) {
$this->options = $options;
Expand All @@ -52,8 +56,6 @@ public function __construct( Options $options ) {
public static function init(): void {
$obj = new self( msls_options() );

add_action( 'init', array( $obj, 'init_i18n_support' ) );

register_activation_hook( self::file(), array( __CLASS__, 'activate' ) );

if ( function_exists( 'is_multisite' ) && is_multisite() ) {
Expand Down Expand Up @@ -194,16 +196,6 @@ public static function path(): string {
return defined( 'MSLS_PLUGIN_PATH' ) ? constant( 'MSLS_PLUGIN_PATH' ) : '';
}

/**
* Loads the translation files for the plugin from the bundled /languages/ directory.
*
* Required because the plugin ships its own .mo files; WordPress only auto-loads
* translations served from wordpress.org's language packs.
*/
public function init_i18n_support(): void {
load_plugin_textdomain( 'multisite-language-switcher', false, self::dirname( '/languages/' ) );
}

/**
* Message handler
*
Expand Down
1 change: 1 addition & 0 deletions includes/RestApi/RestApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ public function list_untranslated_posts( \WP_REST_Request $request ) {
'post_type' => $post_type,
'post_status' => self::UNTRANSLATED_POST_STATUSES,
'numberposts' => self::UNTRANSLATED_POSTS_LIMIT,
// phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in -- capability-checked REST route, bounded by UNTRANSLATED_POSTS_LIMIT; excluded-ID set comes from TranslatedPostIdQuery, not attacker-controlled.
'post__not_in' => $translated_ids,
'suppress_filters' => false,
'orderby' => 'date',
Expand Down