@@ -163,7 +163,7 @@ |
||
163 | 163 | private function _display_minimum_recommended_php_version_notice() |
164 | 164 | { |
165 | 165 | EE_Error::add_persistent_admin_notice( |
166 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
166 | + 'php_version_'.str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED).'_recommended', |
|
167 | 167 | sprintf( |
168 | 168 | __('Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
169 | 169 | 'event_espresso'), |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -18,150 +18,150 @@ discard block |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * converts a Request to a Response |
|
23 | - * |
|
24 | - * @param EE_Request $request |
|
25 | - * @param EE_Response $response |
|
26 | - * @return EE_Response |
|
27 | - */ |
|
28 | - public function handle_request(EE_Request $request, EE_Response $response) |
|
29 | - { |
|
30 | - $this->_request = $request; |
|
31 | - $this->_response = $response; |
|
32 | - //$this->_response->add_output( "\n\t IN >> " . __CLASS__ ); |
|
33 | - //$this->_response->set_notice( 1, 'hey look at this' ); |
|
34 | - // check required WP version |
|
35 | - if ( ! $this->_minimum_wp_version_required()) { |
|
36 | - $this->_request->un_set('activate', true); |
|
37 | - add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
|
38 | - //$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' ); |
|
39 | - $this->_response->terminate_request(); |
|
40 | - $this->_response->deactivate_plugin(); |
|
41 | - } |
|
42 | - // check recommended PHP version |
|
43 | - if ( ! $this->_minimum_php_version_recommended()) { |
|
44 | - $this->_display_minimum_recommended_php_version_notice(); |
|
45 | - } |
|
46 | - $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
47 | - //$this->_response->add_output( "\n\t OUT << " . __CLASS__ ); |
|
48 | - return $this->_response; |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * Helper method to assess installed wp version against given values. |
|
54 | - * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
55 | - * |
|
56 | - * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked against) |
|
57 | - * so consider that when sending in your values. |
|
58 | - * |
|
59 | - * @param string $version_to_check |
|
60 | - * @param string $operator |
|
61 | - * @return bool |
|
62 | - */ |
|
63 | - public static function check_wp_version($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
64 | - { |
|
65 | - global $wp_version; |
|
66 | - return version_compare( |
|
67 | - //first account for wp_version being pre-release (like RC, beta etc which are usually in the format like |
|
68 | - //4.7-RC3-39519 |
|
69 | - strpos($wp_version, '-') > 0 ? substr($wp_version, 0, strpos($wp_version, '-')) : $wp_version, |
|
70 | - $version_to_check, |
|
71 | - $operator |
|
72 | - ); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * _minimum_wp_version_required |
|
79 | - * |
|
80 | - * @access private |
|
81 | - * @return boolean |
|
82 | - */ |
|
83 | - private function _minimum_wp_version_required() |
|
84 | - { |
|
85 | - return self::check_wp_version(); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * _check_php_version |
|
92 | - * |
|
93 | - * @access private |
|
94 | - * @param string $min_version |
|
95 | - * @return boolean |
|
96 | - */ |
|
97 | - private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
98 | - { |
|
99 | - return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * _minimum_php_version_recommended |
|
106 | - * |
|
107 | - * @access private |
|
108 | - * @return boolean |
|
109 | - */ |
|
110 | - private function _minimum_php_version_recommended() |
|
111 | - { |
|
112 | - return $this->_check_php_version(EE_MIN_PHP_VER_RECOMMENDED); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * minimum_wp_version_error |
|
119 | - * |
|
120 | - * @return void |
|
121 | - */ |
|
122 | - public function minimum_wp_version_error() |
|
123 | - { |
|
124 | - global $wp_version; |
|
125 | - ?> |
|
21 | + /** |
|
22 | + * converts a Request to a Response |
|
23 | + * |
|
24 | + * @param EE_Request $request |
|
25 | + * @param EE_Response $response |
|
26 | + * @return EE_Response |
|
27 | + */ |
|
28 | + public function handle_request(EE_Request $request, EE_Response $response) |
|
29 | + { |
|
30 | + $this->_request = $request; |
|
31 | + $this->_response = $response; |
|
32 | + //$this->_response->add_output( "\n\t IN >> " . __CLASS__ ); |
|
33 | + //$this->_response->set_notice( 1, 'hey look at this' ); |
|
34 | + // check required WP version |
|
35 | + if ( ! $this->_minimum_wp_version_required()) { |
|
36 | + $this->_request->un_set('activate', true); |
|
37 | + add_action('admin_notices', array($this, 'minimum_wp_version_error'), 1); |
|
38 | + //$this->_response->add_output( "\n<br />" . 'minimum_wp_version_error' ); |
|
39 | + $this->_response->terminate_request(); |
|
40 | + $this->_response->deactivate_plugin(); |
|
41 | + } |
|
42 | + // check recommended PHP version |
|
43 | + if ( ! $this->_minimum_php_version_recommended()) { |
|
44 | + $this->_display_minimum_recommended_php_version_notice(); |
|
45 | + } |
|
46 | + $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
47 | + //$this->_response->add_output( "\n\t OUT << " . __CLASS__ ); |
|
48 | + return $this->_response; |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * Helper method to assess installed wp version against given values. |
|
54 | + * By default this compares the required minimum version of WP for EE against the installed version of WP |
|
55 | + * |
|
56 | + * Note, $wp_version is the first parameter sent into the PHP version_compare function (what is being checked against) |
|
57 | + * so consider that when sending in your values. |
|
58 | + * |
|
59 | + * @param string $version_to_check |
|
60 | + * @param string $operator |
|
61 | + * @return bool |
|
62 | + */ |
|
63 | + public static function check_wp_version($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=') |
|
64 | + { |
|
65 | + global $wp_version; |
|
66 | + return version_compare( |
|
67 | + //first account for wp_version being pre-release (like RC, beta etc which are usually in the format like |
|
68 | + //4.7-RC3-39519 |
|
69 | + strpos($wp_version, '-') > 0 ? substr($wp_version, 0, strpos($wp_version, '-')) : $wp_version, |
|
70 | + $version_to_check, |
|
71 | + $operator |
|
72 | + ); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * _minimum_wp_version_required |
|
79 | + * |
|
80 | + * @access private |
|
81 | + * @return boolean |
|
82 | + */ |
|
83 | + private function _minimum_wp_version_required() |
|
84 | + { |
|
85 | + return self::check_wp_version(); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * _check_php_version |
|
92 | + * |
|
93 | + * @access private |
|
94 | + * @param string $min_version |
|
95 | + * @return boolean |
|
96 | + */ |
|
97 | + private function _check_php_version($min_version = EE_MIN_PHP_VER_RECOMMENDED) |
|
98 | + { |
|
99 | + return version_compare(PHP_VERSION, $min_version, '>=') ? true : false; |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * _minimum_php_version_recommended |
|
106 | + * |
|
107 | + * @access private |
|
108 | + * @return boolean |
|
109 | + */ |
|
110 | + private function _minimum_php_version_recommended() |
|
111 | + { |
|
112 | + return $this->_check_php_version(EE_MIN_PHP_VER_RECOMMENDED); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * minimum_wp_version_error |
|
119 | + * |
|
120 | + * @return void |
|
121 | + */ |
|
122 | + public function minimum_wp_version_error() |
|
123 | + { |
|
124 | + global $wp_version; |
|
125 | + ?> |
|
126 | 126 | <div class="error"> |
127 | 127 | <p> |
128 | 128 | <?php |
129 | - printf( |
|
130 | - __('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
131 | - 'event_espresso'), |
|
132 | - EE_MIN_WP_VER_REQUIRED, |
|
133 | - $wp_version, |
|
134 | - '<br/>', |
|
135 | - '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
136 | - ); |
|
137 | - ?> |
|
129 | + printf( |
|
130 | + __('We\'re sorry, but Event Espresso requires WordPress version %1$s or greater in order to operate. You are currently running version %2$s.%3$sFor information on how to update your version of WordPress, please go to %4$s.', |
|
131 | + 'event_espresso'), |
|
132 | + EE_MIN_WP_VER_REQUIRED, |
|
133 | + $wp_version, |
|
134 | + '<br/>', |
|
135 | + '<a href="http://codex.wordpress.org/Updating_WordPress">http://codex.wordpress.org/Updating_WordPress</a>' |
|
136 | + ); |
|
137 | + ?> |
|
138 | 138 | </p> |
139 | 139 | </div> |
140 | 140 | <?php |
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * _display_minimum_recommended_php_version_notice |
|
147 | - * |
|
148 | - * @access private |
|
149 | - * @return void |
|
150 | - */ |
|
151 | - private function _display_minimum_recommended_php_version_notice() |
|
152 | - { |
|
153 | - EE_Error::add_persistent_admin_notice( |
|
154 | - 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
155 | - sprintf( |
|
156 | - __('Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
157 | - 'event_espresso'), |
|
158 | - EE_MIN_PHP_VER_RECOMMENDED, |
|
159 | - PHP_VERSION, |
|
160 | - '<br/>', |
|
161 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
162 | - ) |
|
163 | - ); |
|
164 | - } |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * _display_minimum_recommended_php_version_notice |
|
147 | + * |
|
148 | + * @access private |
|
149 | + * @return void |
|
150 | + */ |
|
151 | + private function _display_minimum_recommended_php_version_notice() |
|
152 | + { |
|
153 | + EE_Error::add_persistent_admin_notice( |
|
154 | + 'php_version_' . str_replace('.', '-', EE_MIN_PHP_VER_RECOMMENDED) . '_recommended', |
|
155 | + sprintf( |
|
156 | + __('Event Espresso recommends PHP version %1$s or greater for optimal performance. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
157 | + 'event_espresso'), |
|
158 | + EE_MIN_PHP_VER_RECOMMENDED, |
|
159 | + PHP_VERSION, |
|
160 | + '<br/>', |
|
161 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
162 | + ) |
|
163 | + ); |
|
164 | + } |
|
165 | 165 | |
166 | 166 | |
167 | 167 | } |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | * |
815 | 815 | * @since 4.5.0 |
816 | 816 | * @param string $meta_cap What meta capability is this mapping. |
817 | - * @param array $map_values array { |
|
817 | + * @param string[] $map_values array { |
|
818 | 818 | * //array of values that MUST match a count of 4. It's okay to send an empty string |
819 | 819 | * for capabilities that don't get mapped to. |
820 | 820 | * @type $map_values [0] string A string representing the model name. Required. String's |
@@ -885,8 +885,8 @@ discard block |
||
885 | 885 | * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
886 | 886 | * @since 4.6.x |
887 | 887 | * @param $caps |
888 | - * @param $cap |
|
889 | - * @param $user_id |
|
888 | + * @param string $cap |
|
889 | + * @param integer $user_id |
|
890 | 890 | * @param $args |
891 | 891 | * @return array |
892 | 892 | */ |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public static function instance() |
61 | 61 | { |
62 | 62 | //check if instantiated, and if not do so. |
63 | - if (! self::$_instance instanceof EE_Capabilities) { |
|
63 | + if ( ! self::$_instance instanceof EE_Capabilities) { |
|
64 | 64 | self::$_instance = new self(); |
65 | 65 | } |
66 | 66 | return self::$_instance; |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | $this->_meta_caps = $this->_get_default_meta_caps_array(); |
113 | 113 | $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
114 | 114 | //add filter for map_meta_caps but only if models can query. |
115 | - if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
115 | + if ( ! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
116 | 116 | add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
117 | 117 | } |
118 | 118 | } |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
271 | 271 | //loop through our _meta_caps array |
272 | 272 | foreach ($this->_meta_caps as $meta_map) { |
273 | - if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
273 | + if ( ! $meta_map instanceof EE_Meta_Capability_Map) { |
|
274 | 274 | continue; |
275 | 275 | } |
276 | 276 | // don't load models if there is no object ID in the args |
277 | - if(!empty($args[0])){ |
|
277 | + if ( ! empty($args[0])) { |
|
278 | 278 | $meta_map->ensure_is_model(); |
279 | 279 | } |
280 | 280 | $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
@@ -632,9 +632,9 @@ discard block |
||
632 | 632 | foreach ($caps_map as $role => $caps_for_role) { |
633 | 633 | foreach ($caps_for_role as $cap) { |
634 | 634 | //first check we haven't already added this cap before, or it's a reset |
635 | - if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
635 | + if ($reset || ! isset($caps_set_before[$role]) || ! in_array($cap, $caps_set_before[$role])) { |
|
636 | 636 | if ($this->add_cap_to_role($role, $cap)) { |
637 | - $caps_set_before[ $role ][] = $cap; |
|
637 | + $caps_set_before[$role][] = $cap; |
|
638 | 638 | } |
639 | 639 | } |
640 | 640 | } |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | { |
665 | 665 | $role_object = get_role($role); |
666 | 666 | //if the role isn't available then we create it. |
667 | - if (! $role_object instanceof WP_Role) { |
|
667 | + if ( ! $role_object instanceof WP_Role) { |
|
668 | 668 | //if a plugin wants to create a specific role name then they should create the role before |
669 | 669 | //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
670 | 670 | // - removes any `ee_` namespacing from the start of the slug. |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | public function current_user_can($cap, $context, $id = 0) |
722 | 722 | { |
723 | 723 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
724 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
724 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__'.$context, $cap, $id); |
|
725 | 725 | $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
726 | 726 | $id); |
727 | 727 | return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | public function user_can($user, $cap, $context, $id = 0) |
743 | 743 | { |
744 | 744 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
745 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
745 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__'.$context, $cap, $user, $id); |
|
746 | 746 | $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
747 | 747 | $id); |
748 | 748 | return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
@@ -773,7 +773,7 @@ discard block |
||
773 | 773 | : current_user_can($blog_id, $cap); |
774 | 774 | //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
775 | 775 | $user_can = apply_filters( |
776 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
776 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__'.$context, |
|
777 | 777 | $user_can, |
778 | 778 | $blog_id, |
779 | 779 | $cap, |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | if (empty($role)) { |
810 | 810 | return $capabilities; |
811 | 811 | } |
812 | - return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
812 | + return isset($capabilities[$role]) ? $capabilities[$role] : array(); |
|
813 | 813 | } |
814 | 814 | } |
815 | 815 | |
@@ -875,16 +875,16 @@ discard block |
||
875 | 875 | 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
876 | 876 | 'event_espresso' |
877 | 877 | ), |
878 | - '<br>' . print_r($map_values, true) |
|
878 | + '<br>'.print_r($map_values, true) |
|
879 | 879 | ) |
880 | 880 | ); |
881 | 881 | } |
882 | 882 | //set properties |
883 | 883 | $this->_model = null; |
884 | 884 | $this->_model_name = $map_values[0]; |
885 | - $this->published_cap = (string)$map_values[1]; |
|
886 | - $this->others_cap = (string)$map_values[2]; |
|
887 | - $this->private_cap = (string)$map_values[3]; |
|
885 | + $this->published_cap = (string) $map_values[1]; |
|
886 | + $this->others_cap = (string) $map_values[2]; |
|
887 | + $this->private_cap = (string) $map_values[3]; |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | /** |
@@ -911,11 +911,11 @@ discard block |
||
911 | 911 | return; |
912 | 912 | } |
913 | 913 | //ensure model name is string |
914 | - $this->_model_name = (string)$this->_model_name; |
|
914 | + $this->_model_name = (string) $this->_model_name; |
|
915 | 915 | //error proof if the name has EEM in it |
916 | 916 | $this->_model_name = str_replace('EEM', '', $this->_model_name); |
917 | 917 | $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
918 | - if (! $this->_model instanceof EEM_Base) { |
|
918 | + if ( ! $this->_model instanceof EEM_Base) { |
|
919 | 919 | throw new EE_Error( |
920 | 920 | sprintf( |
921 | 921 | __( |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | /** @var EE_Base_Class $obj */ |
1006 | 1006 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1007 | 1007 | //if no obj then let's just do cap |
1008 | - if (! $obj instanceof EE_Base_Class) { |
|
1008 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1009 | 1009 | $caps[] = $cap; |
1010 | 1010 | return $caps; |
1011 | 1011 | } |
@@ -1024,12 +1024,12 @@ discard block |
||
1024 | 1024 | } |
1025 | 1025 | } else { |
1026 | 1026 | //the user is trying to edit someone else's obj |
1027 | - if (! empty($this->others_cap)) { |
|
1027 | + if ( ! empty($this->others_cap)) { |
|
1028 | 1028 | $caps[] = $this->others_cap; |
1029 | 1029 | } |
1030 | - if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1030 | + if ( ! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1031 | 1031 | $caps[] = $this->published_cap; |
1032 | - } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1032 | + } elseif ( ! empty($this->private_cap) && $obj->status() === 'private') { |
|
1033 | 1033 | $caps[] = $this->private_cap; |
1034 | 1034 | } |
1035 | 1035 | } |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | if ($has_cap) { |
1049 | 1049 | $caps[] = $cap; |
1050 | 1050 | } else { |
1051 | - if (! empty($this->others_cap)) { |
|
1051 | + if ( ! empty($this->others_cap)) { |
|
1052 | 1052 | $caps[] = $this->others_cap; |
1053 | 1053 | } |
1054 | 1054 | } |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | |
1131 | 1131 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1132 | 1132 | //if no obj then let's just do cap |
1133 | - if (! $obj instanceof EE_Base_Class) { |
|
1133 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1134 | 1134 | $caps[] = $cap; |
1135 | 1135 | return $caps; |
1136 | 1136 | } |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | } elseif ($status_obj->private && ! empty($this->private_cap)) { |
1147 | 1147 | //the user is trying to view someone else's obj |
1148 | 1148 | $caps[] = $this->private_cap; |
1149 | - } elseif (! empty($this->others_cap)) { |
|
1149 | + } elseif ( ! empty($this->others_cap)) { |
|
1150 | 1150 | $caps[] = $this->others_cap; |
1151 | 1151 | } else { |
1152 | 1152 | $caps[] = $cap; |
@@ -1163,9 +1163,9 @@ discard block |
||
1163 | 1163 | } |
1164 | 1164 | if ($has_cap) { |
1165 | 1165 | $caps[] = $cap; |
1166 | - } elseif (! empty($this->private_cap)) { |
|
1166 | + } elseif ( ! empty($this->private_cap)) { |
|
1167 | 1167 | $caps[] = $this->private_cap; |
1168 | - } elseif (! empty($this->others_cap)) { |
|
1168 | + } elseif ( ! empty($this->others_cap)) { |
|
1169 | 1169 | $caps[] = $this->others_cap; |
1170 | 1170 | } else { |
1171 | 1171 | $caps[] = $cap; |
@@ -1215,7 +1215,7 @@ discard block |
||
1215 | 1215 | |
1216 | 1216 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1217 | 1217 | //if no obj then let's just do cap |
1218 | - if (! $obj instanceof EE_Message_Template_Group) { |
|
1218 | + if ( ! $obj instanceof EE_Message_Template_Group) { |
|
1219 | 1219 | $caps[] = $cap; |
1220 | 1220 | return $caps; |
1221 | 1221 | } |
@@ -1273,7 +1273,7 @@ discard block |
||
1273 | 1273 | } |
1274 | 1274 | $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
1275 | 1275 | //if no obj then let's just do cap |
1276 | - if (! $obj instanceof EE_Base_Class) { |
|
1276 | + if ( ! $obj instanceof EE_Base_Class) { |
|
1277 | 1277 | $caps[] = $cap; |
1278 | 1278 | return $caps; |
1279 | 1279 | } |
@@ -16,811 +16,811 @@ discard block |
||
16 | 16 | final class EE_Capabilities extends EE_Base |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * the name of the wp option used to store caps previously initialized |
|
21 | - */ |
|
22 | - const option_name = 'ee_caps_initialized'; |
|
23 | - |
|
24 | - /** |
|
25 | - * instance of EE_Capabilities object |
|
26 | - * |
|
27 | - * @var EE_Capabilities |
|
28 | - */ |
|
29 | - private static $_instance; |
|
30 | - |
|
31 | - |
|
32 | - /** |
|
33 | - * This is a map of caps that correspond to a default WP_Role. |
|
34 | - * Array is indexed by Role and values are ee capabilities. |
|
35 | - * |
|
36 | - * @since 4.5.0 |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - private $_caps_map = array(); |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * This used to hold an array of EE_Meta_Capability_Map objects that define the granular capabilities mapped to for |
|
44 | - * a user depending on context. |
|
45 | - * |
|
46 | - * @var EE_Meta_Capability_Map[] |
|
47 | - */ |
|
48 | - private $_meta_caps = array(); |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * singleton method used to instantiate class object |
|
53 | - * |
|
54 | - * @since 4.5.0 |
|
55 | - * @return EE_Capabilities |
|
56 | - */ |
|
57 | - public static function instance() |
|
58 | - { |
|
59 | - //check if instantiated, and if not do so. |
|
60 | - if (! self::$_instance instanceof EE_Capabilities) { |
|
61 | - self::$_instance = new self(); |
|
62 | - } |
|
63 | - return self::$_instance; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * private constructor |
|
69 | - * |
|
70 | - * @since 4.5.0 |
|
71 | - */ |
|
72 | - private function __construct() |
|
73 | - { |
|
74 | - if (is_admin()) { |
|
75 | - add_filter( |
|
76 | - 'FHEE__EE_Capabilities__init_caps_map__caps', |
|
77 | - array($this, 'register_additional_capabilities'), |
|
78 | - 10 |
|
79 | - ); |
|
80 | - } |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * This delays the initialization of the capabilities class until EE_System core is loaded and ready. |
|
86 | - * |
|
87 | - * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
88 | - * actually REMOVE any capabilities from existing roles, it just resaves defaults roles and |
|
89 | - * ensures that they are up to date. |
|
90 | - * @since 4.5.0 |
|
91 | - * @return void |
|
92 | - */ |
|
93 | - public function init_caps($reset = false) |
|
94 | - { |
|
95 | - /** |
|
96 | - * Note, this means that caps can only initialized on the default roles when: |
|
97 | - * - models are queryable |
|
98 | - * - All addons have been registered (which happens at plugins_loaded priority 1) |
|
99 | - * In practice, currently this method is usually called around `init`. |
|
100 | - */ |
|
101 | - if ( |
|
102 | - did_action('AHEE__EE_System__load_espresso_addons__complete') |
|
103 | - && EE_Maintenance_Mode::instance()->models_can_query() |
|
104 | - ) { |
|
105 | - $this->_caps_map = $this->_init_caps_map(); |
|
106 | - $this->init_role_caps($reset); |
|
107 | - $this->_set_meta_caps(); |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * This sets the meta caps property. |
|
114 | - * |
|
115 | - * @since 4.5.0 |
|
116 | - * @return void |
|
117 | - */ |
|
118 | - private function _set_meta_caps() |
|
119 | - { |
|
120 | - //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
|
121 | - $this->_meta_caps = $this->_get_default_meta_caps_array(); |
|
122 | - $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
123 | - //add filter for map_meta_caps but only if models can query. |
|
124 | - if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
125 | - add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
126 | - } |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * This builds and returns the default meta_caps array only once. |
|
132 | - * |
|
133 | - * @since 4.8.28.rc.012 |
|
134 | - * @return array |
|
135 | - * @throws \EE_Error |
|
136 | - */ |
|
137 | - private function _get_default_meta_caps_array() |
|
138 | - { |
|
139 | - static $default_meta_caps = array(); |
|
140 | - if (empty($default_meta_caps)) { |
|
141 | - $default_meta_caps = array( |
|
142 | - //edits |
|
143 | - new EE_Meta_Capability_Map_Edit( |
|
144 | - 'ee_edit_event', |
|
145 | - array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events') |
|
146 | - ), |
|
147 | - new EE_Meta_Capability_Map_Edit( |
|
148 | - 'ee_edit_venue', |
|
149 | - array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues') |
|
150 | - ), |
|
151 | - new EE_Meta_Capability_Map_Edit( |
|
152 | - 'ee_edit_registration', |
|
153 | - array('Registration', '', 'ee_edit_others_registrations', '') |
|
154 | - ), |
|
155 | - new EE_Meta_Capability_Map_Edit( |
|
156 | - 'ee_edit_checkin', |
|
157 | - array('Registration', '', 'ee_edit_others_checkins', '') |
|
158 | - ), |
|
159 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
160 | - 'ee_edit_message', |
|
161 | - array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages') |
|
162 | - ), |
|
163 | - new EE_Meta_Capability_Map_Edit( |
|
164 | - 'ee_edit_default_ticket', |
|
165 | - array('Ticket', '', 'ee_edit_others_default_tickets', '') |
|
166 | - ), |
|
167 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
168 | - 'ee_edit_question', |
|
169 | - array('Question', '', '', 'ee_edit_system_questions') |
|
170 | - ), |
|
171 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
172 | - 'ee_edit_question_group', |
|
173 | - array('Question_Group', '', '', 'ee_edit_system_question_groups') |
|
174 | - ), |
|
175 | - new EE_Meta_Capability_Map_Edit( |
|
176 | - 'ee_edit_payment_method', |
|
177 | - array('Payment_Method', '', 'ee_edit_others_payment_methods', '') |
|
178 | - ), |
|
179 | - //reads |
|
180 | - new EE_Meta_Capability_Map_Read( |
|
181 | - 'ee_read_event', |
|
182 | - array('Event', '', 'ee_read_others_events', 'ee_read_private_events') |
|
183 | - ), |
|
184 | - new EE_Meta_Capability_Map_Read( |
|
185 | - 'ee_read_venue', |
|
186 | - array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues') |
|
187 | - ), |
|
188 | - new EE_Meta_Capability_Map_Read( |
|
189 | - 'ee_read_registration', |
|
190 | - array('Registration', '', '', 'ee_edit_others_registrations') |
|
191 | - ), |
|
192 | - new EE_Meta_Capability_Map_Read( |
|
193 | - 'ee_read_checkin', |
|
194 | - array('Registration', '', '', 'ee_read_others_checkins') |
|
195 | - ), |
|
196 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
197 | - 'ee_read_message', |
|
198 | - array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages') |
|
199 | - ), |
|
200 | - new EE_Meta_Capability_Map_Read( |
|
201 | - 'ee_read_default_ticket', |
|
202 | - array('Ticket', '', '', 'ee_read_others_default_tickets') |
|
203 | - ), |
|
204 | - new EE_Meta_Capability_Map_Read( |
|
205 | - 'ee_read_payment_method', |
|
206 | - array('Payment_Method', '', '', 'ee_read_others_payment_methods') |
|
207 | - ), |
|
208 | - //deletes |
|
209 | - new EE_Meta_Capability_Map_Delete( |
|
210 | - 'ee_delete_event', |
|
211 | - array( |
|
212 | - 'Event', |
|
213 | - 'ee_delete_published_events', |
|
214 | - 'ee_delete_others_events', |
|
215 | - 'ee_delete_private_events', |
|
216 | - ) |
|
217 | - ), |
|
218 | - new EE_Meta_Capability_Map_Delete( |
|
219 | - 'ee_delete_venue', |
|
220 | - array( |
|
221 | - 'Venue', |
|
222 | - 'ee_delete_published_venues', |
|
223 | - 'ee_delete_others_venues', |
|
224 | - 'ee_delete_private_venues', |
|
225 | - ) |
|
226 | - ), |
|
227 | - new EE_Meta_Capability_Map_Delete( |
|
228 | - 'ee_delete_registration', |
|
229 | - array('Registration', '', 'ee_delete_others_registrations', '') |
|
230 | - ), |
|
231 | - new EE_Meta_Capability_Map_Delete( |
|
232 | - 'ee_delete_checkin', |
|
233 | - array('Registration', '', 'ee_delete_others_checkins', '') |
|
234 | - ), |
|
235 | - new EE_Meta_Capability_Map_Messages_Cap( |
|
236 | - 'ee_delete_message', |
|
237 | - array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages') |
|
238 | - ), |
|
239 | - new EE_Meta_Capability_Map_Delete( |
|
240 | - 'ee_delete_default_ticket', |
|
241 | - array('Ticket', '', 'ee_delete_others_default_tickets', '') |
|
242 | - ), |
|
243 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
244 | - 'ee_delete_question', |
|
245 | - array('Question', '', '', 'delete_system_questions') |
|
246 | - ), |
|
247 | - new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
248 | - 'ee_delete_question_group', |
|
249 | - array('Question_Group', '', '', 'delete_system_question_groups') |
|
250 | - ), |
|
251 | - new EE_Meta_Capability_Map_Delete( |
|
252 | - 'ee_delete_payment_method', |
|
253 | - array('Payment_Method', '', 'ee_delete_others_payment_methods', '') |
|
254 | - ), |
|
255 | - ); |
|
256 | - } |
|
257 | - return $default_meta_caps; |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
263 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
264 | - * The actual logic is carried out by implementer classes in their definition of _map_meta_caps. |
|
265 | - * |
|
266 | - * @since 4.5.0 |
|
267 | - * @see wp-includes/capabilities.php |
|
268 | - * @param array $caps actual users capabilities |
|
269 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
270 | - * @param int $user_id The user id |
|
271 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
272 | - * @return array actual users capabilities |
|
273 | - * @throws EE_Error |
|
274 | - */ |
|
275 | - public function map_meta_caps($caps, $cap, $user_id, $args) |
|
276 | - { |
|
277 | - if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
|
278 | - //loop through our _meta_caps array |
|
279 | - foreach ($this->_meta_caps as $meta_map) { |
|
280 | - if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
281 | - continue; |
|
282 | - } |
|
283 | - // don't load models if there is no object ID in the args |
|
284 | - if(!empty($args[0])){ |
|
285 | - $meta_map->ensure_is_model(); |
|
286 | - } |
|
287 | - $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
288 | - } |
|
289 | - } |
|
290 | - return $caps; |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * This sets up and returns the initial capabilities map for Event Espresso |
|
296 | - * |
|
297 | - * @since 4.5.0 |
|
298 | - * @return array |
|
299 | - */ |
|
300 | - private function _init_caps_map() |
|
301 | - { |
|
302 | - $caps = array( |
|
303 | - 'administrator' => array( |
|
304 | - //basic access |
|
305 | - 'ee_read_ee', |
|
306 | - //gateways |
|
307 | - /** |
|
308 | - * note that with payment method capabilities, although we've implemented |
|
309 | - * capability mapping which will be used for accessing payment methods owned by |
|
310 | - * other users. This is not fully implemented yet in the payment method ui. |
|
311 | - * Currently only the "plural" caps are in active use. |
|
312 | - * (Specific payment method caps are in use as well). |
|
313 | - **/ |
|
314 | - 'ee_manage_gateways', |
|
315 | - 'ee_read_payment_method', |
|
316 | - 'ee_read_payment_methods', |
|
317 | - 'ee_read_others_payment_methods', |
|
318 | - 'ee_edit_payment_method', |
|
319 | - 'ee_edit_payment_methods', |
|
320 | - 'ee_edit_others_payment_methods', |
|
321 | - 'ee_delete_payment_method', |
|
322 | - 'ee_delete_payment_methods', |
|
323 | - //events |
|
324 | - 'ee_publish_events', |
|
325 | - 'ee_read_private_events', |
|
326 | - 'ee_read_others_events', |
|
327 | - 'ee_read_event', |
|
328 | - 'ee_read_events', |
|
329 | - 'ee_edit_event', |
|
330 | - 'ee_edit_events', |
|
331 | - 'ee_edit_published_events', |
|
332 | - 'ee_edit_others_events', |
|
333 | - 'ee_edit_private_events', |
|
334 | - 'ee_delete_published_events', |
|
335 | - 'ee_delete_private_events', |
|
336 | - 'ee_delete_event', |
|
337 | - 'ee_delete_events', |
|
338 | - 'ee_delete_others_events', |
|
339 | - //event categories |
|
340 | - 'ee_manage_event_categories', |
|
341 | - 'ee_edit_event_category', |
|
342 | - 'ee_delete_event_category', |
|
343 | - 'ee_assign_event_category', |
|
344 | - //venues |
|
345 | - 'ee_publish_venues', |
|
346 | - 'ee_read_venue', |
|
347 | - 'ee_read_venues', |
|
348 | - 'ee_read_others_venues', |
|
349 | - 'ee_read_private_venues', |
|
350 | - 'ee_edit_venue', |
|
351 | - 'ee_edit_venues', |
|
352 | - 'ee_edit_others_venues', |
|
353 | - 'ee_edit_published_venues', |
|
354 | - 'ee_edit_private_venues', |
|
355 | - 'ee_delete_venue', |
|
356 | - 'ee_delete_venues', |
|
357 | - 'ee_delete_others_venues', |
|
358 | - 'ee_delete_private_venues', |
|
359 | - 'ee_delete_published_venues', |
|
360 | - //venue categories |
|
361 | - 'ee_manage_venue_categories', |
|
362 | - 'ee_edit_venue_category', |
|
363 | - 'ee_delete_venue_category', |
|
364 | - 'ee_assign_venue_category', |
|
365 | - //contacts |
|
366 | - 'ee_read_contact', |
|
367 | - 'ee_read_contacts', |
|
368 | - 'ee_edit_contact', |
|
369 | - 'ee_edit_contacts', |
|
370 | - 'ee_delete_contact', |
|
371 | - 'ee_delete_contacts', |
|
372 | - //registrations |
|
373 | - 'ee_read_registration', |
|
374 | - 'ee_read_registrations', |
|
375 | - 'ee_read_others_registrations', |
|
376 | - 'ee_edit_registration', |
|
377 | - 'ee_edit_registrations', |
|
378 | - 'ee_edit_others_registrations', |
|
379 | - 'ee_delete_registration', |
|
380 | - 'ee_delete_registrations', |
|
381 | - //checkins |
|
382 | - 'ee_read_checkin', |
|
383 | - 'ee_read_others_checkins', |
|
384 | - 'ee_read_checkins', |
|
385 | - 'ee_edit_checkin', |
|
386 | - 'ee_edit_checkins', |
|
387 | - 'ee_edit_others_checkins', |
|
388 | - 'ee_delete_checkin', |
|
389 | - 'ee_delete_checkins', |
|
390 | - 'ee_delete_others_checkins', |
|
391 | - //transactions && payments |
|
392 | - 'ee_read_transaction', |
|
393 | - 'ee_read_transactions', |
|
394 | - 'ee_edit_payments', |
|
395 | - 'ee_delete_payments', |
|
396 | - //messages |
|
397 | - 'ee_read_message', |
|
398 | - 'ee_read_messages', |
|
399 | - 'ee_read_others_messages', |
|
400 | - 'ee_read_global_messages', |
|
401 | - 'ee_edit_global_messages', |
|
402 | - 'ee_edit_message', |
|
403 | - 'ee_edit_messages', |
|
404 | - 'ee_edit_others_messages', |
|
405 | - 'ee_delete_message', |
|
406 | - 'ee_delete_messages', |
|
407 | - 'ee_delete_others_messages', |
|
408 | - 'ee_delete_global_messages', |
|
409 | - 'ee_send_message', |
|
410 | - //tickets |
|
411 | - 'ee_read_default_ticket', |
|
412 | - 'ee_read_default_tickets', |
|
413 | - 'ee_read_others_default_tickets', |
|
414 | - 'ee_edit_default_ticket', |
|
415 | - 'ee_edit_default_tickets', |
|
416 | - 'ee_edit_others_default_tickets', |
|
417 | - 'ee_delete_default_ticket', |
|
418 | - 'ee_delete_default_tickets', |
|
419 | - 'ee_delete_others_default_tickets', |
|
420 | - //prices |
|
421 | - 'ee_edit_default_price', |
|
422 | - 'ee_edit_default_prices', |
|
423 | - 'ee_delete_default_price', |
|
424 | - 'ee_delete_default_prices', |
|
425 | - 'ee_edit_default_price_type', |
|
426 | - 'ee_edit_default_price_types', |
|
427 | - 'ee_delete_default_price_type', |
|
428 | - 'ee_delete_default_price_types', |
|
429 | - 'ee_read_default_prices', |
|
430 | - 'ee_read_default_price_types', |
|
431 | - //registration form |
|
432 | - 'ee_edit_question', |
|
433 | - 'ee_edit_questions', |
|
434 | - 'ee_edit_system_questions', |
|
435 | - 'ee_read_questions', |
|
436 | - 'ee_delete_question', |
|
437 | - 'ee_delete_questions', |
|
438 | - 'ee_edit_question_group', |
|
439 | - 'ee_edit_question_groups', |
|
440 | - 'ee_read_question_groups', |
|
441 | - 'ee_edit_system_question_groups', |
|
442 | - 'ee_delete_question_group', |
|
443 | - 'ee_delete_question_groups', |
|
444 | - //event_type taxonomy |
|
445 | - 'ee_assign_event_type', |
|
446 | - 'ee_manage_event_types', |
|
447 | - 'ee_edit_event_type', |
|
448 | - 'ee_delete_event_type', |
|
449 | - ), |
|
450 | - 'ee_events_administrator' => array( |
|
451 | - //core wp caps |
|
452 | - 'read', |
|
453 | - 'read_private_pages', |
|
454 | - 'read_private_posts', |
|
455 | - 'edit_users', |
|
456 | - 'edit_posts', |
|
457 | - 'edit_pages', |
|
458 | - 'edit_published_posts', |
|
459 | - 'edit_published_pages', |
|
460 | - 'edit_private_pages', |
|
461 | - 'edit_private_posts', |
|
462 | - 'edit_others_posts', |
|
463 | - 'edit_others_pages', |
|
464 | - 'publish_posts', |
|
465 | - 'publish_pages', |
|
466 | - 'delete_posts', |
|
467 | - 'delete_pages', |
|
468 | - 'delete_private_pages', |
|
469 | - 'delete_private_posts', |
|
470 | - 'delete_published_pages', |
|
471 | - 'delete_published_posts', |
|
472 | - 'delete_others_posts', |
|
473 | - 'delete_others_pages', |
|
474 | - 'manage_categories', |
|
475 | - 'manage_links', |
|
476 | - 'moderate_comments', |
|
477 | - 'unfiltered_html', |
|
478 | - 'upload_files', |
|
479 | - 'export', |
|
480 | - 'import', |
|
481 | - 'list_users', |
|
482 | - 'level_1', //required if user with this role shows up in author dropdowns |
|
483 | - //basic ee access |
|
484 | - 'ee_read_ee', |
|
485 | - //events |
|
486 | - 'ee_publish_events', |
|
487 | - 'ee_read_private_events', |
|
488 | - 'ee_read_others_events', |
|
489 | - 'ee_read_event', |
|
490 | - 'ee_read_events', |
|
491 | - 'ee_edit_event', |
|
492 | - 'ee_edit_events', |
|
493 | - 'ee_edit_published_events', |
|
494 | - 'ee_edit_others_events', |
|
495 | - 'ee_edit_private_events', |
|
496 | - 'ee_delete_published_events', |
|
497 | - 'ee_delete_private_events', |
|
498 | - 'ee_delete_event', |
|
499 | - 'ee_delete_events', |
|
500 | - 'ee_delete_others_events', |
|
501 | - //event categories |
|
502 | - 'ee_manage_event_categories', |
|
503 | - 'ee_edit_event_category', |
|
504 | - 'ee_delete_event_category', |
|
505 | - 'ee_assign_event_category', |
|
506 | - //venues |
|
507 | - 'ee_publish_venues', |
|
508 | - 'ee_read_venue', |
|
509 | - 'ee_read_venues', |
|
510 | - 'ee_read_others_venues', |
|
511 | - 'ee_read_private_venues', |
|
512 | - 'ee_edit_venue', |
|
513 | - 'ee_edit_venues', |
|
514 | - 'ee_edit_others_venues', |
|
515 | - 'ee_edit_published_venues', |
|
516 | - 'ee_edit_private_venues', |
|
517 | - 'ee_delete_venue', |
|
518 | - 'ee_delete_venues', |
|
519 | - 'ee_delete_others_venues', |
|
520 | - 'ee_delete_private_venues', |
|
521 | - 'ee_delete_published_venues', |
|
522 | - //venue categories |
|
523 | - 'ee_manage_venue_categories', |
|
524 | - 'ee_edit_venue_category', |
|
525 | - 'ee_delete_venue_category', |
|
526 | - 'ee_assign_venue_category', |
|
527 | - //contacts |
|
528 | - 'ee_read_contact', |
|
529 | - 'ee_read_contacts', |
|
530 | - 'ee_edit_contact', |
|
531 | - 'ee_edit_contacts', |
|
532 | - 'ee_delete_contact', |
|
533 | - 'ee_delete_contacts', |
|
534 | - //registrations |
|
535 | - 'ee_read_registration', |
|
536 | - 'ee_read_registrations', |
|
537 | - 'ee_read_others_registrations', |
|
538 | - 'ee_edit_registration', |
|
539 | - 'ee_edit_registrations', |
|
540 | - 'ee_edit_others_registrations', |
|
541 | - 'ee_delete_registration', |
|
542 | - 'ee_delete_registrations', |
|
543 | - //checkins |
|
544 | - 'ee_read_checkin', |
|
545 | - 'ee_read_others_checkins', |
|
546 | - 'ee_read_checkins', |
|
547 | - 'ee_edit_checkin', |
|
548 | - 'ee_edit_checkins', |
|
549 | - 'ee_edit_others_checkins', |
|
550 | - 'ee_delete_checkin', |
|
551 | - 'ee_delete_checkins', |
|
552 | - 'ee_delete_others_checkins', |
|
553 | - //transactions && payments |
|
554 | - 'ee_read_transaction', |
|
555 | - 'ee_read_transactions', |
|
556 | - 'ee_edit_payments', |
|
557 | - 'ee_delete_payments', |
|
558 | - //messages |
|
559 | - 'ee_read_message', |
|
560 | - 'ee_read_messages', |
|
561 | - 'ee_read_others_messages', |
|
562 | - 'ee_read_global_messages', |
|
563 | - 'ee_edit_global_messages', |
|
564 | - 'ee_edit_message', |
|
565 | - 'ee_edit_messages', |
|
566 | - 'ee_edit_others_messages', |
|
567 | - 'ee_delete_message', |
|
568 | - 'ee_delete_messages', |
|
569 | - 'ee_delete_others_messages', |
|
570 | - 'ee_delete_global_messages', |
|
571 | - 'ee_send_message', |
|
572 | - //tickets |
|
573 | - 'ee_read_default_ticket', |
|
574 | - 'ee_read_default_tickets', |
|
575 | - 'ee_read_others_default_tickets', |
|
576 | - 'ee_edit_default_ticket', |
|
577 | - 'ee_edit_default_tickets', |
|
578 | - 'ee_edit_others_default_tickets', |
|
579 | - 'ee_delete_default_ticket', |
|
580 | - 'ee_delete_default_tickets', |
|
581 | - 'ee_delete_others_default_tickets', |
|
582 | - //prices |
|
583 | - 'ee_edit_default_price', |
|
584 | - 'ee_edit_default_prices', |
|
585 | - 'ee_delete_default_price', |
|
586 | - 'ee_delete_default_prices', |
|
587 | - 'ee_edit_default_price_type', |
|
588 | - 'ee_edit_default_price_types', |
|
589 | - 'ee_delete_default_price_type', |
|
590 | - 'ee_delete_default_price_types', |
|
591 | - 'ee_read_default_prices', |
|
592 | - 'ee_read_default_price_types', |
|
593 | - //registration form |
|
594 | - 'ee_edit_question', |
|
595 | - 'ee_edit_questions', |
|
596 | - 'ee_edit_system_questions', |
|
597 | - 'ee_read_questions', |
|
598 | - 'ee_delete_question', |
|
599 | - 'ee_delete_questions', |
|
600 | - 'ee_edit_question_group', |
|
601 | - 'ee_edit_question_groups', |
|
602 | - 'ee_read_question_groups', |
|
603 | - 'ee_edit_system_question_groups', |
|
604 | - 'ee_delete_question_group', |
|
605 | - 'ee_delete_question_groups', |
|
606 | - //event_type taxonomy |
|
607 | - 'ee_assign_event_type', |
|
608 | - 'ee_manage_event_types', |
|
609 | - 'ee_edit_event_type', |
|
610 | - 'ee_delete_event_type', |
|
611 | - ), |
|
612 | - ); |
|
613 | - $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
614 | - return $caps; |
|
615 | - } |
|
616 | - |
|
617 | - |
|
618 | - /** |
|
619 | - * Callback for FHEE__EE_Capabilities__init_caps_map__caps that is used for registering additional core |
|
620 | - * capabilities that get added. |
|
621 | - * This is typically done for more dynamic cap additions such as what is registered via the |
|
622 | - * `EE_Payment_Method_Manager` |
|
623 | - * |
|
624 | - * @param array $caps The existing $role=>$capability array. |
|
625 | - * @return array. |
|
626 | - */ |
|
627 | - public function register_additional_capabilities($caps) |
|
628 | - { |
|
629 | - //take care of dynamic capabilities for payment methods |
|
630 | - EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
631 | - $caps = EE_Payment_Method_Manager::instance()->add_payment_method_caps($caps); |
|
632 | - return $caps; |
|
633 | - } |
|
634 | - |
|
635 | - |
|
636 | - /** |
|
637 | - * This adds all the default caps to roles as registered in the _caps_map property. |
|
638 | - * |
|
639 | - * @since 4.5.0 |
|
640 | - * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
641 | - * actually REMOVE any capabilities from existing roles, it just resaves defaults roles |
|
642 | - * and ensures that they are up to date. |
|
643 | - * @param array $custom_map Optional. Can be used to send a custom map of roles and capabilities for setting them |
|
644 | - * up. Note that this should ONLY be called on activation hook or some other one-time |
|
645 | - * task otherwise the caps will be added on every request. |
|
646 | - * @return void |
|
647 | - */ |
|
648 | - public function init_role_caps($reset = false, $custom_map = array()) |
|
649 | - { |
|
650 | - $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
651 | - //first let's determine if these caps have already been set. |
|
652 | - $caps_set_before = get_option(self::option_name, array()); |
|
653 | - //if not reset, see what caps are new for each role. if they're new, add them. |
|
654 | - foreach ($caps_map as $role => $caps_for_role) { |
|
655 | - foreach ($caps_for_role as $cap) { |
|
656 | - //first check we haven't already added this cap before, or it's a reset |
|
657 | - if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
658 | - if ($this->add_cap_to_role($role, $cap)) { |
|
659 | - $caps_set_before[ $role ][] = $cap; |
|
660 | - } |
|
661 | - } |
|
662 | - } |
|
663 | - } |
|
664 | - //now let's just save the cap that has been set. |
|
665 | - update_option(self::option_name, $caps_set_before); |
|
666 | - do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
667 | - } |
|
668 | - |
|
669 | - |
|
670 | - /** |
|
671 | - * This method sets a capability on a role. Note this should only be done on activation, or if you have something |
|
672 | - * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note. |
|
673 | - * this is a wrapper for $wp_role->add_cap() |
|
674 | - * |
|
675 | - * @see wp-includes/capabilities.php |
|
676 | - * @since 4.5.0 |
|
677 | - * @param string $role A WordPress role the capability is being added to |
|
678 | - * @param string $cap The capability being added to the role |
|
679 | - * @param bool $grant Whether to grant access to this cap on this role. |
|
680 | - * @return bool |
|
681 | - */ |
|
682 | - public function add_cap_to_role($role, $cap, $grant = true) |
|
683 | - { |
|
684 | - $role_object = get_role($role); |
|
685 | - //if the role isn't available then we create it. |
|
686 | - if (! $role_object instanceof WP_Role) { |
|
687 | - //if a plugin wants to create a specific role name then they should create the role before |
|
688 | - //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
|
689 | - // - removes any `ee_` namespacing from the start of the slug. |
|
690 | - // - replaces `_` with ` ` (empty space). |
|
691 | - // - sentence case on the resulting string. |
|
692 | - $role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role))); |
|
693 | - $role_object = add_role($role, $role_label); |
|
694 | - } |
|
695 | - if ($role_object instanceof WP_Role) { |
|
696 | - $role_object->add_cap($cap, $grant); |
|
697 | - return true; |
|
698 | - } |
|
699 | - return false; |
|
700 | - } |
|
701 | - |
|
702 | - |
|
703 | - /** |
|
704 | - * Functions similarly to add_cap_to_role except removes cap from given role. |
|
705 | - * Wrapper for $wp_role->remove_cap() |
|
706 | - * |
|
707 | - * @see wp-includes/capabilities.php |
|
708 | - * @since 4.5.0 |
|
709 | - * @param string $role A WordPress role the capability is being removed from. |
|
710 | - * @param string $cap The capability being removed |
|
711 | - * @return void |
|
712 | - */ |
|
713 | - public function remove_cap_from_role($role, $cap) |
|
714 | - { |
|
715 | - $role = get_role($role); |
|
716 | - if ($role instanceof WP_Role) { |
|
717 | - $role->remove_cap($cap); |
|
718 | - } |
|
719 | - } |
|
720 | - |
|
721 | - |
|
722 | - /** |
|
723 | - * Wrapper for the native WP current_user_can() method. |
|
724 | - * This is provided as a handy method for a couple things: |
|
725 | - * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
726 | - * write those filters wherever current_user_can is called). |
|
727 | - * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
728 | - * |
|
729 | - * @since 4.5.0 |
|
730 | - * @param string $cap The cap being checked. |
|
731 | - * @param string $context The context where the current_user_can is being called from. |
|
732 | - * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
733 | - * filters. |
|
734 | - * @return bool Whether user can or not. |
|
735 | - */ |
|
736 | - public function current_user_can($cap, $context, $id = 0) |
|
737 | - { |
|
738 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
739 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
740 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
|
741 | - $id); |
|
742 | - return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
743 | - } |
|
744 | - |
|
745 | - |
|
746 | - /** |
|
747 | - * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class. |
|
748 | - * |
|
749 | - * @param int|WP_User $user Either the user_id or a WP_User object |
|
750 | - * @param string $cap The capability string being checked |
|
751 | - * @param string $context The context where the user_can is being called from (used in filters). |
|
752 | - * @param int $id Optional. Id for item where user_can is being called from ( used in map_meta_cap() |
|
753 | - * filters) |
|
754 | - * @return bool Whether user can or not. |
|
755 | - */ |
|
756 | - public function user_can($user, $cap, $context, $id = 0) |
|
757 | - { |
|
758 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
759 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
760 | - $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
|
761 | - $id); |
|
762 | - return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
763 | - } |
|
764 | - |
|
765 | - |
|
766 | - /** |
|
767 | - * Wrapper for the native WP current_user_can_for_blog() method. |
|
768 | - * This is provided as a handy method for a couple things: |
|
769 | - * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
770 | - * write those filters wherever current_user_can is called). |
|
771 | - * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
772 | - * |
|
773 | - * @since 4.5.0 |
|
774 | - * @param int $blog_id The blog id that is being checked for. |
|
775 | - * @param string $cap The cap being checked. |
|
776 | - * @param string $context The context where the current_user_can is being called from. |
|
777 | - * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
778 | - * filters. |
|
779 | - * @return bool Whether user can or not. |
|
780 | - */ |
|
781 | - public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) |
|
782 | - { |
|
783 | - $user_can = ! empty($id) |
|
784 | - ? current_user_can_for_blog($blog_id, $cap, $id) |
|
785 | - : current_user_can($blog_id, $cap); |
|
786 | - //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
787 | - $user_can = apply_filters( |
|
788 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
789 | - $user_can, |
|
790 | - $blog_id, |
|
791 | - $cap, |
|
792 | - $id |
|
793 | - ); |
|
794 | - $user_can = apply_filters( |
|
795 | - 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', |
|
796 | - $user_can, |
|
797 | - $context, |
|
798 | - $blog_id, |
|
799 | - $cap, |
|
800 | - $id |
|
801 | - ); |
|
802 | - return $user_can; |
|
803 | - } |
|
804 | - |
|
805 | - |
|
806 | - /** |
|
807 | - * This helper method just returns an array of registered EE capabilities. |
|
808 | - * Note this array is filtered. It is assumed that all available EE capabilities are assigned to the administrator |
|
809 | - * role. |
|
810 | - * |
|
811 | - * @since 4.5.0 |
|
812 | - * @param string $role If empty then the entire role/capability map is returned. Otherwise just the capabilities |
|
813 | - * for the given role are returned. |
|
814 | - * @return array |
|
815 | - */ |
|
816 | - public function get_ee_capabilities($role = 'administrator') |
|
817 | - { |
|
818 | - $capabilities = $this->_init_caps_map(); |
|
819 | - if (empty($role)) { |
|
820 | - return $capabilities; |
|
821 | - } |
|
822 | - return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
823 | - } |
|
19 | + /** |
|
20 | + * the name of the wp option used to store caps previously initialized |
|
21 | + */ |
|
22 | + const option_name = 'ee_caps_initialized'; |
|
23 | + |
|
24 | + /** |
|
25 | + * instance of EE_Capabilities object |
|
26 | + * |
|
27 | + * @var EE_Capabilities |
|
28 | + */ |
|
29 | + private static $_instance; |
|
30 | + |
|
31 | + |
|
32 | + /** |
|
33 | + * This is a map of caps that correspond to a default WP_Role. |
|
34 | + * Array is indexed by Role and values are ee capabilities. |
|
35 | + * |
|
36 | + * @since 4.5.0 |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + private $_caps_map = array(); |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * This used to hold an array of EE_Meta_Capability_Map objects that define the granular capabilities mapped to for |
|
44 | + * a user depending on context. |
|
45 | + * |
|
46 | + * @var EE_Meta_Capability_Map[] |
|
47 | + */ |
|
48 | + private $_meta_caps = array(); |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * singleton method used to instantiate class object |
|
53 | + * |
|
54 | + * @since 4.5.0 |
|
55 | + * @return EE_Capabilities |
|
56 | + */ |
|
57 | + public static function instance() |
|
58 | + { |
|
59 | + //check if instantiated, and if not do so. |
|
60 | + if (! self::$_instance instanceof EE_Capabilities) { |
|
61 | + self::$_instance = new self(); |
|
62 | + } |
|
63 | + return self::$_instance; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * private constructor |
|
69 | + * |
|
70 | + * @since 4.5.0 |
|
71 | + */ |
|
72 | + private function __construct() |
|
73 | + { |
|
74 | + if (is_admin()) { |
|
75 | + add_filter( |
|
76 | + 'FHEE__EE_Capabilities__init_caps_map__caps', |
|
77 | + array($this, 'register_additional_capabilities'), |
|
78 | + 10 |
|
79 | + ); |
|
80 | + } |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * This delays the initialization of the capabilities class until EE_System core is loaded and ready. |
|
86 | + * |
|
87 | + * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
88 | + * actually REMOVE any capabilities from existing roles, it just resaves defaults roles and |
|
89 | + * ensures that they are up to date. |
|
90 | + * @since 4.5.0 |
|
91 | + * @return void |
|
92 | + */ |
|
93 | + public function init_caps($reset = false) |
|
94 | + { |
|
95 | + /** |
|
96 | + * Note, this means that caps can only initialized on the default roles when: |
|
97 | + * - models are queryable |
|
98 | + * - All addons have been registered (which happens at plugins_loaded priority 1) |
|
99 | + * In practice, currently this method is usually called around `init`. |
|
100 | + */ |
|
101 | + if ( |
|
102 | + did_action('AHEE__EE_System__load_espresso_addons__complete') |
|
103 | + && EE_Maintenance_Mode::instance()->models_can_query() |
|
104 | + ) { |
|
105 | + $this->_caps_map = $this->_init_caps_map(); |
|
106 | + $this->init_role_caps($reset); |
|
107 | + $this->_set_meta_caps(); |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * This sets the meta caps property. |
|
114 | + * |
|
115 | + * @since 4.5.0 |
|
116 | + * @return void |
|
117 | + */ |
|
118 | + private function _set_meta_caps() |
|
119 | + { |
|
120 | + //make sure we're only ever initializing the default _meta_caps array once if it's empty. |
|
121 | + $this->_meta_caps = $this->_get_default_meta_caps_array(); |
|
122 | + $this->_meta_caps = apply_filters('FHEE__EE_Capabilities___set_meta_caps__meta_caps', $this->_meta_caps); |
|
123 | + //add filter for map_meta_caps but only if models can query. |
|
124 | + if (! has_filter('map_meta_cap', array($this, 'map_meta_caps'))) { |
|
125 | + add_filter('map_meta_cap', array($this, 'map_meta_caps'), 10, 4); |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * This builds and returns the default meta_caps array only once. |
|
132 | + * |
|
133 | + * @since 4.8.28.rc.012 |
|
134 | + * @return array |
|
135 | + * @throws \EE_Error |
|
136 | + */ |
|
137 | + private function _get_default_meta_caps_array() |
|
138 | + { |
|
139 | + static $default_meta_caps = array(); |
|
140 | + if (empty($default_meta_caps)) { |
|
141 | + $default_meta_caps = array( |
|
142 | + //edits |
|
143 | + new EE_Meta_Capability_Map_Edit( |
|
144 | + 'ee_edit_event', |
|
145 | + array('Event', 'ee_edit_published_events', 'ee_edit_others_events', 'ee_edit_private_events') |
|
146 | + ), |
|
147 | + new EE_Meta_Capability_Map_Edit( |
|
148 | + 'ee_edit_venue', |
|
149 | + array('Venue', 'ee_edit_published_venues', 'ee_edit_others_venues', 'ee_edit_private_venues') |
|
150 | + ), |
|
151 | + new EE_Meta_Capability_Map_Edit( |
|
152 | + 'ee_edit_registration', |
|
153 | + array('Registration', '', 'ee_edit_others_registrations', '') |
|
154 | + ), |
|
155 | + new EE_Meta_Capability_Map_Edit( |
|
156 | + 'ee_edit_checkin', |
|
157 | + array('Registration', '', 'ee_edit_others_checkins', '') |
|
158 | + ), |
|
159 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
160 | + 'ee_edit_message', |
|
161 | + array('Message_Template_Group', '', 'ee_edit_others_messages', 'ee_edit_global_messages') |
|
162 | + ), |
|
163 | + new EE_Meta_Capability_Map_Edit( |
|
164 | + 'ee_edit_default_ticket', |
|
165 | + array('Ticket', '', 'ee_edit_others_default_tickets', '') |
|
166 | + ), |
|
167 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
168 | + 'ee_edit_question', |
|
169 | + array('Question', '', '', 'ee_edit_system_questions') |
|
170 | + ), |
|
171 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
172 | + 'ee_edit_question_group', |
|
173 | + array('Question_Group', '', '', 'ee_edit_system_question_groups') |
|
174 | + ), |
|
175 | + new EE_Meta_Capability_Map_Edit( |
|
176 | + 'ee_edit_payment_method', |
|
177 | + array('Payment_Method', '', 'ee_edit_others_payment_methods', '') |
|
178 | + ), |
|
179 | + //reads |
|
180 | + new EE_Meta_Capability_Map_Read( |
|
181 | + 'ee_read_event', |
|
182 | + array('Event', '', 'ee_read_others_events', 'ee_read_private_events') |
|
183 | + ), |
|
184 | + new EE_Meta_Capability_Map_Read( |
|
185 | + 'ee_read_venue', |
|
186 | + array('Venue', '', 'ee_read_others_venues', 'ee_read_private_venues') |
|
187 | + ), |
|
188 | + new EE_Meta_Capability_Map_Read( |
|
189 | + 'ee_read_registration', |
|
190 | + array('Registration', '', '', 'ee_edit_others_registrations') |
|
191 | + ), |
|
192 | + new EE_Meta_Capability_Map_Read( |
|
193 | + 'ee_read_checkin', |
|
194 | + array('Registration', '', '', 'ee_read_others_checkins') |
|
195 | + ), |
|
196 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
197 | + 'ee_read_message', |
|
198 | + array('Message_Template_Group', '', 'ee_read_others_messages', 'ee_read_global_messages') |
|
199 | + ), |
|
200 | + new EE_Meta_Capability_Map_Read( |
|
201 | + 'ee_read_default_ticket', |
|
202 | + array('Ticket', '', '', 'ee_read_others_default_tickets') |
|
203 | + ), |
|
204 | + new EE_Meta_Capability_Map_Read( |
|
205 | + 'ee_read_payment_method', |
|
206 | + array('Payment_Method', '', '', 'ee_read_others_payment_methods') |
|
207 | + ), |
|
208 | + //deletes |
|
209 | + new EE_Meta_Capability_Map_Delete( |
|
210 | + 'ee_delete_event', |
|
211 | + array( |
|
212 | + 'Event', |
|
213 | + 'ee_delete_published_events', |
|
214 | + 'ee_delete_others_events', |
|
215 | + 'ee_delete_private_events', |
|
216 | + ) |
|
217 | + ), |
|
218 | + new EE_Meta_Capability_Map_Delete( |
|
219 | + 'ee_delete_venue', |
|
220 | + array( |
|
221 | + 'Venue', |
|
222 | + 'ee_delete_published_venues', |
|
223 | + 'ee_delete_others_venues', |
|
224 | + 'ee_delete_private_venues', |
|
225 | + ) |
|
226 | + ), |
|
227 | + new EE_Meta_Capability_Map_Delete( |
|
228 | + 'ee_delete_registration', |
|
229 | + array('Registration', '', 'ee_delete_others_registrations', '') |
|
230 | + ), |
|
231 | + new EE_Meta_Capability_Map_Delete( |
|
232 | + 'ee_delete_checkin', |
|
233 | + array('Registration', '', 'ee_delete_others_checkins', '') |
|
234 | + ), |
|
235 | + new EE_Meta_Capability_Map_Messages_Cap( |
|
236 | + 'ee_delete_message', |
|
237 | + array('Message_Template_Group', '', 'ee_delete_others_messages', 'ee_delete_global_messages') |
|
238 | + ), |
|
239 | + new EE_Meta_Capability_Map_Delete( |
|
240 | + 'ee_delete_default_ticket', |
|
241 | + array('Ticket', '', 'ee_delete_others_default_tickets', '') |
|
242 | + ), |
|
243 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
244 | + 'ee_delete_question', |
|
245 | + array('Question', '', '', 'delete_system_questions') |
|
246 | + ), |
|
247 | + new EE_Meta_Capability_Map_Registration_Form_Cap( |
|
248 | + 'ee_delete_question_group', |
|
249 | + array('Question_Group', '', '', 'delete_system_question_groups') |
|
250 | + ), |
|
251 | + new EE_Meta_Capability_Map_Delete( |
|
252 | + 'ee_delete_payment_method', |
|
253 | + array('Payment_Method', '', 'ee_delete_others_payment_methods', '') |
|
254 | + ), |
|
255 | + ); |
|
256 | + } |
|
257 | + return $default_meta_caps; |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
263 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
264 | + * The actual logic is carried out by implementer classes in their definition of _map_meta_caps. |
|
265 | + * |
|
266 | + * @since 4.5.0 |
|
267 | + * @see wp-includes/capabilities.php |
|
268 | + * @param array $caps actual users capabilities |
|
269 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
270 | + * @param int $user_id The user id |
|
271 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
272 | + * @return array actual users capabilities |
|
273 | + * @throws EE_Error |
|
274 | + */ |
|
275 | + public function map_meta_caps($caps, $cap, $user_id, $args) |
|
276 | + { |
|
277 | + if (did_action('AHEE__EE_System__load_espresso_addons__complete')) { |
|
278 | + //loop through our _meta_caps array |
|
279 | + foreach ($this->_meta_caps as $meta_map) { |
|
280 | + if (! $meta_map instanceof EE_Meta_Capability_Map) { |
|
281 | + continue; |
|
282 | + } |
|
283 | + // don't load models if there is no object ID in the args |
|
284 | + if(!empty($args[0])){ |
|
285 | + $meta_map->ensure_is_model(); |
|
286 | + } |
|
287 | + $caps = $meta_map->map_meta_caps($caps, $cap, $user_id, $args); |
|
288 | + } |
|
289 | + } |
|
290 | + return $caps; |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * This sets up and returns the initial capabilities map for Event Espresso |
|
296 | + * |
|
297 | + * @since 4.5.0 |
|
298 | + * @return array |
|
299 | + */ |
|
300 | + private function _init_caps_map() |
|
301 | + { |
|
302 | + $caps = array( |
|
303 | + 'administrator' => array( |
|
304 | + //basic access |
|
305 | + 'ee_read_ee', |
|
306 | + //gateways |
|
307 | + /** |
|
308 | + * note that with payment method capabilities, although we've implemented |
|
309 | + * capability mapping which will be used for accessing payment methods owned by |
|
310 | + * other users. This is not fully implemented yet in the payment method ui. |
|
311 | + * Currently only the "plural" caps are in active use. |
|
312 | + * (Specific payment method caps are in use as well). |
|
313 | + **/ |
|
314 | + 'ee_manage_gateways', |
|
315 | + 'ee_read_payment_method', |
|
316 | + 'ee_read_payment_methods', |
|
317 | + 'ee_read_others_payment_methods', |
|
318 | + 'ee_edit_payment_method', |
|
319 | + 'ee_edit_payment_methods', |
|
320 | + 'ee_edit_others_payment_methods', |
|
321 | + 'ee_delete_payment_method', |
|
322 | + 'ee_delete_payment_methods', |
|
323 | + //events |
|
324 | + 'ee_publish_events', |
|
325 | + 'ee_read_private_events', |
|
326 | + 'ee_read_others_events', |
|
327 | + 'ee_read_event', |
|
328 | + 'ee_read_events', |
|
329 | + 'ee_edit_event', |
|
330 | + 'ee_edit_events', |
|
331 | + 'ee_edit_published_events', |
|
332 | + 'ee_edit_others_events', |
|
333 | + 'ee_edit_private_events', |
|
334 | + 'ee_delete_published_events', |
|
335 | + 'ee_delete_private_events', |
|
336 | + 'ee_delete_event', |
|
337 | + 'ee_delete_events', |
|
338 | + 'ee_delete_others_events', |
|
339 | + //event categories |
|
340 | + 'ee_manage_event_categories', |
|
341 | + 'ee_edit_event_category', |
|
342 | + 'ee_delete_event_category', |
|
343 | + 'ee_assign_event_category', |
|
344 | + //venues |
|
345 | + 'ee_publish_venues', |
|
346 | + 'ee_read_venue', |
|
347 | + 'ee_read_venues', |
|
348 | + 'ee_read_others_venues', |
|
349 | + 'ee_read_private_venues', |
|
350 | + 'ee_edit_venue', |
|
351 | + 'ee_edit_venues', |
|
352 | + 'ee_edit_others_venues', |
|
353 | + 'ee_edit_published_venues', |
|
354 | + 'ee_edit_private_venues', |
|
355 | + 'ee_delete_venue', |
|
356 | + 'ee_delete_venues', |
|
357 | + 'ee_delete_others_venues', |
|
358 | + 'ee_delete_private_venues', |
|
359 | + 'ee_delete_published_venues', |
|
360 | + //venue categories |
|
361 | + 'ee_manage_venue_categories', |
|
362 | + 'ee_edit_venue_category', |
|
363 | + 'ee_delete_venue_category', |
|
364 | + 'ee_assign_venue_category', |
|
365 | + //contacts |
|
366 | + 'ee_read_contact', |
|
367 | + 'ee_read_contacts', |
|
368 | + 'ee_edit_contact', |
|
369 | + 'ee_edit_contacts', |
|
370 | + 'ee_delete_contact', |
|
371 | + 'ee_delete_contacts', |
|
372 | + //registrations |
|
373 | + 'ee_read_registration', |
|
374 | + 'ee_read_registrations', |
|
375 | + 'ee_read_others_registrations', |
|
376 | + 'ee_edit_registration', |
|
377 | + 'ee_edit_registrations', |
|
378 | + 'ee_edit_others_registrations', |
|
379 | + 'ee_delete_registration', |
|
380 | + 'ee_delete_registrations', |
|
381 | + //checkins |
|
382 | + 'ee_read_checkin', |
|
383 | + 'ee_read_others_checkins', |
|
384 | + 'ee_read_checkins', |
|
385 | + 'ee_edit_checkin', |
|
386 | + 'ee_edit_checkins', |
|
387 | + 'ee_edit_others_checkins', |
|
388 | + 'ee_delete_checkin', |
|
389 | + 'ee_delete_checkins', |
|
390 | + 'ee_delete_others_checkins', |
|
391 | + //transactions && payments |
|
392 | + 'ee_read_transaction', |
|
393 | + 'ee_read_transactions', |
|
394 | + 'ee_edit_payments', |
|
395 | + 'ee_delete_payments', |
|
396 | + //messages |
|
397 | + 'ee_read_message', |
|
398 | + 'ee_read_messages', |
|
399 | + 'ee_read_others_messages', |
|
400 | + 'ee_read_global_messages', |
|
401 | + 'ee_edit_global_messages', |
|
402 | + 'ee_edit_message', |
|
403 | + 'ee_edit_messages', |
|
404 | + 'ee_edit_others_messages', |
|
405 | + 'ee_delete_message', |
|
406 | + 'ee_delete_messages', |
|
407 | + 'ee_delete_others_messages', |
|
408 | + 'ee_delete_global_messages', |
|
409 | + 'ee_send_message', |
|
410 | + //tickets |
|
411 | + 'ee_read_default_ticket', |
|
412 | + 'ee_read_default_tickets', |
|
413 | + 'ee_read_others_default_tickets', |
|
414 | + 'ee_edit_default_ticket', |
|
415 | + 'ee_edit_default_tickets', |
|
416 | + 'ee_edit_others_default_tickets', |
|
417 | + 'ee_delete_default_ticket', |
|
418 | + 'ee_delete_default_tickets', |
|
419 | + 'ee_delete_others_default_tickets', |
|
420 | + //prices |
|
421 | + 'ee_edit_default_price', |
|
422 | + 'ee_edit_default_prices', |
|
423 | + 'ee_delete_default_price', |
|
424 | + 'ee_delete_default_prices', |
|
425 | + 'ee_edit_default_price_type', |
|
426 | + 'ee_edit_default_price_types', |
|
427 | + 'ee_delete_default_price_type', |
|
428 | + 'ee_delete_default_price_types', |
|
429 | + 'ee_read_default_prices', |
|
430 | + 'ee_read_default_price_types', |
|
431 | + //registration form |
|
432 | + 'ee_edit_question', |
|
433 | + 'ee_edit_questions', |
|
434 | + 'ee_edit_system_questions', |
|
435 | + 'ee_read_questions', |
|
436 | + 'ee_delete_question', |
|
437 | + 'ee_delete_questions', |
|
438 | + 'ee_edit_question_group', |
|
439 | + 'ee_edit_question_groups', |
|
440 | + 'ee_read_question_groups', |
|
441 | + 'ee_edit_system_question_groups', |
|
442 | + 'ee_delete_question_group', |
|
443 | + 'ee_delete_question_groups', |
|
444 | + //event_type taxonomy |
|
445 | + 'ee_assign_event_type', |
|
446 | + 'ee_manage_event_types', |
|
447 | + 'ee_edit_event_type', |
|
448 | + 'ee_delete_event_type', |
|
449 | + ), |
|
450 | + 'ee_events_administrator' => array( |
|
451 | + //core wp caps |
|
452 | + 'read', |
|
453 | + 'read_private_pages', |
|
454 | + 'read_private_posts', |
|
455 | + 'edit_users', |
|
456 | + 'edit_posts', |
|
457 | + 'edit_pages', |
|
458 | + 'edit_published_posts', |
|
459 | + 'edit_published_pages', |
|
460 | + 'edit_private_pages', |
|
461 | + 'edit_private_posts', |
|
462 | + 'edit_others_posts', |
|
463 | + 'edit_others_pages', |
|
464 | + 'publish_posts', |
|
465 | + 'publish_pages', |
|
466 | + 'delete_posts', |
|
467 | + 'delete_pages', |
|
468 | + 'delete_private_pages', |
|
469 | + 'delete_private_posts', |
|
470 | + 'delete_published_pages', |
|
471 | + 'delete_published_posts', |
|
472 | + 'delete_others_posts', |
|
473 | + 'delete_others_pages', |
|
474 | + 'manage_categories', |
|
475 | + 'manage_links', |
|
476 | + 'moderate_comments', |
|
477 | + 'unfiltered_html', |
|
478 | + 'upload_files', |
|
479 | + 'export', |
|
480 | + 'import', |
|
481 | + 'list_users', |
|
482 | + 'level_1', //required if user with this role shows up in author dropdowns |
|
483 | + //basic ee access |
|
484 | + 'ee_read_ee', |
|
485 | + //events |
|
486 | + 'ee_publish_events', |
|
487 | + 'ee_read_private_events', |
|
488 | + 'ee_read_others_events', |
|
489 | + 'ee_read_event', |
|
490 | + 'ee_read_events', |
|
491 | + 'ee_edit_event', |
|
492 | + 'ee_edit_events', |
|
493 | + 'ee_edit_published_events', |
|
494 | + 'ee_edit_others_events', |
|
495 | + 'ee_edit_private_events', |
|
496 | + 'ee_delete_published_events', |
|
497 | + 'ee_delete_private_events', |
|
498 | + 'ee_delete_event', |
|
499 | + 'ee_delete_events', |
|
500 | + 'ee_delete_others_events', |
|
501 | + //event categories |
|
502 | + 'ee_manage_event_categories', |
|
503 | + 'ee_edit_event_category', |
|
504 | + 'ee_delete_event_category', |
|
505 | + 'ee_assign_event_category', |
|
506 | + //venues |
|
507 | + 'ee_publish_venues', |
|
508 | + 'ee_read_venue', |
|
509 | + 'ee_read_venues', |
|
510 | + 'ee_read_others_venues', |
|
511 | + 'ee_read_private_venues', |
|
512 | + 'ee_edit_venue', |
|
513 | + 'ee_edit_venues', |
|
514 | + 'ee_edit_others_venues', |
|
515 | + 'ee_edit_published_venues', |
|
516 | + 'ee_edit_private_venues', |
|
517 | + 'ee_delete_venue', |
|
518 | + 'ee_delete_venues', |
|
519 | + 'ee_delete_others_venues', |
|
520 | + 'ee_delete_private_venues', |
|
521 | + 'ee_delete_published_venues', |
|
522 | + //venue categories |
|
523 | + 'ee_manage_venue_categories', |
|
524 | + 'ee_edit_venue_category', |
|
525 | + 'ee_delete_venue_category', |
|
526 | + 'ee_assign_venue_category', |
|
527 | + //contacts |
|
528 | + 'ee_read_contact', |
|
529 | + 'ee_read_contacts', |
|
530 | + 'ee_edit_contact', |
|
531 | + 'ee_edit_contacts', |
|
532 | + 'ee_delete_contact', |
|
533 | + 'ee_delete_contacts', |
|
534 | + //registrations |
|
535 | + 'ee_read_registration', |
|
536 | + 'ee_read_registrations', |
|
537 | + 'ee_read_others_registrations', |
|
538 | + 'ee_edit_registration', |
|
539 | + 'ee_edit_registrations', |
|
540 | + 'ee_edit_others_registrations', |
|
541 | + 'ee_delete_registration', |
|
542 | + 'ee_delete_registrations', |
|
543 | + //checkins |
|
544 | + 'ee_read_checkin', |
|
545 | + 'ee_read_others_checkins', |
|
546 | + 'ee_read_checkins', |
|
547 | + 'ee_edit_checkin', |
|
548 | + 'ee_edit_checkins', |
|
549 | + 'ee_edit_others_checkins', |
|
550 | + 'ee_delete_checkin', |
|
551 | + 'ee_delete_checkins', |
|
552 | + 'ee_delete_others_checkins', |
|
553 | + //transactions && payments |
|
554 | + 'ee_read_transaction', |
|
555 | + 'ee_read_transactions', |
|
556 | + 'ee_edit_payments', |
|
557 | + 'ee_delete_payments', |
|
558 | + //messages |
|
559 | + 'ee_read_message', |
|
560 | + 'ee_read_messages', |
|
561 | + 'ee_read_others_messages', |
|
562 | + 'ee_read_global_messages', |
|
563 | + 'ee_edit_global_messages', |
|
564 | + 'ee_edit_message', |
|
565 | + 'ee_edit_messages', |
|
566 | + 'ee_edit_others_messages', |
|
567 | + 'ee_delete_message', |
|
568 | + 'ee_delete_messages', |
|
569 | + 'ee_delete_others_messages', |
|
570 | + 'ee_delete_global_messages', |
|
571 | + 'ee_send_message', |
|
572 | + //tickets |
|
573 | + 'ee_read_default_ticket', |
|
574 | + 'ee_read_default_tickets', |
|
575 | + 'ee_read_others_default_tickets', |
|
576 | + 'ee_edit_default_ticket', |
|
577 | + 'ee_edit_default_tickets', |
|
578 | + 'ee_edit_others_default_tickets', |
|
579 | + 'ee_delete_default_ticket', |
|
580 | + 'ee_delete_default_tickets', |
|
581 | + 'ee_delete_others_default_tickets', |
|
582 | + //prices |
|
583 | + 'ee_edit_default_price', |
|
584 | + 'ee_edit_default_prices', |
|
585 | + 'ee_delete_default_price', |
|
586 | + 'ee_delete_default_prices', |
|
587 | + 'ee_edit_default_price_type', |
|
588 | + 'ee_edit_default_price_types', |
|
589 | + 'ee_delete_default_price_type', |
|
590 | + 'ee_delete_default_price_types', |
|
591 | + 'ee_read_default_prices', |
|
592 | + 'ee_read_default_price_types', |
|
593 | + //registration form |
|
594 | + 'ee_edit_question', |
|
595 | + 'ee_edit_questions', |
|
596 | + 'ee_edit_system_questions', |
|
597 | + 'ee_read_questions', |
|
598 | + 'ee_delete_question', |
|
599 | + 'ee_delete_questions', |
|
600 | + 'ee_edit_question_group', |
|
601 | + 'ee_edit_question_groups', |
|
602 | + 'ee_read_question_groups', |
|
603 | + 'ee_edit_system_question_groups', |
|
604 | + 'ee_delete_question_group', |
|
605 | + 'ee_delete_question_groups', |
|
606 | + //event_type taxonomy |
|
607 | + 'ee_assign_event_type', |
|
608 | + 'ee_manage_event_types', |
|
609 | + 'ee_edit_event_type', |
|
610 | + 'ee_delete_event_type', |
|
611 | + ), |
|
612 | + ); |
|
613 | + $caps = apply_filters('FHEE__EE_Capabilities__init_caps_map__caps', $caps); |
|
614 | + return $caps; |
|
615 | + } |
|
616 | + |
|
617 | + |
|
618 | + /** |
|
619 | + * Callback for FHEE__EE_Capabilities__init_caps_map__caps that is used for registering additional core |
|
620 | + * capabilities that get added. |
|
621 | + * This is typically done for more dynamic cap additions such as what is registered via the |
|
622 | + * `EE_Payment_Method_Manager` |
|
623 | + * |
|
624 | + * @param array $caps The existing $role=>$capability array. |
|
625 | + * @return array. |
|
626 | + */ |
|
627 | + public function register_additional_capabilities($caps) |
|
628 | + { |
|
629 | + //take care of dynamic capabilities for payment methods |
|
630 | + EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
|
631 | + $caps = EE_Payment_Method_Manager::instance()->add_payment_method_caps($caps); |
|
632 | + return $caps; |
|
633 | + } |
|
634 | + |
|
635 | + |
|
636 | + /** |
|
637 | + * This adds all the default caps to roles as registered in the _caps_map property. |
|
638 | + * |
|
639 | + * @since 4.5.0 |
|
640 | + * @param bool $reset allows for resetting the default capabilities saved on roles. Note that this doesn't |
|
641 | + * actually REMOVE any capabilities from existing roles, it just resaves defaults roles |
|
642 | + * and ensures that they are up to date. |
|
643 | + * @param array $custom_map Optional. Can be used to send a custom map of roles and capabilities for setting them |
|
644 | + * up. Note that this should ONLY be called on activation hook or some other one-time |
|
645 | + * task otherwise the caps will be added on every request. |
|
646 | + * @return void |
|
647 | + */ |
|
648 | + public function init_role_caps($reset = false, $custom_map = array()) |
|
649 | + { |
|
650 | + $caps_map = empty($custom_map) ? $this->_caps_map : $custom_map; |
|
651 | + //first let's determine if these caps have already been set. |
|
652 | + $caps_set_before = get_option(self::option_name, array()); |
|
653 | + //if not reset, see what caps are new for each role. if they're new, add them. |
|
654 | + foreach ($caps_map as $role => $caps_for_role) { |
|
655 | + foreach ($caps_for_role as $cap) { |
|
656 | + //first check we haven't already added this cap before, or it's a reset |
|
657 | + if ($reset || ! isset($caps_set_before[ $role ]) || ! in_array($cap, $caps_set_before[ $role ])) { |
|
658 | + if ($this->add_cap_to_role($role, $cap)) { |
|
659 | + $caps_set_before[ $role ][] = $cap; |
|
660 | + } |
|
661 | + } |
|
662 | + } |
|
663 | + } |
|
664 | + //now let's just save the cap that has been set. |
|
665 | + update_option(self::option_name, $caps_set_before); |
|
666 | + do_action('AHEE__EE_Capabilities__init_role_caps__complete', $caps_set_before); |
|
667 | + } |
|
668 | + |
|
669 | + |
|
670 | + /** |
|
671 | + * This method sets a capability on a role. Note this should only be done on activation, or if you have something |
|
672 | + * specific to prevent the cap from being added on every page load (adding caps are persistent to the db). Note. |
|
673 | + * this is a wrapper for $wp_role->add_cap() |
|
674 | + * |
|
675 | + * @see wp-includes/capabilities.php |
|
676 | + * @since 4.5.0 |
|
677 | + * @param string $role A WordPress role the capability is being added to |
|
678 | + * @param string $cap The capability being added to the role |
|
679 | + * @param bool $grant Whether to grant access to this cap on this role. |
|
680 | + * @return bool |
|
681 | + */ |
|
682 | + public function add_cap_to_role($role, $cap, $grant = true) |
|
683 | + { |
|
684 | + $role_object = get_role($role); |
|
685 | + //if the role isn't available then we create it. |
|
686 | + if (! $role_object instanceof WP_Role) { |
|
687 | + //if a plugin wants to create a specific role name then they should create the role before |
|
688 | + //EE_Capabilities does. Otherwise this function will create the role name from the slug: |
|
689 | + // - removes any `ee_` namespacing from the start of the slug. |
|
690 | + // - replaces `_` with ` ` (empty space). |
|
691 | + // - sentence case on the resulting string. |
|
692 | + $role_label = ucwords(str_replace('_', ' ', str_replace('ee_', '', $role))); |
|
693 | + $role_object = add_role($role, $role_label); |
|
694 | + } |
|
695 | + if ($role_object instanceof WP_Role) { |
|
696 | + $role_object->add_cap($cap, $grant); |
|
697 | + return true; |
|
698 | + } |
|
699 | + return false; |
|
700 | + } |
|
701 | + |
|
702 | + |
|
703 | + /** |
|
704 | + * Functions similarly to add_cap_to_role except removes cap from given role. |
|
705 | + * Wrapper for $wp_role->remove_cap() |
|
706 | + * |
|
707 | + * @see wp-includes/capabilities.php |
|
708 | + * @since 4.5.0 |
|
709 | + * @param string $role A WordPress role the capability is being removed from. |
|
710 | + * @param string $cap The capability being removed |
|
711 | + * @return void |
|
712 | + */ |
|
713 | + public function remove_cap_from_role($role, $cap) |
|
714 | + { |
|
715 | + $role = get_role($role); |
|
716 | + if ($role instanceof WP_Role) { |
|
717 | + $role->remove_cap($cap); |
|
718 | + } |
|
719 | + } |
|
720 | + |
|
721 | + |
|
722 | + /** |
|
723 | + * Wrapper for the native WP current_user_can() method. |
|
724 | + * This is provided as a handy method for a couple things: |
|
725 | + * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
726 | + * write those filters wherever current_user_can is called). |
|
727 | + * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
728 | + * |
|
729 | + * @since 4.5.0 |
|
730 | + * @param string $cap The cap being checked. |
|
731 | + * @param string $context The context where the current_user_can is being called from. |
|
732 | + * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
733 | + * filters. |
|
734 | + * @return bool Whether user can or not. |
|
735 | + */ |
|
736 | + public function current_user_can($cap, $context, $id = 0) |
|
737 | + { |
|
738 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
739 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap__' . $context, $cap, $id); |
|
740 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__current_user_can__cap', $filtered_cap, $context, $cap, |
|
741 | + $id); |
|
742 | + return ! empty($id) ? current_user_can($filtered_cap, $id) : current_user_can($filtered_cap); |
|
743 | + } |
|
744 | + |
|
745 | + |
|
746 | + /** |
|
747 | + * This is a wrapper for the WP user_can() function and follows the same style as the other wrappers in this class. |
|
748 | + * |
|
749 | + * @param int|WP_User $user Either the user_id or a WP_User object |
|
750 | + * @param string $cap The capability string being checked |
|
751 | + * @param string $context The context where the user_can is being called from (used in filters). |
|
752 | + * @param int $id Optional. Id for item where user_can is being called from ( used in map_meta_cap() |
|
753 | + * filters) |
|
754 | + * @return bool Whether user can or not. |
|
755 | + */ |
|
756 | + public function user_can($user, $cap, $context, $id = 0) |
|
757 | + { |
|
758 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
759 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap__' . $context, $cap, $user, $id); |
|
760 | + $filtered_cap = apply_filters('FHEE__EE_Capabilities__user_can__cap', $filtered_cap, $context, $cap, $user, |
|
761 | + $id); |
|
762 | + return ! empty($id) ? user_can($user, $filtered_cap, $id) : user_can($user, $filtered_cap); |
|
763 | + } |
|
764 | + |
|
765 | + |
|
766 | + /** |
|
767 | + * Wrapper for the native WP current_user_can_for_blog() method. |
|
768 | + * This is provided as a handy method for a couple things: |
|
769 | + * 1. Using the context string it allows for targeted filtering by addons for a specific check (without having to |
|
770 | + * write those filters wherever current_user_can is called). |
|
771 | + * 2. Explicit passing of $id from a given context ( useful in the cases of map_meta_cap filters ) |
|
772 | + * |
|
773 | + * @since 4.5.0 |
|
774 | + * @param int $blog_id The blog id that is being checked for. |
|
775 | + * @param string $cap The cap being checked. |
|
776 | + * @param string $context The context where the current_user_can is being called from. |
|
777 | + * @param int $id Optional. Id for item where current_user_can is being called from (used in map_meta_cap() |
|
778 | + * filters. |
|
779 | + * @return bool Whether user can or not. |
|
780 | + */ |
|
781 | + public function current_user_can_for_blog($blog_id, $cap, $context, $id = 0) |
|
782 | + { |
|
783 | + $user_can = ! empty($id) |
|
784 | + ? current_user_can_for_blog($blog_id, $cap, $id) |
|
785 | + : current_user_can($blog_id, $cap); |
|
786 | + //apply filters (both a global on just the cap, and context specific. Global overrides context specific) |
|
787 | + $user_can = apply_filters( |
|
788 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can__' . $context, |
|
789 | + $user_can, |
|
790 | + $blog_id, |
|
791 | + $cap, |
|
792 | + $id |
|
793 | + ); |
|
794 | + $user_can = apply_filters( |
|
795 | + 'FHEE__EE_Capabilities__current_user_can_for_blog__user_can', |
|
796 | + $user_can, |
|
797 | + $context, |
|
798 | + $blog_id, |
|
799 | + $cap, |
|
800 | + $id |
|
801 | + ); |
|
802 | + return $user_can; |
|
803 | + } |
|
804 | + |
|
805 | + |
|
806 | + /** |
|
807 | + * This helper method just returns an array of registered EE capabilities. |
|
808 | + * Note this array is filtered. It is assumed that all available EE capabilities are assigned to the administrator |
|
809 | + * role. |
|
810 | + * |
|
811 | + * @since 4.5.0 |
|
812 | + * @param string $role If empty then the entire role/capability map is returned. Otherwise just the capabilities |
|
813 | + * for the given role are returned. |
|
814 | + * @return array |
|
815 | + */ |
|
816 | + public function get_ee_capabilities($role = 'administrator') |
|
817 | + { |
|
818 | + $capabilities = $this->_init_caps_map(); |
|
819 | + if (empty($role)) { |
|
820 | + return $capabilities; |
|
821 | + } |
|
822 | + return isset($capabilities[ $role ]) ? $capabilities[ $role ] : array(); |
|
823 | + } |
|
824 | 824 | } |
825 | 825 | |
826 | 826 | |
@@ -837,134 +837,134 @@ discard block |
||
837 | 837 | abstract class EE_Meta_Capability_Map |
838 | 838 | { |
839 | 839 | |
840 | - public $meta_cap; |
|
841 | - |
|
842 | - /** |
|
843 | - * @var EEM_Base |
|
844 | - */ |
|
845 | - protected $_model; |
|
846 | - |
|
847 | - protected $_model_name; |
|
848 | - |
|
849 | - public $published_cap = ''; |
|
850 | - |
|
851 | - public $others_cap = ''; |
|
852 | - |
|
853 | - public $private_cap = ''; |
|
854 | - |
|
855 | - |
|
856 | - /** |
|
857 | - * constructor. |
|
858 | - * Receives the setup arguments for the map. |
|
859 | - * |
|
860 | - * @since 4.5.0 |
|
861 | - * @param string $meta_cap What meta capability is this mapping. |
|
862 | - * @param array $map_values array { |
|
863 | - * //array of values that MUST match a count of 4. It's okay to send an empty string |
|
864 | - * for capabilities that don't get mapped to. |
|
865 | - * @type $map_values [0] string A string representing the model name. Required. String's |
|
866 | - * should always be used when Menu Maps are registered via the |
|
867 | - * plugin API as models are not allowed to be instantiated when |
|
868 | - * in maintenance mode 2 (migrations). |
|
869 | - * @type $map_values [1] string represents the capability used for published. Optional. |
|
870 | - * @type $map_values [2] string represents the capability used for "others". Optional. |
|
871 | - * @type $map_values [3] string represents the capability used for private. Optional. |
|
872 | - * } |
|
873 | - * @throws EE_Error |
|
874 | - */ |
|
875 | - public function __construct($meta_cap, $map_values) |
|
876 | - { |
|
877 | - $this->meta_cap = $meta_cap; |
|
878 | - //verify there are four args in the $map_values array; |
|
879 | - if (count($map_values) !== 4) { |
|
880 | - throw new EE_Error( |
|
881 | - sprintf( |
|
882 | - __( |
|
883 | - 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
|
884 | - 'event_espresso' |
|
885 | - ), |
|
886 | - '<br>' . print_r($map_values, true) |
|
887 | - ) |
|
888 | - ); |
|
889 | - } |
|
890 | - //set properties |
|
891 | - $this->_model = null; |
|
892 | - $this->_model_name = $map_values[0]; |
|
893 | - $this->published_cap = (string)$map_values[1]; |
|
894 | - $this->others_cap = (string)$map_values[2]; |
|
895 | - $this->private_cap = (string)$map_values[3]; |
|
896 | - } |
|
897 | - |
|
898 | - /** |
|
899 | - * Makes it so this object stops filtering caps |
|
900 | - */ |
|
901 | - public function remove_filters() |
|
902 | - { |
|
903 | - remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
904 | - } |
|
905 | - |
|
906 | - |
|
907 | - /** |
|
908 | - * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class |
|
909 | - * |
|
910 | - * @since 4.5.0 |
|
911 | - * @throws EE_Error |
|
912 | - * @return void |
|
913 | - */ |
|
914 | - public function ensure_is_model() |
|
915 | - { |
|
916 | - //is it already instantiated? |
|
917 | - if ($this->_model instanceof EEM_Base) { |
|
918 | - return; |
|
919 | - } |
|
920 | - //ensure model name is string |
|
921 | - $this->_model_name = (string)$this->_model_name; |
|
922 | - //error proof if the name has EEM in it |
|
923 | - $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
924 | - $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
925 | - if (! $this->_model instanceof EEM_Base) { |
|
926 | - throw new EE_Error( |
|
927 | - sprintf( |
|
928 | - __( |
|
929 | - 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', |
|
930 | - 'event_espresso' |
|
931 | - ), |
|
932 | - get_class($this), |
|
933 | - $this->_model |
|
934 | - ) |
|
935 | - ); |
|
936 | - } |
|
937 | - } |
|
938 | - |
|
939 | - |
|
940 | - /** |
|
941 | - * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
|
942 | - * @since 4.6.x |
|
943 | - * @param $caps |
|
944 | - * @param $cap |
|
945 | - * @param $user_id |
|
946 | - * @param $args |
|
947 | - * @return array |
|
948 | - */ |
|
949 | - public function map_meta_caps($caps, $cap, $user_id, $args) |
|
950 | - { |
|
951 | - return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
952 | - } |
|
953 | - |
|
954 | - |
|
955 | - /** |
|
956 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
957 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
958 | - * |
|
959 | - * @since 4.5.0 |
|
960 | - * @see wp-includes/capabilities.php |
|
961 | - * @param array $caps actual users capabilities |
|
962 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
963 | - * @param int $user_id The user id |
|
964 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
965 | - * @return array actual users capabilities |
|
966 | - */ |
|
967 | - abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
840 | + public $meta_cap; |
|
841 | + |
|
842 | + /** |
|
843 | + * @var EEM_Base |
|
844 | + */ |
|
845 | + protected $_model; |
|
846 | + |
|
847 | + protected $_model_name; |
|
848 | + |
|
849 | + public $published_cap = ''; |
|
850 | + |
|
851 | + public $others_cap = ''; |
|
852 | + |
|
853 | + public $private_cap = ''; |
|
854 | + |
|
855 | + |
|
856 | + /** |
|
857 | + * constructor. |
|
858 | + * Receives the setup arguments for the map. |
|
859 | + * |
|
860 | + * @since 4.5.0 |
|
861 | + * @param string $meta_cap What meta capability is this mapping. |
|
862 | + * @param array $map_values array { |
|
863 | + * //array of values that MUST match a count of 4. It's okay to send an empty string |
|
864 | + * for capabilities that don't get mapped to. |
|
865 | + * @type $map_values [0] string A string representing the model name. Required. String's |
|
866 | + * should always be used when Menu Maps are registered via the |
|
867 | + * plugin API as models are not allowed to be instantiated when |
|
868 | + * in maintenance mode 2 (migrations). |
|
869 | + * @type $map_values [1] string represents the capability used for published. Optional. |
|
870 | + * @type $map_values [2] string represents the capability used for "others". Optional. |
|
871 | + * @type $map_values [3] string represents the capability used for private. Optional. |
|
872 | + * } |
|
873 | + * @throws EE_Error |
|
874 | + */ |
|
875 | + public function __construct($meta_cap, $map_values) |
|
876 | + { |
|
877 | + $this->meta_cap = $meta_cap; |
|
878 | + //verify there are four args in the $map_values array; |
|
879 | + if (count($map_values) !== 4) { |
|
880 | + throw new EE_Error( |
|
881 | + sprintf( |
|
882 | + __( |
|
883 | + 'Incoming $map_values array should have a count of four values in it. This is what was given: %s', |
|
884 | + 'event_espresso' |
|
885 | + ), |
|
886 | + '<br>' . print_r($map_values, true) |
|
887 | + ) |
|
888 | + ); |
|
889 | + } |
|
890 | + //set properties |
|
891 | + $this->_model = null; |
|
892 | + $this->_model_name = $map_values[0]; |
|
893 | + $this->published_cap = (string)$map_values[1]; |
|
894 | + $this->others_cap = (string)$map_values[2]; |
|
895 | + $this->private_cap = (string)$map_values[3]; |
|
896 | + } |
|
897 | + |
|
898 | + /** |
|
899 | + * Makes it so this object stops filtering caps |
|
900 | + */ |
|
901 | + public function remove_filters() |
|
902 | + { |
|
903 | + remove_filter('map_meta_cap', array($this, 'map_meta_caps'), 10); |
|
904 | + } |
|
905 | + |
|
906 | + |
|
907 | + /** |
|
908 | + * This method ensures that the $model property is converted from the model name string to a proper EEM_Base class |
|
909 | + * |
|
910 | + * @since 4.5.0 |
|
911 | + * @throws EE_Error |
|
912 | + * @return void |
|
913 | + */ |
|
914 | + public function ensure_is_model() |
|
915 | + { |
|
916 | + //is it already instantiated? |
|
917 | + if ($this->_model instanceof EEM_Base) { |
|
918 | + return; |
|
919 | + } |
|
920 | + //ensure model name is string |
|
921 | + $this->_model_name = (string)$this->_model_name; |
|
922 | + //error proof if the name has EEM in it |
|
923 | + $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
924 | + $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
925 | + if (! $this->_model instanceof EEM_Base) { |
|
926 | + throw new EE_Error( |
|
927 | + sprintf( |
|
928 | + __( |
|
929 | + 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', |
|
930 | + 'event_espresso' |
|
931 | + ), |
|
932 | + get_class($this), |
|
933 | + $this->_model |
|
934 | + ) |
|
935 | + ); |
|
936 | + } |
|
937 | + } |
|
938 | + |
|
939 | + |
|
940 | + /** |
|
941 | + * @see EE_Meta_Capability_Map::_map_meta_caps() for docs on params. |
|
942 | + * @since 4.6.x |
|
943 | + * @param $caps |
|
944 | + * @param $cap |
|
945 | + * @param $user_id |
|
946 | + * @param $args |
|
947 | + * @return array |
|
948 | + */ |
|
949 | + public function map_meta_caps($caps, $cap, $user_id, $args) |
|
950 | + { |
|
951 | + return $this->_map_meta_caps($caps, $cap, $user_id, $args); |
|
952 | + } |
|
953 | + |
|
954 | + |
|
955 | + /** |
|
956 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
957 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
958 | + * |
|
959 | + * @since 4.5.0 |
|
960 | + * @see wp-includes/capabilities.php |
|
961 | + * @param array $caps actual users capabilities |
|
962 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
963 | + * @param int $user_id The user id |
|
964 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
965 | + * @return array actual users capabilities |
|
966 | + */ |
|
967 | + abstract protected function _map_meta_caps($caps, $cap, $user_id, $args); |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | |
@@ -980,81 +980,81 @@ discard block |
||
980 | 980 | class EE_Meta_Capability_Map_Edit extends EE_Meta_Capability_Map |
981 | 981 | { |
982 | 982 | |
983 | - /** |
|
984 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
985 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
986 | - * |
|
987 | - * @since 4.5.0 |
|
988 | - * @see wp-includes/capabilities.php |
|
989 | - * @param array $caps actual users capabilities |
|
990 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
991 | - * @param int $user_id The user id |
|
992 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
993 | - * @return array actual users capabilities |
|
994 | - */ |
|
995 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
996 | - { |
|
997 | - //only process if we're checking our mapped_cap |
|
998 | - if ($cap !== $this->meta_cap) { |
|
999 | - return $caps; |
|
1000 | - } |
|
1001 | - |
|
1002 | - //cast $user_id to int for later explicit comparisons |
|
1003 | - $user_id = (int) $user_id; |
|
1004 | - |
|
1005 | - /** @var EE_Base_Class $obj */ |
|
1006 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1007 | - //if no obj then let's just do cap |
|
1008 | - if (! $obj instanceof EE_Base_Class) { |
|
1009 | - $caps[] = $cap; |
|
1010 | - return $caps; |
|
1011 | - } |
|
1012 | - if ($obj instanceof EE_CPT_Base) { |
|
1013 | - //if the item author is set and the user is the author... |
|
1014 | - if ($obj->wp_user() && $user_id === $obj->wp_user()) { |
|
1015 | - if (empty($this->published_cap)) { |
|
1016 | - $caps[] = $cap; |
|
1017 | - } else { |
|
1018 | - //if obj is published... |
|
1019 | - if ($obj->status() === 'publish') { |
|
1020 | - $caps[] = $this->published_cap; |
|
1021 | - } else { |
|
1022 | - $caps[] = $cap; |
|
1023 | - } |
|
1024 | - } |
|
1025 | - } else { |
|
1026 | - //the user is trying to edit someone else's obj |
|
1027 | - if (! empty($this->others_cap)) { |
|
1028 | - $caps[] = $this->others_cap; |
|
1029 | - } |
|
1030 | - if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1031 | - $caps[] = $this->published_cap; |
|
1032 | - } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1033 | - $caps[] = $this->private_cap; |
|
1034 | - } |
|
1035 | - } |
|
1036 | - } else { |
|
1037 | - //not a cpt object so handled differently |
|
1038 | - $has_cap = false; |
|
1039 | - try { |
|
1040 | - $has_cap = method_exists($obj, 'wp_user') |
|
1041 | - && $obj->wp_user() |
|
1042 | - && $obj->wp_user() === $user_id; |
|
1043 | - } catch (Exception $e) { |
|
1044 | - if (WP_DEBUG) { |
|
1045 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1046 | - } |
|
1047 | - } |
|
1048 | - if ($has_cap) { |
|
1049 | - $caps[] = $cap; |
|
1050 | - } else { |
|
1051 | - if (! empty($this->others_cap)) { |
|
1052 | - $caps[] = $this->others_cap; |
|
1053 | - } |
|
1054 | - } |
|
1055 | - } |
|
1056 | - return $caps; |
|
1057 | - } |
|
983 | + /** |
|
984 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
985 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
986 | + * |
|
987 | + * @since 4.5.0 |
|
988 | + * @see wp-includes/capabilities.php |
|
989 | + * @param array $caps actual users capabilities |
|
990 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
991 | + * @param int $user_id The user id |
|
992 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
993 | + * @return array actual users capabilities |
|
994 | + */ |
|
995 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
996 | + { |
|
997 | + //only process if we're checking our mapped_cap |
|
998 | + if ($cap !== $this->meta_cap) { |
|
999 | + return $caps; |
|
1000 | + } |
|
1001 | + |
|
1002 | + //cast $user_id to int for later explicit comparisons |
|
1003 | + $user_id = (int) $user_id; |
|
1004 | + |
|
1005 | + /** @var EE_Base_Class $obj */ |
|
1006 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1007 | + //if no obj then let's just do cap |
|
1008 | + if (! $obj instanceof EE_Base_Class) { |
|
1009 | + $caps[] = $cap; |
|
1010 | + return $caps; |
|
1011 | + } |
|
1012 | + if ($obj instanceof EE_CPT_Base) { |
|
1013 | + //if the item author is set and the user is the author... |
|
1014 | + if ($obj->wp_user() && $user_id === $obj->wp_user()) { |
|
1015 | + if (empty($this->published_cap)) { |
|
1016 | + $caps[] = $cap; |
|
1017 | + } else { |
|
1018 | + //if obj is published... |
|
1019 | + if ($obj->status() === 'publish') { |
|
1020 | + $caps[] = $this->published_cap; |
|
1021 | + } else { |
|
1022 | + $caps[] = $cap; |
|
1023 | + } |
|
1024 | + } |
|
1025 | + } else { |
|
1026 | + //the user is trying to edit someone else's obj |
|
1027 | + if (! empty($this->others_cap)) { |
|
1028 | + $caps[] = $this->others_cap; |
|
1029 | + } |
|
1030 | + if (! empty($this->published_cap) && $obj->status() === 'publish') { |
|
1031 | + $caps[] = $this->published_cap; |
|
1032 | + } elseif (! empty($this->private_cap) && $obj->status() === 'private') { |
|
1033 | + $caps[] = $this->private_cap; |
|
1034 | + } |
|
1035 | + } |
|
1036 | + } else { |
|
1037 | + //not a cpt object so handled differently |
|
1038 | + $has_cap = false; |
|
1039 | + try { |
|
1040 | + $has_cap = method_exists($obj, 'wp_user') |
|
1041 | + && $obj->wp_user() |
|
1042 | + && $obj->wp_user() === $user_id; |
|
1043 | + } catch (Exception $e) { |
|
1044 | + if (WP_DEBUG) { |
|
1045 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1046 | + } |
|
1047 | + } |
|
1048 | + if ($has_cap) { |
|
1049 | + $caps[] = $cap; |
|
1050 | + } else { |
|
1051 | + if (! empty($this->others_cap)) { |
|
1052 | + $caps[] = $this->others_cap; |
|
1053 | + } |
|
1054 | + } |
|
1055 | + } |
|
1056 | + return $caps; |
|
1057 | + } |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | 1060 | |
@@ -1071,22 +1071,22 @@ discard block |
||
1071 | 1071 | class EE_Meta_Capability_Map_Delete extends EE_Meta_Capability_Map_Edit |
1072 | 1072 | { |
1073 | 1073 | |
1074 | - /** |
|
1075 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1076 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1077 | - * |
|
1078 | - * @since 4.5.0 |
|
1079 | - * @see wp-includes/capabilities.php |
|
1080 | - * @param array $caps actual users capabilities |
|
1081 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1082 | - * @param int $user_id The user id |
|
1083 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1084 | - * @return array actual users capabilities |
|
1085 | - */ |
|
1086 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1087 | - { |
|
1088 | - return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
1089 | - } |
|
1074 | + /** |
|
1075 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1076 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1077 | + * |
|
1078 | + * @since 4.5.0 |
|
1079 | + * @see wp-includes/capabilities.php |
|
1080 | + * @param array $caps actual users capabilities |
|
1081 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1082 | + * @param int $user_id The user id |
|
1083 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1084 | + * @return array actual users capabilities |
|
1085 | + */ |
|
1086 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1087 | + { |
|
1088 | + return parent::_map_meta_caps($caps, $cap, $user_id, $args); |
|
1089 | + } |
|
1090 | 1090 | } |
1091 | 1091 | |
1092 | 1092 | |
@@ -1102,73 +1102,73 @@ discard block |
||
1102 | 1102 | class EE_Meta_Capability_Map_Read extends EE_Meta_Capability_Map |
1103 | 1103 | { |
1104 | 1104 | |
1105 | - /** |
|
1106 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1107 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1108 | - * |
|
1109 | - * @since 4.5.0 |
|
1110 | - * @see wp-includes/capabilities.php |
|
1111 | - * @param array $caps actual users capabilities |
|
1112 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1113 | - * @param int $user_id The user id |
|
1114 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1115 | - * @return array actual users capabilities |
|
1116 | - */ |
|
1117 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1118 | - { |
|
1119 | - //only process if we're checking our mapped cap; |
|
1120 | - if ($cap !== $this->meta_cap) { |
|
1121 | - return $caps; |
|
1122 | - } |
|
1123 | - |
|
1124 | - //cast $user_id to int for later explicit comparisons |
|
1125 | - $user_id = (int) $user_id; |
|
1126 | - |
|
1127 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1128 | - //if no obj then let's just do cap |
|
1129 | - if (! $obj instanceof EE_Base_Class) { |
|
1130 | - $caps[] = $cap; |
|
1131 | - return $caps; |
|
1132 | - } |
|
1133 | - if ($obj instanceof EE_CPT_Base) { |
|
1134 | - $status_obj = get_post_status_object($obj->status()); |
|
1135 | - if ($status_obj->public) { |
|
1136 | - $caps[] = $cap; |
|
1137 | - return $caps; |
|
1138 | - } |
|
1139 | - //if the item author is set and the user is the author... |
|
1140 | - if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1141 | - $caps[] = $cap; |
|
1142 | - } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
1143 | - //the user is trying to view someone else's obj |
|
1144 | - $caps[] = $this->private_cap; |
|
1145 | - } elseif (! empty($this->others_cap)) { |
|
1146 | - $caps[] = $this->others_cap; |
|
1147 | - } else { |
|
1148 | - $caps[] = $cap; |
|
1149 | - } |
|
1150 | - } else { |
|
1151 | - //not a cpt object so handled differently |
|
1152 | - $has_cap = false; |
|
1153 | - try { |
|
1154 | - $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $obj->wp_user() === $user_id; |
|
1155 | - } catch (Exception $e) { |
|
1156 | - if (WP_DEBUG) { |
|
1157 | - EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1158 | - } |
|
1159 | - } |
|
1160 | - if ($has_cap) { |
|
1161 | - $caps[] = $cap; |
|
1162 | - } elseif (! empty($this->private_cap)) { |
|
1163 | - $caps[] = $this->private_cap; |
|
1164 | - } elseif (! empty($this->others_cap)) { |
|
1165 | - $caps[] = $this->others_cap; |
|
1166 | - } else { |
|
1167 | - $caps[] = $cap; |
|
1168 | - } |
|
1169 | - } |
|
1170 | - return $caps; |
|
1171 | - } |
|
1105 | + /** |
|
1106 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1107 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1108 | + * |
|
1109 | + * @since 4.5.0 |
|
1110 | + * @see wp-includes/capabilities.php |
|
1111 | + * @param array $caps actual users capabilities |
|
1112 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1113 | + * @param int $user_id The user id |
|
1114 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1115 | + * @return array actual users capabilities |
|
1116 | + */ |
|
1117 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1118 | + { |
|
1119 | + //only process if we're checking our mapped cap; |
|
1120 | + if ($cap !== $this->meta_cap) { |
|
1121 | + return $caps; |
|
1122 | + } |
|
1123 | + |
|
1124 | + //cast $user_id to int for later explicit comparisons |
|
1125 | + $user_id = (int) $user_id; |
|
1126 | + |
|
1127 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1128 | + //if no obj then let's just do cap |
|
1129 | + if (! $obj instanceof EE_Base_Class) { |
|
1130 | + $caps[] = $cap; |
|
1131 | + return $caps; |
|
1132 | + } |
|
1133 | + if ($obj instanceof EE_CPT_Base) { |
|
1134 | + $status_obj = get_post_status_object($obj->status()); |
|
1135 | + if ($status_obj->public) { |
|
1136 | + $caps[] = $cap; |
|
1137 | + return $caps; |
|
1138 | + } |
|
1139 | + //if the item author is set and the user is the author... |
|
1140 | + if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1141 | + $caps[] = $cap; |
|
1142 | + } elseif ($status_obj->private && ! empty($this->private_cap)) { |
|
1143 | + //the user is trying to view someone else's obj |
|
1144 | + $caps[] = $this->private_cap; |
|
1145 | + } elseif (! empty($this->others_cap)) { |
|
1146 | + $caps[] = $this->others_cap; |
|
1147 | + } else { |
|
1148 | + $caps[] = $cap; |
|
1149 | + } |
|
1150 | + } else { |
|
1151 | + //not a cpt object so handled differently |
|
1152 | + $has_cap = false; |
|
1153 | + try { |
|
1154 | + $has_cap = method_exists($obj, 'wp_user') && $obj->wp_user() && $obj->wp_user() === $user_id; |
|
1155 | + } catch (Exception $e) { |
|
1156 | + if (WP_DEBUG) { |
|
1157 | + EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__); |
|
1158 | + } |
|
1159 | + } |
|
1160 | + if ($has_cap) { |
|
1161 | + $caps[] = $cap; |
|
1162 | + } elseif (! empty($this->private_cap)) { |
|
1163 | + $caps[] = $this->private_cap; |
|
1164 | + } elseif (! empty($this->others_cap)) { |
|
1165 | + $caps[] = $this->others_cap; |
|
1166 | + } else { |
|
1167 | + $caps[] = $cap; |
|
1168 | + } |
|
1169 | + } |
|
1170 | + return $caps; |
|
1171 | + } |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | |
@@ -1185,50 +1185,50 @@ discard block |
||
1185 | 1185 | class EE_Meta_Capability_Map_Messages_Cap extends EE_Meta_Capability_Map |
1186 | 1186 | { |
1187 | 1187 | |
1188 | - /** |
|
1189 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1190 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1191 | - * |
|
1192 | - * @since 4.5.0 |
|
1193 | - * @see wp-includes/capabilities.php |
|
1194 | - * @param array $caps actual users capabilities |
|
1195 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1196 | - * @param int $user_id The user id |
|
1197 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1198 | - * @return array actual users capabilities |
|
1199 | - */ |
|
1200 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1201 | - { |
|
1202 | - //only process if we're checking our mapped_cap |
|
1203 | - if ($cap !== $this->meta_cap) { |
|
1204 | - return $caps; |
|
1205 | - } |
|
1206 | - |
|
1207 | - //cast $user_id to int for later explicit comparisons |
|
1208 | - $user_id = (int) $user_id; |
|
1209 | - |
|
1210 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1211 | - //if no obj then let's just do cap |
|
1212 | - if (! $obj instanceof EE_Message_Template_Group) { |
|
1213 | - $caps[] = $cap; |
|
1214 | - return $caps; |
|
1215 | - } |
|
1216 | - $is_global = $obj->is_global(); |
|
1217 | - if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1218 | - if ($is_global) { |
|
1219 | - $caps[] = $this->private_cap; |
|
1220 | - } else { |
|
1221 | - $caps[] = $cap; |
|
1222 | - } |
|
1223 | - } else { |
|
1224 | - if ($is_global) { |
|
1225 | - $caps[] = $this->private_cap; |
|
1226 | - } else { |
|
1227 | - $caps[] = $this->others_cap; |
|
1228 | - } |
|
1229 | - } |
|
1230 | - return $caps; |
|
1231 | - } |
|
1188 | + /** |
|
1189 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1190 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1191 | + * |
|
1192 | + * @since 4.5.0 |
|
1193 | + * @see wp-includes/capabilities.php |
|
1194 | + * @param array $caps actual users capabilities |
|
1195 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1196 | + * @param int $user_id The user id |
|
1197 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1198 | + * @return array actual users capabilities |
|
1199 | + */ |
|
1200 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1201 | + { |
|
1202 | + //only process if we're checking our mapped_cap |
|
1203 | + if ($cap !== $this->meta_cap) { |
|
1204 | + return $caps; |
|
1205 | + } |
|
1206 | + |
|
1207 | + //cast $user_id to int for later explicit comparisons |
|
1208 | + $user_id = (int) $user_id; |
|
1209 | + |
|
1210 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1211 | + //if no obj then let's just do cap |
|
1212 | + if (! $obj instanceof EE_Message_Template_Group) { |
|
1213 | + $caps[] = $cap; |
|
1214 | + return $caps; |
|
1215 | + } |
|
1216 | + $is_global = $obj->is_global(); |
|
1217 | + if ($obj->wp_user() && $obj->wp_user() === $user_id) { |
|
1218 | + if ($is_global) { |
|
1219 | + $caps[] = $this->private_cap; |
|
1220 | + } else { |
|
1221 | + $caps[] = $cap; |
|
1222 | + } |
|
1223 | + } else { |
|
1224 | + if ($is_global) { |
|
1225 | + $caps[] = $this->private_cap; |
|
1226 | + } else { |
|
1227 | + $caps[] = $this->others_cap; |
|
1228 | + } |
|
1229 | + } |
|
1230 | + return $caps; |
|
1231 | + } |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | |
@@ -1245,39 +1245,39 @@ discard block |
||
1245 | 1245 | class EE_Meta_Capability_Map_Registration_Form_Cap extends EE_Meta_Capability_Map |
1246 | 1246 | { |
1247 | 1247 | |
1248 | - /** |
|
1249 | - * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1250 | - * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1251 | - * |
|
1252 | - * @since 4.5.0 |
|
1253 | - * @see wp-includes/capabilities.php |
|
1254 | - * @param array $caps actual users capabilities |
|
1255 | - * @param string $cap initial capability name that is being checked (the "map" key) |
|
1256 | - * @param int $user_id The user id |
|
1257 | - * @param array $args Adds context to the cap. Typically the object ID. |
|
1258 | - * @return array actual users capabilities |
|
1259 | - */ |
|
1260 | - protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1261 | - { |
|
1262 | - //only process if we're checking our mapped_cap |
|
1263 | - if ($cap !== $this->meta_cap) { |
|
1264 | - return $caps; |
|
1265 | - } |
|
1266 | - $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1267 | - //if no obj then let's just do cap |
|
1268 | - if (! $obj instanceof EE_Base_Class) { |
|
1269 | - $caps[] = $cap; |
|
1270 | - return $caps; |
|
1271 | - } |
|
1272 | - $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
|
1273 | - $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
|
1274 | - if ($is_system) { |
|
1275 | - $caps[] = $this->private_cap; |
|
1276 | - } else { |
|
1277 | - $caps[] = $cap; |
|
1278 | - } |
|
1279 | - return $caps; |
|
1280 | - } |
|
1248 | + /** |
|
1249 | + * This is the callback for the wp map_meta_caps() function which allows for ensuring certain caps that act as a |
|
1250 | + * "meta" for other caps ( i.e. ee_edit_event is a meta for ee_edit_others_events ) work as expected. |
|
1251 | + * |
|
1252 | + * @since 4.5.0 |
|
1253 | + * @see wp-includes/capabilities.php |
|
1254 | + * @param array $caps actual users capabilities |
|
1255 | + * @param string $cap initial capability name that is being checked (the "map" key) |
|
1256 | + * @param int $user_id The user id |
|
1257 | + * @param array $args Adds context to the cap. Typically the object ID. |
|
1258 | + * @return array actual users capabilities |
|
1259 | + */ |
|
1260 | + protected function _map_meta_caps($caps, $cap, $user_id, $args) |
|
1261 | + { |
|
1262 | + //only process if we're checking our mapped_cap |
|
1263 | + if ($cap !== $this->meta_cap) { |
|
1264 | + return $caps; |
|
1265 | + } |
|
1266 | + $obj = ! empty($args[0]) ? $this->_model->get_one_by_ID($args[0]) : null; |
|
1267 | + //if no obj then let's just do cap |
|
1268 | + if (! $obj instanceof EE_Base_Class) { |
|
1269 | + $caps[] = $cap; |
|
1270 | + return $caps; |
|
1271 | + } |
|
1272 | + $is_system = $obj instanceof EE_Question_Group ? $obj->system_group() : false; |
|
1273 | + $is_system = $obj instanceof EE_Question ? $obj->is_system_question() : $is_system; |
|
1274 | + if ($is_system) { |
|
1275 | + $caps[] = $this->private_cap; |
|
1276 | + } else { |
|
1277 | + $caps[] = $cap; |
|
1278 | + } |
|
1279 | + return $caps; |
|
1280 | + } |
|
1281 | 1281 | |
1282 | 1282 | |
1283 | 1283 | } |
@@ -1,3 +1,3 @@ |
||
1 | 1 | <h2><?php esc_html_e('What is the Event Espresso Messages System?', 'event_espresso'); ?></h2> |
2 | -<p><?php printf( esc_html__('The Event Espresso Messages system is a powerful framework that Event Espresso uses to prepare %1$smessages%2$s for different types of use (message types) and delivered by different %1$smessengers%2$s.', 'event_espresso'), '<strong>', '</strong>' ); ?></p> |
|
2 | +<p><?php printf(esc_html__('The Event Espresso Messages system is a powerful framework that Event Espresso uses to prepare %1$smessages%2$s for different types of use (message types) and delivered by different %1$smessengers%2$s.', 'event_espresso'), '<strong>', '</strong>'); ?></p> |
|
3 | 3 | <p><?php esc_html_e('We\'ve intentionally created this framework so that we have as much flexibility as possible for future ideas that we think of (or customers think of) for the kinds of messages that get sent out related to your events.', 'event_espresso'); ?></p> |
4 | 4 | \ No newline at end of file |
@@ -31,35 +31,35 @@ discard block |
||
31 | 31 | <tbody> |
32 | 32 | <tr> |
33 | 33 | <td> |
34 | - <h2><?php printf( esc_html__( 'Hello, %s:', 'event_espresso' ), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]' ); ?></h2> |
|
35 | - <p class="lead"><?php printf( esc_html__( 'Your payment was %1$sCANCELLED%2$s for the following transaction and ticket purchases:', 'event_espresso' ), '<strong>', '</strong>'); ?></p> |
|
36 | - <h3><?php esc_html_e( 'Payment Details:', 'event_espresso' ); ?></h3> |
|
34 | + <h2><?php printf(esc_html__('Hello, %s:', 'event_espresso'), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]'); ?></h2> |
|
35 | + <p class="lead"><?php printf(esc_html__('Your payment was %1$sCANCELLED%2$s for the following transaction and ticket purchases:', 'event_espresso'), '<strong>', '</strong>'); ?></p> |
|
36 | + <h3><?php esc_html_e('Payment Details:', 'event_espresso'); ?></h3> |
|
37 | 37 | <ul> |
38 | 38 | <li> |
39 | - <strong><?php esc_html_e( 'Payment Status:', 'event_espresso' ); ?></strong> [PAYMENT_STATUS] |
|
39 | + <strong><?php esc_html_e('Payment Status:', 'event_espresso'); ?></strong> [PAYMENT_STATUS] |
|
40 | 40 | </li> |
41 | 41 | <li> |
42 | - <strong><?php esc_html_e( 'Transaction ID:', 'event_espresso' ); ?></strong> [TXN_ID] |
|
42 | + <strong><?php esc_html_e('Transaction ID:', 'event_espresso'); ?></strong> [TXN_ID] |
|
43 | 43 | </li> |
44 | 44 | <li> |
45 | - <strong><?php esc_html_e( 'Total Cost:', 'event_espresso' ); ?></strong> [TOTAL_COST] |
|
45 | + <strong><?php esc_html_e('Total Cost:', 'event_espresso'); ?></strong> [TOTAL_COST] |
|
46 | 46 | </li> |
47 | 47 | <li> |
48 | - <strong><?php esc_html_e( 'Payment Method:', 'event_espresso' ); ?></strong> [PAYMENT_GATEWAY] |
|
48 | + <strong><?php esc_html_e('Payment Method:', 'event_espresso'); ?></strong> [PAYMENT_GATEWAY] |
|
49 | 49 | </li> |
50 | 50 | <li> |
51 | - <strong><?php esc_html_e( 'Payment Amount:', 'event_espresso' ); ?></strong> [AMOUNT_PAID] |
|
51 | + <strong><?php esc_html_e('Payment Amount:', 'event_espresso'); ?></strong> [AMOUNT_PAID] |
|
52 | 52 | </li> |
53 | 53 | <li> |
54 | - <strong><?php esc_html_e( 'Amount Due:', 'event_espresso' ); ?></strong> [TOTAL_OWING] |
|
54 | + <strong><?php esc_html_e('Amount Due:', 'event_espresso'); ?></strong> [TOTAL_OWING] |
|
55 | 55 | </li> |
56 | 56 | </ul> |
57 | 57 | <p class="callout"> |
58 | - <?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?> |
|
58 | + <?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?> |
|
59 | 59 | </p> |
60 | 60 | [EVENT_LIST] |
61 | 61 | <p class="callout"> |
62 | - <?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?> |
|
62 | + <?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?> |
|
63 | 63 | </p> |
64 | 64 | </td> |
65 | 65 | </tr> |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | <tbody> |
85 | 85 | <tr> |
86 | 86 | <td> |
87 | - <h3><?php esc_html_e( 'Connect with Us:', 'event_espresso' ); ?></h3> |
|
88 | - <a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e( 'Facebook', 'event_espresso' ); ?></a> |
|
89 | - <a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e( 'Twitter', 'event_espresso' ); ?></a> |
|
90 | - <a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e( 'Google+', 'event_espresso' ); ?></a> |
|
87 | + <h3><?php esc_html_e('Connect with Us:', 'event_espresso'); ?></h3> |
|
88 | + <a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e('Facebook', 'event_espresso'); ?></a> |
|
89 | + <a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e('Twitter', 'event_espresso'); ?></a> |
|
90 | + <a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e('Google+', 'event_espresso'); ?></a> |
|
91 | 91 | </td> |
92 | 92 | </tr> |
93 | 93 | </tbody> |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | <tbody> |
98 | 98 | <tr> |
99 | 99 | <td> |
100 | - <h3><?php esc_html_e( 'Contact Info:', 'event_espresso' ); ?></h3> |
|
101 | - <?php esc_html_e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong> |
|
102 | - <?php esc_html_e( 'Email:', 'event_espresso' ); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong> |
|
100 | + <h3><?php esc_html_e('Contact Info:', 'event_espresso'); ?></h3> |
|
101 | + <?php esc_html_e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong> |
|
102 | + <?php esc_html_e('Email:', 'event_espresso'); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong> |
|
103 | 103 | </td> |
104 | 104 | </tr> |
105 | 105 | </tbody> |
@@ -31,35 +31,35 @@ discard block |
||
31 | 31 | <tbody> |
32 | 32 | <tr> |
33 | 33 | <td> |
34 | - <h2><?php printf( esc_html__( 'Hello, %s:', 'event_espresso' ), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]' ); ?></h2> |
|
35 | - <p class="lead"><?php printf( esc_html__( 'Your payment was %1$sDECLINED%2$s for the following transaction and ticket purchases:', 'event_espresso' ), '<strong>', '</strong>') ?></p> |
|
36 | - <h3><?php esc_html_e( 'Payment Details:', 'event_espresso' ); ?></h3> |
|
34 | + <h2><?php printf(esc_html__('Hello, %s:', 'event_espresso'), '[PRIMARY_REGISTRANT_FNAME] [PRIMARY_REGISTRANT_LNAME]'); ?></h2> |
|
35 | + <p class="lead"><?php printf(esc_html__('Your payment was %1$sDECLINED%2$s for the following transaction and ticket purchases:', 'event_espresso'), '<strong>', '</strong>') ?></p> |
|
36 | + <h3><?php esc_html_e('Payment Details:', 'event_espresso'); ?></h3> |
|
37 | 37 | <ul> |
38 | 38 | <li> |
39 | - <strong><?php esc_html_e( 'Payment Status:', 'event_espresso' ); ?></strong> [PAYMENT_STATUS] |
|
39 | + <strong><?php esc_html_e('Payment Status:', 'event_espresso'); ?></strong> [PAYMENT_STATUS] |
|
40 | 40 | </li> |
41 | 41 | <li> |
42 | - <strong><?php esc_html_e( 'Transaction ID:', 'event_espresso' ); ?></strong> [TXN_ID] |
|
42 | + <strong><?php esc_html_e('Transaction ID:', 'event_espresso'); ?></strong> [TXN_ID] |
|
43 | 43 | </li> |
44 | 44 | <li> |
45 | - <strong><?php esc_html_e( 'Total Cost:', 'event_espresso' ); ?></strong> [TOTAL_COST] |
|
45 | + <strong><?php esc_html_e('Total Cost:', 'event_espresso'); ?></strong> [TOTAL_COST] |
|
46 | 46 | </li> |
47 | 47 | <li> |
48 | - <strong><?php esc_html_e( 'Payment Method:', 'event_espresso' ); ?></strong> [PAYMENT_GATEWAY] |
|
48 | + <strong><?php esc_html_e('Payment Method:', 'event_espresso'); ?></strong> [PAYMENT_GATEWAY] |
|
49 | 49 | </li> |
50 | 50 | <li> |
51 | - <strong><?php esc_html_e( 'Payment Amount:', 'event_espresso' ); ?></strong> [AMOUNT_PAID] |
|
51 | + <strong><?php esc_html_e('Payment Amount:', 'event_espresso'); ?></strong> [AMOUNT_PAID] |
|
52 | 52 | </li> |
53 | 53 | <li> |
54 | - <strong><?php esc_html_e( 'Amount Due:', 'event_espresso' ); ?></strong> [TOTAL_OWING] |
|
54 | + <strong><?php esc_html_e('Amount Due:', 'event_espresso'); ?></strong> [TOTAL_OWING] |
|
55 | 55 | </li> |
56 | 56 | </ul> |
57 | 57 | <p class="callout"> |
58 | - <?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?> |
|
58 | + <?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?> |
|
59 | 59 | </p> |
60 | 60 | [EVENT_LIST] |
61 | 61 | <p class="callout"> |
62 | - <?php printf( esc_html__( 'Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso' ), '<a href="[PAYMENT_URL]">', '</a>' ); ?> |
|
62 | + <?php printf(esc_html__('Please %sretry your payment%s, or choose an alternate payment method to reserve your space.', 'event_espresso'), '<a href="[PAYMENT_URL]">', '</a>'); ?> |
|
63 | 63 | </p> |
64 | 64 | </td> |
65 | 65 | </tr> |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | <tbody> |
85 | 85 | <tr> |
86 | 86 | <td> |
87 | - <h3><?php esc_html_e( 'Connect with Us:', 'event_espresso' ); ?></h3> |
|
88 | - <a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e( 'Facebook', 'event_espresso' ); ?></a> |
|
89 | - <a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e( 'Twitter', 'event_espresso' ); ?></a> |
|
90 | - <a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e( 'Google+', 'event_espresso' ); ?></a> |
|
87 | + <h3><?php esc_html_e('Connect with Us:', 'event_espresso'); ?></h3> |
|
88 | + <a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php esc_html_e('Facebook', 'event_espresso'); ?></a> |
|
89 | + <a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php esc_html_e('Twitter', 'event_espresso'); ?></a> |
|
90 | + <a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php esc_html_e('Google+', 'event_espresso'); ?></a> |
|
91 | 91 | </td> |
92 | 92 | </tr> |
93 | 93 | </tbody> |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | <tbody> |
98 | 98 | <tr> |
99 | 99 | <td> |
100 | - <h3><?php esc_html_e( 'Contact Info:', 'event_espresso' ); ?></h3> |
|
101 | - <?php esc_html_e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong> |
|
102 | - <?php esc_html_e( 'Email:', 'event_espresso' ); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong> |
|
100 | + <h3><?php esc_html_e('Contact Info:', 'event_espresso'); ?></h3> |
|
101 | + <?php esc_html_e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong> |
|
102 | + <?php esc_html_e('Email:', 'event_espresso'); ?> <strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong> |
|
103 | 103 | </td> |
104 | 104 | </tr> |
105 | 105 | </tbody> |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function __construct(){ |
73 | 73 | if( ! $this->_model_name_extended){ |
74 | - throw new EE_Error( |
|
75 | - __( "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'", |
|
76 | - "event_espresso" ) |
|
77 | - ); |
|
74 | + throw new EE_Error( |
|
75 | + __( "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'", |
|
76 | + "event_espresso" ) |
|
77 | + ); |
|
78 | 78 | } |
79 | 79 | $construct_end_action = 'AHEE__EEM_'.$this->_model_name_extended.'__construct__end'; |
80 | 80 | if ( did_action( $construct_end_action )) { |
@@ -95,30 +95,30 @@ discard block |
||
95 | 95 | |
96 | 96 | |
97 | 97 | |
98 | - /** |
|
99 | - * @param array $existing_tables |
|
100 | - * @return array |
|
101 | - */ |
|
102 | - public function add_extra_tables_on_filter( $existing_tables ){ |
|
103 | - return array_merge( (array)$existing_tables, $this->_extra_tables ); |
|
98 | + /** |
|
99 | + * @param array $existing_tables |
|
100 | + * @return array |
|
101 | + */ |
|
102 | + public function add_extra_tables_on_filter( $existing_tables ){ |
|
103 | + return array_merge( (array)$existing_tables, $this->_extra_tables ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
107 | 107 | |
108 | - /** |
|
109 | - * @param array $existing_fields |
|
110 | - * @return array |
|
111 | - */ |
|
112 | - public function add_extra_fields_on_filter( $existing_fields ){ |
|
108 | + /** |
|
109 | + * @param array $existing_fields |
|
110 | + * @return array |
|
111 | + */ |
|
112 | + public function add_extra_fields_on_filter( $existing_fields ){ |
|
113 | 113 | if( $this->_extra_fields){ |
114 | 114 | foreach($this->_extra_fields as $table_alias => $fields){ |
115 | 115 | if( ! isset( $existing_fields[ $table_alias ] ) ){ |
116 | 116 | $existing_fields[ $table_alias ] = array(); |
117 | 117 | } |
118 | 118 | $existing_fields[$table_alias] = array_merge( |
119 | - (array)$existing_fields[$table_alias], |
|
120 | - $this->_extra_fields[$table_alias] |
|
121 | - ); |
|
119 | + (array)$existing_fields[$table_alias], |
|
120 | + $this->_extra_fields[$table_alias] |
|
121 | + ); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 | } |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | |
128 | 128 | |
129 | 129 | |
130 | - /** |
|
131 | - * @param array $existing_relations |
|
132 | - * @return array |
|
133 | - */ |
|
134 | - public function add_extra_relations_on_filter( $existing_relations ){ |
|
135 | - return array_merge((array)$existing_relations,$this->_extra_relations); |
|
130 | + /** |
|
131 | + * @param array $existing_relations |
|
132 | + * @return array |
|
133 | + */ |
|
134 | + public function add_extra_relations_on_filter( $existing_relations ){ |
|
135 | + return array_merge((array)$existing_relations,$this->_extra_relations); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | remove_filter($callback_name,array($this,self::dynamic_callback_method_prefix.$method_name_on_model),10); |
169 | 169 | } |
170 | 170 | } |
171 | - /** @var EEM_Base $model_to_reset */ |
|
172 | - $model_to_reset = 'EEM_' . $this->_model_name_extended; |
|
171 | + /** @var EEM_Base $model_to_reset */ |
|
172 | + $model_to_reset = 'EEM_' . $this->_model_name_extended; |
|
173 | 173 | if ( class_exists( $model_to_reset ) ) { |
174 | 174 | $model_to_reset::reset(); |
175 | 175 | } |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | |
178 | 178 | |
179 | 179 | |
180 | - /** |
|
181 | - * @param string $callback_method_name |
|
182 | - * @param array $args |
|
183 | - * @return mixed |
|
184 | - * @throws EE_Error |
|
185 | - */ |
|
186 | - public function __call( $callback_method_name, $args){ |
|
180 | + /** |
|
181 | + * @param string $callback_method_name |
|
182 | + * @param array $args |
|
183 | + * @return mixed |
|
184 | + * @throws EE_Error |
|
185 | + */ |
|
186 | + public function __call( $callback_method_name, $args){ |
|
187 | 187 | if(strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0){ |
188 | 188 | //it's a dynamic callback for a method name |
189 | 189 | $method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name); |
@@ -194,23 +194,23 @@ discard block |
||
194 | 194 | return call_user_func_array(array($this,$extending_method), $args_provided_to_method_on_model); |
195 | 195 | }else{ |
196 | 196 | throw new EE_Error( |
197 | - sprintf( |
|
198 | - __("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"), |
|
199 | - $this->_model_name_extended, |
|
200 | - get_class($this), |
|
201 | - $extending_method,$extending_method |
|
202 | - ) |
|
203 | - ); |
|
197 | + sprintf( |
|
198 | + __("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"), |
|
199 | + $this->_model_name_extended, |
|
200 | + get_class($this), |
|
201 | + $extending_method,$extending_method |
|
202 | + ) |
|
203 | + ); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | }else{ |
207 | 207 | throw new EE_Error( |
208 | - sprintf( |
|
209 | - __("There is no method named '%s' on '%s'", "event_espresso"), |
|
210 | - $callback_method_name, |
|
211 | - get_class($this) |
|
212 | - ) |
|
213 | - ); |
|
208 | + sprintf( |
|
209 | + __("There is no method named '%s' on '%s'", "event_espresso"), |
|
210 | + $callback_method_name, |
|
211 | + get_class($this) |
|
212 | + ) |
|
213 | + ); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -69,27 +69,27 @@ discard block |
||
69 | 69 | /** |
70 | 70 | * @throws \EE_Error |
71 | 71 | */ |
72 | - public function __construct(){ |
|
73 | - if( ! $this->_model_name_extended){ |
|
72 | + public function __construct() { |
|
73 | + if ( ! $this->_model_name_extended) { |
|
74 | 74 | throw new EE_Error( |
75 | - __( "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'", |
|
76 | - "event_espresso" ) |
|
75 | + __("When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'", |
|
76 | + "event_espresso") |
|
77 | 77 | ); |
78 | 78 | } |
79 | 79 | $construct_end_action = 'AHEE__EEM_'.$this->_model_name_extended.'__construct__end'; |
80 | - if ( did_action( $construct_end_action )) { |
|
80 | + if (did_action($construct_end_action)) { |
|
81 | 81 | throw new EE_Error( |
82 | 82 | sprintf( |
83 | - __( "Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired", "event_espresso"), |
|
83 | + __("Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired", "event_espresso"), |
|
84 | 84 | get_class($this), |
85 | 85 | $this->_model_name_extended, |
86 | 86 | $construct_end_action |
87 | 87 | ) |
88 | 88 | ); |
89 | 89 | } |
90 | - add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables',array($this,'add_extra_tables_on_filter')); |
|
91 | - add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields',array($this,'add_extra_fields_on_filter')); |
|
92 | - add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations',array($this,'add_extra_relations_on_filter')); |
|
90 | + add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables', array($this, 'add_extra_tables_on_filter')); |
|
91 | + add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields', array($this, 'add_extra_fields_on_filter')); |
|
92 | + add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations', array($this, 'add_extra_relations_on_filter')); |
|
93 | 93 | $this->_register_extending_methods(); |
94 | 94 | } |
95 | 95 | |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | * @param array $existing_tables |
100 | 100 | * @return array |
101 | 101 | */ |
102 | - public function add_extra_tables_on_filter( $existing_tables ){ |
|
103 | - return array_merge( (array)$existing_tables, $this->_extra_tables ); |
|
102 | + public function add_extra_tables_on_filter($existing_tables) { |
|
103 | + return array_merge((array) $existing_tables, $this->_extra_tables); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | * @param array $existing_fields |
110 | 110 | * @return array |
111 | 111 | */ |
112 | - public function add_extra_fields_on_filter( $existing_fields ){ |
|
113 | - if( $this->_extra_fields){ |
|
114 | - foreach($this->_extra_fields as $table_alias => $fields){ |
|
115 | - if( ! isset( $existing_fields[ $table_alias ] ) ){ |
|
116 | - $existing_fields[ $table_alias ] = array(); |
|
112 | + public function add_extra_fields_on_filter($existing_fields) { |
|
113 | + if ($this->_extra_fields) { |
|
114 | + foreach ($this->_extra_fields as $table_alias => $fields) { |
|
115 | + if ( ! isset($existing_fields[$table_alias])) { |
|
116 | + $existing_fields[$table_alias] = array(); |
|
117 | 117 | } |
118 | 118 | $existing_fields[$table_alias] = array_merge( |
119 | - (array)$existing_fields[$table_alias], |
|
119 | + (array) $existing_fields[$table_alias], |
|
120 | 120 | $this->_extra_fields[$table_alias] |
121 | 121 | ); |
122 | 122 | |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param array $existing_relations |
132 | 132 | * @return array |
133 | 133 | */ |
134 | - public function add_extra_relations_on_filter( $existing_relations ){ |
|
135 | - return array_merge((array)$existing_relations,$this->_extra_relations); |
|
134 | + public function add_extra_relations_on_filter($existing_relations) { |
|
135 | + return array_merge((array) $existing_relations, $this->_extra_relations); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the |
142 | 142 | * model extended. (Internally uses filters, and the __call magic method) |
143 | 143 | */ |
144 | - protected function _register_extending_methods(){ |
|
144 | + protected function _register_extending_methods() { |
|
145 | 145 | $all_methods = get_class_methods(get_class($this)); |
146 | - foreach($all_methods as $method_name){ |
|
147 | - if(strpos($method_name, self::extending_method_prefix) === 0){ |
|
146 | + foreach ($all_methods as $method_name) { |
|
147 | + if (strpos($method_name, self::extending_method_prefix) === 0) { |
|
148 | 148 | $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name); |
149 | 149 | $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model"; |
150 | - add_filter($callback_name,array($this,self::dynamic_callback_method_prefix.$method_name_on_model),10,10); |
|
150 | + add_filter($callback_name, array($this, self::dynamic_callback_method_prefix.$method_name_on_model), 10, 10); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | } |
@@ -156,21 +156,21 @@ discard block |
||
156 | 156 | * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the |
157 | 157 | * model extended. (Internally uses filters, and the __call magic method) |
158 | 158 | */ |
159 | - public function deregister(){ |
|
160 | - remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables',array($this,'add_extra_tables_on_filter')); |
|
161 | - remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields',array($this,'add_extra_fields_on_filter')); |
|
162 | - remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations',array($this,'add_extra_relations_on_filter')); |
|
159 | + public function deregister() { |
|
160 | + remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables', array($this, 'add_extra_tables_on_filter')); |
|
161 | + remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields', array($this, 'add_extra_fields_on_filter')); |
|
162 | + remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations', array($this, 'add_extra_relations_on_filter')); |
|
163 | 163 | $all_methods = get_class_methods(get_class($this)); |
164 | - foreach($all_methods as $method_name){ |
|
165 | - if(strpos($method_name, self::extending_method_prefix) === 0){ |
|
164 | + foreach ($all_methods as $method_name) { |
|
165 | + if (strpos($method_name, self::extending_method_prefix) === 0) { |
|
166 | 166 | $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name); |
167 | 167 | $callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model"; |
168 | - remove_filter($callback_name,array($this,self::dynamic_callback_method_prefix.$method_name_on_model),10); |
|
168 | + remove_filter($callback_name, array($this, self::dynamic_callback_method_prefix.$method_name_on_model), 10); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | /** @var EEM_Base $model_to_reset */ |
172 | - $model_to_reset = 'EEM_' . $this->_model_name_extended; |
|
173 | - if ( class_exists( $model_to_reset ) ) { |
|
172 | + $model_to_reset = 'EEM_'.$this->_model_name_extended; |
|
173 | + if (class_exists($model_to_reset)) { |
|
174 | 174 | $model_to_reset::reset(); |
175 | 175 | } |
176 | 176 | } |
@@ -183,27 +183,27 @@ discard block |
||
183 | 183 | * @return mixed |
184 | 184 | * @throws EE_Error |
185 | 185 | */ |
186 | - public function __call( $callback_method_name, $args){ |
|
187 | - if(strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0){ |
|
186 | + public function __call($callback_method_name, $args) { |
|
187 | + if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) { |
|
188 | 188 | //it's a dynamic callback for a method name |
189 | 189 | $method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name); |
190 | - list( $original_return_val, $model_called, $args_provided_to_method_on_model ) = (array) $args; |
|
190 | + list($original_return_val, $model_called, $args_provided_to_method_on_model) = (array) $args; |
|
191 | 191 | $this->_ = $model_called; |
192 | 192 | $extending_method = self::extending_method_prefix.$method_called_on_model; |
193 | - if(method_exists($this, $extending_method)){ |
|
194 | - return call_user_func_array(array($this,$extending_method), $args_provided_to_method_on_model); |
|
195 | - }else{ |
|
193 | + if (method_exists($this, $extending_method)) { |
|
194 | + return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model); |
|
195 | + } else { |
|
196 | 196 | throw new EE_Error( |
197 | 197 | sprintf( |
198 | 198 | __("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"), |
199 | 199 | $this->_model_name_extended, |
200 | 200 | get_class($this), |
201 | - $extending_method,$extending_method |
|
201 | + $extending_method, $extending_method |
|
202 | 202 | ) |
203 | 203 | ); |
204 | 204 | } |
205 | 205 | |
206 | - }else{ |
|
206 | + } else { |
|
207 | 207 | throw new EE_Error( |
208 | 208 | sprintf( |
209 | 209 | __("There is no method named '%s' on '%s'", "event_espresso"), |
@@ -1,7 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | +} |
|
5 | 6 | |
6 | 7 | /** |
7 | 8 | * |
@@ -192,7 +193,7 @@ discard block |
||
192 | 193 | $extending_method = self::extending_method_prefix.$method_called_on_model; |
193 | 194 | if(method_exists($this, $extending_method)){ |
194 | 195 | return call_user_func_array(array($this,$extending_method), $args_provided_to_method_on_model); |
195 | - }else{ |
|
196 | + } else{ |
|
196 | 197 | throw new EE_Error( |
197 | 198 | sprintf( |
198 | 199 | __("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"), |
@@ -203,7 +204,7 @@ discard block |
||
203 | 204 | ); |
204 | 205 | } |
205 | 206 | |
206 | - }else{ |
|
207 | + } else{ |
|
207 | 208 | throw new EE_Error( |
208 | 209 | sprintf( |
209 | 210 | __("There is no method named '%s' on '%s'", "event_espresso"), |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <p><strong><?php esc_html_e('Message Types', 'event_espresso'); ?></strong></p> |
2 | -<p><?php printf( esc_html__('Messages are email notifications that are sent out by Event Espresso. Message Types are the %1$skinds%2$s of messages that get delivered. They can be thought of as the "type" of package that is being delivered by the messenger. For example, Event Espresso comes with two Message Types attached to the Email Messenger:', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
2 | +<p><?php printf(esc_html__('Messages are email notifications that are sent out by Event Espresso. Message Types are the %1$skinds%2$s of messages that get delivered. They can be thought of as the "type" of package that is being delivered by the messenger. For example, Event Espresso comes with two Message Types attached to the Email Messenger:', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
3 | 3 | <p> |
4 | 4 | <ul> |
5 | 5 | <li> |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <p><strong><?php esc_html_e('Message Templates', 'event_espresso'); ?></strong></p> |
2 | -<p><?php printf( esc_html__('Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
2 | +<p><?php printf(esc_html__('Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
3 | 3 | <p><?php esc_html_e('There is a template created for each Messenger / Message Type and context combination. For example, messages that are sent for Payment Confirmation have a template for Event Administrator and a different one for Primary Registrant. Whereas, messages that are sent for the Registration confirmation have 3 templates: one for Event Administrator, one for the Primary Registrant, and another for each additional Registrant(s).', 'event_espresso'); ?></p> |
4 | -<p><?php esc_html_e('With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', 'event_espresso' ); ?></p> |
|
5 | 4 | \ No newline at end of file |
5 | +<p><?php esc_html_e('With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', 'event_espresso'); ?></p> |
|
6 | 6 | \ No newline at end of file |
@@ -1,4 +1,4 @@ |
||
1 | 1 | <h2><?php esc_html_e('What are Message Templates', 'event_espresso'); ?></h2> |
2 | -<p><?php printf( esc_html__('Message Templates are the %1$sformat%2$s of the messages going out. Think of them like a “Form letter”. Templates are used to tell the system what you want your messages to look like and the content they will have when they are delivered.', 'event_espresso'), '<em>', '</em>' ); ?></p> |
|
2 | +<p><?php printf(esc_html__('Message Templates are the %1$sformat%2$s of the messages going out. Think of them like a “Form letter”. Templates are used to tell the system what you want your messages to look like and the content they will have when they are delivered.', 'event_espresso'), '<em>', '</em>'); ?></p> |
|
3 | 3 | <p><?php esc_html_e('There is a template created for each messenger/message type AND context combination. So example, Emails that are sent for the Payment confirmation have a template for Event Administrator and a different one for Primary Registrant. Whereas, emails that are sent for the Registration confirmation have 3 templates, one for Event Administrator, Primary Registrant, and Registrant.', 'event_espresso'); ?></p> |
4 | -<p><?php esc_html_e('With the Event Espresso Messages system, every Messenger, Message Type and Context will have a global template created with some default content on creation. You have the ability to edit this global template that will be used for all events you create. However, you also have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', 'event_espresso' ); ?></p> |
|
5 | 4 | \ No newline at end of file |
5 | +<p><?php esc_html_e('With the Event Espresso Messages system, every Messenger, Message Type and Context will have a global template created with some default content on creation. You have the ability to edit this global template that will be used for all events you create. However, you also have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', 'event_espresso'); ?></p> |
|
6 | 6 | \ No newline at end of file |