@@ -3,7 +3,7 @@ |
||
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php esc_html_e( |
6 | - 'Bulk actions allow you to perform an action to multiple Message Types at once. The following bulk actions are supported: Move to Trash. To use the bulk action feature, place a checkmark next to the message types that you want to include. Then select a bulk action from the menu and click on the Apply button.', |
|
7 | - 'event_espresso' |
|
8 | - ); ?> |
|
6 | + 'Bulk actions allow you to perform an action to multiple Message Types at once. The following bulk actions are supported: Move to Trash. To use the bulk action feature, place a checkmark next to the message types that you want to include. Then select a bulk action from the menu and click on the Apply button.', |
|
7 | + 'event_espresso' |
|
8 | + ); ?> |
|
9 | 9 | </p> |
10 | 10 | \ No newline at end of file |
@@ -3,7 +3,7 @@ |
||
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php esc_html_e( |
6 | - 'There may be times where you want to deactivate (or activate new) Message Types for a particular messenger. The messages system makes it easy to do so. To deactivate a Message Type, drag the message type box from the "active area" into the "inactive" area in the right sidebar. To re-activate, simply reverse your steps. Remember that when you deactivate a message type, if that message type has any settings, the settings will be lost. However, any message templates that match the messenger and message type you deactivated will be preserved, they are just marked "inactive" in the database.', |
|
7 | - 'event_espresso' |
|
8 | - ); ?> |
|
6 | + 'There may be times where you want to deactivate (or activate new) Message Types for a particular messenger. The messages system makes it easy to do so. To deactivate a Message Type, drag the message type box from the "active area" into the "inactive" area in the right sidebar. To re-activate, simply reverse your steps. Remember that when you deactivate a message type, if that message type has any settings, the settings will be lost. However, any message templates that match the messenger and message type you deactivated will be preserved, they are just marked "inactive" in the database.', |
|
7 | + 'event_espresso' |
|
8 | + ); ?> |
|
9 | 9 | </p> |
10 | 10 | \ No newline at end of file |
@@ -3,48 +3,48 @@ |
||
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php esc_html_e( |
6 | - 'The Messages Preview page can be accessed by clicking the Preview button while editing a message template. This feature has been created as a way of previewing what the final generated messages will look like when received by a recipient. Here\'s how the preview is prepared:', |
|
7 | - 'event_espresso' |
|
8 | - ); ?> |
|
6 | + 'The Messages Preview page can be accessed by clicking the Preview button while editing a message template. This feature has been created as a way of previewing what the final generated messages will look like when received by a recipient. Here\'s how the preview is prepared:', |
|
7 | + 'event_espresso' |
|
8 | + ); ?> |
|
9 | 9 | </p> |
10 | 10 | <p> |
11 | 11 | <strong> |
12 | 12 | <?php esc_html_e( |
13 | - '1. The system retrieves the appropriate template based on the given messenger, message type, and context', |
|
14 | - 'event_espresso' |
|
15 | - ); ?> |
|
13 | + '1. The system retrieves the appropriate template based on the given messenger, message type, and context', |
|
14 | + 'event_espresso' |
|
15 | + ); ?> |
|
16 | 16 | </strong> |
17 | 17 | </p> |
18 | 18 | <p> |
19 | 19 | <?php esc_html_e( |
20 | - 'When you click the preview button, the messages system remembers what template is being "previewed" based on the messenger, message_type, context and event (if this is a custom event template).', |
|
21 | - 'event_espresso' |
|
22 | - ); ?> |
|
20 | + 'When you click the preview button, the messages system remembers what template is being "previewed" based on the messenger, message_type, context and event (if this is a custom event template).', |
|
21 | + 'event_espresso' |
|
22 | + ); ?> |
|
23 | 23 | </p> |
24 | 24 | <p> |
25 | 25 | <strong><?php esc_html_e('2. Setup data', 'event_espresso'); ?></strong> |
26 | 26 | </p> |
27 | 27 | <p> |
28 | 28 | <?php esc_html_e( |
29 | - 'Before any shortcodes in the template can be parsed, the previewer needs to know what data to use for the shortcodes. Some of the data is dummy data that the previewer generates, but wherever possible the previewer will use actual data from your database. For example, all the organization shortcodes will use actual data you\'ve setup for your organization. For global template previews, the previewer will obtain the first active event from your database and use data from it. If you are previewing a custom event template then THAT event will be used for the preview. The only data that is dummy data is typically data that would be entered by a person registering for an event.', |
|
30 | - 'event_espresso' |
|
31 | - ); ?> |
|
29 | + 'Before any shortcodes in the template can be parsed, the previewer needs to know what data to use for the shortcodes. Some of the data is dummy data that the previewer generates, but wherever possible the previewer will use actual data from your database. For example, all the organization shortcodes will use actual data you\'ve setup for your organization. For global template previews, the previewer will obtain the first active event from your database and use data from it. If you are previewing a custom event template then THAT event will be used for the preview. The only data that is dummy data is typically data that would be entered by a person registering for an event.', |
|
30 | + 'event_espresso' |
|
31 | + ); ?> |
|
32 | 32 | </p> |
33 | 33 | <p> |
34 | 34 | <strong><?php esc_html_e('3. Parse shortcodes', 'event_espresso'); ?></strong> |
35 | 35 | </p> |
36 | 36 | <p> |
37 | 37 | <?php esc_html_e( |
38 | - 'The previewer then goes through all the shortcodes in the template being previewed and replaces them using the prepared data. This is a good way of making sure that the shortcodes are working as you expect, and also clearly seeing what is being displayed for that shortcode when someone receives that message.', |
|
39 | - 'event_espresso' |
|
40 | - ); ?> |
|
38 | + 'The previewer then goes through all the shortcodes in the template being previewed and replaces them using the prepared data. This is a good way of making sure that the shortcodes are working as you expect, and also clearly seeing what is being displayed for that shortcode when someone receives that message.', |
|
39 | + 'event_espresso' |
|
40 | + ); ?> |
|
41 | 41 | </p> |
42 | 42 | <p> |
43 | 43 | <strong><?php esc_html_e('4. Display the preview', 'event_espresso'); ?></strong> |
44 | 44 | </p> |
45 | 45 | <p> |
46 | 46 | <?php esc_html_e( |
47 | - 'An important thing to remember about the previewer is that for the most part, the previewer uses the same underlying system that will be used for actual outgoing messages, so you can be certain that what you see in the preview is what users will see when they receive the message. It is yet another tool provided to make it easier for you to customize the look of your outgoing messages.', |
|
48 | - 'event_espresso' |
|
49 | - ); ?> |
|
47 | + 'An important thing to remember about the previewer is that for the most part, the previewer uses the same underlying system that will be used for actual outgoing messages, so you can be certain that what you see in the preview is what users will see when they receive the message. It is yet another tool provided to make it easier for you to customize the look of your outgoing messages.', |
|
48 | + 'event_espresso' |
|
49 | + ); ?> |
|
50 | 50 | </p> |
51 | 51 | \ No newline at end of file |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <p><strong><?php esc_html_e('Messengers', 'event_espresso'); ?></strong></p> |
2 | 2 | <p> |
3 | 3 | <?php |
4 | - printf( |
|
5 | - esc_html__( |
|
6 | - 'Messengers are the vehicles that deliver messages to individuals (recipients). By default, every install of Event Espresso has the %sEmail%s messenger active. The Email messenger is a vehicle for delivering messages. Other possible vehicles might be any social media applications, 3rd party API\'s etc.', |
|
7 | - 'event_espresso' |
|
8 | - ), |
|
9 | - '<strong>', |
|
10 | - '</strong>' |
|
11 | - ); |
|
12 | - ?> |
|
4 | + printf( |
|
5 | + esc_html__( |
|
6 | + 'Messengers are the vehicles that deliver messages to individuals (recipients). By default, every install of Event Espresso has the %sEmail%s messenger active. The Email messenger is a vehicle for delivering messages. Other possible vehicles might be any social media applications, 3rd party API\'s etc.', |
|
7 | + 'event_espresso' |
|
8 | + ), |
|
9 | + '<strong>', |
|
10 | + '</strong>' |
|
11 | + ); |
|
12 | + ?> |
|
13 | 13 | </p> |
14 | 14 | \ No newline at end of file |
@@ -3,17 +3,17 @@ discard block |
||
3 | 3 | <div class="padding"> |
4 | 4 | <p> |
5 | 5 | <?php printf( |
6 | - esc_html__( |
|
7 | - '%1$sNote:%2$s The %3$s[ESPRESSO_EVENT_ATTENDEES]%4$s shortcode is not used to represent the attendees post type directly, but is instead used to represent the intersection of attendees with events. So it\'s always returning a list of attendees %5$sin relation to%6$s an event.', |
|
8 | - 'event_espresso' |
|
9 | - ), |
|
10 | - '<strong>', |
|
11 | - '</strong>', |
|
12 | - '<code>', |
|
13 | - '</code>', |
|
14 | - '<em>', |
|
15 | - '</em>' |
|
16 | - ); ?> |
|
6 | + esc_html__( |
|
7 | + '%1$sNote:%2$s The %3$s[ESPRESSO_EVENT_ATTENDEES]%4$s shortcode is not used to represent the attendees post type directly, but is instead used to represent the intersection of attendees with events. So it\'s always returning a list of attendees %5$sin relation to%6$s an event.', |
|
8 | + 'event_espresso' |
|
9 | + ), |
|
10 | + '<strong>', |
|
11 | + '</strong>', |
|
12 | + '<code>', |
|
13 | + '</code>', |
|
14 | + '<em>', |
|
15 | + '</em>' |
|
16 | + ); ?> |
|
17 | 17 | </p> |
18 | 18 | |
19 | 19 | <ul> |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | <strong>[ESPRESSO_EVENT_ATTENDEES]</strong><br> |
22 | 22 | <p class="description"> |
23 | 23 | <?php esc_html_e( |
24 | - 'With no parameters, this shows the attendees for the earliest active event, or if no active event, the earliest upcoming event. If it is used in Event Description, then it will show the attendees for that event.', |
|
25 | - 'event_espresso' |
|
26 | - ); ?> |
|
24 | + 'With no parameters, this shows the attendees for the earliest active event, or if no active event, the earliest upcoming event. If it is used in Event Description, then it will show the attendees for that event.', |
|
25 | + 'event_espresso' |
|
26 | + ); ?> |
|
27 | 27 | </p> |
28 | 28 | <br> |
29 | 29 | </li> |
@@ -52,20 +52,20 @@ discard block |
||
52 | 52 | <strong>[ESPRESSO_EVENT_ATTENDEES status=RAP]</strong><br> |
53 | 53 | <p class="description"> |
54 | 54 | <?php esc_html_e( |
55 | - 'You can list attendees that have a specific registration status (use status code) or use "all" to return all attendees regardless of status. Default when you don\'t have this parameter set is to only return attendees attached to approved contacts.', |
|
56 | - 'event_espresso' |
|
57 | - ); ?> |
|
55 | + 'You can list attendees that have a specific registration status (use status code) or use "all" to return all attendees regardless of status. Default when you don\'t have this parameter set is to only return attendees attached to approved contacts.', |
|
56 | + 'event_espresso' |
|
57 | + ); ?> |
|
58 | 58 | </p> |
59 | 59 | <p> |
60 | 60 | <?php esc_html_e('The statuses you can use are:', 'event_espresso'); ?> |
61 | 61 | <br> |
62 | 62 | <?php |
63 | - foreach ($reg_status_array as $status_code => $status_label) { |
|
64 | - $status_code = esc_html($status_code); |
|
65 | - $status_label = esc_html($status_label); |
|
66 | - echo "<strong>$status_code</strong>: $status_label<br>"; |
|
67 | - } |
|
68 | - ?> |
|
63 | + foreach ($reg_status_array as $status_code => $status_label) { |
|
64 | + $status_code = esc_html($status_code); |
|
65 | + $status_label = esc_html($status_label); |
|
66 | + echo "<strong>$status_code</strong>: $status_label<br>"; |
|
67 | + } |
|
68 | + ?> |
|
69 | 69 | |
70 | 70 | </p> |
71 | 71 | <br> |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | <strong>[ESPRESSO_EVENT_ATTENDEES display_on_archives=true]</strong><br> |
75 | 75 | <p class="description"> |
76 | 76 | <?php esc_html_e( |
77 | - 'Will display the attendees list when events are viewed on archive pages.', |
|
78 | - 'event_espresso' |
|
79 | - ); ?> |
|
77 | + 'Will display the attendees list when events are viewed on archive pages.', |
|
78 | + 'event_espresso' |
|
79 | + ); ?> |
|
80 | 80 | </p> |
81 | 81 | <br> |
82 | 82 | </li> |
@@ -15,7 +15,7 @@ |
||
15 | 15 | ), |
16 | 16 | '<a href="https://eventespresso.com/wp-login.php">', |
17 | 17 | '</a>' |
18 | - );?> |
|
18 | + ); ?> |
|
19 | 19 | </p> |
20 | 20 | <p class="ee-attention"> |
21 | 21 | <?php printf( |
@@ -9,77 +9,77 @@ |
||
9 | 9 | </p> |
10 | 10 | <p> |
11 | 11 | <?php printf( |
12 | - esc_html__( |
|
13 | - 'Enter your support license key in this field to benefit from one-click updates. To manage your support license key, please %1$slogin to your Event Espresso account%2$s. Then click on Edit Account Details which appears in the left sidebar menu.', |
|
14 | - 'event_espresso' |
|
15 | - ), |
|
16 | - '<a href="https://eventespresso.com/wp-login.php">', |
|
17 | - '</a>' |
|
18 | - );?> |
|
12 | + esc_html__( |
|
13 | + 'Enter your support license key in this field to benefit from one-click updates. To manage your support license key, please %1$slogin to your Event Espresso account%2$s. Then click on Edit Account Details which appears in the left sidebar menu.', |
|
14 | + 'event_espresso' |
|
15 | + ), |
|
16 | + '<a href="https://eventespresso.com/wp-login.php">', |
|
17 | + '</a>' |
|
18 | + );?> |
|
19 | 19 | </p> |
20 | 20 | <p class="ee-attention"> |
21 | 21 | <?php printf( |
22 | - esc_html__( |
|
23 | - 'Site license keys are now called support license keys. Your support license key should only be entered on live/production sites. If this is a development or test site, %sdo not%s enter your support license key.', |
|
24 | - 'event_espresso' |
|
25 | - ), |
|
26 | - '<strong>', |
|
27 | - '</strong>' |
|
28 | - ); ?> |
|
22 | + esc_html__( |
|
23 | + 'Site license keys are now called support license keys. Your support license key should only be entered on live/production sites. If this is a development or test site, %sdo not%s enter your support license key.', |
|
24 | + 'event_espresso' |
|
25 | + ), |
|
26 | + '<strong>', |
|
27 | + '</strong>' |
|
28 | + ); ?> |
|
29 | 29 | </p> |
30 | 30 | <p> |
31 | 31 | <strong><?php esc_html_e('Contact Information', 'event_espresso'); ?></strong> |
32 | 32 | </p> |
33 | 33 | <p> |
34 | 34 | <?php esc_html_e( |
35 | - 'Enter information about your organization here. Be sure to keep your information up-to-date.', |
|
36 | - 'event_espresso' |
|
37 | - ); ?><br /> |
|
35 | + 'Enter information about your organization here. Be sure to keep your information up-to-date.', |
|
36 | + 'event_espresso' |
|
37 | + ); ?><br /> |
|
38 | 38 | <?php esc_html_e( |
39 | - 'Changing your country on this page will also change your country on the Countries page. This will affect your currency options which are used through Event Espresso. For example, if your country is currently set to United States, then your currency is USD. If you were to switch your country to United Kingdom, then your currency would change to GBP.', |
|
40 | - 'event_espresso' |
|
41 | - ); ?> |
|
39 | + 'Changing your country on this page will also change your country on the Countries page. This will affect your currency options which are used through Event Espresso. For example, if your country is currently set to United States, then your currency is USD. If you were to switch your country to United Kingdom, then your currency would change to GBP.', |
|
40 | + 'event_espresso' |
|
41 | + ); ?> |
|
42 | 42 | </p> |
43 | 43 | <p> |
44 | 44 | <strong><?php esc_html_e('Company Logo', 'event_espresso'); ?></strong> |
45 | 45 | </p> |
46 | 46 | <p> |
47 | 47 | <?php esc_html_e( |
48 | - 'You can upload a new logo here. We recommend an image that is 400 pixels wide or smaller. Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
|
49 | - 'event_espresso' |
|
50 | - ); ?> |
|
48 | + 'You can upload a new logo here. We recommend an image that is 400 pixels wide or smaller. Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
|
49 | + 'event_espresso' |
|
50 | + ); ?> |
|
51 | 51 | </p> |
52 | 52 | <p> |
53 | 53 | <strong><?php esc_html_e('Social Links', 'event_espresso'); ?></strong> |
54 | 54 | </p> |
55 | 55 | <p> |
56 | 56 | <?php esc_html_e( |
57 | - 'These URLs can be displayed automatically within your emails (using shortcodes) and front-end templates (using template tags).', |
|
58 | - 'event_espresso' |
|
59 | - ); ?> |
|
57 | + 'These URLs can be displayed automatically within your emails (using shortcodes) and front-end templates (using template tags).', |
|
58 | + 'event_espresso' |
|
59 | + ); ?> |
|
60 | 60 | </p> |
61 | 61 | <p> |
62 | 62 | <strong><?php esc_html_e('User eXperience Improvement Program (UXIP)', 'event_espresso'); ?></strong> |
63 | 63 | </p> |
64 | 64 | <p> |
65 | 65 | <?php esc_html_e( |
66 | - 'You can take part in making Event Espresso better! Your information will never be sold, traded, or misused in any way. This programs is voluntary and you can opt out at any time.', |
|
67 | - 'event_espresso' |
|
68 | - ); ?> |
|
66 | + 'You can take part in making Event Espresso better! Your information will never be sold, traded, or misused in any way. This programs is voluntary and you can opt out at any time.', |
|
67 | + 'event_espresso' |
|
68 | + ); ?> |
|
69 | 69 | </p> |
70 | 70 | <p> |
71 | 71 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
72 | 72 | <br /> |
73 | 73 | <?php esc_html_e( |
74 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
75 | - 'event_espresso' |
|
76 | - ); ?> |
|
74 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
75 | + 'event_espresso' |
|
76 | + ); ?> |
|
77 | 77 | </p> |
78 | 78 | <p> |
79 | 79 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
80 | 80 | <br /> |
81 | 81 | <?php esc_html_e( |
82 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
83 | - 'event_espresso' |
|
84 | - ); ?> |
|
82 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
83 | + 'event_espresso' |
|
84 | + ); ?> |
|
85 | 85 | </p> |
86 | 86 | \ No newline at end of file |
@@ -69,7 +69,7 @@ |
||
69 | 69 | $keys_only = empty( |
70 | 70 | array_filter( |
71 | 71 | array_values($data_value), |
72 | - function ($v) { |
|
72 | + function($v) { |
|
73 | 73 | return $v !== null && (is_array($v) || trim($v) !== ''); |
74 | 74 | } |
75 | 75 | ) |
@@ -19,38 +19,38 @@ discard block |
||
19 | 19 | */ |
20 | 20 | function ee_recurse_into_array_for_display($data, $depth = 0, $td = true) |
21 | 21 | { |
22 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
23 | - // is_object($incomplete_class) actually returns false, hence why we check for it |
|
24 | - $data = json_decode(json_encode($data), true); |
|
25 | - } |
|
26 | - if (empty($data)) { |
|
27 | - return; |
|
28 | - } |
|
29 | - if (is_array($data)) { |
|
30 | - $depth++; |
|
31 | - ksort($data, SORT_NATURAL | SORT_FLAG_CASE); |
|
32 | - if (EEH_Array::is_associative_array($data)) { ?> |
|
22 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
23 | + // is_object($incomplete_class) actually returns false, hence why we check for it |
|
24 | + $data = json_decode(json_encode($data), true); |
|
25 | + } |
|
26 | + if (empty($data)) { |
|
27 | + return; |
|
28 | + } |
|
29 | + if (is_array($data)) { |
|
30 | + $depth++; |
|
31 | + ksort($data, SORT_NATURAL | SORT_FLAG_CASE); |
|
32 | + if (EEH_Array::is_associative_array($data)) { ?> |
|
33 | 33 | <table class='ee-system-stati ee-system-stati-<?php echo absint($depth); ?>'> |
34 | 34 | <tbody> |
35 | 35 | <?php foreach ($data as $data_key => $data_value) { |
36 | - // if the value is a single element array with no key, |
|
37 | - // and the value is a primitive (not an array, object, etc.) |
|
38 | - if ( |
|
39 | - is_array($data_value) |
|
40 | - && count($data_value) === 1 |
|
41 | - && empty(key($data_value)) |
|
42 | - && is_scalar(reset($data_value)) |
|
43 | - ) { |
|
44 | - ?> |
|
36 | + // if the value is a single element array with no key, |
|
37 | + // and the value is a primitive (not an array, object, etc.) |
|
38 | + if ( |
|
39 | + is_array($data_value) |
|
40 | + && count($data_value) === 1 |
|
41 | + && empty(key($data_value)) |
|
42 | + && is_scalar(reset($data_value)) |
|
43 | + ) { |
|
44 | + ?> |
|
45 | 45 | <tr> |
46 | 46 | <td class="ee-system-stati-value" colspan="2"> |
47 | 47 | <?php echo esc_html(reset($data_value)); ?> |
48 | 48 | </td> |
49 | 49 | </tr> |
50 | 50 | <?php |
51 | - continue; |
|
52 | - } |
|
53 | - ?> |
|
51 | + continue; |
|
52 | + } |
|
53 | + ?> |
|
54 | 54 | <tr> |
55 | 55 | <td class='ee-system-stati-key'> |
56 | 56 | <span class="ee-system-stati-label"> |
@@ -65,31 +65,31 @@ discard block |
||
65 | 65 | <?php if (is_scalar($data_value)) { ?> |
66 | 66 | <?php ee_recurse_into_array_for_display($data_value, $depth); ?> |
67 | 67 | <?php } else { |
68 | - if (is_array($data_value) && count($data_value) === 1) { |
|
69 | - // verify that values have been set |
|
70 | - $keys_only = empty( |
|
71 | - array_filter( |
|
72 | - array_values($data_value), |
|
73 | - function ($v) { |
|
74 | - return $v !== null && (is_array($v) || trim($v) !== ''); |
|
75 | - } |
|
76 | - ) |
|
77 | - ); |
|
78 | - // if the array only consists of keys (no values) |
|
79 | - if ($keys_only) { |
|
80 | - // then use keys for values |
|
81 | - $data_value = array_keys($data_value); |
|
82 | - // but if there is only one value now |
|
83 | - if (count($data_value) === 1) { |
|
84 | - // then pass that single value back into this function |
|
85 | - // this prevents extra empty layers of nothing being added to the output |
|
86 | - ee_recurse_into_array_for_display(reset($data_value), $depth); |
|
87 | - // need to finish the row off though |
|
88 | - echo '</tr>'; |
|
89 | - continue; |
|
90 | - } |
|
91 | - } |
|
92 | - } ?> |
|
68 | + if (is_array($data_value) && count($data_value) === 1) { |
|
69 | + // verify that values have been set |
|
70 | + $keys_only = empty( |
|
71 | + array_filter( |
|
72 | + array_values($data_value), |
|
73 | + function ($v) { |
|
74 | + return $v !== null && (is_array($v) || trim($v) !== ''); |
|
75 | + } |
|
76 | + ) |
|
77 | + ); |
|
78 | + // if the array only consists of keys (no values) |
|
79 | + if ($keys_only) { |
|
80 | + // then use keys for values |
|
81 | + $data_value = array_keys($data_value); |
|
82 | + // but if there is only one value now |
|
83 | + if (count($data_value) === 1) { |
|
84 | + // then pass that single value back into this function |
|
85 | + // this prevents extra empty layers of nothing being added to the output |
|
86 | + ee_recurse_into_array_for_display(reset($data_value), $depth); |
|
87 | + // need to finish the row off though |
|
88 | + echo '</tr>'; |
|
89 | + continue; |
|
90 | + } |
|
91 | + } |
|
92 | + } ?> |
|
93 | 93 | <td class="ee-system-stati-sub-values"> |
94 | 94 | <?php ee_recurse_into_array_for_display($data_value, $depth); ?> |
95 | 95 | </td> |
@@ -107,19 +107,19 @@ discard block |
||
107 | 107 | <?php } ?> |
108 | 108 | </ul> |
109 | 109 | <?php } else { |
110 | - // there's no key (label) and there's only one value, |
|
111 | - // so let's just pass that value back into this function, |
|
112 | - // but reset the depth back to where it was. |
|
113 | - // this prevents extra empty layers of nothing being added to the output |
|
114 | - $depth--; |
|
115 | - ee_recurse_into_array_for_display(reset($data), $depth, false); |
|
116 | - } |
|
117 | - } else { |
|
118 | - echo wp_kses($td ? '<td class="ee-system-stati-value">' : '', AllowedTags::getAllowedTags()); |
|
119 | - // simple value |
|
120 | - echo wp_kses($data, AllowedTags::getAllowedTags()); |
|
121 | - echo wp_kses($td ? '</td>' : '', AllowedTags::getAllowedTags()); |
|
122 | - } |
|
110 | + // there's no key (label) and there's only one value, |
|
111 | + // so let's just pass that value back into this function, |
|
112 | + // but reset the depth back to where it was. |
|
113 | + // this prevents extra empty layers of nothing being added to the output |
|
114 | + $depth--; |
|
115 | + ee_recurse_into_array_for_display(reset($data), $depth, false); |
|
116 | + } |
|
117 | + } else { |
|
118 | + echo wp_kses($td ? '<td class="ee-system-stati-value">' : '', AllowedTags::getAllowedTags()); |
|
119 | + // simple value |
|
120 | + echo wp_kses($data, AllowedTags::getAllowedTags()); |
|
121 | + echo wp_kses($td ? '</td>' : '', AllowedTags::getAllowedTags()); |
|
122 | + } |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | ?> |
@@ -17,76 +17,76 @@ |
||
17 | 17 | |
18 | 18 | class BulkEntityDelete extends EntityMutator |
19 | 19 | { |
20 | - /** |
|
21 | - * Defines the mutation data modification closure. |
|
22 | - * |
|
23 | - * @return callable |
|
24 | - */ |
|
25 | - public static function mutateAndGetPayload() |
|
26 | - { |
|
27 | - /** |
|
28 | - * Updates an entity. |
|
29 | - * |
|
30 | - * @param array $input The input for the mutation |
|
31 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | - * @return array |
|
34 | - * @throws UserError |
|
35 | - * @throws ReflectionException |
|
36 | - * @throws InvalidArgumentException |
|
37 | - * @throws InvalidInterfaceException |
|
38 | - * @throws InvalidDataTypeException |
|
39 | - * @throws EE_Error |
|
40 | - */ |
|
41 | - return static function (array $input, AppContext $context, ResolveInfo $info): array { |
|
42 | - /** |
|
43 | - * Stop now if a user isn't allowed to delete. |
|
44 | - */ |
|
45 | - if (! current_user_can('ee_delete_events')) { |
|
46 | - throw new UserError( |
|
47 | - esc_html__('Sorry, you do not have the required permissions to delete entities', 'event_espresso') |
|
48 | - ); |
|
49 | - } |
|
20 | + /** |
|
21 | + * Defines the mutation data modification closure. |
|
22 | + * |
|
23 | + * @return callable |
|
24 | + */ |
|
25 | + public static function mutateAndGetPayload() |
|
26 | + { |
|
27 | + /** |
|
28 | + * Updates an entity. |
|
29 | + * |
|
30 | + * @param array $input The input for the mutation |
|
31 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | + * @return array |
|
34 | + * @throws UserError |
|
35 | + * @throws ReflectionException |
|
36 | + * @throws InvalidArgumentException |
|
37 | + * @throws InvalidInterfaceException |
|
38 | + * @throws InvalidDataTypeException |
|
39 | + * @throws EE_Error |
|
40 | + */ |
|
41 | + return static function (array $input, AppContext $context, ResolveInfo $info): array { |
|
42 | + /** |
|
43 | + * Stop now if a user isn't allowed to delete. |
|
44 | + */ |
|
45 | + if (! current_user_can('ee_delete_events')) { |
|
46 | + throw new UserError( |
|
47 | + esc_html__('Sorry, you do not have the required permissions to delete entities', 'event_espresso') |
|
48 | + ); |
|
49 | + } |
|
50 | 50 | |
51 | - $details = EntityReorder::prepareEntityDetailsFromInput($input); |
|
51 | + $details = EntityReorder::prepareEntityDetailsFromInput($input); |
|
52 | 52 | |
53 | - $deletePermanently = ! empty($input['deletePermanently']); |
|
53 | + $deletePermanently = ! empty($input['deletePermanently']); |
|
54 | 54 | |
55 | - $deletionMethod = __NAMESPACE__; |
|
56 | - // if it's for datetimes. |
|
57 | - if ($details['entityType'] === EEM_Datetime::instance()->item_name()) { |
|
58 | - $deletionMethod .= '\DatetimeDelete::' . ($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations'); |
|
59 | - } elseif ($details['entityType'] === EEM_Ticket::instance()->item_name()) { |
|
60 | - $deletionMethod .= '\TicketDelete::' . ($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket'); |
|
61 | - } elseif ($details['entityType'] === EEM_Price::instance()->item_name()) { |
|
62 | - $deletionMethod .= '\PriceDelete::deletePriceAndRelations'; |
|
63 | - } else { |
|
64 | - throw new UserError( |
|
65 | - esc_html__( |
|
66 | - 'A valid data model could not be obtained. Did you supply a valid entity type?', |
|
67 | - 'event_espresso' |
|
68 | - ) |
|
69 | - ); |
|
70 | - } |
|
55 | + $deletionMethod = __NAMESPACE__; |
|
56 | + // if it's for datetimes. |
|
57 | + if ($details['entityType'] === EEM_Datetime::instance()->item_name()) { |
|
58 | + $deletionMethod .= '\DatetimeDelete::' . ($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations'); |
|
59 | + } elseif ($details['entityType'] === EEM_Ticket::instance()->item_name()) { |
|
60 | + $deletionMethod .= '\TicketDelete::' . ($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket'); |
|
61 | + } elseif ($details['entityType'] === EEM_Price::instance()->item_name()) { |
|
62 | + $deletionMethod .= '\PriceDelete::deletePriceAndRelations'; |
|
63 | + } else { |
|
64 | + throw new UserError( |
|
65 | + esc_html__( |
|
66 | + 'A valid data model could not be obtained. Did you supply a valid entity type?', |
|
67 | + 'event_espresso' |
|
68 | + ) |
|
69 | + ); |
|
70 | + } |
|
71 | 71 | |
72 | - $deleted = []; |
|
73 | - $failed = []; |
|
72 | + $deleted = []; |
|
73 | + $failed = []; |
|
74 | 74 | |
75 | - foreach ($details['entity_db_ids'] as $key => $entityDbid) { |
|
76 | - $guid = $details['entityGuids'][ $key ]; |
|
77 | - $entity = $details['entities'][ $entityDbid ]; |
|
78 | - try { |
|
79 | - $result = $deletionMethod($entity); |
|
80 | - EntityMutator::validateResults($result); |
|
81 | - // we are here it means the deletion was successful. |
|
82 | - $deleted[] = $guid; |
|
83 | - } catch (Exception $e) { |
|
84 | - // sorry mate, couldn't help you :( |
|
85 | - $failed[] = $guid; |
|
86 | - } |
|
87 | - } |
|
75 | + foreach ($details['entity_db_ids'] as $key => $entityDbid) { |
|
76 | + $guid = $details['entityGuids'][ $key ]; |
|
77 | + $entity = $details['entities'][ $entityDbid ]; |
|
78 | + try { |
|
79 | + $result = $deletionMethod($entity); |
|
80 | + EntityMutator::validateResults($result); |
|
81 | + // we are here it means the deletion was successful. |
|
82 | + $deleted[] = $guid; |
|
83 | + } catch (Exception $e) { |
|
84 | + // sorry mate, couldn't help you :( |
|
85 | + $failed[] = $guid; |
|
86 | + } |
|
87 | + } |
|
88 | 88 | |
89 | - return compact('deleted', 'failed'); |
|
90 | - }; |
|
91 | - } |
|
89 | + return compact('deleted', 'failed'); |
|
90 | + }; |
|
91 | + } |
|
92 | 92 | } |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | * @throws InvalidDataTypeException |
39 | 39 | * @throws EE_Error |
40 | 40 | */ |
41 | - return static function (array $input, AppContext $context, ResolveInfo $info): array { |
|
41 | + return static function(array $input, AppContext $context, ResolveInfo $info): array { |
|
42 | 42 | /** |
43 | 43 | * Stop now if a user isn't allowed to delete. |
44 | 44 | */ |
45 | - if (! current_user_can('ee_delete_events')) { |
|
45 | + if ( ! current_user_can('ee_delete_events')) { |
|
46 | 46 | throw new UserError( |
47 | 47 | esc_html__('Sorry, you do not have the required permissions to delete entities', 'event_espresso') |
48 | 48 | ); |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | $deletionMethod = __NAMESPACE__; |
56 | 56 | // if it's for datetimes. |
57 | 57 | if ($details['entityType'] === EEM_Datetime::instance()->item_name()) { |
58 | - $deletionMethod .= '\DatetimeDelete::' . ($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations'); |
|
58 | + $deletionMethod .= '\DatetimeDelete::'.($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations'); |
|
59 | 59 | } elseif ($details['entityType'] === EEM_Ticket::instance()->item_name()) { |
60 | - $deletionMethod .= '\TicketDelete::' . ($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket'); |
|
60 | + $deletionMethod .= '\TicketDelete::'.($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket'); |
|
61 | 61 | } elseif ($details['entityType'] === EEM_Price::instance()->item_name()) { |
62 | 62 | $deletionMethod .= '\PriceDelete::deletePriceAndRelations'; |
63 | 63 | } else { |
@@ -73,8 +73,8 @@ discard block |
||
73 | 73 | $failed = []; |
74 | 74 | |
75 | 75 | foreach ($details['entity_db_ids'] as $key => $entityDbid) { |
76 | - $guid = $details['entityGuids'][ $key ]; |
|
77 | - $entity = $details['entities'][ $entityDbid ]; |
|
76 | + $guid = $details['entityGuids'][$key]; |
|
77 | + $entity = $details['entities'][$entityDbid]; |
|
78 | 78 | try { |
79 | 79 | $result = $deletionMethod($entity); |
80 | 80 | EntityMutator::validateResults($result); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | // $block_editor_context can be either an object or a string |
108 | 108 | // so checking it here, thus no type hinting in function params |
109 | - if (! $block_editor_context instanceof WP_Block_Editor_Context) { |
|
109 | + if ( ! $block_editor_context instanceof WP_Block_Editor_Context) { |
|
110 | 110 | return $categories; |
111 | 111 | } |
112 | 112 | return array_merge( |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | foreach ($this->blocks as $block) { |
168 | 168 | $block->initialize(); |
169 | 169 | $this->trackAssetManagersForBlocks($block); |
170 | - if (! $this->block_asset_manager_collection->has($block->assetManager())) { |
|
170 | + if ( ! $this->block_asset_manager_collection->has($block->assetManager())) { |
|
171 | 171 | $this->block_asset_manager_collection->add($block->assetManager()); |
172 | 172 | $block->assetManager()->setAssetHandles(); |
173 | 173 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $supported_routes = $block->supportedRoutes(); |
190 | 190 | foreach ($supported_routes as $supported_route) { |
191 | 191 | if ($this->route_manager->routeMatchesCurrentRequest($supported_route)) { |
192 | - $this->block_asset_managers[ $block->blockType() ] = $block->assetManager()->assetNamespace(); |
|
192 | + $this->block_asset_managers[$block->blockType()] = $block->assetManager()->assetNamespace(); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
@@ -205,10 +205,10 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function matchesRoute(BlockInterface $block) |
207 | 207 | { |
208 | - if (isset($this->block_asset_managers[ $block->blockType() ])) { |
|
208 | + if (isset($this->block_asset_managers[$block->blockType()])) { |
|
209 | 209 | return true; |
210 | 210 | } |
211 | - unset($this->block_asset_managers[ $block->blockType() ]); |
|
211 | + unset($this->block_asset_managers[$block->blockType()]); |
|
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | try { |
225 | 225 | // cycle thru block loader folders |
226 | 226 | foreach ($this->blocks as $block) { |
227 | - if (! $this->matchesRoute($block)) { |
|
227 | + if ( ! $this->matchesRoute($block)) { |
|
228 | 228 | continue; |
229 | 229 | } |
230 | 230 | // perform any setup required for the block |
231 | 231 | $block_type = $block->registerBlock(); |
232 | - if (! $block_type instanceof WP_Block_Type) { |
|
232 | + if ( ! $block_type instanceof WP_Block_Type) { |
|
233 | 233 | throw new InvalidEntityException($block_type, 'WP_Block_Type'); |
234 | 234 | } |
235 | 235 | do_action( |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | $assets = array_flip($this->block_asset_managers); |
249 | 249 | foreach ($this->block_asset_manager_collection as $asset_manager) { |
250 | 250 | // if there are no longer any blocks that require these assets, |
251 | - if (! isset($assets[ $asset_manager->assetNamespace() ])) { |
|
251 | + if ( ! isset($assets[$asset_manager->assetNamespace()])) { |
|
252 | 252 | // then unset asset enqueueing and bail |
253 | 253 | remove_action('wp_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0); |
254 | 254 | remove_action('admin_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0); |
@@ -32,228 +32,228 @@ |
||
32 | 32 | */ |
33 | 33 | class BlockRegistrationManager extends BlockManager |
34 | 34 | { |
35 | - /** |
|
36 | - * @var BlockAssetManagerCollection $block_asset_manager_collection |
|
37 | - */ |
|
38 | - protected $block_asset_manager_collection; |
|
35 | + /** |
|
36 | + * @var BlockAssetManagerCollection $block_asset_manager_collection |
|
37 | + */ |
|
38 | + protected $block_asset_manager_collection; |
|
39 | 39 | |
40 | - /** |
|
41 | - * @var RouteMatchSpecificationManager $route_manager |
|
42 | - */ |
|
43 | - protected $route_manager; |
|
40 | + /** |
|
41 | + * @var RouteMatchSpecificationManager $route_manager |
|
42 | + */ |
|
43 | + protected $route_manager; |
|
44 | 44 | |
45 | - /** |
|
46 | - * array for tracking asset managers required by blocks for the current route |
|
47 | - * |
|
48 | - * @var array $block_asset_managers |
|
49 | - */ |
|
50 | - protected $block_asset_managers = array(); |
|
45 | + /** |
|
46 | + * array for tracking asset managers required by blocks for the current route |
|
47 | + * |
|
48 | + * @var array $block_asset_managers |
|
49 | + */ |
|
50 | + protected $block_asset_managers = array(); |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * BlockRegistrationManager constructor. |
|
55 | - * |
|
56 | - * @param BlockAssetManagerCollection $block_asset_manager_collection |
|
57 | - * @param BlockCollection $blocks |
|
58 | - * @param RouteMatchSpecificationManager $route_manager |
|
59 | - * @param RequestInterface $request |
|
60 | - */ |
|
61 | - public function __construct( |
|
62 | - BlockAssetManagerCollection $block_asset_manager_collection, |
|
63 | - BlockCollection $blocks, |
|
64 | - RouteMatchSpecificationManager $route_manager, |
|
65 | - RequestInterface $request |
|
66 | - ) { |
|
67 | - $this->block_asset_manager_collection = $block_asset_manager_collection; |
|
68 | - $this->route_manager = $route_manager; |
|
69 | - parent::__construct($blocks, $request); |
|
70 | - } |
|
53 | + /** |
|
54 | + * BlockRegistrationManager constructor. |
|
55 | + * |
|
56 | + * @param BlockAssetManagerCollection $block_asset_manager_collection |
|
57 | + * @param BlockCollection $blocks |
|
58 | + * @param RouteMatchSpecificationManager $route_manager |
|
59 | + * @param RequestInterface $request |
|
60 | + */ |
|
61 | + public function __construct( |
|
62 | + BlockAssetManagerCollection $block_asset_manager_collection, |
|
63 | + BlockCollection $blocks, |
|
64 | + RouteMatchSpecificationManager $route_manager, |
|
65 | + RequestInterface $request |
|
66 | + ) { |
|
67 | + $this->block_asset_manager_collection = $block_asset_manager_collection; |
|
68 | + $this->route_manager = $route_manager; |
|
69 | + parent::__construct($blocks, $request); |
|
70 | + } |
|
71 | 71 | |
72 | 72 | |
73 | - /** |
|
74 | - * Returns the name of a hook point to be used to call initialize() |
|
75 | - * |
|
76 | - * @return string |
|
77 | - */ |
|
78 | - public function initHook() |
|
79 | - { |
|
80 | - return 'AHEE__EE_System__initialize'; |
|
81 | - } |
|
73 | + /** |
|
74 | + * Returns the name of a hook point to be used to call initialize() |
|
75 | + * |
|
76 | + * @return string |
|
77 | + */ |
|
78 | + public function initHook() |
|
79 | + { |
|
80 | + return 'AHEE__EE_System__initialize'; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * Perform any early setup required for block editors to functions |
|
86 | - * |
|
87 | - * @return void |
|
88 | - * @throws Exception |
|
89 | - */ |
|
90 | - public function initialize() |
|
91 | - { |
|
92 | - $this->initializeBlocks(); |
|
93 | - add_action('AHEE__EE_System__initialize_last', array($this, 'registerBlocks')); |
|
94 | - add_action('wp_loaded', array($this, 'unloadAssets')); |
|
95 | - add_filter('block_categories_all', array($this, 'addEspressoBlockCategories'), 10, 2); |
|
96 | - } |
|
84 | + /** |
|
85 | + * Perform any early setup required for block editors to functions |
|
86 | + * |
|
87 | + * @return void |
|
88 | + * @throws Exception |
|
89 | + */ |
|
90 | + public function initialize() |
|
91 | + { |
|
92 | + $this->initializeBlocks(); |
|
93 | + add_action('AHEE__EE_System__initialize_last', array($this, 'registerBlocks')); |
|
94 | + add_action('wp_loaded', array($this, 'unloadAssets')); |
|
95 | + add_filter('block_categories_all', array($this, 'addEspressoBlockCategories'), 10, 2); |
|
96 | + } |
|
97 | 97 | |
98 | 98 | |
99 | - /** |
|
100 | - * @param array $categories |
|
101 | - * @since 4.9.71.p |
|
102 | - * @return array |
|
103 | - */ |
|
104 | - public function addEspressoBlockCategories(array $categories, $block_editor_context): array |
|
105 | - { |
|
106 | - // $block_editor_context can be either an object or a string |
|
107 | - // so checking it here, thus no type hinting in function params |
|
108 | - if (! $block_editor_context instanceof WP_Block_Editor_Context) { |
|
109 | - return $categories; |
|
110 | - } |
|
111 | - return array_merge( |
|
112 | - $categories, |
|
113 | - [ |
|
114 | - [ |
|
115 | - 'slug' => 'event-espresso', |
|
116 | - 'title' => esc_html__('Event Espresso', 'event_espresso'), |
|
117 | - ] |
|
118 | - ] |
|
119 | - ); |
|
120 | - } |
|
99 | + /** |
|
100 | + * @param array $categories |
|
101 | + * @since 4.9.71.p |
|
102 | + * @return array |
|
103 | + */ |
|
104 | + public function addEspressoBlockCategories(array $categories, $block_editor_context): array |
|
105 | + { |
|
106 | + // $block_editor_context can be either an object or a string |
|
107 | + // so checking it here, thus no type hinting in function params |
|
108 | + if (! $block_editor_context instanceof WP_Block_Editor_Context) { |
|
109 | + return $categories; |
|
110 | + } |
|
111 | + return array_merge( |
|
112 | + $categories, |
|
113 | + [ |
|
114 | + [ |
|
115 | + 'slug' => 'event-espresso', |
|
116 | + 'title' => esc_html__('Event Espresso', 'event_espresso'), |
|
117 | + ] |
|
118 | + ] |
|
119 | + ); |
|
120 | + } |
|
121 | 121 | |
122 | 122 | |
123 | - /** |
|
124 | - * @return CollectionInterface|BlockInterface[] |
|
125 | - * @throws CollectionLoaderException |
|
126 | - * @throws CollectionDetailsException |
|
127 | - */ |
|
128 | - protected function populateBlockCollection() |
|
129 | - { |
|
130 | - $loader = new CollectionLoader( |
|
131 | - new CollectionDetails( |
|
132 | - // collection name |
|
133 | - 'editor_blocks', |
|
134 | - // collection interface |
|
135 | - 'EventEspresso\core\domain\entities\editor\BlockInterface', |
|
136 | - // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
137 | - apply_filters( |
|
138 | - 'FHEE__EventEspresso_core_services_editor_BlockManager__populateBlockCollection__collection_FQCNs', |
|
139 | - array('EventEspresso\core\domain\entities\editor\blocks') |
|
140 | - ), |
|
141 | - // file paths to classes to add |
|
142 | - array(), |
|
143 | - // file mask to use if parsing folder for files to add |
|
144 | - '', |
|
145 | - // what to use as identifier for collection entities |
|
146 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
147 | - CollectionDetails::ID_CLASS_NAME |
|
148 | - ), |
|
149 | - $this->blocks |
|
150 | - ); |
|
151 | - return $loader->getCollection(); |
|
152 | - } |
|
123 | + /** |
|
124 | + * @return CollectionInterface|BlockInterface[] |
|
125 | + * @throws CollectionLoaderException |
|
126 | + * @throws CollectionDetailsException |
|
127 | + */ |
|
128 | + protected function populateBlockCollection() |
|
129 | + { |
|
130 | + $loader = new CollectionLoader( |
|
131 | + new CollectionDetails( |
|
132 | + // collection name |
|
133 | + 'editor_blocks', |
|
134 | + // collection interface |
|
135 | + 'EventEspresso\core\domain\entities\editor\BlockInterface', |
|
136 | + // FQCNs for classes to add (all classes within each namespace will be loaded) |
|
137 | + apply_filters( |
|
138 | + 'FHEE__EventEspresso_core_services_editor_BlockManager__populateBlockCollection__collection_FQCNs', |
|
139 | + array('EventEspresso\core\domain\entities\editor\blocks') |
|
140 | + ), |
|
141 | + // file paths to classes to add |
|
142 | + array(), |
|
143 | + // file mask to use if parsing folder for files to add |
|
144 | + '', |
|
145 | + // what to use as identifier for collection entities |
|
146 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
147 | + CollectionDetails::ID_CLASS_NAME |
|
148 | + ), |
|
149 | + $this->blocks |
|
150 | + ); |
|
151 | + return $loader->getCollection(); |
|
152 | + } |
|
153 | 153 | |
154 | 154 | |
155 | - /** |
|
156 | - * populates the BlockCollection and calls initialize() on all installed blocks |
|
157 | - * |
|
158 | - * @return void |
|
159 | - * @throws Exception |
|
160 | - */ |
|
161 | - public function initializeBlocks() |
|
162 | - { |
|
163 | - try { |
|
164 | - $this->populateBlockCollection(); |
|
165 | - // cycle thru block loaders and initialize each loader |
|
166 | - foreach ($this->blocks as $block) { |
|
167 | - $block->initialize(); |
|
168 | - $this->trackAssetManagersForBlocks($block); |
|
169 | - if (! $this->block_asset_manager_collection->has($block->assetManager())) { |
|
170 | - $this->block_asset_manager_collection->add($block->assetManager()); |
|
171 | - $block->assetManager()->setAssetHandles(); |
|
172 | - } |
|
173 | - } |
|
174 | - } catch (Exception $exception) { |
|
175 | - new ExceptionStackTraceDisplay($exception); |
|
176 | - } |
|
177 | - } |
|
155 | + /** |
|
156 | + * populates the BlockCollection and calls initialize() on all installed blocks |
|
157 | + * |
|
158 | + * @return void |
|
159 | + * @throws Exception |
|
160 | + */ |
|
161 | + public function initializeBlocks() |
|
162 | + { |
|
163 | + try { |
|
164 | + $this->populateBlockCollection(); |
|
165 | + // cycle thru block loaders and initialize each loader |
|
166 | + foreach ($this->blocks as $block) { |
|
167 | + $block->initialize(); |
|
168 | + $this->trackAssetManagersForBlocks($block); |
|
169 | + if (! $this->block_asset_manager_collection->has($block->assetManager())) { |
|
170 | + $this->block_asset_manager_collection->add($block->assetManager()); |
|
171 | + $block->assetManager()->setAssetHandles(); |
|
172 | + } |
|
173 | + } |
|
174 | + } catch (Exception $exception) { |
|
175 | + new ExceptionStackTraceDisplay($exception); |
|
176 | + } |
|
177 | + } |
|
178 | 178 | |
179 | 179 | |
180 | - /** |
|
181 | - * track blocks with routes that match the current request |
|
182 | - * |
|
183 | - * @param BlockInterface $block |
|
184 | - * @throws InvalidClassException |
|
185 | - */ |
|
186 | - private function trackAssetManagersForBlocks(BlockInterface $block) |
|
187 | - { |
|
188 | - $supported_routes = $block->supportedRoutes(); |
|
189 | - foreach ($supported_routes as $supported_route) { |
|
190 | - if ($this->route_manager->routeMatchesCurrentRequest($supported_route)) { |
|
191 | - $this->block_asset_managers[ $block->blockType() ] = $block->assetManager()->assetNamespace(); |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
180 | + /** |
|
181 | + * track blocks with routes that match the current request |
|
182 | + * |
|
183 | + * @param BlockInterface $block |
|
184 | + * @throws InvalidClassException |
|
185 | + */ |
|
186 | + private function trackAssetManagersForBlocks(BlockInterface $block) |
|
187 | + { |
|
188 | + $supported_routes = $block->supportedRoutes(); |
|
189 | + foreach ($supported_routes as $supported_route) { |
|
190 | + if ($this->route_manager->routeMatchesCurrentRequest($supported_route)) { |
|
191 | + $this->block_asset_managers[ $block->blockType() ] = $block->assetManager()->assetNamespace(); |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | 195 | |
196 | 196 | |
197 | - /** |
|
198 | - * returns true if the block should be registered for the current request |
|
199 | - * else removes block from block_routes array and returns false |
|
200 | - * |
|
201 | - * @param BlockInterface $block |
|
202 | - * @return boolean |
|
203 | - * @throws InvalidClassException |
|
204 | - */ |
|
205 | - public function matchesRoute(BlockInterface $block) |
|
206 | - { |
|
207 | - if (isset($this->block_asset_managers[ $block->blockType() ])) { |
|
208 | - return true; |
|
209 | - } |
|
210 | - unset($this->block_asset_managers[ $block->blockType() ]); |
|
211 | - return false; |
|
212 | - } |
|
197 | + /** |
|
198 | + * returns true if the block should be registered for the current request |
|
199 | + * else removes block from block_routes array and returns false |
|
200 | + * |
|
201 | + * @param BlockInterface $block |
|
202 | + * @return boolean |
|
203 | + * @throws InvalidClassException |
|
204 | + */ |
|
205 | + public function matchesRoute(BlockInterface $block) |
|
206 | + { |
|
207 | + if (isset($this->block_asset_managers[ $block->blockType() ])) { |
|
208 | + return true; |
|
209 | + } |
|
210 | + unset($this->block_asset_managers[ $block->blockType() ]); |
|
211 | + return false; |
|
212 | + } |
|
213 | 213 | |
214 | 214 | |
215 | - /** |
|
216 | - * calls registerBlock() and load assets for all installed blocks |
|
217 | - * |
|
218 | - * @return void |
|
219 | - * @throws Exception |
|
220 | - */ |
|
221 | - public function registerBlocks() |
|
222 | - { |
|
223 | - try { |
|
224 | - // cycle thru block loader folders |
|
225 | - foreach ($this->blocks as $block) { |
|
226 | - if (! $this->matchesRoute($block)) { |
|
227 | - continue; |
|
228 | - } |
|
229 | - // perform any setup required for the block |
|
230 | - $block_type = $block->registerBlock(); |
|
231 | - if (! $block_type instanceof WP_Block_Type) { |
|
232 | - throw new InvalidEntityException($block_type, 'WP_Block_Type'); |
|
233 | - } |
|
234 | - do_action( |
|
235 | - 'FHEE__EventEspresso_core_services_editor_BlockManager__registerBlocks__block_type_registered', |
|
236 | - $block, |
|
237 | - $block_type |
|
238 | - ); |
|
239 | - } |
|
240 | - } catch (Exception $exception) { |
|
241 | - new ExceptionStackTraceDisplay($exception); |
|
242 | - } |
|
243 | - } |
|
215 | + /** |
|
216 | + * calls registerBlock() and load assets for all installed blocks |
|
217 | + * |
|
218 | + * @return void |
|
219 | + * @throws Exception |
|
220 | + */ |
|
221 | + public function registerBlocks() |
|
222 | + { |
|
223 | + try { |
|
224 | + // cycle thru block loader folders |
|
225 | + foreach ($this->blocks as $block) { |
|
226 | + if (! $this->matchesRoute($block)) { |
|
227 | + continue; |
|
228 | + } |
|
229 | + // perform any setup required for the block |
|
230 | + $block_type = $block->registerBlock(); |
|
231 | + if (! $block_type instanceof WP_Block_Type) { |
|
232 | + throw new InvalidEntityException($block_type, 'WP_Block_Type'); |
|
233 | + } |
|
234 | + do_action( |
|
235 | + 'FHEE__EventEspresso_core_services_editor_BlockManager__registerBlocks__block_type_registered', |
|
236 | + $block, |
|
237 | + $block_type |
|
238 | + ); |
|
239 | + } |
|
240 | + } catch (Exception $exception) { |
|
241 | + new ExceptionStackTraceDisplay($exception); |
|
242 | + } |
|
243 | + } |
|
244 | 244 | |
245 | - public function unloadAssets() |
|
246 | - { |
|
247 | - $assets = array_flip($this->block_asset_managers); |
|
248 | - foreach ($this->block_asset_manager_collection as $asset_manager) { |
|
249 | - // if there are no longer any blocks that require these assets, |
|
250 | - if (! isset($assets[ $asset_manager->assetNamespace() ])) { |
|
251 | - // then unset asset enqueueing and bail |
|
252 | - remove_action('wp_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0); |
|
253 | - remove_action('admin_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0); |
|
254 | - remove_action('wp_enqueue_scripts', array($asset_manager, 'addAssets'), 2); |
|
255 | - remove_action('admin_enqueue_scripts', array($asset_manager, 'addAssets'), 2); |
|
256 | - } |
|
257 | - } |
|
258 | - } |
|
245 | + public function unloadAssets() |
|
246 | + { |
|
247 | + $assets = array_flip($this->block_asset_managers); |
|
248 | + foreach ($this->block_asset_manager_collection as $asset_manager) { |
|
249 | + // if there are no longer any blocks that require these assets, |
|
250 | + if (! isset($assets[ $asset_manager->assetNamespace() ])) { |
|
251 | + // then unset asset enqueueing and bail |
|
252 | + remove_action('wp_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0); |
|
253 | + remove_action('admin_enqueue_scripts', array($asset_manager, 'addManifestFile'), 0); |
|
254 | + remove_action('wp_enqueue_scripts', array($asset_manager, 'addAssets'), 2); |
|
255 | + remove_action('admin_enqueue_scripts', array($asset_manager, 'addAssets'), 2); |
|
256 | + } |
|
257 | + } |
|
258 | + } |
|
259 | 259 | } |