@@ -15,140 +15,140 @@ |
||
15 | 15 | class Pricing_Price_Types_Default_Help_Tour extends EE_Help_Tour |
16 | 16 | { |
17 | 17 | |
18 | - protected function _set_tour_properties() |
|
19 | - { |
|
20 | - $this->_label = __('Price Types Tour', 'event_espresso'); |
|
21 | - $this->_slug = 'default-price-types-joyride'; |
|
22 | - } |
|
18 | + protected function _set_tour_properties() |
|
19 | + { |
|
20 | + $this->_label = __('Price Types Tour', 'event_espresso'); |
|
21 | + $this->_slug = 'default-price-types-joyride'; |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - protected function _set_tour_stops() |
|
26 | - { |
|
27 | - $this->_stops = array( |
|
28 | - 10 => array( |
|
29 | - 'content' => $this->_start(), |
|
30 | - ), |
|
31 | - 20 => array( |
|
32 | - 'id' => 'name', |
|
33 | - 'content' => $this->_name_column_stop(), |
|
34 | - 'options' => array( |
|
35 | - 'tipLocation' => 'top', |
|
36 | - 'tipAdjustmentX' => -5, |
|
37 | - 'tipAdjustmentY' => -30, |
|
38 | - ), |
|
39 | - ), |
|
40 | - 30 => array( |
|
41 | - 'id' => 'base_type', |
|
42 | - 'content' => $this->_base_type_stop(), |
|
43 | - 'options' => array( |
|
44 | - 'tipLocation' => 'top', |
|
45 | - 'tipAdjustmentX' => 120, |
|
46 | - 'tipAdjustmentY' => -30, |
|
47 | - ), |
|
48 | - ), |
|
49 | - 40 => array( |
|
50 | - 'id' => 'percent', |
|
51 | - 'content' => $this->_percent_column_stop(), |
|
52 | - 'options' => array( |
|
53 | - 'tipLocation' => 'top', |
|
54 | - 'tipAdjustmentX' => 120, |
|
55 | - 'tipAdjustmentY' => -30, |
|
56 | - ), |
|
57 | - ), |
|
58 | - 50 => array( |
|
59 | - 'id' => 'order', |
|
60 | - 'content' => $this->_order_column_stop(), |
|
61 | - 'options' => array( |
|
62 | - 'tipLocation' => 'left', |
|
63 | - 'tipAdjustmentY' => -30, |
|
64 | - 'tipAdjustmentX' => 100, |
|
65 | - ), |
|
66 | - ), |
|
67 | - 60 => array( |
|
68 | - 'class' => 'bulkactions', |
|
69 | - 'content' => $this->_bulk_actions_stop(), |
|
70 | - 'options' => array( |
|
71 | - 'tipLocation' => 'left', |
|
72 | - 'tipAdjustmentY' => -50, |
|
73 | - 'tipAdjustmentX' => -75, |
|
74 | - ), |
|
75 | - ), |
|
76 | - 70 => array( |
|
77 | - 'id' => 'event-espresso_page_pricing-search-input', |
|
78 | - 'content' => $this->_search_stop(), |
|
79 | - 'options' => array( |
|
80 | - 'tipLocation' => 'left', |
|
81 | - 'tipAdjustmentY' => -50, |
|
82 | - 'tipAdjustmentX' => -15, |
|
83 | - ), |
|
84 | - ), |
|
85 | - ); |
|
86 | - } |
|
25 | + protected function _set_tour_stops() |
|
26 | + { |
|
27 | + $this->_stops = array( |
|
28 | + 10 => array( |
|
29 | + 'content' => $this->_start(), |
|
30 | + ), |
|
31 | + 20 => array( |
|
32 | + 'id' => 'name', |
|
33 | + 'content' => $this->_name_column_stop(), |
|
34 | + 'options' => array( |
|
35 | + 'tipLocation' => 'top', |
|
36 | + 'tipAdjustmentX' => -5, |
|
37 | + 'tipAdjustmentY' => -30, |
|
38 | + ), |
|
39 | + ), |
|
40 | + 30 => array( |
|
41 | + 'id' => 'base_type', |
|
42 | + 'content' => $this->_base_type_stop(), |
|
43 | + 'options' => array( |
|
44 | + 'tipLocation' => 'top', |
|
45 | + 'tipAdjustmentX' => 120, |
|
46 | + 'tipAdjustmentY' => -30, |
|
47 | + ), |
|
48 | + ), |
|
49 | + 40 => array( |
|
50 | + 'id' => 'percent', |
|
51 | + 'content' => $this->_percent_column_stop(), |
|
52 | + 'options' => array( |
|
53 | + 'tipLocation' => 'top', |
|
54 | + 'tipAdjustmentX' => 120, |
|
55 | + 'tipAdjustmentY' => -30, |
|
56 | + ), |
|
57 | + ), |
|
58 | + 50 => array( |
|
59 | + 'id' => 'order', |
|
60 | + 'content' => $this->_order_column_stop(), |
|
61 | + 'options' => array( |
|
62 | + 'tipLocation' => 'left', |
|
63 | + 'tipAdjustmentY' => -30, |
|
64 | + 'tipAdjustmentX' => 100, |
|
65 | + ), |
|
66 | + ), |
|
67 | + 60 => array( |
|
68 | + 'class' => 'bulkactions', |
|
69 | + 'content' => $this->_bulk_actions_stop(), |
|
70 | + 'options' => array( |
|
71 | + 'tipLocation' => 'left', |
|
72 | + 'tipAdjustmentY' => -50, |
|
73 | + 'tipAdjustmentX' => -75, |
|
74 | + ), |
|
75 | + ), |
|
76 | + 70 => array( |
|
77 | + 'id' => 'event-espresso_page_pricing-search-input', |
|
78 | + 'content' => $this->_search_stop(), |
|
79 | + 'options' => array( |
|
80 | + 'tipLocation' => 'left', |
|
81 | + 'tipAdjustmentY' => -50, |
|
82 | + 'tipAdjustmentX' => -15, |
|
83 | + ), |
|
84 | + ), |
|
85 | + ); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - protected function _start() |
|
90 | - { |
|
91 | - $content = '<h3>' . __('Price Types', 'event_espresso') . '</h3>'; |
|
92 | - $content .= '<p>' |
|
93 | - . __( |
|
94 | - 'This tour of the Price Types page will go over different areas of the screen to help you understand what they are used for.', |
|
95 | - 'event_espresso' |
|
96 | - ) . '</p>'; |
|
97 | - return $content; |
|
98 | - } |
|
89 | + protected function _start() |
|
90 | + { |
|
91 | + $content = '<h3>' . __('Price Types', 'event_espresso') . '</h3>'; |
|
92 | + $content .= '<p>' |
|
93 | + . __( |
|
94 | + 'This tour of the Price Types page will go over different areas of the screen to help you understand what they are used for.', |
|
95 | + 'event_espresso' |
|
96 | + ) . '</p>'; |
|
97 | + return $content; |
|
98 | + } |
|
99 | 99 | |
100 | - protected function _name_column_stop() |
|
101 | - { |
|
102 | - return '<p>' |
|
103 | - . __( |
|
104 | - 'The name of the price type. Can be sorted in ascending or descending order.', |
|
105 | - 'event_espresso' |
|
106 | - ) . '</p>'; |
|
107 | - } |
|
100 | + protected function _name_column_stop() |
|
101 | + { |
|
102 | + return '<p>' |
|
103 | + . __( |
|
104 | + 'The name of the price type. Can be sorted in ascending or descending order.', |
|
105 | + 'event_espresso' |
|
106 | + ) . '</p>'; |
|
107 | + } |
|
108 | 108 | |
109 | - protected function _base_type_stop() |
|
110 | - { |
|
111 | - return '<p>' . __('View if a price type is a discount, surcharge, or tax.', 'event_espresso') . '</p>'; |
|
112 | - } |
|
109 | + protected function _base_type_stop() |
|
110 | + { |
|
111 | + return '<p>' . __('View if a price type is a discount, surcharge, or tax.', 'event_espresso') . '</p>'; |
|
112 | + } |
|
113 | 113 | |
114 | - protected function _member_column_stop() |
|
115 | - { |
|
116 | - return '<p>' |
|
117 | - . __( |
|
118 | - 'Here you can see if the discount/surcharge is percentage based or a flat monetary amount.', |
|
119 | - 'event_espresso' |
|
120 | - ) . '</p>'; |
|
121 | - } |
|
114 | + protected function _member_column_stop() |
|
115 | + { |
|
116 | + return '<p>' |
|
117 | + . __( |
|
118 | + 'Here you can see if the discount/surcharge is percentage based or a flat monetary amount.', |
|
119 | + 'event_espresso' |
|
120 | + ) . '</p>'; |
|
121 | + } |
|
122 | 122 | |
123 | - protected function _percent_column_stop() |
|
124 | - { |
|
125 | - return '<p>' |
|
126 | - . __( |
|
127 | - 'View if the discount, surcharge, or tax is percentage-based or a fixed amount.', |
|
128 | - 'event_espresso' |
|
129 | - ) . '</p>'; |
|
130 | - } |
|
123 | + protected function _percent_column_stop() |
|
124 | + { |
|
125 | + return '<p>' |
|
126 | + . __( |
|
127 | + 'View if the discount, surcharge, or tax is percentage-based or a fixed amount.', |
|
128 | + 'event_espresso' |
|
129 | + ) . '</p>'; |
|
130 | + } |
|
131 | 131 | |
132 | - protected function _order_column_stop() |
|
133 | - { |
|
134 | - return '<p>' |
|
135 | - . __( |
|
136 | - 'View the order in which each discount, surcharge, or tax will be applied to the base ticket cost. Zero (0) means it will be applied first.', |
|
137 | - 'event_espresso' |
|
138 | - ) . '</p>'; |
|
139 | - } |
|
132 | + protected function _order_column_stop() |
|
133 | + { |
|
134 | + return '<p>' |
|
135 | + . __( |
|
136 | + 'View the order in which each discount, surcharge, or tax will be applied to the base ticket cost. Zero (0) means it will be applied first.', |
|
137 | + 'event_espresso' |
|
138 | + ) . '</p>'; |
|
139 | + } |
|
140 | 140 | |
141 | - protected function _bulk_actions_stop() |
|
142 | - { |
|
143 | - return '<p>' . __('Perform bulk actions to multiple price types.', 'event_espresso') . '</p>'; |
|
144 | - } |
|
141 | + protected function _bulk_actions_stop() |
|
142 | + { |
|
143 | + return '<p>' . __('Perform bulk actions to multiple price types.', 'event_espresso') . '</p>'; |
|
144 | + } |
|
145 | 145 | |
146 | - protected function _search_stop() |
|
147 | - { |
|
148 | - return '<p>' |
|
149 | - . __( |
|
150 | - 'Search through price types. The following source will be searched: Price Type Name.', |
|
151 | - 'event_espresso' |
|
152 | - ) . '</p>'; |
|
153 | - } |
|
146 | + protected function _search_stop() |
|
147 | + { |
|
148 | + return '<p>' |
|
149 | + . __( |
|
150 | + 'Search through price types. The following source will be searched: Price Type Name.', |
|
151 | + 'event_espresso' |
|
152 | + ) . '</p>'; |
|
153 | + } |
|
154 | 154 | } |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | |
89 | 89 | protected function _start() |
90 | 90 | { |
91 | - $content = '<h3>' . __('Price Types', 'event_espresso') . '</h3>'; |
|
91 | + $content = '<h3>'.__('Price Types', 'event_espresso').'</h3>'; |
|
92 | 92 | $content .= '<p>' |
93 | 93 | . __( |
94 | 94 | 'This tour of the Price Types page will go over different areas of the screen to help you understand what they are used for.', |
95 | 95 | 'event_espresso' |
96 | - ) . '</p>'; |
|
96 | + ).'</p>'; |
|
97 | 97 | return $content; |
98 | 98 | } |
99 | 99 | |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | . __( |
104 | 104 | 'The name of the price type. Can be sorted in ascending or descending order.', |
105 | 105 | 'event_espresso' |
106 | - ) . '</p>'; |
|
106 | + ).'</p>'; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | protected function _base_type_stop() |
110 | 110 | { |
111 | - return '<p>' . __('View if a price type is a discount, surcharge, or tax.', 'event_espresso') . '</p>'; |
|
111 | + return '<p>'.__('View if a price type is a discount, surcharge, or tax.', 'event_espresso').'</p>'; |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | protected function _member_column_stop() |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | . __( |
118 | 118 | 'Here you can see if the discount/surcharge is percentage based or a flat monetary amount.', |
119 | 119 | 'event_espresso' |
120 | - ) . '</p>'; |
|
120 | + ).'</p>'; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | protected function _percent_column_stop() |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | . __( |
127 | 127 | 'View if the discount, surcharge, or tax is percentage-based or a fixed amount.', |
128 | 128 | 'event_espresso' |
129 | - ) . '</p>'; |
|
129 | + ).'</p>'; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | protected function _order_column_stop() |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | . __( |
136 | 136 | 'View the order in which each discount, surcharge, or tax will be applied to the base ticket cost. Zero (0) means it will be applied first.', |
137 | 137 | 'event_espresso' |
138 | - ) . '</p>'; |
|
138 | + ).'</p>'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | protected function _bulk_actions_stop() |
142 | 142 | { |
143 | - return '<p>' . __('Perform bulk actions to multiple price types.', 'event_espresso') . '</p>'; |
|
143 | + return '<p>'.__('Perform bulk actions to multiple price types.', 'event_espresso').'</p>'; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | protected function _search_stop() |
@@ -149,6 +149,6 @@ discard block |
||
149 | 149 | . __( |
150 | 150 | 'Search through price types. The following source will be searched: Price Type Name.', |
151 | 151 | 'event_espresso' |
152 | - ) . '</p>'; |
|
152 | + ).'</p>'; |
|
153 | 153 | } |
154 | 154 | } |
@@ -15,42 +15,42 @@ |
||
15 | 15 | class Global_EE_Caf_Hooks |
16 | 16 | { |
17 | 17 | |
18 | - public function __construct() |
|
19 | - { |
|
20 | - $this->_do_hooks(); |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - private function _do_hooks() |
|
25 | - { |
|
26 | - add_filter('FHEE_show_sponsors_meta_box', '__return_false', 10); |
|
27 | - add_filter('FHEE_show_ratings_request_meta_box', '__return_false', 10); |
|
28 | - add_filter( |
|
29 | - 'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', |
|
30 | - array($this, 'forums_lazy_loading'), |
|
31 | - 10 |
|
32 | - ); |
|
33 | - add_action( |
|
34 | - 'AHEE__EE_Admin_Page__espresso_news_post_box__after_content', |
|
35 | - array($this, 'extra_news_box_content'), |
|
36 | - 10 |
|
37 | - ); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - public function extra_news_box_content($content) |
|
42 | - { |
|
43 | - echo '<h3 style="margin:0">' . __('From the Forums', 'event_espresso') . '</h3>'; |
|
44 | - echo '<div id="ee_forum_posts_content">'; |
|
45 | - $url = 'http://eventespresso.com/forum/event-espresso-support/feed/'; |
|
46 | - EE_Admin_Page::cached_rss_display('ee_forum_posts_content', $url); |
|
47 | - echo '</div>'; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - public function forums_lazy_loading($ids) |
|
52 | - { |
|
53 | - $ids[] = 'ee_forum_posts_content'; |
|
54 | - return $ids; |
|
55 | - } |
|
18 | + public function __construct() |
|
19 | + { |
|
20 | + $this->_do_hooks(); |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + private function _do_hooks() |
|
25 | + { |
|
26 | + add_filter('FHEE_show_sponsors_meta_box', '__return_false', 10); |
|
27 | + add_filter('FHEE_show_ratings_request_meta_box', '__return_false', 10); |
|
28 | + add_filter( |
|
29 | + 'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', |
|
30 | + array($this, 'forums_lazy_loading'), |
|
31 | + 10 |
|
32 | + ); |
|
33 | + add_action( |
|
34 | + 'AHEE__EE_Admin_Page__espresso_news_post_box__after_content', |
|
35 | + array($this, 'extra_news_box_content'), |
|
36 | + 10 |
|
37 | + ); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + public function extra_news_box_content($content) |
|
42 | + { |
|
43 | + echo '<h3 style="margin:0">' . __('From the Forums', 'event_espresso') . '</h3>'; |
|
44 | + echo '<div id="ee_forum_posts_content">'; |
|
45 | + $url = 'http://eventespresso.com/forum/event-espresso-support/feed/'; |
|
46 | + EE_Admin_Page::cached_rss_display('ee_forum_posts_content', $url); |
|
47 | + echo '</div>'; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + public function forums_lazy_loading($ids) |
|
52 | + { |
|
53 | + $ids[] = 'ee_forum_posts_content'; |
|
54 | + return $ids; |
|
55 | + } |
|
56 | 56 | } |
@@ -40,7 +40,7 @@ |
||
40 | 40 | |
41 | 41 | public function extra_news_box_content($content) |
42 | 42 | { |
43 | - echo '<h3 style="margin:0">' . __('From the Forums', 'event_espresso') . '</h3>'; |
|
43 | + echo '<h3 style="margin:0">'.__('From the Forums', 'event_espresso').'</h3>'; |
|
44 | 44 | echo '<div id="ee_forum_posts_content">'; |
45 | 45 | $url = 'http://eventespresso.com/forum/event-espresso-support/feed/'; |
46 | 46 | EE_Admin_Page::cached_rss_display('ee_forum_posts_content', $url); |
@@ -11,80 +11,80 @@ |
||
11 | 11 | class EE_Term_Taxonomy extends EE_Base_Class |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @param array $props_n_values |
|
16 | - * @return EE_Term_Taxonomy |
|
17 | - */ |
|
18 | - public static function new_instance($props_n_values = array()) |
|
19 | - { |
|
20 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
21 | - return $has_object ? $has_object : new self($props_n_values); |
|
22 | - } |
|
14 | + /** |
|
15 | + * @param array $props_n_values |
|
16 | + * @return EE_Term_Taxonomy |
|
17 | + */ |
|
18 | + public static function new_instance($props_n_values = array()) |
|
19 | + { |
|
20 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
21 | + return $has_object ? $has_object : new self($props_n_values); |
|
22 | + } |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @param array $props_n_values |
|
27 | - * @return EE_Term_Taxonomy |
|
28 | - */ |
|
29 | - public static function new_instance_from_db($props_n_values = array()) |
|
30 | - { |
|
31 | - return new self($props_n_values, true); |
|
32 | - } |
|
25 | + /** |
|
26 | + * @param array $props_n_values |
|
27 | + * @return EE_Term_Taxonomy |
|
28 | + */ |
|
29 | + public static function new_instance_from_db($props_n_values = array()) |
|
30 | + { |
|
31 | + return new self($props_n_values, true); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Gets taxonomy |
|
37 | - * |
|
38 | - * @return string |
|
39 | - */ |
|
40 | - public function taxonomy() |
|
41 | - { |
|
42 | - return $this->get('taxonomy'); |
|
43 | - } |
|
35 | + /** |
|
36 | + * Gets taxonomy |
|
37 | + * |
|
38 | + * @return string |
|
39 | + */ |
|
40 | + public function taxonomy() |
|
41 | + { |
|
42 | + return $this->get('taxonomy'); |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * Sets taxonomy |
|
48 | - * |
|
49 | - * @param string $taxonomy |
|
50 | - * @return boolean |
|
51 | - */ |
|
52 | - public function set_taxonomy($taxonomy) |
|
53 | - { |
|
54 | - $this->set('taxonomy', $taxonomy); |
|
55 | - } |
|
46 | + /** |
|
47 | + * Sets taxonomy |
|
48 | + * |
|
49 | + * @param string $taxonomy |
|
50 | + * @return boolean |
|
51 | + */ |
|
52 | + public function set_taxonomy($taxonomy) |
|
53 | + { |
|
54 | + $this->set('taxonomy', $taxonomy); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * Gets term_count |
|
60 | - * |
|
61 | - * @return int |
|
62 | - */ |
|
63 | - public function count() |
|
64 | - { |
|
65 | - return $this->get('term_count'); |
|
66 | - } |
|
58 | + /** |
|
59 | + * Gets term_count |
|
60 | + * |
|
61 | + * @return int |
|
62 | + */ |
|
63 | + public function count() |
|
64 | + { |
|
65 | + return $this->get('term_count'); |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * Sets term_count |
|
71 | - * |
|
72 | - * @param int $term_count |
|
73 | - * @return boolean |
|
74 | - */ |
|
75 | - public function set_count($term_count) |
|
76 | - { |
|
77 | - $this->set('term_count', $term_count); |
|
78 | - } |
|
69 | + /** |
|
70 | + * Sets term_count |
|
71 | + * |
|
72 | + * @param int $term_count |
|
73 | + * @return boolean |
|
74 | + */ |
|
75 | + public function set_count($term_count) |
|
76 | + { |
|
77 | + $this->set('term_count', $term_count); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * Gets the term for this term taxonomy |
|
83 | - * |
|
84 | - * @return EE_Term |
|
85 | - */ |
|
86 | - public function term() |
|
87 | - { |
|
88 | - return $this->get_first_related('Term'); |
|
89 | - } |
|
81 | + /** |
|
82 | + * Gets the term for this term taxonomy |
|
83 | + * |
|
84 | + * @return EE_Term |
|
85 | + */ |
|
86 | + public function term() |
|
87 | + { |
|
88 | + return $this->get_first_related('Term'); |
|
89 | + } |
|
90 | 90 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function set_message_type($message_type = false) |
50 | 50 | { |
51 | - if (! $message_type) { |
|
51 | + if ( ! $message_type) { |
|
52 | 52 | throw new EE_Error(esc_html__('Missing required value for the message_type parameter', 'event_espresso')); |
53 | 53 | } |
54 | 54 | $this->set('MTP_message_type', $message_type); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function set_messenger($messenger = false) |
63 | 63 | { |
64 | - if (! $messenger) { |
|
64 | + if ( ! $messenger) { |
|
65 | 65 | throw new EE_Error(esc_html__('Missing required value for the messenger parameter', 'event_espresso')); |
66 | 66 | } |
67 | 67 | $this->set('MTP_messenger', $messenger); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function set_group_template_id($GRP_ID = false) |
76 | 76 | { |
77 | - if (! $GRP_ID) { |
|
77 | + if ( ! $GRP_ID) { |
|
78 | 78 | throw new EE_Error( |
79 | 79 | esc_html__( |
80 | 80 | 'Missing required value for the message template group id', |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | } |
291 | 291 | // note contexts could have CHECKBOX fields per context. So we return the objects indexed by context AND field. |
292 | 292 | foreach ($mtps as $mtp) { |
293 | - $mtps_arr[ $mtp->get('MTP_context') ][ $mtp->get('MTP_template_field') ] = $mtp; |
|
293 | + $mtps_arr[$mtp->get('MTP_context')][$mtp->get('MTP_template_field')] = $mtp; |
|
294 | 294 | } |
295 | 295 | return $mtps_arr; |
296 | 296 | } |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | public function deactivate_context($context) |
431 | 431 | { |
432 | 432 | $this->validate_context($context); |
433 | - return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, false); |
|
433 | + return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX.$context, false); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | public function activate_context($context) |
446 | 446 | { |
447 | 447 | $this->validate_context($context); |
448 | - return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true); |
|
448 | + return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX.$context, true); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | { |
466 | 466 | $this->validate_context($context); |
467 | 467 | return filter_var( |
468 | - $this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true, true), |
|
468 | + $this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX.$context, true, true), |
|
469 | 469 | FILTER_VALIDATE_BOOLEAN |
470 | 470 | ); |
471 | 471 | } |
@@ -481,7 +481,7 @@ discard block |
||
481 | 481 | public function validate_context($context) |
482 | 482 | { |
483 | 483 | $contexts = $this->contexts_config(); |
484 | - if (! isset($contexts[ $context ])) { |
|
484 | + if ( ! isset($contexts[$context])) { |
|
485 | 485 | throw new InvalidIdentifierException( |
486 | 486 | '', |
487 | 487 | '', |
@@ -13,487 +13,487 @@ |
||
13 | 13 | class EE_Message_Template_Group extends EE_Soft_Delete_Base_Class |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Extra Meta key prefix for whether a given context for this message tmeplate group is active or not. |
|
18 | - */ |
|
19 | - const ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX = 'active_context_'; |
|
20 | - |
|
21 | - /** |
|
22 | - * @param array $props_n_values |
|
23 | - * @param string $timezone |
|
24 | - * @return EE_Message_Template_Group|mixed |
|
25 | - * @throws EE_Error |
|
26 | - */ |
|
27 | - public static function new_instance($props_n_values = array(), $timezone = '') |
|
28 | - { |
|
29 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
30 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @param array $props_n_values |
|
36 | - * @param string $timezone |
|
37 | - * @return EE_Message_Template_Group |
|
38 | - */ |
|
39 | - public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
40 | - { |
|
41 | - return new self($props_n_values, true, $timezone); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * @param bool $message_type |
|
47 | - * @throws EE_Error |
|
48 | - */ |
|
49 | - public function set_message_type($message_type = false) |
|
50 | - { |
|
51 | - if (! $message_type) { |
|
52 | - throw new EE_Error(esc_html__('Missing required value for the message_type parameter', 'event_espresso')); |
|
53 | - } |
|
54 | - $this->set('MTP_message_type', $message_type); |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * @param bool $messenger |
|
60 | - * @throws EE_Error |
|
61 | - */ |
|
62 | - public function set_messenger($messenger = false) |
|
63 | - { |
|
64 | - if (! $messenger) { |
|
65 | - throw new EE_Error(esc_html__('Missing required value for the messenger parameter', 'event_espresso')); |
|
66 | - } |
|
67 | - $this->set('MTP_messenger', $messenger); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @param bool $GRP_ID |
|
73 | - * @throws EE_Error |
|
74 | - */ |
|
75 | - public function set_group_template_id($GRP_ID = false) |
|
76 | - { |
|
77 | - if (! $GRP_ID) { |
|
78 | - throw new EE_Error( |
|
79 | - esc_html__( |
|
80 | - 'Missing required value for the message template group id', |
|
81 | - 'event_espresso' |
|
82 | - ) |
|
83 | - ); |
|
84 | - } |
|
85 | - $this->set('GRP_ID', $GRP_ID); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * get Group ID |
|
91 | - * |
|
92 | - * @access public |
|
93 | - * @return int |
|
94 | - * @throws EE_Error |
|
95 | - */ |
|
96 | - public function GRP_ID() |
|
97 | - { |
|
98 | - return $this->get('GRP_ID'); |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * get User ID |
|
104 | - * |
|
105 | - * @access public |
|
106 | - * @return int |
|
107 | - * @throws EE_Error |
|
108 | - */ |
|
109 | - public function user() |
|
110 | - { |
|
111 | - $user_id = $this->get('MTP_user_id'); |
|
112 | - return empty($user_id) ? get_current_user_id() : $user_id; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * Wrapper for the user function() (preserve backward compat) |
|
118 | - * |
|
119 | - * @since 4.5.0 |
|
120 | - * @return int |
|
121 | - * @throws EE_Error |
|
122 | - */ |
|
123 | - public function wp_user() |
|
124 | - { |
|
125 | - return $this->user(); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * This simply returns a count of all related events to this message template group |
|
131 | - * |
|
132 | - * @return int |
|
133 | - */ |
|
134 | - public function count_events() |
|
135 | - { |
|
136 | - return $this->count_related('Event'); |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * returns the name saved in the db for this template |
|
142 | - * |
|
143 | - * @return string |
|
144 | - * @throws EE_Error |
|
145 | - */ |
|
146 | - public function name() |
|
147 | - { |
|
148 | - return $this->get('MTP_name'); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * Returns the description saved in the db for this template group |
|
154 | - * |
|
155 | - * @return string |
|
156 | - * @throws EE_Error |
|
157 | - */ |
|
158 | - public function description() |
|
159 | - { |
|
160 | - return $this->get('MTP_description'); |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * returns all related EE_Message_Template objects |
|
166 | - * |
|
167 | - * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
168 | - * @return EE_Message_Template[] |
|
169 | - * @throws EE_Error |
|
170 | - */ |
|
171 | - public function message_templates($query_params = array()) |
|
172 | - { |
|
173 | - return $this->get_many_related('Message_Template', $query_params); |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * get Message Messenger |
|
179 | - * |
|
180 | - * @access public |
|
181 | - * @return string |
|
182 | - * @throws EE_Error |
|
183 | - */ |
|
184 | - public function messenger() |
|
185 | - { |
|
186 | - return $this->get('MTP_messenger'); |
|
187 | - } |
|
188 | - |
|
189 | - |
|
190 | - /** |
|
191 | - * get Message Messenger OBJECT |
|
192 | - * If an attempt to get the corresponding messenger object fails, then we set this message |
|
193 | - * template group to inactive, and save to db. Then return null so client code can handle |
|
194 | - * appropriately. |
|
195 | - * |
|
196 | - * @return EE_messenger |
|
197 | - * @throws EE_Error |
|
198 | - */ |
|
199 | - public function messenger_obj() |
|
200 | - { |
|
201 | - $messenger = $this->messenger(); |
|
202 | - try { |
|
203 | - $messenger = EEH_MSG_Template::messenger_obj($messenger); |
|
204 | - } catch (EE_Error $e) { |
|
205 | - // if an exception was thrown then let's deactivate this message template group because it means there is no |
|
206 | - // class for this messenger in this group. |
|
207 | - $this->set('MTP_is_active', false); |
|
208 | - $this->save(); |
|
209 | - return null; |
|
210 | - } |
|
211 | - return $messenger; |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * get Message Type |
|
217 | - * |
|
218 | - * @access public |
|
219 | - * @return string |
|
220 | - * @throws EE_Error |
|
221 | - */ |
|
222 | - public function message_type() |
|
223 | - { |
|
224 | - return $this->get('MTP_message_type'); |
|
225 | - } |
|
226 | - |
|
227 | - |
|
228 | - /** |
|
229 | - * get Message type OBJECT |
|
230 | - * If an attempt to get the corresponding message type object fails, then we set this message |
|
231 | - * template group to inactive, and save to db. Then return null so client code can handle |
|
232 | - * appropriately. |
|
233 | - * |
|
234 | - * @throws EE_Error |
|
235 | - * @return EE_message_type|false if exception thrown. |
|
236 | - */ |
|
237 | - public function message_type_obj() |
|
238 | - { |
|
239 | - $message_type = $this->message_type(); |
|
240 | - try { |
|
241 | - $message_type = EEH_MSG_Template::message_type_obj($message_type); |
|
242 | - } catch (EE_Error $e) { |
|
243 | - // if an exception was thrown then let's deactivate this message template group because it means there is no |
|
244 | - // class for the message type in this group. |
|
245 | - $this->set('MTP_is_active', false); |
|
246 | - $this->save(); |
|
247 | - return null; |
|
248 | - } |
|
249 | - return $message_type; |
|
250 | - } |
|
251 | - |
|
252 | - |
|
253 | - /** |
|
254 | - * @return array |
|
255 | - * @throws EE_Error |
|
256 | - */ |
|
257 | - public function contexts_config() |
|
258 | - { |
|
259 | - return $this->message_type_obj()->get_contexts(); |
|
260 | - } |
|
261 | - |
|
262 | - |
|
263 | - /** |
|
264 | - * This returns the context_label for contexts as set in the message type object |
|
265 | - * Note this is an array with singular and plural keys |
|
266 | - * |
|
267 | - * @access public |
|
268 | - * @return array labels for "context" |
|
269 | - * @throws EE_Error |
|
270 | - */ |
|
271 | - public function context_label() |
|
272 | - { |
|
273 | - $obj = $this->message_type_obj(); |
|
274 | - return $obj->get_context_label(); |
|
275 | - } |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * This returns an array of EE_Message_Template objects indexed by context and field. |
|
280 | - * |
|
281 | - * @return array () |
|
282 | - * @throws EE_Error |
|
283 | - */ |
|
284 | - public function context_templates() |
|
285 | - { |
|
286 | - $mtps_arr = array(); |
|
287 | - $mtps = $this->get_many_related('Message_Template'); |
|
288 | - if (empty($mtps)) { |
|
289 | - return array(); |
|
290 | - } |
|
291 | - // note contexts could have CHECKBOX fields per context. So we return the objects indexed by context AND field. |
|
292 | - foreach ($mtps as $mtp) { |
|
293 | - $mtps_arr[ $mtp->get('MTP_context') ][ $mtp->get('MTP_template_field') ] = $mtp; |
|
294 | - } |
|
295 | - return $mtps_arr; |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * this returns if the template group this template belongs to is global |
|
301 | - * |
|
302 | - * @return bool true if it is, false if it isn't |
|
303 | - * @throws EE_Error |
|
304 | - */ |
|
305 | - public function is_global() |
|
306 | - { |
|
307 | - return $this->get('MTP_is_global'); |
|
308 | - } |
|
309 | - |
|
310 | - |
|
311 | - /** |
|
312 | - * this returns if the template group this template belongs to is active (i.e. turned "on" or not) |
|
313 | - * |
|
314 | - * @return bool true if it is, false if it isn't |
|
315 | - * @throws EE_Error |
|
316 | - */ |
|
317 | - public function is_active() |
|
318 | - { |
|
319 | - return $this->get('MTP_is_active'); |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - /** |
|
324 | - * This will return an array of shortcodes => labels from the messenger and message_type objects associated with |
|
325 | - * this template. |
|
326 | - * |
|
327 | - * @since 4.3.0 |
|
328 | - * @uses EEH_MSG_Template::get_shortcodes() |
|
329 | - * @param string $context what context we're going to return shortcodes for |
|
330 | - * @param array $fields what fields we're returning valid shortcodes for. If empty then we assume all fields are |
|
331 | - * to be returned. |
|
332 | - * @param bool $merged If TRUE then we don't return shortcodes indexed by field but instead an array of the |
|
333 | - * unique shortcodes for all the given (or all) fields. |
|
334 | - * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no |
|
335 | - * shortcodes found. |
|
336 | - * @throws EE_Error |
|
337 | - */ |
|
338 | - public function get_shortcodes($context, $fields = array(), $merged = false) |
|
339 | - { |
|
340 | - $messenger = $this->messenger(); |
|
341 | - $message_type = $this->message_type(); |
|
342 | - return EEH_MSG_Template::get_shortcodes($message_type, $messenger, $fields, $context, $merged); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * This just gets the template pack name assigned to this message template group. If it's not set, then we just |
|
348 | - * use the default template pack. |
|
349 | - * |
|
350 | - * @since 4.5.0 |
|
351 | - * @return string |
|
352 | - * @throws EE_Error |
|
353 | - */ |
|
354 | - public function get_template_pack_name() |
|
355 | - { |
|
356 | - return $this->get_extra_meta('MTP_template_pack', true, 'default'); |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * This returns the specific template pack object referenced by the template pack name attached to this message |
|
362 | - * template group. If no template pack is assigned then the default template pack is retrieved. |
|
363 | - * |
|
364 | - * @since 4.5.0 |
|
365 | - * @return EE_Messages_Template_Pack |
|
366 | - * @throws EE_Error |
|
367 | - * @throws InvalidArgumentException |
|
368 | - * @throws ReflectionException |
|
369 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
370 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
371 | - */ |
|
372 | - public function get_template_pack() |
|
373 | - { |
|
374 | - $pack_name = $this->get_template_pack_name(); |
|
375 | - EE_Registry::instance()->load_helper('MSG_Template'); |
|
376 | - return EEH_MSG_Template::get_template_pack($pack_name); |
|
377 | - } |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * This retrieves the template variation assigned to this message template group. If it's not set, then we just |
|
382 | - * use the default template variation. |
|
383 | - * |
|
384 | - * @since 4.5.0 |
|
385 | - * @return string |
|
386 | - * @throws EE_Error |
|
387 | - */ |
|
388 | - public function get_template_pack_variation() |
|
389 | - { |
|
390 | - return $this->get_extra_meta('MTP_variation', true, 'default'); |
|
391 | - } |
|
392 | - |
|
393 | - |
|
394 | - /** |
|
395 | - * This just sets the template pack name attached to this message template group. |
|
396 | - * |
|
397 | - * @since 4.5.0 |
|
398 | - * @param string $template_pack_name What message template pack is assigned. |
|
399 | - * @return int |
|
400 | - * @throws EE_Error |
|
401 | - */ |
|
402 | - public function set_template_pack_name($template_pack_name) |
|
403 | - { |
|
404 | - return $this->update_extra_meta('MTP_template_pack', $template_pack_name); |
|
405 | - } |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * This just sets the template pack variation attached to this message template group. |
|
410 | - * |
|
411 | - * @since 4.5.0 |
|
412 | - * @param string $variation What variation is being set on the message template group. |
|
413 | - * @return int |
|
414 | - * @throws EE_Error |
|
415 | - */ |
|
416 | - public function set_template_pack_variation($variation) |
|
417 | - { |
|
418 | - return $this->update_extra_meta('MTP_variation', $variation); |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - /** |
|
423 | - * Deactivates the given context. |
|
424 | - * |
|
425 | - * @param $context |
|
426 | - * @return bool|int |
|
427 | - * @throws EE_Error |
|
428 | - * @throws InvalidIdentifierException |
|
429 | - */ |
|
430 | - public function deactivate_context($context) |
|
431 | - { |
|
432 | - $this->validate_context($context); |
|
433 | - return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, false); |
|
434 | - } |
|
435 | - |
|
436 | - |
|
437 | - /** |
|
438 | - * Activates the given context. |
|
439 | - * |
|
440 | - * @param $context |
|
441 | - * @return bool|int |
|
442 | - * @throws EE_Error |
|
443 | - * @throws InvalidIdentifierException |
|
444 | - */ |
|
445 | - public function activate_context($context) |
|
446 | - { |
|
447 | - $this->validate_context($context); |
|
448 | - return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true); |
|
449 | - } |
|
450 | - |
|
451 | - |
|
452 | - /** |
|
453 | - * Returns whether the context is active or not. |
|
454 | - * Note, this will default to true if the extra meta record doesn't exist. |
|
455 | - * Also, this does NOT account for whether the "To" field is empty or not. Some messengers may allow the "To" field |
|
456 | - * to be empty (@see EE_Messenger::allow_empty_to_field()) so an empty "To" field is not always an indicator of |
|
457 | - * whether a context is "active" or not. |
|
458 | - * |
|
459 | - * @param $context |
|
460 | - * @return bool |
|
461 | - * @throws EE_Error |
|
462 | - * @throws InvalidIdentifierException |
|
463 | - */ |
|
464 | - public function is_context_active($context) |
|
465 | - { |
|
466 | - $this->validate_context($context); |
|
467 | - return filter_var( |
|
468 | - $this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true, true), |
|
469 | - FILTER_VALIDATE_BOOLEAN |
|
470 | - ); |
|
471 | - } |
|
472 | - |
|
473 | - |
|
474 | - /** |
|
475 | - * Validates the incoming context to verify it matches a registered context for the related message type. |
|
476 | - * |
|
477 | - * @param string $context |
|
478 | - * @throws EE_Error |
|
479 | - * @throws InvalidIdentifierException |
|
480 | - */ |
|
481 | - public function validate_context($context) |
|
482 | - { |
|
483 | - $contexts = $this->contexts_config(); |
|
484 | - if (! isset($contexts[ $context ])) { |
|
485 | - throw new InvalidIdentifierException( |
|
486 | - '', |
|
487 | - '', |
|
488 | - sprintf( |
|
489 | - esc_html__( |
|
490 | - 'An invalid string identifying a context was provided. "%1$s" was received, and one of "%2$s" was expected.', |
|
491 | - 'event_espresso' |
|
492 | - ), |
|
493 | - $context, |
|
494 | - implode(',', array_keys($contexts)) |
|
495 | - ) |
|
496 | - ); |
|
497 | - } |
|
498 | - } |
|
16 | + /** |
|
17 | + * Extra Meta key prefix for whether a given context for this message tmeplate group is active or not. |
|
18 | + */ |
|
19 | + const ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX = 'active_context_'; |
|
20 | + |
|
21 | + /** |
|
22 | + * @param array $props_n_values |
|
23 | + * @param string $timezone |
|
24 | + * @return EE_Message_Template_Group|mixed |
|
25 | + * @throws EE_Error |
|
26 | + */ |
|
27 | + public static function new_instance($props_n_values = array(), $timezone = '') |
|
28 | + { |
|
29 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
30 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @param array $props_n_values |
|
36 | + * @param string $timezone |
|
37 | + * @return EE_Message_Template_Group |
|
38 | + */ |
|
39 | + public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
40 | + { |
|
41 | + return new self($props_n_values, true, $timezone); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * @param bool $message_type |
|
47 | + * @throws EE_Error |
|
48 | + */ |
|
49 | + public function set_message_type($message_type = false) |
|
50 | + { |
|
51 | + if (! $message_type) { |
|
52 | + throw new EE_Error(esc_html__('Missing required value for the message_type parameter', 'event_espresso')); |
|
53 | + } |
|
54 | + $this->set('MTP_message_type', $message_type); |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * @param bool $messenger |
|
60 | + * @throws EE_Error |
|
61 | + */ |
|
62 | + public function set_messenger($messenger = false) |
|
63 | + { |
|
64 | + if (! $messenger) { |
|
65 | + throw new EE_Error(esc_html__('Missing required value for the messenger parameter', 'event_espresso')); |
|
66 | + } |
|
67 | + $this->set('MTP_messenger', $messenger); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @param bool $GRP_ID |
|
73 | + * @throws EE_Error |
|
74 | + */ |
|
75 | + public function set_group_template_id($GRP_ID = false) |
|
76 | + { |
|
77 | + if (! $GRP_ID) { |
|
78 | + throw new EE_Error( |
|
79 | + esc_html__( |
|
80 | + 'Missing required value for the message template group id', |
|
81 | + 'event_espresso' |
|
82 | + ) |
|
83 | + ); |
|
84 | + } |
|
85 | + $this->set('GRP_ID', $GRP_ID); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * get Group ID |
|
91 | + * |
|
92 | + * @access public |
|
93 | + * @return int |
|
94 | + * @throws EE_Error |
|
95 | + */ |
|
96 | + public function GRP_ID() |
|
97 | + { |
|
98 | + return $this->get('GRP_ID'); |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * get User ID |
|
104 | + * |
|
105 | + * @access public |
|
106 | + * @return int |
|
107 | + * @throws EE_Error |
|
108 | + */ |
|
109 | + public function user() |
|
110 | + { |
|
111 | + $user_id = $this->get('MTP_user_id'); |
|
112 | + return empty($user_id) ? get_current_user_id() : $user_id; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * Wrapper for the user function() (preserve backward compat) |
|
118 | + * |
|
119 | + * @since 4.5.0 |
|
120 | + * @return int |
|
121 | + * @throws EE_Error |
|
122 | + */ |
|
123 | + public function wp_user() |
|
124 | + { |
|
125 | + return $this->user(); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * This simply returns a count of all related events to this message template group |
|
131 | + * |
|
132 | + * @return int |
|
133 | + */ |
|
134 | + public function count_events() |
|
135 | + { |
|
136 | + return $this->count_related('Event'); |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * returns the name saved in the db for this template |
|
142 | + * |
|
143 | + * @return string |
|
144 | + * @throws EE_Error |
|
145 | + */ |
|
146 | + public function name() |
|
147 | + { |
|
148 | + return $this->get('MTP_name'); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * Returns the description saved in the db for this template group |
|
154 | + * |
|
155 | + * @return string |
|
156 | + * @throws EE_Error |
|
157 | + */ |
|
158 | + public function description() |
|
159 | + { |
|
160 | + return $this->get('MTP_description'); |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * returns all related EE_Message_Template objects |
|
166 | + * |
|
167 | + * @param array $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md |
|
168 | + * @return EE_Message_Template[] |
|
169 | + * @throws EE_Error |
|
170 | + */ |
|
171 | + public function message_templates($query_params = array()) |
|
172 | + { |
|
173 | + return $this->get_many_related('Message_Template', $query_params); |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * get Message Messenger |
|
179 | + * |
|
180 | + * @access public |
|
181 | + * @return string |
|
182 | + * @throws EE_Error |
|
183 | + */ |
|
184 | + public function messenger() |
|
185 | + { |
|
186 | + return $this->get('MTP_messenger'); |
|
187 | + } |
|
188 | + |
|
189 | + |
|
190 | + /** |
|
191 | + * get Message Messenger OBJECT |
|
192 | + * If an attempt to get the corresponding messenger object fails, then we set this message |
|
193 | + * template group to inactive, and save to db. Then return null so client code can handle |
|
194 | + * appropriately. |
|
195 | + * |
|
196 | + * @return EE_messenger |
|
197 | + * @throws EE_Error |
|
198 | + */ |
|
199 | + public function messenger_obj() |
|
200 | + { |
|
201 | + $messenger = $this->messenger(); |
|
202 | + try { |
|
203 | + $messenger = EEH_MSG_Template::messenger_obj($messenger); |
|
204 | + } catch (EE_Error $e) { |
|
205 | + // if an exception was thrown then let's deactivate this message template group because it means there is no |
|
206 | + // class for this messenger in this group. |
|
207 | + $this->set('MTP_is_active', false); |
|
208 | + $this->save(); |
|
209 | + return null; |
|
210 | + } |
|
211 | + return $messenger; |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * get Message Type |
|
217 | + * |
|
218 | + * @access public |
|
219 | + * @return string |
|
220 | + * @throws EE_Error |
|
221 | + */ |
|
222 | + public function message_type() |
|
223 | + { |
|
224 | + return $this->get('MTP_message_type'); |
|
225 | + } |
|
226 | + |
|
227 | + |
|
228 | + /** |
|
229 | + * get Message type OBJECT |
|
230 | + * If an attempt to get the corresponding message type object fails, then we set this message |
|
231 | + * template group to inactive, and save to db. Then return null so client code can handle |
|
232 | + * appropriately. |
|
233 | + * |
|
234 | + * @throws EE_Error |
|
235 | + * @return EE_message_type|false if exception thrown. |
|
236 | + */ |
|
237 | + public function message_type_obj() |
|
238 | + { |
|
239 | + $message_type = $this->message_type(); |
|
240 | + try { |
|
241 | + $message_type = EEH_MSG_Template::message_type_obj($message_type); |
|
242 | + } catch (EE_Error $e) { |
|
243 | + // if an exception was thrown then let's deactivate this message template group because it means there is no |
|
244 | + // class for the message type in this group. |
|
245 | + $this->set('MTP_is_active', false); |
|
246 | + $this->save(); |
|
247 | + return null; |
|
248 | + } |
|
249 | + return $message_type; |
|
250 | + } |
|
251 | + |
|
252 | + |
|
253 | + /** |
|
254 | + * @return array |
|
255 | + * @throws EE_Error |
|
256 | + */ |
|
257 | + public function contexts_config() |
|
258 | + { |
|
259 | + return $this->message_type_obj()->get_contexts(); |
|
260 | + } |
|
261 | + |
|
262 | + |
|
263 | + /** |
|
264 | + * This returns the context_label for contexts as set in the message type object |
|
265 | + * Note this is an array with singular and plural keys |
|
266 | + * |
|
267 | + * @access public |
|
268 | + * @return array labels for "context" |
|
269 | + * @throws EE_Error |
|
270 | + */ |
|
271 | + public function context_label() |
|
272 | + { |
|
273 | + $obj = $this->message_type_obj(); |
|
274 | + return $obj->get_context_label(); |
|
275 | + } |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * This returns an array of EE_Message_Template objects indexed by context and field. |
|
280 | + * |
|
281 | + * @return array () |
|
282 | + * @throws EE_Error |
|
283 | + */ |
|
284 | + public function context_templates() |
|
285 | + { |
|
286 | + $mtps_arr = array(); |
|
287 | + $mtps = $this->get_many_related('Message_Template'); |
|
288 | + if (empty($mtps)) { |
|
289 | + return array(); |
|
290 | + } |
|
291 | + // note contexts could have CHECKBOX fields per context. So we return the objects indexed by context AND field. |
|
292 | + foreach ($mtps as $mtp) { |
|
293 | + $mtps_arr[ $mtp->get('MTP_context') ][ $mtp->get('MTP_template_field') ] = $mtp; |
|
294 | + } |
|
295 | + return $mtps_arr; |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * this returns if the template group this template belongs to is global |
|
301 | + * |
|
302 | + * @return bool true if it is, false if it isn't |
|
303 | + * @throws EE_Error |
|
304 | + */ |
|
305 | + public function is_global() |
|
306 | + { |
|
307 | + return $this->get('MTP_is_global'); |
|
308 | + } |
|
309 | + |
|
310 | + |
|
311 | + /** |
|
312 | + * this returns if the template group this template belongs to is active (i.e. turned "on" or not) |
|
313 | + * |
|
314 | + * @return bool true if it is, false if it isn't |
|
315 | + * @throws EE_Error |
|
316 | + */ |
|
317 | + public function is_active() |
|
318 | + { |
|
319 | + return $this->get('MTP_is_active'); |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + /** |
|
324 | + * This will return an array of shortcodes => labels from the messenger and message_type objects associated with |
|
325 | + * this template. |
|
326 | + * |
|
327 | + * @since 4.3.0 |
|
328 | + * @uses EEH_MSG_Template::get_shortcodes() |
|
329 | + * @param string $context what context we're going to return shortcodes for |
|
330 | + * @param array $fields what fields we're returning valid shortcodes for. If empty then we assume all fields are |
|
331 | + * to be returned. |
|
332 | + * @param bool $merged If TRUE then we don't return shortcodes indexed by field but instead an array of the |
|
333 | + * unique shortcodes for all the given (or all) fields. |
|
334 | + * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no |
|
335 | + * shortcodes found. |
|
336 | + * @throws EE_Error |
|
337 | + */ |
|
338 | + public function get_shortcodes($context, $fields = array(), $merged = false) |
|
339 | + { |
|
340 | + $messenger = $this->messenger(); |
|
341 | + $message_type = $this->message_type(); |
|
342 | + return EEH_MSG_Template::get_shortcodes($message_type, $messenger, $fields, $context, $merged); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * This just gets the template pack name assigned to this message template group. If it's not set, then we just |
|
348 | + * use the default template pack. |
|
349 | + * |
|
350 | + * @since 4.5.0 |
|
351 | + * @return string |
|
352 | + * @throws EE_Error |
|
353 | + */ |
|
354 | + public function get_template_pack_name() |
|
355 | + { |
|
356 | + return $this->get_extra_meta('MTP_template_pack', true, 'default'); |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * This returns the specific template pack object referenced by the template pack name attached to this message |
|
362 | + * template group. If no template pack is assigned then the default template pack is retrieved. |
|
363 | + * |
|
364 | + * @since 4.5.0 |
|
365 | + * @return EE_Messages_Template_Pack |
|
366 | + * @throws EE_Error |
|
367 | + * @throws InvalidArgumentException |
|
368 | + * @throws ReflectionException |
|
369 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
370 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
371 | + */ |
|
372 | + public function get_template_pack() |
|
373 | + { |
|
374 | + $pack_name = $this->get_template_pack_name(); |
|
375 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
376 | + return EEH_MSG_Template::get_template_pack($pack_name); |
|
377 | + } |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * This retrieves the template variation assigned to this message template group. If it's not set, then we just |
|
382 | + * use the default template variation. |
|
383 | + * |
|
384 | + * @since 4.5.0 |
|
385 | + * @return string |
|
386 | + * @throws EE_Error |
|
387 | + */ |
|
388 | + public function get_template_pack_variation() |
|
389 | + { |
|
390 | + return $this->get_extra_meta('MTP_variation', true, 'default'); |
|
391 | + } |
|
392 | + |
|
393 | + |
|
394 | + /** |
|
395 | + * This just sets the template pack name attached to this message template group. |
|
396 | + * |
|
397 | + * @since 4.5.0 |
|
398 | + * @param string $template_pack_name What message template pack is assigned. |
|
399 | + * @return int |
|
400 | + * @throws EE_Error |
|
401 | + */ |
|
402 | + public function set_template_pack_name($template_pack_name) |
|
403 | + { |
|
404 | + return $this->update_extra_meta('MTP_template_pack', $template_pack_name); |
|
405 | + } |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * This just sets the template pack variation attached to this message template group. |
|
410 | + * |
|
411 | + * @since 4.5.0 |
|
412 | + * @param string $variation What variation is being set on the message template group. |
|
413 | + * @return int |
|
414 | + * @throws EE_Error |
|
415 | + */ |
|
416 | + public function set_template_pack_variation($variation) |
|
417 | + { |
|
418 | + return $this->update_extra_meta('MTP_variation', $variation); |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + /** |
|
423 | + * Deactivates the given context. |
|
424 | + * |
|
425 | + * @param $context |
|
426 | + * @return bool|int |
|
427 | + * @throws EE_Error |
|
428 | + * @throws InvalidIdentifierException |
|
429 | + */ |
|
430 | + public function deactivate_context($context) |
|
431 | + { |
|
432 | + $this->validate_context($context); |
|
433 | + return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, false); |
|
434 | + } |
|
435 | + |
|
436 | + |
|
437 | + /** |
|
438 | + * Activates the given context. |
|
439 | + * |
|
440 | + * @param $context |
|
441 | + * @return bool|int |
|
442 | + * @throws EE_Error |
|
443 | + * @throws InvalidIdentifierException |
|
444 | + */ |
|
445 | + public function activate_context($context) |
|
446 | + { |
|
447 | + $this->validate_context($context); |
|
448 | + return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true); |
|
449 | + } |
|
450 | + |
|
451 | + |
|
452 | + /** |
|
453 | + * Returns whether the context is active or not. |
|
454 | + * Note, this will default to true if the extra meta record doesn't exist. |
|
455 | + * Also, this does NOT account for whether the "To" field is empty or not. Some messengers may allow the "To" field |
|
456 | + * to be empty (@see EE_Messenger::allow_empty_to_field()) so an empty "To" field is not always an indicator of |
|
457 | + * whether a context is "active" or not. |
|
458 | + * |
|
459 | + * @param $context |
|
460 | + * @return bool |
|
461 | + * @throws EE_Error |
|
462 | + * @throws InvalidIdentifierException |
|
463 | + */ |
|
464 | + public function is_context_active($context) |
|
465 | + { |
|
466 | + $this->validate_context($context); |
|
467 | + return filter_var( |
|
468 | + $this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true, true), |
|
469 | + FILTER_VALIDATE_BOOLEAN |
|
470 | + ); |
|
471 | + } |
|
472 | + |
|
473 | + |
|
474 | + /** |
|
475 | + * Validates the incoming context to verify it matches a registered context for the related message type. |
|
476 | + * |
|
477 | + * @param string $context |
|
478 | + * @throws EE_Error |
|
479 | + * @throws InvalidIdentifierException |
|
480 | + */ |
|
481 | + public function validate_context($context) |
|
482 | + { |
|
483 | + $contexts = $this->contexts_config(); |
|
484 | + if (! isset($contexts[ $context ])) { |
|
485 | + throw new InvalidIdentifierException( |
|
486 | + '', |
|
487 | + '', |
|
488 | + sprintf( |
|
489 | + esc_html__( |
|
490 | + 'An invalid string identifying a context was provided. "%1$s" was received, and one of "%2$s" was expected.', |
|
491 | + 'event_espresso' |
|
492 | + ), |
|
493 | + $context, |
|
494 | + implode(',', array_keys($contexts)) |
|
495 | + ) |
|
496 | + ); |
|
497 | + } |
|
498 | + } |
|
499 | 499 | } |
@@ -13,173 +13,173 @@ |
||
13 | 13 | class EE_Message_Template extends EE_Base_Class |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @param array $props_n_values |
|
18 | - * @param string $timezone |
|
19 | - * @return EE_Message_Template|mixed |
|
20 | - */ |
|
21 | - public static function new_instance($props_n_values = array(), $timezone = '') |
|
22 | - { |
|
23 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
24 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
25 | - } |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * @param array $props_n_values |
|
30 | - * @param string $timezone |
|
31 | - * @return EE_Message_Template |
|
32 | - */ |
|
33 | - public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
34 | - { |
|
35 | - return new self($props_n_values, true, $timezone); |
|
36 | - } |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * @param bool $GRP_ID |
|
41 | - * @throws EE_Error |
|
42 | - */ |
|
43 | - public function set_group_template_id($GRP_ID = false) |
|
44 | - { |
|
45 | - if (! $GRP_ID) { |
|
46 | - throw new EE_Error(__('Missing required value for the message template group id', 'event_espresso')); |
|
47 | - } |
|
48 | - $this->set('GRP_ID', $GRP_ID); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * get Group ID |
|
54 | - * |
|
55 | - * @access public |
|
56 | - * @return int |
|
57 | - */ |
|
58 | - public function GRP_ID() |
|
59 | - { |
|
60 | - return $this->get('GRP_ID'); |
|
61 | - } |
|
62 | - |
|
63 | - |
|
64 | - /** |
|
65 | - * get User ID |
|
66 | - * |
|
67 | - * @access public |
|
68 | - * @return int |
|
69 | - */ |
|
70 | - public function user() |
|
71 | - { |
|
72 | - return $this->get_first_related('Message_Template_Group')->get('MTP_user_id'); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * get Message Messenger |
|
78 | - * |
|
79 | - * @access public |
|
80 | - * @return string |
|
81 | - */ |
|
82 | - public function messenger() |
|
83 | - { |
|
84 | - return $this->get_first_related('Message_Template_Group')->messenger(); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * get Message Messenger OBJECT |
|
90 | - * |
|
91 | - * @access public |
|
92 | - * @return object Messenger Object for the given messenger |
|
93 | - */ |
|
94 | - public function messenger_obj() |
|
95 | - { |
|
96 | - return $this->get_first_related('Message_Template_Group')->messenger_obj(); |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * get Message Type |
|
102 | - * |
|
103 | - * @access public |
|
104 | - * @return string |
|
105 | - */ |
|
106 | - public function message_type() |
|
107 | - { |
|
108 | - return $this->get_first_related('Message_Template_Group')->message_type(); |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * get Message type OBJECT |
|
114 | - * |
|
115 | - * @access public |
|
116 | - * @return object Message Type object for the given message type |
|
117 | - */ |
|
118 | - public function message_type_obj() |
|
119 | - { |
|
120 | - return $this->get_first_related('Message_Template_Group')->message_type_obj(); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * This returns the set context array configured in the message type object |
|
126 | - * |
|
127 | - * @access public |
|
128 | - * @return array array of contexts and their configuration. |
|
129 | - */ |
|
130 | - public function contexts_config() |
|
131 | - { |
|
132 | - return $this->get_first_related('Message_Template_Group')->contexts_config(); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * This returns the context_label for contexts as set in the message type object |
|
138 | - * |
|
139 | - * @access public |
|
140 | - * @return string label for "context" |
|
141 | - */ |
|
142 | - public function context_label() |
|
143 | - { |
|
144 | - return $this->get_first_related('Message_Template_Group')->context_label(); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * this returns if the template group this template belongs to is global |
|
150 | - * |
|
151 | - * @return boolean true if it is, false if it isn't |
|
152 | - */ |
|
153 | - public function is_global() |
|
154 | - { |
|
155 | - return $this->get_first_related('Message_Template_Group')->is_global(); |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * this returns if the template group this template belongs to is active (i.e. turned "on" or not) |
|
161 | - * |
|
162 | - * @return boolean true if it is, false if it isn't |
|
163 | - */ |
|
164 | - public function is_active() |
|
165 | - { |
|
166 | - return $this->get_first_related('Message_Template_Group')->is_active(); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * This will return an array of shortcodes => labels from the messenger and message_type objects associated with |
|
172 | - * this template. |
|
173 | - * |
|
174 | - * @access public |
|
175 | - * @param string $context what context we're going to return shortcodes for |
|
176 | - * @param array $fields what fields we're returning valid shortcodes for. If empty then we assume all fields are |
|
177 | - * to be merged and returned. |
|
178 | - * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no |
|
179 | - * shortcodes found. |
|
180 | - */ |
|
181 | - public function get_shortcodes($context, $fields = array()) |
|
182 | - { |
|
183 | - return $this->get_first_related('Message_Template_Group')->get_shortcodes($context, $fields); |
|
184 | - } |
|
16 | + /** |
|
17 | + * @param array $props_n_values |
|
18 | + * @param string $timezone |
|
19 | + * @return EE_Message_Template|mixed |
|
20 | + */ |
|
21 | + public static function new_instance($props_n_values = array(), $timezone = '') |
|
22 | + { |
|
23 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
24 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
25 | + } |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * @param array $props_n_values |
|
30 | + * @param string $timezone |
|
31 | + * @return EE_Message_Template |
|
32 | + */ |
|
33 | + public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
34 | + { |
|
35 | + return new self($props_n_values, true, $timezone); |
|
36 | + } |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * @param bool $GRP_ID |
|
41 | + * @throws EE_Error |
|
42 | + */ |
|
43 | + public function set_group_template_id($GRP_ID = false) |
|
44 | + { |
|
45 | + if (! $GRP_ID) { |
|
46 | + throw new EE_Error(__('Missing required value for the message template group id', 'event_espresso')); |
|
47 | + } |
|
48 | + $this->set('GRP_ID', $GRP_ID); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * get Group ID |
|
54 | + * |
|
55 | + * @access public |
|
56 | + * @return int |
|
57 | + */ |
|
58 | + public function GRP_ID() |
|
59 | + { |
|
60 | + return $this->get('GRP_ID'); |
|
61 | + } |
|
62 | + |
|
63 | + |
|
64 | + /** |
|
65 | + * get User ID |
|
66 | + * |
|
67 | + * @access public |
|
68 | + * @return int |
|
69 | + */ |
|
70 | + public function user() |
|
71 | + { |
|
72 | + return $this->get_first_related('Message_Template_Group')->get('MTP_user_id'); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * get Message Messenger |
|
78 | + * |
|
79 | + * @access public |
|
80 | + * @return string |
|
81 | + */ |
|
82 | + public function messenger() |
|
83 | + { |
|
84 | + return $this->get_first_related('Message_Template_Group')->messenger(); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * get Message Messenger OBJECT |
|
90 | + * |
|
91 | + * @access public |
|
92 | + * @return object Messenger Object for the given messenger |
|
93 | + */ |
|
94 | + public function messenger_obj() |
|
95 | + { |
|
96 | + return $this->get_first_related('Message_Template_Group')->messenger_obj(); |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * get Message Type |
|
102 | + * |
|
103 | + * @access public |
|
104 | + * @return string |
|
105 | + */ |
|
106 | + public function message_type() |
|
107 | + { |
|
108 | + return $this->get_first_related('Message_Template_Group')->message_type(); |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * get Message type OBJECT |
|
114 | + * |
|
115 | + * @access public |
|
116 | + * @return object Message Type object for the given message type |
|
117 | + */ |
|
118 | + public function message_type_obj() |
|
119 | + { |
|
120 | + return $this->get_first_related('Message_Template_Group')->message_type_obj(); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * This returns the set context array configured in the message type object |
|
126 | + * |
|
127 | + * @access public |
|
128 | + * @return array array of contexts and their configuration. |
|
129 | + */ |
|
130 | + public function contexts_config() |
|
131 | + { |
|
132 | + return $this->get_first_related('Message_Template_Group')->contexts_config(); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * This returns the context_label for contexts as set in the message type object |
|
138 | + * |
|
139 | + * @access public |
|
140 | + * @return string label for "context" |
|
141 | + */ |
|
142 | + public function context_label() |
|
143 | + { |
|
144 | + return $this->get_first_related('Message_Template_Group')->context_label(); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * this returns if the template group this template belongs to is global |
|
150 | + * |
|
151 | + * @return boolean true if it is, false if it isn't |
|
152 | + */ |
|
153 | + public function is_global() |
|
154 | + { |
|
155 | + return $this->get_first_related('Message_Template_Group')->is_global(); |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * this returns if the template group this template belongs to is active (i.e. turned "on" or not) |
|
161 | + * |
|
162 | + * @return boolean true if it is, false if it isn't |
|
163 | + */ |
|
164 | + public function is_active() |
|
165 | + { |
|
166 | + return $this->get_first_related('Message_Template_Group')->is_active(); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * This will return an array of shortcodes => labels from the messenger and message_type objects associated with |
|
172 | + * this template. |
|
173 | + * |
|
174 | + * @access public |
|
175 | + * @param string $context what context we're going to return shortcodes for |
|
176 | + * @param array $fields what fields we're returning valid shortcodes for. If empty then we assume all fields are |
|
177 | + * to be merged and returned. |
|
178 | + * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no |
|
179 | + * shortcodes found. |
|
180 | + */ |
|
181 | + public function get_shortcodes($context, $fields = array()) |
|
182 | + { |
|
183 | + return $this->get_first_related('Message_Template_Group')->get_shortcodes($context, $fields); |
|
184 | + } |
|
185 | 185 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | */ |
43 | 43 | public function set_group_template_id($GRP_ID = false) |
44 | 44 | { |
45 | - if (! $GRP_ID) { |
|
45 | + if ( ! $GRP_ID) { |
|
46 | 46 | throw new EE_Error(__('Missing required value for the message template group id', 'event_espresso')); |
47 | 47 | } |
48 | 48 | $this->set('GRP_ID', $GRP_ID); |
@@ -11,25 +11,25 @@ |
||
11 | 11 | class EE_Ticket_Price extends EE_Base_Class |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * @param array $props_n_values |
|
16 | - * @param string $timezone |
|
17 | - * @return EE_Ticket_Price|mixed |
|
18 | - */ |
|
19 | - public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array()) |
|
20 | - { |
|
21 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
22 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
23 | - } |
|
14 | + /** |
|
15 | + * @param array $props_n_values |
|
16 | + * @param string $timezone |
|
17 | + * @return EE_Ticket_Price|mixed |
|
18 | + */ |
|
19 | + public static function new_instance($props_n_values = array(), $timezone = '', $date_formats = array()) |
|
20 | + { |
|
21 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
22 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @param array $props_n_values |
|
28 | - * @param string $timezone |
|
29 | - * @return EE_Ticket_Price |
|
30 | - */ |
|
31 | - public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
32 | - { |
|
33 | - return new self($props_n_values, true, $timezone); |
|
34 | - } |
|
26 | + /** |
|
27 | + * @param array $props_n_values |
|
28 | + * @param string $timezone |
|
29 | + * @return EE_Ticket_Price |
|
30 | + */ |
|
31 | + public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
32 | + { |
|
33 | + return new self($props_n_values, true, $timezone); |
|
34 | + } |
|
35 | 35 | } |
@@ -12,25 +12,25 @@ |
||
12 | 12 | class EE_Ticket_Template extends EE_Base_Class |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * @param array $props_n_values |
|
17 | - * @param string $timezone |
|
18 | - * @return EE_Ticket_Template|mixed |
|
19 | - */ |
|
20 | - public static function new_instance($props_n_values = array(), $timezone = '') |
|
21 | - { |
|
22 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
23 | - return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
24 | - } |
|
15 | + /** |
|
16 | + * @param array $props_n_values |
|
17 | + * @param string $timezone |
|
18 | + * @return EE_Ticket_Template|mixed |
|
19 | + */ |
|
20 | + public static function new_instance($props_n_values = array(), $timezone = '') |
|
21 | + { |
|
22 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone); |
|
23 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone); |
|
24 | + } |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * @param array $props_n_values |
|
29 | - * @param string $timezone |
|
30 | - * @return EE_Ticket_Template |
|
31 | - */ |
|
32 | - public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
33 | - { |
|
34 | - return new self($props_n_values, true, $timezone); |
|
35 | - } |
|
27 | + /** |
|
28 | + * @param array $props_n_values |
|
29 | + * @param string $timezone |
|
30 | + * @return EE_Ticket_Template |
|
31 | + */ |
|
32 | + public static function new_instance_from_db($props_n_values = array(), $timezone = '') |
|
33 | + { |
|
34 | + return new self($props_n_values, true, $timezone); |
|
35 | + } |
|
36 | 36 | } |
@@ -10,115 +10,115 @@ |
||
10 | 10 | class EE_Extra_Meta extends EE_Base_Class |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @param array $props_n_values |
|
15 | - * @return EE_Extra_Meta|mixed |
|
16 | - */ |
|
17 | - public static function new_instance($props_n_values = array()) |
|
18 | - { |
|
19 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
20 | - return $has_object ? $has_object : new self($props_n_values); |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * @param array $props_n_values |
|
26 | - * @return EE_Extra_Meta |
|
27 | - */ |
|
28 | - public static function new_instance_from_db($props_n_values = array()) |
|
29 | - { |
|
30 | - return new self($props_n_values, true); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Gets FK_ID |
|
36 | - * |
|
37 | - * @return int |
|
38 | - */ |
|
39 | - public function FK_ID() |
|
40 | - { |
|
41 | - return $this->get('FK_ID'); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * Sets FK_ID |
|
47 | - * |
|
48 | - * @param int $FK_ID |
|
49 | - * @return boolean |
|
50 | - */ |
|
51 | - public function set_FK_ID($FK_ID) |
|
52 | - { |
|
53 | - $this->set('FK_ID', $FK_ID); |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * Gets model |
|
59 | - * |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function model() |
|
63 | - { |
|
64 | - return $this->get('EXM_model'); |
|
65 | - } |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * Sets model |
|
70 | - * |
|
71 | - * @param string $model |
|
72 | - * @return boolean |
|
73 | - */ |
|
74 | - public function set_model($model) |
|
75 | - { |
|
76 | - $this->set('EXM_model', $model); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * Gets key |
|
82 | - * |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function key() |
|
86 | - { |
|
87 | - return $this->get('EXM_key'); |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * Sets key |
|
93 | - * |
|
94 | - * @param string $key |
|
95 | - * @return boolean |
|
96 | - */ |
|
97 | - public function set_key($key) |
|
98 | - { |
|
99 | - $this->set('EXM_key', $key); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * Gets value |
|
105 | - * |
|
106 | - * @return string |
|
107 | - */ |
|
108 | - public function value() |
|
109 | - { |
|
110 | - return $this->get('EXM_value'); |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * Sets value |
|
116 | - * |
|
117 | - * @param string $value |
|
118 | - * @return boolean |
|
119 | - */ |
|
120 | - public function set_value($value) |
|
121 | - { |
|
122 | - $this->set('EXM_value', $value); |
|
123 | - } |
|
13 | + /** |
|
14 | + * @param array $props_n_values |
|
15 | + * @return EE_Extra_Meta|mixed |
|
16 | + */ |
|
17 | + public static function new_instance($props_n_values = array()) |
|
18 | + { |
|
19 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
20 | + return $has_object ? $has_object : new self($props_n_values); |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * @param array $props_n_values |
|
26 | + * @return EE_Extra_Meta |
|
27 | + */ |
|
28 | + public static function new_instance_from_db($props_n_values = array()) |
|
29 | + { |
|
30 | + return new self($props_n_values, true); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Gets FK_ID |
|
36 | + * |
|
37 | + * @return int |
|
38 | + */ |
|
39 | + public function FK_ID() |
|
40 | + { |
|
41 | + return $this->get('FK_ID'); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * Sets FK_ID |
|
47 | + * |
|
48 | + * @param int $FK_ID |
|
49 | + * @return boolean |
|
50 | + */ |
|
51 | + public function set_FK_ID($FK_ID) |
|
52 | + { |
|
53 | + $this->set('FK_ID', $FK_ID); |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * Gets model |
|
59 | + * |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function model() |
|
63 | + { |
|
64 | + return $this->get('EXM_model'); |
|
65 | + } |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * Sets model |
|
70 | + * |
|
71 | + * @param string $model |
|
72 | + * @return boolean |
|
73 | + */ |
|
74 | + public function set_model($model) |
|
75 | + { |
|
76 | + $this->set('EXM_model', $model); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * Gets key |
|
82 | + * |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function key() |
|
86 | + { |
|
87 | + return $this->get('EXM_key'); |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * Sets key |
|
93 | + * |
|
94 | + * @param string $key |
|
95 | + * @return boolean |
|
96 | + */ |
|
97 | + public function set_key($key) |
|
98 | + { |
|
99 | + $this->set('EXM_key', $key); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * Gets value |
|
105 | + * |
|
106 | + * @return string |
|
107 | + */ |
|
108 | + public function value() |
|
109 | + { |
|
110 | + return $this->get('EXM_value'); |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * Sets value |
|
116 | + * |
|
117 | + * @param string $value |
|
118 | + * @return boolean |
|
119 | + */ |
|
120 | + public function set_value($value) |
|
121 | + { |
|
122 | + $this->set('EXM_value', $value); |
|
123 | + } |
|
124 | 124 | } |
@@ -10,112 +10,112 @@ |
||
10 | 10 | class EE_Post_Meta extends EE_Base_Class |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * @param array $props_n_values |
|
15 | - * @return EE_Post_Meta|mixed |
|
16 | - */ |
|
17 | - public static function new_instance($props_n_values = array()) |
|
18 | - { |
|
19 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
20 | - return $has_object ? $has_object : new self($props_n_values); |
|
21 | - } |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * @param array $props_n_values |
|
26 | - * @return EE_Post_Meta |
|
27 | - */ |
|
28 | - public static function new_instance_from_db($props_n_values = array()) |
|
29 | - { |
|
30 | - return new self($props_n_values, true); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Gets meta_id |
|
36 | - * |
|
37 | - * @return int |
|
38 | - */ |
|
39 | - public function meta_id() |
|
40 | - { |
|
41 | - return $this->get('meta_id'); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * Sets meta_id |
|
47 | - * |
|
48 | - * @param int $meta_id |
|
49 | - * @return boolean |
|
50 | - */ |
|
51 | - public function set_meta_id($meta_id) |
|
52 | - { |
|
53 | - return $this->set('meta_id', $meta_id); |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * Gets post_id |
|
58 | - * |
|
59 | - * @return int |
|
60 | - */ |
|
61 | - public function post_id() |
|
62 | - { |
|
63 | - return $this->get('post_id'); |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * Sets post_id |
|
69 | - * |
|
70 | - * @param int $post_id |
|
71 | - * @return boolean |
|
72 | - */ |
|
73 | - public function set_post_id($post_id) |
|
74 | - { |
|
75 | - return $this->set('post_id', $post_id); |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Gets meta_key |
|
80 | - * |
|
81 | - * @return string |
|
82 | - */ |
|
83 | - public function meta_key() |
|
84 | - { |
|
85 | - return $this->get('meta_key'); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * Sets meta_key |
|
91 | - * |
|
92 | - * @param string $meta_key |
|
93 | - * @return boolean |
|
94 | - */ |
|
95 | - public function set_meta_key($meta_key) |
|
96 | - { |
|
97 | - return $this->set('meta_key', $meta_key); |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Gets meta_value |
|
102 | - * |
|
103 | - * @return mixed |
|
104 | - */ |
|
105 | - public function meta_value() |
|
106 | - { |
|
107 | - return $this->get('meta_value'); |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * Sets meta_value |
|
113 | - * |
|
114 | - * @param mixed $meta_value |
|
115 | - * @return boolean |
|
116 | - */ |
|
117 | - public function set_meta_value($meta_value) |
|
118 | - { |
|
119 | - return $this->set('meta_value', $meta_value); |
|
120 | - } |
|
13 | + /** |
|
14 | + * @param array $props_n_values |
|
15 | + * @return EE_Post_Meta|mixed |
|
16 | + */ |
|
17 | + public static function new_instance($props_n_values = array()) |
|
18 | + { |
|
19 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
20 | + return $has_object ? $has_object : new self($props_n_values); |
|
21 | + } |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * @param array $props_n_values |
|
26 | + * @return EE_Post_Meta |
|
27 | + */ |
|
28 | + public static function new_instance_from_db($props_n_values = array()) |
|
29 | + { |
|
30 | + return new self($props_n_values, true); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Gets meta_id |
|
36 | + * |
|
37 | + * @return int |
|
38 | + */ |
|
39 | + public function meta_id() |
|
40 | + { |
|
41 | + return $this->get('meta_id'); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * Sets meta_id |
|
47 | + * |
|
48 | + * @param int $meta_id |
|
49 | + * @return boolean |
|
50 | + */ |
|
51 | + public function set_meta_id($meta_id) |
|
52 | + { |
|
53 | + return $this->set('meta_id', $meta_id); |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * Gets post_id |
|
58 | + * |
|
59 | + * @return int |
|
60 | + */ |
|
61 | + public function post_id() |
|
62 | + { |
|
63 | + return $this->get('post_id'); |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * Sets post_id |
|
69 | + * |
|
70 | + * @param int $post_id |
|
71 | + * @return boolean |
|
72 | + */ |
|
73 | + public function set_post_id($post_id) |
|
74 | + { |
|
75 | + return $this->set('post_id', $post_id); |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Gets meta_key |
|
80 | + * |
|
81 | + * @return string |
|
82 | + */ |
|
83 | + public function meta_key() |
|
84 | + { |
|
85 | + return $this->get('meta_key'); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * Sets meta_key |
|
91 | + * |
|
92 | + * @param string $meta_key |
|
93 | + * @return boolean |
|
94 | + */ |
|
95 | + public function set_meta_key($meta_key) |
|
96 | + { |
|
97 | + return $this->set('meta_key', $meta_key); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Gets meta_value |
|
102 | + * |
|
103 | + * @return mixed |
|
104 | + */ |
|
105 | + public function meta_value() |
|
106 | + { |
|
107 | + return $this->get('meta_value'); |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * Sets meta_value |
|
113 | + * |
|
114 | + * @param mixed $meta_value |
|
115 | + * @return boolean |
|
116 | + */ |
|
117 | + public function set_meta_value($meta_value) |
|
118 | + { |
|
119 | + return $this->set('meta_value', $meta_value); |
|
120 | + } |
|
121 | 121 | } |