@@ -49,29 +49,29 @@ |
||
49 | 49 | |
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * _migration_step |
|
54 | - * |
|
55 | - * @access protected |
|
56 | - * @param int $num_items |
|
57 | - * @throws EE_Error |
|
58 | - * @return int number of items ACTUALLY migrated |
|
59 | - * @throws InvalidDataTypeException |
|
60 | - */ |
|
52 | + /** |
|
53 | + * _migration_step |
|
54 | + * |
|
55 | + * @access protected |
|
56 | + * @param int $num_items |
|
57 | + * @throws EE_Error |
|
58 | + * @return int number of items ACTUALLY migrated |
|
59 | + * @throws InvalidDataTypeException |
|
60 | + */ |
|
61 | 61 | protected function _migration_step( $num_items = 1 ){ |
62 | 62 | |
63 | 63 | $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
64 | 64 | $overridden_invoice_body = EEH_Template::locate_template( $templates_relative_path . 'invoice_body.template.php', NULL, FALSE, FALSE, TRUE ); |
65 | 65 | $overridden_receipt_body= EEH_Template::locate_template( $templates_relative_path . 'receipt_body.template.php', NULL, FALSE, FALSE, TRUE ); |
66 | 66 | if( $overridden_invoice_body || $overridden_receipt_body ) { |
67 | - new PersistentAdminNotice( |
|
68 | - 'invoice_overriding_templates', |
|
69 | - esc_html__( |
|
70 | - 'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents (but this will be removed in an upcoming version). We recommend deleting your old Invoice/Receipt templates and using the new messages system. Then modify the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.', |
|
71 | - 'event_espresso' |
|
72 | - ), |
|
73 | - true |
|
74 | - ); |
|
67 | + new PersistentAdminNotice( |
|
68 | + 'invoice_overriding_templates', |
|
69 | + esc_html__( |
|
70 | + 'Note: in this version of Event Espresso, PDF and HTML Invoices and Receipts are now Messages and can be changed just like any other messages; however we noticed you had previously overridden the old default Invoice/Receipt templates. Because of this, your old Invoice/Receipt templates will continue to be used INSTEAD of the new Invoice/Receipt message equivalents (but this will be removed in an upcoming version). We recommend deleting your old Invoice/Receipt templates and using the new messages system. Then modify the new Invoice and Receipt messages\'s content in Messages -> Invoice and Messages -> Receipt.', |
|
71 | + 'event_espresso' |
|
72 | + ), |
|
73 | + true |
|
74 | + ); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | //regardless of whether it worked or not, we ought to continue the migration |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * Just initializes the status of the migration |
31 | 31 | */ |
32 | 32 | public function __construct() { |
33 | - $this->_pretty_name = __( 'Update Invoice Settings', 'event_espresso' ); |
|
33 | + $this->_pretty_name = __('Update Invoice Settings', 'event_espresso'); |
|
34 | 34 | parent::__construct(); |
35 | 35 | } |
36 | 36 | |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * @return int number of items ACTUALLY migrated |
59 | 59 | * @throws InvalidDataTypeException |
60 | 60 | */ |
61 | - protected function _migration_step( $num_items = 1 ){ |
|
61 | + protected function _migration_step($num_items = 1) { |
|
62 | 62 | |
63 | 63 | $templates_relative_path = 'modules/gateways/Invoice/lib/templates/'; |
64 | - $overridden_invoice_body = EEH_Template::locate_template( $templates_relative_path . 'invoice_body.template.php', NULL, FALSE, FALSE, TRUE ); |
|
65 | - $overridden_receipt_body= EEH_Template::locate_template( $templates_relative_path . 'receipt_body.template.php', NULL, FALSE, FALSE, TRUE ); |
|
66 | - if( $overridden_invoice_body || $overridden_receipt_body ) { |
|
64 | + $overridden_invoice_body = EEH_Template::locate_template($templates_relative_path.'invoice_body.template.php', NULL, FALSE, FALSE, TRUE); |
|
65 | + $overridden_receipt_body = EEH_Template::locate_template($templates_relative_path.'receipt_body.template.php', NULL, FALSE, FALSE, TRUE); |
|
66 | + if ($overridden_invoice_body || $overridden_receipt_body) { |
|
67 | 67 | new PersistentAdminNotice( |
68 | 68 | 'invoice_overriding_templates', |
69 | 69 | esc_html__( |
@@ -18,65 +18,65 @@ |
||
18 | 18 | class CoffeeMill |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * @var CoffeeShop $coffee_shop |
|
23 | - */ |
|
24 | - private static $coffee_shop; |
|
25 | - |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * @return mixed |
|
30 | - */ |
|
31 | - public static function getCoffeeShop() |
|
32 | - { |
|
33 | - return self::$coffee_shop; |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @param CoffeeShop $coffee_shop |
|
40 | - */ |
|
41 | - public static function setCoffeeShop(CoffeeShop $coffee_shop) |
|
42 | - { |
|
43 | - self::$coffee_shop = $coffee_shop; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * @param string $identifier |
|
50 | - * @param array $arguments |
|
51 | - * @param string $type |
|
52 | - * @return mixed |
|
53 | - * @throws ServiceNotFoundException |
|
54 | - */ |
|
55 | - public static function createNew($identifier, $arguments = array(), $type = CoffeeMaker::BREW_NEW) |
|
56 | - { |
|
57 | - return self::$coffee_shop->brew($identifier, $arguments, $type); |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * IMPORTANT!!! |
|
64 | - * Usage of this method is discouraged as it promotes service location. |
|
65 | - * It's current use is only as a stop gap measure until the CoffeeShop |
|
66 | - * Dependency Injection Container can be implemented properly for all classes. |
|
67 | - * If it is at all possible, inject your dependencies via your class constructor. |
|
68 | - * This method WILL BE DEPRECATED at some point in the near future. |
|
69 | - * |
|
70 | - * @param string $identifier |
|
71 | - * @param array $arguments |
|
72 | - * @param string $type |
|
73 | - * @return mixed |
|
74 | - * @throws ServiceNotFoundException |
|
75 | - */ |
|
76 | - public static function getService($identifier, $arguments = array(), $type = CoffeeMaker::BREW_SHARED) |
|
77 | - { |
|
78 | - return self::$coffee_shop->brew($identifier, $arguments, $type); |
|
79 | - } |
|
21 | + /** |
|
22 | + * @var CoffeeShop $coffee_shop |
|
23 | + */ |
|
24 | + private static $coffee_shop; |
|
25 | + |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * @return mixed |
|
30 | + */ |
|
31 | + public static function getCoffeeShop() |
|
32 | + { |
|
33 | + return self::$coffee_shop; |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @param CoffeeShop $coffee_shop |
|
40 | + */ |
|
41 | + public static function setCoffeeShop(CoffeeShop $coffee_shop) |
|
42 | + { |
|
43 | + self::$coffee_shop = $coffee_shop; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * @param string $identifier |
|
50 | + * @param array $arguments |
|
51 | + * @param string $type |
|
52 | + * @return mixed |
|
53 | + * @throws ServiceNotFoundException |
|
54 | + */ |
|
55 | + public static function createNew($identifier, $arguments = array(), $type = CoffeeMaker::BREW_NEW) |
|
56 | + { |
|
57 | + return self::$coffee_shop->brew($identifier, $arguments, $type); |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * IMPORTANT!!! |
|
64 | + * Usage of this method is discouraged as it promotes service location. |
|
65 | + * It's current use is only as a stop gap measure until the CoffeeShop |
|
66 | + * Dependency Injection Container can be implemented properly for all classes. |
|
67 | + * If it is at all possible, inject your dependencies via your class constructor. |
|
68 | + * This method WILL BE DEPRECATED at some point in the near future. |
|
69 | + * |
|
70 | + * @param string $identifier |
|
71 | + * @param array $arguments |
|
72 | + * @param string $type |
|
73 | + * @return mixed |
|
74 | + * @throws ServiceNotFoundException |
|
75 | + */ |
|
76 | + public static function getService($identifier, $arguments = array(), $type = CoffeeMaker::BREW_SHARED) |
|
77 | + { |
|
78 | + return self::$coffee_shop->brew($identifier, $arguments, $type); |
|
79 | + } |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | // End of file CoffeeMill.php |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | |
@@ -17,65 +17,65 @@ discard block |
||
17 | 17 | class EE_Checkbox_Dropdown_Selector_Input extends EE_Form_Input_With_Options_Base |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var string text to display on the select button itself |
|
22 | - */ |
|
23 | - protected $_select_button_text; |
|
20 | + /** |
|
21 | + * @var string text to display on the select button itself |
|
22 | + */ |
|
23 | + protected $_select_button_text; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @param array $answer_options |
|
27 | - * @param array $input_settings |
|
28 | - */ |
|
29 | - public function __construct($answer_options, $input_settings = array()) |
|
30 | - { |
|
31 | - $this->_select_button_text = EEH_Array::is_set( $input_settings, 'select_button_text', |
|
32 | - esc_html__('Select', 'event_espresso')); |
|
33 | - $display_strategy = new EE_Checkbox_Dropdown_Selector_Display_Strategy(); |
|
34 | - $this->_set_display_strategy($display_strategy); |
|
35 | - $this->load_iframe_assets($display_strategy); |
|
36 | - $this->_add_validation_strategy( |
|
37 | - new EE_Many_Valued_Validation_Strategy( |
|
38 | - array( |
|
39 | - new EE_Enum_Validation_Strategy( |
|
40 | - isset($input_settings['validation_error_message']) |
|
41 | - ? $input_settings['validation_error_message'] |
|
42 | - : null |
|
43 | - ), |
|
44 | - ) |
|
45 | - ) |
|
46 | - ); |
|
47 | - $this->_multiple_selections = true; |
|
48 | - parent::__construct($answer_options, $input_settings); |
|
49 | - } |
|
25 | + /** |
|
26 | + * @param array $answer_options |
|
27 | + * @param array $input_settings |
|
28 | + */ |
|
29 | + public function __construct($answer_options, $input_settings = array()) |
|
30 | + { |
|
31 | + $this->_select_button_text = EEH_Array::is_set( $input_settings, 'select_button_text', |
|
32 | + esc_html__('Select', 'event_espresso')); |
|
33 | + $display_strategy = new EE_Checkbox_Dropdown_Selector_Display_Strategy(); |
|
34 | + $this->_set_display_strategy($display_strategy); |
|
35 | + $this->load_iframe_assets($display_strategy); |
|
36 | + $this->_add_validation_strategy( |
|
37 | + new EE_Many_Valued_Validation_Strategy( |
|
38 | + array( |
|
39 | + new EE_Enum_Validation_Strategy( |
|
40 | + isset($input_settings['validation_error_message']) |
|
41 | + ? $input_settings['validation_error_message'] |
|
42 | + : null |
|
43 | + ), |
|
44 | + ) |
|
45 | + ) |
|
46 | + ); |
|
47 | + $this->_multiple_selections = true; |
|
48 | + parent::__construct($answer_options, $input_settings); |
|
49 | + } |
|
50 | 50 | |
51 | - /* |
|
51 | + /* |
|
52 | 52 | * Returns the text to display in the select button |
53 | 53 | */ |
54 | - public function select_button_text(){ |
|
55 | - return $this->_select_button_text; |
|
56 | - } |
|
54 | + public function select_button_text(){ |
|
55 | + return $this->_select_button_text; |
|
56 | + } |
|
57 | 57 | |
58 | - /* |
|
58 | + /* |
|
59 | 59 | * add css and js for iframes |
60 | 60 | */ |
61 | - protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy){ |
|
62 | - add_filter( |
|
63 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
64 | - array($display_strategy, 'iframe_css') |
|
65 | - ); |
|
66 | - add_filter( |
|
67 | - 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
68 | - array($display_strategy, 'iframe_js') |
|
69 | - ); |
|
70 | - add_filter( |
|
71 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
72 | - array($display_strategy, 'iframe_css') |
|
73 | - ); |
|
74 | - add_filter( |
|
75 | - 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
76 | - array($display_strategy, 'iframe_js') |
|
77 | - ); |
|
78 | - } |
|
61 | + protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy){ |
|
62 | + add_filter( |
|
63 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
|
64 | + array($display_strategy, 'iframe_css') |
|
65 | + ); |
|
66 | + add_filter( |
|
67 | + 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js', |
|
68 | + array($display_strategy, 'iframe_js') |
|
69 | + ); |
|
70 | + add_filter( |
|
71 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
|
72 | + array($display_strategy, 'iframe_css') |
|
73 | + ); |
|
74 | + add_filter( |
|
75 | + 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
|
76 | + array($display_strategy, 'iframe_js') |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | 81 | } |
82 | 82 | \ No newline at end of file |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function __construct($answer_options, $input_settings = array()) |
30 | 30 | { |
31 | - $this->_select_button_text = EEH_Array::is_set( $input_settings, 'select_button_text', |
|
31 | + $this->_select_button_text = EEH_Array::is_set($input_settings, 'select_button_text', |
|
32 | 32 | esc_html__('Select', 'event_espresso')); |
33 | 33 | $display_strategy = new EE_Checkbox_Dropdown_Selector_Display_Strategy(); |
34 | 34 | $this->_set_display_strategy($display_strategy); |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | /* |
52 | 52 | * Returns the text to display in the select button |
53 | 53 | */ |
54 | - public function select_button_text(){ |
|
54 | + public function select_button_text() { |
|
55 | 55 | return $this->_select_button_text; |
56 | 56 | } |
57 | 57 | |
58 | 58 | /* |
59 | 59 | * add css and js for iframes |
60 | 60 | */ |
61 | - protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy){ |
|
61 | + protected function load_iframe_assets(EE_Checkbox_Dropdown_Selector_Display_Strategy $display_strategy) { |
|
62 | 62 | add_filter( |
63 | 63 | 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css', |
64 | 64 | array($display_strategy, 'iframe_css') |
@@ -16,282 +16,282 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @var string $iframe_name |
|
21 | - */ |
|
22 | - private $iframe_name; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var string $route_name |
|
26 | - */ |
|
27 | - private $route_name; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var string $slug |
|
31 | - */ |
|
32 | - private $slug; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var boolean $append_filterable_content |
|
36 | - */ |
|
37 | - private $append_filterable_content; |
|
38 | - |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * IframeEmbedButton constructor. |
|
43 | - * |
|
44 | - * @param string $iframe_name i18n name for the iframe. This will be used in HTML |
|
45 | - * @param string $route_name the name of the registered route |
|
46 | - * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
|
47 | - * will most likely be "event" since that's the only usage atm |
|
48 | - */ |
|
49 | - public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
50 | - { |
|
51 | - $this->iframe_name = $iframe_name; |
|
52 | - $this->route_name = $route_name; |
|
53 | - $this->slug = $slug; |
|
54 | - } |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * Adds an iframe embed code button to the Event editor. |
|
60 | - */ |
|
61 | - public function addEventEditorIframeEmbedButtonFilter() |
|
62 | - { |
|
63 | - // add button for iframe code to event editor. |
|
64 | - add_filter( |
|
65 | - 'get_sample_permalink_html', |
|
66 | - array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
67 | - 10, |
|
68 | - 2 |
|
69 | - ); |
|
70 | - add_action( |
|
71 | - 'admin_enqueue_scripts', |
|
72 | - array( $this, 'embedButtonAssets' ), |
|
73 | - 10 |
|
74 | - ); |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @param $permalink_string |
|
81 | - * @param $id |
|
82 | - * @return string |
|
83 | - */ |
|
84 | - public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
85 | - { |
|
86 | - return $this->eventEditorIframeEmbedButton( |
|
87 | - $permalink_string, |
|
88 | - $id |
|
89 | - ); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * iframe embed code button to the Event editor. |
|
96 | - * |
|
97 | - * @param string $permalink_string |
|
98 | - * @param int $id |
|
99 | - * @return string |
|
100 | - */ |
|
101 | - public function eventEditorIframeEmbedButton( |
|
102 | - $permalink_string, |
|
103 | - $id |
|
104 | - ) { |
|
105 | - //make sure this is ONLY when editing and the event id has been set. |
|
106 | - if ( ! empty( $id ) ) { |
|
107 | - $post = get_post( $id ); |
|
108 | - //if NOT event then let's get out. |
|
109 | - if ( $post->post_type !== 'espresso_events' ) { |
|
110 | - return $permalink_string; |
|
111 | - } |
|
112 | - $permalink_string .= $this->embedButtonHtml( |
|
113 | - array( $this->slug => $id ), |
|
114 | - 'button-small' |
|
115 | - ); |
|
116 | - } |
|
117 | - return $permalink_string; |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * Adds an iframe embed code button via a WP do_action() as determined by the first parameter |
|
124 | - * |
|
125 | - * @param string $action name of the WP do_action() to hook into |
|
126 | - */ |
|
127 | - public function addActionIframeEmbedButton( $action ) |
|
128 | - { |
|
129 | - // add button for iframe code to event editor. |
|
130 | - add_action( |
|
131 | - $action, |
|
132 | - array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
133 | - 10, 2 |
|
134 | - ); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * @return void |
|
141 | - */ |
|
142 | - public function addActionIframeEmbedButtonCallback() |
|
143 | - { |
|
144 | - echo $this->embedButtonHtml(); |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter |
|
151 | - * |
|
152 | - * @param string $filter name of the WP apply_filters() to hook into |
|
153 | - * @param bool $append if true, will add iframe embed button to end of content, |
|
154 | - * else if false, will add to the beginning of the content |
|
155 | - */ |
|
156 | - public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
157 | - { |
|
158 | - $this->append_filterable_content = $append; |
|
159 | - // add button for iframe code to event editor. |
|
160 | - add_filter( |
|
161 | - $filter, |
|
162 | - array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
163 | - 10 |
|
164 | - ); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * @param array|string $filterable_content |
|
171 | - * @return array|string |
|
172 | - */ |
|
173 | - public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
174 | - { |
|
175 | - $embedButtonHtml = $this->embedButtonHtml(); |
|
176 | - if ( is_array( $filterable_content ) ) { |
|
177 | - $filterable_content = $this->append_filterable_content |
|
178 | - ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
179 | - : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
180 | - } else { |
|
181 | - $filterable_content = $this->append_filterable_content |
|
182 | - ? $filterable_content . $embedButtonHtml |
|
183 | - : $embedButtonHtml . $filterable_content; |
|
184 | - } |
|
185 | - return $filterable_content; |
|
186 | - } |
|
187 | - |
|
188 | - |
|
189 | - |
|
190 | - /** |
|
191 | - * iframe_embed_html |
|
192 | - * |
|
193 | - * @param array $query_args |
|
194 | - * @param string $button_class |
|
195 | - * @return string |
|
196 | - */ |
|
197 | - public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
198 | - { |
|
199 | - // incoming args will replace the defaults listed here in the second array (union preserves first array) |
|
200 | - $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
201 | - $query_args = (array)apply_filters( |
|
202 | - 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
|
203 | - $query_args |
|
204 | - ); |
|
205 | - // add this route to our localized vars |
|
206 | - $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
207 | - ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
208 | - : array(); |
|
209 | - $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
210 | - \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
211 | - $iframe_embed_html = \EEH_HTML::link( |
|
212 | - '#', |
|
213 | - sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
214 | - sprintf( |
|
215 | - esc_html__( |
|
216 | - 'click here to generate code for embedding %1$s iframe into another site.', |
|
217 | - 'event_espresso' |
|
218 | - ), |
|
219 | - \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
220 | - ), |
|
221 | - "{$this->route_name}-iframe-embed-trigger-js", |
|
222 | - 'iframe-embed-trigger-js button ' . $button_class, |
|
223 | - '', |
|
224 | - ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
225 | - ); |
|
226 | - $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | - 'display:none;' ); |
|
228 | - $iframe_embed_html .= esc_html( |
|
229 | - \EEH_HTML::div( |
|
230 | - '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
231 | - '', |
|
232 | - '', |
|
233 | - 'width:100%; height: 500px;' |
|
234 | - ) |
|
235 | - ); |
|
236 | - $iframe_embed_html .= \EEH_HTML::divx(); |
|
237 | - return $iframe_embed_html; |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * enqueue iframe button js |
|
244 | - */ |
|
245 | - public function embedButtonAssets() |
|
246 | - { |
|
247 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
248 | - 'copy and paste the following into any other site\'s content to display this event:', |
|
249 | - 'event_espresso' |
|
250 | - ); |
|
251 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
252 | - 'click anywhere outside of this window to close it.', |
|
253 | - 'event_espresso' |
|
254 | - ); |
|
255 | - wp_register_script( |
|
256 | - 'iframe_embed_button', |
|
257 | - plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
258 | - array( 'ee-dialog' ), |
|
259 | - EVENT_ESPRESSO_VERSION, |
|
260 | - true |
|
261 | - ); |
|
262 | - wp_enqueue_script( 'iframe_embed_button' ); |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * generates embed button sections for admin pages |
|
269 | - * |
|
270 | - * @param array $embed_buttons |
|
271 | - * @return string |
|
272 | - */ |
|
273 | - public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
274 | - { |
|
275 | - $embed_buttons = (array)apply_filters( |
|
276 | - 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
|
277 | - $embed_buttons |
|
278 | - ); |
|
279 | - if ( empty($embed_buttons)) { |
|
280 | - return ''; |
|
281 | - } |
|
282 | - // add button for iframe code to event editor. |
|
283 | - $html = \EEH_HTML::br( 2 ); |
|
284 | - $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
285 | - $html .= \EEH_HTML::p( |
|
286 | - esc_html__( |
|
287 | - 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
|
288 | - 'event_espresso' |
|
289 | - ) |
|
290 | - ); |
|
291 | - $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
292 | - $html .= \EEH_HTML::br( 2 ); |
|
293 | - return $html; |
|
294 | - } |
|
19 | + /** |
|
20 | + * @var string $iframe_name |
|
21 | + */ |
|
22 | + private $iframe_name; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var string $route_name |
|
26 | + */ |
|
27 | + private $route_name; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var string $slug |
|
31 | + */ |
|
32 | + private $slug; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var boolean $append_filterable_content |
|
36 | + */ |
|
37 | + private $append_filterable_content; |
|
38 | + |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * IframeEmbedButton constructor. |
|
43 | + * |
|
44 | + * @param string $iframe_name i18n name for the iframe. This will be used in HTML |
|
45 | + * @param string $route_name the name of the registered route |
|
46 | + * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
|
47 | + * will most likely be "event" since that's the only usage atm |
|
48 | + */ |
|
49 | + public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
50 | + { |
|
51 | + $this->iframe_name = $iframe_name; |
|
52 | + $this->route_name = $route_name; |
|
53 | + $this->slug = $slug; |
|
54 | + } |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * Adds an iframe embed code button to the Event editor. |
|
60 | + */ |
|
61 | + public function addEventEditorIframeEmbedButtonFilter() |
|
62 | + { |
|
63 | + // add button for iframe code to event editor. |
|
64 | + add_filter( |
|
65 | + 'get_sample_permalink_html', |
|
66 | + array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
67 | + 10, |
|
68 | + 2 |
|
69 | + ); |
|
70 | + add_action( |
|
71 | + 'admin_enqueue_scripts', |
|
72 | + array( $this, 'embedButtonAssets' ), |
|
73 | + 10 |
|
74 | + ); |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @param $permalink_string |
|
81 | + * @param $id |
|
82 | + * @return string |
|
83 | + */ |
|
84 | + public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
85 | + { |
|
86 | + return $this->eventEditorIframeEmbedButton( |
|
87 | + $permalink_string, |
|
88 | + $id |
|
89 | + ); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * iframe embed code button to the Event editor. |
|
96 | + * |
|
97 | + * @param string $permalink_string |
|
98 | + * @param int $id |
|
99 | + * @return string |
|
100 | + */ |
|
101 | + public function eventEditorIframeEmbedButton( |
|
102 | + $permalink_string, |
|
103 | + $id |
|
104 | + ) { |
|
105 | + //make sure this is ONLY when editing and the event id has been set. |
|
106 | + if ( ! empty( $id ) ) { |
|
107 | + $post = get_post( $id ); |
|
108 | + //if NOT event then let's get out. |
|
109 | + if ( $post->post_type !== 'espresso_events' ) { |
|
110 | + return $permalink_string; |
|
111 | + } |
|
112 | + $permalink_string .= $this->embedButtonHtml( |
|
113 | + array( $this->slug => $id ), |
|
114 | + 'button-small' |
|
115 | + ); |
|
116 | + } |
|
117 | + return $permalink_string; |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * Adds an iframe embed code button via a WP do_action() as determined by the first parameter |
|
124 | + * |
|
125 | + * @param string $action name of the WP do_action() to hook into |
|
126 | + */ |
|
127 | + public function addActionIframeEmbedButton( $action ) |
|
128 | + { |
|
129 | + // add button for iframe code to event editor. |
|
130 | + add_action( |
|
131 | + $action, |
|
132 | + array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
133 | + 10, 2 |
|
134 | + ); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * @return void |
|
141 | + */ |
|
142 | + public function addActionIframeEmbedButtonCallback() |
|
143 | + { |
|
144 | + echo $this->embedButtonHtml(); |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * Adds an iframe embed code button via a WP apply_filters() as determined by the first parameter |
|
151 | + * |
|
152 | + * @param string $filter name of the WP apply_filters() to hook into |
|
153 | + * @param bool $append if true, will add iframe embed button to end of content, |
|
154 | + * else if false, will add to the beginning of the content |
|
155 | + */ |
|
156 | + public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
157 | + { |
|
158 | + $this->append_filterable_content = $append; |
|
159 | + // add button for iframe code to event editor. |
|
160 | + add_filter( |
|
161 | + $filter, |
|
162 | + array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
163 | + 10 |
|
164 | + ); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * @param array|string $filterable_content |
|
171 | + * @return array|string |
|
172 | + */ |
|
173 | + public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
174 | + { |
|
175 | + $embedButtonHtml = $this->embedButtonHtml(); |
|
176 | + if ( is_array( $filterable_content ) ) { |
|
177 | + $filterable_content = $this->append_filterable_content |
|
178 | + ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
179 | + : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
180 | + } else { |
|
181 | + $filterable_content = $this->append_filterable_content |
|
182 | + ? $filterable_content . $embedButtonHtml |
|
183 | + : $embedButtonHtml . $filterable_content; |
|
184 | + } |
|
185 | + return $filterable_content; |
|
186 | + } |
|
187 | + |
|
188 | + |
|
189 | + |
|
190 | + /** |
|
191 | + * iframe_embed_html |
|
192 | + * |
|
193 | + * @param array $query_args |
|
194 | + * @param string $button_class |
|
195 | + * @return string |
|
196 | + */ |
|
197 | + public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
198 | + { |
|
199 | + // incoming args will replace the defaults listed here in the second array (union preserves first array) |
|
200 | + $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
201 | + $query_args = (array)apply_filters( |
|
202 | + 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
|
203 | + $query_args |
|
204 | + ); |
|
205 | + // add this route to our localized vars |
|
206 | + $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
207 | + ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
208 | + : array(); |
|
209 | + $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
210 | + \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
211 | + $iframe_embed_html = \EEH_HTML::link( |
|
212 | + '#', |
|
213 | + sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
214 | + sprintf( |
|
215 | + esc_html__( |
|
216 | + 'click here to generate code for embedding %1$s iframe into another site.', |
|
217 | + 'event_espresso' |
|
218 | + ), |
|
219 | + \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
220 | + ), |
|
221 | + "{$this->route_name}-iframe-embed-trigger-js", |
|
222 | + 'iframe-embed-trigger-js button ' . $button_class, |
|
223 | + '', |
|
224 | + ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
225 | + ); |
|
226 | + $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | + 'display:none;' ); |
|
228 | + $iframe_embed_html .= esc_html( |
|
229 | + \EEH_HTML::div( |
|
230 | + '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
231 | + '', |
|
232 | + '', |
|
233 | + 'width:100%; height: 500px;' |
|
234 | + ) |
|
235 | + ); |
|
236 | + $iframe_embed_html .= \EEH_HTML::divx(); |
|
237 | + return $iframe_embed_html; |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * enqueue iframe button js |
|
244 | + */ |
|
245 | + public function embedButtonAssets() |
|
246 | + { |
|
247 | + \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
248 | + 'copy and paste the following into any other site\'s content to display this event:', |
|
249 | + 'event_espresso' |
|
250 | + ); |
|
251 | + \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
252 | + 'click anywhere outside of this window to close it.', |
|
253 | + 'event_espresso' |
|
254 | + ); |
|
255 | + wp_register_script( |
|
256 | + 'iframe_embed_button', |
|
257 | + plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
258 | + array( 'ee-dialog' ), |
|
259 | + EVENT_ESPRESSO_VERSION, |
|
260 | + true |
|
261 | + ); |
|
262 | + wp_enqueue_script( 'iframe_embed_button' ); |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * generates embed button sections for admin pages |
|
269 | + * |
|
270 | + * @param array $embed_buttons |
|
271 | + * @return string |
|
272 | + */ |
|
273 | + public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
274 | + { |
|
275 | + $embed_buttons = (array)apply_filters( |
|
276 | + 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
|
277 | + $embed_buttons |
|
278 | + ); |
|
279 | + if ( empty($embed_buttons)) { |
|
280 | + return ''; |
|
281 | + } |
|
282 | + // add button for iframe code to event editor. |
|
283 | + $html = \EEH_HTML::br( 2 ); |
|
284 | + $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
285 | + $html .= \EEH_HTML::p( |
|
286 | + esc_html__( |
|
287 | + 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
|
288 | + 'event_espresso' |
|
289 | + ) |
|
290 | + ); |
|
291 | + $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
292 | + $html .= \EEH_HTML::br( 2 ); |
|
293 | + return $html; |
|
294 | + } |
|
295 | 295 | |
296 | 296 | |
297 | 297 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\iframe_display; |
3 | 3 | |
4 | -defined( 'ABSPATH' ) || exit; |
|
4 | +defined('ABSPATH') || exit; |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param string $slug URL slug used for the thing the iframe button is being embedded in. |
47 | 47 | * will most likely be "event" since that's the only usage atm |
48 | 48 | */ |
49 | - public function __construct( $iframe_name, $route_name, $slug = 'event' ) |
|
49 | + public function __construct($iframe_name, $route_name, $slug = 'event') |
|
50 | 50 | { |
51 | 51 | $this->iframe_name = $iframe_name; |
52 | 52 | $this->route_name = $route_name; |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | // add button for iframe code to event editor. |
64 | 64 | add_filter( |
65 | 65 | 'get_sample_permalink_html', |
66 | - array( $this, 'appendIframeEmbedButtonToSamplePermalinkHtml' ), |
|
66 | + array($this, 'appendIframeEmbedButtonToSamplePermalinkHtml'), |
|
67 | 67 | 10, |
68 | 68 | 2 |
69 | 69 | ); |
70 | 70 | add_action( |
71 | 71 | 'admin_enqueue_scripts', |
72 | - array( $this, 'embedButtonAssets' ), |
|
72 | + array($this, 'embedButtonAssets'), |
|
73 | 73 | 10 |
74 | 74 | ); |
75 | 75 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * @param $id |
82 | 82 | * @return string |
83 | 83 | */ |
84 | - public function appendIframeEmbedButtonToSamplePermalinkHtml( $permalink_string, $id ) |
|
84 | + public function appendIframeEmbedButtonToSamplePermalinkHtml($permalink_string, $id) |
|
85 | 85 | { |
86 | 86 | return $this->eventEditorIframeEmbedButton( |
87 | 87 | $permalink_string, |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | $id |
104 | 104 | ) { |
105 | 105 | //make sure this is ONLY when editing and the event id has been set. |
106 | - if ( ! empty( $id ) ) { |
|
107 | - $post = get_post( $id ); |
|
106 | + if ( ! empty($id)) { |
|
107 | + $post = get_post($id); |
|
108 | 108 | //if NOT event then let's get out. |
109 | - if ( $post->post_type !== 'espresso_events' ) { |
|
109 | + if ($post->post_type !== 'espresso_events') { |
|
110 | 110 | return $permalink_string; |
111 | 111 | } |
112 | 112 | $permalink_string .= $this->embedButtonHtml( |
113 | - array( $this->slug => $id ), |
|
113 | + array($this->slug => $id), |
|
114 | 114 | 'button-small' |
115 | 115 | ); |
116 | 116 | } |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param string $action name of the WP do_action() to hook into |
126 | 126 | */ |
127 | - public function addActionIframeEmbedButton( $action ) |
|
127 | + public function addActionIframeEmbedButton($action) |
|
128 | 128 | { |
129 | 129 | // add button for iframe code to event editor. |
130 | 130 | add_action( |
131 | 131 | $action, |
132 | - array( $this, 'addActionIframeEmbedButtonCallback' ), |
|
132 | + array($this, 'addActionIframeEmbedButtonCallback'), |
|
133 | 133 | 10, 2 |
134 | 134 | ); |
135 | 135 | } |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | * @param bool $append if true, will add iframe embed button to end of content, |
154 | 154 | * else if false, will add to the beginning of the content |
155 | 155 | */ |
156 | - public function addFilterIframeEmbedButton( $filter, $append = true ) |
|
156 | + public function addFilterIframeEmbedButton($filter, $append = true) |
|
157 | 157 | { |
158 | 158 | $this->append_filterable_content = $append; |
159 | 159 | // add button for iframe code to event editor. |
160 | 160 | add_filter( |
161 | 161 | $filter, |
162 | - array( $this, 'addFilterIframeEmbedButtonCallback' ), |
|
162 | + array($this, 'addFilterIframeEmbedButtonCallback'), |
|
163 | 163 | 10 |
164 | 164 | ); |
165 | 165 | } |
@@ -170,17 +170,17 @@ discard block |
||
170 | 170 | * @param array|string $filterable_content |
171 | 171 | * @return array|string |
172 | 172 | */ |
173 | - public function addFilterIframeEmbedButtonCallback( $filterable_content ) |
|
173 | + public function addFilterIframeEmbedButtonCallback($filterable_content) |
|
174 | 174 | { |
175 | 175 | $embedButtonHtml = $this->embedButtonHtml(); |
176 | - if ( is_array( $filterable_content ) ) { |
|
176 | + if (is_array($filterable_content)) { |
|
177 | 177 | $filterable_content = $this->append_filterable_content |
178 | - ? $filterable_content + array( $this->route_name => $embedButtonHtml ) |
|
179 | - : array( $this->route_name => $embedButtonHtml ) + $filterable_content; |
|
178 | + ? $filterable_content + array($this->route_name => $embedButtonHtml) |
|
179 | + : array($this->route_name => $embedButtonHtml) + $filterable_content; |
|
180 | 180 | } else { |
181 | 181 | $filterable_content = $this->append_filterable_content |
182 | - ? $filterable_content . $embedButtonHtml |
|
183 | - : $embedButtonHtml . $filterable_content; |
|
182 | + ? $filterable_content.$embedButtonHtml |
|
183 | + : $embedButtonHtml.$filterable_content; |
|
184 | 184 | } |
185 | 185 | return $filterable_content; |
186 | 186 | } |
@@ -194,40 +194,40 @@ discard block |
||
194 | 194 | * @param string $button_class |
195 | 195 | * @return string |
196 | 196 | */ |
197 | - public function embedButtonHtml( $query_args = array(), $button_class = '' ) |
|
197 | + public function embedButtonHtml($query_args = array(), $button_class = '') |
|
198 | 198 | { |
199 | 199 | // incoming args will replace the defaults listed here in the second array (union preserves first array) |
200 | - $query_args = (array)$query_args + array( $this->route_name => 'iframe' ); |
|
201 | - $query_args = (array)apply_filters( |
|
200 | + $query_args = (array) $query_args + array($this->route_name => 'iframe'); |
|
201 | + $query_args = (array) apply_filters( |
|
202 | 202 | 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__embedButtonHtml__query_args', |
203 | 203 | $query_args |
204 | 204 | ); |
205 | 205 | // add this route to our localized vars |
206 | - $iframe_module_routes = isset( \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] ) |
|
207 | - ? \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] |
|
206 | + $iframe_module_routes = isset(\EE_Registry::$i18n_js_strings['iframe_module_routes']) |
|
207 | + ? \EE_Registry::$i18n_js_strings['iframe_module_routes'] |
|
208 | 208 | : array(); |
209 | - $iframe_module_routes[ $this->route_name ] = $this->route_name; |
|
210 | - \EE_Registry::$i18n_js_strings[ 'iframe_module_routes' ] = $iframe_module_routes; |
|
209 | + $iframe_module_routes[$this->route_name] = $this->route_name; |
|
210 | + \EE_Registry::$i18n_js_strings['iframe_module_routes'] = $iframe_module_routes; |
|
211 | 211 | $iframe_embed_html = \EEH_HTML::link( |
212 | 212 | '#', |
213 | - sprintf( esc_html__( 'Embed %1$s', 'event_espresso' ), $this->iframe_name ), |
|
213 | + sprintf(esc_html__('Embed %1$s', 'event_espresso'), $this->iframe_name), |
|
214 | 214 | sprintf( |
215 | 215 | esc_html__( |
216 | 216 | 'click here to generate code for embedding %1$s iframe into another site.', |
217 | 217 | 'event_espresso' |
218 | 218 | ), |
219 | - \EEH_Inflector::add_indefinite_article( $this->iframe_name ) |
|
219 | + \EEH_Inflector::add_indefinite_article($this->iframe_name) |
|
220 | 220 | ), |
221 | 221 | "{$this->route_name}-iframe-embed-trigger-js", |
222 | - 'iframe-embed-trigger-js button ' . $button_class, |
|
222 | + 'iframe-embed-trigger-js button '.$button_class, |
|
223 | 223 | '', |
224 | - ' data-iframe_embed_button="#' . $this->route_name . '-iframe-js" tabindex="-1"' |
|
224 | + ' data-iframe_embed_button="#'.$this->route_name.'-iframe-js" tabindex="-1"' |
|
225 | 225 | ); |
226 | - $iframe_embed_html .= \EEH_HTML::div( '', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | - 'display:none;' ); |
|
226 | + $iframe_embed_html .= \EEH_HTML::div('', "{$this->route_name}-iframe-js", 'iframe-embed-wrapper-js', |
|
227 | + 'display:none;'); |
|
228 | 228 | $iframe_embed_html .= esc_html( |
229 | 229 | \EEH_HTML::div( |
230 | - '<iframe src="' . add_query_arg( $query_args, site_url() ) . '" width="100%" height="100%"></iframe>', |
|
230 | + '<iframe src="'.add_query_arg($query_args, site_url()).'" width="100%" height="100%"></iframe>', |
|
231 | 231 | '', |
232 | 232 | '', |
233 | 233 | 'width:100%; height: 500px;' |
@@ -244,22 +244,22 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function embedButtonAssets() |
246 | 246 | { |
247 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_title' ] = esc_html__( |
|
247 | + \EE_Registry::$i18n_js_strings['iframe_embed_title'] = esc_html__( |
|
248 | 248 | 'copy and paste the following into any other site\'s content to display this event:', |
249 | 249 | 'event_espresso' |
250 | 250 | ); |
251 | - \EE_Registry::$i18n_js_strings[ 'iframe_embed_close_msg' ] = esc_html__( |
|
251 | + \EE_Registry::$i18n_js_strings['iframe_embed_close_msg'] = esc_html__( |
|
252 | 252 | 'click anywhere outside of this window to close it.', |
253 | 253 | 'event_espresso' |
254 | 254 | ); |
255 | 255 | wp_register_script( |
256 | 256 | 'iframe_embed_button', |
257 | - plugin_dir_url( __FILE__ ) . 'iframe-embed-button.js', |
|
258 | - array( 'ee-dialog' ), |
|
257 | + plugin_dir_url(__FILE__).'iframe-embed-button.js', |
|
258 | + array('ee-dialog'), |
|
259 | 259 | EVENT_ESPRESSO_VERSION, |
260 | 260 | true |
261 | 261 | ); |
262 | - wp_enqueue_script( 'iframe_embed_button' ); |
|
262 | + wp_enqueue_script('iframe_embed_button'); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | |
@@ -270,26 +270,26 @@ discard block |
||
270 | 270 | * @param array $embed_buttons |
271 | 271 | * @return string |
272 | 272 | */ |
273 | - public function addIframeEmbedButtonsSection( array $embed_buttons ) |
|
273 | + public function addIframeEmbedButtonsSection(array $embed_buttons) |
|
274 | 274 | { |
275 | - $embed_buttons = (array)apply_filters( |
|
275 | + $embed_buttons = (array) apply_filters( |
|
276 | 276 | 'FHEE__EventEspresso_core_libraries_iframe_display_IframeEmbedButton__addIframeEmbedButtonsSection__embed_buttons', |
277 | 277 | $embed_buttons |
278 | 278 | ); |
279 | - if ( empty($embed_buttons)) { |
|
279 | + if (empty($embed_buttons)) { |
|
280 | 280 | return ''; |
281 | 281 | } |
282 | 282 | // add button for iframe code to event editor. |
283 | - $html = \EEH_HTML::br( 2 ); |
|
284 | - $html .= \EEH_HTML::h3( esc_html__( 'iFrame Embed Code', 'event_espresso' ) ); |
|
283 | + $html = \EEH_HTML::br(2); |
|
284 | + $html .= \EEH_HTML::h3(esc_html__('iFrame Embed Code', 'event_espresso')); |
|
285 | 285 | $html .= \EEH_HTML::p( |
286 | 286 | esc_html__( |
287 | 287 | 'Click the following button(s) to generate iframe HTML that will allow you to embed your event content within the content of other websites.', |
288 | 288 | 'event_espresso' |
289 | 289 | ) |
290 | 290 | ); |
291 | - $html .= ' ' . implode( ' ', $embed_buttons ) . ' '; |
|
292 | - $html .= \EEH_HTML::br( 2 ); |
|
291 | + $html .= ' '.implode(' ', $embed_buttons).' '; |
|
292 | + $html .= \EEH_HTML::br(2); |
|
293 | 293 | return $html; |
294 | 294 | } |
295 | 295 |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | self::priority_low => __('low', 'event_espresso'), |
128 | 128 | ); |
129 | 129 | |
130 | - $this->_fields = array( |
|
130 | + $this->_fields = array( |
|
131 | 131 | 'Message' => array( |
132 | 132 | 'MSG_ID' => new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')), |
133 | 133 | 'MSG_token' => new EE_Plain_Text_Field('MSG_token', |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | ); |
358 | 358 | break; |
359 | 359 | default : |
360 | - $query_params[0]['AND**filter_by']['OR**filter_by_' . $request_key][$model_name . '.' . $request_key] = $request_value; |
|
360 | + $query_params[0]['AND**filter_by']['OR**filter_by_'.$request_key][$model_name.'.'.$request_key] = $request_value; |
|
361 | 361 | break; |
362 | 362 | } |
363 | 363 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | //prepend to the last element of $label_parts an "and". |
421 | 421 | if (count($label_parts) > 1) { |
422 | 422 | $label_parts_index_to_prepend = count($label_parts) - 1; |
423 | - $label_parts[$label_parts_index_to_prepend] = 'and' . $label_parts[$label_parts_index_to_prepend]; |
|
423 | + $label_parts[$label_parts_index_to_prepend] = 'and'.$label_parts[$label_parts_index_to_prepend]; |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | $pretty_label .= sprintf( |
@@ -541,13 +541,13 @@ discard block |
||
541 | 541 | ) |
542 | 542 | ); |
543 | 543 | |
544 | - if(! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) { |
|
544 | + if ( ! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) { |
|
545 | 545 | global $wpdb; |
546 | 546 | $number_deleted = $wpdb->query(' |
547 | 547 | DELETE |
548 | - FROM ' . $this->table() . ' |
|
548 | + FROM ' . $this->table().' |
|
549 | 549 | WHERE |
550 | - MSG_ID IN (' . implode(",", $message_ids_to_delete) . ') |
|
550 | + MSG_ID IN (' . implode(",", $message_ids_to_delete).') |
|
551 | 551 | '); |
552 | 552 | } |
553 | 553 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -12,556 +12,556 @@ discard block |
||
12 | 12 | class EEM_Message extends EEM_Base implements EEI_Query_Filter |
13 | 13 | { |
14 | 14 | |
15 | - // private instance of the Message object |
|
16 | - protected static $_instance = null; |
|
15 | + // private instance of the Message object |
|
16 | + protected static $_instance = null; |
|
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * This priority indicates a message should be generated and sent ASAP |
|
21 | - * |
|
22 | - * @type int |
|
23 | - */ |
|
24 | - const priority_high = 10; |
|
19 | + /** |
|
20 | + * This priority indicates a message should be generated and sent ASAP |
|
21 | + * |
|
22 | + * @type int |
|
23 | + */ |
|
24 | + const priority_high = 10; |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * This priority indicates a message should be generated ASAP and queued for sending. |
|
29 | - * |
|
30 | - * @type |
|
31 | - */ |
|
32 | - const priority_medium = 20; |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * This priority indicates a message should be queued for generating. |
|
37 | - * |
|
38 | - * @type int |
|
39 | - */ |
|
40 | - const priority_low = 30; |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * indicates this message was sent at the time modified |
|
45 | - */ |
|
46 | - const status_sent = 'MSN'; |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * indicates this message is waiting to be sent |
|
51 | - */ |
|
52 | - const status_idle = 'MID'; |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * indicates an attempt was a made to send this message |
|
57 | - * at the scheduled time, but it failed at the time modified. This differs from MDO status in that it will ALWAYS |
|
58 | - * appear to the end user. |
|
59 | - */ |
|
60 | - const status_failed = 'MFL'; |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * indicates the message has been flagged for resending (at the time modified). |
|
65 | - */ |
|
66 | - const status_resend = 'MRS'; |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * indicates the message has been flagged for generation but has not been generated yet. Messages always start as |
|
71 | - * this status when added to the queue. |
|
72 | - */ |
|
73 | - const status_incomplete = 'MIC'; |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * Indicates everything was generated fine for the message, however, the messenger was unable to send. |
|
78 | - * This status means that its possible to retry sending the message. |
|
79 | - */ |
|
80 | - const status_retry = 'MRT'; |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * This is used for more informational messages that may not indicate anything is broken but still cannot be |
|
85 | - * generated or sent correctly. An example of a message that would get flagged this way would be when a not |
|
86 | - * approved message was queued for generation, but at time of generation, the attached registration(s) are |
|
87 | - * approved. So the message queued for generation is no longer valid. Messages for this status will only persist |
|
88 | - * in the db and be viewable in the message activity list table when the messages system is in debug mode. |
|
89 | - * |
|
90 | - * @see EEM_Message::debug() |
|
91 | - */ |
|
92 | - const status_debug_only = 'MDO'; |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * This status is given to messages it is processed by the messenger send method. |
|
97 | - * Messages with this status should rarely be seen in the Message List table, but if they are, that's usually |
|
98 | - * indicative of a PHP timeout or memory limit issue. |
|
99 | - */ |
|
100 | - const status_messenger_executing = 'MEX'; |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * Private constructor to prevent direct creation. |
|
105 | - * |
|
106 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and |
|
107 | - * any incoming timezone data that gets saved). Note this just sends the timezone info to |
|
108 | - * the date time model field objects. Default is null (and will be assumed using the set |
|
109 | - * timezone in the 'timezone_string' wp option) |
|
110 | - * @return EEM_Message |
|
111 | - */ |
|
112 | - protected function __construct($timezone = null) |
|
113 | - { |
|
114 | - $this->singular_item = __('Message', 'event_espresso'); |
|
115 | - $this->plural_item = __('Messages', 'event_espresso'); |
|
116 | - |
|
117 | - //used for token generator |
|
118 | - EE_Registry::instance()->load_helper('URL'); |
|
119 | - |
|
120 | - $this->_tables = array( |
|
121 | - 'Message' => new EE_Primary_Table('esp_message', 'MSG_ID'), |
|
122 | - ); |
|
123 | - |
|
124 | - $allowed_priority = array( |
|
125 | - self::priority_high => __('high', 'event_espresso'), |
|
126 | - self::priority_medium => __('medium', 'event_espresso'), |
|
127 | - self::priority_low => __('low', 'event_espresso'), |
|
128 | - ); |
|
129 | - |
|
130 | - $this->_fields = array( |
|
131 | - 'Message' => array( |
|
132 | - 'MSG_ID' => new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')), |
|
133 | - 'MSG_token' => new EE_Plain_Text_Field('MSG_token', |
|
134 | - __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', |
|
135 | - 'event_espresso'), false, EEH_URL::generate_unique_token()), |
|
136 | - 'GRP_ID' => new EE_Foreign_Key_Int_Field('GRP_ID', |
|
137 | - __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), true, 0, |
|
138 | - 'Message_Template_Group'), |
|
139 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', |
|
140 | - __('Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', |
|
141 | - 'event_espresso'), true, 0, 'Transaction'), |
|
142 | - 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', |
|
143 | - __('Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', |
|
144 | - 'event_espresso'), false, 'email'), |
|
145 | - 'MSG_message_type' => new EE_Plain_Text_Field('MSG_message_type', |
|
146 | - __('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'), |
|
147 | - false, 'receipt'), |
|
148 | - 'MSG_context' => new EE_Plain_Text_Field('MSG_context', __('Context', 'event_espresso'), false), |
|
149 | - 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field('MSG_recipient_ID', |
|
150 | - __('Recipient ID', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
151 | - 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field('MSG_recipient_type', |
|
152 | - __('Recipient Type', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
153 | - 'MSG_content' => new EE_Maybe_Serialized_Text_Field('MSG_content', |
|
154 | - __('Content', 'event_espresso'), true, ''), |
|
155 | - 'MSG_to' => new EE_Maybe_Serialized_Text_Field('MSG_to', __('Address To', 'event_espresso'), |
|
156 | - true), |
|
157 | - 'MSG_from' => new EE_Maybe_Serialized_Text_Field('MSG_from', |
|
158 | - __('Address From', 'event_espresso'), true), |
|
159 | - 'MSG_subject' => new EE_Maybe_Serialized_Text_Field('MSG_subject', |
|
160 | - __('Subject', 'event_espresso'), true, ''), |
|
161 | - 'MSG_priority' => new EE_Enum_Integer_Field('MSG_priority', __('Priority', 'event_espresso'), |
|
162 | - false, self::priority_low, $allowed_priority), |
|
163 | - 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status', 'event_espresso'), false, |
|
164 | - self::status_incomplete, 'Status'), |
|
165 | - 'MSG_created' => new EE_Datetime_Field('MSG_created', __('Created', 'event_espresso'), false, |
|
166 | - EE_Datetime_Field::now), |
|
167 | - 'MSG_modified' => new EE_Datetime_Field('MSG_modified', __('Modified', 'event_espresso'), true, |
|
168 | - EE_Datetime_Field::now), |
|
169 | - ), |
|
170 | - ); |
|
171 | - $this->_model_relations = array( |
|
172 | - 'Attendee' => new EE_Belongs_To_Any_Relation(), |
|
173 | - 'Registration' => new EE_Belongs_To_Any_Relation(), |
|
174 | - 'WP_User' => new EE_Belongs_To_Any_Relation(), |
|
175 | - 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
|
176 | - 'Transaction' => new EE_Belongs_To_Relation(), |
|
177 | - ); |
|
178 | - parent::__construct($timezone); |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * @return \EE_Message |
|
184 | - */ |
|
185 | - public function create_default_object() |
|
186 | - { |
|
187 | - /** @type EE_Message $message */ |
|
188 | - $message = parent::create_default_object(); |
|
189 | - if ($message instanceof EE_Message) { |
|
190 | - return EE_Message_Factory::set_messenger_and_message_type($message); |
|
191 | - } |
|
192 | - return null; |
|
193 | - } |
|
194 | - |
|
195 | - |
|
196 | - /** |
|
197 | - * @param mixed $cols_n_values |
|
198 | - * @return \EE_Message |
|
199 | - */ |
|
200 | - public function instantiate_class_from_array_or_object($cols_n_values) |
|
201 | - { |
|
202 | - /** @type EE_Message $message */ |
|
203 | - $message = parent::instantiate_class_from_array_or_object($cols_n_values); |
|
204 | - if ($message instanceof EE_Message) { |
|
205 | - return EE_Message_Factory::set_messenger_and_message_type($message); |
|
206 | - } |
|
207 | - return null; |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * Returns whether or not a message of that type was sent for a given attendee. |
|
213 | - * |
|
214 | - * @param EE_Attendee|int $attendee |
|
215 | - * @param string $message_type the message type slug |
|
216 | - * @return boolean |
|
217 | - */ |
|
218 | - public function message_sent_for_attendee($attendee, $message_type) |
|
219 | - { |
|
220 | - $attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee); |
|
221 | - return $this->exists(array( |
|
222 | - array( |
|
223 | - 'Attendee.ATT_ID' => $attendee_ID, |
|
224 | - 'MSG_message_type' => $message_type, |
|
225 | - 'STS_ID' => array('IN', $this->stati_indicating_sent()), |
|
226 | - ), |
|
227 | - )); |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * Returns whether or not a message of that type was sent for a given registration |
|
233 | - * |
|
234 | - * @param EE_Registration|int $registration |
|
235 | - * @param string $message_type the message type slug |
|
236 | - * @return boolean |
|
237 | - */ |
|
238 | - public function message_sent_for_registration($registration, $message_type) |
|
239 | - { |
|
240 | - $registrationID = EEM_Registration::instance()->ensure_is_ID($registration); |
|
241 | - return $this->exists(array( |
|
242 | - array( |
|
243 | - 'Registration.REG_ID' => $registrationID, |
|
244 | - 'MSG_message_type' => $message_type, |
|
245 | - 'STS_ID' => array('IN', $this->stati_indicating_sent()), |
|
246 | - ), |
|
247 | - )); |
|
248 | - } |
|
249 | - |
|
250 | - |
|
251 | - /** |
|
252 | - * This retrieves an EE_Message object from the db matching the given token string. |
|
253 | - * |
|
254 | - * @param string $token |
|
255 | - * @return EE_Message |
|
256 | - */ |
|
257 | - public function get_one_by_token($token) |
|
258 | - { |
|
259 | - return $this->get_one(array( |
|
260 | - array( |
|
261 | - 'MSG_token' => $token, |
|
262 | - ), |
|
263 | - )); |
|
264 | - } |
|
265 | - |
|
266 | - |
|
267 | - /** |
|
268 | - * Returns stati that indicate the message HAS been sent |
|
269 | - * |
|
270 | - * @return array of strings for possible stati |
|
271 | - */ |
|
272 | - public function stati_indicating_sent() |
|
273 | - { |
|
274 | - return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent)); |
|
275 | - } |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * Returns stati that indicate the message is waiting to be sent. |
|
280 | - * |
|
281 | - * @return array of strings for possible stati. |
|
282 | - */ |
|
283 | - public function stati_indicating_to_send() |
|
284 | - { |
|
285 | - return apply_filters('FHEE__EEM_Message__stati_indicating_to_send', |
|
286 | - array(self::status_idle, self::status_resend)); |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * Returns stati that indicate the message has failed sending |
|
292 | - * |
|
293 | - * @return array array of strings for possible stati. |
|
294 | - */ |
|
295 | - public function stati_indicating_failed_sending() |
|
296 | - { |
|
297 | - $failed_stati = array( |
|
298 | - self::status_failed, |
|
299 | - self::status_retry, |
|
300 | - self::status_messenger_executing, |
|
301 | - ); |
|
302 | - //if WP_DEBUG is set, then let's include debug_only fails |
|
303 | - if (WP_DEBUG) { |
|
304 | - $failed_stati[] = self::status_debug_only; |
|
305 | - } |
|
306 | - return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati); |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * Returns filterable array of all EEM_Message statuses. |
|
312 | - * |
|
313 | - * @return array |
|
314 | - */ |
|
315 | - public function all_statuses() |
|
316 | - { |
|
317 | - return apply_filters( |
|
318 | - 'FHEE__EEM_Message__all_statuses', |
|
319 | - array( |
|
320 | - EEM_Message::status_sent, |
|
321 | - EEM_Message::status_incomplete, |
|
322 | - EEM_Message::status_idle, |
|
323 | - EEM_Message::status_resend, |
|
324 | - EEM_Message::status_retry, |
|
325 | - EEM_Message::status_failed, |
|
326 | - EEM_Message::status_messenger_executing, |
|
327 | - EEM_Message::status_debug_only, |
|
328 | - ) |
|
329 | - ); |
|
330 | - } |
|
331 | - |
|
332 | - /** |
|
333 | - * Detects any specific query variables in the request and uses those to setup appropriate |
|
334 | - * filter for any queries. |
|
335 | - * |
|
336 | - * @return array |
|
337 | - */ |
|
338 | - public function filter_by_query_params() |
|
339 | - { |
|
340 | - // expected possible query_vars, the key in this array matches an expected key in the request, |
|
341 | - // the value, matches the corresponding EEM_Base child reference. |
|
342 | - $expected_vars = $this->_expected_vars_for_query_inject(); |
|
343 | - $query_params[0] = array(); |
|
344 | - foreach ($expected_vars as $request_key => $model_name) { |
|
345 | - $request_value = EE_Registry::instance()->REQ->get($request_key); |
|
346 | - if ($request_value) { |
|
347 | - //special case |
|
348 | - switch ($request_key) { |
|
349 | - case '_REG_ID' : |
|
350 | - $query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array( |
|
351 | - 'Transaction.Registration.REG_ID' => $request_value, |
|
352 | - ); |
|
353 | - break; |
|
354 | - case 'EVT_ID' : |
|
355 | - $query_params[0]['AND**filter_by']['OR**filter_by_EVT_ID'] = array( |
|
356 | - 'Transaction.Registration.EVT_ID' => $request_value, |
|
357 | - ); |
|
358 | - break; |
|
359 | - default : |
|
360 | - $query_params[0]['AND**filter_by']['OR**filter_by_' . $request_key][$model_name . '.' . $request_key] = $request_value; |
|
361 | - break; |
|
362 | - } |
|
363 | - } |
|
364 | - } |
|
365 | - return $query_params; |
|
366 | - } |
|
367 | - |
|
368 | - |
|
369 | - /** |
|
370 | - * @return string |
|
371 | - */ |
|
372 | - public function get_pretty_label_for_results() |
|
373 | - { |
|
374 | - $expected_vars = $this->_expected_vars_for_query_inject(); |
|
375 | - $pretty_label = ''; |
|
376 | - $label_parts = array(); |
|
377 | - foreach ($expected_vars as $request_key => $model_name) { |
|
378 | - $model = EE_Registry::instance()->load_model($model_name); |
|
379 | - if ($model_field_value = EE_Registry::instance()->REQ->get($request_key)) { |
|
380 | - switch ($request_key) { |
|
381 | - case '_REG_ID' : |
|
382 | - $label_parts[] = sprintf( |
|
383 | - esc_html__('Registration with the ID: %s', 'event_espresso'), |
|
384 | - $model_field_value |
|
385 | - ); |
|
386 | - break; |
|
387 | - case 'ATT_ID' : |
|
388 | - /** @var EE_Attendee $attendee */ |
|
389 | - $attendee = $model->get_one_by_ID($model_field_value); |
|
390 | - $label_parts[] = $attendee instanceof EE_Attendee |
|
391 | - ? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name()) |
|
392 | - : sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value); |
|
393 | - break; |
|
394 | - case 'ID' : |
|
395 | - /** @var EE_WP_User $wpUser */ |
|
396 | - $wpUser = $model->get_one_by_ID($model_field_value); |
|
397 | - $label_parts[] = $wpUser instanceof EE_WP_User |
|
398 | - ? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name()) |
|
399 | - : sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value); |
|
400 | - break; |
|
401 | - case 'TXN_ID' : |
|
402 | - $label_parts[] = sprintf( |
|
403 | - esc_html__('Transaction with the ID: %s', 'event_espresso'), |
|
404 | - $model_field_value |
|
405 | - ); |
|
406 | - break; |
|
407 | - case 'EVT_ID' : |
|
408 | - /** @var EE_Event $Event */ |
|
409 | - $Event = $model->get_one_by_ID($model_field_value); |
|
410 | - $label_parts[] = $Event instanceof EE_Event |
|
411 | - ? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name()) |
|
412 | - : sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value); |
|
413 | - break; |
|
414 | - } |
|
415 | - } |
|
416 | - } |
|
417 | - |
|
418 | - if ($label_parts) { |
|
419 | - |
|
420 | - //prepend to the last element of $label_parts an "and". |
|
421 | - if (count($label_parts) > 1) { |
|
422 | - $label_parts_index_to_prepend = count($label_parts) - 1; |
|
423 | - $label_parts[$label_parts_index_to_prepend] = 'and' . $label_parts[$label_parts_index_to_prepend]; |
|
424 | - } |
|
425 | - |
|
426 | - $pretty_label .= sprintf( |
|
427 | - esc_html_x( |
|
428 | - 'Showing messages for %s', |
|
429 | - 'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.', |
|
430 | - 'event_espresso' |
|
431 | - ), |
|
432 | - implode(', ', $label_parts) |
|
433 | - ); |
|
434 | - } |
|
435 | - return $pretty_label; |
|
436 | - } |
|
437 | - |
|
438 | - |
|
439 | - /** |
|
440 | - * This returns the array of expected variables for the EEI_Query_Filter methods being implemented |
|
441 | - * The array is in the format: |
|
442 | - * array( |
|
443 | - * {$field_name} => {$model_name} |
|
444 | - * ); |
|
445 | - * |
|
446 | - * @since 4.9.0 |
|
447 | - * @return array |
|
448 | - */ |
|
449 | - protected function _expected_vars_for_query_inject() |
|
450 | - { |
|
451 | - return array( |
|
452 | - '_REG_ID' => 'Registration', |
|
453 | - 'ATT_ID' => 'Attendee', |
|
454 | - 'ID' => 'WP_User', |
|
455 | - 'TXN_ID' => 'Transaction', |
|
456 | - 'EVT_ID' => 'Event', |
|
457 | - ); |
|
458 | - } |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * This returns whether EEM_Message is in debug mode or not. |
|
463 | - * Currently "debug mode" is used to control the handling of the EEM_Message::debug_only status when |
|
464 | - * generating/sending messages. Debug mode can be set by either: |
|
465 | - * 1. Sending in a value for the $set_debug argument |
|
466 | - * 2. Defining `EE_DEBUG_MESSAGES` constant in wp-config.php |
|
467 | - * 3. Overriding the above via the provided filter. |
|
468 | - * |
|
469 | - * @param bool|null $set_debug If provided, then the debug mode will be set internally until reset via the |
|
470 | - * provided boolean. When no argument is provided (default null) then the debug |
|
471 | - * mode will be returned. |
|
472 | - * @return bool true means Messages is in debug mode. false means messages system is not in debug mode. |
|
473 | - */ |
|
474 | - public static function debug($set_debug = null) |
|
475 | - { |
|
476 | - static $is_debugging = null; |
|
477 | - |
|
478 | - //initialize (use constant if set). |
|
479 | - if (is_null($set_debug) && is_null($is_debugging)) { |
|
480 | - $is_debugging = defined('EE_DEBUG_MESSAGES') && EE_DEBUG_MESSAGES; |
|
481 | - } |
|
482 | - |
|
483 | - if ( ! is_null($set_debug)) { |
|
484 | - $is_debugging = filter_var($set_debug, FILTER_VALIDATE_BOOLEAN); |
|
485 | - } |
|
486 | - |
|
487 | - //return filtered value |
|
488 | - return apply_filters('FHEE__EEM_Message__debug', $is_debugging); |
|
489 | - } |
|
490 | - |
|
491 | - |
|
492 | - /** |
|
493 | - * Deletes old messages meeting certain criteria for removal from the database. |
|
494 | - * By default, this will delete messages that: |
|
495 | - * - are older than the value of the delete_threshold in months. |
|
496 | - * - have a STS_ID other than EEM_Message::status_idle |
|
497 | - * |
|
498 | - * @param int $delete_threshold This integer will be used to set the boundary for what messages are deleted in months. |
|
499 | - * @return bool|false|int Either the number of records affected or false if there was an error (you can call |
|
500 | - * $wpdb->last_error to find out what the error was. |
|
501 | - */ |
|
502 | - public function delete_old_messages($delete_threshold = 6) |
|
503 | - { |
|
504 | - $number_deleted = 0; |
|
505 | - /** |
|
506 | - * Allows code to change the boundary for what messages are kept. |
|
507 | - * Uses the value of the `delete_threshold` variable by default. |
|
508 | - * |
|
509 | - * @param int $seconds seconds that will be subtracted from the timestamp for now. |
|
510 | - * @return int |
|
511 | - */ |
|
512 | - $time_to_leave_alone = absint( |
|
513 | - apply_filters( |
|
514 | - 'FHEE__EEM_Message__delete_old_messages__time_to_leave_alone', |
|
515 | - ((int) $delete_threshold) * MONTH_IN_SECONDS |
|
516 | - ) |
|
517 | - ); |
|
518 | - |
|
519 | - |
|
520 | - /** |
|
521 | - * Allows code to change what message stati are ignored when deleting. |
|
522 | - * Defaults to only ignore EEM_Message::status_idle messages. |
|
523 | - * |
|
524 | - * @param string $message_stati_to_keep An array of message statuses that will be ignored when deleting. |
|
525 | - */ |
|
526 | - $message_stati_to_keep = (array) apply_filters( |
|
527 | - 'FHEE__EEM_Message__delete_old_messages__message_stati_to_keep', |
|
528 | - array( |
|
529 | - EEM_Message::status_idle |
|
530 | - ) |
|
531 | - ); |
|
532 | - |
|
533 | - //first get all the ids of messages being deleted |
|
534 | - $message_ids_to_delete = EEM_Message::instance()->get_col( |
|
535 | - array( |
|
536 | - 0 => array( |
|
537 | - 'STS_ID' => array('NOT_IN', $message_stati_to_keep), |
|
538 | - 'MSG_modified' => array('<', time() - $time_to_leave_alone) |
|
539 | - ) |
|
540 | - ) |
|
541 | - ); |
|
542 | - |
|
543 | - if(! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) { |
|
544 | - global $wpdb; |
|
545 | - $number_deleted = $wpdb->query(' |
|
27 | + /** |
|
28 | + * This priority indicates a message should be generated ASAP and queued for sending. |
|
29 | + * |
|
30 | + * @type |
|
31 | + */ |
|
32 | + const priority_medium = 20; |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * This priority indicates a message should be queued for generating. |
|
37 | + * |
|
38 | + * @type int |
|
39 | + */ |
|
40 | + const priority_low = 30; |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * indicates this message was sent at the time modified |
|
45 | + */ |
|
46 | + const status_sent = 'MSN'; |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * indicates this message is waiting to be sent |
|
51 | + */ |
|
52 | + const status_idle = 'MID'; |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * indicates an attempt was a made to send this message |
|
57 | + * at the scheduled time, but it failed at the time modified. This differs from MDO status in that it will ALWAYS |
|
58 | + * appear to the end user. |
|
59 | + */ |
|
60 | + const status_failed = 'MFL'; |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * indicates the message has been flagged for resending (at the time modified). |
|
65 | + */ |
|
66 | + const status_resend = 'MRS'; |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * indicates the message has been flagged for generation but has not been generated yet. Messages always start as |
|
71 | + * this status when added to the queue. |
|
72 | + */ |
|
73 | + const status_incomplete = 'MIC'; |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * Indicates everything was generated fine for the message, however, the messenger was unable to send. |
|
78 | + * This status means that its possible to retry sending the message. |
|
79 | + */ |
|
80 | + const status_retry = 'MRT'; |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * This is used for more informational messages that may not indicate anything is broken but still cannot be |
|
85 | + * generated or sent correctly. An example of a message that would get flagged this way would be when a not |
|
86 | + * approved message was queued for generation, but at time of generation, the attached registration(s) are |
|
87 | + * approved. So the message queued for generation is no longer valid. Messages for this status will only persist |
|
88 | + * in the db and be viewable in the message activity list table when the messages system is in debug mode. |
|
89 | + * |
|
90 | + * @see EEM_Message::debug() |
|
91 | + */ |
|
92 | + const status_debug_only = 'MDO'; |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * This status is given to messages it is processed by the messenger send method. |
|
97 | + * Messages with this status should rarely be seen in the Message List table, but if they are, that's usually |
|
98 | + * indicative of a PHP timeout or memory limit issue. |
|
99 | + */ |
|
100 | + const status_messenger_executing = 'MEX'; |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * Private constructor to prevent direct creation. |
|
105 | + * |
|
106 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and |
|
107 | + * any incoming timezone data that gets saved). Note this just sends the timezone info to |
|
108 | + * the date time model field objects. Default is null (and will be assumed using the set |
|
109 | + * timezone in the 'timezone_string' wp option) |
|
110 | + * @return EEM_Message |
|
111 | + */ |
|
112 | + protected function __construct($timezone = null) |
|
113 | + { |
|
114 | + $this->singular_item = __('Message', 'event_espresso'); |
|
115 | + $this->plural_item = __('Messages', 'event_espresso'); |
|
116 | + |
|
117 | + //used for token generator |
|
118 | + EE_Registry::instance()->load_helper('URL'); |
|
119 | + |
|
120 | + $this->_tables = array( |
|
121 | + 'Message' => new EE_Primary_Table('esp_message', 'MSG_ID'), |
|
122 | + ); |
|
123 | + |
|
124 | + $allowed_priority = array( |
|
125 | + self::priority_high => __('high', 'event_espresso'), |
|
126 | + self::priority_medium => __('medium', 'event_espresso'), |
|
127 | + self::priority_low => __('low', 'event_espresso'), |
|
128 | + ); |
|
129 | + |
|
130 | + $this->_fields = array( |
|
131 | + 'Message' => array( |
|
132 | + 'MSG_ID' => new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')), |
|
133 | + 'MSG_token' => new EE_Plain_Text_Field('MSG_token', |
|
134 | + __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', |
|
135 | + 'event_espresso'), false, EEH_URL::generate_unique_token()), |
|
136 | + 'GRP_ID' => new EE_Foreign_Key_Int_Field('GRP_ID', |
|
137 | + __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), true, 0, |
|
138 | + 'Message_Template_Group'), |
|
139 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', |
|
140 | + __('Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', |
|
141 | + 'event_espresso'), true, 0, 'Transaction'), |
|
142 | + 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', |
|
143 | + __('Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', |
|
144 | + 'event_espresso'), false, 'email'), |
|
145 | + 'MSG_message_type' => new EE_Plain_Text_Field('MSG_message_type', |
|
146 | + __('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'), |
|
147 | + false, 'receipt'), |
|
148 | + 'MSG_context' => new EE_Plain_Text_Field('MSG_context', __('Context', 'event_espresso'), false), |
|
149 | + 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field('MSG_recipient_ID', |
|
150 | + __('Recipient ID', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
151 | + 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field('MSG_recipient_type', |
|
152 | + __('Recipient Type', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
153 | + 'MSG_content' => new EE_Maybe_Serialized_Text_Field('MSG_content', |
|
154 | + __('Content', 'event_espresso'), true, ''), |
|
155 | + 'MSG_to' => new EE_Maybe_Serialized_Text_Field('MSG_to', __('Address To', 'event_espresso'), |
|
156 | + true), |
|
157 | + 'MSG_from' => new EE_Maybe_Serialized_Text_Field('MSG_from', |
|
158 | + __('Address From', 'event_espresso'), true), |
|
159 | + 'MSG_subject' => new EE_Maybe_Serialized_Text_Field('MSG_subject', |
|
160 | + __('Subject', 'event_espresso'), true, ''), |
|
161 | + 'MSG_priority' => new EE_Enum_Integer_Field('MSG_priority', __('Priority', 'event_espresso'), |
|
162 | + false, self::priority_low, $allowed_priority), |
|
163 | + 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status', 'event_espresso'), false, |
|
164 | + self::status_incomplete, 'Status'), |
|
165 | + 'MSG_created' => new EE_Datetime_Field('MSG_created', __('Created', 'event_espresso'), false, |
|
166 | + EE_Datetime_Field::now), |
|
167 | + 'MSG_modified' => new EE_Datetime_Field('MSG_modified', __('Modified', 'event_espresso'), true, |
|
168 | + EE_Datetime_Field::now), |
|
169 | + ), |
|
170 | + ); |
|
171 | + $this->_model_relations = array( |
|
172 | + 'Attendee' => new EE_Belongs_To_Any_Relation(), |
|
173 | + 'Registration' => new EE_Belongs_To_Any_Relation(), |
|
174 | + 'WP_User' => new EE_Belongs_To_Any_Relation(), |
|
175 | + 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
|
176 | + 'Transaction' => new EE_Belongs_To_Relation(), |
|
177 | + ); |
|
178 | + parent::__construct($timezone); |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * @return \EE_Message |
|
184 | + */ |
|
185 | + public function create_default_object() |
|
186 | + { |
|
187 | + /** @type EE_Message $message */ |
|
188 | + $message = parent::create_default_object(); |
|
189 | + if ($message instanceof EE_Message) { |
|
190 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
191 | + } |
|
192 | + return null; |
|
193 | + } |
|
194 | + |
|
195 | + |
|
196 | + /** |
|
197 | + * @param mixed $cols_n_values |
|
198 | + * @return \EE_Message |
|
199 | + */ |
|
200 | + public function instantiate_class_from_array_or_object($cols_n_values) |
|
201 | + { |
|
202 | + /** @type EE_Message $message */ |
|
203 | + $message = parent::instantiate_class_from_array_or_object($cols_n_values); |
|
204 | + if ($message instanceof EE_Message) { |
|
205 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
206 | + } |
|
207 | + return null; |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * Returns whether or not a message of that type was sent for a given attendee. |
|
213 | + * |
|
214 | + * @param EE_Attendee|int $attendee |
|
215 | + * @param string $message_type the message type slug |
|
216 | + * @return boolean |
|
217 | + */ |
|
218 | + public function message_sent_for_attendee($attendee, $message_type) |
|
219 | + { |
|
220 | + $attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee); |
|
221 | + return $this->exists(array( |
|
222 | + array( |
|
223 | + 'Attendee.ATT_ID' => $attendee_ID, |
|
224 | + 'MSG_message_type' => $message_type, |
|
225 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()), |
|
226 | + ), |
|
227 | + )); |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * Returns whether or not a message of that type was sent for a given registration |
|
233 | + * |
|
234 | + * @param EE_Registration|int $registration |
|
235 | + * @param string $message_type the message type slug |
|
236 | + * @return boolean |
|
237 | + */ |
|
238 | + public function message_sent_for_registration($registration, $message_type) |
|
239 | + { |
|
240 | + $registrationID = EEM_Registration::instance()->ensure_is_ID($registration); |
|
241 | + return $this->exists(array( |
|
242 | + array( |
|
243 | + 'Registration.REG_ID' => $registrationID, |
|
244 | + 'MSG_message_type' => $message_type, |
|
245 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()), |
|
246 | + ), |
|
247 | + )); |
|
248 | + } |
|
249 | + |
|
250 | + |
|
251 | + /** |
|
252 | + * This retrieves an EE_Message object from the db matching the given token string. |
|
253 | + * |
|
254 | + * @param string $token |
|
255 | + * @return EE_Message |
|
256 | + */ |
|
257 | + public function get_one_by_token($token) |
|
258 | + { |
|
259 | + return $this->get_one(array( |
|
260 | + array( |
|
261 | + 'MSG_token' => $token, |
|
262 | + ), |
|
263 | + )); |
|
264 | + } |
|
265 | + |
|
266 | + |
|
267 | + /** |
|
268 | + * Returns stati that indicate the message HAS been sent |
|
269 | + * |
|
270 | + * @return array of strings for possible stati |
|
271 | + */ |
|
272 | + public function stati_indicating_sent() |
|
273 | + { |
|
274 | + return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent)); |
|
275 | + } |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * Returns stati that indicate the message is waiting to be sent. |
|
280 | + * |
|
281 | + * @return array of strings for possible stati. |
|
282 | + */ |
|
283 | + public function stati_indicating_to_send() |
|
284 | + { |
|
285 | + return apply_filters('FHEE__EEM_Message__stati_indicating_to_send', |
|
286 | + array(self::status_idle, self::status_resend)); |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * Returns stati that indicate the message has failed sending |
|
292 | + * |
|
293 | + * @return array array of strings for possible stati. |
|
294 | + */ |
|
295 | + public function stati_indicating_failed_sending() |
|
296 | + { |
|
297 | + $failed_stati = array( |
|
298 | + self::status_failed, |
|
299 | + self::status_retry, |
|
300 | + self::status_messenger_executing, |
|
301 | + ); |
|
302 | + //if WP_DEBUG is set, then let's include debug_only fails |
|
303 | + if (WP_DEBUG) { |
|
304 | + $failed_stati[] = self::status_debug_only; |
|
305 | + } |
|
306 | + return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati); |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * Returns filterable array of all EEM_Message statuses. |
|
312 | + * |
|
313 | + * @return array |
|
314 | + */ |
|
315 | + public function all_statuses() |
|
316 | + { |
|
317 | + return apply_filters( |
|
318 | + 'FHEE__EEM_Message__all_statuses', |
|
319 | + array( |
|
320 | + EEM_Message::status_sent, |
|
321 | + EEM_Message::status_incomplete, |
|
322 | + EEM_Message::status_idle, |
|
323 | + EEM_Message::status_resend, |
|
324 | + EEM_Message::status_retry, |
|
325 | + EEM_Message::status_failed, |
|
326 | + EEM_Message::status_messenger_executing, |
|
327 | + EEM_Message::status_debug_only, |
|
328 | + ) |
|
329 | + ); |
|
330 | + } |
|
331 | + |
|
332 | + /** |
|
333 | + * Detects any specific query variables in the request and uses those to setup appropriate |
|
334 | + * filter for any queries. |
|
335 | + * |
|
336 | + * @return array |
|
337 | + */ |
|
338 | + public function filter_by_query_params() |
|
339 | + { |
|
340 | + // expected possible query_vars, the key in this array matches an expected key in the request, |
|
341 | + // the value, matches the corresponding EEM_Base child reference. |
|
342 | + $expected_vars = $this->_expected_vars_for_query_inject(); |
|
343 | + $query_params[0] = array(); |
|
344 | + foreach ($expected_vars as $request_key => $model_name) { |
|
345 | + $request_value = EE_Registry::instance()->REQ->get($request_key); |
|
346 | + if ($request_value) { |
|
347 | + //special case |
|
348 | + switch ($request_key) { |
|
349 | + case '_REG_ID' : |
|
350 | + $query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array( |
|
351 | + 'Transaction.Registration.REG_ID' => $request_value, |
|
352 | + ); |
|
353 | + break; |
|
354 | + case 'EVT_ID' : |
|
355 | + $query_params[0]['AND**filter_by']['OR**filter_by_EVT_ID'] = array( |
|
356 | + 'Transaction.Registration.EVT_ID' => $request_value, |
|
357 | + ); |
|
358 | + break; |
|
359 | + default : |
|
360 | + $query_params[0]['AND**filter_by']['OR**filter_by_' . $request_key][$model_name . '.' . $request_key] = $request_value; |
|
361 | + break; |
|
362 | + } |
|
363 | + } |
|
364 | + } |
|
365 | + return $query_params; |
|
366 | + } |
|
367 | + |
|
368 | + |
|
369 | + /** |
|
370 | + * @return string |
|
371 | + */ |
|
372 | + public function get_pretty_label_for_results() |
|
373 | + { |
|
374 | + $expected_vars = $this->_expected_vars_for_query_inject(); |
|
375 | + $pretty_label = ''; |
|
376 | + $label_parts = array(); |
|
377 | + foreach ($expected_vars as $request_key => $model_name) { |
|
378 | + $model = EE_Registry::instance()->load_model($model_name); |
|
379 | + if ($model_field_value = EE_Registry::instance()->REQ->get($request_key)) { |
|
380 | + switch ($request_key) { |
|
381 | + case '_REG_ID' : |
|
382 | + $label_parts[] = sprintf( |
|
383 | + esc_html__('Registration with the ID: %s', 'event_espresso'), |
|
384 | + $model_field_value |
|
385 | + ); |
|
386 | + break; |
|
387 | + case 'ATT_ID' : |
|
388 | + /** @var EE_Attendee $attendee */ |
|
389 | + $attendee = $model->get_one_by_ID($model_field_value); |
|
390 | + $label_parts[] = $attendee instanceof EE_Attendee |
|
391 | + ? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name()) |
|
392 | + : sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value); |
|
393 | + break; |
|
394 | + case 'ID' : |
|
395 | + /** @var EE_WP_User $wpUser */ |
|
396 | + $wpUser = $model->get_one_by_ID($model_field_value); |
|
397 | + $label_parts[] = $wpUser instanceof EE_WP_User |
|
398 | + ? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name()) |
|
399 | + : sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value); |
|
400 | + break; |
|
401 | + case 'TXN_ID' : |
|
402 | + $label_parts[] = sprintf( |
|
403 | + esc_html__('Transaction with the ID: %s', 'event_espresso'), |
|
404 | + $model_field_value |
|
405 | + ); |
|
406 | + break; |
|
407 | + case 'EVT_ID' : |
|
408 | + /** @var EE_Event $Event */ |
|
409 | + $Event = $model->get_one_by_ID($model_field_value); |
|
410 | + $label_parts[] = $Event instanceof EE_Event |
|
411 | + ? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name()) |
|
412 | + : sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value); |
|
413 | + break; |
|
414 | + } |
|
415 | + } |
|
416 | + } |
|
417 | + |
|
418 | + if ($label_parts) { |
|
419 | + |
|
420 | + //prepend to the last element of $label_parts an "and". |
|
421 | + if (count($label_parts) > 1) { |
|
422 | + $label_parts_index_to_prepend = count($label_parts) - 1; |
|
423 | + $label_parts[$label_parts_index_to_prepend] = 'and' . $label_parts[$label_parts_index_to_prepend]; |
|
424 | + } |
|
425 | + |
|
426 | + $pretty_label .= sprintf( |
|
427 | + esc_html_x( |
|
428 | + 'Showing messages for %s', |
|
429 | + 'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.', |
|
430 | + 'event_espresso' |
|
431 | + ), |
|
432 | + implode(', ', $label_parts) |
|
433 | + ); |
|
434 | + } |
|
435 | + return $pretty_label; |
|
436 | + } |
|
437 | + |
|
438 | + |
|
439 | + /** |
|
440 | + * This returns the array of expected variables for the EEI_Query_Filter methods being implemented |
|
441 | + * The array is in the format: |
|
442 | + * array( |
|
443 | + * {$field_name} => {$model_name} |
|
444 | + * ); |
|
445 | + * |
|
446 | + * @since 4.9.0 |
|
447 | + * @return array |
|
448 | + */ |
|
449 | + protected function _expected_vars_for_query_inject() |
|
450 | + { |
|
451 | + return array( |
|
452 | + '_REG_ID' => 'Registration', |
|
453 | + 'ATT_ID' => 'Attendee', |
|
454 | + 'ID' => 'WP_User', |
|
455 | + 'TXN_ID' => 'Transaction', |
|
456 | + 'EVT_ID' => 'Event', |
|
457 | + ); |
|
458 | + } |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * This returns whether EEM_Message is in debug mode or not. |
|
463 | + * Currently "debug mode" is used to control the handling of the EEM_Message::debug_only status when |
|
464 | + * generating/sending messages. Debug mode can be set by either: |
|
465 | + * 1. Sending in a value for the $set_debug argument |
|
466 | + * 2. Defining `EE_DEBUG_MESSAGES` constant in wp-config.php |
|
467 | + * 3. Overriding the above via the provided filter. |
|
468 | + * |
|
469 | + * @param bool|null $set_debug If provided, then the debug mode will be set internally until reset via the |
|
470 | + * provided boolean. When no argument is provided (default null) then the debug |
|
471 | + * mode will be returned. |
|
472 | + * @return bool true means Messages is in debug mode. false means messages system is not in debug mode. |
|
473 | + */ |
|
474 | + public static function debug($set_debug = null) |
|
475 | + { |
|
476 | + static $is_debugging = null; |
|
477 | + |
|
478 | + //initialize (use constant if set). |
|
479 | + if (is_null($set_debug) && is_null($is_debugging)) { |
|
480 | + $is_debugging = defined('EE_DEBUG_MESSAGES') && EE_DEBUG_MESSAGES; |
|
481 | + } |
|
482 | + |
|
483 | + if ( ! is_null($set_debug)) { |
|
484 | + $is_debugging = filter_var($set_debug, FILTER_VALIDATE_BOOLEAN); |
|
485 | + } |
|
486 | + |
|
487 | + //return filtered value |
|
488 | + return apply_filters('FHEE__EEM_Message__debug', $is_debugging); |
|
489 | + } |
|
490 | + |
|
491 | + |
|
492 | + /** |
|
493 | + * Deletes old messages meeting certain criteria for removal from the database. |
|
494 | + * By default, this will delete messages that: |
|
495 | + * - are older than the value of the delete_threshold in months. |
|
496 | + * - have a STS_ID other than EEM_Message::status_idle |
|
497 | + * |
|
498 | + * @param int $delete_threshold This integer will be used to set the boundary for what messages are deleted in months. |
|
499 | + * @return bool|false|int Either the number of records affected or false if there was an error (you can call |
|
500 | + * $wpdb->last_error to find out what the error was. |
|
501 | + */ |
|
502 | + public function delete_old_messages($delete_threshold = 6) |
|
503 | + { |
|
504 | + $number_deleted = 0; |
|
505 | + /** |
|
506 | + * Allows code to change the boundary for what messages are kept. |
|
507 | + * Uses the value of the `delete_threshold` variable by default. |
|
508 | + * |
|
509 | + * @param int $seconds seconds that will be subtracted from the timestamp for now. |
|
510 | + * @return int |
|
511 | + */ |
|
512 | + $time_to_leave_alone = absint( |
|
513 | + apply_filters( |
|
514 | + 'FHEE__EEM_Message__delete_old_messages__time_to_leave_alone', |
|
515 | + ((int) $delete_threshold) * MONTH_IN_SECONDS |
|
516 | + ) |
|
517 | + ); |
|
518 | + |
|
519 | + |
|
520 | + /** |
|
521 | + * Allows code to change what message stati are ignored when deleting. |
|
522 | + * Defaults to only ignore EEM_Message::status_idle messages. |
|
523 | + * |
|
524 | + * @param string $message_stati_to_keep An array of message statuses that will be ignored when deleting. |
|
525 | + */ |
|
526 | + $message_stati_to_keep = (array) apply_filters( |
|
527 | + 'FHEE__EEM_Message__delete_old_messages__message_stati_to_keep', |
|
528 | + array( |
|
529 | + EEM_Message::status_idle |
|
530 | + ) |
|
531 | + ); |
|
532 | + |
|
533 | + //first get all the ids of messages being deleted |
|
534 | + $message_ids_to_delete = EEM_Message::instance()->get_col( |
|
535 | + array( |
|
536 | + 0 => array( |
|
537 | + 'STS_ID' => array('NOT_IN', $message_stati_to_keep), |
|
538 | + 'MSG_modified' => array('<', time() - $time_to_leave_alone) |
|
539 | + ) |
|
540 | + ) |
|
541 | + ); |
|
542 | + |
|
543 | + if(! empty($message_ids_to_delete) && is_array($message_ids_to_delete)) { |
|
544 | + global $wpdb; |
|
545 | + $number_deleted = $wpdb->query(' |
|
546 | 546 | DELETE |
547 | 547 | FROM ' . $this->table() . ' |
548 | 548 | WHERE |
549 | 549 | MSG_ID IN (' . implode(",", $message_ids_to_delete) . ') |
550 | 550 | '); |
551 | - } |
|
552 | - |
|
553 | - /** |
|
554 | - * This will get called if the number of records deleted 0 or greater. So a successful deletion is one where |
|
555 | - * there were no errors. An unsuccessful deletion is where there were errors. Keep that in mind for the actions |
|
556 | - * below. |
|
557 | - */ |
|
558 | - if ($number_deleted !== false) { |
|
559 | - do_action('AHEE__EEM_Message__delete_old_messages__after_successful_deletion', $message_ids_to_delete, $number_deleted); |
|
560 | - } else { |
|
561 | - do_action('AHEE__EEM_Message__delete_old_messages__after_deletion_fail', $message_ids_to_delete, $number_deleted); |
|
562 | - } |
|
563 | - return $number_deleted; |
|
564 | - } |
|
551 | + } |
|
552 | + |
|
553 | + /** |
|
554 | + * This will get called if the number of records deleted 0 or greater. So a successful deletion is one where |
|
555 | + * there were no errors. An unsuccessful deletion is where there were errors. Keep that in mind for the actions |
|
556 | + * below. |
|
557 | + */ |
|
558 | + if ($number_deleted !== false) { |
|
559 | + do_action('AHEE__EEM_Message__delete_old_messages__after_successful_deletion', $message_ids_to_delete, $number_deleted); |
|
560 | + } else { |
|
561 | + do_action('AHEE__EEM_Message__delete_old_messages__after_deletion_fail', $message_ids_to_delete, $number_deleted); |
|
562 | + } |
|
563 | + return $number_deleted; |
|
564 | + } |
|
565 | 565 | |
566 | 566 | } |
567 | 567 | // End of file EEM_Message.model.php |
@@ -12,199 +12,199 @@ |
||
12 | 12 | class EE_Messages_Scheduler extends EE_Base |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * Number of seconds between batch sends/generates on the cron job. |
|
17 | - * Defaults to 5 minutes in seconds. If you want to change this interval, you can use the native WordPress |
|
18 | - * `cron_schedules` filter and modify the existing custom `ee_message_cron` schedule interval added. |
|
19 | - * |
|
20 | - * @type int |
|
21 | - */ |
|
22 | - const message_cron_schedule = 300; |
|
23 | - |
|
24 | - /** |
|
25 | - * Constructor |
|
26 | - */ |
|
27 | - public function __construct() |
|
28 | - { |
|
29 | - //register tasks (and make sure only registered once). |
|
30 | - if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
31 | - add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
|
32 | - } |
|
33 | - |
|
34 | - //register callbacks for scheduled events (but make sure they are set only once). |
|
35 | - if (! has_action( |
|
36 | - 'AHEE__EE_Messages_Scheduler__generation', |
|
37 | - array('EE_Messages_Scheduler', 'batch_generation') |
|
38 | - )) { |
|
39 | - add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
|
40 | - add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending')); |
|
41 | - add_action('AHEE__EE_Messages_Scheduler__cleanup', array('EE_Messages_Scheduler', 'cleanup')); |
|
42 | - } |
|
43 | - |
|
44 | - //add custom schedules |
|
45 | - add_filter('cron_schedules', array($this, 'custom_schedules')); |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * Add custom schedules for wp_cron |
|
51 | - * |
|
52 | - * @param $schedules |
|
53 | - */ |
|
54 | - public function custom_schedules($schedules) |
|
55 | - { |
|
56 | - $schedules['ee_message_cron'] = array( |
|
57 | - 'interval' => self::message_cron_schedule, |
|
58 | - 'display' => __( |
|
59 | - 'This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)', |
|
60 | - 'event_espresso' |
|
61 | - ), |
|
62 | - ); |
|
63 | - return $schedules; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * Callback for FHEE__EEH_Activation__get_cron_tasks that is used to retrieve scheduled Cron events to add and |
|
69 | - * remove. |
|
70 | - * |
|
71 | - * @param array $tasks already existing scheduled tasks |
|
72 | - * @return array |
|
73 | - */ |
|
74 | - public function register_scheduled_tasks($tasks) |
|
75 | - { |
|
76 | - EE_Registry::instance()->load_helper('DTT_Helper'); |
|
77 | - $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron'; |
|
78 | - $tasks['AHEE__EE_Messages_Scheduler__sending'] = 'ee_message_cron'; |
|
79 | - $tasks['AHEE__EE_Messages_Scheduler__cleanup'] = array( EEH_DTT_Helper::tomorrow(), 'daily'); |
|
80 | - return $tasks; |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * This initiates a non-blocking separate request to execute on a scheduled task. |
|
86 | - * Note: The EED_Messages module has the handlers for these requests. |
|
87 | - * |
|
88 | - * @param string $task The task the request is being generated for. |
|
89 | - */ |
|
90 | - public static function initiate_scheduled_non_blocking_request($task) |
|
91 | - { |
|
92 | - if (apply_filters( |
|
93 | - 'EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', |
|
94 | - true |
|
95 | - )) { |
|
96 | - $request_url = add_query_arg( |
|
97 | - array_merge( |
|
98 | - array('ee' => 'msg_cron_trigger'), |
|
99 | - EE_Messages_Scheduler::get_request_params($task) |
|
100 | - ), |
|
101 | - site_url() |
|
102 | - ); |
|
103 | - $request_args = array( |
|
104 | - 'timeout' => 300, |
|
105 | - 'blocking' => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false, |
|
106 | - 'sslverify' => false, |
|
107 | - 'redirection' => 10, |
|
108 | - ); |
|
109 | - $response = wp_remote_get($request_url, $request_args); |
|
110 | - if (is_wp_error($response)) { |
|
111 | - trigger_error($response->get_error_message()); |
|
112 | - } |
|
113 | - } else { |
|
114 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron($task); |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * This returns |
|
121 | - * the request params used for a scheduled message task request. |
|
122 | - * |
|
123 | - * @param string $task The task the request is for. |
|
124 | - * @return array |
|
125 | - */ |
|
126 | - public static function get_request_params($task) |
|
127 | - { |
|
128 | - //transient is used for flood control on msg_cron_trigger requests |
|
129 | - $transient_key = 'ee_trans_' . uniqid($task); |
|
130 | - set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS); |
|
131 | - return array( |
|
132 | - 'type' => $task, |
|
133 | - 'key' => $transient_key, |
|
134 | - ); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * This is used to execute an immediate call to the run_cron task performed by EED_Messages |
|
140 | - * |
|
141 | - * @param string $task The task the request is being generated for. |
|
142 | - */ |
|
143 | - public static function initiate_immediate_request_on_cron($task) |
|
144 | - { |
|
145 | - $request_args = EE_Messages_Scheduler::get_request_params($task); |
|
146 | - //set those request args in the request so it gets picked up |
|
147 | - foreach ($request_args as $request_key => $request_value) { |
|
148 | - EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
149 | - } |
|
150 | - EED_Messages::instance()->run_cron(); |
|
151 | - } |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event |
|
156 | - */ |
|
157 | - public static function batch_generation() |
|
158 | - { |
|
159 | - /** |
|
160 | - * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
161 | - */ |
|
162 | - if (! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
163 | - || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
164 | - ) { |
|
165 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate'); |
|
166 | - } |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * Callback for scheduled AHEE__EE_Messages_Scheduler__sending |
|
172 | - */ |
|
173 | - public static function batch_sending() |
|
174 | - { |
|
175 | - /** |
|
176 | - * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
177 | - */ |
|
178 | - if (! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
179 | - || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
180 | - ) { |
|
181 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron('send'); |
|
182 | - } |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * This is the callback for the `AHEE__EE_Messages_Scheduler__cleanup` scheduled event action. |
|
188 | - * This runs once a day and if cleanup is active (set via messages settings), it will (by default) delete permanently |
|
189 | - * from the database messages that have a MSG_modified date older than 30 days. |
|
190 | - */ |
|
191 | - public static function cleanup() |
|
192 | - { |
|
193 | - //first check if user has cleanup turned on or if we're in maintenance mode. If in maintenance mode we'll wait |
|
194 | - //until the next scheduled event. |
|
195 | - if (! EE_Registry::instance()->CFG->messages->delete_threshold |
|
196 | - || ! EE_Maintenance_Mode::instance()->models_can_query() |
|
197 | - ) { |
|
198 | - return; |
|
199 | - } |
|
200 | - |
|
201 | - /** |
|
202 | - * This filter switch allows other code (such as the EE_Worker_Queue add-on) to replace this with its own handling |
|
203 | - * of deleting messages. |
|
204 | - */ |
|
205 | - if (apply_filters('FHEE__EE_Messages_Scheduler__cleanup__handle_cleanup_on_cron', true)) { |
|
206 | - EEM_Message::instance()->delete_old_messages(EE_Registry::instance()->CFG->messages->delete_threshold); |
|
207 | - } |
|
208 | - } |
|
15 | + /** |
|
16 | + * Number of seconds between batch sends/generates on the cron job. |
|
17 | + * Defaults to 5 minutes in seconds. If you want to change this interval, you can use the native WordPress |
|
18 | + * `cron_schedules` filter and modify the existing custom `ee_message_cron` schedule interval added. |
|
19 | + * |
|
20 | + * @type int |
|
21 | + */ |
|
22 | + const message_cron_schedule = 300; |
|
23 | + |
|
24 | + /** |
|
25 | + * Constructor |
|
26 | + */ |
|
27 | + public function __construct() |
|
28 | + { |
|
29 | + //register tasks (and make sure only registered once). |
|
30 | + if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
31 | + add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
|
32 | + } |
|
33 | + |
|
34 | + //register callbacks for scheduled events (but make sure they are set only once). |
|
35 | + if (! has_action( |
|
36 | + 'AHEE__EE_Messages_Scheduler__generation', |
|
37 | + array('EE_Messages_Scheduler', 'batch_generation') |
|
38 | + )) { |
|
39 | + add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
|
40 | + add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending')); |
|
41 | + add_action('AHEE__EE_Messages_Scheduler__cleanup', array('EE_Messages_Scheduler', 'cleanup')); |
|
42 | + } |
|
43 | + |
|
44 | + //add custom schedules |
|
45 | + add_filter('cron_schedules', array($this, 'custom_schedules')); |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * Add custom schedules for wp_cron |
|
51 | + * |
|
52 | + * @param $schedules |
|
53 | + */ |
|
54 | + public function custom_schedules($schedules) |
|
55 | + { |
|
56 | + $schedules['ee_message_cron'] = array( |
|
57 | + 'interval' => self::message_cron_schedule, |
|
58 | + 'display' => __( |
|
59 | + 'This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)', |
|
60 | + 'event_espresso' |
|
61 | + ), |
|
62 | + ); |
|
63 | + return $schedules; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * Callback for FHEE__EEH_Activation__get_cron_tasks that is used to retrieve scheduled Cron events to add and |
|
69 | + * remove. |
|
70 | + * |
|
71 | + * @param array $tasks already existing scheduled tasks |
|
72 | + * @return array |
|
73 | + */ |
|
74 | + public function register_scheduled_tasks($tasks) |
|
75 | + { |
|
76 | + EE_Registry::instance()->load_helper('DTT_Helper'); |
|
77 | + $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron'; |
|
78 | + $tasks['AHEE__EE_Messages_Scheduler__sending'] = 'ee_message_cron'; |
|
79 | + $tasks['AHEE__EE_Messages_Scheduler__cleanup'] = array( EEH_DTT_Helper::tomorrow(), 'daily'); |
|
80 | + return $tasks; |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * This initiates a non-blocking separate request to execute on a scheduled task. |
|
86 | + * Note: The EED_Messages module has the handlers for these requests. |
|
87 | + * |
|
88 | + * @param string $task The task the request is being generated for. |
|
89 | + */ |
|
90 | + public static function initiate_scheduled_non_blocking_request($task) |
|
91 | + { |
|
92 | + if (apply_filters( |
|
93 | + 'EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', |
|
94 | + true |
|
95 | + )) { |
|
96 | + $request_url = add_query_arg( |
|
97 | + array_merge( |
|
98 | + array('ee' => 'msg_cron_trigger'), |
|
99 | + EE_Messages_Scheduler::get_request_params($task) |
|
100 | + ), |
|
101 | + site_url() |
|
102 | + ); |
|
103 | + $request_args = array( |
|
104 | + 'timeout' => 300, |
|
105 | + 'blocking' => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false, |
|
106 | + 'sslverify' => false, |
|
107 | + 'redirection' => 10, |
|
108 | + ); |
|
109 | + $response = wp_remote_get($request_url, $request_args); |
|
110 | + if (is_wp_error($response)) { |
|
111 | + trigger_error($response->get_error_message()); |
|
112 | + } |
|
113 | + } else { |
|
114 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron($task); |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * This returns |
|
121 | + * the request params used for a scheduled message task request. |
|
122 | + * |
|
123 | + * @param string $task The task the request is for. |
|
124 | + * @return array |
|
125 | + */ |
|
126 | + public static function get_request_params($task) |
|
127 | + { |
|
128 | + //transient is used for flood control on msg_cron_trigger requests |
|
129 | + $transient_key = 'ee_trans_' . uniqid($task); |
|
130 | + set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS); |
|
131 | + return array( |
|
132 | + 'type' => $task, |
|
133 | + 'key' => $transient_key, |
|
134 | + ); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * This is used to execute an immediate call to the run_cron task performed by EED_Messages |
|
140 | + * |
|
141 | + * @param string $task The task the request is being generated for. |
|
142 | + */ |
|
143 | + public static function initiate_immediate_request_on_cron($task) |
|
144 | + { |
|
145 | + $request_args = EE_Messages_Scheduler::get_request_params($task); |
|
146 | + //set those request args in the request so it gets picked up |
|
147 | + foreach ($request_args as $request_key => $request_value) { |
|
148 | + EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
149 | + } |
|
150 | + EED_Messages::instance()->run_cron(); |
|
151 | + } |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * Callback for scheduled AHEE__EE_Messages_Scheduler__generation wp cron event |
|
156 | + */ |
|
157 | + public static function batch_generation() |
|
158 | + { |
|
159 | + /** |
|
160 | + * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
161 | + */ |
|
162 | + if (! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
163 | + || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
164 | + ) { |
|
165 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate'); |
|
166 | + } |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * Callback for scheduled AHEE__EE_Messages_Scheduler__sending |
|
172 | + */ |
|
173 | + public static function batch_sending() |
|
174 | + { |
|
175 | + /** |
|
176 | + * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
|
177 | + */ |
|
178 | + if (! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
179 | + || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
|
180 | + ) { |
|
181 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron('send'); |
|
182 | + } |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * This is the callback for the `AHEE__EE_Messages_Scheduler__cleanup` scheduled event action. |
|
188 | + * This runs once a day and if cleanup is active (set via messages settings), it will (by default) delete permanently |
|
189 | + * from the database messages that have a MSG_modified date older than 30 days. |
|
190 | + */ |
|
191 | + public static function cleanup() |
|
192 | + { |
|
193 | + //first check if user has cleanup turned on or if we're in maintenance mode. If in maintenance mode we'll wait |
|
194 | + //until the next scheduled event. |
|
195 | + if (! EE_Registry::instance()->CFG->messages->delete_threshold |
|
196 | + || ! EE_Maintenance_Mode::instance()->models_can_query() |
|
197 | + ) { |
|
198 | + return; |
|
199 | + } |
|
200 | + |
|
201 | + /** |
|
202 | + * This filter switch allows other code (such as the EE_Worker_Queue add-on) to replace this with its own handling |
|
203 | + * of deleting messages. |
|
204 | + */ |
|
205 | + if (apply_filters('FHEE__EE_Messages_Scheduler__cleanup__handle_cleanup_on_cron', true)) { |
|
206 | + EEM_Message::instance()->delete_old_messages(EE_Registry::instance()->CFG->messages->delete_threshold); |
|
207 | + } |
|
208 | + } |
|
209 | 209 | |
210 | 210 | } //end EE_Messages_Scheduler |
211 | 211 | \ No newline at end of file |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | public function __construct() |
28 | 28 | { |
29 | 29 | //register tasks (and make sure only registered once). |
30 | - if (! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
30 | + if ( ! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
31 | 31 | add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
32 | 32 | } |
33 | 33 | |
34 | 34 | //register callbacks for scheduled events (but make sure they are set only once). |
35 | - if (! has_action( |
|
35 | + if ( ! has_action( |
|
36 | 36 | 'AHEE__EE_Messages_Scheduler__generation', |
37 | 37 | array('EE_Messages_Scheduler', 'batch_generation') |
38 | 38 | )) { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | EE_Registry::instance()->load_helper('DTT_Helper'); |
77 | 77 | $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron'; |
78 | 78 | $tasks['AHEE__EE_Messages_Scheduler__sending'] = 'ee_message_cron'; |
79 | - $tasks['AHEE__EE_Messages_Scheduler__cleanup'] = array( EEH_DTT_Helper::tomorrow(), 'daily'); |
|
79 | + $tasks['AHEE__EE_Messages_Scheduler__cleanup'] = array(EEH_DTT_Helper::tomorrow(), 'daily'); |
|
80 | 80 | return $tasks; |
81 | 81 | } |
82 | 82 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | 'EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', |
94 | 94 | true |
95 | 95 | )) { |
96 | - $request_url = add_query_arg( |
|
96 | + $request_url = add_query_arg( |
|
97 | 97 | array_merge( |
98 | 98 | array('ee' => 'msg_cron_trigger'), |
99 | 99 | EE_Messages_Scheduler::get_request_params($task) |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | 'sslverify' => false, |
107 | 107 | 'redirection' => 10, |
108 | 108 | ); |
109 | - $response = wp_remote_get($request_url, $request_args); |
|
109 | + $response = wp_remote_get($request_url, $request_args); |
|
110 | 110 | if (is_wp_error($response)) { |
111 | 111 | trigger_error($response->get_error_message()); |
112 | 112 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | public static function get_request_params($task) |
127 | 127 | { |
128 | 128 | //transient is used for flood control on msg_cron_trigger requests |
129 | - $transient_key = 'ee_trans_' . uniqid($task); |
|
129 | + $transient_key = 'ee_trans_'.uniqid($task); |
|
130 | 130 | set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS); |
131 | 131 | return array( |
132 | 132 | 'type' => $task, |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | /** |
160 | 160 | * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
161 | 161 | */ |
162 | - if (! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
162 | + if ( ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
163 | 163 | || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
164 | 164 | ) { |
165 | 165 | EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate'); |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | /** |
176 | 176 | * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
177 | 177 | */ |
178 | - if (! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
178 | + if ( ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
179 | 179 | || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
180 | 180 | ) { |
181 | 181 | EE_Messages_Scheduler::initiate_immediate_request_on_cron('send'); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | { |
193 | 193 | //first check if user has cleanup turned on or if we're in maintenance mode. If in maintenance mode we'll wait |
194 | 194 | //until the next scheduled event. |
195 | - if (! EE_Registry::instance()->CFG->messages->delete_threshold |
|
195 | + if ( ! EE_Registry::instance()->CFG->messages->delete_threshold |
|
196 | 196 | || ! EE_Maintenance_Mode::instance()->models_can_query() |
197 | 197 | ) { |
198 | 198 | return; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * _find_common_base_path |
305 | 305 | * given two paths, this determines if there is a common base path between the two |
306 | 306 | * |
307 | - * @param array $paths |
|
307 | + * @param string[] $paths |
|
308 | 308 | * @return string |
309 | 309 | */ |
310 | 310 | protected static function _find_common_base_path($paths) |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
335 | 335 | * @param bool $throw_exceptions if set to true, will throw an exception if the template is either |
336 | 336 | * not found or is not readable |
337 | - * @return mixed string |
|
337 | + * @return string string |
|
338 | 338 | * @throws \DomainException |
339 | 339 | */ |
340 | 340 | public static function display_template( |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | /** |
6 | 6 | * Event Espresso |
@@ -16,35 +16,35 @@ discard block |
||
16 | 16 | |
17 | 17 | |
18 | 18 | if ( ! function_exists('espresso_get_template_part')) { |
19 | - /** |
|
20 | - * espresso_get_template_part |
|
21 | - * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
|
22 | - * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name |
|
23 | - * |
|
24 | - * @param string $slug The slug name for the generic template. |
|
25 | - * @param string $name The name of the specialised template. |
|
26 | - * @return string the html output for the formatted money value |
|
27 | - */ |
|
28 | - function espresso_get_template_part($slug = null, $name = null) |
|
29 | - { |
|
30 | - EEH_Template::get_template_part($slug, $name); |
|
31 | - } |
|
19 | + /** |
|
20 | + * espresso_get_template_part |
|
21 | + * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files |
|
22 | + * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name |
|
23 | + * |
|
24 | + * @param string $slug The slug name for the generic template. |
|
25 | + * @param string $name The name of the specialised template. |
|
26 | + * @return string the html output for the formatted money value |
|
27 | + */ |
|
28 | + function espresso_get_template_part($slug = null, $name = null) |
|
29 | + { |
|
30 | + EEH_Template::get_template_part($slug, $name); |
|
31 | + } |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | if ( ! function_exists('espresso_get_object_css_class')) { |
36 | - /** |
|
37 | - * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
38 | - * |
|
39 | - * @param EE_Base_Class $object the EE object the css class is being generated for |
|
40 | - * @param string $prefix added to the beginning of the generated class |
|
41 | - * @param string $suffix added to the end of the generated class |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
45 | - { |
|
46 | - return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | - } |
|
36 | + /** |
|
37 | + * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
38 | + * |
|
39 | + * @param EE_Base_Class $object the EE object the css class is being generated for |
|
40 | + * @param string $prefix added to the beginning of the generated class |
|
41 | + * @param string $suffix added to the end of the generated class |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
45 | + { |
|
46 | + return EEH_Template::get_object_css_class($object, $prefix, $suffix); |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -59,650 +59,650 @@ discard block |
||
59 | 59 | class EEH_Template |
60 | 60 | { |
61 | 61 | |
62 | - private static $_espresso_themes = array(); |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme |
|
67 | - * |
|
68 | - * @return boolean |
|
69 | - */ |
|
70 | - public static function is_espresso_theme() |
|
71 | - { |
|
72 | - return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then |
|
77 | - * load it's functions.php file ( if not already loaded ) |
|
78 | - * |
|
79 | - * @return void |
|
80 | - */ |
|
81 | - public static function load_espresso_theme_functions() |
|
82 | - { |
|
83 | - if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
84 | - if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
85 | - require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
86 | - } |
|
87 | - } |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory |
|
93 | - * |
|
94 | - * @return array |
|
95 | - */ |
|
96 | - public static function get_espresso_themes() |
|
97 | - { |
|
98 | - if (empty(EEH_Template::$_espresso_themes)) { |
|
99 | - $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
100 | - if (empty($espresso_themes)) { |
|
101 | - return array(); |
|
102 | - } |
|
103 | - if (($key = array_search('global_assets', $espresso_themes)) !== false) { |
|
104 | - unset($espresso_themes[$key]); |
|
105 | - } |
|
106 | - EEH_Template::$_espresso_themes = array(); |
|
107 | - foreach ($espresso_themes as $espresso_theme) { |
|
108 | - EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
109 | - } |
|
110 | - } |
|
111 | - return EEH_Template::$_espresso_themes; |
|
112 | - } |
|
113 | - |
|
114 | - |
|
115 | - /** |
|
116 | - * EEH_Template::get_template_part |
|
117 | - * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, |
|
118 | - * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS |
|
119 | - * filtering based off of the entire template part name |
|
120 | - * |
|
121 | - * @param string $slug The slug name for the generic template. |
|
122 | - * @param string $name The name of the specialised template. |
|
123 | - * @param array $template_args |
|
124 | - * @param bool $return_string |
|
125 | - * @return string the html output for the formatted money value |
|
126 | - */ |
|
127 | - public static function get_template_part( |
|
128 | - $slug = null, |
|
129 | - $name = null, |
|
130 | - $template_args = array(), |
|
131 | - $return_string = false |
|
132 | - ) { |
|
133 | - do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
134 | - $templates = array(); |
|
135 | - $name = (string)$name; |
|
136 | - if ($name != '') { |
|
137 | - $templates[] = "{$slug}-{$name}.php"; |
|
138 | - } |
|
139 | - // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
|
140 | - if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) { |
|
141 | - EEH_Template::locate_template($templates, $template_args, true, $return_string); |
|
142 | - } |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * locate_template |
|
148 | - * locate a template file by looking in the following places, in the following order: |
|
149 | - * <server path up to>/wp-content/themes/<current active WordPress theme>/ |
|
150 | - * <assumed full absolute server path> |
|
151 | - * <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/ |
|
152 | - * <server path up to>/wp-content/uploads/espresso/templates/ |
|
153 | - * <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/ |
|
154 | - * <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/ |
|
155 | - * <server path up to>/wp-content/plugins/<EE4 folder>/ |
|
156 | - * as soon as the template is found in one of these locations, it will be returned or loaded |
|
157 | - * Example: |
|
158 | - * You are using the WordPress Twenty Sixteen theme, |
|
159 | - * and you want to customize the "some-event.template.php" template, |
|
160 | - * which is located in the "/relative/path/to/" folder relative to the main EE plugin folder. |
|
161 | - * Assuming WP is installed on your server in the "/home/public_html/" folder, |
|
162 | - * EEH_Template::locate_template() will look at the following paths in order until the template is found: |
|
163 | - * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
164 | - * /relative/path/to/some-event.template.php |
|
165 | - * /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
166 | - * /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php |
|
167 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
168 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
169 | - * /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php |
|
170 | - * Had you passed an absolute path to your template that was in some other location, |
|
171 | - * ie: "/absolute/path/to/some-event.template.php" |
|
172 | - * then the search would have been : |
|
173 | - * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
174 | - * /absolute/path/to/some-event.template.php |
|
175 | - * and stopped there upon finding it in the second location |
|
176 | - * |
|
177 | - * @param array|string $templates array of template file names including extension (or just a single string) |
|
178 | - * @param array $template_args an array of arguments to be extracted for use in the template |
|
179 | - * @param boolean $load whether to pass the located template path on to the |
|
180 | - * EEH_Template::display_template() method or simply return it |
|
181 | - * @param boolean $return_string whether to send output immediately to screen, or capture and return as a |
|
182 | - * string |
|
183 | - * @param boolean $check_if_custom If TRUE, this flags this method to return boolean for whether this will |
|
184 | - * generate a custom template or not. Used in places where you don't actually |
|
185 | - * load the template, you just want to know if there's a custom version of it. |
|
186 | - * @return mixed |
|
187 | - */ |
|
188 | - public static function locate_template( |
|
189 | - $templates = array(), |
|
190 | - $template_args = array(), |
|
191 | - $load = true, |
|
192 | - $return_string = true, |
|
193 | - $check_if_custom = false |
|
194 | - ) { |
|
195 | - // first use WP locate_template to check for template in the current theme folder |
|
196 | - $template_path = locate_template($templates); |
|
197 | - |
|
198 | - if ($check_if_custom && ! empty($template_path)) { |
|
199 | - return true; |
|
200 | - } |
|
201 | - |
|
202 | - // not in the theme |
|
203 | - if (empty($template_path)) { |
|
204 | - // not even a template to look for ? |
|
205 | - if (empty($templates)) { |
|
206 | - // get post_type |
|
207 | - $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
208 | - // get array of EE Custom Post Types |
|
209 | - $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
|
210 | - // build template name based on request |
|
211 | - if (isset($EE_CPTs[$post_type])) { |
|
212 | - $archive_or_single = is_archive() ? 'archive' : ''; |
|
213 | - $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
214 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
215 | - } |
|
216 | - } |
|
217 | - // currently active EE template theme |
|
218 | - $current_theme = EE_Config::get_current_theme(); |
|
219 | - |
|
220 | - // array of paths to folders that may contain templates |
|
221 | - $template_folder_paths = array( |
|
222 | - // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
|
223 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
224 | - // then in the root of the /wp-content/uploads/espresso/templates/ folder |
|
225 | - EVENT_ESPRESSO_TEMPLATE_DIR, |
|
226 | - ); |
|
227 | - |
|
228 | - //add core plugin folders for checking only if we're not $check_if_custom |
|
229 | - if ( ! $check_if_custom) { |
|
230 | - $core_paths = array( |
|
231 | - // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
|
232 | - EE_PUBLIC . $current_theme, |
|
233 | - // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
|
234 | - EE_TEMPLATES . $current_theme, |
|
235 | - // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
|
236 | - EE_PLUGIN_DIR_PATH, |
|
237 | - ); |
|
238 | - $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
239 | - } |
|
240 | - |
|
241 | - // now filter that array |
|
242 | - $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', |
|
243 | - $template_folder_paths); |
|
244 | - $templates = is_array($templates) ? $templates : array($templates); |
|
245 | - $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
246 | - // array to hold all possible template paths |
|
247 | - $full_template_paths = array(); |
|
248 | - |
|
249 | - // loop through $templates |
|
250 | - foreach ($templates as $template) { |
|
251 | - // normalize directory separators |
|
252 | - $template = EEH_File::standardise_directory_separators($template); |
|
253 | - $file_name = basename($template); |
|
254 | - $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
255 | - // while looping through all template folder paths |
|
256 | - foreach ($template_folder_paths as $template_folder_path) { |
|
257 | - // normalize directory separators |
|
258 | - $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
259 | - // determine if any common base path exists between the two paths |
|
260 | - $common_base_path = EEH_Template::_find_common_base_path( |
|
261 | - array($template_folder_path, $template_path_minus_file_name) |
|
262 | - ); |
|
263 | - if ($common_base_path !== '') { |
|
264 | - // both paths have a common base, so just tack the filename onto our search path |
|
265 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
266 | - } else { |
|
267 | - // no common base path, so let's just concatenate |
|
268 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
269 | - } |
|
270 | - // build up our template locations array by adding our resolved paths |
|
271 | - $full_template_paths[] = $resolved_path; |
|
272 | - } |
|
273 | - // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
|
274 | - array_unshift($full_template_paths, $template); |
|
275 | - // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
|
276 | - array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
277 | - } |
|
278 | - // filter final array of full template paths |
|
279 | - $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
|
280 | - $full_template_paths, $file_name); |
|
281 | - // now loop through our final array of template location paths and check each location |
|
282 | - foreach ((array)$full_template_paths as $full_template_path) { |
|
283 | - if (is_readable($full_template_path)) { |
|
284 | - $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
285 | - break; |
|
286 | - } |
|
287 | - } |
|
288 | - } |
|
289 | - |
|
290 | - // hook that can be used to display the full template path that will be used |
|
291 | - do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
292 | - |
|
293 | - // if we got it and you want to see it... |
|
294 | - if ($template_path && $load && ! $check_if_custom) { |
|
295 | - if ($return_string) { |
|
296 | - return EEH_Template::display_template($template_path, $template_args, true); |
|
297 | - } else { |
|
298 | - EEH_Template::display_template($template_path, $template_args, false); |
|
299 | - } |
|
300 | - } |
|
301 | - return $check_if_custom && ! empty($template_path) ? true : $template_path; |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * _find_common_base_path |
|
307 | - * given two paths, this determines if there is a common base path between the two |
|
308 | - * |
|
309 | - * @param array $paths |
|
310 | - * @return string |
|
311 | - */ |
|
312 | - protected static function _find_common_base_path($paths) |
|
313 | - { |
|
314 | - $last_offset = 0; |
|
315 | - $common_base_path = ''; |
|
316 | - while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
317 | - $dir_length = $index - $last_offset + 1; |
|
318 | - $directory = substr($paths[0], $last_offset, $dir_length); |
|
319 | - foreach ($paths as $path) { |
|
320 | - if (substr($path, $last_offset, $dir_length) != $directory) { |
|
321 | - return $common_base_path; |
|
322 | - } |
|
323 | - } |
|
324 | - $common_base_path .= $directory; |
|
325 | - $last_offset = $index + 1; |
|
326 | - } |
|
327 | - return substr($common_base_path, 0, -1); |
|
328 | - } |
|
329 | - |
|
330 | - |
|
331 | - /** |
|
332 | - * load and display a template |
|
333 | - * |
|
334 | - * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
|
335 | - * @param array $template_args an array of arguments to be extracted for use in the template |
|
336 | - * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
|
337 | - * @param bool $throw_exceptions if set to true, will throw an exception if the template is either |
|
338 | - * not found or is not readable |
|
339 | - * @return mixed string |
|
340 | - * @throws \DomainException |
|
341 | - */ |
|
62 | + private static $_espresso_themes = array(); |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme |
|
67 | + * |
|
68 | + * @return boolean |
|
69 | + */ |
|
70 | + public static function is_espresso_theme() |
|
71 | + { |
|
72 | + return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then |
|
77 | + * load it's functions.php file ( if not already loaded ) |
|
78 | + * |
|
79 | + * @return void |
|
80 | + */ |
|
81 | + public static function load_espresso_theme_functions() |
|
82 | + { |
|
83 | + if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
|
84 | + if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
85 | + require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
86 | + } |
|
87 | + } |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory |
|
93 | + * |
|
94 | + * @return array |
|
95 | + */ |
|
96 | + public static function get_espresso_themes() |
|
97 | + { |
|
98 | + if (empty(EEH_Template::$_espresso_themes)) { |
|
99 | + $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
100 | + if (empty($espresso_themes)) { |
|
101 | + return array(); |
|
102 | + } |
|
103 | + if (($key = array_search('global_assets', $espresso_themes)) !== false) { |
|
104 | + unset($espresso_themes[$key]); |
|
105 | + } |
|
106 | + EEH_Template::$_espresso_themes = array(); |
|
107 | + foreach ($espresso_themes as $espresso_theme) { |
|
108 | + EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme; |
|
109 | + } |
|
110 | + } |
|
111 | + return EEH_Template::$_espresso_themes; |
|
112 | + } |
|
113 | + |
|
114 | + |
|
115 | + /** |
|
116 | + * EEH_Template::get_template_part |
|
117 | + * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, |
|
118 | + * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS |
|
119 | + * filtering based off of the entire template part name |
|
120 | + * |
|
121 | + * @param string $slug The slug name for the generic template. |
|
122 | + * @param string $name The name of the specialised template. |
|
123 | + * @param array $template_args |
|
124 | + * @param bool $return_string |
|
125 | + * @return string the html output for the formatted money value |
|
126 | + */ |
|
127 | + public static function get_template_part( |
|
128 | + $slug = null, |
|
129 | + $name = null, |
|
130 | + $template_args = array(), |
|
131 | + $return_string = false |
|
132 | + ) { |
|
133 | + do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
|
134 | + $templates = array(); |
|
135 | + $name = (string)$name; |
|
136 | + if ($name != '') { |
|
137 | + $templates[] = "{$slug}-{$name}.php"; |
|
138 | + } |
|
139 | + // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' ); |
|
140 | + if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) { |
|
141 | + EEH_Template::locate_template($templates, $template_args, true, $return_string); |
|
142 | + } |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * locate_template |
|
148 | + * locate a template file by looking in the following places, in the following order: |
|
149 | + * <server path up to>/wp-content/themes/<current active WordPress theme>/ |
|
150 | + * <assumed full absolute server path> |
|
151 | + * <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/ |
|
152 | + * <server path up to>/wp-content/uploads/espresso/templates/ |
|
153 | + * <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/ |
|
154 | + * <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/ |
|
155 | + * <server path up to>/wp-content/plugins/<EE4 folder>/ |
|
156 | + * as soon as the template is found in one of these locations, it will be returned or loaded |
|
157 | + * Example: |
|
158 | + * You are using the WordPress Twenty Sixteen theme, |
|
159 | + * and you want to customize the "some-event.template.php" template, |
|
160 | + * which is located in the "/relative/path/to/" folder relative to the main EE plugin folder. |
|
161 | + * Assuming WP is installed on your server in the "/home/public_html/" folder, |
|
162 | + * EEH_Template::locate_template() will look at the following paths in order until the template is found: |
|
163 | + * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
164 | + * /relative/path/to/some-event.template.php |
|
165 | + * /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
166 | + * /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php |
|
167 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
168 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php |
|
169 | + * /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php |
|
170 | + * Had you passed an absolute path to your template that was in some other location, |
|
171 | + * ie: "/absolute/path/to/some-event.template.php" |
|
172 | + * then the search would have been : |
|
173 | + * /home/public_html/wp-content/themes/twentysixteen/some-event.template.php |
|
174 | + * /absolute/path/to/some-event.template.php |
|
175 | + * and stopped there upon finding it in the second location |
|
176 | + * |
|
177 | + * @param array|string $templates array of template file names including extension (or just a single string) |
|
178 | + * @param array $template_args an array of arguments to be extracted for use in the template |
|
179 | + * @param boolean $load whether to pass the located template path on to the |
|
180 | + * EEH_Template::display_template() method or simply return it |
|
181 | + * @param boolean $return_string whether to send output immediately to screen, or capture and return as a |
|
182 | + * string |
|
183 | + * @param boolean $check_if_custom If TRUE, this flags this method to return boolean for whether this will |
|
184 | + * generate a custom template or not. Used in places where you don't actually |
|
185 | + * load the template, you just want to know if there's a custom version of it. |
|
186 | + * @return mixed |
|
187 | + */ |
|
188 | + public static function locate_template( |
|
189 | + $templates = array(), |
|
190 | + $template_args = array(), |
|
191 | + $load = true, |
|
192 | + $return_string = true, |
|
193 | + $check_if_custom = false |
|
194 | + ) { |
|
195 | + // first use WP locate_template to check for template in the current theme folder |
|
196 | + $template_path = locate_template($templates); |
|
197 | + |
|
198 | + if ($check_if_custom && ! empty($template_path)) { |
|
199 | + return true; |
|
200 | + } |
|
201 | + |
|
202 | + // not in the theme |
|
203 | + if (empty($template_path)) { |
|
204 | + // not even a template to look for ? |
|
205 | + if (empty($templates)) { |
|
206 | + // get post_type |
|
207 | + $post_type = EE_Registry::instance()->REQ->get('post_type'); |
|
208 | + // get array of EE Custom Post Types |
|
209 | + $EE_CPTs = EE_Register_CPTs::get_CPTs(); |
|
210 | + // build template name based on request |
|
211 | + if (isset($EE_CPTs[$post_type])) { |
|
212 | + $archive_or_single = is_archive() ? 'archive' : ''; |
|
213 | + $archive_or_single = is_single() ? 'single' : $archive_or_single; |
|
214 | + $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
215 | + } |
|
216 | + } |
|
217 | + // currently active EE template theme |
|
218 | + $current_theme = EE_Config::get_current_theme(); |
|
219 | + |
|
220 | + // array of paths to folders that may contain templates |
|
221 | + $template_folder_paths = array( |
|
222 | + // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
|
223 | + EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
224 | + // then in the root of the /wp-content/uploads/espresso/templates/ folder |
|
225 | + EVENT_ESPRESSO_TEMPLATE_DIR, |
|
226 | + ); |
|
227 | + |
|
228 | + //add core plugin folders for checking only if we're not $check_if_custom |
|
229 | + if ( ! $check_if_custom) { |
|
230 | + $core_paths = array( |
|
231 | + // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
|
232 | + EE_PUBLIC . $current_theme, |
|
233 | + // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
|
234 | + EE_TEMPLATES . $current_theme, |
|
235 | + // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
|
236 | + EE_PLUGIN_DIR_PATH, |
|
237 | + ); |
|
238 | + $template_folder_paths = array_merge($template_folder_paths, $core_paths); |
|
239 | + } |
|
240 | + |
|
241 | + // now filter that array |
|
242 | + $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', |
|
243 | + $template_folder_paths); |
|
244 | + $templates = is_array($templates) ? $templates : array($templates); |
|
245 | + $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths); |
|
246 | + // array to hold all possible template paths |
|
247 | + $full_template_paths = array(); |
|
248 | + |
|
249 | + // loop through $templates |
|
250 | + foreach ($templates as $template) { |
|
251 | + // normalize directory separators |
|
252 | + $template = EEH_File::standardise_directory_separators($template); |
|
253 | + $file_name = basename($template); |
|
254 | + $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1)); |
|
255 | + // while looping through all template folder paths |
|
256 | + foreach ($template_folder_paths as $template_folder_path) { |
|
257 | + // normalize directory separators |
|
258 | + $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path); |
|
259 | + // determine if any common base path exists between the two paths |
|
260 | + $common_base_path = EEH_Template::_find_common_base_path( |
|
261 | + array($template_folder_path, $template_path_minus_file_name) |
|
262 | + ); |
|
263 | + if ($common_base_path !== '') { |
|
264 | + // both paths have a common base, so just tack the filename onto our search path |
|
265 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
266 | + } else { |
|
267 | + // no common base path, so let's just concatenate |
|
268 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
269 | + } |
|
270 | + // build up our template locations array by adding our resolved paths |
|
271 | + $full_template_paths[] = $resolved_path; |
|
272 | + } |
|
273 | + // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
|
274 | + array_unshift($full_template_paths, $template); |
|
275 | + // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
|
276 | + array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
277 | + } |
|
278 | + // filter final array of full template paths |
|
279 | + $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
|
280 | + $full_template_paths, $file_name); |
|
281 | + // now loop through our final array of template location paths and check each location |
|
282 | + foreach ((array)$full_template_paths as $full_template_path) { |
|
283 | + if (is_readable($full_template_path)) { |
|
284 | + $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
|
285 | + break; |
|
286 | + } |
|
287 | + } |
|
288 | + } |
|
289 | + |
|
290 | + // hook that can be used to display the full template path that will be used |
|
291 | + do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path); |
|
292 | + |
|
293 | + // if we got it and you want to see it... |
|
294 | + if ($template_path && $load && ! $check_if_custom) { |
|
295 | + if ($return_string) { |
|
296 | + return EEH_Template::display_template($template_path, $template_args, true); |
|
297 | + } else { |
|
298 | + EEH_Template::display_template($template_path, $template_args, false); |
|
299 | + } |
|
300 | + } |
|
301 | + return $check_if_custom && ! empty($template_path) ? true : $template_path; |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * _find_common_base_path |
|
307 | + * given two paths, this determines if there is a common base path between the two |
|
308 | + * |
|
309 | + * @param array $paths |
|
310 | + * @return string |
|
311 | + */ |
|
312 | + protected static function _find_common_base_path($paths) |
|
313 | + { |
|
314 | + $last_offset = 0; |
|
315 | + $common_base_path = ''; |
|
316 | + while (($index = strpos($paths[0], DS, $last_offset)) !== false) { |
|
317 | + $dir_length = $index - $last_offset + 1; |
|
318 | + $directory = substr($paths[0], $last_offset, $dir_length); |
|
319 | + foreach ($paths as $path) { |
|
320 | + if (substr($path, $last_offset, $dir_length) != $directory) { |
|
321 | + return $common_base_path; |
|
322 | + } |
|
323 | + } |
|
324 | + $common_base_path .= $directory; |
|
325 | + $last_offset = $index + 1; |
|
326 | + } |
|
327 | + return substr($common_base_path, 0, -1); |
|
328 | + } |
|
329 | + |
|
330 | + |
|
331 | + /** |
|
332 | + * load and display a template |
|
333 | + * |
|
334 | + * @param bool|string $template_path server path to the file to be loaded, including file name and extension |
|
335 | + * @param array $template_args an array of arguments to be extracted for use in the template |
|
336 | + * @param boolean $return_string whether to send output immediately to screen, or capture and return as a string |
|
337 | + * @param bool $throw_exceptions if set to true, will throw an exception if the template is either |
|
338 | + * not found or is not readable |
|
339 | + * @return mixed string |
|
340 | + * @throws \DomainException |
|
341 | + */ |
|
342 | 342 | public static function display_template( |
343 | - $template_path = false, |
|
344 | - $template_args = array(), |
|
345 | - $return_string = false, |
|
346 | - $throw_exceptions = false |
|
347 | - ) { |
|
348 | - |
|
349 | - /** |
|
350 | - * These two filters are intended for last minute changes to templates being loaded and/or template arg |
|
351 | - * modifications. NOTE... modifying these things can cause breakage as most templates running through |
|
352 | - * the display_template method are templates we DON'T want modified (usually because of js |
|
353 | - * dependencies etc). So unless you know what you are doing, do NOT filter templates or template args |
|
354 | - * using this. |
|
355 | - * |
|
356 | - * @since 4.6.0 |
|
357 | - */ |
|
358 | - $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
359 | - $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
360 | - |
|
361 | - // you gimme nuttin - YOU GET NUTTIN !! |
|
362 | - if ( ! $template_path || ! is_readable($template_path)) { |
|
363 | - return ''; |
|
364 | - } |
|
365 | - // if $template_args are not in an array, then make it so |
|
366 | - if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
367 | - $template_args = array($template_args); |
|
368 | - } |
|
369 | - extract( $template_args, EXTR_SKIP ); |
|
370 | - // ignore whether template is accessible ? |
|
371 | - if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
372 | - throw new \DomainException( |
|
373 | - esc_html__( |
|
374 | - 'Invalid, unreadable, or missing file.', |
|
375 | - 'event_espresso' |
|
376 | - ) |
|
377 | - ); |
|
378 | - } |
|
379 | - |
|
380 | - |
|
381 | - if ($return_string) { |
|
382 | - // because we want to return a string, we are going to capture the output |
|
383 | - ob_start(); |
|
384 | - include($template_path); |
|
385 | - return ob_get_clean(); |
|
386 | - } else { |
|
387 | - include($template_path); |
|
388 | - } |
|
389 | - return ''; |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - * get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
395 | - * |
|
396 | - * @param EE_Base_Class $object the EE object the css class is being generated for |
|
397 | - * @param string $prefix added to the beginning of the generated class |
|
398 | - * @param string $suffix added to the end of the generated class |
|
399 | - * @return string |
|
400 | - */ |
|
401 | - public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
402 | - { |
|
403 | - // in the beginning... |
|
404 | - $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
405 | - // da muddle |
|
406 | - $class = ''; |
|
407 | - // the end |
|
408 | - $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
409 | - // is the passed object an EE object ? |
|
410 | - if ($object instanceof EE_Base_Class) { |
|
411 | - // grab the exact type of object |
|
412 | - $obj_class = get_class($object); |
|
413 | - // depending on the type of object... |
|
414 | - switch ($obj_class) { |
|
415 | - // no specifics just yet... |
|
416 | - default : |
|
417 | - $class = strtolower(str_replace('_', '-', $obj_class)); |
|
418 | - $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
419 | - |
|
420 | - } |
|
421 | - } |
|
422 | - return $prefix . $class . $suffix; |
|
423 | - } |
|
424 | - |
|
425 | - |
|
426 | - |
|
427 | - /** |
|
428 | - * EEH_Template::format_currency |
|
429 | - * This helper takes a raw float value and formats it according to the default config country currency settings, or |
|
430 | - * the country currency settings from the supplied country ISO code |
|
431 | - * |
|
432 | - * @param float $amount raw money value |
|
433 | - * @param boolean $return_raw whether to return the formatted float value only with no currency sign or code |
|
434 | - * @param boolean $display_code whether to display the country code (USD). Default = TRUE |
|
435 | - * @param string $CNT_ISO 2 letter ISO code for a country |
|
436 | - * @param string $cur_code_span_class |
|
437 | - * @return string the html output for the formatted money value |
|
438 | - * @throws \EE_Error |
|
439 | - */ |
|
440 | - public static function format_currency( |
|
441 | - $amount = null, |
|
442 | - $return_raw = false, |
|
443 | - $display_code = true, |
|
444 | - $CNT_ISO = '', |
|
445 | - $cur_code_span_class = 'currency-code' |
|
446 | - ) { |
|
447 | - // ensure amount was received |
|
448 | - if ($amount === null) { |
|
449 | - $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
450 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
451 | - return ''; |
|
452 | - } |
|
453 | - //ensure amount is float |
|
454 | - $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount); |
|
455 | - $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
456 | - // filter raw amount (allows 0.00 to be changed to "free" for example) |
|
457 | - $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
458 | - // still a number or was amount converted to a string like "free" ? |
|
459 | - if (is_float($amount_formatted)) { |
|
460 | - // was a country ISO code passed ? if so generate currency config object for that country |
|
461 | - $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
462 | - // verify results |
|
463 | - if ( ! $mny instanceof EE_Currency_Config) { |
|
464 | - // set default config country currency settings |
|
465 | - $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
466 | - ? EE_Registry::instance()->CFG->currency |
|
467 | - : new EE_Currency_Config(); |
|
468 | - } |
|
469 | - // format float |
|
470 | - $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
471 | - // add formatting ? |
|
472 | - if ( ! $return_raw) { |
|
473 | - // add currency sign |
|
474 | - if ($mny->sign_b4) { |
|
475 | - if ($amount >= 0) { |
|
476 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
477 | - } else { |
|
478 | - $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
479 | - } |
|
480 | - |
|
481 | - } else { |
|
482 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
483 | - } |
|
484 | - |
|
485 | - // filter to allow global setting of display_code |
|
486 | - $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
487 | - |
|
488 | - // add currency code ? |
|
489 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
490 | - } |
|
491 | - // filter results |
|
492 | - $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', |
|
493 | - $amount_formatted, $mny, $return_raw); |
|
494 | - } |
|
495 | - // clean up vars |
|
496 | - unset($mny); |
|
497 | - // return formatted currency amount |
|
498 | - return $amount_formatted; |
|
499 | - } |
|
500 | - |
|
501 | - |
|
502 | - /** |
|
503 | - * This function is used for outputting the localized label for a given status id in the schema requested (and |
|
504 | - * possibly plural). The intended use of this function is only for cases where wanting a label outside of a |
|
505 | - * related status model or model object (i.e. in documentation etc.) |
|
506 | - * |
|
507 | - * @param string $status_id Status ID matching a registered status in the esp_status table. If there is no |
|
508 | - * match, then 'Unknown' will be returned. |
|
509 | - * @param boolean $plural Whether to return plural or not |
|
510 | - * @param string $schema 'UPPER', 'lower', or 'Sentence' |
|
511 | - * @return string The localized label for the status id. |
|
512 | - */ |
|
513 | - public static function pretty_status($status_id, $plural = false, $schema = 'upper') |
|
514 | - { |
|
515 | - /** @type EEM_Status $EEM_Status */ |
|
516 | - $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
517 | - $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, |
|
518 | - $schema); |
|
519 | - return $status[$status_id]; |
|
520 | - } |
|
521 | - |
|
522 | - |
|
523 | - /** |
|
524 | - * This helper just returns a button or link for the given parameters |
|
525 | - * |
|
526 | - * @param string $url the url for the link, note that `esc_url` will be called on it |
|
527 | - * @param string $label What is the label you want displayed for the button |
|
528 | - * @param string $class what class is used for the button (defaults to 'button-primary') |
|
529 | - * @param string $icon |
|
530 | - * @param string $title |
|
531 | - * @return string the html output for the button |
|
532 | - */ |
|
533 | - public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') |
|
534 | - { |
|
535 | - $icon_html = ''; |
|
536 | - if ( ! empty($icon)) { |
|
537 | - $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
538 | - $dashicons = array_filter($dashicons); |
|
539 | - $count = count($dashicons); |
|
540 | - $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
|
541 | - foreach ($dashicons as $dashicon) { |
|
542 | - $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
543 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
544 | - } |
|
545 | - $icon_html .= $count > 1 ? '</span>' : ''; |
|
546 | - } |
|
547 | - $label = ! empty($icon) ? $icon_html . $label : $label; |
|
548 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
549 | - return $button; |
|
550 | - } |
|
551 | - |
|
552 | - |
|
553 | - /** |
|
554 | - * This returns a generated link that will load the related help tab on admin pages. |
|
555 | - * |
|
556 | - * @param string $help_tab_id the id for the connected help tab |
|
557 | - * @param bool|string $page The page identifier for the page the help tab is on |
|
558 | - * @param bool|string $action The action (route) for the admin page the help tab is on. |
|
559 | - * @param bool|string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
560 | - * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
|
561 | - * @return string generated link |
|
562 | - */ |
|
563 | - public static function get_help_tab_link( |
|
564 | - $help_tab_id, |
|
565 | - $page = false, |
|
566 | - $action = false, |
|
567 | - $icon_style = false, |
|
568 | - $help_text = false |
|
569 | - ) { |
|
570 | - |
|
571 | - if ( ! $page) { |
|
572 | - $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
573 | - } |
|
574 | - |
|
575 | - if ( ! $action) { |
|
576 | - $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
577 | - } |
|
578 | - |
|
579 | - $action = empty($action) ? 'default' : $action; |
|
580 | - |
|
581 | - |
|
582 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
583 | - $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
584 | - $help_text = ! $help_text ? '' : $help_text; |
|
585 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
586 | - 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
587 | - } |
|
588 | - |
|
589 | - |
|
590 | - /** |
|
591 | - * This helper generates the html structure for the jquery joyride plugin with the given params. |
|
592 | - * |
|
593 | - * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
594 | - * @see EE_Admin_Page->_stop_callback() for the construct expected for the $stops param. |
|
595 | - * @param EE_Help_Tour |
|
596 | - * @return string html |
|
597 | - */ |
|
598 | - public static function help_tour_stops_generator(EE_Help_Tour $tour) |
|
599 | - { |
|
600 | - $id = $tour->get_slug(); |
|
601 | - $stops = $tour->get_stops(); |
|
602 | - |
|
603 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
604 | - |
|
605 | - foreach ($stops as $stop) { |
|
606 | - $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
607 | - $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
608 | - |
|
609 | - //if container is set to modal then let's make sure we set the options accordingly |
|
610 | - if (empty($data_id) && empty($data_class)) { |
|
611 | - $stop['options']['modal'] = true; |
|
612 | - $stop['options']['expose'] = true; |
|
613 | - } |
|
614 | - |
|
615 | - $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
616 | - $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
617 | - $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
|
618 | - |
|
619 | - //options |
|
620 | - if (isset($stop['options']) && is_array($stop['options'])) { |
|
621 | - $options = ' data-options="'; |
|
622 | - foreach ($stop['options'] as $option => $value) { |
|
623 | - $options .= $option . ':' . $value . ';'; |
|
624 | - } |
|
625 | - $options .= '"'; |
|
626 | - } else { |
|
627 | - $options = ''; |
|
628 | - } |
|
629 | - |
|
630 | - //let's put all together |
|
631 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
632 | - } |
|
633 | - |
|
634 | - $content .= '</ol>'; |
|
635 | - return $content; |
|
636 | - } |
|
637 | - |
|
638 | - |
|
639 | - /** |
|
640 | - * This is a helper method to generate a status legend for a given status array. |
|
641 | - * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods |
|
642 | - * status_array. |
|
643 | - * |
|
644 | - * @param array $status_array array of statuses that will make up the legend. In format: |
|
645 | - * array( |
|
646 | - * 'status_item' => 'status_name' |
|
647 | - * ) |
|
648 | - * @param string $active_status This is used to indicate what the active status is IF that is to be highlighted in |
|
649 | - * the legend. |
|
650 | - * @throws EE_Error |
|
651 | - * @return string html structure for status. |
|
652 | - */ |
|
653 | - public static function status_legend($status_array, $active_status = '') |
|
654 | - { |
|
655 | - if ( ! is_array($status_array)) { |
|
656 | - throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', |
|
657 | - 'event_espresso')); |
|
658 | - } |
|
659 | - |
|
660 | - $setup_array = array(); |
|
661 | - foreach ($status_array as $item => $status) { |
|
662 | - $setup_array[$item] = array( |
|
663 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
664 | - 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
665 | - 'status' => $status, |
|
666 | - ); |
|
667 | - } |
|
668 | - |
|
669 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
670 | - $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
671 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
672 | - foreach ($setup_array as $item => $details) { |
|
673 | - $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
|
674 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
675 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
676 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
677 | - $content .= '</dt>' . "\n"; |
|
678 | - } |
|
679 | - $content .= '</dl>' . "\n"; |
|
680 | - $content .= '</div>' . "\n"; |
|
681 | - return $content; |
|
682 | - } |
|
683 | - |
|
684 | - |
|
685 | - /** |
|
686 | - * Gets HTML for laying out a deeply-nested array (and objects) in a format |
|
687 | - * that's nice for presenting in the wp admin |
|
688 | - * |
|
689 | - * @param mixed $data |
|
690 | - * @return string |
|
691 | - */ |
|
692 | - public static function layout_array_as_table($data) |
|
693 | - { |
|
694 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
695 | - $data = (array)$data; |
|
696 | - } |
|
697 | - ob_start(); |
|
698 | - if (is_array($data)) { |
|
699 | - if (EEH_Array::is_associative_array($data)) { |
|
700 | - ?> |
|
343 | + $template_path = false, |
|
344 | + $template_args = array(), |
|
345 | + $return_string = false, |
|
346 | + $throw_exceptions = false |
|
347 | + ) { |
|
348 | + |
|
349 | + /** |
|
350 | + * These two filters are intended for last minute changes to templates being loaded and/or template arg |
|
351 | + * modifications. NOTE... modifying these things can cause breakage as most templates running through |
|
352 | + * the display_template method are templates we DON'T want modified (usually because of js |
|
353 | + * dependencies etc). So unless you know what you are doing, do NOT filter templates or template args |
|
354 | + * using this. |
|
355 | + * |
|
356 | + * @since 4.6.0 |
|
357 | + */ |
|
358 | + $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path); |
|
359 | + $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args); |
|
360 | + |
|
361 | + // you gimme nuttin - YOU GET NUTTIN !! |
|
362 | + if ( ! $template_path || ! is_readable($template_path)) { |
|
363 | + return ''; |
|
364 | + } |
|
365 | + // if $template_args are not in an array, then make it so |
|
366 | + if ( ! is_array($template_args) && ! is_object($template_args)) { |
|
367 | + $template_args = array($template_args); |
|
368 | + } |
|
369 | + extract( $template_args, EXTR_SKIP ); |
|
370 | + // ignore whether template is accessible ? |
|
371 | + if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
372 | + throw new \DomainException( |
|
373 | + esc_html__( |
|
374 | + 'Invalid, unreadable, or missing file.', |
|
375 | + 'event_espresso' |
|
376 | + ) |
|
377 | + ); |
|
378 | + } |
|
379 | + |
|
380 | + |
|
381 | + if ($return_string) { |
|
382 | + // because we want to return a string, we are going to capture the output |
|
383 | + ob_start(); |
|
384 | + include($template_path); |
|
385 | + return ob_get_clean(); |
|
386 | + } else { |
|
387 | + include($template_path); |
|
388 | + } |
|
389 | + return ''; |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + * get_object_css_class - attempts to generate a css class based on the type of EE object passed |
|
395 | + * |
|
396 | + * @param EE_Base_Class $object the EE object the css class is being generated for |
|
397 | + * @param string $prefix added to the beginning of the generated class |
|
398 | + * @param string $suffix added to the end of the generated class |
|
399 | + * @return string |
|
400 | + */ |
|
401 | + public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
|
402 | + { |
|
403 | + // in the beginning... |
|
404 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
405 | + // da muddle |
|
406 | + $class = ''; |
|
407 | + // the end |
|
408 | + $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
409 | + // is the passed object an EE object ? |
|
410 | + if ($object instanceof EE_Base_Class) { |
|
411 | + // grab the exact type of object |
|
412 | + $obj_class = get_class($object); |
|
413 | + // depending on the type of object... |
|
414 | + switch ($obj_class) { |
|
415 | + // no specifics just yet... |
|
416 | + default : |
|
417 | + $class = strtolower(str_replace('_', '-', $obj_class)); |
|
418 | + $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
419 | + |
|
420 | + } |
|
421 | + } |
|
422 | + return $prefix . $class . $suffix; |
|
423 | + } |
|
424 | + |
|
425 | + |
|
426 | + |
|
427 | + /** |
|
428 | + * EEH_Template::format_currency |
|
429 | + * This helper takes a raw float value and formats it according to the default config country currency settings, or |
|
430 | + * the country currency settings from the supplied country ISO code |
|
431 | + * |
|
432 | + * @param float $amount raw money value |
|
433 | + * @param boolean $return_raw whether to return the formatted float value only with no currency sign or code |
|
434 | + * @param boolean $display_code whether to display the country code (USD). Default = TRUE |
|
435 | + * @param string $CNT_ISO 2 letter ISO code for a country |
|
436 | + * @param string $cur_code_span_class |
|
437 | + * @return string the html output for the formatted money value |
|
438 | + * @throws \EE_Error |
|
439 | + */ |
|
440 | + public static function format_currency( |
|
441 | + $amount = null, |
|
442 | + $return_raw = false, |
|
443 | + $display_code = true, |
|
444 | + $CNT_ISO = '', |
|
445 | + $cur_code_span_class = 'currency-code' |
|
446 | + ) { |
|
447 | + // ensure amount was received |
|
448 | + if ($amount === null) { |
|
449 | + $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso'); |
|
450 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
451 | + return ''; |
|
452 | + } |
|
453 | + //ensure amount is float |
|
454 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount); |
|
455 | + $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
|
456 | + // filter raw amount (allows 0.00 to be changed to "free" for example) |
|
457 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
|
458 | + // still a number or was amount converted to a string like "free" ? |
|
459 | + if (is_float($amount_formatted)) { |
|
460 | + // was a country ISO code passed ? if so generate currency config object for that country |
|
461 | + $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null; |
|
462 | + // verify results |
|
463 | + if ( ! $mny instanceof EE_Currency_Config) { |
|
464 | + // set default config country currency settings |
|
465 | + $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config |
|
466 | + ? EE_Registry::instance()->CFG->currency |
|
467 | + : new EE_Currency_Config(); |
|
468 | + } |
|
469 | + // format float |
|
470 | + $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds); |
|
471 | + // add formatting ? |
|
472 | + if ( ! $return_raw) { |
|
473 | + // add currency sign |
|
474 | + if ($mny->sign_b4) { |
|
475 | + if ($amount >= 0) { |
|
476 | + $amount_formatted = $mny->sign . $amount_formatted; |
|
477 | + } else { |
|
478 | + $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
479 | + } |
|
480 | + |
|
481 | + } else { |
|
482 | + $amount_formatted = $amount_formatted . $mny->sign; |
|
483 | + } |
|
484 | + |
|
485 | + // filter to allow global setting of display_code |
|
486 | + $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
|
487 | + |
|
488 | + // add currency code ? |
|
489 | + $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
490 | + } |
|
491 | + // filter results |
|
492 | + $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', |
|
493 | + $amount_formatted, $mny, $return_raw); |
|
494 | + } |
|
495 | + // clean up vars |
|
496 | + unset($mny); |
|
497 | + // return formatted currency amount |
|
498 | + return $amount_formatted; |
|
499 | + } |
|
500 | + |
|
501 | + |
|
502 | + /** |
|
503 | + * This function is used for outputting the localized label for a given status id in the schema requested (and |
|
504 | + * possibly plural). The intended use of this function is only for cases where wanting a label outside of a |
|
505 | + * related status model or model object (i.e. in documentation etc.) |
|
506 | + * |
|
507 | + * @param string $status_id Status ID matching a registered status in the esp_status table. If there is no |
|
508 | + * match, then 'Unknown' will be returned. |
|
509 | + * @param boolean $plural Whether to return plural or not |
|
510 | + * @param string $schema 'UPPER', 'lower', or 'Sentence' |
|
511 | + * @return string The localized label for the status id. |
|
512 | + */ |
|
513 | + public static function pretty_status($status_id, $plural = false, $schema = 'upper') |
|
514 | + { |
|
515 | + /** @type EEM_Status $EEM_Status */ |
|
516 | + $EEM_Status = EE_Registry::instance()->load_model('Status'); |
|
517 | + $status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, |
|
518 | + $schema); |
|
519 | + return $status[$status_id]; |
|
520 | + } |
|
521 | + |
|
522 | + |
|
523 | + /** |
|
524 | + * This helper just returns a button or link for the given parameters |
|
525 | + * |
|
526 | + * @param string $url the url for the link, note that `esc_url` will be called on it |
|
527 | + * @param string $label What is the label you want displayed for the button |
|
528 | + * @param string $class what class is used for the button (defaults to 'button-primary') |
|
529 | + * @param string $icon |
|
530 | + * @param string $title |
|
531 | + * @return string the html output for the button |
|
532 | + */ |
|
533 | + public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '') |
|
534 | + { |
|
535 | + $icon_html = ''; |
|
536 | + if ( ! empty($icon)) { |
|
537 | + $dashicons = preg_split("(ee-icon |dashicons )", $icon); |
|
538 | + $dashicons = array_filter($dashicons); |
|
539 | + $count = count($dashicons); |
|
540 | + $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
|
541 | + foreach ($dashicons as $dashicon) { |
|
542 | + $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
|
543 | + $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
544 | + } |
|
545 | + $icon_html .= $count > 1 ? '</span>' : ''; |
|
546 | + } |
|
547 | + $label = ! empty($icon) ? $icon_html . $label : $label; |
|
548 | + $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
549 | + return $button; |
|
550 | + } |
|
551 | + |
|
552 | + |
|
553 | + /** |
|
554 | + * This returns a generated link that will load the related help tab on admin pages. |
|
555 | + * |
|
556 | + * @param string $help_tab_id the id for the connected help tab |
|
557 | + * @param bool|string $page The page identifier for the page the help tab is on |
|
558 | + * @param bool|string $action The action (route) for the admin page the help tab is on. |
|
559 | + * @param bool|string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
560 | + * @param bool|string $help_text (optional) send help text you want to use for the link if default not to be used |
|
561 | + * @return string generated link |
|
562 | + */ |
|
563 | + public static function get_help_tab_link( |
|
564 | + $help_tab_id, |
|
565 | + $page = false, |
|
566 | + $action = false, |
|
567 | + $icon_style = false, |
|
568 | + $help_text = false |
|
569 | + ) { |
|
570 | + |
|
571 | + if ( ! $page) { |
|
572 | + $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page; |
|
573 | + } |
|
574 | + |
|
575 | + if ( ! $action) { |
|
576 | + $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action; |
|
577 | + } |
|
578 | + |
|
579 | + $action = empty($action) ? 'default' : $action; |
|
580 | + |
|
581 | + |
|
582 | + $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
583 | + $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
|
584 | + $help_text = ! $help_text ? '' : $help_text; |
|
585 | + return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
586 | + 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
587 | + } |
|
588 | + |
|
589 | + |
|
590 | + /** |
|
591 | + * This helper generates the html structure for the jquery joyride plugin with the given params. |
|
592 | + * |
|
593 | + * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
594 | + * @see EE_Admin_Page->_stop_callback() for the construct expected for the $stops param. |
|
595 | + * @param EE_Help_Tour |
|
596 | + * @return string html |
|
597 | + */ |
|
598 | + public static function help_tour_stops_generator(EE_Help_Tour $tour) |
|
599 | + { |
|
600 | + $id = $tour->get_slug(); |
|
601 | + $stops = $tour->get_stops(); |
|
602 | + |
|
603 | + $content = '<ol style="display:none" id="' . $id . '">'; |
|
604 | + |
|
605 | + foreach ($stops as $stop) { |
|
606 | + $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
607 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
608 | + |
|
609 | + //if container is set to modal then let's make sure we set the options accordingly |
|
610 | + if (empty($data_id) && empty($data_class)) { |
|
611 | + $stop['options']['modal'] = true; |
|
612 | + $stop['options']['expose'] = true; |
|
613 | + } |
|
614 | + |
|
615 | + $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
616 | + $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
617 | + $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
|
618 | + |
|
619 | + //options |
|
620 | + if (isset($stop['options']) && is_array($stop['options'])) { |
|
621 | + $options = ' data-options="'; |
|
622 | + foreach ($stop['options'] as $option => $value) { |
|
623 | + $options .= $option . ':' . $value . ';'; |
|
624 | + } |
|
625 | + $options .= '"'; |
|
626 | + } else { |
|
627 | + $options = ''; |
|
628 | + } |
|
629 | + |
|
630 | + //let's put all together |
|
631 | + $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
632 | + } |
|
633 | + |
|
634 | + $content .= '</ol>'; |
|
635 | + return $content; |
|
636 | + } |
|
637 | + |
|
638 | + |
|
639 | + /** |
|
640 | + * This is a helper method to generate a status legend for a given status array. |
|
641 | + * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods |
|
642 | + * status_array. |
|
643 | + * |
|
644 | + * @param array $status_array array of statuses that will make up the legend. In format: |
|
645 | + * array( |
|
646 | + * 'status_item' => 'status_name' |
|
647 | + * ) |
|
648 | + * @param string $active_status This is used to indicate what the active status is IF that is to be highlighted in |
|
649 | + * the legend. |
|
650 | + * @throws EE_Error |
|
651 | + * @return string html structure for status. |
|
652 | + */ |
|
653 | + public static function status_legend($status_array, $active_status = '') |
|
654 | + { |
|
655 | + if ( ! is_array($status_array)) { |
|
656 | + throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', |
|
657 | + 'event_espresso')); |
|
658 | + } |
|
659 | + |
|
660 | + $setup_array = array(); |
|
661 | + foreach ($status_array as $item => $status) { |
|
662 | + $setup_array[$item] = array( |
|
663 | + 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
664 | + 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
|
665 | + 'status' => $status, |
|
666 | + ); |
|
667 | + } |
|
668 | + |
|
669 | + $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
670 | + $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
671 | + $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
672 | + foreach ($setup_array as $item => $details) { |
|
673 | + $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
|
674 | + $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
675 | + $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
676 | + $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
677 | + $content .= '</dt>' . "\n"; |
|
678 | + } |
|
679 | + $content .= '</dl>' . "\n"; |
|
680 | + $content .= '</div>' . "\n"; |
|
681 | + return $content; |
|
682 | + } |
|
683 | + |
|
684 | + |
|
685 | + /** |
|
686 | + * Gets HTML for laying out a deeply-nested array (and objects) in a format |
|
687 | + * that's nice for presenting in the wp admin |
|
688 | + * |
|
689 | + * @param mixed $data |
|
690 | + * @return string |
|
691 | + */ |
|
692 | + public static function layout_array_as_table($data) |
|
693 | + { |
|
694 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
695 | + $data = (array)$data; |
|
696 | + } |
|
697 | + ob_start(); |
|
698 | + if (is_array($data)) { |
|
699 | + if (EEH_Array::is_associative_array($data)) { |
|
700 | + ?> |
|
701 | 701 | <table class="widefat"> |
702 | 702 | <tbody> |
703 | 703 | <?php |
704 | - foreach ($data as $data_key => $data_values) { |
|
705 | - ?> |
|
704 | + foreach ($data as $data_key => $data_values) { |
|
705 | + ?> |
|
706 | 706 | <tr> |
707 | 707 | <td> |
708 | 708 | <?php echo $data_key; ?> |
@@ -712,248 +712,248 @@ discard block |
||
712 | 712 | </td> |
713 | 713 | </tr> |
714 | 714 | <?php |
715 | - } ?> |
|
715 | + } ?> |
|
716 | 716 | </tbody> |
717 | 717 | </table> |
718 | 718 | <?php |
719 | - } else { |
|
720 | - ?> |
|
719 | + } else { |
|
720 | + ?> |
|
721 | 721 | <ul> |
722 | 722 | <?php |
723 | - foreach ($data as $datum) { |
|
724 | - echo "<li>"; |
|
725 | - echo self::layout_array_as_table($datum); |
|
726 | - echo "</li>"; |
|
727 | - } ?> |
|
723 | + foreach ($data as $datum) { |
|
724 | + echo "<li>"; |
|
725 | + echo self::layout_array_as_table($datum); |
|
726 | + echo "</li>"; |
|
727 | + } ?> |
|
728 | 728 | </ul> |
729 | 729 | <?php |
730 | - } |
|
731 | - } else { |
|
732 | - //simple value |
|
733 | - echo esc_html($data); |
|
734 | - } |
|
735 | - return ob_get_clean(); |
|
736 | - } |
|
737 | - |
|
738 | - |
|
739 | - /** |
|
740 | - * wrapper for self::get_paging_html() that simply echos the generated paging html |
|
741 | - * |
|
742 | - * @since 4.4.0 |
|
743 | - * @see self:get_paging_html() for argument docs. |
|
744 | - * @param $total_items |
|
745 | - * @param $current |
|
746 | - * @param $per_page |
|
747 | - * @param $url |
|
748 | - * @param bool $show_num_field |
|
749 | - * @param string $paged_arg_name |
|
750 | - * @param array $items_label |
|
751 | - * @return string |
|
752 | - */ |
|
753 | - public static function paging_html( |
|
754 | - $total_items, |
|
755 | - $current, |
|
756 | - $per_page, |
|
757 | - $url, |
|
758 | - $show_num_field = true, |
|
759 | - $paged_arg_name = 'paged', |
|
760 | - $items_label = array() |
|
761 | - ) { |
|
762 | - echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, |
|
763 | - $items_label); |
|
764 | - } |
|
765 | - |
|
766 | - |
|
767 | - /** |
|
768 | - * A method for generating paging similar to WP_List_Table |
|
769 | - * |
|
770 | - * @since 4.4.0 |
|
771 | - * @see wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination() |
|
772 | - * @param integer $total_items How many total items there are to page. |
|
773 | - * @param integer $current What the current page is. |
|
774 | - * @param integer $per_page How many items per page. |
|
775 | - * @param string $url What the base url for page links is. |
|
776 | - * @param boolean $show_num_field Whether to show the input for changing page number. |
|
777 | - * @param string $paged_arg_name The name of the key for the paged query argument. |
|
778 | - * @param array $items_label An array of singular/plural values for the items label: |
|
779 | - * array( |
|
780 | - * 'single' => 'item', |
|
781 | - * 'plural' => 'items' |
|
782 | - * ) |
|
783 | - * @return string |
|
784 | - */ |
|
785 | - public static function get_paging_html( |
|
786 | - $total_items, |
|
787 | - $current, |
|
788 | - $per_page, |
|
789 | - $url, |
|
790 | - $show_num_field = true, |
|
791 | - $paged_arg_name = 'paged', |
|
792 | - $items_label = array() |
|
793 | - ) { |
|
794 | - $page_links = array(); |
|
795 | - $disable_first = $disable_last = ''; |
|
796 | - $total_items = (int)$total_items; |
|
797 | - $per_page = (int)$per_page; |
|
798 | - $current = (int)$current; |
|
799 | - $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
800 | - |
|
801 | - //filter items_label |
|
802 | - $items_label = apply_filters( |
|
803 | - 'FHEE__EEH_Template__get_paging_html__items_label', |
|
804 | - $items_label |
|
805 | - ); |
|
806 | - |
|
807 | - if (empty($items_label) |
|
808 | - || ! is_array($items_label) |
|
809 | - || ! isset($items_label['single']) |
|
810 | - || ! isset($items_label['plural']) |
|
811 | - ) { |
|
812 | - $items_label = array( |
|
813 | - 'single' => __('1 item', 'event_espresso'), |
|
814 | - 'plural' => __('%s items', 'event_espresso'), |
|
815 | - ); |
|
816 | - } else { |
|
817 | - $items_label = array( |
|
818 | - 'single' => '1 ' . esc_html($items_label['single']), |
|
819 | - 'plural' => '%s ' . esc_html($items_label['plural']), |
|
820 | - ); |
|
821 | - } |
|
822 | - |
|
823 | - $total_pages = ceil($total_items / $per_page); |
|
824 | - |
|
825 | - if ($total_pages <= 1) { |
|
826 | - return ''; |
|
827 | - } |
|
828 | - |
|
829 | - $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
830 | - |
|
831 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
832 | - |
|
833 | - if ($current === 1) { |
|
834 | - $disable_first = ' disabled'; |
|
835 | - } |
|
836 | - if ($current == $total_pages) { |
|
837 | - $disable_last = ' disabled'; |
|
838 | - } |
|
839 | - |
|
840 | - $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
841 | - 'first-page' . $disable_first, |
|
842 | - esc_attr__('Go to the first page'), |
|
843 | - esc_url(remove_query_arg($paged_arg_name, $url)), |
|
844 | - '«' |
|
845 | - ); |
|
846 | - |
|
847 | - $page_links[] = sprintf( |
|
848 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
849 | - 'prev-page' . $disable_first, |
|
850 | - esc_attr__('Go to the previous page'), |
|
851 | - esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
852 | - '‹' |
|
853 | - ); |
|
854 | - |
|
855 | - if ( ! $show_num_field) { |
|
856 | - $html_current_page = $current; |
|
857 | - } else { |
|
858 | - $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
859 | - esc_attr__('Current page'), |
|
860 | - $current, |
|
861 | - strlen($total_pages) |
|
862 | - ); |
|
863 | - } |
|
864 | - |
|
865 | - $html_total_pages = sprintf( |
|
866 | - '<span class="total-pages">%s</span>', |
|
867 | - number_format_i18n($total_pages) |
|
868 | - ); |
|
869 | - $page_links[] = sprintf( |
|
870 | - _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
871 | - $html_current_page, |
|
872 | - $html_total_pages, |
|
873 | - '<span class="paging-input">', |
|
874 | - '</span>' |
|
875 | - ); |
|
876 | - |
|
877 | - $page_links[] = sprintf( |
|
878 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
879 | - 'next-page' . $disable_last, |
|
880 | - esc_attr__('Go to the next page'), |
|
881 | - esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
882 | - '›' |
|
883 | - ); |
|
884 | - |
|
885 | - $page_links[] = sprintf( |
|
886 | - '<a class="%s" title="%s" href="%s">%s</a>', |
|
887 | - 'last-page' . $disable_last, |
|
888 | - esc_attr__('Go to the last page'), |
|
889 | - esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
890 | - '»' |
|
891 | - ); |
|
892 | - |
|
893 | - $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
894 | - // set page class |
|
895 | - if ($total_pages) { |
|
896 | - $page_class = $total_pages < 2 ? ' one-page' : ''; |
|
897 | - } else { |
|
898 | - $page_class = ' no-pages'; |
|
899 | - } |
|
900 | - |
|
901 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
902 | - } |
|
903 | - |
|
904 | - |
|
905 | - /** |
|
906 | - * @param string $wrap_class |
|
907 | - * @param string $wrap_id |
|
908 | - * @return string |
|
909 | - */ |
|
910 | - public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array()) |
|
911 | - { |
|
912 | - $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
913 | - if ( |
|
914 | - ! $admin && |
|
915 | - ! apply_filters( |
|
916 | - 'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer', |
|
917 | - EE_Registry::instance()->CFG->admin->show_reg_footer |
|
918 | - ) |
|
919 | - ) { |
|
920 | - return ''; |
|
921 | - } |
|
922 | - $tag = $admin ? 'span' : 'div'; |
|
923 | - $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
924 | - $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
|
925 | - $attributes .= ! empty($wrap_class) |
|
926 | - ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
|
927 | - : ' class="powered-by-event-espresso-credit"'; |
|
928 | - $query_args = array_merge( |
|
929 | - array( |
|
930 | - 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id(), |
|
931 | - 'utm_source' => 'powered_by_event_espresso', |
|
932 | - 'utm_medium' => 'link', |
|
933 | - 'utm_campaign' => 'powered_by', |
|
934 | - ), |
|
935 | - $query_args |
|
936 | - ); |
|
937 | - $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
|
938 | - $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
939 | - $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
|
940 | - $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
941 | - return (string)apply_filters( |
|
942 | - 'FHEE__EEH_Template__powered_by_event_espresso__html', |
|
943 | - sprintf( |
|
944 | - esc_html_x( |
|
945 | - '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s', |
|
946 | - 'Online event registration and ticketing powered by [link to eventespresso.com]', |
|
947 | - 'event_espresso' |
|
948 | - ), |
|
949 | - "<{$tag}{$attributes}>", |
|
950 | - "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>", |
|
951 | - $admin ? '' : '<br />' |
|
952 | - ), |
|
953 | - $wrap_class, |
|
954 | - $wrap_id |
|
955 | - ); |
|
956 | - } |
|
730 | + } |
|
731 | + } else { |
|
732 | + //simple value |
|
733 | + echo esc_html($data); |
|
734 | + } |
|
735 | + return ob_get_clean(); |
|
736 | + } |
|
737 | + |
|
738 | + |
|
739 | + /** |
|
740 | + * wrapper for self::get_paging_html() that simply echos the generated paging html |
|
741 | + * |
|
742 | + * @since 4.4.0 |
|
743 | + * @see self:get_paging_html() for argument docs. |
|
744 | + * @param $total_items |
|
745 | + * @param $current |
|
746 | + * @param $per_page |
|
747 | + * @param $url |
|
748 | + * @param bool $show_num_field |
|
749 | + * @param string $paged_arg_name |
|
750 | + * @param array $items_label |
|
751 | + * @return string |
|
752 | + */ |
|
753 | + public static function paging_html( |
|
754 | + $total_items, |
|
755 | + $current, |
|
756 | + $per_page, |
|
757 | + $url, |
|
758 | + $show_num_field = true, |
|
759 | + $paged_arg_name = 'paged', |
|
760 | + $items_label = array() |
|
761 | + ) { |
|
762 | + echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, |
|
763 | + $items_label); |
|
764 | + } |
|
765 | + |
|
766 | + |
|
767 | + /** |
|
768 | + * A method for generating paging similar to WP_List_Table |
|
769 | + * |
|
770 | + * @since 4.4.0 |
|
771 | + * @see wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination() |
|
772 | + * @param integer $total_items How many total items there are to page. |
|
773 | + * @param integer $current What the current page is. |
|
774 | + * @param integer $per_page How many items per page. |
|
775 | + * @param string $url What the base url for page links is. |
|
776 | + * @param boolean $show_num_field Whether to show the input for changing page number. |
|
777 | + * @param string $paged_arg_name The name of the key for the paged query argument. |
|
778 | + * @param array $items_label An array of singular/plural values for the items label: |
|
779 | + * array( |
|
780 | + * 'single' => 'item', |
|
781 | + * 'plural' => 'items' |
|
782 | + * ) |
|
783 | + * @return string |
|
784 | + */ |
|
785 | + public static function get_paging_html( |
|
786 | + $total_items, |
|
787 | + $current, |
|
788 | + $per_page, |
|
789 | + $url, |
|
790 | + $show_num_field = true, |
|
791 | + $paged_arg_name = 'paged', |
|
792 | + $items_label = array() |
|
793 | + ) { |
|
794 | + $page_links = array(); |
|
795 | + $disable_first = $disable_last = ''; |
|
796 | + $total_items = (int)$total_items; |
|
797 | + $per_page = (int)$per_page; |
|
798 | + $current = (int)$current; |
|
799 | + $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
|
800 | + |
|
801 | + //filter items_label |
|
802 | + $items_label = apply_filters( |
|
803 | + 'FHEE__EEH_Template__get_paging_html__items_label', |
|
804 | + $items_label |
|
805 | + ); |
|
806 | + |
|
807 | + if (empty($items_label) |
|
808 | + || ! is_array($items_label) |
|
809 | + || ! isset($items_label['single']) |
|
810 | + || ! isset($items_label['plural']) |
|
811 | + ) { |
|
812 | + $items_label = array( |
|
813 | + 'single' => __('1 item', 'event_espresso'), |
|
814 | + 'plural' => __('%s items', 'event_espresso'), |
|
815 | + ); |
|
816 | + } else { |
|
817 | + $items_label = array( |
|
818 | + 'single' => '1 ' . esc_html($items_label['single']), |
|
819 | + 'plural' => '%s ' . esc_html($items_label['plural']), |
|
820 | + ); |
|
821 | + } |
|
822 | + |
|
823 | + $total_pages = ceil($total_items / $per_page); |
|
824 | + |
|
825 | + if ($total_pages <= 1) { |
|
826 | + return ''; |
|
827 | + } |
|
828 | + |
|
829 | + $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
|
830 | + |
|
831 | + $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
832 | + |
|
833 | + if ($current === 1) { |
|
834 | + $disable_first = ' disabled'; |
|
835 | + } |
|
836 | + if ($current == $total_pages) { |
|
837 | + $disable_last = ' disabled'; |
|
838 | + } |
|
839 | + |
|
840 | + $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
|
841 | + 'first-page' . $disable_first, |
|
842 | + esc_attr__('Go to the first page'), |
|
843 | + esc_url(remove_query_arg($paged_arg_name, $url)), |
|
844 | + '«' |
|
845 | + ); |
|
846 | + |
|
847 | + $page_links[] = sprintf( |
|
848 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
849 | + 'prev-page' . $disable_first, |
|
850 | + esc_attr__('Go to the previous page'), |
|
851 | + esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
|
852 | + '‹' |
|
853 | + ); |
|
854 | + |
|
855 | + if ( ! $show_num_field) { |
|
856 | + $html_current_page = $current; |
|
857 | + } else { |
|
858 | + $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />", |
|
859 | + esc_attr__('Current page'), |
|
860 | + $current, |
|
861 | + strlen($total_pages) |
|
862 | + ); |
|
863 | + } |
|
864 | + |
|
865 | + $html_total_pages = sprintf( |
|
866 | + '<span class="total-pages">%s</span>', |
|
867 | + number_format_i18n($total_pages) |
|
868 | + ); |
|
869 | + $page_links[] = sprintf( |
|
870 | + _x('%3$s%1$s of %2$s%4$s', 'paging'), |
|
871 | + $html_current_page, |
|
872 | + $html_total_pages, |
|
873 | + '<span class="paging-input">', |
|
874 | + '</span>' |
|
875 | + ); |
|
876 | + |
|
877 | + $page_links[] = sprintf( |
|
878 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
879 | + 'next-page' . $disable_last, |
|
880 | + esc_attr__('Go to the next page'), |
|
881 | + esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
|
882 | + '›' |
|
883 | + ); |
|
884 | + |
|
885 | + $page_links[] = sprintf( |
|
886 | + '<a class="%s" title="%s" href="%s">%s</a>', |
|
887 | + 'last-page' . $disable_last, |
|
888 | + esc_attr__('Go to the last page'), |
|
889 | + esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
|
890 | + '»' |
|
891 | + ); |
|
892 | + |
|
893 | + $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
894 | + // set page class |
|
895 | + if ($total_pages) { |
|
896 | + $page_class = $total_pages < 2 ? ' one-page' : ''; |
|
897 | + } else { |
|
898 | + $page_class = ' no-pages'; |
|
899 | + } |
|
900 | + |
|
901 | + return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
902 | + } |
|
903 | + |
|
904 | + |
|
905 | + /** |
|
906 | + * @param string $wrap_class |
|
907 | + * @param string $wrap_id |
|
908 | + * @return string |
|
909 | + */ |
|
910 | + public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array()) |
|
911 | + { |
|
912 | + $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX); |
|
913 | + if ( |
|
914 | + ! $admin && |
|
915 | + ! apply_filters( |
|
916 | + 'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer', |
|
917 | + EE_Registry::instance()->CFG->admin->show_reg_footer |
|
918 | + ) |
|
919 | + ) { |
|
920 | + return ''; |
|
921 | + } |
|
922 | + $tag = $admin ? 'span' : 'div'; |
|
923 | + $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : ''; |
|
924 | + $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class; |
|
925 | + $attributes .= ! empty($wrap_class) |
|
926 | + ? " class=\"{$wrap_class} powered-by-event-espresso-credit\"" |
|
927 | + : ' class="powered-by-event-espresso-credit"'; |
|
928 | + $query_args = array_merge( |
|
929 | + array( |
|
930 | + 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id(), |
|
931 | + 'utm_source' => 'powered_by_event_espresso', |
|
932 | + 'utm_medium' => 'link', |
|
933 | + 'utm_campaign' => 'powered_by', |
|
934 | + ), |
|
935 | + $query_args |
|
936 | + ); |
|
937 | + $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
|
938 | + $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
939 | + $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
|
940 | + $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
|
941 | + return (string)apply_filters( |
|
942 | + 'FHEE__EEH_Template__powered_by_event_espresso__html', |
|
943 | + sprintf( |
|
944 | + esc_html_x( |
|
945 | + '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s', |
|
946 | + 'Online event registration and ticketing powered by [link to eventespresso.com]', |
|
947 | + 'event_espresso' |
|
948 | + ), |
|
949 | + "<{$tag}{$attributes}>", |
|
950 | + "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>", |
|
951 | + $admin ? '' : '<br />' |
|
952 | + ), |
|
953 | + $wrap_class, |
|
954 | + $wrap_id |
|
955 | + ); |
|
956 | + } |
|
957 | 957 | |
958 | 958 | |
959 | 959 | } //end EEH_Template class |
@@ -962,33 +962,33 @@ discard block |
||
962 | 962 | |
963 | 963 | |
964 | 964 | if ( ! function_exists('espresso_pagination')) { |
965 | - /** |
|
966 | - * espresso_pagination |
|
967 | - * |
|
968 | - * @access public |
|
969 | - * @return void |
|
970 | - */ |
|
971 | - function espresso_pagination() |
|
972 | - { |
|
973 | - global $wp_query; |
|
974 | - $big = 999999999; // need an unlikely integer |
|
975 | - $pagination = paginate_links( |
|
976 | - array( |
|
977 | - 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
978 | - 'format' => '?paged=%#%', |
|
979 | - 'current' => max(1, get_query_var('paged')), |
|
980 | - 'total' => $wp_query->max_num_pages, |
|
981 | - 'show_all' => true, |
|
982 | - 'end_size' => 10, |
|
983 | - 'mid_size' => 6, |
|
984 | - 'prev_next' => true, |
|
985 | - 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
986 | - 'next_text' => __('NEXT ›', 'event_espresso'), |
|
987 | - 'type' => 'plain', |
|
988 | - 'add_args' => false, |
|
989 | - 'add_fragment' => '', |
|
990 | - ) |
|
991 | - ); |
|
992 | - echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : ''; |
|
993 | - } |
|
965 | + /** |
|
966 | + * espresso_pagination |
|
967 | + * |
|
968 | + * @access public |
|
969 | + * @return void |
|
970 | + */ |
|
971 | + function espresso_pagination() |
|
972 | + { |
|
973 | + global $wp_query; |
|
974 | + $big = 999999999; // need an unlikely integer |
|
975 | + $pagination = paginate_links( |
|
976 | + array( |
|
977 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
978 | + 'format' => '?paged=%#%', |
|
979 | + 'current' => max(1, get_query_var('paged')), |
|
980 | + 'total' => $wp_query->max_num_pages, |
|
981 | + 'show_all' => true, |
|
982 | + 'end_size' => 10, |
|
983 | + 'mid_size' => 6, |
|
984 | + 'prev_next' => true, |
|
985 | + 'prev_text' => __('‹ PREV', 'event_espresso'), |
|
986 | + 'next_text' => __('NEXT ›', 'event_espresso'), |
|
987 | + 'type' => 'plain', |
|
988 | + 'add_args' => false, |
|
989 | + 'add_fragment' => '', |
|
990 | + ) |
|
991 | + ); |
|
992 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : ''; |
|
993 | + } |
|
994 | 994 | } |
995 | 995 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | } |
5 | 5 | /** |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | public static function load_espresso_theme_functions() |
82 | 82 | { |
83 | 83 | if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) { |
84 | - if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) { |
|
85 | - require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php'); |
|
84 | + if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) { |
|
85 | + require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php'); |
|
86 | 86 | } |
87 | 87 | } |
88 | 88 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public static function get_espresso_themes() |
97 | 97 | { |
98 | 98 | if (empty(EEH_Template::$_espresso_themes)) { |
99 | - $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR); |
|
99 | + $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR); |
|
100 | 100 | if (empty($espresso_themes)) { |
101 | 101 | return array(); |
102 | 102 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | ) { |
133 | 133 | do_action("get_template_part_{$slug}-{$name}", $slug, $name); |
134 | 134 | $templates = array(); |
135 | - $name = (string)$name; |
|
135 | + $name = (string) $name; |
|
136 | 136 | if ($name != '') { |
137 | 137 | $templates[] = "{$slug}-{$name}.php"; |
138 | 138 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | if (isset($EE_CPTs[$post_type])) { |
212 | 212 | $archive_or_single = is_archive() ? 'archive' : ''; |
213 | 213 | $archive_or_single = is_single() ? 'single' : $archive_or_single; |
214 | - $templates = $archive_or_single . '-' . $post_type . '.php'; |
|
214 | + $templates = $archive_or_single.'-'.$post_type.'.php'; |
|
215 | 215 | } |
216 | 216 | } |
217 | 217 | // currently active EE template theme |
@@ -220,18 +220,18 @@ discard block |
||
220 | 220 | // array of paths to folders that may contain templates |
221 | 221 | $template_folder_paths = array( |
222 | 222 | // first check the /wp-content/uploads/espresso/templates/(current EE theme)/ folder for an EE theme template file |
223 | - EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme, |
|
223 | + EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme, |
|
224 | 224 | // then in the root of the /wp-content/uploads/espresso/templates/ folder |
225 | 225 | EVENT_ESPRESSO_TEMPLATE_DIR, |
226 | 226 | ); |
227 | 227 | |
228 | 228 | //add core plugin folders for checking only if we're not $check_if_custom |
229 | 229 | if ( ! $check_if_custom) { |
230 | - $core_paths = array( |
|
230 | + $core_paths = array( |
|
231 | 231 | // in the /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin |
232 | - EE_PUBLIC . $current_theme, |
|
232 | + EE_PUBLIC.$current_theme, |
|
233 | 233 | // in the /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin |
234 | - EE_TEMPLATES . $current_theme, |
|
234 | + EE_TEMPLATES.$current_theme, |
|
235 | 235 | // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/ |
236 | 236 | EE_PLUGIN_DIR_PATH, |
237 | 237 | ); |
@@ -262,10 +262,10 @@ discard block |
||
262 | 262 | ); |
263 | 263 | if ($common_base_path !== '') { |
264 | 264 | // both paths have a common base, so just tack the filename onto our search path |
265 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name; |
|
265 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name; |
|
266 | 266 | } else { |
267 | 267 | // no common base path, so let's just concatenate |
268 | - $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template; |
|
268 | + $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template; |
|
269 | 269 | } |
270 | 270 | // build up our template locations array by adding our resolved paths |
271 | 271 | $full_template_paths[] = $resolved_path; |
@@ -273,13 +273,13 @@ discard block |
||
273 | 273 | // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first |
274 | 274 | array_unshift($full_template_paths, $template); |
275 | 275 | // path to the directory of the current theme: /wp-content/themes/(current WP theme)/ |
276 | - array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name); |
|
276 | + array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name); |
|
277 | 277 | } |
278 | 278 | // filter final array of full template paths |
279 | 279 | $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', |
280 | 280 | $full_template_paths, $file_name); |
281 | 281 | // now loop through our final array of template location paths and check each location |
282 | - foreach ((array)$full_template_paths as $full_template_path) { |
|
282 | + foreach ((array) $full_template_paths as $full_template_path) { |
|
283 | 283 | if (is_readable($full_template_path)) { |
284 | 284 | $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path); |
285 | 285 | break; |
@@ -366,9 +366,9 @@ discard block |
||
366 | 366 | if ( ! is_array($template_args) && ! is_object($template_args)) { |
367 | 367 | $template_args = array($template_args); |
368 | 368 | } |
369 | - extract( $template_args, EXTR_SKIP ); |
|
369 | + extract($template_args, EXTR_SKIP); |
|
370 | 370 | // ignore whether template is accessible ? |
371 | - if ( $throw_exceptions && ! is_readable( $template_path ) ) { |
|
371 | + if ($throw_exceptions && ! is_readable($template_path)) { |
|
372 | 372 | throw new \DomainException( |
373 | 373 | esc_html__( |
374 | 374 | 'Invalid, unreadable, or missing file.', |
@@ -401,11 +401,11 @@ discard block |
||
401 | 401 | public static function get_object_css_class($object = null, $prefix = '', $suffix = '') |
402 | 402 | { |
403 | 403 | // in the beginning... |
404 | - $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : ''; |
|
404 | + $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : ''; |
|
405 | 405 | // da muddle |
406 | 406 | $class = ''; |
407 | 407 | // the end |
408 | - $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : ''; |
|
408 | + $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : ''; |
|
409 | 409 | // is the passed object an EE object ? |
410 | 410 | if ($object instanceof EE_Base_Class) { |
411 | 411 | // grab the exact type of object |
@@ -415,11 +415,11 @@ discard block |
||
415 | 415 | // no specifics just yet... |
416 | 416 | default : |
417 | 417 | $class = strtolower(str_replace('_', '-', $obj_class)); |
418 | - $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : ''; |
|
418 | + $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : ''; |
|
419 | 419 | |
420 | 420 | } |
421 | 421 | } |
422 | - return $prefix . $class . $suffix; |
|
422 | + return $prefix.$class.$suffix; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | return ''; |
452 | 452 | } |
453 | 453 | //ensure amount is float |
454 | - $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount); |
|
454 | + $amount = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount); |
|
455 | 455 | $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount); |
456 | 456 | // filter raw amount (allows 0.00 to be changed to "free" for example) |
457 | 457 | $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw); |
@@ -473,20 +473,20 @@ discard block |
||
473 | 473 | // add currency sign |
474 | 474 | if ($mny->sign_b4) { |
475 | 475 | if ($amount >= 0) { |
476 | - $amount_formatted = $mny->sign . $amount_formatted; |
|
476 | + $amount_formatted = $mny->sign.$amount_formatted; |
|
477 | 477 | } else { |
478 | - $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted); |
|
478 | + $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | } else { |
482 | - $amount_formatted = $amount_formatted . $mny->sign; |
|
482 | + $amount_formatted = $amount_formatted.$mny->sign; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | // filter to allow global setting of display_code |
486 | 486 | $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code); |
487 | 487 | |
488 | 488 | // add currency code ? |
489 | - $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted; |
|
489 | + $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted; |
|
490 | 490 | } |
491 | 491 | // filter results |
492 | 492 | $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', |
@@ -540,12 +540,12 @@ discard block |
||
540 | 540 | $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : ''; |
541 | 541 | foreach ($dashicons as $dashicon) { |
542 | 542 | $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons '; |
543 | - $icon_html .= '<span class="' . $type . $dashicon . '"></span>'; |
|
543 | + $icon_html .= '<span class="'.$type.$dashicon.'"></span>'; |
|
544 | 544 | } |
545 | 545 | $icon_html .= $count > 1 ? '</span>' : ''; |
546 | 546 | } |
547 | - $label = ! empty($icon) ? $icon_html . $label : $label; |
|
548 | - $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . esc_url($url) . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>'; |
|
547 | + $label = ! empty($icon) ? $icon_html.$label : $label; |
|
548 | + $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.esc_url($url).'" class="'.$class.'" title="'.$title.'">'.$label.'</a>'; |
|
549 | 549 | return $button; |
550 | 550 | } |
551 | 551 | |
@@ -579,11 +579,11 @@ discard block |
||
579 | 579 | $action = empty($action) ? 'default' : $action; |
580 | 580 | |
581 | 581 | |
582 | - $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id; |
|
582 | + $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id; |
|
583 | 583 | $icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style; |
584 | 584 | $help_text = ! $help_text ? '' : $help_text; |
585 | - return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
586 | - 'event_espresso') . '" > ' . $help_text . ' </a>'; |
|
585 | + return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', |
|
586 | + 'event_espresso').'" > '.$help_text.' </a>'; |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | |
@@ -600,11 +600,11 @@ discard block |
||
600 | 600 | $id = $tour->get_slug(); |
601 | 601 | $stops = $tour->get_stops(); |
602 | 602 | |
603 | - $content = '<ol style="display:none" id="' . $id . '">'; |
|
603 | + $content = '<ol style="display:none" id="'.$id.'">'; |
|
604 | 604 | |
605 | 605 | foreach ($stops as $stop) { |
606 | - $data_id = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : ''; |
|
607 | - $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : ''; |
|
606 | + $data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : ''; |
|
607 | + $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : ''; |
|
608 | 608 | |
609 | 609 | //if container is set to modal then let's make sure we set the options accordingly |
610 | 610 | if (empty($data_id) && empty($data_class)) { |
@@ -612,15 +612,15 @@ discard block |
||
612 | 612 | $stop['options']['expose'] = true; |
613 | 613 | } |
614 | 614 | |
615 | - $custom_class = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : ''; |
|
616 | - $button_text = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : ''; |
|
615 | + $custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : ''; |
|
616 | + $button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : ''; |
|
617 | 617 | $inner_content = isset($stop['content']) ? $stop['content'] : ''; |
618 | 618 | |
619 | 619 | //options |
620 | 620 | if (isset($stop['options']) && is_array($stop['options'])) { |
621 | 621 | $options = ' data-options="'; |
622 | 622 | foreach ($stop['options'] as $option => $value) { |
623 | - $options .= $option . ':' . $value . ';'; |
|
623 | + $options .= $option.':'.$value.';'; |
|
624 | 624 | } |
625 | 625 | $options .= '"'; |
626 | 626 | } else { |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | } |
629 | 629 | |
630 | 630 | //let's put all together |
631 | - $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>'; |
|
631 | + $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>'; |
|
632 | 632 | } |
633 | 633 | |
634 | 634 | $content .= '</ol>'; |
@@ -660,24 +660,24 @@ discard block |
||
660 | 660 | $setup_array = array(); |
661 | 661 | foreach ($status_array as $item => $status) { |
662 | 662 | $setup_array[$item] = array( |
663 | - 'class' => 'ee-status-legend ee-status-legend-' . $status, |
|
663 | + 'class' => 'ee-status-legend ee-status-legend-'.$status, |
|
664 | 664 | 'desc' => EEH_Template::pretty_status($status, false, 'sentence'), |
665 | 665 | 'status' => $status, |
666 | 666 | ); |
667 | 667 | } |
668 | 668 | |
669 | - $content = '<div class="ee-list-table-legend-container">' . "\n"; |
|
670 | - $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n"; |
|
671 | - $content .= '<dl class="ee-list-table-legend">' . "\n\t"; |
|
669 | + $content = '<div class="ee-list-table-legend-container">'."\n"; |
|
670 | + $content .= '<h4 class="status-legend-title">'.esc_html__('Status Legend', 'event_espresso').'</h4>'."\n"; |
|
671 | + $content .= '<dl class="ee-list-table-legend">'."\n\t"; |
|
672 | 672 | foreach ($setup_array as $item => $details) { |
673 | 673 | $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : ''; |
674 | - $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t"; |
|
675 | - $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t"; |
|
676 | - $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t"; |
|
677 | - $content .= '</dt>' . "\n"; |
|
674 | + $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t"; |
|
675 | + $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t"; |
|
676 | + $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t"; |
|
677 | + $content .= '</dt>'."\n"; |
|
678 | 678 | } |
679 | - $content .= '</dl>' . "\n"; |
|
680 | - $content .= '</div>' . "\n"; |
|
679 | + $content .= '</dl>'."\n"; |
|
680 | + $content .= '</div>'."\n"; |
|
681 | 681 | return $content; |
682 | 682 | } |
683 | 683 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | public static function layout_array_as_table($data) |
693 | 693 | { |
694 | 694 | if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
695 | - $data = (array)$data; |
|
695 | + $data = (array) $data; |
|
696 | 696 | } |
697 | 697 | ob_start(); |
698 | 698 | if (is_array($data)) { |
@@ -793,9 +793,9 @@ discard block |
||
793 | 793 | ) { |
794 | 794 | $page_links = array(); |
795 | 795 | $disable_first = $disable_last = ''; |
796 | - $total_items = (int)$total_items; |
|
797 | - $per_page = (int)$per_page; |
|
798 | - $current = (int)$current; |
|
796 | + $total_items = (int) $total_items; |
|
797 | + $per_page = (int) $per_page; |
|
798 | + $current = (int) $current; |
|
799 | 799 | $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name); |
800 | 800 | |
801 | 801 | //filter items_label |
@@ -815,8 +815,8 @@ discard block |
||
815 | 815 | ); |
816 | 816 | } else { |
817 | 817 | $items_label = array( |
818 | - 'single' => '1 ' . esc_html($items_label['single']), |
|
819 | - 'plural' => '%s ' . esc_html($items_label['plural']), |
|
818 | + 'single' => '1 '.esc_html($items_label['single']), |
|
819 | + 'plural' => '%s '.esc_html($items_label['plural']), |
|
820 | 820 | ); |
821 | 821 | } |
822 | 822 | |
@@ -828,7 +828,7 @@ discard block |
||
828 | 828 | |
829 | 829 | $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single']; |
830 | 830 | |
831 | - $output = '<span class="displaying-num">' . $item_label . '</span>'; |
|
831 | + $output = '<span class="displaying-num">'.$item_label.'</span>'; |
|
832 | 832 | |
833 | 833 | if ($current === 1) { |
834 | 834 | $disable_first = ' disabled'; |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | } |
839 | 839 | |
840 | 840 | $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>", |
841 | - 'first-page' . $disable_first, |
|
841 | + 'first-page'.$disable_first, |
|
842 | 842 | esc_attr__('Go to the first page'), |
843 | 843 | esc_url(remove_query_arg($paged_arg_name, $url)), |
844 | 844 | '«' |
@@ -846,7 +846,7 @@ discard block |
||
846 | 846 | |
847 | 847 | $page_links[] = sprintf( |
848 | 848 | '<a class="%s" title="%s" href="%s">%s</a>', |
849 | - 'prev-page' . $disable_first, |
|
849 | + 'prev-page'.$disable_first, |
|
850 | 850 | esc_attr__('Go to the previous page'), |
851 | 851 | esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)), |
852 | 852 | '‹' |
@@ -866,7 +866,7 @@ discard block |
||
866 | 866 | '<span class="total-pages">%s</span>', |
867 | 867 | number_format_i18n($total_pages) |
868 | 868 | ); |
869 | - $page_links[] = sprintf( |
|
869 | + $page_links[] = sprintf( |
|
870 | 870 | _x('%3$s%1$s of %2$s%4$s', 'paging'), |
871 | 871 | $html_current_page, |
872 | 872 | $html_total_pages, |
@@ -876,7 +876,7 @@ discard block |
||
876 | 876 | |
877 | 877 | $page_links[] = sprintf( |
878 | 878 | '<a class="%s" title="%s" href="%s">%s</a>', |
879 | - 'next-page' . $disable_last, |
|
879 | + 'next-page'.$disable_last, |
|
880 | 880 | esc_attr__('Go to the next page'), |
881 | 881 | esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)), |
882 | 882 | '›' |
@@ -884,13 +884,13 @@ discard block |
||
884 | 884 | |
885 | 885 | $page_links[] = sprintf( |
886 | 886 | '<a class="%s" title="%s" href="%s">%s</a>', |
887 | - 'last-page' . $disable_last, |
|
887 | + 'last-page'.$disable_last, |
|
888 | 888 | esc_attr__('Go to the last page'), |
889 | 889 | esc_url(add_query_arg($paged_arg_name, $total_pages, $url)), |
890 | 890 | '»' |
891 | 891 | ); |
892 | 892 | |
893 | - $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>'; |
|
893 | + $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>'; |
|
894 | 894 | // set page class |
895 | 895 | if ($total_pages) { |
896 | 896 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | $page_class = ' no-pages'; |
899 | 899 | } |
900 | 900 | |
901 | - return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>'; |
|
901 | + return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>'; |
|
902 | 902 | } |
903 | 903 | |
904 | 904 | |
@@ -935,10 +935,10 @@ discard block |
||
935 | 935 | $query_args |
936 | 936 | ); |
937 | 937 | $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text', |
938 | - $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
938 | + $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso'); |
|
939 | 939 | $url = add_query_arg($query_args, 'https://eventespresso.com/'); |
940 | 940 | $url = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url); |
941 | - return (string)apply_filters( |
|
941 | + return (string) apply_filters( |
|
942 | 942 | 'FHEE__EEH_Template__powered_by_event_espresso__html', |
943 | 943 | sprintf( |
944 | 944 | esc_html_x( |
@@ -989,6 +989,6 @@ discard block |
||
989 | 989 | 'add_fragment' => '', |
990 | 990 | ) |
991 | 991 | ); |
992 | - echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : ''; |
|
992 | + echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : ''; |
|
993 | 993 | } |
994 | 994 | } |
995 | 995 | \ No newline at end of file |
@@ -85,6 +85,11 @@ |
||
85 | 85 | public function count_units_to_process() { |
86 | 86 | return \EEM_Attendee::instance()->count( array( 'caps' => \EEM_Base::caps_read_admin )); |
87 | 87 | } |
88 | + |
|
89 | + /** |
|
90 | + * @param integer $offset |
|
91 | + * @param integer $limit |
|
92 | + */ |
|
88 | 93 | public function get_csv_data( $offset, $limit ) { |
89 | 94 | $attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results( |
90 | 95 | array( |
@@ -108,10 +108,10 @@ |
||
108 | 108 | } |
109 | 109 | } |
110 | 110 | $csv_data[] = apply_filters( |
111 | - 'FHEE___EventEspresso_core_libraries_batch_JobHandlers_AttendeesReport__get_csv_data__row', |
|
112 | - $csv_row, |
|
113 | - $attendee_row |
|
114 | - ); |
|
111 | + 'FHEE___EventEspresso_core_libraries_batch_JobHandlers_AttendeesReport__get_csv_data__row', |
|
112 | + $csv_row, |
|
113 | + $attendee_row |
|
114 | + ); |
|
115 | 115 | } |
116 | 116 | return $csv_data; |
117 | 117 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | use EventEspressoBatchRequest\Helpers\JobParameters; |
19 | 19 | use EventEspressoBatchRequest\Helpers\JobStepResponse; |
20 | 20 | |
21 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
21 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
22 | 22 | exit('No direct script access allowed'); |
23 | 23 | } |
24 | 24 | |
@@ -27,84 +27,84 @@ discard block |
||
27 | 27 | |
28 | 28 | |
29 | 29 | public function create_job(JobParameters $job_parameters) { |
30 | - if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_contacts', 'generating_report' ) ) { |
|
30 | + if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_contacts', 'generating_report')) { |
|
31 | 31 | throw new BatchRequestException( |
32 | - __( 'You do not have permission to view contacts', 'event_espresso') |
|
32 | + __('You do not have permission to view contacts', 'event_espresso') |
|
33 | 33 | ); |
34 | 34 | } |
35 | 35 | $filepath = $this->create_file_from_job_with_name( |
36 | 36 | $job_parameters->job_id(), |
37 | 37 | __('contact-list-report.csv', 'event_espresso') |
38 | 38 | ); |
39 | - $job_parameters->add_extra_data( 'filepath', $filepath ); |
|
40 | - $job_parameters->set_job_size( $this->count_units_to_process() ); |
|
39 | + $job_parameters->add_extra_data('filepath', $filepath); |
|
40 | + $job_parameters->set_job_size($this->count_units_to_process()); |
|
41 | 41 | //we should also set the header columns |
42 | - $csv_data_for_row = $this->get_csv_data( 0, 1 ); |
|
43 | - \EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true ); |
|
42 | + $csv_data_for_row = $this->get_csv_data(0, 1); |
|
43 | + \EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true); |
|
44 | 44 | //if we actually processed a row there, record it |
45 | - if( $job_parameters->job_size() ) { |
|
46 | - $job_parameters->mark_processed( 1 ); |
|
45 | + if ($job_parameters->job_size()) { |
|
46 | + $job_parameters->mark_processed(1); |
|
47 | 47 | } |
48 | 48 | return new JobStepResponse( |
49 | 49 | $job_parameters, |
50 | - __( 'Contacts report started successfully...', 'event_espresso' ) |
|
50 | + __('Contacts report started successfully...', 'event_espresso') |
|
51 | 51 | ); |
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public function continue_job(JobParameters $job_parameters, $batch_size = 50) { |
56 | - $csv_data = $this->get_csv_data( $job_parameters->units_processed(), $batch_size ); |
|
57 | - \EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false ); |
|
58 | - $units_processed = count( $csv_data ); |
|
59 | - $job_parameters->mark_processed( $units_processed ); |
|
56 | + $csv_data = $this->get_csv_data($job_parameters->units_processed(), $batch_size); |
|
57 | + \EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false); |
|
58 | + $units_processed = count($csv_data); |
|
59 | + $job_parameters->mark_processed($units_processed); |
|
60 | 60 | $extra_response_data = array( |
61 | 61 | 'file_url' => '' |
62 | 62 | ); |
63 | - if( $units_processed < $batch_size ) { |
|
64 | - $job_parameters->set_status( JobParameters::status_complete ); |
|
65 | - $extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) ); |
|
63 | + if ($units_processed < $batch_size) { |
|
64 | + $job_parameters->set_status(JobParameters::status_complete); |
|
65 | + $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath')); |
|
66 | 66 | } |
67 | 67 | return new JobStepResponse( |
68 | 68 | $job_parameters, |
69 | 69 | sprintf( |
70 | - __( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ), |
|
71 | - count( $csv_data ) ), |
|
70 | + __('Wrote %1$s rows to report CSV file...', 'event_espresso'), |
|
71 | + count($csv_data) ), |
|
72 | 72 | $extra_response_data ); |
73 | 73 | } |
74 | 74 | |
75 | 75 | |
76 | 76 | public function cleanup_job(JobParameters $job_parameters) { |
77 | 77 | $this->_file_helper->delete( |
78 | - \EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ), |
|
78 | + \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')), |
|
79 | 79 | true, |
80 | 80 | 'd' |
81 | 81 | ); |
82 | - return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) ); |
|
82 | + return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso')); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | public function count_units_to_process() { |
86 | - return \EEM_Attendee::instance()->count( array( 'caps' => \EEM_Base::caps_read_admin )); |
|
86 | + return \EEM_Attendee::instance()->count(array('caps' => \EEM_Base::caps_read_admin)); |
|
87 | 87 | } |
88 | - public function get_csv_data( $offset, $limit ) { |
|
88 | + public function get_csv_data($offset, $limit) { |
|
89 | 89 | $attendee_rows = \EEM_Attendee::instance()->get_all_wpdb_results( |
90 | 90 | array( |
91 | - 'limit' => array( $offset, $limit ), |
|
92 | - 'force_join' => array( 'State', 'Country' ), |
|
91 | + 'limit' => array($offset, $limit), |
|
92 | + 'force_join' => array('State', 'Country'), |
|
93 | 93 | 'caps' => \EEM_Base::caps_read_admin |
94 | 94 | ) |
95 | 95 | ); |
96 | 96 | $csv_data = array(); |
97 | - foreach( $attendee_rows as $attendee_row ){ |
|
97 | + foreach ($attendee_rows as $attendee_row) { |
|
98 | 98 | $csv_row = array(); |
99 | - foreach( \EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){ |
|
100 | - if( $field_name == 'STA_ID' ){ |
|
101 | - $state_name_field = \EEM_State::instance()->field_settings_for( 'STA_name' ); |
|
102 | - $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
|
103 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
104 | - $country_name_field = \EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
|
105 | - $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
|
106 | - }else{ |
|
107 | - $csv_row[ wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES) ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
|
99 | + foreach (\EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) { |
|
100 | + if ($field_name == 'STA_ID') { |
|
101 | + $state_name_field = \EEM_State::instance()->field_settings_for('STA_name'); |
|
102 | + $csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()]; |
|
103 | + }elseif ($field_name == 'CNT_ISO') { |
|
104 | + $country_name_field = \EEM_Country::instance()->field_settings_for('CNT_name'); |
|
105 | + $csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()]; |
|
106 | + } else { |
|
107 | + $csv_row[wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES)] = $attendee_row[$field_obj->get_qualified_column()]; |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | $csv_data[] = apply_filters( |
@@ -100,10 +100,10 @@ |
||
100 | 100 | if( $field_name == 'STA_ID' ){ |
101 | 101 | $state_name_field = \EEM_State::instance()->field_settings_for( 'STA_name' ); |
102 | 102 | $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
103 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
103 | + } elseif( $field_name == 'CNT_ISO' ){ |
|
104 | 104 | $country_name_field = \EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
105 | 105 | $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
106 | - }else{ |
|
106 | + } else{ |
|
107 | 107 | $csv_row[ wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES) ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
108 | 108 | } |
109 | 109 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | |
61 | 61 | /** |
62 | - * @return boolean |
|
62 | + * @return boolean|null |
|
63 | 63 | */ |
64 | 64 | public function process_reg_step() { |
65 | 65 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | |
70 | 70 | /** |
71 | - * @return boolean |
|
71 | + * @return boolean|null |
|
72 | 72 | */ |
73 | 73 | public function update_reg_step() { |
74 | 74 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_SPCO_Reg_Step_Registration_Confirmation |
|
5 | - * |
|
6 | - * Description |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Brent Christensen |
|
11 | - * @since 4.5.0 |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class EE_SPCO_Reg_Step_Registration_Confirmation |
|
5 | + * |
|
6 | + * Description |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Brent Christensen |
|
11 | + * @since 4.5.0 |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | class EE_SPCO_Reg_Step_Registration_Confirmation extends EE_SPCO_Reg_Step { |
15 | 15 | |
16 | 16 | /** |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | * @param EE_Checkout $checkout |
21 | 21 | * @return \EE_SPCO_Reg_Step_Registration_Confirmation |
22 | 22 | */ |
23 | - public function __construct( EE_Checkout $checkout ) { |
|
23 | + public function __construct(EE_Checkout $checkout) { |
|
24 | 24 | $this->_slug = 'registration_confirmation'; |
25 | 25 | $this->_name = __('Registration Confirmation', 'event_espresso'); |
26 | - $this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'registration_page_confirmation.template.php'; |
|
26 | + $this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'registration_page_confirmation.template.php'; |
|
27 | 27 | $this->checkout = $checkout; |
28 | 28 | } |
29 | 29 | |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return boolean |
44 | 44 | */ |
45 | 45 | public function initialize_reg_step() { |
46 | - $this->checkout->remove_reg_step( $this->_slug ); |
|
46 | + $this->checkout->remove_reg_step($this->_slug); |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 |