PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 All 205 releases
booking / includes / page-catalog-booking-resources / booking-resources-domain-access.php

booking-resources-domain-access.php in Booking Calendar 11.9, at includes/page-catalog-booking-resources/booking-resources-domain-access.php

61 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Booking Resources domain authorization helpers.
4 *
5 * @package Booking Calendar
6 * @since 11.9.0
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 if ( ! function_exists( 'wpbc_catalog_booking_resources_get_role_capability' ) ) {
14 /**
15 * Map an established Booking Calendar minimum-role option to a capability.
16 *
17 * This belongs to the Resource domain rather than its catalog page because
18 * other authorized consumers, including the Setup Wizard, create Resources
19 * without loading the catalog UI.
20 *
21 * @param string $role_option Booking Calendar option containing a minimum role.
22 *
23 * @return string WordPress capability name.
24 */
25 function wpbc_catalog_booking_resources_get_role_capability( $role_option ) {
26 $minimum_role = get_bk_option( sanitize_key( $role_option ) );
27 $capabilities = array(
28 'administrator' => 'activate_plugins',
29 'editor' => 'publish_pages',
30 'author' => 'publish_posts',
31 'contributor' => 'edit_posts',
32 'subscriber' => 'read',
33 );
34
35 return isset( $capabilities[ $minimum_role ] ) ? $capabilities[ $minimum_role ] : 'manage_options';
36 }
37 }
38
39 if ( ! function_exists( 'wpbc_catalog_booking_resources_get_manage_capability' ) ) {
40 /**
41 * Return the capability required by the canonical Resources role setting.
42 *
43 * Free installations use the Settings role because they do not expose the
44 * multi-resource role option. Paid editions use the Resources role so every
45 * Resource-domain consumer enforces the same administration boundary.
46 *
47 * @return string WordPress capability name.
48 */
49 function wpbc_catalog_booking_resources_get_manage_capability() {
50 $role_option = class_exists( 'wpdev_bk_personal' ) ? 'booking_user_role_resources' : 'booking_user_role_settings';
51 $capability = wpbc_catalog_booking_resources_get_role_capability( $role_option );
52
53 /**
54 * Filter the capability required to manage Booking Resources.
55 *
56 * @param string $capability WordPress capability name.
57 */
58 return (string) apply_filters( 'wpbc_catalog_booking_resources_manage_capability', $capability );
59 }
60 }
61