@@ -15,135 +15,135 @@ |
||
15 | 15 | class Pricing_Default_Prices_Help_Tour extends EE_Help_Tour |
16 | 16 | { |
17 | 17 | |
18 | - protected function _set_tour_properties() |
|
19 | - { |
|
20 | - $this->_label = __('Default Pricing Tour', 'event_espresso'); |
|
21 | - $this->_slug = 'default-prices-joyride'; |
|
22 | - } |
|
18 | + protected function _set_tour_properties() |
|
19 | + { |
|
20 | + $this->_label = __('Default Pricing Tour', 'event_espresso'); |
|
21 | + $this->_slug = 'default-prices-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' => 'type', |
|
42 | - 'content' => $this->_type_column_stop(), |
|
43 | - 'options' => array( |
|
44 | - 'tipLocation' => 'top', |
|
45 | - 'tipAdjustmentX' => 5, |
|
46 | - 'tipAdjustmentY' => -30, |
|
47 | - ), |
|
48 | - ), |
|
49 | - 40 => array( |
|
50 | - 'id' => 'description', |
|
51 | - 'content' => $this->_description_column_stop(), |
|
52 | - 'options' => array( |
|
53 | - 'tipLocation' => 'top', |
|
54 | - 'tipAdjustmentX' => 5, |
|
55 | - 'tipAdjustmentY' => -30, |
|
56 | - ), |
|
57 | - ), |
|
58 | - 50 => array( |
|
59 | - 'id' => 'amount', |
|
60 | - 'content' => $this->_amount_column_stop(), |
|
61 | - 'options' => array( |
|
62 | - 'tipLocation' => 'left', |
|
63 | - 'tipAdjustmentY' => -50, |
|
64 | - 'tipAdjustmentX' => 20, |
|
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' => 'type', |
|
42 | + 'content' => $this->_type_column_stop(), |
|
43 | + 'options' => array( |
|
44 | + 'tipLocation' => 'top', |
|
45 | + 'tipAdjustmentX' => 5, |
|
46 | + 'tipAdjustmentY' => -30, |
|
47 | + ), |
|
48 | + ), |
|
49 | + 40 => array( |
|
50 | + 'id' => 'description', |
|
51 | + 'content' => $this->_description_column_stop(), |
|
52 | + 'options' => array( |
|
53 | + 'tipLocation' => 'top', |
|
54 | + 'tipAdjustmentX' => 5, |
|
55 | + 'tipAdjustmentY' => -30, |
|
56 | + ), |
|
57 | + ), |
|
58 | + 50 => array( |
|
59 | + 'id' => 'amount', |
|
60 | + 'content' => $this->_amount_column_stop(), |
|
61 | + 'options' => array( |
|
62 | + 'tipLocation' => 'left', |
|
63 | + 'tipAdjustmentY' => -50, |
|
64 | + 'tipAdjustmentX' => 20, |
|
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>' . __('Default Pricing', 'event_espresso') . '</h3>'; |
|
92 | - $content .= '<p>' |
|
93 | - . __( |
|
94 | - 'This tour of the Default Pricing 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>' . __('Default Pricing', 'event_espresso') . '</h3>'; |
|
92 | + $content .= '<p>' |
|
93 | + . __( |
|
94 | + 'This tour of the Default Pricing 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, discount, tax, or surcharge that will be seen by your customers. 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, discount, tax, or surcharge that will be seen by your customers. Can be sorted in ascending or descending order.', |
|
105 | + 'event_espresso' |
|
106 | + ) . '</p>'; |
|
107 | + } |
|
108 | 108 | |
109 | - protected function _type_column_stop() |
|
110 | - { |
|
111 | - return '<p>' |
|
112 | - . __( |
|
113 | - 'Price Types are a way of categorizing a price, discount, tax, or surcharge and indicating how it gets applied to a running total when a transaction occurs. Can be sorted in ascending or descending order.', |
|
114 | - 'event_espresso' |
|
115 | - ) . '</p>'; |
|
116 | - } |
|
109 | + protected function _type_column_stop() |
|
110 | + { |
|
111 | + return '<p>' |
|
112 | + . __( |
|
113 | + 'Price Types are a way of categorizing a price, discount, tax, or surcharge and indicating how it gets applied to a running total when a transaction occurs. Can be sorted in ascending or descending order.', |
|
114 | + 'event_espresso' |
|
115 | + ) . '</p>'; |
|
116 | + } |
|
117 | 117 | |
118 | - protected function _description_column_stop() |
|
119 | - { |
|
120 | - return '<p>' |
|
121 | - . __( |
|
122 | - 'View the price type (price, discount, tax or surcharge) description.', |
|
123 | - 'event_espresso' |
|
124 | - ) . '</p>'; |
|
125 | - } |
|
118 | + protected function _description_column_stop() |
|
119 | + { |
|
120 | + return '<p>' |
|
121 | + . __( |
|
122 | + 'View the price type (price, discount, tax or surcharge) description.', |
|
123 | + 'event_espresso' |
|
124 | + ) . '</p>'; |
|
125 | + } |
|
126 | 126 | |
127 | - protected function _amount_column_stop() |
|
128 | - { |
|
129 | - return '<p>' |
|
130 | - . __( |
|
131 | - 'The ticket amount before any deductions. Can be sorted in ascending or descending order.', |
|
132 | - 'event_espresso' |
|
133 | - ) . '</p>'; |
|
134 | - } |
|
127 | + protected function _amount_column_stop() |
|
128 | + { |
|
129 | + return '<p>' |
|
130 | + . __( |
|
131 | + 'The ticket amount before any deductions. Can be sorted in ascending or descending order.', |
|
132 | + 'event_espresso' |
|
133 | + ) . '</p>'; |
|
134 | + } |
|
135 | 135 | |
136 | - protected function _bulk_actions_stop() |
|
137 | - { |
|
138 | - return '<p>' . __('Perform bulk actions to multiple price types.', 'event_espresso') . '</p>'; |
|
139 | - } |
|
136 | + protected function _bulk_actions_stop() |
|
137 | + { |
|
138 | + return '<p>' . __('Perform bulk actions to multiple price types.', 'event_espresso') . '</p>'; |
|
139 | + } |
|
140 | 140 | |
141 | - protected function _search_stop() |
|
142 | - { |
|
143 | - return '<p>' |
|
144 | - . __( |
|
145 | - 'Search through default pricing. The following sources will be searched: Price Name, Price Type, Price Description, and Price Amount.', |
|
146 | - 'event_espresso' |
|
147 | - ) . '</p>'; |
|
148 | - } |
|
141 | + protected function _search_stop() |
|
142 | + { |
|
143 | + return '<p>' |
|
144 | + . __( |
|
145 | + 'Search through default pricing. The following sources will be searched: Price Name, Price Type, Price Description, and Price Amount.', |
|
146 | + 'event_espresso' |
|
147 | + ) . '</p>'; |
|
148 | + } |
|
149 | 149 | } |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | |
89 | 89 | protected function _start() |
90 | 90 | { |
91 | - $content = '<h3>' . __('Default Pricing', 'event_espresso') . '</h3>'; |
|
91 | + $content = '<h3>'.__('Default Pricing', 'event_espresso').'</h3>'; |
|
92 | 92 | $content .= '<p>' |
93 | 93 | . __( |
94 | 94 | 'This tour of the Default Pricing 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,7 +103,7 @@ discard block |
||
103 | 103 | . __( |
104 | 104 | 'The name of the price, discount, tax, or surcharge that will be seen by your customers. Can be sorted in ascending or descending order.', |
105 | 105 | 'event_espresso' |
106 | - ) . '</p>'; |
|
106 | + ).'</p>'; |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | protected function _type_column_stop() |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | . __( |
113 | 113 | 'Price Types are a way of categorizing a price, discount, tax, or surcharge and indicating how it gets applied to a running total when a transaction occurs. Can be sorted in ascending or descending order.', |
114 | 114 | 'event_espresso' |
115 | - ) . '</p>'; |
|
115 | + ).'</p>'; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | protected function _description_column_stop() |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | . __( |
122 | 122 | 'View the price type (price, discount, tax or surcharge) description.', |
123 | 123 | 'event_espresso' |
124 | - ) . '</p>'; |
|
124 | + ).'</p>'; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | protected function _amount_column_stop() |
@@ -130,12 +130,12 @@ discard block |
||
130 | 130 | . __( |
131 | 131 | 'The ticket amount before any deductions. Can be sorted in ascending or descending order.', |
132 | 132 | 'event_espresso' |
133 | - ) . '</p>'; |
|
133 | + ).'</p>'; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | protected function _bulk_actions_stop() |
137 | 137 | { |
138 | - return '<p>' . __('Perform bulk actions to multiple price types.', 'event_espresso') . '</p>'; |
|
138 | + return '<p>'.__('Perform bulk actions to multiple price types.', 'event_espresso').'</p>'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | protected function _search_stop() |
@@ -144,6 +144,6 @@ discard block |
||
144 | 144 | . __( |
145 | 145 | 'Search through default pricing. The following sources will be searched: Price Name, Price Type, Price Description, and Price Amount.', |
146 | 146 | 'event_espresso' |
147 | - ) . '</p>'; |
|
147 | + ).'</p>'; |
|
148 | 148 | } |
149 | 149 | } |
@@ -15,84 +15,84 @@ |
||
15 | 15 | class Pricing_Edit_Price_Type_Help_Tour extends EE_Help_Tour |
16 | 16 | { |
17 | 17 | |
18 | - protected function _set_tour_properties() |
|
19 | - { |
|
20 | - $this->_label = __('Edit Price Type Tour', 'event_espresso'); |
|
21 | - $this->_slug = 'edit-price-type-joyride'; |
|
22 | - } |
|
18 | + protected function _set_tour_properties() |
|
19 | + { |
|
20 | + $this->_label = __('Edit Price Type Tour', 'event_espresso'); |
|
21 | + $this->_slug = 'edit-price-type-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' => 'base_type', |
|
33 | - 'content' => $this->_basic_type_stop(), |
|
34 | - 'options' => array( |
|
35 | - 'tipLocation' => 'top', |
|
36 | - 'tipAdjustmentY' => -50, |
|
37 | - 'tipAdjustmentX' => -15, |
|
38 | - ), |
|
39 | - ), |
|
40 | - 30 => array( |
|
41 | - 'id' => 'PRT_name', |
|
42 | - 'content' => $this->_price_type_name_stop(), |
|
43 | - 'options' => array( |
|
44 | - 'tipLocation' => 'top', |
|
45 | - 'tipAdjustmentY' => -40, |
|
46 | - ), |
|
47 | - ), |
|
48 | - 40 => array( |
|
49 | - 'id' => 'PRT_name', |
|
50 | - 'content' => $this->_percentage_dollar_amount_stop(), |
|
51 | - 'options' => array( |
|
52 | - 'tipLocation' => 'top', |
|
53 | - 'tipAdjustmentY' => 45, |
|
54 | - ), |
|
55 | - ), |
|
56 | - 50 => array( |
|
57 | - 'id' => 'PRT_order', |
|
58 | - 'content' => $this->_order_of_application_stop(), |
|
59 | - 'options' => array( |
|
60 | - 'tipLocation' => 'top', |
|
61 | - 'tipAdjustmentY' => -40, |
|
62 | - ), |
|
63 | - ), |
|
64 | - ); |
|
65 | - } |
|
25 | + protected function _set_tour_stops() |
|
26 | + { |
|
27 | + $this->_stops = array( |
|
28 | + 10 => array( |
|
29 | + 'content' => $this->_start(), |
|
30 | + ), |
|
31 | + 20 => array( |
|
32 | + 'id' => 'base_type', |
|
33 | + 'content' => $this->_basic_type_stop(), |
|
34 | + 'options' => array( |
|
35 | + 'tipLocation' => 'top', |
|
36 | + 'tipAdjustmentY' => -50, |
|
37 | + 'tipAdjustmentX' => -15, |
|
38 | + ), |
|
39 | + ), |
|
40 | + 30 => array( |
|
41 | + 'id' => 'PRT_name', |
|
42 | + 'content' => $this->_price_type_name_stop(), |
|
43 | + 'options' => array( |
|
44 | + 'tipLocation' => 'top', |
|
45 | + 'tipAdjustmentY' => -40, |
|
46 | + ), |
|
47 | + ), |
|
48 | + 40 => array( |
|
49 | + 'id' => 'PRT_name', |
|
50 | + 'content' => $this->_percentage_dollar_amount_stop(), |
|
51 | + 'options' => array( |
|
52 | + 'tipLocation' => 'top', |
|
53 | + 'tipAdjustmentY' => 45, |
|
54 | + ), |
|
55 | + ), |
|
56 | + 50 => array( |
|
57 | + 'id' => 'PRT_order', |
|
58 | + 'content' => $this->_order_of_application_stop(), |
|
59 | + 'options' => array( |
|
60 | + 'tipLocation' => 'top', |
|
61 | + 'tipAdjustmentY' => -40, |
|
62 | + ), |
|
63 | + ), |
|
64 | + ); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - protected function _start() |
|
69 | - { |
|
70 | - $content = '<h3>' . __('Edit Price Type', 'event_espresso') . '</h3>'; |
|
71 | - $content .= '<p>' |
|
72 | - . __( |
|
73 | - 'This tour of the Edit Price Type page will go over different areas of the screen to help you understand what they are used for.', |
|
74 | - 'event_espresso' |
|
75 | - ) . '</p>'; |
|
76 | - return $content; |
|
77 | - } |
|
68 | + protected function _start() |
|
69 | + { |
|
70 | + $content = '<h3>' . __('Edit Price Type', 'event_espresso') . '</h3>'; |
|
71 | + $content .= '<p>' |
|
72 | + . __( |
|
73 | + 'This tour of the Edit Price Type page will go over different areas of the screen to help you understand what they are used for.', |
|
74 | + 'event_espresso' |
|
75 | + ) . '</p>'; |
|
76 | + return $content; |
|
77 | + } |
|
78 | 78 | |
79 | - protected function _basic_type_stop() |
|
80 | - { |
|
81 | - return '<p>' . __('Set a price type to be a discount, surcharge, or tax.', 'event_espresso') . '</p>'; |
|
82 | - } |
|
79 | + protected function _basic_type_stop() |
|
80 | + { |
|
81 | + return '<p>' . __('Set a price type to be a discount, surcharge, or tax.', 'event_espresso') . '</p>'; |
|
82 | + } |
|
83 | 83 | |
84 | - protected function _price_type_name_stop() |
|
85 | - { |
|
86 | - return '<p>' . __('The name of the price type.', 'event_espresso') . '</p>'; |
|
87 | - } |
|
84 | + protected function _price_type_name_stop() |
|
85 | + { |
|
86 | + return '<p>' . __('The name of the price type.', 'event_espresso') . '</p>'; |
|
87 | + } |
|
88 | 88 | |
89 | - protected function _percentage_dollar_amount_stop() |
|
90 | - { |
|
91 | - return '<p>' . __('Set a price type to be percentage-based or a fixed amount.', 'event_espresso') . '</p>'; |
|
92 | - } |
|
89 | + protected function _percentage_dollar_amount_stop() |
|
90 | + { |
|
91 | + return '<p>' . __('Set a price type to be percentage-based or a fixed amount.', 'event_espresso') . '</p>'; |
|
92 | + } |
|
93 | 93 | |
94 | - protected function _order_of_application_stop() |
|
95 | - { |
|
96 | - return '<p>' . __('Set the order of application for a price type.', 'event_espresso') . '</p>'; |
|
97 | - } |
|
94 | + protected function _order_of_application_stop() |
|
95 | + { |
|
96 | + return '<p>' . __('Set the order of application for a price type.', 'event_espresso') . '</p>'; |
|
97 | + } |
|
98 | 98 | } |
@@ -67,32 +67,32 @@ |
||
67 | 67 | |
68 | 68 | protected function _start() |
69 | 69 | { |
70 | - $content = '<h3>' . __('Edit Price Type', 'event_espresso') . '</h3>'; |
|
70 | + $content = '<h3>'.__('Edit Price Type', 'event_espresso').'</h3>'; |
|
71 | 71 | $content .= '<p>' |
72 | 72 | . __( |
73 | 73 | 'This tour of the Edit Price Type page will go over different areas of the screen to help you understand what they are used for.', |
74 | 74 | 'event_espresso' |
75 | - ) . '</p>'; |
|
75 | + ).'</p>'; |
|
76 | 76 | return $content; |
77 | 77 | } |
78 | 78 | |
79 | 79 | protected function _basic_type_stop() |
80 | 80 | { |
81 | - return '<p>' . __('Set a price type to be a discount, surcharge, or tax.', 'event_espresso') . '</p>'; |
|
81 | + return '<p>'.__('Set a price type to be a discount, surcharge, or tax.', 'event_espresso').'</p>'; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | protected function _price_type_name_stop() |
85 | 85 | { |
86 | - return '<p>' . __('The name of the price type.', 'event_espresso') . '</p>'; |
|
86 | + return '<p>'.__('The name of the price type.', 'event_espresso').'</p>'; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | protected function _percentage_dollar_amount_stop() |
90 | 90 | { |
91 | - return '<p>' . __('Set a price type to be percentage-based or a fixed amount.', 'event_espresso') . '</p>'; |
|
91 | + return '<p>'.__('Set a price type to be percentage-based or a fixed amount.', 'event_espresso').'</p>'; |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | protected function _order_of_application_stop() |
95 | 95 | { |
96 | - return '<p>' . __('Set the order of application for a price type.', 'event_espresso') . '</p>'; |
|
96 | + return '<p>'.__('Set the order of application for a price type.', 'event_espresso').'</p>'; |
|
97 | 97 | } |
98 | 98 | } |
@@ -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); |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | public function wp_post() |
41 | 41 | { |
42 | 42 | global $wpdb; |
43 | - if (! $this->_wp_post instanceof WP_Post) { |
|
43 | + if ( ! $this->_wp_post instanceof WP_Post) { |
|
44 | 44 | if ($this->ID()) { |
45 | 45 | $this->_wp_post = get_post($this->ID()); |
46 | 46 | } else { |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | // and let's make retrieving the EE CPT object easy too |
67 | 67 | $classname = get_class($this); |
68 | - if (! isset($this->_wp_post->{$classname})) { |
|
68 | + if ( ! isset($this->_wp_post->{$classname})) { |
|
69 | 69 | $this->_wp_post->{$classname} = $this; |
70 | 70 | } |
71 | 71 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function remove_relation_to_term_taxonomy($term_taxonomy) |
146 | 146 | { |
147 | - if (! $term_taxonomy) { |
|
147 | + if ( ! $term_taxonomy) { |
|
148 | 148 | EE_Error::add_error( |
149 | 149 | sprintf( |
150 | 150 | __( |
@@ -225,10 +225,10 @@ discard block |
||
225 | 225 | { |
226 | 226 | // first let's see if we already have the _feature_image property set AND if it has a cached element on it FOR the given size |
227 | 227 | $attr_key = is_array($attr) ? implode('_', $attr) : $attr; |
228 | - $cache_key = is_array($size) ? implode('_', $size) . $attr_key : $size . $attr_key; |
|
229 | - $this->_feature_image[ $cache_key ] = isset($this->_feature_image[ $cache_key ]) |
|
230 | - ? $this->_feature_image[ $cache_key ] : $this->get_model()->get_feature_image($this->ID(), $size, $attr); |
|
231 | - return $this->_feature_image[ $cache_key ]; |
|
228 | + $cache_key = is_array($size) ? implode('_', $size).$attr_key : $size.$attr_key; |
|
229 | + $this->_feature_image[$cache_key] = isset($this->_feature_image[$cache_key]) |
|
230 | + ? $this->_feature_image[$cache_key] : $this->get_model()->get_feature_image($this->ID(), $size, $attr); |
|
231 | + return $this->_feature_image[$cache_key]; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | foreach ($related_obj_names as $related_name) { |
296 | 296 | // related_obj_name so we're saving a revision on an object related to this object |
297 | 297 | // do we have $where_query params for this related object? If we do then we include that. |
298 | - $cols_n_values = isset($where_query[ $related_name ]) ? $where_query[ $related_name ] : array(); |
|
298 | + $cols_n_values = isset($where_query[$related_name]) ? $where_query[$related_name] : array(); |
|
299 | 299 | $where_params = ! empty($cols_n_values) ? array($cols_n_values) : array(); |
300 | 300 | $related_objs = $this->get_many_related($related_name, $where_params); |
301 | 301 | $revision_related_objs = $revision_obj->get_many_related($related_name, $where_params); |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | */ |
345 | 345 | public function update_post_meta($meta_key, $meta_value, $prev_value = null) |
346 | 346 | { |
347 | - if (! $this->ID()) { |
|
347 | + if ( ! $this->ID()) { |
|
348 | 348 | $this->save(); |
349 | 349 | } |
350 | 350 | return update_post_meta($this->ID(), $meta_key, $meta_value, $prev_value); |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | */ |
379 | 379 | public function delete_post_meta($meta_key, $meta_value = '') |
380 | 380 | { |
381 | - if (! $this->ID()) { |
|
381 | + if ( ! $this->ID()) { |
|
382 | 382 | // there are obviously no postmetas for this if it's not saved |
383 | 383 | // so let's just report this as a success |
384 | 384 | return true; |
@@ -14,432 +14,432 @@ |
||
14 | 14 | abstract class EE_CPT_Base extends EE_Soft_Delete_Base_Class |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * This is a property for holding cached feature images on CPT objects. Cache's are set on the first |
|
19 | - * "feature_image()" method call. Each key in the array corresponds to the requested size. |
|
20 | - * |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - protected $_feature_image = array(); |
|
24 | - |
|
25 | - /** |
|
26 | - * @var WP_Post the WP_Post that corresponds with this CPT model object |
|
27 | - */ |
|
28 | - protected $_wp_post; |
|
29 | - |
|
30 | - |
|
31 | - abstract public function wp_user(); |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Returns the WP post associated with this CPT model object. If this CPT is saved, fetches it |
|
36 | - * from the DB. Otherwise, create an unsaved WP_POst object. Caches the post internally. |
|
37 | - * |
|
38 | - * @return WP_Post |
|
39 | - */ |
|
40 | - public function wp_post() |
|
41 | - { |
|
42 | - global $wpdb; |
|
43 | - if (! $this->_wp_post instanceof WP_Post) { |
|
44 | - if ($this->ID()) { |
|
45 | - $this->_wp_post = get_post($this->ID()); |
|
46 | - } else { |
|
47 | - $simulated_db_result = new stdClass(); |
|
48 | - foreach ($this->get_model()->field_settings(true) as $field_name => $field_obj) { |
|
49 | - if ( |
|
50 | - $this->get_model()->get_table_obj_by_alias($field_obj->get_table_alias())->get_table_name() |
|
51 | - === $wpdb->posts |
|
52 | - ) { |
|
53 | - $column = $field_obj->get_table_column(); |
|
54 | - |
|
55 | - if ($field_obj instanceof EE_Datetime_Field) { |
|
56 | - $value_on_model_obj = $this->get_DateTime_object($field_name); |
|
57 | - } elseif ($field_obj->is_db_only_field()) { |
|
58 | - $value_on_model_obj = $field_obj->get_default_value(); |
|
59 | - } else { |
|
60 | - $value_on_model_obj = $this->get_raw($field_name); |
|
61 | - } |
|
62 | - $simulated_db_result->{$column} = $field_obj->prepare_for_use_in_db($value_on_model_obj); |
|
63 | - } |
|
64 | - } |
|
65 | - $this->_wp_post = new WP_Post($simulated_db_result); |
|
66 | - } |
|
67 | - // and let's make retrieving the EE CPT object easy too |
|
68 | - $classname = get_class($this); |
|
69 | - if (! isset($this->_wp_post->{$classname})) { |
|
70 | - $this->_wp_post->{$classname} = $this; |
|
71 | - } |
|
72 | - } |
|
73 | - return $this->_wp_post; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * When fetching a new value for a post field that uses the global $post for rendering, |
|
78 | - * set the global $post temporarily to be this model object; and afterwards restore it |
|
79 | - * |
|
80 | - * @param string $fieldname |
|
81 | - * @param bool $pretty |
|
82 | - * @param string $extra_cache_ref |
|
83 | - * @return mixed |
|
84 | - */ |
|
85 | - protected function _get_fresh_property($fieldname, $pretty = false, $extra_cache_ref = null) |
|
86 | - { |
|
87 | - global $post; |
|
88 | - |
|
89 | - if ( |
|
90 | - $pretty |
|
91 | - && ( |
|
92 | - ! ( |
|
93 | - $post instanceof WP_Post |
|
94 | - && $post->ID |
|
95 | - ) |
|
96 | - || (int) $post->ID !== $this->ID() |
|
97 | - ) |
|
98 | - && $this->get_model()->field_settings_for($fieldname) instanceof EE_Post_Content_Field |
|
99 | - ) { |
|
100 | - $old_post = $post; |
|
101 | - $post = $this->wp_post(); |
|
102 | - $return_value = parent::_get_fresh_property($fieldname, $pretty, $extra_cache_ref); |
|
103 | - $post = $old_post; |
|
104 | - } else { |
|
105 | - $return_value = parent::_get_fresh_property($fieldname, $pretty, $extra_cache_ref); |
|
106 | - } |
|
107 | - return $return_value; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Adds to the specified event category. If it category doesn't exist, creates it. |
|
112 | - * |
|
113 | - * @param string $category_name |
|
114 | - * @param string $category_description optional |
|
115 | - * @param int $parent_term_taxonomy_id optional |
|
116 | - * @return EE_Term_Taxonomy |
|
117 | - */ |
|
118 | - public function add_event_category($category_name, $category_description = null, $parent_term_taxonomy_id = null) |
|
119 | - { |
|
120 | - return $this->get_model()->add_event_category( |
|
121 | - $this, |
|
122 | - $category_name, |
|
123 | - $category_description, |
|
124 | - $parent_term_taxonomy_id |
|
125 | - ); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * Removes the event category by specified name from being related ot this event |
|
131 | - * |
|
132 | - * @param string $category_name |
|
133 | - * @return bool |
|
134 | - */ |
|
135 | - public function remove_event_category($category_name) |
|
136 | - { |
|
137 | - return $this->get_model()->remove_event_category($this, $category_name); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * Removes the relation to the specified term taxonomy, and maintains the |
|
143 | - * data integrity of the term taxonomy provided |
|
144 | - * |
|
145 | - * @param EE_Term_Taxonomy $term_taxonomy |
|
146 | - * @return EE_Base_Class the relation was removed from |
|
147 | - */ |
|
148 | - public function remove_relation_to_term_taxonomy($term_taxonomy) |
|
149 | - { |
|
150 | - if (! $term_taxonomy) { |
|
151 | - EE_Error::add_error( |
|
152 | - sprintf( |
|
153 | - __( |
|
154 | - "No Term_Taxonomy provided which to remove from model object of type %s and id %d", |
|
155 | - "event_espresso" |
|
156 | - ), |
|
157 | - get_class($this), |
|
158 | - $this->ID() |
|
159 | - ), |
|
160 | - __FILE__, |
|
161 | - __FUNCTION__, |
|
162 | - __LINE__ |
|
163 | - ); |
|
164 | - return null; |
|
165 | - } |
|
166 | - $term_taxonomy->set_count($term_taxonomy->count() - 1); |
|
167 | - $term_taxonomy->save(); |
|
168 | - return $this->_remove_relation_to($term_taxonomy, 'Term_Taxonomy'); |
|
169 | - } |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * The main purpose of this method is to return the post type for the model object |
|
174 | - * |
|
175 | - * @access public |
|
176 | - * @return string |
|
177 | - */ |
|
178 | - public function post_type() |
|
179 | - { |
|
180 | - return $this->get_model()->post_type(); |
|
181 | - } |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * The main purpose of this method is to return the parent for the model object |
|
186 | - * |
|
187 | - * @access public |
|
188 | - * @return int |
|
189 | - */ |
|
190 | - public function parent() |
|
191 | - { |
|
192 | - return $this->get('parent'); |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - /** |
|
197 | - * return the _status property |
|
198 | - * |
|
199 | - * @return string |
|
200 | - */ |
|
201 | - public function status() |
|
202 | - { |
|
203 | - return $this->get('status'); |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * @param string $status |
|
209 | - */ |
|
210 | - public function set_status($status) |
|
211 | - { |
|
212 | - $this->set('status', $status); |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - /** |
|
217 | - * This calls the equivalent model method for retrieving the feature image which in turn is a wrapper for |
|
218 | - * WordPress' get_the_post_thumbnail() function. |
|
219 | - * |
|
220 | - * @link http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail |
|
221 | - * @access protected |
|
222 | - * @param string|array $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array |
|
223 | - * representing width and height in pixels (i.e. array(32,32) ). |
|
224 | - * @param string|array $attr Optional. Query string or array of attributes. |
|
225 | - * @return string HTML image element |
|
226 | - */ |
|
227 | - protected function _get_feature_image($size, $attr) |
|
228 | - { |
|
229 | - // first let's see if we already have the _feature_image property set AND if it has a cached element on it FOR the given size |
|
230 | - $attr_key = is_array($attr) ? implode('_', $attr) : $attr; |
|
231 | - $cache_key = is_array($size) ? implode('_', $size) . $attr_key : $size . $attr_key; |
|
232 | - $this->_feature_image[ $cache_key ] = isset($this->_feature_image[ $cache_key ]) |
|
233 | - ? $this->_feature_image[ $cache_key ] : $this->get_model()->get_feature_image($this->ID(), $size, $attr); |
|
234 | - return $this->_feature_image[ $cache_key ]; |
|
235 | - } |
|
236 | - |
|
237 | - |
|
238 | - /** |
|
239 | - * See _get_feature_image. Returns the HTML to display a featured image |
|
240 | - * |
|
241 | - * @param string $size |
|
242 | - * @param string|array $attr |
|
243 | - * @return string of html |
|
244 | - */ |
|
245 | - public function feature_image($size = 'thumbnail', $attr = '') |
|
246 | - { |
|
247 | - return $this->_get_feature_image($size, $attr); |
|
248 | - } |
|
249 | - |
|
250 | - |
|
251 | - /** |
|
252 | - * This uses the wp "wp_get_attachment_image_src()" function to return the feature image for the current class |
|
253 | - * using the given size params. |
|
254 | - * |
|
255 | - * @param string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array |
|
256 | - * representing width and height in pixels eg. array(32,32). |
|
257 | - * @return string|boolean the url of the image or false if not found |
|
258 | - */ |
|
259 | - public function feature_image_url($size = 'thumbnail') |
|
260 | - { |
|
261 | - $attachment = wp_get_attachment_image_src(get_post_thumbnail_id($this->ID()), $size); |
|
262 | - return ! empty($attachment) ? $attachment[0] : false; |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * This is a method for restoring this_obj using details from the given $revision_id |
|
268 | - * |
|
269 | - * @param int $revision_id ID of the revision we're getting data from |
|
270 | - * @param array $related_obj_names if included this will be used to restore for related obj |
|
271 | - * if not included then we just do restore on the meta. |
|
272 | - * We will accept an array of related_obj_names for restoration here. |
|
273 | - * @param array $where_query You can optionally include an array of key=>value pairs |
|
274 | - * that allow you to further constrict the relation to being added. |
|
275 | - * However, keep in mind that the columns (keys) given |
|
276 | - * must match a column on the JOIN table and currently |
|
277 | - * only the HABTM models accept these additional conditions. |
|
278 | - * Also remember that if an exact match isn't found for these extra cols/val pairs, |
|
279 | - * then a NEW row is created in the join table. |
|
280 | - * This array is INDEXED by RELATED OBJ NAME (so it corresponds with the obj_names |
|
281 | - * sent); |
|
282 | - * @return void |
|
283 | - */ |
|
284 | - public function restore_revision($revision_id, $related_obj_names = array(), $where_query = array()) |
|
285 | - { |
|
286 | - // get revision object |
|
287 | - $revision_obj = $this->get_model()->get_one_by_ID($revision_id); |
|
288 | - if ($revision_obj instanceof EE_CPT_Base) { |
|
289 | - // no related_obj_name so we assume we're saving a revision on this object. |
|
290 | - if (empty($related_obj_names)) { |
|
291 | - $fields = $this->get_model()->get_meta_table_fields(); |
|
292 | - foreach ($fields as $field) { |
|
293 | - $this->set($field, $revision_obj->get($field)); |
|
294 | - } |
|
295 | - $this->save(); |
|
296 | - } |
|
297 | - $related_obj_names = (array) $related_obj_names; |
|
298 | - foreach ($related_obj_names as $related_name) { |
|
299 | - // related_obj_name so we're saving a revision on an object related to this object |
|
300 | - // do we have $where_query params for this related object? If we do then we include that. |
|
301 | - $cols_n_values = isset($where_query[ $related_name ]) ? $where_query[ $related_name ] : array(); |
|
302 | - $where_params = ! empty($cols_n_values) ? array($cols_n_values) : array(); |
|
303 | - $related_objs = $this->get_many_related($related_name, $where_params); |
|
304 | - $revision_related_objs = $revision_obj->get_many_related($related_name, $where_params); |
|
305 | - // load helper |
|
306 | - // remove related objs from this object that are not in revision |
|
307 | - // array_diff *should* work cause I think objects are indexed by ID? |
|
308 | - $related_to_remove = EEH_Array::object_array_diff($related_objs, $revision_related_objs); |
|
309 | - foreach ($related_to_remove as $rr) { |
|
310 | - $this->_remove_relation_to($rr, $related_name, $cols_n_values); |
|
311 | - } |
|
312 | - // add all related objs attached to revision to this object |
|
313 | - foreach ($revision_related_objs as $r_obj) { |
|
314 | - $this->_add_relation_to($r_obj, $related_name, $cols_n_values); |
|
315 | - } |
|
316 | - } |
|
317 | - } |
|
318 | - } |
|
319 | - |
|
320 | - |
|
321 | - /** |
|
322 | - * Wrapper for get_post_meta, http://codex.wordpress.org/Function_Reference/get_post_meta |
|
323 | - * |
|
324 | - * @param string $meta_key |
|
325 | - * @param boolean $single |
|
326 | - * @return mixed <ul><li>If only $id is set it will return all meta values in an associative array.</li> |
|
327 | - * <li>If $single is set to false, or left blank, the function returns an array containing all values of the |
|
328 | - * specified key.</li> |
|
329 | - * <li>If $single is set to true, the function returns the first value of the specified key (not in an |
|
330 | - * array</li></ul> |
|
331 | - */ |
|
332 | - public function get_post_meta($meta_key = null, $single = false) |
|
333 | - { |
|
334 | - return get_post_meta($this->ID(), $meta_key, $single); |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * Wrapper for update_post_meta, http://codex.wordpress.org/Function_Reference/update_post_meta |
|
340 | - * |
|
341 | - * @param string $meta_key |
|
342 | - * @param mixed $meta_value |
|
343 | - * @param mixed $prev_value |
|
344 | - * @return mixed Returns meta_id if the meta doesn't exist, otherwise returns true on success and false on failure. |
|
345 | - * NOTE: If the meta_value passed to this function is the same as the value that is already in the |
|
346 | - * database, this function returns false. |
|
347 | - */ |
|
348 | - public function update_post_meta($meta_key, $meta_value, $prev_value = null) |
|
349 | - { |
|
350 | - if (! $this->ID()) { |
|
351 | - $this->save(); |
|
352 | - } |
|
353 | - return update_post_meta($this->ID(), $meta_key, $meta_value, $prev_value); |
|
354 | - } |
|
355 | - |
|
356 | - |
|
357 | - /** |
|
358 | - * Wrapper for add_post_meta, http://codex.wordpress.org/Function_Reference/add_post_meta |
|
359 | - * |
|
360 | - * @param mixed $meta_key |
|
361 | - * @param mixed $meta_value |
|
362 | - * @param bool $unique . If postmeta for this $meta_key already exists, whether to add an additional item or not |
|
363 | - * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given |
|
364 | - * key already exists, in which case false is returned. |
|
365 | - */ |
|
366 | - public function add_post_meta($meta_key, $meta_value, $unique = false) |
|
367 | - { |
|
368 | - if ($this->ID()) { |
|
369 | - $this->save(); |
|
370 | - } |
|
371 | - return add_post_meta($this->ID(), $meta_key, $meta_value, $unique); |
|
372 | - } |
|
373 | - |
|
374 | - |
|
375 | - /** |
|
376 | - * Wrapper for delete_post_meta, http://codex.wordpress.org/Function_Reference/delete_post_meta |
|
377 | - * |
|
378 | - * @param mixed $meta_key |
|
379 | - * @param mixed $meta_value |
|
380 | - * @return boolean False for failure. True for success. |
|
381 | - */ |
|
382 | - public function delete_post_meta($meta_key, $meta_value = '') |
|
383 | - { |
|
384 | - if (! $this->ID()) { |
|
385 | - // there are obviously no postmetas for this if it's not saved |
|
386 | - // so let's just report this as a success |
|
387 | - return true; |
|
388 | - } |
|
389 | - return delete_post_meta($this->ID(), $meta_key, $meta_value); |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - * Gets the URL for viewing this event on the front-end |
|
395 | - * |
|
396 | - * @return string |
|
397 | - */ |
|
398 | - public function get_permalink() |
|
399 | - { |
|
400 | - return get_permalink($this->ID()); |
|
401 | - } |
|
402 | - |
|
403 | - |
|
404 | - /** |
|
405 | - * Gets all the term-taxonomies for this CPT |
|
406 | - * |
|
407 | - * @param array $query_params |
|
408 | - * @return EE_Term_Taxonomy |
|
409 | - */ |
|
410 | - public function term_taxonomies($query_params = array()) |
|
411 | - { |
|
412 | - return $this->get_many_related('Term_Taxonomy', $query_params); |
|
413 | - } |
|
414 | - |
|
415 | - |
|
416 | - /** |
|
417 | - * @return mixed |
|
418 | - */ |
|
419 | - public function get_custom_post_statuses() |
|
420 | - { |
|
421 | - return $this->get_model()->get_custom_post_statuses(); |
|
422 | - } |
|
423 | - |
|
424 | - |
|
425 | - /** |
|
426 | - * @return mixed |
|
427 | - */ |
|
428 | - public function get_all_post_statuses() |
|
429 | - { |
|
430 | - return $this->get_model()->get_status_array(); |
|
431 | - } |
|
432 | - |
|
433 | - |
|
434 | - /** |
|
435 | - * Don't serialize the WP Post. That's just duplicate data and we want to avoid recursion |
|
436 | - * |
|
437 | - * @return array |
|
438 | - */ |
|
439 | - public function __sleep() |
|
440 | - { |
|
441 | - $properties_to_serialize = parent::__sleep(); |
|
442 | - $properties_to_serialize = array_diff($properties_to_serialize, array('_wp_post')); |
|
443 | - return $properties_to_serialize; |
|
444 | - } |
|
17 | + /** |
|
18 | + * This is a property for holding cached feature images on CPT objects. Cache's are set on the first |
|
19 | + * "feature_image()" method call. Each key in the array corresponds to the requested size. |
|
20 | + * |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + protected $_feature_image = array(); |
|
24 | + |
|
25 | + /** |
|
26 | + * @var WP_Post the WP_Post that corresponds with this CPT model object |
|
27 | + */ |
|
28 | + protected $_wp_post; |
|
29 | + |
|
30 | + |
|
31 | + abstract public function wp_user(); |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Returns the WP post associated with this CPT model object. If this CPT is saved, fetches it |
|
36 | + * from the DB. Otherwise, create an unsaved WP_POst object. Caches the post internally. |
|
37 | + * |
|
38 | + * @return WP_Post |
|
39 | + */ |
|
40 | + public function wp_post() |
|
41 | + { |
|
42 | + global $wpdb; |
|
43 | + if (! $this->_wp_post instanceof WP_Post) { |
|
44 | + if ($this->ID()) { |
|
45 | + $this->_wp_post = get_post($this->ID()); |
|
46 | + } else { |
|
47 | + $simulated_db_result = new stdClass(); |
|
48 | + foreach ($this->get_model()->field_settings(true) as $field_name => $field_obj) { |
|
49 | + if ( |
|
50 | + $this->get_model()->get_table_obj_by_alias($field_obj->get_table_alias())->get_table_name() |
|
51 | + === $wpdb->posts |
|
52 | + ) { |
|
53 | + $column = $field_obj->get_table_column(); |
|
54 | + |
|
55 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
56 | + $value_on_model_obj = $this->get_DateTime_object($field_name); |
|
57 | + } elseif ($field_obj->is_db_only_field()) { |
|
58 | + $value_on_model_obj = $field_obj->get_default_value(); |
|
59 | + } else { |
|
60 | + $value_on_model_obj = $this->get_raw($field_name); |
|
61 | + } |
|
62 | + $simulated_db_result->{$column} = $field_obj->prepare_for_use_in_db($value_on_model_obj); |
|
63 | + } |
|
64 | + } |
|
65 | + $this->_wp_post = new WP_Post($simulated_db_result); |
|
66 | + } |
|
67 | + // and let's make retrieving the EE CPT object easy too |
|
68 | + $classname = get_class($this); |
|
69 | + if (! isset($this->_wp_post->{$classname})) { |
|
70 | + $this->_wp_post->{$classname} = $this; |
|
71 | + } |
|
72 | + } |
|
73 | + return $this->_wp_post; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * When fetching a new value for a post field that uses the global $post for rendering, |
|
78 | + * set the global $post temporarily to be this model object; and afterwards restore it |
|
79 | + * |
|
80 | + * @param string $fieldname |
|
81 | + * @param bool $pretty |
|
82 | + * @param string $extra_cache_ref |
|
83 | + * @return mixed |
|
84 | + */ |
|
85 | + protected function _get_fresh_property($fieldname, $pretty = false, $extra_cache_ref = null) |
|
86 | + { |
|
87 | + global $post; |
|
88 | + |
|
89 | + if ( |
|
90 | + $pretty |
|
91 | + && ( |
|
92 | + ! ( |
|
93 | + $post instanceof WP_Post |
|
94 | + && $post->ID |
|
95 | + ) |
|
96 | + || (int) $post->ID !== $this->ID() |
|
97 | + ) |
|
98 | + && $this->get_model()->field_settings_for($fieldname) instanceof EE_Post_Content_Field |
|
99 | + ) { |
|
100 | + $old_post = $post; |
|
101 | + $post = $this->wp_post(); |
|
102 | + $return_value = parent::_get_fresh_property($fieldname, $pretty, $extra_cache_ref); |
|
103 | + $post = $old_post; |
|
104 | + } else { |
|
105 | + $return_value = parent::_get_fresh_property($fieldname, $pretty, $extra_cache_ref); |
|
106 | + } |
|
107 | + return $return_value; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Adds to the specified event category. If it category doesn't exist, creates it. |
|
112 | + * |
|
113 | + * @param string $category_name |
|
114 | + * @param string $category_description optional |
|
115 | + * @param int $parent_term_taxonomy_id optional |
|
116 | + * @return EE_Term_Taxonomy |
|
117 | + */ |
|
118 | + public function add_event_category($category_name, $category_description = null, $parent_term_taxonomy_id = null) |
|
119 | + { |
|
120 | + return $this->get_model()->add_event_category( |
|
121 | + $this, |
|
122 | + $category_name, |
|
123 | + $category_description, |
|
124 | + $parent_term_taxonomy_id |
|
125 | + ); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * Removes the event category by specified name from being related ot this event |
|
131 | + * |
|
132 | + * @param string $category_name |
|
133 | + * @return bool |
|
134 | + */ |
|
135 | + public function remove_event_category($category_name) |
|
136 | + { |
|
137 | + return $this->get_model()->remove_event_category($this, $category_name); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * Removes the relation to the specified term taxonomy, and maintains the |
|
143 | + * data integrity of the term taxonomy provided |
|
144 | + * |
|
145 | + * @param EE_Term_Taxonomy $term_taxonomy |
|
146 | + * @return EE_Base_Class the relation was removed from |
|
147 | + */ |
|
148 | + public function remove_relation_to_term_taxonomy($term_taxonomy) |
|
149 | + { |
|
150 | + if (! $term_taxonomy) { |
|
151 | + EE_Error::add_error( |
|
152 | + sprintf( |
|
153 | + __( |
|
154 | + "No Term_Taxonomy provided which to remove from model object of type %s and id %d", |
|
155 | + "event_espresso" |
|
156 | + ), |
|
157 | + get_class($this), |
|
158 | + $this->ID() |
|
159 | + ), |
|
160 | + __FILE__, |
|
161 | + __FUNCTION__, |
|
162 | + __LINE__ |
|
163 | + ); |
|
164 | + return null; |
|
165 | + } |
|
166 | + $term_taxonomy->set_count($term_taxonomy->count() - 1); |
|
167 | + $term_taxonomy->save(); |
|
168 | + return $this->_remove_relation_to($term_taxonomy, 'Term_Taxonomy'); |
|
169 | + } |
|
170 | + |
|
171 | + |
|
172 | + /** |
|
173 | + * The main purpose of this method is to return the post type for the model object |
|
174 | + * |
|
175 | + * @access public |
|
176 | + * @return string |
|
177 | + */ |
|
178 | + public function post_type() |
|
179 | + { |
|
180 | + return $this->get_model()->post_type(); |
|
181 | + } |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * The main purpose of this method is to return the parent for the model object |
|
186 | + * |
|
187 | + * @access public |
|
188 | + * @return int |
|
189 | + */ |
|
190 | + public function parent() |
|
191 | + { |
|
192 | + return $this->get('parent'); |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + /** |
|
197 | + * return the _status property |
|
198 | + * |
|
199 | + * @return string |
|
200 | + */ |
|
201 | + public function status() |
|
202 | + { |
|
203 | + return $this->get('status'); |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * @param string $status |
|
209 | + */ |
|
210 | + public function set_status($status) |
|
211 | + { |
|
212 | + $this->set('status', $status); |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + /** |
|
217 | + * This calls the equivalent model method for retrieving the feature image which in turn is a wrapper for |
|
218 | + * WordPress' get_the_post_thumbnail() function. |
|
219 | + * |
|
220 | + * @link http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail |
|
221 | + * @access protected |
|
222 | + * @param string|array $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array |
|
223 | + * representing width and height in pixels (i.e. array(32,32) ). |
|
224 | + * @param string|array $attr Optional. Query string or array of attributes. |
|
225 | + * @return string HTML image element |
|
226 | + */ |
|
227 | + protected function _get_feature_image($size, $attr) |
|
228 | + { |
|
229 | + // first let's see if we already have the _feature_image property set AND if it has a cached element on it FOR the given size |
|
230 | + $attr_key = is_array($attr) ? implode('_', $attr) : $attr; |
|
231 | + $cache_key = is_array($size) ? implode('_', $size) . $attr_key : $size . $attr_key; |
|
232 | + $this->_feature_image[ $cache_key ] = isset($this->_feature_image[ $cache_key ]) |
|
233 | + ? $this->_feature_image[ $cache_key ] : $this->get_model()->get_feature_image($this->ID(), $size, $attr); |
|
234 | + return $this->_feature_image[ $cache_key ]; |
|
235 | + } |
|
236 | + |
|
237 | + |
|
238 | + /** |
|
239 | + * See _get_feature_image. Returns the HTML to display a featured image |
|
240 | + * |
|
241 | + * @param string $size |
|
242 | + * @param string|array $attr |
|
243 | + * @return string of html |
|
244 | + */ |
|
245 | + public function feature_image($size = 'thumbnail', $attr = '') |
|
246 | + { |
|
247 | + return $this->_get_feature_image($size, $attr); |
|
248 | + } |
|
249 | + |
|
250 | + |
|
251 | + /** |
|
252 | + * This uses the wp "wp_get_attachment_image_src()" function to return the feature image for the current class |
|
253 | + * using the given size params. |
|
254 | + * |
|
255 | + * @param string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array |
|
256 | + * representing width and height in pixels eg. array(32,32). |
|
257 | + * @return string|boolean the url of the image or false if not found |
|
258 | + */ |
|
259 | + public function feature_image_url($size = 'thumbnail') |
|
260 | + { |
|
261 | + $attachment = wp_get_attachment_image_src(get_post_thumbnail_id($this->ID()), $size); |
|
262 | + return ! empty($attachment) ? $attachment[0] : false; |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * This is a method for restoring this_obj using details from the given $revision_id |
|
268 | + * |
|
269 | + * @param int $revision_id ID of the revision we're getting data from |
|
270 | + * @param array $related_obj_names if included this will be used to restore for related obj |
|
271 | + * if not included then we just do restore on the meta. |
|
272 | + * We will accept an array of related_obj_names for restoration here. |
|
273 | + * @param array $where_query You can optionally include an array of key=>value pairs |
|
274 | + * that allow you to further constrict the relation to being added. |
|
275 | + * However, keep in mind that the columns (keys) given |
|
276 | + * must match a column on the JOIN table and currently |
|
277 | + * only the HABTM models accept these additional conditions. |
|
278 | + * Also remember that if an exact match isn't found for these extra cols/val pairs, |
|
279 | + * then a NEW row is created in the join table. |
|
280 | + * This array is INDEXED by RELATED OBJ NAME (so it corresponds with the obj_names |
|
281 | + * sent); |
|
282 | + * @return void |
|
283 | + */ |
|
284 | + public function restore_revision($revision_id, $related_obj_names = array(), $where_query = array()) |
|
285 | + { |
|
286 | + // get revision object |
|
287 | + $revision_obj = $this->get_model()->get_one_by_ID($revision_id); |
|
288 | + if ($revision_obj instanceof EE_CPT_Base) { |
|
289 | + // no related_obj_name so we assume we're saving a revision on this object. |
|
290 | + if (empty($related_obj_names)) { |
|
291 | + $fields = $this->get_model()->get_meta_table_fields(); |
|
292 | + foreach ($fields as $field) { |
|
293 | + $this->set($field, $revision_obj->get($field)); |
|
294 | + } |
|
295 | + $this->save(); |
|
296 | + } |
|
297 | + $related_obj_names = (array) $related_obj_names; |
|
298 | + foreach ($related_obj_names as $related_name) { |
|
299 | + // related_obj_name so we're saving a revision on an object related to this object |
|
300 | + // do we have $where_query params for this related object? If we do then we include that. |
|
301 | + $cols_n_values = isset($where_query[ $related_name ]) ? $where_query[ $related_name ] : array(); |
|
302 | + $where_params = ! empty($cols_n_values) ? array($cols_n_values) : array(); |
|
303 | + $related_objs = $this->get_many_related($related_name, $where_params); |
|
304 | + $revision_related_objs = $revision_obj->get_many_related($related_name, $where_params); |
|
305 | + // load helper |
|
306 | + // remove related objs from this object that are not in revision |
|
307 | + // array_diff *should* work cause I think objects are indexed by ID? |
|
308 | + $related_to_remove = EEH_Array::object_array_diff($related_objs, $revision_related_objs); |
|
309 | + foreach ($related_to_remove as $rr) { |
|
310 | + $this->_remove_relation_to($rr, $related_name, $cols_n_values); |
|
311 | + } |
|
312 | + // add all related objs attached to revision to this object |
|
313 | + foreach ($revision_related_objs as $r_obj) { |
|
314 | + $this->_add_relation_to($r_obj, $related_name, $cols_n_values); |
|
315 | + } |
|
316 | + } |
|
317 | + } |
|
318 | + } |
|
319 | + |
|
320 | + |
|
321 | + /** |
|
322 | + * Wrapper for get_post_meta, http://codex.wordpress.org/Function_Reference/get_post_meta |
|
323 | + * |
|
324 | + * @param string $meta_key |
|
325 | + * @param boolean $single |
|
326 | + * @return mixed <ul><li>If only $id is set it will return all meta values in an associative array.</li> |
|
327 | + * <li>If $single is set to false, or left blank, the function returns an array containing all values of the |
|
328 | + * specified key.</li> |
|
329 | + * <li>If $single is set to true, the function returns the first value of the specified key (not in an |
|
330 | + * array</li></ul> |
|
331 | + */ |
|
332 | + public function get_post_meta($meta_key = null, $single = false) |
|
333 | + { |
|
334 | + return get_post_meta($this->ID(), $meta_key, $single); |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * Wrapper for update_post_meta, http://codex.wordpress.org/Function_Reference/update_post_meta |
|
340 | + * |
|
341 | + * @param string $meta_key |
|
342 | + * @param mixed $meta_value |
|
343 | + * @param mixed $prev_value |
|
344 | + * @return mixed Returns meta_id if the meta doesn't exist, otherwise returns true on success and false on failure. |
|
345 | + * NOTE: If the meta_value passed to this function is the same as the value that is already in the |
|
346 | + * database, this function returns false. |
|
347 | + */ |
|
348 | + public function update_post_meta($meta_key, $meta_value, $prev_value = null) |
|
349 | + { |
|
350 | + if (! $this->ID()) { |
|
351 | + $this->save(); |
|
352 | + } |
|
353 | + return update_post_meta($this->ID(), $meta_key, $meta_value, $prev_value); |
|
354 | + } |
|
355 | + |
|
356 | + |
|
357 | + /** |
|
358 | + * Wrapper for add_post_meta, http://codex.wordpress.org/Function_Reference/add_post_meta |
|
359 | + * |
|
360 | + * @param mixed $meta_key |
|
361 | + * @param mixed $meta_value |
|
362 | + * @param bool $unique . If postmeta for this $meta_key already exists, whether to add an additional item or not |
|
363 | + * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given |
|
364 | + * key already exists, in which case false is returned. |
|
365 | + */ |
|
366 | + public function add_post_meta($meta_key, $meta_value, $unique = false) |
|
367 | + { |
|
368 | + if ($this->ID()) { |
|
369 | + $this->save(); |
|
370 | + } |
|
371 | + return add_post_meta($this->ID(), $meta_key, $meta_value, $unique); |
|
372 | + } |
|
373 | + |
|
374 | + |
|
375 | + /** |
|
376 | + * Wrapper for delete_post_meta, http://codex.wordpress.org/Function_Reference/delete_post_meta |
|
377 | + * |
|
378 | + * @param mixed $meta_key |
|
379 | + * @param mixed $meta_value |
|
380 | + * @return boolean False for failure. True for success. |
|
381 | + */ |
|
382 | + public function delete_post_meta($meta_key, $meta_value = '') |
|
383 | + { |
|
384 | + if (! $this->ID()) { |
|
385 | + // there are obviously no postmetas for this if it's not saved |
|
386 | + // so let's just report this as a success |
|
387 | + return true; |
|
388 | + } |
|
389 | + return delete_post_meta($this->ID(), $meta_key, $meta_value); |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + * Gets the URL for viewing this event on the front-end |
|
395 | + * |
|
396 | + * @return string |
|
397 | + */ |
|
398 | + public function get_permalink() |
|
399 | + { |
|
400 | + return get_permalink($this->ID()); |
|
401 | + } |
|
402 | + |
|
403 | + |
|
404 | + /** |
|
405 | + * Gets all the term-taxonomies for this CPT |
|
406 | + * |
|
407 | + * @param array $query_params |
|
408 | + * @return EE_Term_Taxonomy |
|
409 | + */ |
|
410 | + public function term_taxonomies($query_params = array()) |
|
411 | + { |
|
412 | + return $this->get_many_related('Term_Taxonomy', $query_params); |
|
413 | + } |
|
414 | + |
|
415 | + |
|
416 | + /** |
|
417 | + * @return mixed |
|
418 | + */ |
|
419 | + public function get_custom_post_statuses() |
|
420 | + { |
|
421 | + return $this->get_model()->get_custom_post_statuses(); |
|
422 | + } |
|
423 | + |
|
424 | + |
|
425 | + /** |
|
426 | + * @return mixed |
|
427 | + */ |
|
428 | + public function get_all_post_statuses() |
|
429 | + { |
|
430 | + return $this->get_model()->get_status_array(); |
|
431 | + } |
|
432 | + |
|
433 | + |
|
434 | + /** |
|
435 | + * Don't serialize the WP Post. That's just duplicate data and we want to avoid recursion |
|
436 | + * |
|
437 | + * @return array |
|
438 | + */ |
|
439 | + public function __sleep() |
|
440 | + { |
|
441 | + $properties_to_serialize = parent::__sleep(); |
|
442 | + $properties_to_serialize = array_diff($properties_to_serialize, array('_wp_post')); |
|
443 | + return $properties_to_serialize; |
|
444 | + } |
|
445 | 445 | } |
@@ -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 | } |