admin-toolbar-mode.php
1 year ago
api-route-mode.php
1 year ago
backend-menu-mode.php
1 year ago
content-access-form.php
1 year ago
content-service-tips.php
1 year ago
default-subject-tab.php
1 year ago
jwt-login-url.php
1 year ago
loading-content.php
1 year ago
login-form.php
1 year ago
multisite-sync-notification.php
1 year ago
post-list.php
1 year ago
visitor-subject-tab.php
1 year ago
content-access-form.php
433 lines
| 1 | <?php /** @version 7.0.0 */ ?> |
| 2 | |
| 3 | <?php if (defined('AAM_KEY')) { ?> |
| 4 | <?php |
| 5 | $params = isset($params) ? $params : (object) []; |
| 6 | $resource = $params->resource; |
| 7 | $permission_scope = []; // Additional attributes to add |
| 8 | |
| 9 | if ($resource->type === AAM_Framework_Type_Resource::TERM) { |
| 10 | $permission_scope['taxonomy'] = $params->resource_identifier->taxonomy; |
| 11 | |
| 12 | if (!empty($params->resource_identifier->post_type)) { |
| 13 | $permission_scope['post_type'] = $params->resource_identifier->post_type; |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | $id = $params->resource_id; |
| 18 | ?> |
| 19 | |
| 20 | <div class="aam-overwrite<?php echo $resource->is_customized($params->resource_identifier) ? '' : ' hidden'; ?>"> |
| 21 | <span> |
| 22 | <i class="icon-check"></i> |
| 23 | <?php echo __('Settings are customized', 'advanced-access-manager'); ?> |
| 24 | </span> |
| 25 | <span> |
| 26 | <a |
| 27 | href="#" |
| 28 | id="content_reset" |
| 29 | class="btn btn-xs btn-primary" |
| 30 | ><?php echo __('Reset to default', 'advanced-access-manager'); ?></a> |
| 31 | </span> |
| 32 | </div> |
| 33 | |
| 34 | <input |
| 35 | type="hidden" |
| 36 | value="<?php echo esc_attr($resource->type); ?>" |
| 37 | id="content_resource_type" |
| 38 | /> |
| 39 | <input |
| 40 | type="hidden" |
| 41 | value="<?php echo esc_attr($id); ?>" |
| 42 | id="content_resource_id" |
| 43 | /> |
| 44 | <input |
| 45 | type="hidden" |
| 46 | value="<?php echo esc_attr(json_encode($permission_scope)); ?>" |
| 47 | id="content_permission_scope" |
| 48 | /> |
| 49 | <div id="content_resource_settings" class="hidden"><?php echo json_encode($resource->get_permissions($params->resource_identifier)); ?></div> |
| 50 | |
| 51 | <table class="table table-striped table-bordered" id="permission_toggles"> |
| 52 | <tbody> |
| 53 | <?php if (count($params->access_controls) > 0) { ?> |
| 54 | <?php foreach ($params->access_controls as $control => $settings) { ?> |
| 55 | <tr> |
| 56 | <td> |
| 57 | <strong class="aam-block aam-highlight text-uppercase"><?php echo esc_js($settings['title']); ?></strong> |
| 58 | <?php if (!empty($settings['customize'])) { ?> |
| 59 | <small class="aam-small-highlighted"> |
| 60 | <?php echo esc_js($settings['customize']); ?>: |
| 61 | <a |
| 62 | href="#<?php echo esc_attr($settings['modal']); ?>" |
| 63 | data-toggle="modal" |
| 64 | class="advanced-post-option" |
| 65 | ><?php echo __('customize', 'advanced-access-manager'); ?></a> |
| 66 | </small> |
| 67 | <?php } ?> |
| 68 | |
| 69 | <?php if (AAM::api()->config->get('core.settings.ui.tips')) { ?> |
| 70 | <p class="aam-hint"> |
| 71 | <?php echo esc_js($settings['description']); ?> |
| 72 | </p> |
| 73 | <?php } ?> |
| 74 | </td> |
| 75 | <td class="text-center"> |
| 76 | <input |
| 77 | data-toggle="toggle" |
| 78 | id="access_control_<?php echo esc_attr($control); ?>" |
| 79 | type="checkbox" |
| 80 | <?php echo ($settings['is_denied'] ? 'checked' : ''); ?> |
| 81 | data-permission="<?php echo esc_attr($control); ?>" |
| 82 | data-on="<?php echo __('Deny', 'advanced-access-manager'); ?>" |
| 83 | data-off="<?php echo __('Allow', 'advanced-access-manager'); ?>" |
| 84 | data-size="small" |
| 85 | data-onstyle="danger" |
| 86 | data-offstyle="success" |
| 87 | /> |
| 88 | </td> |
| 89 | </tr> |
| 90 | <?php } ?> |
| 91 | <?php } else { ?> |
| 92 | <div class="row"> |
| 93 | <div class="col-xs-12"> |
| 94 | <p class="aam-notification"> |
| 95 | <?php |
| 96 | if ($resource->type === AAM_Framework_Type_Resource::POST_TYPE) { |
| 97 | $resource_type = __('post type', 'advanced-access-manager'); |
| 98 | $resource_name = $params->resource_identifier->label; |
| 99 | } elseif ($resource->type === AAM_Framework_Type_Resource::TAXONOMY) { |
| 100 | $resource_type = __('taxonomy', 'advanced-access-manager'); |
| 101 | $resource_name = $params->resource_identifier->label; |
| 102 | } elseif ($resource->type === AAM_Framework_Type_Resource::TERM) { |
| 103 | $resource_type = __('term', 'advanced-access-manager'); |
| 104 | $resource_name = $params->resource_identifier->name; |
| 105 | } |
| 106 | |
| 107 | echo sprintf( |
| 108 | __('Upgrade to our %spremium add-on%s in order to be able to manage access controls for the %s %s.', 'advanced-access-manager'), |
| 109 | '<a href="https://aamportal.com/premium?ref=plugin" target="_blank">', |
| 110 | '</a>', |
| 111 | $resource_type, |
| 112 | $resource_name |
| 113 | ); |
| 114 | ?> |
| 115 | </p> |
| 116 | </div> |
| 117 | </div> |
| 118 | <?php } ?> |
| 119 | </tbody> |
| 120 | </table> |
| 121 | |
| 122 | <?php if (!empty($params->access_controls['list'])) { ?> |
| 123 | <div class="modal fade" data-backdrop="false" id="modal_content_visibility" tabindex="-1" role="dialog"> |
| 124 | <div class="modal-dialog" role="document"> |
| 125 | <div class="modal-content"> |
| 126 | <div class="modal-header"> |
| 127 | <button |
| 128 | type="button" |
| 129 | class="close" |
| 130 | data-dismiss="modal" |
| 131 | aria-label="<?php echo __('Close', 'advanced-access-manager'); ?>" |
| 132 | ><span aria-hidden="true">×</span></button> |
| 133 | <h4 class="modal-title"><?php echo __('Customize Visibility', 'advanced-access-manager'); ?></h4> |
| 134 | </div> |
| 135 | <div class="modal-body"> |
| 136 | <?php if (AAM::api()->config->get('core.settings.ui.tips')) { ?> |
| 137 | <p class="aam-info"> |
| 138 | <?php echo $params->access_controls['list']['tooltip']; ?> |
| 139 | </p> |
| 140 | <?php } ?> |
| 141 | |
| 142 | <table class="table table-striped table-bordered"> |
| 143 | <tbody> |
| 144 | <tr> |
| 145 | <td> |
| 146 | <span class='aam-setting-title'><?php echo __('Frontend', 'advanced-access-manager'); ?></span> |
| 147 | <p class="aam-setting-description"> |
| 148 | <?php echo esc_js($params->access_controls['list']['on']['frontend']); ?> |
| 149 | </p> |
| 150 | </td> |
| 151 | <td class="text-center"> |
| 152 | <input |
| 153 | data-toggle="toggle" |
| 154 | name="frontend" |
| 155 | id="hidden_frontend" |
| 156 | type="checkbox" |
| 157 | <?php echo ($params->access_controls['list']['is_denied'] && in_array('frontend', $params->access_controls['list']['areas']) ? 'checked' : ''); ?> |
| 158 | data-on="<?php echo __('Hidden', 'advanced-access-manager'); ?>" |
| 159 | data-off="<?php echo __('Visible', 'advanced-access-manager'); ?>" |
| 160 | data-size="small" |
| 161 | data-onstyle="danger" |
| 162 | data-offstyle="success" |
| 163 | /> |
| 164 | </td> |
| 165 | </tr> |
| 166 | <?php if (!$params->access_level->is_visitor()) { ?> |
| 167 | <tr> |
| 168 | <td> |
| 169 | <span class='aam-setting-title'><?php echo __('Backend', 'advanced-access-manager'); ?></span> |
| 170 | <p class="aam-setting-description"> |
| 171 | <?php echo esc_js($params->access_controls['list']['on']['backend']); ?> |
| 172 | </p> |
| 173 | </td> |
| 174 | <td class="text-center"> |
| 175 | <input |
| 176 | data-toggle="toggle" |
| 177 | name="backend" |
| 178 | id="hidden_backend" |
| 179 | type="checkbox" |
| 180 | <?php echo ($params->access_controls['list']['is_denied'] && in_array('backend', $params->access_controls['list']['areas']) ? 'checked' : ''); ?> |
| 181 | data-on="<?php echo __('Hidden', 'advanced-access-manager'); ?>" |
| 182 | data-off="<?php echo __('Visible', 'advanced-access-manager'); ?>" |
| 183 | data-size="small" |
| 184 | data-onstyle="danger" |
| 185 | data-offstyle="success" |
| 186 | /> |
| 187 | </td> |
| 188 | </tr> |
| 189 | <?php } ?> |
| 190 | <tr> |
| 191 | <td> |
| 192 | <span class='aam-setting-title'><?php echo __('RESTful API', 'advanced-access-manager'); ?></span> |
| 193 | <p class="aam-setting-description"> |
| 194 | <?php echo esc_js($params->access_controls['list']['on']['api']); ?> |
| 195 | </p> |
| 196 | </td> |
| 197 | <td class="text-center"> |
| 198 | <input |
| 199 | data-toggle="toggle" |
| 200 | name="api" |
| 201 | id="hidden_api" |
| 202 | type="checkbox" |
| 203 | <?php echo ($params->access_controls['list']['is_denied'] && in_array('api', $params->access_controls['list']['areas']) ? 'checked' : ''); ?> |
| 204 | data-on="<?php echo __('Hidden', 'advanced-access-manager'); ?>" |
| 205 | data-off="<?php echo __('Visible', 'advanced-access-manager'); ?>" |
| 206 | data-size="small" |
| 207 | data-onstyle="danger" |
| 208 | data-offstyle="success" |
| 209 | /> |
| 210 | </td> |
| 211 | </tr> |
| 212 | </tbody> |
| 213 | </table> |
| 214 | |
| 215 | <?php do_action('aam_ui_content_access_form_visibility_action', $params); ?> |
| 216 | </div> |
| 217 | <div class="modal-footer"> |
| 218 | <button |
| 219 | type="button" |
| 220 | class="btn btn-success btn-save" |
| 221 | id="save_list_permission" |
| 222 | ><?php echo __('Save', 'advanced-access-manager'); ?></button> |
| 223 | <button |
| 224 | type="button" |
| 225 | class="btn btn-default" |
| 226 | data-dismiss="modal" |
| 227 | ><?php echo __('Close', 'advanced-access-manager'); ?></button> |
| 228 | </div> |
| 229 | </div> |
| 230 | </div> |
| 231 | </div> |
| 232 | <?php } ?> |
| 233 | |
| 234 | <?php if (!empty($params->access_controls['read'])) { ?> |
| 235 | <div class="modal fade" data-backdrop="false" id="modal_content_restriction" tabindex="-1" role="dialog"> |
| 236 | <div class="modal-dialog" role="document"> |
| 237 | <div class="modal-content"> |
| 238 | <div class="modal-header"> |
| 239 | <button |
| 240 | type="button" |
| 241 | class="close" |
| 242 | data-dismiss="modal" |
| 243 | aria-label="<?php echo __('Close', 'advanced-access-manager'); ?>" |
| 244 | ><span aria-hidden="true">×</span></button> |
| 245 | <h4 class="modal-title"><?php echo __('Customize Restriction', 'advanced-access-manager'); ?></h4> |
| 246 | </div> |
| 247 | <div class="modal-body"> |
| 248 | <?php if (AAM::api()->config->get('core.settings.ui.tips')) { ?> |
| 249 | <p class="aam-info"> |
| 250 | <?php echo $params->access_controls['read']['tooltip']; ?> |
| 251 | </p> |
| 252 | <?php } ?> |
| 253 | |
| 254 | <?php |
| 255 | $restriction_settings = $resource->get_permission($params->resource_identifier, 'read'); |
| 256 | $restriction_type = isset($restriction_settings['restriction_type']) ? $restriction_settings['restriction_type'] : 'default'; |
| 257 | $restriction_types = apply_filters('aam_ui_content_restriction_types_filter', [ |
| 258 | 'default' => [ |
| 259 | 'title' => __('Restrict direct access', 'advanced-access-manager') |
| 260 | ], |
| 261 | 'teaser_message' => [ |
| 262 | 'title' => __('Show a teaser message instead of the content', 'advanced-access-manager') |
| 263 | ], |
| 264 | 'redirect' => [ |
| 265 | 'title' => __('Redirect to a different location', 'advanced-access-manager') |
| 266 | ], |
| 267 | 'password_protected' => [ |
| 268 | 'title' => __('Protect access with a password', 'advanced-access-manager') |
| 269 | ], |
| 270 | 'expire' => [ |
| 271 | 'title' => __('Deny direct access after defined date/time', 'advanced-access-manager') |
| 272 | ], |
| 273 | ], $resource); |
| 274 | ?> |
| 275 | <div id="restriction_types"> |
| 276 | <?php foreach($restriction_types as $type => $settings) { ?> |
| 277 | <div class="radio red"> |
| 278 | <input |
| 279 | type="radio" |
| 280 | name="content_restriction_type" |
| 281 | id="content_restriction_type_<?php echo esc_attr($type); ?>" |
| 282 | value="<?php echo esc_attr($type); ?>" |
| 283 | <?php echo ($restriction_type === $type ? 'checked' : ''); ?> |
| 284 | /> |
| 285 | <label for="content_restriction_type_<?php echo $type; ?>"> |
| 286 | <?php echo esc_js($settings['title']); ?> |
| 287 | </label> |
| 288 | </div> |
| 289 | <?php } ?> |
| 290 | </div> |
| 291 | |
| 292 | <div id="restriction_type_extra"> |
| 293 | <div data-type="teaser_message" class="<?php echo $restriction_type !== 'teaser_message' ? 'hidden' : ''; ?>"> |
| 294 | <hr /> |
| 295 | |
| 296 | <div class="form-group"> |
| 297 | <label><?php echo __('Plain text or valid HTML', 'advanced-access-manager'); ?></label> |
| 298 | <textarea |
| 299 | class="form-control" |
| 300 | placeholder="<?php echo __('Enter your teaser message...', 'advanced-access-manager'); ?>" |
| 301 | rows="5" |
| 302 | id="aam_teaser_message" |
| 303 | ><?php echo esc_textarea(isset($restriction_settings['message']) ? $restriction_settings['message'] : ''); ?></textarea> |
| 304 | <span class="hint text-muted"><?php echo AAM_Backend_View_Helper::preparePhrase('Use [[excerpt]] shortcode to insert post excerpt to the teaser message.', 'strong'); ?></span> |
| 305 | </div> |
| 306 | </div> |
| 307 | |
| 308 | <div data-type="redirect" class="<?php echo $restriction_type !== 'redirect' ? 'hidden' : ''; ?>"> |
| 309 | <?php $redirect_type = isset($restriction_settings['redirect']['type']) ? $restriction_settings['redirect']['type'] : 'default'; ?> |
| 310 | |
| 311 | <?php |
| 312 | $redirect_types = [ |
| 313 | 'page_redirect' => __('Redirected to existing page (select from the drop-down)', 'advanced-access-manager'), |
| 314 | 'url_redirect' => __('Redirected to the URL (enter full URL starting from http or https)', 'advanced-access-manager'), |
| 315 | 'trigger_callback' => __('Trigger PHP callback function (valid PHP callback is required)', 'advanced-access-manager') |
| 316 | ]; |
| 317 | |
| 318 | if ($params->access_level->is_visitor()) { |
| 319 | $redirect_types['login_redirect'] = __('Redirect to the login page (after login, user will be redirected back to the restricted page)', 'advanced-access-manager'); |
| 320 | } |
| 321 | ?> |
| 322 | |
| 323 | <hr /> |
| 324 | |
| 325 | <div class="form-group"> |
| 326 | <label><?php echo __('Select Redirect Type', 'advanced-access-manager'); ?></label> |
| 327 | <select class="form-control" id="restricted_redirect_type"> |
| 328 | <option value=""><?php echo __('-- Redirect Type --', 'advanced-access-manager'); ?></option> |
| 329 | <?php foreach($redirect_types as $type => $label) { ?> |
| 330 | <option |
| 331 | value="<?php echo $type; ?>" |
| 332 | <?php echo $type === $redirect_type ? 'selected' : ''; ?> |
| 333 | ><?php echo $label; ?></option> |
| 334 | <?php } ?> |
| 335 | </select> |
| 336 | |
| 337 | <div |
| 338 | class="form-group aam-mt-2 restricted-redirect-type<?php echo ($redirect_type === 'page_redirect' ? '' : ' hidden'); ?>" |
| 339 | data-type="page_redirect" |
| 340 | > |
| 341 | <label><?php echo __('Existing Page', 'advanced-access-manager'); ?></label> |
| 342 | <?php wp_dropdown_pages([ |
| 343 | 'depth' => 99, |
| 344 | 'echo' => 1, |
| 345 | 'selected' => (isset($restriction_settings['redirect']['redirect_page_id']) ? $restriction_settings['redirect']['redirect_page_id'] : 0), |
| 346 | 'class' => 'form-control', |
| 347 | 'id' => 'restricted_redirect_page_id', |
| 348 | 'show_option_none' => __('-- Select Page --', 'advanced-access-manager') |
| 349 | ]); ?> |
| 350 | </div> |
| 351 | |
| 352 | <div |
| 353 | class="form-group aam-mt-2 restricted-redirect-type<?php echo ($redirect_type === 'url_redirect' ? 'block' : ' hidden'); ?>" |
| 354 | data-type="url_redirect" |
| 355 | > |
| 356 | <label><?php echo __('The URL', 'advanced-access-manager'); ?></label> |
| 357 | <input |
| 358 | type="text" |
| 359 | class="form-control" |
| 360 | placeholder="https://" |
| 361 | id="restricted_redirect_url" |
| 362 | value="<?php echo esc_attr(isset($restriction_settings['redirect']['redirect_url']) ? $restriction_settings['redirect']['redirect_url'] : ''); ?>" |
| 363 | /> |
| 364 | </div> |
| 365 | |
| 366 | <div |
| 367 | class="form-group aam-mt-2 restricted-redirect-type<?php echo ($redirect_type === 'trigger_callback' ? 'block' : ' hidden'); ?>" |
| 368 | data-type="trigger_callback" |
| 369 | > |
| 370 | <label><?php echo __('PHP Callback Function', 'advanced-access-manager'); ?></label> |
| 371 | <input |
| 372 | type="text" |
| 373 | class="form-control" |
| 374 | placeholder="<?php echo __('Enter valid callback', 'advanced-access-manager'); ?>" |
| 375 | id="restricted_callback" |
| 376 | value="<?php echo esc_attr(isset($restriction_settings['redirect']['callback']) ? $restriction_settings['redirect']['callback'] : ''); ?>" |
| 377 | /> |
| 378 | </div> |
| 379 | </div> |
| 380 | </div> |
| 381 | |
| 382 | <div data-type="password_protected" class="<?php echo $restriction_type !== 'password_protected' ? 'hidden' : ''; ?>"> |
| 383 | <hr /> |
| 384 | |
| 385 | <div class="form-group"> |
| 386 | <label><?php echo __('Password', 'advanced-access-manager'); ?></label> |
| 387 | <input |
| 388 | type="text" |
| 389 | class="form-control" |
| 390 | placeholder="<?php echo __('Enter Password', 'advanced-access-manager'); ?>" |
| 391 | id="restricted_password" |
| 392 | value="<?php echo esc_attr(isset($restriction_settings['password']) ? $restriction_settings['password'] : ''); ?>" |
| 393 | /> |
| 394 | </div> |
| 395 | </div> |
| 396 | |
| 397 | <div data-type="expire" class="<?php echo $restriction_type !== 'expire' ? 'hidden' : ''; ?>"> |
| 398 | <hr /> |
| 399 | |
| 400 | <div class="form-group"> |
| 401 | <div id="content_expire_datepicker"></div> |
| 402 | <input |
| 403 | type="hidden" |
| 404 | id="aam_expire_datetime" |
| 405 | value="<?php echo esc_attr(isset($restriction_settings['expires_after']) ? $restriction_settings['expires_after'] : strtotime('tomorrow')); ?>" |
| 406 | /> |
| 407 | </div> |
| 408 | </div> |
| 409 | |
| 410 | <?php do_action('aam_ui_content_restriction_type_extra_action', $params); ?> |
| 411 | </div> |
| 412 | |
| 413 | <?php do_action('aam_ui_content_access_form_restriction_action', $params); ?> |
| 414 | </div> |
| 415 | <div class="modal-footer"> |
| 416 | <button |
| 417 | type="button" |
| 418 | class="btn btn-success btn-save" |
| 419 | id="save_read_permission" |
| 420 | ><?php echo __('Save Settings', 'advanced-access-manager'); ?></button> |
| 421 | <button |
| 422 | type="button" |
| 423 | class="btn btn-default" |
| 424 | data-dismiss="modal" |
| 425 | ><?php echo __('Close', 'advanced-access-manager'); ?></button> |
| 426 | </div> |
| 427 | </div> |
| 428 | </div> |
| 429 | </div> |
| 430 | <?php } ?> |
| 431 | |
| 432 | <?php do_action('aam_ui_append_content_access_form_action', $params); ?> |
| 433 | <?php } |