Skip to content

Commit

Permalink
Require WordPress 6.2 or later (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy authored Feb 27, 2024
1 parent 4e268ee commit 934a4b3
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 13 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/lint-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ jobs:
wp: 'trunk'
experimental: true

- php: '7.4'
wp: '6.2'
experimental: false

- php: '8.3'
wp: 'trunk'
experimental: true
Expand Down
3 changes: 1 addition & 2 deletions inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ function preferred_languages_get_locale_switcher_user_id() {
/* @var WP_Locale_Switcher $wp_locale_switcher */
global $wp_locale_switcher;

return $wp_locale_switcher instanceof WP_Locale_Switcher &&
method_exists( $wp_locale_switcher, 'get_switched_user_id' ) ?
return $wp_locale_switcher instanceof WP_Locale_Switcher ?
$wp_locale_switcher->get_switched_user_id() : false;
}

Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ parameters:
ignoreErrors:
- message: '/^Call to private\/internal function preferred_languages_load_just_in_time\(\)\.$/'
- message: '/has no return type specified\.$/'
# See https://github.com/swissspidy/preferred-languages/issues/962.
- message: '/^Call to function method_exists\(\) with WP_Locale_Switcher and .get_switched_user_id. will always evaluate to true\.$/'
- message: '/^Call to method PHPUnit\\Framework\\Assert::assertFalse\(\) with false will always evaluate to true\.$/'
- message: '/^Cannot access offset 1 on mixed\.$/'
- message: '/^Cannot access offset .messages. on mixed\.$/'
Expand Down
2 changes: 1 addition & 1 deletion preferred-languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: preferred-languages
* Requires at least: 6.1
* Requires at least: 6.2
* Requires PHP: 7.0
*
* Copyright (c) 2017 Pascal Birchler (email: swissspidy@chat.wordpress.org)
Expand Down
8 changes: 0 additions & 8 deletions tests/phpunit/tests/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@ public function test_get_locale_switcher_user_id_default() {
* @covers ::preferred_languages_get_locale_switcher_user_id
*/
public function test_get_locale_switcher_user_id_switched() {
if ( ! function_exists( 'switch_to_user_locale' ) ) {
$this->markTestSkipped( 'This test requires WordPress 6.2 and switch_to_user_locale() to be available' );
}

update_user_meta( self::$administrator, 'locale', 'de_DE' );

switch_to_user_locale( self::$administrator );
Expand Down Expand Up @@ -401,10 +397,6 @@ public function test_get_list_admin_fallback() {
* @covers ::preferred_languages_get_list
*/
public function test_get_list_user_locale_switching() {
if ( ! function_exists( 'switch_to_user_locale' ) ) {
$this->markTestSkipped( 'This test requires WordPress 6.2 and switch_to_user_locale() to be available' );
}

update_user_meta( self::$administrator, 'preferred_languages', 'de_DE,es_ES' );

switch_to_user_locale( self::$administrator );
Expand Down

0 comments on commit 934a4b3

Please sign in to comment.