@@ -15,96 +15,96 @@ |
||
15 | 15 | class Pricing_Add_New_Default_Price_Help_Tour extends EE_Help_Tour |
16 | 16 | { |
17 | 17 | |
18 | - protected function _set_tour_properties() |
|
19 | - { |
|
20 | - $this->_label = __('Add New Default Price Tour', 'event_espresso'); |
|
21 | - $this->_slug = 'add-new-default-price-joyride'; |
|
22 | - } |
|
18 | + protected function _set_tour_properties() |
|
19 | + { |
|
20 | + $this->_label = __('Add New Default Price Tour', 'event_espresso'); |
|
21 | + $this->_slug = 'add-new-default-price-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' => 'PRT_ID', |
|
33 | - 'content' => $this->_price_type_stop(), |
|
34 | - 'options' => array( |
|
35 | - 'tipLocation' => 'top', |
|
36 | - 'tipAdjustmentY' => -50, |
|
37 | - 'tipAdjustmentX' => -15, |
|
38 | - ), |
|
39 | - ), |
|
40 | - 30 => array( |
|
41 | - 'id' => 'PRC_name', |
|
42 | - 'content' => $this->_price_name_stop(), |
|
43 | - 'options' => array( |
|
44 | - 'tipLocation' => 'top', |
|
45 | - 'tipAdjustmentY' => -40, |
|
46 | - ), |
|
47 | - ), |
|
48 | - 40 => array( |
|
49 | - 'id' => 'PRC_desc', |
|
50 | - 'content' => $this->_price_description_stop(), |
|
51 | - 'options' => array( |
|
52 | - 'tipLocation' => 'top', |
|
53 | - 'tipAdjustmentY' => -40, |
|
54 | - ), |
|
55 | - ), |
|
56 | - 50 => array( |
|
57 | - 'id' => 'PRC_amount', |
|
58 | - 'content' => $this->_price_amount_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' => 'PRT_ID', |
|
33 | + 'content' => $this->_price_type_stop(), |
|
34 | + 'options' => array( |
|
35 | + 'tipLocation' => 'top', |
|
36 | + 'tipAdjustmentY' => -50, |
|
37 | + 'tipAdjustmentX' => -15, |
|
38 | + ), |
|
39 | + ), |
|
40 | + 30 => array( |
|
41 | + 'id' => 'PRC_name', |
|
42 | + 'content' => $this->_price_name_stop(), |
|
43 | + 'options' => array( |
|
44 | + 'tipLocation' => 'top', |
|
45 | + 'tipAdjustmentY' => -40, |
|
46 | + ), |
|
47 | + ), |
|
48 | + 40 => array( |
|
49 | + 'id' => 'PRC_desc', |
|
50 | + 'content' => $this->_price_description_stop(), |
|
51 | + 'options' => array( |
|
52 | + 'tipLocation' => 'top', |
|
53 | + 'tipAdjustmentY' => -40, |
|
54 | + ), |
|
55 | + ), |
|
56 | + 50 => array( |
|
57 | + 'id' => 'PRC_amount', |
|
58 | + 'content' => $this->_price_amount_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>' . __('Add New Default Price', 'event_espresso') . '</h3>'; |
|
71 | - $content .= '<p>' |
|
72 | - . __( |
|
73 | - 'This tour of the add new default price 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>' . __('Add New Default Price', 'event_espresso') . '</h3>'; |
|
71 | + $content .= '<p>' |
|
72 | + . __( |
|
73 | + 'This tour of the add new default price 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 _price_type_stop() |
|
80 | - { |
|
81 | - return '<p>' |
|
82 | - . __( |
|
83 | - '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.', |
|
84 | - 'event_espresso' |
|
85 | - ) . '</p>'; |
|
86 | - } |
|
79 | + protected function _price_type_stop() |
|
80 | + { |
|
81 | + return '<p>' |
|
82 | + . __( |
|
83 | + '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.', |
|
84 | + 'event_espresso' |
|
85 | + ) . '</p>'; |
|
86 | + } |
|
87 | 87 | |
88 | - protected function _price_name_stop() |
|
89 | - { |
|
90 | - return '<p>' |
|
91 | - . __( |
|
92 | - 'The name of the price, discount, tax, or surcharge that will be seen by your customers.', |
|
93 | - 'event_espresso' |
|
94 | - ) . '</p>'; |
|
95 | - } |
|
88 | + protected function _price_name_stop() |
|
89 | + { |
|
90 | + return '<p>' |
|
91 | + . __( |
|
92 | + 'The name of the price, discount, tax, or surcharge that will be seen by your customers.', |
|
93 | + 'event_espresso' |
|
94 | + ) . '</p>'; |
|
95 | + } |
|
96 | 96 | |
97 | - protected function _price_description_stop() |
|
98 | - { |
|
99 | - return '<p>' |
|
100 | - . __( |
|
101 | - 'View the price type (price, discount, tax or surcharge) description.', |
|
102 | - 'event_espresso' |
|
103 | - ) . '</p>'; |
|
104 | - } |
|
97 | + protected function _price_description_stop() |
|
98 | + { |
|
99 | + return '<p>' |
|
100 | + . __( |
|
101 | + 'View the price type (price, discount, tax or surcharge) description.', |
|
102 | + 'event_espresso' |
|
103 | + ) . '</p>'; |
|
104 | + } |
|
105 | 105 | |
106 | - protected function _price_amount_stop() |
|
107 | - { |
|
108 | - return '<p>' . __('The ticket amount before any deductions.', 'event_espresso') . '</p>'; |
|
109 | - } |
|
106 | + protected function _price_amount_stop() |
|
107 | + { |
|
108 | + return '<p>' . __('The ticket amount before any deductions.', 'event_espresso') . '</p>'; |
|
109 | + } |
|
110 | 110 | } |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | |
68 | 68 | protected function _start() |
69 | 69 | { |
70 | - $content = '<h3>' . __('Add New Default Price', 'event_espresso') . '</h3>'; |
|
70 | + $content = '<h3>'.__('Add New Default Price', 'event_espresso').'</h3>'; |
|
71 | 71 | $content .= '<p>' |
72 | 72 | . __( |
73 | 73 | 'This tour of the add new default price 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 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | . __( |
83 | 83 | '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.', |
84 | 84 | 'event_espresso' |
85 | - ) . '</p>'; |
|
85 | + ).'</p>'; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | protected function _price_name_stop() |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | . __( |
92 | 92 | 'The name of the price, discount, tax, or surcharge that will be seen by your customers.', |
93 | 93 | 'event_espresso' |
94 | - ) . '</p>'; |
|
94 | + ).'</p>'; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | protected function _price_description_stop() |
@@ -100,11 +100,11 @@ discard block |
||
100 | 100 | . __( |
101 | 101 | 'View the price type (price, discount, tax or surcharge) description.', |
102 | 102 | 'event_espresso' |
103 | - ) . '</p>'; |
|
103 | + ).'</p>'; |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | protected function _price_amount_stop() |
107 | 107 | { |
108 | - return '<p>' . __('The ticket amount before any deductions.', 'event_espresso') . '</p>'; |
|
108 | + return '<p>'.__('The ticket amount before any deductions.', 'event_espresso').'</p>'; |
|
109 | 109 | } |
110 | 110 | } |
@@ -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); |
@@ -52,7 +52,7 @@ |
||
52 | 52 | /** |
53 | 53 | * Callback for FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks hook |
54 | 54 | * |
55 | - * @param $callbacks |
|
55 | + * @param callable[] $callbacks |
|
56 | 56 | * @return array |
57 | 57 | */ |
58 | 58 | public function modify_callbacks($callbacks) |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | : array(); |
136 | 136 | $EQGids = array_keys($EQGs); |
137 | 137 | |
138 | - if (! empty($QSGs)) { |
|
138 | + if ( ! empty($QSGs)) { |
|
139 | 139 | $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
140 | 140 | foreach ($QSGs as $QSG) { |
141 | 141 | $checked = in_array($QSG->ID(), $EQGids, true) |
@@ -155,16 +155,16 @@ discard block |
||
155 | 155 | ); |
156 | 156 | |
157 | 157 | $html .= ' |
158 | - <p id="event-question-group-' . $QSG->ID() . '"> |
|
159 | - <input value="' . $QSG->ID() . '" type="checkbox"' |
|
158 | + <p id="event-question-group-' . $QSG->ID().'"> |
|
159 | + <input value="' . $QSG->ID().'" type="checkbox"' |
|
160 | 160 | . $visibility |
161 | - . ' name="question_groups[' . $QSG->ID() . ']"' . $checked . ' /> |
|
162 | - <a href="' . $edit_link . '" title="' |
|
161 | + . ' name="question_groups['.$QSG->ID().']"'.$checked.' /> |
|
162 | + <a href="' . $edit_link.'" title="' |
|
163 | 163 | . sprintf( |
164 | 164 | esc_attr__('Edit %s Group', 'event_espresso'), |
165 | 165 | $QSG->get('QSG_name') |
166 | 166 | ) |
167 | - . '" target="_blank">' . $QSG->get('QSG_name') . '</a> |
|
167 | + . '" target="_blank">'.$QSG->get('QSG_name').'</a> |
|
168 | 168 | </p>'; |
169 | 169 | } |
170 | 170 | $html .= count($QSGs) > 10 ? '</div>' : ''; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $current_qgs = array_keys($current_qgs); // we just want the ids |
204 | 204 | |
205 | 205 | // now let's get the groups selected in the editor and update (IF we have data) |
206 | - if (! empty($question_groups)) { |
|
206 | + if ( ! empty($question_groups)) { |
|
207 | 207 | foreach ($question_groups as $id => $val) { |
208 | 208 | // add to event |
209 | 209 | if ($val) { |
@@ -16,210 +16,210 @@ |
||
16 | 16 | class espresso_events_Registration_Form_Hooks extends EE_Admin_Hooks |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var EE_Event|null |
|
21 | - */ |
|
22 | - protected $_event; |
|
23 | - |
|
24 | - |
|
25 | - protected function _set_hooks_properties() |
|
26 | - { |
|
27 | - |
|
28 | - $this->_name = 'registration_form'; |
|
29 | - $this->_metaboxes = array( |
|
30 | - 0 => array( |
|
31 | - 'page_route' => array('edit', 'create_new'), |
|
32 | - 'func' => 'primary_questions', |
|
33 | - 'label' => esc_html__('Questions for Primary Registrant', 'event_espresso'), |
|
34 | - 'priority' => 'default', |
|
35 | - 'context' => 'side', |
|
36 | - ), |
|
37 | - ); |
|
38 | - |
|
39 | - // hook into the handler for saving question groups |
|
40 | - add_filter( |
|
41 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
42 | - array($this, 'modify_callbacks'), |
|
43 | - 10 |
|
44 | - ); |
|
45 | - |
|
46 | - // hook into revision restores (we're hooking into the global action because EE_Admin_Hooks classes are already |
|
47 | - // restricted by page) |
|
48 | - add_action('AHEE_EE_Admin_Page_CPT__restore_revision', array($this, 'restore_revision'), 10, 2); |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * Callback for FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks hook |
|
54 | - * |
|
55 | - * @param $callbacks |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public function modify_callbacks($callbacks) |
|
59 | - { |
|
60 | - // now let's add the question group callback |
|
61 | - $callbacks[] = array($this, 'primary_question_group_update'); |
|
62 | - return $callbacks; |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * Hooked into revision restores. |
|
68 | - * |
|
69 | - * @param $post_id |
|
70 | - * @param $revision_id |
|
71 | - * @return EE_Base_Class |
|
72 | - * @throws EE_Error |
|
73 | - * @throws InvalidArgumentException |
|
74 | - * @throws ReflectionException |
|
75 | - * @throws InvalidDataTypeException |
|
76 | - * @throws InvalidInterfaceException |
|
77 | - */ |
|
78 | - public function restore_revision($post_id, $revision_id) |
|
79 | - { |
|
80 | - $EVT_MDL = EE_Registry::instance()->load_model('Event'); |
|
81 | - $post_evt = $EVT_MDL->get_one_by_ID($post_id); |
|
82 | - // restore revision for primary questions |
|
83 | - $post_evt->restore_revision( |
|
84 | - $revision_id, |
|
85 | - ['Question_Group'], |
|
86 | - ['Question_Group' => ['Event_Question_Group.EQG_primary' => true]] |
|
87 | - ); |
|
88 | - return $post_evt; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * Content of metabox. |
|
94 | - * |
|
95 | - * @param $post_id |
|
96 | - * @param $post |
|
97 | - * @throws EE_Error |
|
98 | - * @throws InvalidArgumentException |
|
99 | - * @throws InvalidDataTypeException |
|
100 | - * @throws InvalidInterfaceException |
|
101 | - */ |
|
102 | - public function primary_questions($post_id, $post) |
|
103 | - { |
|
104 | - $this->_event = $this->_adminpage_obj->get_event_object(); |
|
105 | - $event_id = $this->_event->ID(); |
|
106 | - ?> |
|
19 | + /** |
|
20 | + * @var EE_Event|null |
|
21 | + */ |
|
22 | + protected $_event; |
|
23 | + |
|
24 | + |
|
25 | + protected function _set_hooks_properties() |
|
26 | + { |
|
27 | + |
|
28 | + $this->_name = 'registration_form'; |
|
29 | + $this->_metaboxes = array( |
|
30 | + 0 => array( |
|
31 | + 'page_route' => array('edit', 'create_new'), |
|
32 | + 'func' => 'primary_questions', |
|
33 | + 'label' => esc_html__('Questions for Primary Registrant', 'event_espresso'), |
|
34 | + 'priority' => 'default', |
|
35 | + 'context' => 'side', |
|
36 | + ), |
|
37 | + ); |
|
38 | + |
|
39 | + // hook into the handler for saving question groups |
|
40 | + add_filter( |
|
41 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
42 | + array($this, 'modify_callbacks'), |
|
43 | + 10 |
|
44 | + ); |
|
45 | + |
|
46 | + // hook into revision restores (we're hooking into the global action because EE_Admin_Hooks classes are already |
|
47 | + // restricted by page) |
|
48 | + add_action('AHEE_EE_Admin_Page_CPT__restore_revision', array($this, 'restore_revision'), 10, 2); |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * Callback for FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks hook |
|
54 | + * |
|
55 | + * @param $callbacks |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public function modify_callbacks($callbacks) |
|
59 | + { |
|
60 | + // now let's add the question group callback |
|
61 | + $callbacks[] = array($this, 'primary_question_group_update'); |
|
62 | + return $callbacks; |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * Hooked into revision restores. |
|
68 | + * |
|
69 | + * @param $post_id |
|
70 | + * @param $revision_id |
|
71 | + * @return EE_Base_Class |
|
72 | + * @throws EE_Error |
|
73 | + * @throws InvalidArgumentException |
|
74 | + * @throws ReflectionException |
|
75 | + * @throws InvalidDataTypeException |
|
76 | + * @throws InvalidInterfaceException |
|
77 | + */ |
|
78 | + public function restore_revision($post_id, $revision_id) |
|
79 | + { |
|
80 | + $EVT_MDL = EE_Registry::instance()->load_model('Event'); |
|
81 | + $post_evt = $EVT_MDL->get_one_by_ID($post_id); |
|
82 | + // restore revision for primary questions |
|
83 | + $post_evt->restore_revision( |
|
84 | + $revision_id, |
|
85 | + ['Question_Group'], |
|
86 | + ['Question_Group' => ['Event_Question_Group.EQG_primary' => true]] |
|
87 | + ); |
|
88 | + return $post_evt; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * Content of metabox. |
|
94 | + * |
|
95 | + * @param $post_id |
|
96 | + * @param $post |
|
97 | + * @throws EE_Error |
|
98 | + * @throws InvalidArgumentException |
|
99 | + * @throws InvalidDataTypeException |
|
100 | + * @throws InvalidInterfaceException |
|
101 | + */ |
|
102 | + public function primary_questions($post_id, $post) |
|
103 | + { |
|
104 | + $this->_event = $this->_adminpage_obj->get_event_object(); |
|
105 | + $event_id = $this->_event->ID(); |
|
106 | + ?> |
|
107 | 107 | <div class="inside"> |
108 | 108 | <p><strong> |
109 | 109 | <?php _e('Question Groups', 'event_espresso'); ?> |
110 | 110 | </strong><br/> |
111 | 111 | <?php |
112 | - printf( |
|
113 | - esc_html__( |
|
114 | - 'Add a pre-populated %1$sgroup of questions%2$s to your event. The personal information group is required for all events', |
|
115 | - 'event_espresso' |
|
116 | - ), |
|
117 | - '<a href="admin.php?page=espresso_registration_form" target="_blank">', |
|
118 | - '</a>' |
|
119 | - ) |
|
120 | - ?> |
|
112 | + printf( |
|
113 | + esc_html__( |
|
114 | + 'Add a pre-populated %1$sgroup of questions%2$s to your event. The personal information group is required for all events', |
|
115 | + 'event_espresso' |
|
116 | + ), |
|
117 | + '<a href="admin.php?page=espresso_registration_form" target="_blank">', |
|
118 | + '</a>' |
|
119 | + ) |
|
120 | + ?> |
|
121 | 121 | </p> |
122 | 122 | <?php |
123 | 123 | |
124 | - $qsg_where['QSG_deleted'] = false; |
|
125 | - $query_params = apply_filters( |
|
126 | - 'FHEE__espresso_events_Registration_Form_Hooks__primary_questions__question_group_query_parameters', |
|
127 | - array($qsg_where, 'order_by' => array('QSG_order' => 'ASC')) |
|
128 | - ); |
|
129 | - $QSGs = EEM_Question_Group::instance()->get_all($query_params); |
|
130 | - $EQGs = ! empty($event_id) |
|
131 | - ? $this->_event->get_many_related( |
|
132 | - 'Question_Group', |
|
133 | - [['Event_Question_Group.EQG_primary' => true]] |
|
134 | - ) |
|
135 | - : array(); |
|
136 | - $EQGids = array_keys($EQGs); |
|
137 | - |
|
138 | - if (! empty($QSGs)) { |
|
139 | - $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
|
140 | - foreach ($QSGs as $QSG) { |
|
141 | - $checked = in_array($QSG->ID(), $EQGids, true) |
|
142 | - || $QSG->get('QSG_system') === 1 |
|
143 | - ? ' checked="checked"' |
|
144 | - : ''; |
|
145 | - $visibility = $QSG->get('QSG_system') === 1 |
|
146 | - ? ' style="visibility:hidden"' |
|
147 | - : ''; |
|
148 | - $edit_query_args = $this->_adminpage_obj->is_caf() ? array( |
|
149 | - 'action' => 'edit_question_group', |
|
150 | - 'QSG_ID' => $QSG->ID(), |
|
151 | - ) : array('action' => 'question_groups'); |
|
152 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( |
|
153 | - $edit_query_args, |
|
154 | - EE_FORMS_ADMIN_URL |
|
155 | - ); |
|
156 | - |
|
157 | - $html .= ' |
|
124 | + $qsg_where['QSG_deleted'] = false; |
|
125 | + $query_params = apply_filters( |
|
126 | + 'FHEE__espresso_events_Registration_Form_Hooks__primary_questions__question_group_query_parameters', |
|
127 | + array($qsg_where, 'order_by' => array('QSG_order' => 'ASC')) |
|
128 | + ); |
|
129 | + $QSGs = EEM_Question_Group::instance()->get_all($query_params); |
|
130 | + $EQGs = ! empty($event_id) |
|
131 | + ? $this->_event->get_many_related( |
|
132 | + 'Question_Group', |
|
133 | + [['Event_Question_Group.EQG_primary' => true]] |
|
134 | + ) |
|
135 | + : array(); |
|
136 | + $EQGids = array_keys($EQGs); |
|
137 | + |
|
138 | + if (! empty($QSGs)) { |
|
139 | + $html = count($QSGs) > 10 ? '<div style="height:250px;overflow:auto;">' : ''; |
|
140 | + foreach ($QSGs as $QSG) { |
|
141 | + $checked = in_array($QSG->ID(), $EQGids, true) |
|
142 | + || $QSG->get('QSG_system') === 1 |
|
143 | + ? ' checked="checked"' |
|
144 | + : ''; |
|
145 | + $visibility = $QSG->get('QSG_system') === 1 |
|
146 | + ? ' style="visibility:hidden"' |
|
147 | + : ''; |
|
148 | + $edit_query_args = $this->_adminpage_obj->is_caf() ? array( |
|
149 | + 'action' => 'edit_question_group', |
|
150 | + 'QSG_ID' => $QSG->ID(), |
|
151 | + ) : array('action' => 'question_groups'); |
|
152 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce( |
|
153 | + $edit_query_args, |
|
154 | + EE_FORMS_ADMIN_URL |
|
155 | + ); |
|
156 | + |
|
157 | + $html .= ' |
|
158 | 158 | <p id="event-question-group-' . $QSG->ID() . '"> |
159 | 159 | <input value="' . $QSG->ID() . '" type="checkbox"' |
160 | - . $visibility |
|
161 | - . ' name="question_groups[' . $QSG->ID() . ']"' . $checked . ' /> |
|
160 | + . $visibility |
|
161 | + . ' name="question_groups[' . $QSG->ID() . ']"' . $checked . ' /> |
|
162 | 162 | <a href="' . $edit_link . '" title="' |
163 | - . sprintf( |
|
164 | - esc_attr__('Edit %s Group', 'event_espresso'), |
|
165 | - $QSG->get('QSG_name') |
|
166 | - ) |
|
167 | - . '" target="_blank">' . $QSG->get('QSG_name') . '</a> |
|
163 | + . sprintf( |
|
164 | + esc_attr__('Edit %s Group', 'event_espresso'), |
|
165 | + $QSG->get('QSG_name') |
|
166 | + ) |
|
167 | + . '" target="_blank">' . $QSG->get('QSG_name') . '</a> |
|
168 | 168 | </p>'; |
169 | - } |
|
170 | - $html .= count($QSGs) > 10 ? '</div>' : ''; |
|
171 | - |
|
172 | - echo $html; |
|
173 | - } else { |
|
174 | - esc_html_e( |
|
175 | - 'There seems to be a problem with your questions. Please contact [email protected]', |
|
176 | - 'event_espresso' |
|
177 | - ); |
|
178 | - } |
|
179 | - do_action('AHEE_event_editor_questions_notice'); |
|
180 | - ?> |
|
169 | + } |
|
170 | + $html .= count($QSGs) > 10 ? '</div>' : ''; |
|
171 | + |
|
172 | + echo $html; |
|
173 | + } else { |
|
174 | + esc_html_e( |
|
175 | + 'There seems to be a problem with your questions. Please contact [email protected]', |
|
176 | + 'event_espresso' |
|
177 | + ); |
|
178 | + } |
|
179 | + do_action('AHEE_event_editor_questions_notice'); |
|
180 | + ?> |
|
181 | 181 | </div> |
182 | 182 | <?php |
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * @param EE_Event $evtobj |
|
188 | - * @param array $data |
|
189 | - * @return bool |
|
190 | - * @throws EE_Error |
|
191 | - */ |
|
192 | - public function primary_question_group_update($evtobj, $data) |
|
193 | - { |
|
194 | - $question_groups = ! empty($data['question_groups']) ? (array) $data['question_groups'] : array(); |
|
195 | - $added_qgs = array_keys($question_groups); |
|
196 | - $success = array(); |
|
197 | - |
|
198 | - // let's get all current question groups associated with this event. |
|
199 | - $current_qgs = $evtobj->get_many_related( |
|
200 | - 'Question_Group', |
|
201 | - [['Event_Question_Group.EQG_primary' => true]] |
|
202 | - ); |
|
203 | - $current_qgs = array_keys($current_qgs); // we just want the ids |
|
204 | - |
|
205 | - // now let's get the groups selected in the editor and update (IF we have data) |
|
206 | - if (! empty($question_groups)) { |
|
207 | - foreach ($question_groups as $id => $val) { |
|
208 | - // add to event |
|
209 | - if ($val) { |
|
210 | - $qg = $evtobj->_add_relation_to($id, 'Question_Group', ['EQG_primary' => true]); |
|
211 | - } |
|
212 | - $success[] = ! empty($qg) ? 1 : 0; |
|
213 | - } |
|
214 | - } |
|
215 | - |
|
216 | - // wait a minute... are there question groups missing in the saved groups that ARE with the current event? |
|
217 | - $removed_qgs = array_diff($current_qgs, $added_qgs); |
|
218 | - |
|
219 | - foreach ($removed_qgs as $qgid) { |
|
220 | - $qg = $evtobj->_remove_relation_to($qgid, 'Question_Group', ['EQG_primary' => true]); |
|
221 | - $success[] = ! empty($qg) ? 1 : 0; |
|
222 | - } |
|
223 | - return in_array(0, $success, true) ? false : true; |
|
224 | - } |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * @param EE_Event $evtobj |
|
188 | + * @param array $data |
|
189 | + * @return bool |
|
190 | + * @throws EE_Error |
|
191 | + */ |
|
192 | + public function primary_question_group_update($evtobj, $data) |
|
193 | + { |
|
194 | + $question_groups = ! empty($data['question_groups']) ? (array) $data['question_groups'] : array(); |
|
195 | + $added_qgs = array_keys($question_groups); |
|
196 | + $success = array(); |
|
197 | + |
|
198 | + // let's get all current question groups associated with this event. |
|
199 | + $current_qgs = $evtobj->get_many_related( |
|
200 | + 'Question_Group', |
|
201 | + [['Event_Question_Group.EQG_primary' => true]] |
|
202 | + ); |
|
203 | + $current_qgs = array_keys($current_qgs); // we just want the ids |
|
204 | + |
|
205 | + // now let's get the groups selected in the editor and update (IF we have data) |
|
206 | + if (! empty($question_groups)) { |
|
207 | + foreach ($question_groups as $id => $val) { |
|
208 | + // add to event |
|
209 | + if ($val) { |
|
210 | + $qg = $evtobj->_add_relation_to($id, 'Question_Group', ['EQG_primary' => true]); |
|
211 | + } |
|
212 | + $success[] = ! empty($qg) ? 1 : 0; |
|
213 | + } |
|
214 | + } |
|
215 | + |
|
216 | + // wait a minute... are there question groups missing in the saved groups that ARE with the current event? |
|
217 | + $removed_qgs = array_diff($current_qgs, $added_qgs); |
|
218 | + |
|
219 | + foreach ($removed_qgs as $qgid) { |
|
220 | + $qg = $evtobj->_remove_relation_to($qgid, 'Question_Group', ['EQG_primary' => true]); |
|
221 | + $success[] = ! empty($qg) ? 1 : 0; |
|
222 | + } |
|
223 | + return in_array(0, $success, true) ? false : true; |
|
224 | + } |
|
225 | 225 | } |
@@ -137,7 +137,7 @@ |
||
137 | 137 | * @param EE_Transaction $transaction |
138 | 138 | * @param string $payment_status One of EEM_Payment's statuses, like 'PAP' (Approved). |
139 | 139 | * By default, searches for approved payments |
140 | - * @return float|false float on success, false on fail |
|
140 | + * @return double float on success, false on fail |
|
141 | 141 | * @throws \EE_Error |
142 | 142 | */ |
143 | 143 | public function recalculate_total_payments_for_transaction( |
@@ -16,423 +16,423 @@ |
||
16 | 16 | class EE_Transaction_Payments |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var EE_Transaction_Payments $_instance |
|
21 | - * @access private |
|
22 | - */ |
|
23 | - private static $_instance; |
|
24 | - |
|
25 | - /** |
|
26 | - * @deprecated |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - protected $_old_txn_status; |
|
30 | - |
|
31 | - /** |
|
32 | - * @deprecated |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - protected $_new_txn_status; |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @singleton method used to instantiate class object |
|
40 | - * @access public |
|
41 | - * @return EE_Transaction_Payments instance |
|
42 | - */ |
|
43 | - public static function instance() |
|
44 | - { |
|
45 | - // check if class object is instantiated |
|
46 | - if (! self::$_instance instanceof EE_Transaction_Payments) { |
|
47 | - self::$_instance = new self(); |
|
48 | - } |
|
49 | - return self::$_instance; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * recalculate_transaction_total |
|
55 | - * |
|
56 | - * @access private |
|
57 | - * @param EE_Transaction $transaction |
|
58 | - * @param bool $update_txn |
|
59 | - * @return bool true if TXN total was updated, false if not |
|
60 | - * @throws \EE_Error |
|
61 | - */ |
|
62 | - public function recalculate_transaction_total(EE_Transaction $transaction, $update_txn = true) |
|
63 | - { |
|
64 | - $total_line_item = $transaction->total_line_item(); |
|
65 | - if (! $total_line_item instanceof EE_Line_Item) { |
|
66 | - EE_Error::add_error( |
|
67 | - sprintf( |
|
68 | - __('The Total Line Item for Transaction %1$d\'s was not found or is invalid.', 'event_espresso'), |
|
69 | - $transaction->ID() |
|
70 | - ), |
|
71 | - __FILE__, |
|
72 | - __FUNCTION__, |
|
73 | - __LINE__ |
|
74 | - ); |
|
75 | - return false; |
|
76 | - } |
|
77 | - $new_total = $total_line_item->recalculate_total_including_taxes(); |
|
78 | - $transaction->set_total($new_total); |
|
79 | - if ($update_txn) { |
|
80 | - return $transaction->save() ? true : false; |
|
81 | - } |
|
82 | - return false; |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * Updates the provided EE_Transaction with all the applicable payments |
|
88 | - * returns a boolean for whether the TXN was saved to the db |
|
89 | - * (meaning a status change occurred) |
|
90 | - * or not saved (which could **still** mean that |
|
91 | - * the TXN status changed, but just was not yet saved). |
|
92 | - * So if passing a value of false for the $update_txn param, |
|
93 | - * then client code needs to take responsibility for saving the TXN |
|
94 | - * regardless of what happens within EE_Transaction_Payments; |
|
95 | - * |
|
96 | - * @param EE_Transaction /int $transaction_obj_or_id EE_Transaction or its ID |
|
97 | - * @param boolean $update_txn whether to save the TXN |
|
98 | - * @return boolean whether the TXN was saved |
|
99 | - * @throws \EE_Error |
|
100 | - */ |
|
101 | - public function calculate_total_payments_and_update_status(EE_Transaction $transaction, $update_txn = true) |
|
102 | - { |
|
103 | - // verify transaction |
|
104 | - if (! $transaction instanceof EE_Transaction) { |
|
105 | - EE_Error::add_error( |
|
106 | - __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
|
107 | - __FILE__, |
|
108 | - __FUNCTION__, |
|
109 | - __LINE__ |
|
110 | - ); |
|
111 | - return false; |
|
112 | - } |
|
113 | - // calculate total paid |
|
114 | - $total_paid = $this->recalculate_total_payments_for_transaction($transaction); |
|
115 | - // if total paid has changed |
|
116 | - if ($total_paid !== false && (float) $total_paid !== $transaction->paid()) { |
|
117 | - $transaction->set_paid($total_paid); |
|
118 | - // maybe update status, and make sure to save transaction if not done already |
|
119 | - if (! $transaction->update_status_based_on_total_paid($update_txn)) { |
|
120 | - if ($update_txn) { |
|
121 | - return $transaction->save() ? true : false; |
|
122 | - } |
|
123 | - } else { |
|
124 | - // the status got updated and was saved by |
|
125 | - // update_transaction_status_based_on_total_paid() |
|
126 | - return true; |
|
127 | - } |
|
128 | - } |
|
129 | - return false; |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * recalculate_total_payments_for_transaction |
|
135 | - * |
|
136 | - * @access public |
|
137 | - * @param EE_Transaction $transaction |
|
138 | - * @param string $payment_status One of EEM_Payment's statuses, like 'PAP' (Approved). |
|
139 | - * By default, searches for approved payments |
|
140 | - * @return float|false float on success, false on fail |
|
141 | - * @throws \EE_Error |
|
142 | - */ |
|
143 | - public function recalculate_total_payments_for_transaction( |
|
144 | - EE_Transaction $transaction, |
|
145 | - $payment_status = EEM_Payment::status_id_approved |
|
146 | - ) { |
|
147 | - // verify transaction |
|
148 | - if (! $transaction instanceof EE_Transaction) { |
|
149 | - EE_Error::add_error( |
|
150 | - __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
|
151 | - __FILE__, |
|
152 | - __FUNCTION__, |
|
153 | - __LINE__ |
|
154 | - ); |
|
155 | - return false; |
|
156 | - } |
|
157 | - // ensure Payment model is loaded |
|
158 | - EE_Registry::instance()->load_model('Payment'); |
|
159 | - // calls EEM_Base::sum() |
|
160 | - return EEM_Payment::instance()->sum( |
|
161 | - // query params |
|
162 | - array(array('TXN_ID' => $transaction->ID(), 'STS_ID' => $payment_status)), |
|
163 | - // field to sum |
|
164 | - 'PAY_amount' |
|
165 | - ); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * delete_payment_and_update_transaction |
|
171 | - * Before deleting the selected payment, we fetch it's transaction, |
|
172 | - * then delete the payment, and update the transactions' amount paid. |
|
173 | - * |
|
174 | - * @param EE_Payment $payment |
|
175 | - * @return boolean |
|
176 | - * @throws \EE_Error |
|
177 | - */ |
|
178 | - public function delete_payment_and_update_transaction(EE_Payment $payment) |
|
179 | - { |
|
180 | - // verify payment |
|
181 | - if (! $payment instanceof EE_Payment) { |
|
182 | - EE_Error::add_error( |
|
183 | - __('A valid Payment object was not received.', 'event_espresso'), |
|
184 | - __FILE__, |
|
185 | - __FUNCTION__, |
|
186 | - __LINE__ |
|
187 | - ); |
|
188 | - return false; |
|
189 | - } |
|
190 | - if (! $this->delete_registration_payments_and_update_registrations($payment)) { |
|
191 | - return false; |
|
192 | - } |
|
193 | - if (! $payment->delete()) { |
|
194 | - EE_Error::add_error( |
|
195 | - __('The payment could not be deleted.', 'event_espresso'), |
|
196 | - __FILE__, |
|
197 | - __FUNCTION__, |
|
198 | - __LINE__ |
|
199 | - ); |
|
200 | - return false; |
|
201 | - } |
|
202 | - |
|
203 | - $transaction = $payment->transaction(); |
|
204 | - $TXN_status = $transaction->status_ID(); |
|
205 | - if ($TXN_status === EEM_Transaction::abandoned_status_code |
|
206 | - || $TXN_status === EEM_Transaction::failed_status_code |
|
207 | - || $payment->amount() === 0 |
|
208 | - ) { |
|
209 | - EE_Error::add_success(__('The Payment was successfully deleted.', 'event_espresso')); |
|
210 | - return true; |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - // if this fails, that just means that the transaction didn't get its status changed and/or updated. |
|
215 | - // however the payment was still deleted. |
|
216 | - if (! $this->calculate_total_payments_and_update_status($transaction)) { |
|
217 | - EE_Error::add_attention( |
|
218 | - __( |
|
219 | - 'It appears that the Payment was deleted but no change was recorded for the Transaction for an unknown reason. Please verify that all data for this Transaction looks correct..', |
|
220 | - 'event_espresso' |
|
221 | - ), |
|
222 | - __FILE__, |
|
223 | - __FUNCTION__, |
|
224 | - __LINE__ |
|
225 | - ); |
|
226 | - return true; |
|
227 | - } |
|
228 | - |
|
229 | - EE_Error::add_success( |
|
230 | - __( |
|
231 | - 'The Payment was successfully deleted, and the Transaction has been updated accordingly.', |
|
232 | - 'event_espresso' |
|
233 | - ) |
|
234 | - ); |
|
235 | - return true; |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * delete_registration_payments_and_update_registrations |
|
241 | - * |
|
242 | - * removes all registration payment records associated with a payment |
|
243 | - * and subtracts their amounts from the corresponding registrations REG_paid field |
|
244 | - * |
|
245 | - * @param EE_Payment $payment |
|
246 | - * @param array $reg_payment_query_params |
|
247 | - * @return bool |
|
248 | - * @throws \EE_Error |
|
249 | - */ |
|
250 | - public function delete_registration_payments_and_update_registrations( |
|
251 | - EE_Payment $payment, |
|
252 | - $reg_payment_query_params = array() |
|
253 | - ) { |
|
254 | - $save_payment = false; |
|
255 | - $reg_payment_query_params = ! empty($reg_payment_query_params) ? $reg_payment_query_params |
|
256 | - : array(array('PAY_ID' => $payment->ID())); |
|
257 | - $registration_payments = EEM_Registration_Payment::instance()->get_all($reg_payment_query_params); |
|
258 | - if (! empty($registration_payments)) { |
|
259 | - foreach ($registration_payments as $registration_payment) { |
|
260 | - if ($registration_payment instanceof EE_Registration_Payment) { |
|
261 | - $amount_paid = $registration_payment->amount(); |
|
262 | - $registration = $registration_payment->registration(); |
|
263 | - if ($registration instanceof EE_Registration) { |
|
264 | - $registration->set_paid($registration->paid() - $amount_paid); |
|
265 | - if ($registration->save() !== false) { |
|
266 | - $registration_payment->delete_permanently(); |
|
267 | - $save_payment = true; |
|
268 | - } |
|
269 | - } else { |
|
270 | - EE_Error::add_error( |
|
271 | - sprintf( |
|
272 | - __( |
|
273 | - 'An invalid Registration object was associated with Registration Payment ID# %1$d.', |
|
274 | - 'event_espresso' |
|
275 | - ), |
|
276 | - $registration_payment->ID() |
|
277 | - ), |
|
278 | - __FILE__, |
|
279 | - __FUNCTION__, |
|
280 | - __LINE__ |
|
281 | - ); |
|
282 | - return false; |
|
283 | - } |
|
284 | - } else { |
|
285 | - EE_Error::add_error( |
|
286 | - sprintf( |
|
287 | - __( |
|
288 | - 'An invalid Registration Payment object was associated with payment ID# %1$d.', |
|
289 | - 'event_espresso' |
|
290 | - ), |
|
291 | - $payment->ID() |
|
292 | - ), |
|
293 | - __FILE__, |
|
294 | - __FUNCTION__, |
|
295 | - __LINE__ |
|
296 | - ); |
|
297 | - return false; |
|
298 | - } |
|
299 | - } |
|
300 | - } |
|
301 | - if ($save_payment) { |
|
302 | - $payment->save(); |
|
303 | - } |
|
304 | - return true; |
|
305 | - } |
|
306 | - |
|
307 | - |
|
308 | - |
|
309 | - /********************************** DEPRECATED METHODS **********************************/ |
|
310 | - |
|
311 | - |
|
312 | - /** |
|
313 | - * possibly toggles TXN status |
|
314 | - * |
|
315 | - * @deprecated 4.9.1 |
|
316 | - * @param EE_Transaction $transaction |
|
317 | - * @param boolean $update_txn whether to save the TXN |
|
318 | - * @return boolean whether the TXN was saved |
|
319 | - * @throws \EE_Error |
|
320 | - */ |
|
321 | - public function update_transaction_status_based_on_total_paid(EE_Transaction $transaction, $update_txn = true) |
|
322 | - { |
|
323 | - EE_Error::doing_it_wrong( |
|
324 | - __CLASS__ . '::' . __FUNCTION__, |
|
325 | - sprintf( |
|
326 | - __('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
327 | - 'EE_Transaction::update_status_based_on_total_paid()' |
|
328 | - ), |
|
329 | - '4.9.1', |
|
330 | - '5.0.0' |
|
331 | - ); |
|
332 | - // verify transaction |
|
333 | - if (! $transaction instanceof EE_Transaction) { |
|
334 | - EE_Error::add_error( |
|
335 | - __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
|
336 | - __FILE__, |
|
337 | - __FUNCTION__, |
|
338 | - __LINE__ |
|
339 | - ); |
|
340 | - return false; |
|
341 | - } |
|
342 | - // set transaction status based on comparison of TXN_paid vs TXN_total |
|
343 | - return $transaction->update_status_based_on_total_paid($update_txn); |
|
344 | - } |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * @deprecated 4.9.12 |
|
349 | - * @return string |
|
350 | - */ |
|
351 | - public function old_txn_status() |
|
352 | - { |
|
353 | - EE_Error::doing_it_wrong( |
|
354 | - __METHOD__, |
|
355 | - esc_html__( |
|
356 | - 'This logic has been moved into \EE_Transaction::old_txn_status(), please use that method instead.', |
|
357 | - 'event_espresso' |
|
358 | - ), |
|
359 | - '4.9.12' |
|
360 | - ); |
|
361 | - return $this->_old_txn_status; |
|
362 | - } |
|
363 | - |
|
364 | - |
|
365 | - /** |
|
366 | - * @deprecated 4.9.12 |
|
367 | - * @param string $old_txn_status |
|
368 | - */ |
|
369 | - public function set_old_txn_status($old_txn_status) |
|
370 | - { |
|
371 | - EE_Error::doing_it_wrong( |
|
372 | - __METHOD__, |
|
373 | - esc_html__( |
|
374 | - 'This logic has been moved into \EE_Transaction::set_old_txn_status(), please use that method instead.', |
|
375 | - 'event_espresso' |
|
376 | - ), |
|
377 | - '4.9.12' |
|
378 | - ); |
|
379 | - // only set the first time |
|
380 | - if ($this->_old_txn_status === null) { |
|
381 | - $this->_old_txn_status = $old_txn_status; |
|
382 | - } |
|
383 | - } |
|
384 | - |
|
385 | - |
|
386 | - /** |
|
387 | - * @deprecated 4.9.12 |
|
388 | - * @return string |
|
389 | - */ |
|
390 | - public function new_txn_status() |
|
391 | - { |
|
392 | - EE_Error::doing_it_wrong( |
|
393 | - __METHOD__, |
|
394 | - esc_html__( |
|
395 | - 'This logic has been removed. Please just use \EE_Transaction::status_ID() instead.', |
|
396 | - 'event_espresso' |
|
397 | - ), |
|
398 | - '4.9.12' |
|
399 | - ); |
|
400 | - return $this->_new_txn_status; |
|
401 | - } |
|
402 | - |
|
403 | - |
|
404 | - /** |
|
405 | - * @deprecated 4.9.12 |
|
406 | - * @param string $new_txn_status |
|
407 | - */ |
|
408 | - public function set_new_txn_status($new_txn_status) |
|
409 | - { |
|
410 | - EE_Error::doing_it_wrong( |
|
411 | - __METHOD__, |
|
412 | - esc_html__( |
|
413 | - 'This logic has been removed. Please just use \EE_Transaction::set_status() instead.', |
|
414 | - 'event_espresso' |
|
415 | - ), |
|
416 | - '4.9.12' |
|
417 | - ); |
|
418 | - $this->_new_txn_status = $new_txn_status; |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - /** |
|
423 | - * @deprecated 4.9.12 |
|
424 | - * @return bool |
|
425 | - */ |
|
426 | - public function txn_status_updated() |
|
427 | - { |
|
428 | - EE_Error::doing_it_wrong( |
|
429 | - __METHOD__, |
|
430 | - esc_html__( |
|
431 | - 'This logic has been moved into \EE_Transaction::txn_status_updated(), please use that method instead.', |
|
432 | - 'event_espresso' |
|
433 | - ), |
|
434 | - '4.9.12' |
|
435 | - ); |
|
436 | - return $this->_new_txn_status !== $this->_old_txn_status && $this->_old_txn_status !== null ? true : false; |
|
437 | - } |
|
19 | + /** |
|
20 | + * @var EE_Transaction_Payments $_instance |
|
21 | + * @access private |
|
22 | + */ |
|
23 | + private static $_instance; |
|
24 | + |
|
25 | + /** |
|
26 | + * @deprecated |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + protected $_old_txn_status; |
|
30 | + |
|
31 | + /** |
|
32 | + * @deprecated |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + protected $_new_txn_status; |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @singleton method used to instantiate class object |
|
40 | + * @access public |
|
41 | + * @return EE_Transaction_Payments instance |
|
42 | + */ |
|
43 | + public static function instance() |
|
44 | + { |
|
45 | + // check if class object is instantiated |
|
46 | + if (! self::$_instance instanceof EE_Transaction_Payments) { |
|
47 | + self::$_instance = new self(); |
|
48 | + } |
|
49 | + return self::$_instance; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * recalculate_transaction_total |
|
55 | + * |
|
56 | + * @access private |
|
57 | + * @param EE_Transaction $transaction |
|
58 | + * @param bool $update_txn |
|
59 | + * @return bool true if TXN total was updated, false if not |
|
60 | + * @throws \EE_Error |
|
61 | + */ |
|
62 | + public function recalculate_transaction_total(EE_Transaction $transaction, $update_txn = true) |
|
63 | + { |
|
64 | + $total_line_item = $transaction->total_line_item(); |
|
65 | + if (! $total_line_item instanceof EE_Line_Item) { |
|
66 | + EE_Error::add_error( |
|
67 | + sprintf( |
|
68 | + __('The Total Line Item for Transaction %1$d\'s was not found or is invalid.', 'event_espresso'), |
|
69 | + $transaction->ID() |
|
70 | + ), |
|
71 | + __FILE__, |
|
72 | + __FUNCTION__, |
|
73 | + __LINE__ |
|
74 | + ); |
|
75 | + return false; |
|
76 | + } |
|
77 | + $new_total = $total_line_item->recalculate_total_including_taxes(); |
|
78 | + $transaction->set_total($new_total); |
|
79 | + if ($update_txn) { |
|
80 | + return $transaction->save() ? true : false; |
|
81 | + } |
|
82 | + return false; |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * Updates the provided EE_Transaction with all the applicable payments |
|
88 | + * returns a boolean for whether the TXN was saved to the db |
|
89 | + * (meaning a status change occurred) |
|
90 | + * or not saved (which could **still** mean that |
|
91 | + * the TXN status changed, but just was not yet saved). |
|
92 | + * So if passing a value of false for the $update_txn param, |
|
93 | + * then client code needs to take responsibility for saving the TXN |
|
94 | + * regardless of what happens within EE_Transaction_Payments; |
|
95 | + * |
|
96 | + * @param EE_Transaction /int $transaction_obj_or_id EE_Transaction or its ID |
|
97 | + * @param boolean $update_txn whether to save the TXN |
|
98 | + * @return boolean whether the TXN was saved |
|
99 | + * @throws \EE_Error |
|
100 | + */ |
|
101 | + public function calculate_total_payments_and_update_status(EE_Transaction $transaction, $update_txn = true) |
|
102 | + { |
|
103 | + // verify transaction |
|
104 | + if (! $transaction instanceof EE_Transaction) { |
|
105 | + EE_Error::add_error( |
|
106 | + __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
|
107 | + __FILE__, |
|
108 | + __FUNCTION__, |
|
109 | + __LINE__ |
|
110 | + ); |
|
111 | + return false; |
|
112 | + } |
|
113 | + // calculate total paid |
|
114 | + $total_paid = $this->recalculate_total_payments_for_transaction($transaction); |
|
115 | + // if total paid has changed |
|
116 | + if ($total_paid !== false && (float) $total_paid !== $transaction->paid()) { |
|
117 | + $transaction->set_paid($total_paid); |
|
118 | + // maybe update status, and make sure to save transaction if not done already |
|
119 | + if (! $transaction->update_status_based_on_total_paid($update_txn)) { |
|
120 | + if ($update_txn) { |
|
121 | + return $transaction->save() ? true : false; |
|
122 | + } |
|
123 | + } else { |
|
124 | + // the status got updated and was saved by |
|
125 | + // update_transaction_status_based_on_total_paid() |
|
126 | + return true; |
|
127 | + } |
|
128 | + } |
|
129 | + return false; |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * recalculate_total_payments_for_transaction |
|
135 | + * |
|
136 | + * @access public |
|
137 | + * @param EE_Transaction $transaction |
|
138 | + * @param string $payment_status One of EEM_Payment's statuses, like 'PAP' (Approved). |
|
139 | + * By default, searches for approved payments |
|
140 | + * @return float|false float on success, false on fail |
|
141 | + * @throws \EE_Error |
|
142 | + */ |
|
143 | + public function recalculate_total_payments_for_transaction( |
|
144 | + EE_Transaction $transaction, |
|
145 | + $payment_status = EEM_Payment::status_id_approved |
|
146 | + ) { |
|
147 | + // verify transaction |
|
148 | + if (! $transaction instanceof EE_Transaction) { |
|
149 | + EE_Error::add_error( |
|
150 | + __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
|
151 | + __FILE__, |
|
152 | + __FUNCTION__, |
|
153 | + __LINE__ |
|
154 | + ); |
|
155 | + return false; |
|
156 | + } |
|
157 | + // ensure Payment model is loaded |
|
158 | + EE_Registry::instance()->load_model('Payment'); |
|
159 | + // calls EEM_Base::sum() |
|
160 | + return EEM_Payment::instance()->sum( |
|
161 | + // query params |
|
162 | + array(array('TXN_ID' => $transaction->ID(), 'STS_ID' => $payment_status)), |
|
163 | + // field to sum |
|
164 | + 'PAY_amount' |
|
165 | + ); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * delete_payment_and_update_transaction |
|
171 | + * Before deleting the selected payment, we fetch it's transaction, |
|
172 | + * then delete the payment, and update the transactions' amount paid. |
|
173 | + * |
|
174 | + * @param EE_Payment $payment |
|
175 | + * @return boolean |
|
176 | + * @throws \EE_Error |
|
177 | + */ |
|
178 | + public function delete_payment_and_update_transaction(EE_Payment $payment) |
|
179 | + { |
|
180 | + // verify payment |
|
181 | + if (! $payment instanceof EE_Payment) { |
|
182 | + EE_Error::add_error( |
|
183 | + __('A valid Payment object was not received.', 'event_espresso'), |
|
184 | + __FILE__, |
|
185 | + __FUNCTION__, |
|
186 | + __LINE__ |
|
187 | + ); |
|
188 | + return false; |
|
189 | + } |
|
190 | + if (! $this->delete_registration_payments_and_update_registrations($payment)) { |
|
191 | + return false; |
|
192 | + } |
|
193 | + if (! $payment->delete()) { |
|
194 | + EE_Error::add_error( |
|
195 | + __('The payment could not be deleted.', 'event_espresso'), |
|
196 | + __FILE__, |
|
197 | + __FUNCTION__, |
|
198 | + __LINE__ |
|
199 | + ); |
|
200 | + return false; |
|
201 | + } |
|
202 | + |
|
203 | + $transaction = $payment->transaction(); |
|
204 | + $TXN_status = $transaction->status_ID(); |
|
205 | + if ($TXN_status === EEM_Transaction::abandoned_status_code |
|
206 | + || $TXN_status === EEM_Transaction::failed_status_code |
|
207 | + || $payment->amount() === 0 |
|
208 | + ) { |
|
209 | + EE_Error::add_success(__('The Payment was successfully deleted.', 'event_espresso')); |
|
210 | + return true; |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + // if this fails, that just means that the transaction didn't get its status changed and/or updated. |
|
215 | + // however the payment was still deleted. |
|
216 | + if (! $this->calculate_total_payments_and_update_status($transaction)) { |
|
217 | + EE_Error::add_attention( |
|
218 | + __( |
|
219 | + 'It appears that the Payment was deleted but no change was recorded for the Transaction for an unknown reason. Please verify that all data for this Transaction looks correct..', |
|
220 | + 'event_espresso' |
|
221 | + ), |
|
222 | + __FILE__, |
|
223 | + __FUNCTION__, |
|
224 | + __LINE__ |
|
225 | + ); |
|
226 | + return true; |
|
227 | + } |
|
228 | + |
|
229 | + EE_Error::add_success( |
|
230 | + __( |
|
231 | + 'The Payment was successfully deleted, and the Transaction has been updated accordingly.', |
|
232 | + 'event_espresso' |
|
233 | + ) |
|
234 | + ); |
|
235 | + return true; |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * delete_registration_payments_and_update_registrations |
|
241 | + * |
|
242 | + * removes all registration payment records associated with a payment |
|
243 | + * and subtracts their amounts from the corresponding registrations REG_paid field |
|
244 | + * |
|
245 | + * @param EE_Payment $payment |
|
246 | + * @param array $reg_payment_query_params |
|
247 | + * @return bool |
|
248 | + * @throws \EE_Error |
|
249 | + */ |
|
250 | + public function delete_registration_payments_and_update_registrations( |
|
251 | + EE_Payment $payment, |
|
252 | + $reg_payment_query_params = array() |
|
253 | + ) { |
|
254 | + $save_payment = false; |
|
255 | + $reg_payment_query_params = ! empty($reg_payment_query_params) ? $reg_payment_query_params |
|
256 | + : array(array('PAY_ID' => $payment->ID())); |
|
257 | + $registration_payments = EEM_Registration_Payment::instance()->get_all($reg_payment_query_params); |
|
258 | + if (! empty($registration_payments)) { |
|
259 | + foreach ($registration_payments as $registration_payment) { |
|
260 | + if ($registration_payment instanceof EE_Registration_Payment) { |
|
261 | + $amount_paid = $registration_payment->amount(); |
|
262 | + $registration = $registration_payment->registration(); |
|
263 | + if ($registration instanceof EE_Registration) { |
|
264 | + $registration->set_paid($registration->paid() - $amount_paid); |
|
265 | + if ($registration->save() !== false) { |
|
266 | + $registration_payment->delete_permanently(); |
|
267 | + $save_payment = true; |
|
268 | + } |
|
269 | + } else { |
|
270 | + EE_Error::add_error( |
|
271 | + sprintf( |
|
272 | + __( |
|
273 | + 'An invalid Registration object was associated with Registration Payment ID# %1$d.', |
|
274 | + 'event_espresso' |
|
275 | + ), |
|
276 | + $registration_payment->ID() |
|
277 | + ), |
|
278 | + __FILE__, |
|
279 | + __FUNCTION__, |
|
280 | + __LINE__ |
|
281 | + ); |
|
282 | + return false; |
|
283 | + } |
|
284 | + } else { |
|
285 | + EE_Error::add_error( |
|
286 | + sprintf( |
|
287 | + __( |
|
288 | + 'An invalid Registration Payment object was associated with payment ID# %1$d.', |
|
289 | + 'event_espresso' |
|
290 | + ), |
|
291 | + $payment->ID() |
|
292 | + ), |
|
293 | + __FILE__, |
|
294 | + __FUNCTION__, |
|
295 | + __LINE__ |
|
296 | + ); |
|
297 | + return false; |
|
298 | + } |
|
299 | + } |
|
300 | + } |
|
301 | + if ($save_payment) { |
|
302 | + $payment->save(); |
|
303 | + } |
|
304 | + return true; |
|
305 | + } |
|
306 | + |
|
307 | + |
|
308 | + |
|
309 | + /********************************** DEPRECATED METHODS **********************************/ |
|
310 | + |
|
311 | + |
|
312 | + /** |
|
313 | + * possibly toggles TXN status |
|
314 | + * |
|
315 | + * @deprecated 4.9.1 |
|
316 | + * @param EE_Transaction $transaction |
|
317 | + * @param boolean $update_txn whether to save the TXN |
|
318 | + * @return boolean whether the TXN was saved |
|
319 | + * @throws \EE_Error |
|
320 | + */ |
|
321 | + public function update_transaction_status_based_on_total_paid(EE_Transaction $transaction, $update_txn = true) |
|
322 | + { |
|
323 | + EE_Error::doing_it_wrong( |
|
324 | + __CLASS__ . '::' . __FUNCTION__, |
|
325 | + sprintf( |
|
326 | + __('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
|
327 | + 'EE_Transaction::update_status_based_on_total_paid()' |
|
328 | + ), |
|
329 | + '4.9.1', |
|
330 | + '5.0.0' |
|
331 | + ); |
|
332 | + // verify transaction |
|
333 | + if (! $transaction instanceof EE_Transaction) { |
|
334 | + EE_Error::add_error( |
|
335 | + __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
|
336 | + __FILE__, |
|
337 | + __FUNCTION__, |
|
338 | + __LINE__ |
|
339 | + ); |
|
340 | + return false; |
|
341 | + } |
|
342 | + // set transaction status based on comparison of TXN_paid vs TXN_total |
|
343 | + return $transaction->update_status_based_on_total_paid($update_txn); |
|
344 | + } |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * @deprecated 4.9.12 |
|
349 | + * @return string |
|
350 | + */ |
|
351 | + public function old_txn_status() |
|
352 | + { |
|
353 | + EE_Error::doing_it_wrong( |
|
354 | + __METHOD__, |
|
355 | + esc_html__( |
|
356 | + 'This logic has been moved into \EE_Transaction::old_txn_status(), please use that method instead.', |
|
357 | + 'event_espresso' |
|
358 | + ), |
|
359 | + '4.9.12' |
|
360 | + ); |
|
361 | + return $this->_old_txn_status; |
|
362 | + } |
|
363 | + |
|
364 | + |
|
365 | + /** |
|
366 | + * @deprecated 4.9.12 |
|
367 | + * @param string $old_txn_status |
|
368 | + */ |
|
369 | + public function set_old_txn_status($old_txn_status) |
|
370 | + { |
|
371 | + EE_Error::doing_it_wrong( |
|
372 | + __METHOD__, |
|
373 | + esc_html__( |
|
374 | + 'This logic has been moved into \EE_Transaction::set_old_txn_status(), please use that method instead.', |
|
375 | + 'event_espresso' |
|
376 | + ), |
|
377 | + '4.9.12' |
|
378 | + ); |
|
379 | + // only set the first time |
|
380 | + if ($this->_old_txn_status === null) { |
|
381 | + $this->_old_txn_status = $old_txn_status; |
|
382 | + } |
|
383 | + } |
|
384 | + |
|
385 | + |
|
386 | + /** |
|
387 | + * @deprecated 4.9.12 |
|
388 | + * @return string |
|
389 | + */ |
|
390 | + public function new_txn_status() |
|
391 | + { |
|
392 | + EE_Error::doing_it_wrong( |
|
393 | + __METHOD__, |
|
394 | + esc_html__( |
|
395 | + 'This logic has been removed. Please just use \EE_Transaction::status_ID() instead.', |
|
396 | + 'event_espresso' |
|
397 | + ), |
|
398 | + '4.9.12' |
|
399 | + ); |
|
400 | + return $this->_new_txn_status; |
|
401 | + } |
|
402 | + |
|
403 | + |
|
404 | + /** |
|
405 | + * @deprecated 4.9.12 |
|
406 | + * @param string $new_txn_status |
|
407 | + */ |
|
408 | + public function set_new_txn_status($new_txn_status) |
|
409 | + { |
|
410 | + EE_Error::doing_it_wrong( |
|
411 | + __METHOD__, |
|
412 | + esc_html__( |
|
413 | + 'This logic has been removed. Please just use \EE_Transaction::set_status() instead.', |
|
414 | + 'event_espresso' |
|
415 | + ), |
|
416 | + '4.9.12' |
|
417 | + ); |
|
418 | + $this->_new_txn_status = $new_txn_status; |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + /** |
|
423 | + * @deprecated 4.9.12 |
|
424 | + * @return bool |
|
425 | + */ |
|
426 | + public function txn_status_updated() |
|
427 | + { |
|
428 | + EE_Error::doing_it_wrong( |
|
429 | + __METHOD__, |
|
430 | + esc_html__( |
|
431 | + 'This logic has been moved into \EE_Transaction::txn_status_updated(), please use that method instead.', |
|
432 | + 'event_espresso' |
|
433 | + ), |
|
434 | + '4.9.12' |
|
435 | + ); |
|
436 | + return $this->_new_txn_status !== $this->_old_txn_status && $this->_old_txn_status !== null ? true : false; |
|
437 | + } |
|
438 | 438 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | public static function instance() |
44 | 44 | { |
45 | 45 | // check if class object is instantiated |
46 | - if (! self::$_instance instanceof EE_Transaction_Payments) { |
|
46 | + if ( ! self::$_instance instanceof EE_Transaction_Payments) { |
|
47 | 47 | self::$_instance = new self(); |
48 | 48 | } |
49 | 49 | return self::$_instance; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | public function recalculate_transaction_total(EE_Transaction $transaction, $update_txn = true) |
63 | 63 | { |
64 | 64 | $total_line_item = $transaction->total_line_item(); |
65 | - if (! $total_line_item instanceof EE_Line_Item) { |
|
65 | + if ( ! $total_line_item instanceof EE_Line_Item) { |
|
66 | 66 | EE_Error::add_error( |
67 | 67 | sprintf( |
68 | 68 | __('The Total Line Item for Transaction %1$d\'s was not found or is invalid.', 'event_espresso'), |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | public function calculate_total_payments_and_update_status(EE_Transaction $transaction, $update_txn = true) |
102 | 102 | { |
103 | 103 | // verify transaction |
104 | - if (! $transaction instanceof EE_Transaction) { |
|
104 | + if ( ! $transaction instanceof EE_Transaction) { |
|
105 | 105 | EE_Error::add_error( |
106 | 106 | __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
107 | 107 | __FILE__, |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | if ($total_paid !== false && (float) $total_paid !== $transaction->paid()) { |
117 | 117 | $transaction->set_paid($total_paid); |
118 | 118 | // maybe update status, and make sure to save transaction if not done already |
119 | - if (! $transaction->update_status_based_on_total_paid($update_txn)) { |
|
119 | + if ( ! $transaction->update_status_based_on_total_paid($update_txn)) { |
|
120 | 120 | if ($update_txn) { |
121 | 121 | return $transaction->save() ? true : false; |
122 | 122 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $payment_status = EEM_Payment::status_id_approved |
146 | 146 | ) { |
147 | 147 | // verify transaction |
148 | - if (! $transaction instanceof EE_Transaction) { |
|
148 | + if ( ! $transaction instanceof EE_Transaction) { |
|
149 | 149 | EE_Error::add_error( |
150 | 150 | __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
151 | 151 | __FILE__, |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | public function delete_payment_and_update_transaction(EE_Payment $payment) |
179 | 179 | { |
180 | 180 | // verify payment |
181 | - if (! $payment instanceof EE_Payment) { |
|
181 | + if ( ! $payment instanceof EE_Payment) { |
|
182 | 182 | EE_Error::add_error( |
183 | 183 | __('A valid Payment object was not received.', 'event_espresso'), |
184 | 184 | __FILE__, |
@@ -187,10 +187,10 @@ discard block |
||
187 | 187 | ); |
188 | 188 | return false; |
189 | 189 | } |
190 | - if (! $this->delete_registration_payments_and_update_registrations($payment)) { |
|
190 | + if ( ! $this->delete_registration_payments_and_update_registrations($payment)) { |
|
191 | 191 | return false; |
192 | 192 | } |
193 | - if (! $payment->delete()) { |
|
193 | + if ( ! $payment->delete()) { |
|
194 | 194 | EE_Error::add_error( |
195 | 195 | __('The payment could not be deleted.', 'event_espresso'), |
196 | 196 | __FILE__, |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | // if this fails, that just means that the transaction didn't get its status changed and/or updated. |
215 | 215 | // however the payment was still deleted. |
216 | - if (! $this->calculate_total_payments_and_update_status($transaction)) { |
|
216 | + if ( ! $this->calculate_total_payments_and_update_status($transaction)) { |
|
217 | 217 | EE_Error::add_attention( |
218 | 218 | __( |
219 | 219 | 'It appears that the Payment was deleted but no change was recorded for the Transaction for an unknown reason. Please verify that all data for this Transaction looks correct..', |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $reg_payment_query_params = ! empty($reg_payment_query_params) ? $reg_payment_query_params |
256 | 256 | : array(array('PAY_ID' => $payment->ID())); |
257 | 257 | $registration_payments = EEM_Registration_Payment::instance()->get_all($reg_payment_query_params); |
258 | - if (! empty($registration_payments)) { |
|
258 | + if ( ! empty($registration_payments)) { |
|
259 | 259 | foreach ($registration_payments as $registration_payment) { |
260 | 260 | if ($registration_payment instanceof EE_Registration_Payment) { |
261 | 261 | $amount_paid = $registration_payment->amount(); |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | public function update_transaction_status_based_on_total_paid(EE_Transaction $transaction, $update_txn = true) |
322 | 322 | { |
323 | 323 | EE_Error::doing_it_wrong( |
324 | - __CLASS__ . '::' . __FUNCTION__, |
|
324 | + __CLASS__.'::'.__FUNCTION__, |
|
325 | 325 | sprintf( |
326 | 326 | __('This method is deprecated. Please use "%s" instead', 'event_espresso'), |
327 | 327 | 'EE_Transaction::update_status_based_on_total_paid()' |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | '5.0.0' |
331 | 331 | ); |
332 | 332 | // verify transaction |
333 | - if (! $transaction instanceof EE_Transaction) { |
|
333 | + if ( ! $transaction instanceof EE_Transaction) { |
|
334 | 334 | EE_Error::add_error( |
335 | 335 | __('Please provide a valid EE_Transaction object.', 'event_espresso'), |
336 | 336 | __FILE__, |
@@ -61,7 +61,7 @@ |
||
61 | 61 | * Set Answer value |
62 | 62 | * |
63 | 63 | * @access public |
64 | - * @param mixed $ANS_value |
|
64 | + * @param string $ANS_value |
|
65 | 65 | */ |
66 | 66 | public function set_value($ANS_value = '') |
67 | 67 | { |
@@ -10,144 +10,144 @@ |
||
10 | 10 | class EE_Answer extends EE_Base_Class |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * |
|
15 | - * @param array $props_n_values |
|
16 | - * @return EE_Answer |
|
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 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * |
|
27 | - * @param array $props_n_values |
|
28 | - * @return EE_Answer |
|
29 | - */ |
|
30 | - public static function new_instance_from_db($props_n_values = array()) |
|
31 | - { |
|
32 | - return new self($props_n_values, true); |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * Set Question ID |
|
38 | - * |
|
39 | - * @access public |
|
40 | - * @param int $QST_ID |
|
41 | - */ |
|
42 | - public function set_question($QST_ID = 0) |
|
43 | - { |
|
44 | - $this->set('QST_ID', $QST_ID); |
|
45 | - } |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * Set Registration ID |
|
50 | - * |
|
51 | - * @access public |
|
52 | - * @param int $REG_ID |
|
53 | - */ |
|
54 | - public function set_registration($REG_ID = 0) |
|
55 | - { |
|
56 | - $this->set('REG_ID', $REG_ID); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * Set Answer value |
|
62 | - * |
|
63 | - * @access public |
|
64 | - * @param mixed $ANS_value |
|
65 | - */ |
|
66 | - public function set_value($ANS_value = '') |
|
67 | - { |
|
68 | - $this->set('ANS_value', $ANS_value); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * get Attendee First Name |
|
74 | - * |
|
75 | - * @access public |
|
76 | - * @return int |
|
77 | - */ |
|
78 | - public function registration_ID() |
|
79 | - { |
|
80 | - return $this->get('REG_ID'); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * get Attendee Last Name |
|
86 | - * |
|
87 | - * @access public |
|
88 | - * @return int |
|
89 | - */ |
|
90 | - public function question_ID() |
|
91 | - { |
|
92 | - return $this->get('QST_ID'); |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * get Attendee Address |
|
98 | - * |
|
99 | - * @access public |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - public function value() |
|
103 | - { |
|
104 | - return $this->get('ANS_value'); |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * Gets a pretty form of the value (mostly applies to answers that have multiple answers) |
|
110 | - * |
|
111 | - * @param null $schema |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - public function pretty_value($schema = null) |
|
115 | - { |
|
116 | - return $this->get_pretty('ANS_value', $schema); |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - /** |
|
121 | - * Echoes out a pretty value (even for multi-choice options) |
|
122 | - * |
|
123 | - * @param string $schema |
|
124 | - */ |
|
125 | - public function e_value($schema = null) |
|
126 | - { |
|
127 | - $this->e('ANS_value', $schema); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * Gets the related EE_Question to this EE_Answer |
|
133 | - * |
|
134 | - * @return EE_Question |
|
135 | - */ |
|
136 | - public function question() |
|
137 | - { |
|
138 | - return $this->get_first_related('Question'); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * Gets the related EE_Registration to this EE_Answer |
|
144 | - * |
|
145 | - * @return EE_Registration |
|
146 | - */ |
|
147 | - public function registration() |
|
148 | - { |
|
149 | - return $this->get_first_related('Registration'); |
|
150 | - } |
|
13 | + /** |
|
14 | + * |
|
15 | + * @param array $props_n_values |
|
16 | + * @return EE_Answer |
|
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 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * |
|
27 | + * @param array $props_n_values |
|
28 | + * @return EE_Answer |
|
29 | + */ |
|
30 | + public static function new_instance_from_db($props_n_values = array()) |
|
31 | + { |
|
32 | + return new self($props_n_values, true); |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * Set Question ID |
|
38 | + * |
|
39 | + * @access public |
|
40 | + * @param int $QST_ID |
|
41 | + */ |
|
42 | + public function set_question($QST_ID = 0) |
|
43 | + { |
|
44 | + $this->set('QST_ID', $QST_ID); |
|
45 | + } |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * Set Registration ID |
|
50 | + * |
|
51 | + * @access public |
|
52 | + * @param int $REG_ID |
|
53 | + */ |
|
54 | + public function set_registration($REG_ID = 0) |
|
55 | + { |
|
56 | + $this->set('REG_ID', $REG_ID); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * Set Answer value |
|
62 | + * |
|
63 | + * @access public |
|
64 | + * @param mixed $ANS_value |
|
65 | + */ |
|
66 | + public function set_value($ANS_value = '') |
|
67 | + { |
|
68 | + $this->set('ANS_value', $ANS_value); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * get Attendee First Name |
|
74 | + * |
|
75 | + * @access public |
|
76 | + * @return int |
|
77 | + */ |
|
78 | + public function registration_ID() |
|
79 | + { |
|
80 | + return $this->get('REG_ID'); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * get Attendee Last Name |
|
86 | + * |
|
87 | + * @access public |
|
88 | + * @return int |
|
89 | + */ |
|
90 | + public function question_ID() |
|
91 | + { |
|
92 | + return $this->get('QST_ID'); |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * get Attendee Address |
|
98 | + * |
|
99 | + * @access public |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + public function value() |
|
103 | + { |
|
104 | + return $this->get('ANS_value'); |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * Gets a pretty form of the value (mostly applies to answers that have multiple answers) |
|
110 | + * |
|
111 | + * @param null $schema |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + public function pretty_value($schema = null) |
|
115 | + { |
|
116 | + return $this->get_pretty('ANS_value', $schema); |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + /** |
|
121 | + * Echoes out a pretty value (even for multi-choice options) |
|
122 | + * |
|
123 | + * @param string $schema |
|
124 | + */ |
|
125 | + public function e_value($schema = null) |
|
126 | + { |
|
127 | + $this->e('ANS_value', $schema); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * Gets the related EE_Question to this EE_Answer |
|
133 | + * |
|
134 | + * @return EE_Question |
|
135 | + */ |
|
136 | + public function question() |
|
137 | + { |
|
138 | + return $this->get_first_related('Question'); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * Gets the related EE_Registration to this EE_Answer |
|
144 | + * |
|
145 | + * @return EE_Registration |
|
146 | + */ |
|
147 | + public function registration() |
|
148 | + { |
|
149 | + return $this->get_first_related('Registration'); |
|
150 | + } |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /* End of file EE_Answer.class.php */ |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @link http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail |
218 | 218 | * @access protected |
219 | - * @param string|array $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array |
|
219 | + * @param string $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array |
|
220 | 220 | * representing width and height in pixels (i.e. array(32,32) ). |
221 | 221 | * @param string|array $attr Optional. Query string or array of attributes. |
222 | 222 | * @return string HTML image element |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * This is a method for restoring this_obj using details from the given $revision_id |
265 | 265 | * |
266 | 266 | * @param int $revision_id ID of the revision we're getting data from |
267 | - * @param array $related_obj_names if included this will be used to restore for related obj |
|
267 | + * @param string[] $related_obj_names if included this will be used to restore for related obj |
|
268 | 268 | * if not included then we just do restore on the meta. |
269 | 269 | * We will accept an array of related_obj_names for restoration here. |
270 | 270 | * @param array $where_query You can optionally include an array of key=>value pairs |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @param string $meta_key |
322 | 322 | * @param boolean $single |
323 | - * @return mixed <ul><li>If only $id is set it will return all meta values in an associative array.</li> |
|
323 | + * @return string|null <ul><li>If only $id is set it will return all meta values in an associative array.</li> |
|
324 | 324 | * <li>If $single is set to false, or left blank, the function returns an array containing all values of the |
325 | 325 | * specified key.</li> |
326 | 326 | * <li>If $single is set to true, the function returns the first value of the specified key (not in an |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | /** |
355 | 355 | * Wrapper for add_post_meta, http://codex.wordpress.org/Function_Reference/add_post_meta |
356 | 356 | * |
357 | - * @param mixed $meta_key |
|
358 | - * @param mixed $meta_value |
|
357 | + * @param string $meta_key |
|
358 | + * @param string $meta_value |
|
359 | 359 | * @param bool $unique . If postmeta for this $meta_key already exists, whether to add an additional item or not |
360 | 360 | * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given |
361 | 361 | * key already exists, in which case false is returned. |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | /** |
373 | 373 | * Wrapper for delete_post_meta, http://codex.wordpress.org/Function_Reference/delete_post_meta |
374 | 374 | * |
375 | - * @param mixed $meta_key |
|
375 | + * @param string $meta_key |
|
376 | 376 | * @param mixed $meta_value |
377 | 377 | * @return boolean False for failure. True for success. |
378 | 378 | */ |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * Gets all the term-taxonomies for this CPT |
403 | 403 | * |
404 | 404 | * @param array $query_params |
405 | - * @return EE_Term_Taxonomy |
|
405 | + * @return EE_Base_Class[] |
|
406 | 406 | */ |
407 | 407 | public function term_taxonomies($query_params = array()) |
408 | 408 | { |
@@ -14,429 +14,429 @@ |
||
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 ($this->get_model()->get_table_obj_by_alias($field_obj->get_table_alias())->get_table_name() |
|
50 | - === $wpdb->posts |
|
51 | - ) { |
|
52 | - $column = $field_obj->get_table_column(); |
|
53 | - |
|
54 | - if ($field_obj instanceof EE_Datetime_Field) { |
|
55 | - $value_on_model_obj = $this->get_DateTime_object($field_name); |
|
56 | - } elseif ($field_obj->is_db_only_field()) { |
|
57 | - $value_on_model_obj = $field_obj->get_default_value(); |
|
58 | - } else { |
|
59 | - $value_on_model_obj = $this->get_raw($field_name); |
|
60 | - } |
|
61 | - $simulated_db_result->{$column} = $field_obj->prepare_for_use_in_db($value_on_model_obj); |
|
62 | - } |
|
63 | - } |
|
64 | - $this->_wp_post = new WP_Post($simulated_db_result); |
|
65 | - } |
|
66 | - // and let's make retrieving the EE CPT object easy too |
|
67 | - $classname = get_class($this); |
|
68 | - if (! isset($this->_wp_post->{$classname})) { |
|
69 | - $this->_wp_post->{$classname} = $this; |
|
70 | - } |
|
71 | - } |
|
72 | - return $this->_wp_post; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * When fetching a new value for a post field that uses the global $post for rendering, |
|
77 | - * set the global $post temporarily to be this model object; and afterwards restore it |
|
78 | - * |
|
79 | - * @param string $fieldname |
|
80 | - * @param bool $pretty |
|
81 | - * @param string $extra_cache_ref |
|
82 | - * @return mixed |
|
83 | - */ |
|
84 | - protected function _get_fresh_property($fieldname, $pretty = false, $extra_cache_ref = null) |
|
85 | - { |
|
86 | - global $post; |
|
87 | - |
|
88 | - if ($pretty |
|
89 | - && ( |
|
90 | - ! ( |
|
91 | - $post instanceof WP_Post |
|
92 | - && $post->ID |
|
93 | - ) |
|
94 | - || (int) $post->ID !== $this->ID() |
|
95 | - ) |
|
96 | - && $this->get_model()->field_settings_for($fieldname) instanceof EE_Post_Content_Field) { |
|
97 | - $old_post = $post; |
|
98 | - $post = $this->wp_post(); |
|
99 | - $return_value = parent::_get_fresh_property($fieldname, $pretty, $extra_cache_ref); |
|
100 | - $post = $old_post; |
|
101 | - } else { |
|
102 | - $return_value = parent::_get_fresh_property($fieldname, $pretty, $extra_cache_ref); |
|
103 | - } |
|
104 | - return $return_value; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * Adds to the specified event category. If it category doesn't exist, creates it. |
|
109 | - * |
|
110 | - * @param string $category_name |
|
111 | - * @param string $category_description optional |
|
112 | - * @param int $parent_term_taxonomy_id optional |
|
113 | - * @return EE_Term_Taxonomy |
|
114 | - */ |
|
115 | - public function add_event_category($category_name, $category_description = null, $parent_term_taxonomy_id = null) |
|
116 | - { |
|
117 | - return $this->get_model()->add_event_category( |
|
118 | - $this, |
|
119 | - $category_name, |
|
120 | - $category_description, |
|
121 | - $parent_term_taxonomy_id |
|
122 | - ); |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * Removes the event category by specified name from being related ot this event |
|
128 | - * |
|
129 | - * @param string $category_name |
|
130 | - * @return bool |
|
131 | - */ |
|
132 | - public function remove_event_category($category_name) |
|
133 | - { |
|
134 | - return $this->get_model()->remove_event_category($this, $category_name); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * Removes the relation to the specified term taxonomy, and maintains the |
|
140 | - * data integrity of the term taxonomy provided |
|
141 | - * |
|
142 | - * @param EE_Term_Taxonomy $term_taxonomy |
|
143 | - * @return EE_Base_Class the relation was removed from |
|
144 | - */ |
|
145 | - public function remove_relation_to_term_taxonomy($term_taxonomy) |
|
146 | - { |
|
147 | - if (! $term_taxonomy) { |
|
148 | - EE_Error::add_error( |
|
149 | - sprintf( |
|
150 | - __( |
|
151 | - "No Term_Taxonomy provided which to remove from model object of type %s and id %d", |
|
152 | - "event_espresso" |
|
153 | - ), |
|
154 | - get_class($this), |
|
155 | - $this->ID() |
|
156 | - ), |
|
157 | - __FILE__, |
|
158 | - __FUNCTION__, |
|
159 | - __LINE__ |
|
160 | - ); |
|
161 | - return null; |
|
162 | - } |
|
163 | - $term_taxonomy->set_count($term_taxonomy->count() - 1); |
|
164 | - $term_taxonomy->save(); |
|
165 | - return $this->_remove_relation_to($term_taxonomy, 'Term_Taxonomy'); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * The main purpose of this method is to return the post type for the model object |
|
171 | - * |
|
172 | - * @access public |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - public function post_type() |
|
176 | - { |
|
177 | - return $this->get_model()->post_type(); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * The main purpose of this method is to return the parent for the model object |
|
183 | - * |
|
184 | - * @access public |
|
185 | - * @return int |
|
186 | - */ |
|
187 | - public function parent() |
|
188 | - { |
|
189 | - return $this->get('parent'); |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * return the _status property |
|
195 | - * |
|
196 | - * @return string |
|
197 | - */ |
|
198 | - public function status() |
|
199 | - { |
|
200 | - return $this->get('status'); |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * @param string $status |
|
206 | - */ |
|
207 | - public function set_status($status) |
|
208 | - { |
|
209 | - $this->set('status', $status); |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - /** |
|
214 | - * This calls the equivalent model method for retrieving the feature image which in turn is a wrapper for |
|
215 | - * WordPress' get_the_post_thumbnail() function. |
|
216 | - * |
|
217 | - * @link http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail |
|
218 | - * @access protected |
|
219 | - * @param string|array $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array |
|
220 | - * representing width and height in pixels (i.e. array(32,32) ). |
|
221 | - * @param string|array $attr Optional. Query string or array of attributes. |
|
222 | - * @return string HTML image element |
|
223 | - */ |
|
224 | - protected function _get_feature_image($size, $attr) |
|
225 | - { |
|
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 | - $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 ]; |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * See _get_feature_image. Returns the HTML to display a featured image |
|
237 | - * |
|
238 | - * @param string $size |
|
239 | - * @param string|array $attr |
|
240 | - * @return string of html |
|
241 | - */ |
|
242 | - public function feature_image($size = 'thumbnail', $attr = '') |
|
243 | - { |
|
244 | - return $this->_get_feature_image($size, $attr); |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * This uses the wp "wp_get_attachment_image_src()" function to return the feature image for the current class |
|
250 | - * using the given size params. |
|
251 | - * |
|
252 | - * @param string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array |
|
253 | - * representing width and height in pixels eg. array(32,32). |
|
254 | - * @return string|boolean the url of the image or false if not found |
|
255 | - */ |
|
256 | - public function feature_image_url($size = 'thumbnail') |
|
257 | - { |
|
258 | - $attachment = wp_get_attachment_image_src(get_post_thumbnail_id($this->ID()), $size); |
|
259 | - return ! empty($attachment) ? $attachment[0] : false; |
|
260 | - } |
|
261 | - |
|
262 | - |
|
263 | - /** |
|
264 | - * This is a method for restoring this_obj using details from the given $revision_id |
|
265 | - * |
|
266 | - * @param int $revision_id ID of the revision we're getting data from |
|
267 | - * @param array $related_obj_names if included this will be used to restore for related obj |
|
268 | - * if not included then we just do restore on the meta. |
|
269 | - * We will accept an array of related_obj_names for restoration here. |
|
270 | - * @param array $where_query You can optionally include an array of key=>value pairs |
|
271 | - * that allow you to further constrict the relation to being added. |
|
272 | - * However, keep in mind that the columns (keys) given |
|
273 | - * must match a column on the JOIN table and currently |
|
274 | - * only the HABTM models accept these additional conditions. |
|
275 | - * Also remember that if an exact match isn't found for these extra cols/val pairs, |
|
276 | - * then a NEW row is created in the join table. |
|
277 | - * This array is INDEXED by RELATED OBJ NAME (so it corresponds with the obj_names |
|
278 | - * sent); |
|
279 | - * @return void |
|
280 | - */ |
|
281 | - public function restore_revision($revision_id, $related_obj_names = array(), $where_query = array()) |
|
282 | - { |
|
283 | - // get revision object |
|
284 | - $revision_obj = $this->get_model()->get_one_by_ID($revision_id); |
|
285 | - if ($revision_obj instanceof EE_CPT_Base) { |
|
286 | - // no related_obj_name so we assume we're saving a revision on this object. |
|
287 | - if (empty($related_obj_names)) { |
|
288 | - $fields = $this->get_model()->get_meta_table_fields(); |
|
289 | - foreach ($fields as $field) { |
|
290 | - $this->set($field, $revision_obj->get($field)); |
|
291 | - } |
|
292 | - $this->save(); |
|
293 | - } |
|
294 | - $related_obj_names = (array) $related_obj_names; |
|
295 | - foreach ($related_obj_names as $related_name) { |
|
296 | - // related_obj_name so we're saving a revision on an object related to this object |
|
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(); |
|
299 | - $where_params = ! empty($cols_n_values) ? array($cols_n_values) : array(); |
|
300 | - $related_objs = $this->get_many_related($related_name, $where_params); |
|
301 | - $revision_related_objs = $revision_obj->get_many_related($related_name, $where_params); |
|
302 | - // load helper |
|
303 | - // remove related objs from this object that are not in revision |
|
304 | - // array_diff *should* work cause I think objects are indexed by ID? |
|
305 | - $related_to_remove = EEH_Array::object_array_diff($related_objs, $revision_related_objs); |
|
306 | - foreach ($related_to_remove as $rr) { |
|
307 | - $this->_remove_relation_to($rr, $related_name, $cols_n_values); |
|
308 | - } |
|
309 | - // add all related objs attached to revision to this object |
|
310 | - foreach ($revision_related_objs as $r_obj) { |
|
311 | - $this->_add_relation_to($r_obj, $related_name, $cols_n_values); |
|
312 | - } |
|
313 | - } |
|
314 | - } |
|
315 | - } |
|
316 | - |
|
317 | - |
|
318 | - /** |
|
319 | - * Wrapper for get_post_meta, http://codex.wordpress.org/Function_Reference/get_post_meta |
|
320 | - * |
|
321 | - * @param string $meta_key |
|
322 | - * @param boolean $single |
|
323 | - * @return mixed <ul><li>If only $id is set it will return all meta values in an associative array.</li> |
|
324 | - * <li>If $single is set to false, or left blank, the function returns an array containing all values of the |
|
325 | - * specified key.</li> |
|
326 | - * <li>If $single is set to true, the function returns the first value of the specified key (not in an |
|
327 | - * array</li></ul> |
|
328 | - */ |
|
329 | - public function get_post_meta($meta_key = null, $single = false) |
|
330 | - { |
|
331 | - return get_post_meta($this->ID(), $meta_key, $single); |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * Wrapper for update_post_meta, http://codex.wordpress.org/Function_Reference/update_post_meta |
|
337 | - * |
|
338 | - * @param string $meta_key |
|
339 | - * @param mixed $meta_value |
|
340 | - * @param mixed $prev_value |
|
341 | - * @return mixed Returns meta_id if the meta doesn't exist, otherwise returns true on success and false on failure. |
|
342 | - * NOTE: If the meta_value passed to this function is the same as the value that is already in the |
|
343 | - * database, this function returns false. |
|
344 | - */ |
|
345 | - public function update_post_meta($meta_key, $meta_value, $prev_value = null) |
|
346 | - { |
|
347 | - if (! $this->ID()) { |
|
348 | - $this->save(); |
|
349 | - } |
|
350 | - return update_post_meta($this->ID(), $meta_key, $meta_value, $prev_value); |
|
351 | - } |
|
352 | - |
|
353 | - |
|
354 | - /** |
|
355 | - * Wrapper for add_post_meta, http://codex.wordpress.org/Function_Reference/add_post_meta |
|
356 | - * |
|
357 | - * @param mixed $meta_key |
|
358 | - * @param mixed $meta_value |
|
359 | - * @param bool $unique . If postmeta for this $meta_key already exists, whether to add an additional item or not |
|
360 | - * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given |
|
361 | - * key already exists, in which case false is returned. |
|
362 | - */ |
|
363 | - public function add_post_meta($meta_key, $meta_value, $unique = false) |
|
364 | - { |
|
365 | - if ($this->ID()) { |
|
366 | - $this->save(); |
|
367 | - } |
|
368 | - return add_post_meta($this->ID(), $meta_key, $meta_value, $unique); |
|
369 | - } |
|
370 | - |
|
371 | - |
|
372 | - /** |
|
373 | - * Wrapper for delete_post_meta, http://codex.wordpress.org/Function_Reference/delete_post_meta |
|
374 | - * |
|
375 | - * @param mixed $meta_key |
|
376 | - * @param mixed $meta_value |
|
377 | - * @return boolean False for failure. True for success. |
|
378 | - */ |
|
379 | - public function delete_post_meta($meta_key, $meta_value = '') |
|
380 | - { |
|
381 | - if (! $this->ID()) { |
|
382 | - // there are obviously no postmetas for this if it's not saved |
|
383 | - // so let's just report this as a success |
|
384 | - return true; |
|
385 | - } |
|
386 | - return delete_post_meta($this->ID(), $meta_key, $meta_value); |
|
387 | - } |
|
388 | - |
|
389 | - |
|
390 | - /** |
|
391 | - * Gets the URL for viewing this event on the front-end |
|
392 | - * |
|
393 | - * @return string |
|
394 | - */ |
|
395 | - public function get_permalink() |
|
396 | - { |
|
397 | - return get_permalink($this->ID()); |
|
398 | - } |
|
399 | - |
|
400 | - |
|
401 | - /** |
|
402 | - * Gets all the term-taxonomies for this CPT |
|
403 | - * |
|
404 | - * @param array $query_params |
|
405 | - * @return EE_Term_Taxonomy |
|
406 | - */ |
|
407 | - public function term_taxonomies($query_params = array()) |
|
408 | - { |
|
409 | - return $this->get_many_related('Term_Taxonomy', $query_params); |
|
410 | - } |
|
411 | - |
|
412 | - |
|
413 | - /** |
|
414 | - * @return mixed |
|
415 | - */ |
|
416 | - public function get_custom_post_statuses() |
|
417 | - { |
|
418 | - return $this->get_model()->get_custom_post_statuses(); |
|
419 | - } |
|
420 | - |
|
421 | - |
|
422 | - /** |
|
423 | - * @return mixed |
|
424 | - */ |
|
425 | - public function get_all_post_statuses() |
|
426 | - { |
|
427 | - return $this->get_model()->get_status_array(); |
|
428 | - } |
|
429 | - |
|
430 | - |
|
431 | - /** |
|
432 | - * Don't serialize the WP Post. That's just duplicate data and we want to avoid recursion |
|
433 | - * |
|
434 | - * @return array |
|
435 | - */ |
|
436 | - public function __sleep() |
|
437 | - { |
|
438 | - $properties_to_serialize = parent::__sleep(); |
|
439 | - $properties_to_serialize = array_diff($properties_to_serialize, array('_wp_post')); |
|
440 | - return $properties_to_serialize; |
|
441 | - } |
|
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 ($this->get_model()->get_table_obj_by_alias($field_obj->get_table_alias())->get_table_name() |
|
50 | + === $wpdb->posts |
|
51 | + ) { |
|
52 | + $column = $field_obj->get_table_column(); |
|
53 | + |
|
54 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
55 | + $value_on_model_obj = $this->get_DateTime_object($field_name); |
|
56 | + } elseif ($field_obj->is_db_only_field()) { |
|
57 | + $value_on_model_obj = $field_obj->get_default_value(); |
|
58 | + } else { |
|
59 | + $value_on_model_obj = $this->get_raw($field_name); |
|
60 | + } |
|
61 | + $simulated_db_result->{$column} = $field_obj->prepare_for_use_in_db($value_on_model_obj); |
|
62 | + } |
|
63 | + } |
|
64 | + $this->_wp_post = new WP_Post($simulated_db_result); |
|
65 | + } |
|
66 | + // and let's make retrieving the EE CPT object easy too |
|
67 | + $classname = get_class($this); |
|
68 | + if (! isset($this->_wp_post->{$classname})) { |
|
69 | + $this->_wp_post->{$classname} = $this; |
|
70 | + } |
|
71 | + } |
|
72 | + return $this->_wp_post; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * When fetching a new value for a post field that uses the global $post for rendering, |
|
77 | + * set the global $post temporarily to be this model object; and afterwards restore it |
|
78 | + * |
|
79 | + * @param string $fieldname |
|
80 | + * @param bool $pretty |
|
81 | + * @param string $extra_cache_ref |
|
82 | + * @return mixed |
|
83 | + */ |
|
84 | + protected function _get_fresh_property($fieldname, $pretty = false, $extra_cache_ref = null) |
|
85 | + { |
|
86 | + global $post; |
|
87 | + |
|
88 | + if ($pretty |
|
89 | + && ( |
|
90 | + ! ( |
|
91 | + $post instanceof WP_Post |
|
92 | + && $post->ID |
|
93 | + ) |
|
94 | + || (int) $post->ID !== $this->ID() |
|
95 | + ) |
|
96 | + && $this->get_model()->field_settings_for($fieldname) instanceof EE_Post_Content_Field) { |
|
97 | + $old_post = $post; |
|
98 | + $post = $this->wp_post(); |
|
99 | + $return_value = parent::_get_fresh_property($fieldname, $pretty, $extra_cache_ref); |
|
100 | + $post = $old_post; |
|
101 | + } else { |
|
102 | + $return_value = parent::_get_fresh_property($fieldname, $pretty, $extra_cache_ref); |
|
103 | + } |
|
104 | + return $return_value; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * Adds to the specified event category. If it category doesn't exist, creates it. |
|
109 | + * |
|
110 | + * @param string $category_name |
|
111 | + * @param string $category_description optional |
|
112 | + * @param int $parent_term_taxonomy_id optional |
|
113 | + * @return EE_Term_Taxonomy |
|
114 | + */ |
|
115 | + public function add_event_category($category_name, $category_description = null, $parent_term_taxonomy_id = null) |
|
116 | + { |
|
117 | + return $this->get_model()->add_event_category( |
|
118 | + $this, |
|
119 | + $category_name, |
|
120 | + $category_description, |
|
121 | + $parent_term_taxonomy_id |
|
122 | + ); |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * Removes the event category by specified name from being related ot this event |
|
128 | + * |
|
129 | + * @param string $category_name |
|
130 | + * @return bool |
|
131 | + */ |
|
132 | + public function remove_event_category($category_name) |
|
133 | + { |
|
134 | + return $this->get_model()->remove_event_category($this, $category_name); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * Removes the relation to the specified term taxonomy, and maintains the |
|
140 | + * data integrity of the term taxonomy provided |
|
141 | + * |
|
142 | + * @param EE_Term_Taxonomy $term_taxonomy |
|
143 | + * @return EE_Base_Class the relation was removed from |
|
144 | + */ |
|
145 | + public function remove_relation_to_term_taxonomy($term_taxonomy) |
|
146 | + { |
|
147 | + if (! $term_taxonomy) { |
|
148 | + EE_Error::add_error( |
|
149 | + sprintf( |
|
150 | + __( |
|
151 | + "No Term_Taxonomy provided which to remove from model object of type %s and id %d", |
|
152 | + "event_espresso" |
|
153 | + ), |
|
154 | + get_class($this), |
|
155 | + $this->ID() |
|
156 | + ), |
|
157 | + __FILE__, |
|
158 | + __FUNCTION__, |
|
159 | + __LINE__ |
|
160 | + ); |
|
161 | + return null; |
|
162 | + } |
|
163 | + $term_taxonomy->set_count($term_taxonomy->count() - 1); |
|
164 | + $term_taxonomy->save(); |
|
165 | + return $this->_remove_relation_to($term_taxonomy, 'Term_Taxonomy'); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * The main purpose of this method is to return the post type for the model object |
|
171 | + * |
|
172 | + * @access public |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + public function post_type() |
|
176 | + { |
|
177 | + return $this->get_model()->post_type(); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * The main purpose of this method is to return the parent for the model object |
|
183 | + * |
|
184 | + * @access public |
|
185 | + * @return int |
|
186 | + */ |
|
187 | + public function parent() |
|
188 | + { |
|
189 | + return $this->get('parent'); |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * return the _status property |
|
195 | + * |
|
196 | + * @return string |
|
197 | + */ |
|
198 | + public function status() |
|
199 | + { |
|
200 | + return $this->get('status'); |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * @param string $status |
|
206 | + */ |
|
207 | + public function set_status($status) |
|
208 | + { |
|
209 | + $this->set('status', $status); |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + /** |
|
214 | + * This calls the equivalent model method for retrieving the feature image which in turn is a wrapper for |
|
215 | + * WordPress' get_the_post_thumbnail() function. |
|
216 | + * |
|
217 | + * @link http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail |
|
218 | + * @access protected |
|
219 | + * @param string|array $size (optional) Image size. Defaults to 'post-thumbnail' but can also be a 2-item array |
|
220 | + * representing width and height in pixels (i.e. array(32,32) ). |
|
221 | + * @param string|array $attr Optional. Query string or array of attributes. |
|
222 | + * @return string HTML image element |
|
223 | + */ |
|
224 | + protected function _get_feature_image($size, $attr) |
|
225 | + { |
|
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 | + $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 ]; |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * See _get_feature_image. Returns the HTML to display a featured image |
|
237 | + * |
|
238 | + * @param string $size |
|
239 | + * @param string|array $attr |
|
240 | + * @return string of html |
|
241 | + */ |
|
242 | + public function feature_image($size = 'thumbnail', $attr = '') |
|
243 | + { |
|
244 | + return $this->_get_feature_image($size, $attr); |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * This uses the wp "wp_get_attachment_image_src()" function to return the feature image for the current class |
|
250 | + * using the given size params. |
|
251 | + * |
|
252 | + * @param string|array $size can either be a string: 'thumbnail', 'medium', 'large', 'full' OR 2-item array |
|
253 | + * representing width and height in pixels eg. array(32,32). |
|
254 | + * @return string|boolean the url of the image or false if not found |
|
255 | + */ |
|
256 | + public function feature_image_url($size = 'thumbnail') |
|
257 | + { |
|
258 | + $attachment = wp_get_attachment_image_src(get_post_thumbnail_id($this->ID()), $size); |
|
259 | + return ! empty($attachment) ? $attachment[0] : false; |
|
260 | + } |
|
261 | + |
|
262 | + |
|
263 | + /** |
|
264 | + * This is a method for restoring this_obj using details from the given $revision_id |
|
265 | + * |
|
266 | + * @param int $revision_id ID of the revision we're getting data from |
|
267 | + * @param array $related_obj_names if included this will be used to restore for related obj |
|
268 | + * if not included then we just do restore on the meta. |
|
269 | + * We will accept an array of related_obj_names for restoration here. |
|
270 | + * @param array $where_query You can optionally include an array of key=>value pairs |
|
271 | + * that allow you to further constrict the relation to being added. |
|
272 | + * However, keep in mind that the columns (keys) given |
|
273 | + * must match a column on the JOIN table and currently |
|
274 | + * only the HABTM models accept these additional conditions. |
|
275 | + * Also remember that if an exact match isn't found for these extra cols/val pairs, |
|
276 | + * then a NEW row is created in the join table. |
|
277 | + * This array is INDEXED by RELATED OBJ NAME (so it corresponds with the obj_names |
|
278 | + * sent); |
|
279 | + * @return void |
|
280 | + */ |
|
281 | + public function restore_revision($revision_id, $related_obj_names = array(), $where_query = array()) |
|
282 | + { |
|
283 | + // get revision object |
|
284 | + $revision_obj = $this->get_model()->get_one_by_ID($revision_id); |
|
285 | + if ($revision_obj instanceof EE_CPT_Base) { |
|
286 | + // no related_obj_name so we assume we're saving a revision on this object. |
|
287 | + if (empty($related_obj_names)) { |
|
288 | + $fields = $this->get_model()->get_meta_table_fields(); |
|
289 | + foreach ($fields as $field) { |
|
290 | + $this->set($field, $revision_obj->get($field)); |
|
291 | + } |
|
292 | + $this->save(); |
|
293 | + } |
|
294 | + $related_obj_names = (array) $related_obj_names; |
|
295 | + foreach ($related_obj_names as $related_name) { |
|
296 | + // related_obj_name so we're saving a revision on an object related to this object |
|
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(); |
|
299 | + $where_params = ! empty($cols_n_values) ? array($cols_n_values) : array(); |
|
300 | + $related_objs = $this->get_many_related($related_name, $where_params); |
|
301 | + $revision_related_objs = $revision_obj->get_many_related($related_name, $where_params); |
|
302 | + // load helper |
|
303 | + // remove related objs from this object that are not in revision |
|
304 | + // array_diff *should* work cause I think objects are indexed by ID? |
|
305 | + $related_to_remove = EEH_Array::object_array_diff($related_objs, $revision_related_objs); |
|
306 | + foreach ($related_to_remove as $rr) { |
|
307 | + $this->_remove_relation_to($rr, $related_name, $cols_n_values); |
|
308 | + } |
|
309 | + // add all related objs attached to revision to this object |
|
310 | + foreach ($revision_related_objs as $r_obj) { |
|
311 | + $this->_add_relation_to($r_obj, $related_name, $cols_n_values); |
|
312 | + } |
|
313 | + } |
|
314 | + } |
|
315 | + } |
|
316 | + |
|
317 | + |
|
318 | + /** |
|
319 | + * Wrapper for get_post_meta, http://codex.wordpress.org/Function_Reference/get_post_meta |
|
320 | + * |
|
321 | + * @param string $meta_key |
|
322 | + * @param boolean $single |
|
323 | + * @return mixed <ul><li>If only $id is set it will return all meta values in an associative array.</li> |
|
324 | + * <li>If $single is set to false, or left blank, the function returns an array containing all values of the |
|
325 | + * specified key.</li> |
|
326 | + * <li>If $single is set to true, the function returns the first value of the specified key (not in an |
|
327 | + * array</li></ul> |
|
328 | + */ |
|
329 | + public function get_post_meta($meta_key = null, $single = false) |
|
330 | + { |
|
331 | + return get_post_meta($this->ID(), $meta_key, $single); |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * Wrapper for update_post_meta, http://codex.wordpress.org/Function_Reference/update_post_meta |
|
337 | + * |
|
338 | + * @param string $meta_key |
|
339 | + * @param mixed $meta_value |
|
340 | + * @param mixed $prev_value |
|
341 | + * @return mixed Returns meta_id if the meta doesn't exist, otherwise returns true on success and false on failure. |
|
342 | + * NOTE: If the meta_value passed to this function is the same as the value that is already in the |
|
343 | + * database, this function returns false. |
|
344 | + */ |
|
345 | + public function update_post_meta($meta_key, $meta_value, $prev_value = null) |
|
346 | + { |
|
347 | + if (! $this->ID()) { |
|
348 | + $this->save(); |
|
349 | + } |
|
350 | + return update_post_meta($this->ID(), $meta_key, $meta_value, $prev_value); |
|
351 | + } |
|
352 | + |
|
353 | + |
|
354 | + /** |
|
355 | + * Wrapper for add_post_meta, http://codex.wordpress.org/Function_Reference/add_post_meta |
|
356 | + * |
|
357 | + * @param mixed $meta_key |
|
358 | + * @param mixed $meta_value |
|
359 | + * @param bool $unique . If postmeta for this $meta_key already exists, whether to add an additional item or not |
|
360 | + * @return boolean Boolean true, except if the $unique argument was set to true and a custom field with the given |
|
361 | + * key already exists, in which case false is returned. |
|
362 | + */ |
|
363 | + public function add_post_meta($meta_key, $meta_value, $unique = false) |
|
364 | + { |
|
365 | + if ($this->ID()) { |
|
366 | + $this->save(); |
|
367 | + } |
|
368 | + return add_post_meta($this->ID(), $meta_key, $meta_value, $unique); |
|
369 | + } |
|
370 | + |
|
371 | + |
|
372 | + /** |
|
373 | + * Wrapper for delete_post_meta, http://codex.wordpress.org/Function_Reference/delete_post_meta |
|
374 | + * |
|
375 | + * @param mixed $meta_key |
|
376 | + * @param mixed $meta_value |
|
377 | + * @return boolean False for failure. True for success. |
|
378 | + */ |
|
379 | + public function delete_post_meta($meta_key, $meta_value = '') |
|
380 | + { |
|
381 | + if (! $this->ID()) { |
|
382 | + // there are obviously no postmetas for this if it's not saved |
|
383 | + // so let's just report this as a success |
|
384 | + return true; |
|
385 | + } |
|
386 | + return delete_post_meta($this->ID(), $meta_key, $meta_value); |
|
387 | + } |
|
388 | + |
|
389 | + |
|
390 | + /** |
|
391 | + * Gets the URL for viewing this event on the front-end |
|
392 | + * |
|
393 | + * @return string |
|
394 | + */ |
|
395 | + public function get_permalink() |
|
396 | + { |
|
397 | + return get_permalink($this->ID()); |
|
398 | + } |
|
399 | + |
|
400 | + |
|
401 | + /** |
|
402 | + * Gets all the term-taxonomies for this CPT |
|
403 | + * |
|
404 | + * @param array $query_params |
|
405 | + * @return EE_Term_Taxonomy |
|
406 | + */ |
|
407 | + public function term_taxonomies($query_params = array()) |
|
408 | + { |
|
409 | + return $this->get_many_related('Term_Taxonomy', $query_params); |
|
410 | + } |
|
411 | + |
|
412 | + |
|
413 | + /** |
|
414 | + * @return mixed |
|
415 | + */ |
|
416 | + public function get_custom_post_statuses() |
|
417 | + { |
|
418 | + return $this->get_model()->get_custom_post_statuses(); |
|
419 | + } |
|
420 | + |
|
421 | + |
|
422 | + /** |
|
423 | + * @return mixed |
|
424 | + */ |
|
425 | + public function get_all_post_statuses() |
|
426 | + { |
|
427 | + return $this->get_model()->get_status_array(); |
|
428 | + } |
|
429 | + |
|
430 | + |
|
431 | + /** |
|
432 | + * Don't serialize the WP Post. That's just duplicate data and we want to avoid recursion |
|
433 | + * |
|
434 | + * @return array |
|
435 | + */ |
|
436 | + public function __sleep() |
|
437 | + { |
|
438 | + $properties_to_serialize = parent::__sleep(); |
|
439 | + $properties_to_serialize = array_diff($properties_to_serialize, array('_wp_post')); |
|
440 | + return $properties_to_serialize; |
|
441 | + } |
|
442 | 442 | } |
@@ -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; |