Skip to content
Merged
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
12 changes: 10 additions & 2 deletions inc/objects/class-limitations.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,17 @@ protected function merge_recursive(array &$array1, array &$array2, $should_sum =
} elseif (isset($array1[ $key ]) && is_numeric($array1[ $key ]) && is_numeric($value) && $should_sum && ! $is_unlimited) {
$array1[ $key ] = ((int) $array1[ $key ]) + $value;
} elseif ('visibility' === $key && isset($array1[ $key ]) && $should_sum) {
/*
* Hidden takes priority over visible: if any source restricts
* visibility to 'hidden', the item must be hidden. A product or
* membership that marks a plugin/theme as hidden should always
* override a default of 'visible'.
*
* Priority: hidden (1) > visible (0)
*/
$key_priority = [
'hidden' => 0,
'visible' => 1,
'visible' => 0,
'hidden' => 1,
];

$array1[ $key ] = $key_priority[ $value ] > $key_priority[ $array1[ $key ] ] ? $value : $array1[ $key ];
Expand Down
4 changes: 2 additions & 2 deletions tests/WP_Ultimo/Managers/Limitation_Manager_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use WP_Ultimo\Models\Site;
use WP_Ultimo\Database\Sites\Site_Type;

class Limitation_Manager_Test extends \WP_UnitTestCase {

Check warning on line 18 in tests/WP_Ultimo/Managers/Limitation_Manager_Test.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Missing doc comment for class Limitation_Manager_Test

use Manager_Test_Trait;

Expand All @@ -29,28 +29,28 @@
*/
protected function create_test_customer(): Customer {

$user_id = self::factory()->user->create([

Check warning on line 32 in tests/WP_Ultimo/Managers/Limitation_Manager_Test.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Opening parenthesis of a multi-line function call must be the last content on the line
'role' => 'subscriber',
]);

Check warning on line 34 in tests/WP_Ultimo/Managers/Limitation_Manager_Test.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Closing parenthesis of a multi-line function call must be on a line by itself

$customer = new Customer([

Check warning on line 36 in tests/WP_Ultimo/Managers/Limitation_Manager_Test.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Opening parenthesis of a multi-line function call must be the last content on the line
'user_id' => $user_id,
]);

Check warning on line 38 in tests/WP_Ultimo/Managers/Limitation_Manager_Test.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Closing parenthesis of a multi-line function call must be on a line by itself
$customer->set_skip_validation(true);
$customer->save();

return $customer;
}

protected function get_manager_class(): string {

Check warning on line 45 in tests/WP_Ultimo/Managers/Limitation_Manager_Test.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Missing doc comment for function get_manager_class()
return Limitation_Manager::class;
}

protected function get_expected_slug(): ?string {

Check warning on line 49 in tests/WP_Ultimo/Managers/Limitation_Manager_Test.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Missing doc comment for function get_expected_slug()
return null;
}

protected function get_expected_model_class(): ?string {

Check warning on line 53 in tests/WP_Ultimo/Managers/Limitation_Manager_Test.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Missing doc comment for function get_expected_model_class()
return null;
}

Expand Down Expand Up @@ -139,7 +139,7 @@

$manager = $this->get_manager_instance();

add_filter('wu_limitations_get_object_type', function ($model, $object_model) {

Check warning on line 142 in tests/WP_Ultimo/Managers/Limitation_Manager_Test.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Only one argument is allowed per line in a multi-line function call

Check warning on line 142 in tests/WP_Ultimo/Managers/Limitation_Manager_Test.php

View workflow job for this annotation

GitHub Actions / Code Quality Checks

Opening parenthesis of a multi-line function call must be the last content on the line
if ($object_model instanceof \stdClass) {
return 'custom_type';
}
Expand Down Expand Up @@ -1791,8 +1791,8 @@
$merged = $base->merge($override_data);

$plugin = $merged->plugins->{'akismet/akismet.php'};
// visible has higher priority than hidden
$this->assertEquals('visible', $plugin->visibility);
// hidden has higher priority than visible — restrictions take precedence (fix for issue #234)
$this->assertEquals('hidden', $plugin->visibility);
}

// ---------------------------------------------------------------
Expand Down
Loading
Loading