C:\xampp\htdocs\landing\wp-content\plugins\js_composer\include\autoload\bc-access-rules-4.8.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php
if ( ! defined'ABSPATH' ) ) {
    die( 
'-1' );
}
// Part BC: Post types
// =========================

/**
 * @param $state
 * @return bool|string
 */
function vc_bc_access_rule_48_post_type_get_state$state ) {
    if ( 
null === $state ) {
        
$content_types vc_settings()->get'content_types' );
        if ( empty( 
$content_types ) ) {
            
$state true;
        } else {
            
$state 'custom';
        }
    }

    return 
$state;
}

/**
 * @param $value
 * @param $role
 * @param $rule
 * @return bool
 * @throws \Exception
 */
function vc_bc_access_rule_48_post_type_rule$value$role$rule ) {
    if ( ! 
$role ) {
        return 
$value;
    }
    global 
$vc_bc_access_rule_48_editor_post_types;
    
$part vc_role_access()->who$role->name )->part'post_types' );
    if ( ! isset( 
$part->getRole()->capabilities$part->getStateKey() ] ) ) {
        if ( 
is_null$vc_bc_access_rule_48_editor_post_types ) ) {
            
$pt_array vc_settings()->get'content_types' );
            
$vc_bc_access_rule_48_editor_post_types $pt_array $pt_array vc_default_editor_post_types();
        }

        return 
in_array$rule$vc_bc_access_rule_48_editor_post_typestrue );
    }

    return 
$value;
}

// Part BC: shortcodes
// =========================

/**
 * @param $state
 * @param $role
 * @return bool|string
 */
function vc_bc_access_rule_48_shortcodes_get_state$state$role ) {
    if ( ! 
$role ) {
        return 
$state;
    }
    if ( 
null === $state ) {
        
$group_access_settings vc_settings()->get'groups_access_rules' );
        if ( ! isset( 
$group_access_settings$role->name ]['shortcodes'] ) ) {
            
$state true;
        } else {
            
$state 'custom';
        }
    }

    return 
$state;
}

/**
 * @param $value
 * @param $role
 * @param $rule
 * @return bool
 * @throws \Exception
 */
function vc_bc_access_rule_48_shortcodes_rule$value$role$rule ) {
    if ( ! 
$role ) {
        return 
$value;
    }
    if ( ! 
vc_bc_access_get_shortcodes_state_is_set$role ) ) {
        if ( 
preg_match'/_edit$/'$rule ) ) {
            return 
false;
        }
        
$group_access_settings vc_settings()->get'groups_access_rules' );
        if ( isset( 
$group_access_settings$role->name ]['shortcodes'] ) && ! empty( $group_access_settings$role->name ]['shortcodes'] ) ) {
            
$rule preg_replace'/_all$/'''$rule );

            return 
'vc_row' === $rule || ( isset( $group_access_settings$role->name ]['shortcodes'][ $rule ] ) && === (int) $group_access_settings$role->name ]['shortcodes'][ $rule ] );
        } else {
            return 
true;
        }
    }

    return 
$value;
}

/**
 * Check is state set
 *
 * @param $role
 *
 * @return bool
 * @throws \Exception
 */
function vc_bc_access_get_shortcodes_state_is_set$role ) {
    if ( ! 
$role ) {
        return 
false;
    }
    
$part vc_role_access()->who$role->name )->part'shortcodes' );

    return isset( 
$part->getRole()->capabilities$part->getStateKey() ] );
}

// Part BC: backened editor
// ===========================
/**
 * @param $state
 * @param $role
 * @return bool|string
 */
function vc_bc_access_rule_48_backend_editor_get_state$state$role ) {
    if ( ! 
$role ) {
        return 
$state;
    }
    if ( 
null === $state ) {
        
$group_access_settings vc_settings()->get'groups_access_rules' );
        if ( ! isset( 
$group_access_settings$role->name ]['show'] ) || 'all' === $group_access_settings$role->name ]['show'] ) {
            
$state true;
        } elseif ( 
'no' === $group_access_settings$role->name ]['show'] ) {
            
$state false;
        } else {
            
$state 'default';
        }
    }

    return 
$state;
}

/**
 * @param $state
 * @param $role
 * @return bool
 */
function vc_bc_access_rule_48_frontend_editor_get_state$state$role ) {
    if ( ! 
$role ) {
        return 
$state;
    }
    if ( 
null === $state ) {
        
$group_access_settings vc_settings()->get'groups_access_rules' );

        if ( isset( 
$group_access_settings$role->name ]['show'] ) && 'no' === $group_access_settings$role->name ]['show'] ) {
            
$state false;
        } else {
            
$state true;
        }
    }

    return 
$state;
}

/**
 * @param $value
 * @param $role
 * @return bool
 * @throws \Exception
 */
function vc_bc_access_rule_48_backend_editor_can_disabled_ce_editor_rule$value$role ) {
    if ( ! 
$role ) {
        return 
$value;
    }
    
$part vc_role_access()->who$role->name )->part'backend_editor' );
    if ( ! isset( 
$part->getRole()->capabilities$part->getStateKey() ] ) ) {
        
$group_access_settings vc_settings()->get'groups_access_rules' );

        return isset( 
$group_access_settings$role->name ]['show'] ) && 'only' === $group_access_settings$role->name ]['show'];
    }

    return 
$value;
}

/**
 * @param $role
 * @return mixed
 * @throws \Exception
 */
function vc_bc_access_rule_48_backend_editor_add_cap_disabled_ce_editor$role ) {
    if ( ! 
$role ) {
        return 
$role;
    }
    
$part vc_role_access()->who$role->name )->part'backend_editor' );
    if ( ! isset( 
$part->getRole()->capabilities$part->getStateKey() ] ) ) {
        
$group_access_settings vc_settings()->get'groups_access_rules' );
        if ( isset( 
$group_access_settings$role->name ]['show'] ) && 'only' === $group_access_settings$role->name ]['show'] ) {
            
$role->capabilities$part->getStateKey() . '/disabled_ce_editor' ] = true;
        }
    }

    return 
$role;
}

function 
vc_bc_access_rule_48() {
    
add_filter'vc_role_access_with_post_types_get_state''vc_bc_access_rule_48_post_type_get_state' );
    
add_filter'vc_role_access_with_post_types_can''vc_bc_access_rule_48_post_type_rule'10);

    
add_filter'vc_role_access_with_shortcodes_get_state''vc_bc_access_rule_48_shortcodes_get_state'10);
    
add_filter'vc_role_access_with_shortcodes_can''vc_bc_access_rule_48_shortcodes_rule'10);

    
add_filter'vc_role_access_with_backend_editor_get_state''vc_bc_access_rule_48_backend_editor_get_state'10);
    
add_filter'vc_role_access_with_backend_editor_can_disabled_ce_editor''vc_bc_access_rule_48_backend_editor_can_disabled_ce_editor_rule'10);

    
add_filter'vc_role_access_with_frontend_editor_get_state''vc_bc_access_rule_48_frontend_editor_get_state'10);

    
add_filter'vc_role_access_all_caps_role''vc_bc_access_rule_48_backend_editor_add_cap_disabled_ce_editor' );
}

// BC function for shortcode
add_action'vc_before_init''vc_bc_access_rule_48' );
x

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