C:\xampp\htdocs\landing\wp-content\plugins\better-wp-security\core\modules\user-groups\Upgrader.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php

namespace iThemesSecurity\User_Groups;

use 
iThemesSecurity\User_Groups\Module\Settings;
use 
iThemesSecurity\User_Groups\Repository\Repository;
use 
ITSEC_Lib_Canonical_Roles;

final class 
Upgrader {

    
/** @var Repository */
    
private $user_groups;

    
/** @var Settings */
    
private $settings;

    
/**
     * Upgrader constructor.
     *
     * @param Repository $user_groups
     * @param Settings   $settings
     */
    
public function __constructRepository $user_groupsSettings $settings ) {
        
$this->user_groups $user_groups;
        
$this->settings    $settings;
    }

    
/**
     * Upgrade an existing setting to a user group.
     *
     * @param string   $label     Label to give the user group if a new one has to be created.
     * @param callable $configure Callable to configure the user group.
     *
     * @return User_Group Either the newly created user group, or an existing user group that was an exact match.
     */
    
public function find_or_create$label, callable $configure ) {
        
$user_group = new User_Group$this->user_groups->next_id() );
        
$configure$user_group );

        foreach ( 
$this->user_groups->all() as $maybe_group ) {
            if ( 
$maybe_group->equals$user_group ) ) {
                return 
$maybe_group;
            }
        }

        
$user_group->set_label$label );
        
$this->user_groups->persist$user_group, [] );

        return 
$user_group;
    }

    
/**
     * Upgrade a min role based setting to a group based setting.
     *
     * @param string $min_role The minimum canonical role.
     *
     * @return string[] The list of user group IDs to store.
     */
    
public function upgrade_from_min_role$min_role ) {
        
$groups = [];

        foreach ( 
ITSEC_Lib_Canonical_Roles::get_canonical_roles_of_at_least$min_role ) as $role ) {
            if ( 
'super-admin' === $role ) {
                continue;
            }

            
$groups[] = $this->settings->get_default_group_id$roletrue );
        }

        if ( 
'subscriber' === $min_role ) {
            
$groups[] = 'everybody-else';
        }

        return 
$groups;
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586