@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public static function register(string $addon_name = '', array $setup_args = []): bool |
31 | 31 | { |
32 | - self::$exporters[ $addon_name ] = $setup_args; |
|
32 | + self::$exporters[$addon_name] = $setup_args; |
|
33 | 33 | // add to list of modules to be registered |
34 | 34 | add_filter( |
35 | 35 | 'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters', |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public static function deregister(string $addon_name = '') |
46 | 46 | { |
47 | - unset(self::$exporters[ $addon_name ]); |
|
47 | + unset(self::$exporters[$addon_name]); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 |
@@ -12,51 +12,51 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_Register_Personal_Data_Exporter implements EEI_Plugin_API |
14 | 14 | { |
15 | - /** |
|
16 | - * FQCN for all privacy policy generators |
|
17 | - * |
|
18 | - * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
19 | - */ |
|
20 | - protected static $exporters = []; |
|
15 | + /** |
|
16 | + * FQCN for all privacy policy generators |
|
17 | + * |
|
18 | + * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
19 | + */ |
|
20 | + protected static $exporters = []; |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @param string $addon_name |
|
25 | - * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies, |
|
26 | - * OR fully qualified class names of privacy policies |
|
27 | - * @return bool |
|
28 | - */ |
|
29 | - public static function register(string $addon_name = '', array $setup_args = []): bool |
|
30 | - { |
|
31 | - self::$exporters[ $addon_name ] = $setup_args; |
|
32 | - // add to list of modules to be registered |
|
33 | - add_filter( |
|
34 | - 'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters', |
|
35 | - ['EE_Register_Personal_Data_Exporter', 'addExporters'] |
|
36 | - ); |
|
37 | - return true; |
|
38 | - } |
|
23 | + /** |
|
24 | + * @param string $addon_name |
|
25 | + * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies, |
|
26 | + * OR fully qualified class names of privacy policies |
|
27 | + * @return bool |
|
28 | + */ |
|
29 | + public static function register(string $addon_name = '', array $setup_args = []): bool |
|
30 | + { |
|
31 | + self::$exporters[ $addon_name ] = $setup_args; |
|
32 | + // add to list of modules to be registered |
|
33 | + add_filter( |
|
34 | + 'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters', |
|
35 | + ['EE_Register_Personal_Data_Exporter', 'addExporters'] |
|
36 | + ); |
|
37 | + return true; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * @param string $addon_name |
|
43 | - */ |
|
44 | - public static function deregister(string $addon_name = '') |
|
45 | - { |
|
46 | - unset(self::$exporters[ $addon_name ]); |
|
47 | - } |
|
41 | + /** |
|
42 | + * @param string $addon_name |
|
43 | + */ |
|
44 | + public static function deregister(string $addon_name = '') |
|
45 | + { |
|
46 | + unset(self::$exporters[ $addon_name ]); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * Adds our personal data exporters registered by add-ons |
|
52 | - * |
|
53 | - * @param string[] $exporters |
|
54 | - * @return string[] |
|
55 | - */ |
|
56 | - public static function addExporters(array $exporters): array |
|
57 | - { |
|
58 | - return array_merge($exporters, ...self::$exporters); |
|
59 | - } |
|
50 | + /** |
|
51 | + * Adds our personal data exporters registered by add-ons |
|
52 | + * |
|
53 | + * @param string[] $exporters |
|
54 | + * @return string[] |
|
55 | + */ |
|
56 | + public static function addExporters(array $exporters): array |
|
57 | + { |
|
58 | + return array_merge($exporters, ...self::$exporters); |
|
59 | + } |
|
60 | 60 | } |
61 | 61 | // End of file EE_Register_Personal_Data_Exporter.lib.php |
62 | 62 | // Location: ${NAMESPACE}/EE_Register_Personal_Data_Exporter.lib.php |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public static function register(string $addon_name = '', array $setup_args = []): bool |
31 | 31 | { |
32 | - self::$erasers[ $addon_name ] = $setup_args; |
|
32 | + self::$erasers[$addon_name] = $setup_args; |
|
33 | 33 | // add to list of modules to be registered |
34 | 34 | add_filter( |
35 | 35 | 'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public static function deregister(string $addon_name = '') |
46 | 46 | { |
47 | - unset(self::$erasers[ $addon_name ]); |
|
47 | + unset(self::$erasers[$addon_name]); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 |
@@ -12,51 +12,51 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_Register_Personal_Data_Eraser implements EEI_Plugin_API |
14 | 14 | { |
15 | - /** |
|
16 | - * FQCN for all privacy policy generators |
|
17 | - * |
|
18 | - * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
19 | - */ |
|
20 | - protected static $erasers = []; |
|
15 | + /** |
|
16 | + * FQCN for all privacy policy generators |
|
17 | + * |
|
18 | + * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
19 | + */ |
|
20 | + protected static $erasers = []; |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @param string $addon_name |
|
25 | - * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies, |
|
26 | - * OR fully qualified class names of privacy policies |
|
27 | - * @return bool |
|
28 | - */ |
|
29 | - public static function register(string $addon_name = '', array $setup_args = []): bool |
|
30 | - { |
|
31 | - self::$erasers[ $addon_name ] = $setup_args; |
|
32 | - // add to list of modules to be registered |
|
33 | - add_filter( |
|
34 | - 'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
|
35 | - ['EE_Register_Personal_Data_Eraser', 'addErasers'] |
|
36 | - ); |
|
37 | - return true; |
|
38 | - } |
|
23 | + /** |
|
24 | + * @param string $addon_name |
|
25 | + * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies, |
|
26 | + * OR fully qualified class names of privacy policies |
|
27 | + * @return bool |
|
28 | + */ |
|
29 | + public static function register(string $addon_name = '', array $setup_args = []): bool |
|
30 | + { |
|
31 | + self::$erasers[ $addon_name ] = $setup_args; |
|
32 | + // add to list of modules to be registered |
|
33 | + add_filter( |
|
34 | + 'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
|
35 | + ['EE_Register_Personal_Data_Eraser', 'addErasers'] |
|
36 | + ); |
|
37 | + return true; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * @param string $addon_name |
|
43 | - */ |
|
44 | - public static function deregister(string $addon_name = '') |
|
45 | - { |
|
46 | - unset(self::$erasers[ $addon_name ]); |
|
47 | - } |
|
41 | + /** |
|
42 | + * @param string $addon_name |
|
43 | + */ |
|
44 | + public static function deregister(string $addon_name = '') |
|
45 | + { |
|
46 | + unset(self::$erasers[ $addon_name ]); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * Adds our personal data erasers registered by add-ons |
|
52 | - * |
|
53 | - * @param string[] $erasers |
|
54 | - * @return string[] |
|
55 | - */ |
|
56 | - public static function addErasers(array $erasers): array |
|
57 | - { |
|
58 | - return array_merge($erasers, ...self::$erasers); |
|
59 | - } |
|
50 | + /** |
|
51 | + * Adds our personal data erasers registered by add-ons |
|
52 | + * |
|
53 | + * @param string[] $erasers |
|
54 | + * @return string[] |
|
55 | + */ |
|
56 | + public static function addErasers(array $erasers): array |
|
57 | + { |
|
58 | + return array_merge($erasers, ...self::$erasers); |
|
59 | + } |
|
60 | 60 | } |
61 | 61 | // End of file EE_Register_Personal_Data_Eraser.lib.php |
62 | 62 | // Location: ${NAMESPACE}/EE_Register_Personal_Data_Eraser.lib.php |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | // make sure we don't register twice |
51 | - if (isset(self::$_settings[ $addon_name ])) { |
|
51 | + if (isset(self::$_settings[$addon_name])) { |
|
52 | 52 | return true; |
53 | 53 | } |
54 | 54 | |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | ); |
69 | 69 | } |
70 | 70 | // setup $_settings array from incoming values. |
71 | - self::$_settings[ $addon_name ] = [ |
|
71 | + self::$_settings[$addon_name] = [ |
|
72 | 72 | // array of full server paths to any EED_Widgets used by the widget |
73 | 73 | 'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : [], |
74 | 74 | ]; |
@@ -109,6 +109,6 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public static function deregister(string $addon_name = '') |
111 | 111 | { |
112 | - unset(self::$_settings[ $addon_name ]); |
|
112 | + unset(self::$_settings[$addon_name]); |
|
113 | 113 | } |
114 | 114 | } |
@@ -14,100 +14,100 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_Register_Widget implements EEI_Plugin_API |
16 | 16 | { |
17 | - /** |
|
18 | - * Holds values for registered widgets |
|
19 | - * |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected static $_settings = []; |
|
17 | + /** |
|
18 | + * Holds values for registered widgets |
|
19 | + * |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected static $_settings = []; |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Method for registering new EED_Widgets |
|
27 | - * |
|
28 | - * @param string $addon_name a unique identifier for this set of widgets |
|
29 | - * @param array $setup_args an array of arguments provided for registering widgets |
|
30 | - * @type array widget_paths an array of full server paths to folders containing any EED_Widgets, or to the |
|
31 | - * EED_Widget files themselves |
|
32 | - * @return bool |
|
33 | - * @throws EE_Error |
|
34 | - * @since 4.3.0 |
|
35 | - */ |
|
36 | - public static function register(string $addon_name = '', array $setup_args = []): bool |
|
37 | - { |
|
25 | + /** |
|
26 | + * Method for registering new EED_Widgets |
|
27 | + * |
|
28 | + * @param string $addon_name a unique identifier for this set of widgets |
|
29 | + * @param array $setup_args an array of arguments provided for registering widgets |
|
30 | + * @type array widget_paths an array of full server paths to folders containing any EED_Widgets, or to the |
|
31 | + * EED_Widget files themselves |
|
32 | + * @return bool |
|
33 | + * @throws EE_Error |
|
34 | + * @since 4.3.0 |
|
35 | + */ |
|
36 | + public static function register(string $addon_name = '', array $setup_args = []): bool |
|
37 | + { |
|
38 | 38 | |
39 | - // required fields MUST be present, so let's make sure they are. |
|
40 | - if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['widget_paths'])) { |
|
41 | - throw new EE_Error( |
|
42 | - esc_html__( |
|
43 | - 'In order to register Widgets with EE_Register_Widget::register(), you must include a "widget_id" (a unique identifier for this set of widgets), and an array containing the following keys: "widget_paths" (an array of full server paths to folders that contain widgets, or to the widget files themselves)', |
|
44 | - 'event_espresso' |
|
45 | - ) |
|
46 | - ); |
|
47 | - } |
|
39 | + // required fields MUST be present, so let's make sure they are. |
|
40 | + if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['widget_paths'])) { |
|
41 | + throw new EE_Error( |
|
42 | + esc_html__( |
|
43 | + 'In order to register Widgets with EE_Register_Widget::register(), you must include a "widget_id" (a unique identifier for this set of widgets), and an array containing the following keys: "widget_paths" (an array of full server paths to folders that contain widgets, or to the widget files themselves)', |
|
44 | + 'event_espresso' |
|
45 | + ) |
|
46 | + ); |
|
47 | + } |
|
48 | 48 | |
49 | - // make sure we don't register twice |
|
50 | - if (isset(self::$_settings[ $addon_name ])) { |
|
51 | - return true; |
|
52 | - } |
|
49 | + // make sure we don't register twice |
|
50 | + if (isset(self::$_settings[ $addon_name ])) { |
|
51 | + return true; |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - // make sure this was called in the right place! |
|
56 | - if ( |
|
57 | - ! did_action('AHEE__EE_System__load_espresso_addons') |
|
58 | - || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
59 | - ) { |
|
60 | - EE_Error::doing_it_wrong( |
|
61 | - __METHOD__, |
|
62 | - esc_html__( |
|
63 | - 'An attempt to register widgets has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register widgets.', |
|
64 | - 'event_espresso' |
|
65 | - ), |
|
66 | - '4.3.0' |
|
67 | - ); |
|
68 | - } |
|
69 | - // setup $_settings array from incoming values. |
|
70 | - self::$_settings[ $addon_name ] = [ |
|
71 | - // array of full server paths to any EED_Widgets used by the widget |
|
72 | - 'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : [], |
|
73 | - ]; |
|
74 | - // add to list of widgets to be registered |
|
75 | - add_filter( |
|
76 | - 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
77 | - ['EE_Register_Widget', 'add_widgets'] |
|
78 | - ); |
|
79 | - return true; |
|
80 | - } |
|
55 | + // make sure this was called in the right place! |
|
56 | + if ( |
|
57 | + ! did_action('AHEE__EE_System__load_espresso_addons') |
|
58 | + || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
59 | + ) { |
|
60 | + EE_Error::doing_it_wrong( |
|
61 | + __METHOD__, |
|
62 | + esc_html__( |
|
63 | + 'An attempt to register widgets has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register widgets.', |
|
64 | + 'event_espresso' |
|
65 | + ), |
|
66 | + '4.3.0' |
|
67 | + ); |
|
68 | + } |
|
69 | + // setup $_settings array from incoming values. |
|
70 | + self::$_settings[ $addon_name ] = [ |
|
71 | + // array of full server paths to any EED_Widgets used by the widget |
|
72 | + 'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : [], |
|
73 | + ]; |
|
74 | + // add to list of widgets to be registered |
|
75 | + add_filter( |
|
76 | + 'FHEE__EE_Config__register_widgets__widgets_to_register', |
|
77 | + ['EE_Register_Widget', 'add_widgets'] |
|
78 | + ); |
|
79 | + return true; |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * Filters the list of widgets to add ours. |
|
85 | - * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg. |
|
86 | - * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/widgets/espresso_monkey'...) |
|
87 | - * |
|
88 | - * @param array $widgets_to_register array of paths to all widgets that require registering |
|
89 | - * @return array |
|
90 | - */ |
|
91 | - public static function add_widgets(array $widgets_to_register = []): array |
|
92 | - { |
|
93 | - $widget_paths = []; |
|
94 | - foreach (self::$_settings as $settings) { |
|
95 | - $widget_paths[] = $settings['widget_paths']; |
|
96 | - } |
|
97 | - return array_merge($widgets_to_register, ...$widget_paths); |
|
98 | - } |
|
83 | + /** |
|
84 | + * Filters the list of widgets to add ours. |
|
85 | + * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg. |
|
86 | + * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/widgets/espresso_monkey'...) |
|
87 | + * |
|
88 | + * @param array $widgets_to_register array of paths to all widgets that require registering |
|
89 | + * @return array |
|
90 | + */ |
|
91 | + public static function add_widgets(array $widgets_to_register = []): array |
|
92 | + { |
|
93 | + $widget_paths = []; |
|
94 | + foreach (self::$_settings as $settings) { |
|
95 | + $widget_paths[] = $settings['widget_paths']; |
|
96 | + } |
|
97 | + return array_merge($widgets_to_register, ...$widget_paths); |
|
98 | + } |
|
99 | 99 | |
100 | 100 | |
101 | - /** |
|
102 | - * This deregisters a widget that was previously registered with a specific $addon_name. |
|
103 | - * |
|
104 | - * @param string $addon_name the name for the widget that was previously registered |
|
105 | - * @return void |
|
106 | - * @since 4.3.0 |
|
107 | - * |
|
108 | - */ |
|
109 | - public static function deregister(string $addon_name = '') |
|
110 | - { |
|
111 | - unset(self::$_settings[ $addon_name ]); |
|
112 | - } |
|
101 | + /** |
|
102 | + * This deregisters a widget that was previously registered with a specific $addon_name. |
|
103 | + * |
|
104 | + * @param string $addon_name the name for the widget that was previously registered |
|
105 | + * @return void |
|
106 | + * @since 4.3.0 |
|
107 | + * |
|
108 | + */ |
|
109 | + public static function deregister(string $addon_name = '') |
|
110 | + { |
|
111 | + unset(self::$_settings[ $addon_name ]); |
|
112 | + } |
|
113 | 113 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | // make sure we don't register twice |
68 | - if (isset(self::$_ee_messages_shortcode_registry[ $addon_name ])) { |
|
68 | + if (isset(self::$_ee_messages_shortcode_registry[$addon_name])) { |
|
69 | 69 | return true; |
70 | 70 | } |
71 | 71 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | ); |
88 | 88 | } |
89 | 89 | |
90 | - self::$_ee_messages_shortcode_registry[ $addon_name ] = [ |
|
90 | + self::$_ee_messages_shortcode_registry[$addon_name] = [ |
|
91 | 91 | 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
92 | 92 | 'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes']) |
93 | 93 | ? (array) $setup_args['list_type_shortcodes'] : [], |
@@ -101,19 +101,19 @@ discard block |
||
101 | 101 | ); |
102 | 102 | |
103 | 103 | // add below filters if the required callback is provided. |
104 | - if (! empty($setup_args['msgr_validator_callback'])) { |
|
104 | + if ( ! empty($setup_args['msgr_validator_callback'])) { |
|
105 | 105 | add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2); |
106 | 106 | } |
107 | 107 | |
108 | - if (! empty($setup_args['msgr_template_fields_callback'])) { |
|
108 | + if ( ! empty($setup_args['msgr_template_fields_callback'])) { |
|
109 | 109 | add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2); |
110 | 110 | } |
111 | 111 | |
112 | - if (! empty($setup_args['valid_shortcodes_callback'])) { |
|
112 | + if ( ! empty($setup_args['valid_shortcodes_callback'])) { |
|
113 | 113 | add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2); |
114 | 114 | } |
115 | 115 | |
116 | - if (! empty($setup_args['list_type_shortcodes'])) { |
|
116 | + if ( ! empty($setup_args['list_type_shortcodes'])) { |
|
117 | 117 | add_filter( |
118 | 118 | 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', |
119 | 119 | ['EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'], |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public static function deregister(string $addon_name = '') |
135 | 135 | { |
136 | - unset(self::$_ee_messages_shortcode_registry[ $addon_name ]); |
|
136 | + unset(self::$_ee_messages_shortcode_registry[$addon_name]); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | public static function register_msgs_autoload_paths(array $paths): array |
149 | 149 | { |
150 | 150 | $autoload_paths = []; |
151 | - if (! empty(self::$_ee_messages_shortcode_registry)) { |
|
151 | + if ( ! empty(self::$_ee_messages_shortcode_registry)) { |
|
152 | 152 | foreach (self::$_ee_messages_shortcode_registry as $st_reg) { |
153 | 153 | if (empty($st_reg['autoloadpaths'])) { |
154 | 154 | continue; |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | } |
177 | 177 | $shortcodes = []; |
178 | 178 | foreach (self::$_ee_messages_shortcode_registry as $sc_reg) { |
179 | - if (! empty($sc_reg['list_type_shortcodes'])) { |
|
179 | + if ( ! empty($sc_reg['list_type_shortcodes'])) { |
|
180 | 180 | $shortcodes[] = $sc_reg['list_type_shortcodes']; |
181 | 181 | } |
182 | 182 | } |
@@ -10,174 +10,174 @@ |
||
10 | 10 | */ |
11 | 11 | class EE_Register_Messages_Shortcode_Library implements EEI_Plugin_API |
12 | 12 | { |
13 | - /** |
|
14 | - * holds values for registered messages shortcode libraries |
|
15 | - * |
|
16 | - * @var array |
|
17 | - */ |
|
18 | - protected static $_ee_messages_shortcode_registry = []; |
|
19 | - |
|
20 | - |
|
21 | - /** |
|
22 | - * Helper method for registering a new shortcodes library class for the messages system. |
|
23 | - * |
|
24 | - * Note this is not used for adding shortcodes to existing libraries. It's for registering anything |
|
25 | - * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class. |
|
26 | - * |
|
27 | - * @param string $addon_name What is the name of this shortcode library (e.g. 'question_list'); |
|
28 | - * @param array $setup_args An array of arguments provided for registering the new messages shortcode library. |
|
29 | - * { |
|
30 | - * |
|
31 | - * @type array $autoloadpaths An array of paths to add to the messages autoloader |
|
32 | - * for the new shortcode library class file. |
|
33 | - * @type string $msgr_validator_callback Callback for a method that will register the library with the |
|
34 | - * messenger _validator_config. Optional. |
|
35 | - * @type string $msgr_template_fields_callback Callback for changing adding the _template_fields property for |
|
36 | - * messenger. For example, the shortcode library may add a new |
|
37 | - * field to the message templates. Optional. |
|
38 | - * @type string $valid_shortcodes_callback Callback for message types _valid_shortcodes array setup. |
|
39 | - * Optional. |
|
40 | - * @type array $list_type_shortcodes If there are any specific shortcodes with this message |
|
41 | - * shortcode library that should be considered "list type" |
|
42 | - * then include them in an array. |
|
43 | - * List Type shortcodes are shortcodes that have a corresponding |
|
44 | - * field that indicates how they are parsed. Optional. |
|
45 | - * } |
|
46 | - * @return bool |
|
47 | - * @throws EE_Error |
|
48 | - * @throws EE_Error |
|
49 | - * @since 4.3.0 |
|
50 | - * |
|
51 | - */ |
|
52 | - public static function register(string $addon_name = '', array $setup_args = []): bool |
|
53 | - { |
|
54 | - |
|
55 | - // required fields MUST be present, so let's make sure they are. |
|
56 | - if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) { |
|
57 | - throw new EE_Error( |
|
58 | - esc_html__( |
|
59 | - 'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', |
|
60 | - 'event_espresso' |
|
61 | - ) |
|
62 | - ); |
|
63 | - } |
|
64 | - |
|
65 | - // make sure we don't register twice |
|
66 | - if (isset(self::$_ee_messages_shortcode_registry[ $addon_name ])) { |
|
67 | - return true; |
|
68 | - } |
|
69 | - |
|
70 | - // make sure this was called in the right place! |
|
71 | - if ( |
|
72 | - ! did_action('EE_Brewing_Regular___messages_caf') |
|
73 | - || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
74 | - ) { |
|
75 | - EE_Error::doing_it_wrong( |
|
76 | - __METHOD__, |
|
77 | - sprintf( |
|
78 | - esc_html__( |
|
79 | - 'Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - $addon_name |
|
83 | - ), |
|
84 | - '4.3.0' |
|
85 | - ); |
|
86 | - } |
|
87 | - |
|
88 | - self::$_ee_messages_shortcode_registry[ $addon_name ] = [ |
|
89 | - 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
|
90 | - 'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes']) |
|
91 | - ? (array) $setup_args['list_type_shortcodes'] : [], |
|
92 | - ]; |
|
93 | - |
|
94 | - // add filters |
|
95 | - add_filter( |
|
96 | - 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
97 | - ['EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'], |
|
98 | - 10 |
|
99 | - ); |
|
100 | - |
|
101 | - // add below filters if the required callback is provided. |
|
102 | - if (! empty($setup_args['msgr_validator_callback'])) { |
|
103 | - add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2); |
|
104 | - } |
|
105 | - |
|
106 | - if (! empty($setup_args['msgr_template_fields_callback'])) { |
|
107 | - add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2); |
|
108 | - } |
|
109 | - |
|
110 | - if (! empty($setup_args['valid_shortcodes_callback'])) { |
|
111 | - add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2); |
|
112 | - } |
|
113 | - |
|
114 | - if (! empty($setup_args['list_type_shortcodes'])) { |
|
115 | - add_filter( |
|
116 | - 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', |
|
117 | - ['EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'], |
|
118 | - 10 |
|
119 | - ); |
|
120 | - } |
|
121 | - return true; |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * This deregisters any messages shortcode library previously registered with the given name. |
|
127 | - * |
|
128 | - * @param string $addon_name name used to register the shortcode library. |
|
129 | - * @return void |
|
130 | - * @since 4.3.0 |
|
131 | - */ |
|
132 | - public static function deregister(string $addon_name = '') |
|
133 | - { |
|
134 | - unset(self::$_ee_messages_shortcode_registry[ $addon_name ]); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - /** |
|
139 | - * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
140 | - * |
|
141 | - * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
142 | - * @return array |
|
143 | - * @since 4.3.0 |
|
144 | - * |
|
145 | - */ |
|
146 | - public static function register_msgs_autoload_paths(array $paths): array |
|
147 | - { |
|
148 | - $autoload_paths = []; |
|
149 | - if (! empty(self::$_ee_messages_shortcode_registry)) { |
|
150 | - foreach (self::$_ee_messages_shortcode_registry as $st_reg) { |
|
151 | - if (empty($st_reg['autoloadpaths'])) { |
|
152 | - continue; |
|
153 | - } |
|
154 | - $autoload_paths[] = $st_reg['autoloadpaths']; |
|
155 | - } |
|
156 | - } |
|
157 | - return array_merge($paths, ...$autoload_paths); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes |
|
163 | - * filter which is used to add additional list type shortcodes. |
|
164 | - * |
|
165 | - * @param array $original_shortcodes |
|
166 | - * @return array Modifications to original shortcodes. |
|
167 | - * @since 4.3.0 |
|
168 | - * |
|
169 | - */ |
|
170 | - public static function register_list_type_shortcodes(array $original_shortcodes): array |
|
171 | - { |
|
172 | - if (empty(self::$_ee_messages_shortcode_registry)) { |
|
173 | - return $original_shortcodes; |
|
174 | - } |
|
175 | - $shortcodes = []; |
|
176 | - foreach (self::$_ee_messages_shortcode_registry as $sc_reg) { |
|
177 | - if (! empty($sc_reg['list_type_shortcodes'])) { |
|
178 | - $shortcodes[] = $sc_reg['list_type_shortcodes']; |
|
179 | - } |
|
180 | - } |
|
181 | - return array_merge($original_shortcodes, ...$shortcodes); |
|
182 | - } |
|
13 | + /** |
|
14 | + * holds values for registered messages shortcode libraries |
|
15 | + * |
|
16 | + * @var array |
|
17 | + */ |
|
18 | + protected static $_ee_messages_shortcode_registry = []; |
|
19 | + |
|
20 | + |
|
21 | + /** |
|
22 | + * Helper method for registering a new shortcodes library class for the messages system. |
|
23 | + * |
|
24 | + * Note this is not used for adding shortcodes to existing libraries. It's for registering anything |
|
25 | + * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class. |
|
26 | + * |
|
27 | + * @param string $addon_name What is the name of this shortcode library (e.g. 'question_list'); |
|
28 | + * @param array $setup_args An array of arguments provided for registering the new messages shortcode library. |
|
29 | + * { |
|
30 | + * |
|
31 | + * @type array $autoloadpaths An array of paths to add to the messages autoloader |
|
32 | + * for the new shortcode library class file. |
|
33 | + * @type string $msgr_validator_callback Callback for a method that will register the library with the |
|
34 | + * messenger _validator_config. Optional. |
|
35 | + * @type string $msgr_template_fields_callback Callback for changing adding the _template_fields property for |
|
36 | + * messenger. For example, the shortcode library may add a new |
|
37 | + * field to the message templates. Optional. |
|
38 | + * @type string $valid_shortcodes_callback Callback for message types _valid_shortcodes array setup. |
|
39 | + * Optional. |
|
40 | + * @type array $list_type_shortcodes If there are any specific shortcodes with this message |
|
41 | + * shortcode library that should be considered "list type" |
|
42 | + * then include them in an array. |
|
43 | + * List Type shortcodes are shortcodes that have a corresponding |
|
44 | + * field that indicates how they are parsed. Optional. |
|
45 | + * } |
|
46 | + * @return bool |
|
47 | + * @throws EE_Error |
|
48 | + * @throws EE_Error |
|
49 | + * @since 4.3.0 |
|
50 | + * |
|
51 | + */ |
|
52 | + public static function register(string $addon_name = '', array $setup_args = []): bool |
|
53 | + { |
|
54 | + |
|
55 | + // required fields MUST be present, so let's make sure they are. |
|
56 | + if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) { |
|
57 | + throw new EE_Error( |
|
58 | + esc_html__( |
|
59 | + 'In order to register a messages shortcode library with EE_Register_Messages_Shortcode_Library::register, you must include a "name" (a unique identifier for this set of message shortcodes), and an array containing the following keys: : "autoload_paths"', |
|
60 | + 'event_espresso' |
|
61 | + ) |
|
62 | + ); |
|
63 | + } |
|
64 | + |
|
65 | + // make sure we don't register twice |
|
66 | + if (isset(self::$_ee_messages_shortcode_registry[ $addon_name ])) { |
|
67 | + return true; |
|
68 | + } |
|
69 | + |
|
70 | + // make sure this was called in the right place! |
|
71 | + if ( |
|
72 | + ! did_action('EE_Brewing_Regular___messages_caf') |
|
73 | + || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
74 | + ) { |
|
75 | + EE_Error::doing_it_wrong( |
|
76 | + __METHOD__, |
|
77 | + sprintf( |
|
78 | + esc_html__( |
|
79 | + 'Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + $addon_name |
|
83 | + ), |
|
84 | + '4.3.0' |
|
85 | + ); |
|
86 | + } |
|
87 | + |
|
88 | + self::$_ee_messages_shortcode_registry[ $addon_name ] = [ |
|
89 | + 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
|
90 | + 'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes']) |
|
91 | + ? (array) $setup_args['list_type_shortcodes'] : [], |
|
92 | + ]; |
|
93 | + |
|
94 | + // add filters |
|
95 | + add_filter( |
|
96 | + 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
97 | + ['EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'], |
|
98 | + 10 |
|
99 | + ); |
|
100 | + |
|
101 | + // add below filters if the required callback is provided. |
|
102 | + if (! empty($setup_args['msgr_validator_callback'])) { |
|
103 | + add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2); |
|
104 | + } |
|
105 | + |
|
106 | + if (! empty($setup_args['msgr_template_fields_callback'])) { |
|
107 | + add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2); |
|
108 | + } |
|
109 | + |
|
110 | + if (! empty($setup_args['valid_shortcodes_callback'])) { |
|
111 | + add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2); |
|
112 | + } |
|
113 | + |
|
114 | + if (! empty($setup_args['list_type_shortcodes'])) { |
|
115 | + add_filter( |
|
116 | + 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', |
|
117 | + ['EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'], |
|
118 | + 10 |
|
119 | + ); |
|
120 | + } |
|
121 | + return true; |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * This deregisters any messages shortcode library previously registered with the given name. |
|
127 | + * |
|
128 | + * @param string $addon_name name used to register the shortcode library. |
|
129 | + * @return void |
|
130 | + * @since 4.3.0 |
|
131 | + */ |
|
132 | + public static function deregister(string $addon_name = '') |
|
133 | + { |
|
134 | + unset(self::$_ee_messages_shortcode_registry[ $addon_name ]); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + /** |
|
139 | + * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
140 | + * |
|
141 | + * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
142 | + * @return array |
|
143 | + * @since 4.3.0 |
|
144 | + * |
|
145 | + */ |
|
146 | + public static function register_msgs_autoload_paths(array $paths): array |
|
147 | + { |
|
148 | + $autoload_paths = []; |
|
149 | + if (! empty(self::$_ee_messages_shortcode_registry)) { |
|
150 | + foreach (self::$_ee_messages_shortcode_registry as $st_reg) { |
|
151 | + if (empty($st_reg['autoloadpaths'])) { |
|
152 | + continue; |
|
153 | + } |
|
154 | + $autoload_paths[] = $st_reg['autoloadpaths']; |
|
155 | + } |
|
156 | + } |
|
157 | + return array_merge($paths, ...$autoload_paths); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes |
|
163 | + * filter which is used to add additional list type shortcodes. |
|
164 | + * |
|
165 | + * @param array $original_shortcodes |
|
166 | + * @return array Modifications to original shortcodes. |
|
167 | + * @since 4.3.0 |
|
168 | + * |
|
169 | + */ |
|
170 | + public static function register_list_type_shortcodes(array $original_shortcodes): array |
|
171 | + { |
|
172 | + if (empty(self::$_ee_messages_shortcode_registry)) { |
|
173 | + return $original_shortcodes; |
|
174 | + } |
|
175 | + $shortcodes = []; |
|
176 | + foreach (self::$_ee_messages_shortcode_registry as $sc_reg) { |
|
177 | + if (! empty($sc_reg['list_type_shortcodes'])) { |
|
178 | + $shortcodes[] = $sc_reg['list_type_shortcodes']; |
|
179 | + } |
|
180 | + } |
|
181 | + return array_merge($original_shortcodes, ...$shortcodes); |
|
182 | + } |
|
183 | 183 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | ); |
49 | 49 | } |
50 | 50 | // make sure we don't register twice |
51 | - if (isset(self::$_settings[ $addon_name ])) { |
|
51 | + if (isset(self::$_settings[$addon_name])) { |
|
52 | 52 | return true; |
53 | 53 | } |
54 | 54 | // make sure this was called in the right place! |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | ); |
67 | 67 | } |
68 | 68 | // setup $_settings array from incoming values. |
69 | - self::$_settings[ $addon_name ] = ['dms_paths' => (array) $setup_args['dms_paths']]; |
|
69 | + self::$_settings[$addon_name] = ['dms_paths' => (array) $setup_args['dms_paths']]; |
|
70 | 70 | // setup DMS |
71 | 71 | $filters_set = has_filter( |
72 | 72 | 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', |
73 | 73 | ['EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'] |
74 | 74 | ); |
75 | - if (! $filters_set) { |
|
75 | + if ( ! $filters_set) { |
|
76 | 76 | add_filter( |
77 | 77 | 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', |
78 | 78 | ['EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'] |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | // so if for some reason an addon has multiple dms paths, |
97 | 97 | // we append one or more * to the classname |
98 | 98 | // which will get stripped out later on |
99 | - $dms_paths[ $addon_name . str_repeat('*', $wildcards) ] = $dms_path; |
|
99 | + $dms_paths[$addon_name.str_repeat('*', $wildcards)] = $dms_path; |
|
100 | 100 | $wildcards++; |
101 | 101 | } |
102 | 102 | } |
@@ -114,6 +114,6 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public static function deregister(string $addon_name = '') |
116 | 116 | { |
117 | - unset(self::$_settings[ $addon_name ]); |
|
117 | + unset(self::$_settings[$addon_name]); |
|
118 | 118 | } |
119 | 119 | } |
@@ -14,105 +14,105 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_Register_Data_Migration_Scripts implements EEI_Plugin_API |
16 | 16 | { |
17 | - /** |
|
18 | - * Holds values for registered DMSs |
|
19 | - * |
|
20 | - * @var array[][] |
|
21 | - */ |
|
22 | - protected static $_settings = []; |
|
17 | + /** |
|
18 | + * Holds values for registered DMSs |
|
19 | + * |
|
20 | + * @var array[][] |
|
21 | + */ |
|
22 | + protected static $_settings = []; |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Method for registering new Data Migration Scripts |
|
27 | - * |
|
28 | - * @param string $addon_name EE_Addon class name that this set of data migration scripts belongs to |
|
29 | - * If EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name |
|
30 | - * @param array $setup_args { |
|
31 | - * @type string $dms_paths an array of full server paths to folders that contain data migration scripts |
|
32 | - * } |
|
33 | - * @return bool |
|
34 | - * @throws EE_Error |
|
35 | - * @since 4.3.0 |
|
36 | - * @since 4.3.0 |
|
37 | - */ |
|
38 | - public static function register(string $addon_name = '', array $setup_args = []): bool |
|
39 | - { |
|
40 | - // required fields MUST be present, so let's make sure they are. |
|
41 | - if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['dms_paths'])) { |
|
42 | - throw new EE_Error( |
|
43 | - esc_html__( |
|
44 | - 'In order to register Data Migration Scripts with EE_Register_Data_Migration_Scripts::register(), you must include the EE_Addon class name (used as a unique identifier for this set of data migration scripts), and an array containing the following keys: "dms_paths" (an array of full server paths to folders that contain data migration scripts)', |
|
45 | - 'event_espresso' |
|
46 | - ) |
|
47 | - ); |
|
48 | - } |
|
49 | - // make sure we don't register twice |
|
50 | - if (isset(self::$_settings[ $addon_name ])) { |
|
51 | - return true; |
|
52 | - } |
|
53 | - // make sure this was called in the right place! |
|
54 | - if ( |
|
55 | - ! did_action('AHEE__EE_System__load_espresso_addons') |
|
56 | - || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
57 | - ) { |
|
58 | - EE_Error::doing_it_wrong( |
|
59 | - __METHOD__, |
|
60 | - esc_html__( |
|
61 | - 'An attempt to register Data Migration Scripts has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register Data Migration Scripts.', |
|
62 | - 'event_espresso' |
|
63 | - ), |
|
64 | - '4.3.0' |
|
65 | - ); |
|
66 | - } |
|
67 | - // setup $_settings array from incoming values. |
|
68 | - self::$_settings[ $addon_name ] = ['dms_paths' => (array) $setup_args['dms_paths']]; |
|
69 | - // setup DMS |
|
70 | - $filters_set = has_filter( |
|
71 | - 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', |
|
72 | - ['EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'] |
|
73 | - ); |
|
74 | - if (! $filters_set) { |
|
75 | - add_filter( |
|
76 | - 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', |
|
77 | - ['EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'] |
|
78 | - ); |
|
79 | - } |
|
80 | - return true; |
|
81 | - } |
|
25 | + /** |
|
26 | + * Method for registering new Data Migration Scripts |
|
27 | + * |
|
28 | + * @param string $addon_name EE_Addon class name that this set of data migration scripts belongs to |
|
29 | + * If EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name |
|
30 | + * @param array $setup_args { |
|
31 | + * @type string $dms_paths an array of full server paths to folders that contain data migration scripts |
|
32 | + * } |
|
33 | + * @return bool |
|
34 | + * @throws EE_Error |
|
35 | + * @since 4.3.0 |
|
36 | + * @since 4.3.0 |
|
37 | + */ |
|
38 | + public static function register(string $addon_name = '', array $setup_args = []): bool |
|
39 | + { |
|
40 | + // required fields MUST be present, so let's make sure they are. |
|
41 | + if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['dms_paths'])) { |
|
42 | + throw new EE_Error( |
|
43 | + esc_html__( |
|
44 | + 'In order to register Data Migration Scripts with EE_Register_Data_Migration_Scripts::register(), you must include the EE_Addon class name (used as a unique identifier for this set of data migration scripts), and an array containing the following keys: "dms_paths" (an array of full server paths to folders that contain data migration scripts)', |
|
45 | + 'event_espresso' |
|
46 | + ) |
|
47 | + ); |
|
48 | + } |
|
49 | + // make sure we don't register twice |
|
50 | + if (isset(self::$_settings[ $addon_name ])) { |
|
51 | + return true; |
|
52 | + } |
|
53 | + // make sure this was called in the right place! |
|
54 | + if ( |
|
55 | + ! did_action('AHEE__EE_System__load_espresso_addons') |
|
56 | + || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
57 | + ) { |
|
58 | + EE_Error::doing_it_wrong( |
|
59 | + __METHOD__, |
|
60 | + esc_html__( |
|
61 | + 'An attempt to register Data Migration Scripts has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register Data Migration Scripts.', |
|
62 | + 'event_espresso' |
|
63 | + ), |
|
64 | + '4.3.0' |
|
65 | + ); |
|
66 | + } |
|
67 | + // setup $_settings array from incoming values. |
|
68 | + self::$_settings[ $addon_name ] = ['dms_paths' => (array) $setup_args['dms_paths']]; |
|
69 | + // setup DMS |
|
70 | + $filters_set = has_filter( |
|
71 | + 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', |
|
72 | + ['EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'] |
|
73 | + ); |
|
74 | + if (! $filters_set) { |
|
75 | + add_filter( |
|
76 | + 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', |
|
77 | + ['EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders'] |
|
78 | + ); |
|
79 | + } |
|
80 | + return true; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * @param array $dms_paths |
|
86 | - * @return array |
|
87 | - */ |
|
88 | - public static function add_data_migration_script_folders(array $dms_paths = []): array |
|
89 | - { |
|
90 | - foreach (self::$_settings as $addon_name => $settings) { |
|
91 | - $wildcards = 0; |
|
92 | - foreach ($settings['dms_paths'] as $dms_path) { |
|
93 | - // since we are using the addon name for the array key |
|
94 | - // we need to ensure that the key is unique, |
|
95 | - // so if for some reason an addon has multiple dms paths, |
|
96 | - // we append one or more * to the classname |
|
97 | - // which will get stripped out later on |
|
98 | - $dms_paths[ $addon_name . str_repeat('*', $wildcards) ] = $dms_path; |
|
99 | - $wildcards++; |
|
100 | - } |
|
101 | - } |
|
102 | - return $dms_paths; |
|
103 | - } |
|
84 | + /** |
|
85 | + * @param array $dms_paths |
|
86 | + * @return array |
|
87 | + */ |
|
88 | + public static function add_data_migration_script_folders(array $dms_paths = []): array |
|
89 | + { |
|
90 | + foreach (self::$_settings as $addon_name => $settings) { |
|
91 | + $wildcards = 0; |
|
92 | + foreach ($settings['dms_paths'] as $dms_path) { |
|
93 | + // since we are using the addon name for the array key |
|
94 | + // we need to ensure that the key is unique, |
|
95 | + // so if for some reason an addon has multiple dms paths, |
|
96 | + // we append one or more * to the classname |
|
97 | + // which will get stripped out later on |
|
98 | + $dms_paths[ $addon_name . str_repeat('*', $wildcards) ] = $dms_path; |
|
99 | + $wildcards++; |
|
100 | + } |
|
101 | + } |
|
102 | + return $dms_paths; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * This deregisters a set of Data Migration Scripts that were previously registered with a specific dms_id |
|
108 | - * |
|
109 | - * @param string $addon_name EE_Addon class name that this set of data migration scripts belongs to |
|
110 | - * @return void |
|
111 | - * @since 4.3.0 |
|
112 | - * @since 4.3.0 |
|
113 | - */ |
|
114 | - public static function deregister(string $addon_name = '') |
|
115 | - { |
|
116 | - unset(self::$_settings[ $addon_name ]); |
|
117 | - } |
|
106 | + /** |
|
107 | + * This deregisters a set of Data Migration Scripts that were previously registered with a specific dms_id |
|
108 | + * |
|
109 | + * @param string $addon_name EE_Addon class name that this set of data migration scripts belongs to |
|
110 | + * @return void |
|
111 | + * @since 4.3.0 |
|
112 | + * @since 4.3.0 |
|
113 | + */ |
|
114 | + public static function deregister(string $addon_name = '') |
|
115 | + { |
|
116 | + unset(self::$_settings[ $addon_name ]); |
|
117 | + } |
|
118 | 118 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public static function register(string $addon_name = '', array $setup_args = []): bool |
31 | 31 | { |
32 | - self::$privacy_policies[ $addon_name ] = $setup_args; |
|
32 | + self::$privacy_policies[$addon_name] = $setup_args; |
|
33 | 33 | // add to list of modules to be registered |
34 | 34 | add_filter( |
35 | 35 | 'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public static function deregister(string $addon_name = '') |
46 | 46 | { |
47 | - unset(self::$privacy_policies[ $addon_name ]); |
|
47 | + unset(self::$privacy_policies[$addon_name]); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 |
@@ -12,51 +12,51 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_Register_Privacy_Policy implements EEI_Plugin_API |
14 | 14 | { |
15 | - /** |
|
16 | - * FQCN for all privacy policy generators |
|
17 | - * |
|
18 | - * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
19 | - */ |
|
20 | - protected static $privacy_policies = []; |
|
15 | + /** |
|
16 | + * FQCN for all privacy policy generators |
|
17 | + * |
|
18 | + * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
19 | + */ |
|
20 | + protected static $privacy_policies = []; |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @param string $addon_name |
|
25 | - * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies, |
|
26 | - * OR fully qualified class names of privacy policies |
|
27 | - * @return bool |
|
28 | - */ |
|
29 | - public static function register(string $addon_name = '', array $setup_args = []): bool |
|
30 | - { |
|
31 | - self::$privacy_policies[ $addon_name ] = $setup_args; |
|
32 | - // add to list of modules to be registered |
|
33 | - add_filter( |
|
34 | - 'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
|
35 | - ['EE_Register_Privacy_Policy', 'addPrivacyPolicies'] |
|
36 | - ); |
|
37 | - return true; |
|
38 | - } |
|
23 | + /** |
|
24 | + * @param string $addon_name |
|
25 | + * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies, |
|
26 | + * OR fully qualified class names of privacy policies |
|
27 | + * @return bool |
|
28 | + */ |
|
29 | + public static function register(string $addon_name = '', array $setup_args = []): bool |
|
30 | + { |
|
31 | + self::$privacy_policies[ $addon_name ] = $setup_args; |
|
32 | + // add to list of modules to be registered |
|
33 | + add_filter( |
|
34 | + 'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
|
35 | + ['EE_Register_Privacy_Policy', 'addPrivacyPolicies'] |
|
36 | + ); |
|
37 | + return true; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * @param string $addon_name |
|
43 | - */ |
|
44 | - public static function deregister(string $addon_name = '') |
|
45 | - { |
|
46 | - unset(self::$privacy_policies[ $addon_name ]); |
|
47 | - } |
|
41 | + /** |
|
42 | + * @param string $addon_name |
|
43 | + */ |
|
44 | + public static function deregister(string $addon_name = '') |
|
45 | + { |
|
46 | + unset(self::$privacy_policies[ $addon_name ]); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * Adds our privacy policy generators registered by add-ons |
|
52 | - * |
|
53 | - * @param string[] $privacy_policies |
|
54 | - * @return string[] |
|
55 | - */ |
|
56 | - public static function addPrivacyPolicies(array $privacy_policies): array |
|
57 | - { |
|
58 | - return array_merge($privacy_policies, ...self::$privacy_policies); |
|
59 | - } |
|
50 | + /** |
|
51 | + * Adds our privacy policy generators registered by add-ons |
|
52 | + * |
|
53 | + * @param string[] $privacy_policies |
|
54 | + * @return string[] |
|
55 | + */ |
|
56 | + public static function addPrivacyPolicies(array $privacy_policies): array |
|
57 | + { |
|
58 | + return array_merge($privacy_policies, ...self::$privacy_policies); |
|
59 | + } |
|
60 | 60 | } |
61 | 61 | // End of file EE_Register_Privacy_Policy.lib.php |
62 | 62 | // Location: ${NAMESPACE}/EE_Register_Privacy_Policy.lib.php |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | ); |
60 | 60 | } |
61 | 61 | // make sure we don't register twice |
62 | - if (isset(self::$_settings[ $addon_name ])) { |
|
62 | + if (isset(self::$_settings[$addon_name])) { |
|
63 | 63 | return true; |
64 | 64 | } |
65 | 65 | // make sure this was called in the right place! |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | ); |
78 | 78 | } |
79 | 79 | // setup $_settings array from incoming values. |
80 | - self::$_settings[ $addon_name ] = [ |
|
80 | + self::$_settings[$addon_name] = [ |
|
81 | 81 | // array of full server paths to any EE_PMT_Base children used |
82 | 82 | 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
83 | 83 | ? (array) $setup_args['payment_method_paths'] |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | if (did_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods')) { |
94 | 94 | $payment_method_manager = LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
95 | 95 | // register payment methods directly |
96 | - foreach (self::$_settings[ $addon_name ]['payment_method_paths'] as $payment_method_path) { |
|
96 | + foreach (self::$_settings[$addon_name]['payment_method_paths'] as $payment_method_path) { |
|
97 | 97 | $payment_method_manager->register_payment_method($payment_method_path); |
98 | 98 | } |
99 | 99 | $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
100 | 100 | $capabilities->addCaps( |
101 | - self::getPaymentMethodCapabilities(self::$_settings[ $addon_name ]) |
|
101 | + self::getPaymentMethodCapabilities(self::$_settings[$addon_name]) |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | return true; |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public static function deregister(string $addon_name = '') |
137 | 137 | { |
138 | - if (isset(self::$_settings[ $addon_name ])) { |
|
138 | + if (isset(self::$_settings[$addon_name])) { |
|
139 | 139 | // set action for just this module id to delay deregistration until core is loaded and ready. |
140 | - $module_settings = self::$_settings[ $addon_name ]; |
|
141 | - unset(self::$_settings[ $addon_name ]); |
|
140 | + $module_settings = self::$_settings[$addon_name]; |
|
141 | + unset(self::$_settings[$addon_name]); |
|
142 | 142 | add_action( |
143 | 143 | 'AHEE__EE_System__core_loaded_and_ready', |
144 | - function () use ($module_settings) { |
|
144 | + function() use ($module_settings) { |
|
145 | 145 | $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
146 | 146 | $capabilities->removeCaps( |
147 | 147 | EE_Register_Payment_Method::getPaymentMethodCapabilities($module_settings) |
@@ -18,163 +18,163 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Register_Payment_Method implements EEI_Plugin_API |
20 | 20 | { |
21 | - /** |
|
22 | - * Holds values for registered payment methods |
|
23 | - * |
|
24 | - * @var array |
|
25 | - */ |
|
26 | - protected static $_settings = []; |
|
21 | + /** |
|
22 | + * Holds values for registered payment methods |
|
23 | + * |
|
24 | + * @var array |
|
25 | + */ |
|
26 | + protected static $_settings = []; |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * Method for registering new EE_PMT_Base children |
|
31 | - * |
|
32 | - * @param string $addon_name a unique identifier for this set of modules Required. |
|
33 | - * @param array $setup_args an array of arguments provided for registering modules Required.{ |
|
34 | - * @type string[] $payment_method_paths each element is the folder containing the EE_PMT_Base child class |
|
35 | - * (eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains |
|
36 | - * the files EE_PMT_Payomatic.pm.php) |
|
37 | - * } |
|
38 | - * @return bool |
|
39 | - * @throws EE_Error |
|
40 | - * @type array payment_method_paths an array of full server paths to folders containing any EE_PMT_Base |
|
41 | - * children, or to the EED_Module files themselves |
|
42 | - * @throws InvalidDataTypeException |
|
43 | - * @throws DomainException |
|
44 | - * @throws InvalidArgumentException |
|
45 | - * @throws InvalidInterfaceException |
|
46 | - * @throws InvalidDataTypeException |
|
47 | - * @since 4.5.0 |
|
48 | - */ |
|
49 | - public static function register(string $addon_name = '', array $setup_args = []): bool |
|
50 | - { |
|
51 | - // required fields MUST be present, so let's make sure they are. |
|
52 | - if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['payment_method_paths'])) { |
|
53 | - throw new EE_Error( |
|
54 | - esc_html__( |
|
55 | - 'In order to register Payment Methods with EE_Register_Payment_Method::register(), you must include a "payment_method_id" (a unique identifier for this set of modules), and an array containing the following keys: "payment_method_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)', |
|
56 | - 'event_espresso' |
|
57 | - ) |
|
58 | - ); |
|
59 | - } |
|
60 | - // make sure we don't register twice |
|
61 | - if (isset(self::$_settings[ $addon_name ])) { |
|
62 | - return true; |
|
63 | - } |
|
64 | - // make sure this was called in the right place! |
|
65 | - if ( |
|
66 | - ! did_action('AHEE__EE_System__load_espresso_addons') |
|
67 | - || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
68 | - ) { |
|
69 | - EE_Error::doing_it_wrong( |
|
70 | - __METHOD__, |
|
71 | - esc_html__( |
|
72 | - 'An attempt to register modules has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.', |
|
73 | - 'event_espresso' |
|
74 | - ), |
|
75 | - '4.3.0' |
|
76 | - ); |
|
77 | - } |
|
78 | - // setup $_settings array from incoming values. |
|
79 | - self::$_settings[ $addon_name ] = [ |
|
80 | - // array of full server paths to any EE_PMT_Base children used |
|
81 | - 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
82 | - ? (array) $setup_args['payment_method_paths'] |
|
83 | - : [], |
|
84 | - ]; |
|
85 | - // add to list of modules to be registered |
|
86 | - add_filter( |
|
87 | - 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
88 | - ['EE_Register_Payment_Method', 'add_payment_methods'] |
|
89 | - ); |
|
90 | - // If EE_Payment_Method_Manager::register_payment_methods has already been called, |
|
91 | - // then we need to add our caps for this payment method manually |
|
92 | - if (did_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods')) { |
|
93 | - $payment_method_manager = LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
94 | - // register payment methods directly |
|
95 | - foreach (self::$_settings[ $addon_name ]['payment_method_paths'] as $payment_method_path) { |
|
96 | - $payment_method_manager->register_payment_method($payment_method_path); |
|
97 | - } |
|
98 | - $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
99 | - $capabilities->addCaps( |
|
100 | - self::getPaymentMethodCapabilities(self::$_settings[ $addon_name ]) |
|
101 | - ); |
|
102 | - } |
|
103 | - return true; |
|
104 | - } |
|
29 | + /** |
|
30 | + * Method for registering new EE_PMT_Base children |
|
31 | + * |
|
32 | + * @param string $addon_name a unique identifier for this set of modules Required. |
|
33 | + * @param array $setup_args an array of arguments provided for registering modules Required.{ |
|
34 | + * @type string[] $payment_method_paths each element is the folder containing the EE_PMT_Base child class |
|
35 | + * (eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains |
|
36 | + * the files EE_PMT_Payomatic.pm.php) |
|
37 | + * } |
|
38 | + * @return bool |
|
39 | + * @throws EE_Error |
|
40 | + * @type array payment_method_paths an array of full server paths to folders containing any EE_PMT_Base |
|
41 | + * children, or to the EED_Module files themselves |
|
42 | + * @throws InvalidDataTypeException |
|
43 | + * @throws DomainException |
|
44 | + * @throws InvalidArgumentException |
|
45 | + * @throws InvalidInterfaceException |
|
46 | + * @throws InvalidDataTypeException |
|
47 | + * @since 4.5.0 |
|
48 | + */ |
|
49 | + public static function register(string $addon_name = '', array $setup_args = []): bool |
|
50 | + { |
|
51 | + // required fields MUST be present, so let's make sure they are. |
|
52 | + if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['payment_method_paths'])) { |
|
53 | + throw new EE_Error( |
|
54 | + esc_html__( |
|
55 | + 'In order to register Payment Methods with EE_Register_Payment_Method::register(), you must include a "payment_method_id" (a unique identifier for this set of modules), and an array containing the following keys: "payment_method_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)', |
|
56 | + 'event_espresso' |
|
57 | + ) |
|
58 | + ); |
|
59 | + } |
|
60 | + // make sure we don't register twice |
|
61 | + if (isset(self::$_settings[ $addon_name ])) { |
|
62 | + return true; |
|
63 | + } |
|
64 | + // make sure this was called in the right place! |
|
65 | + if ( |
|
66 | + ! did_action('AHEE__EE_System__load_espresso_addons') |
|
67 | + || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
68 | + ) { |
|
69 | + EE_Error::doing_it_wrong( |
|
70 | + __METHOD__, |
|
71 | + esc_html__( |
|
72 | + 'An attempt to register modules has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.', |
|
73 | + 'event_espresso' |
|
74 | + ), |
|
75 | + '4.3.0' |
|
76 | + ); |
|
77 | + } |
|
78 | + // setup $_settings array from incoming values. |
|
79 | + self::$_settings[ $addon_name ] = [ |
|
80 | + // array of full server paths to any EE_PMT_Base children used |
|
81 | + 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
82 | + ? (array) $setup_args['payment_method_paths'] |
|
83 | + : [], |
|
84 | + ]; |
|
85 | + // add to list of modules to be registered |
|
86 | + add_filter( |
|
87 | + 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
88 | + ['EE_Register_Payment_Method', 'add_payment_methods'] |
|
89 | + ); |
|
90 | + // If EE_Payment_Method_Manager::register_payment_methods has already been called, |
|
91 | + // then we need to add our caps for this payment method manually |
|
92 | + if (did_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods')) { |
|
93 | + $payment_method_manager = LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
94 | + // register payment methods directly |
|
95 | + foreach (self::$_settings[ $addon_name ]['payment_method_paths'] as $payment_method_path) { |
|
96 | + $payment_method_manager->register_payment_method($payment_method_path); |
|
97 | + } |
|
98 | + $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
99 | + $capabilities->addCaps( |
|
100 | + self::getPaymentMethodCapabilities(self::$_settings[ $addon_name ]) |
|
101 | + ); |
|
102 | + } |
|
103 | + return true; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | - /** |
|
108 | - * Filters the list of payment methods to add ours. |
|
109 | - * and they're just full filepaths to FOLDERS containing a payment method class file. Eg. |
|
110 | - * |
|
111 | - * @param array $payment_method_folders array of paths to all payment methods that require registering |
|
112 | - * @return array |
|
113 | - */ |
|
114 | - public static function add_payment_methods(array $payment_method_folders): array |
|
115 | - { |
|
116 | - $payment_method_paths = []; |
|
117 | - foreach (self::$_settings as $settings) { |
|
118 | - $payment_method_paths[] = $settings['payment_method_paths']; |
|
119 | - } |
|
120 | - return array_merge($payment_method_folders, ...$payment_method_paths); |
|
121 | - } |
|
107 | + /** |
|
108 | + * Filters the list of payment methods to add ours. |
|
109 | + * and they're just full filepaths to FOLDERS containing a payment method class file. Eg. |
|
110 | + * |
|
111 | + * @param array $payment_method_folders array of paths to all payment methods that require registering |
|
112 | + * @return array |
|
113 | + */ |
|
114 | + public static function add_payment_methods(array $payment_method_folders): array |
|
115 | + { |
|
116 | + $payment_method_paths = []; |
|
117 | + foreach (self::$_settings as $settings) { |
|
118 | + $payment_method_paths[] = $settings['payment_method_paths']; |
|
119 | + } |
|
120 | + return array_merge($payment_method_folders, ...$payment_method_paths); |
|
121 | + } |
|
122 | 122 | |
123 | 123 | |
124 | - /** |
|
125 | - * This deregisters a module that was previously registered with a specific $addon_name. |
|
126 | - * |
|
127 | - * @param string $addon_name the name for the module that was previously registered |
|
128 | - * @return void |
|
129 | - * @throws DomainException |
|
130 | - * @throws InvalidArgumentException |
|
131 | - * @throws InvalidInterfaceException |
|
132 | - * @throws InvalidDataTypeException |
|
133 | - * @since 4.3.0 |
|
134 | - */ |
|
135 | - public static function deregister(string $addon_name = '') |
|
136 | - { |
|
137 | - if (isset(self::$_settings[ $addon_name ])) { |
|
138 | - // set action for just this module id to delay deregistration until core is loaded and ready. |
|
139 | - $module_settings = self::$_settings[ $addon_name ]; |
|
140 | - unset(self::$_settings[ $addon_name ]); |
|
141 | - add_action( |
|
142 | - 'AHEE__EE_System__core_loaded_and_ready', |
|
143 | - function () use ($module_settings) { |
|
144 | - $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
145 | - $capabilities->removeCaps( |
|
146 | - EE_Register_Payment_Method::getPaymentMethodCapabilities($module_settings) |
|
147 | - ); |
|
148 | - } |
|
149 | - ); |
|
150 | - } |
|
151 | - } |
|
124 | + /** |
|
125 | + * This deregisters a module that was previously registered with a specific $addon_name. |
|
126 | + * |
|
127 | + * @param string $addon_name the name for the module that was previously registered |
|
128 | + * @return void |
|
129 | + * @throws DomainException |
|
130 | + * @throws InvalidArgumentException |
|
131 | + * @throws InvalidInterfaceException |
|
132 | + * @throws InvalidDataTypeException |
|
133 | + * @since 4.3.0 |
|
134 | + */ |
|
135 | + public static function deregister(string $addon_name = '') |
|
136 | + { |
|
137 | + if (isset(self::$_settings[ $addon_name ])) { |
|
138 | + // set action for just this module id to delay deregistration until core is loaded and ready. |
|
139 | + $module_settings = self::$_settings[ $addon_name ]; |
|
140 | + unset(self::$_settings[ $addon_name ]); |
|
141 | + add_action( |
|
142 | + 'AHEE__EE_System__core_loaded_and_ready', |
|
143 | + function () use ($module_settings) { |
|
144 | + $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
145 | + $capabilities->removeCaps( |
|
146 | + EE_Register_Payment_Method::getPaymentMethodCapabilities($module_settings) |
|
147 | + ); |
|
148 | + } |
|
149 | + ); |
|
150 | + } |
|
151 | + } |
|
152 | 152 | |
153 | 153 | |
154 | - /** |
|
155 | - * returns an array of the caps that get added when a Payment Method is registered |
|
156 | - * |
|
157 | - * @param array $settings |
|
158 | - * @return array |
|
159 | - * @throws DomainException |
|
160 | - * @throws InvalidArgumentException |
|
161 | - * @throws InvalidInterfaceException |
|
162 | - * @throws InvalidDataTypeException |
|
163 | - * @access private Developers do NOT use this method. It's only public for PHP5.3 closure support (see deregister) |
|
164 | - * When we drop support for PHP5.3 this will be made private again. You have been warned. |
|
165 | - */ |
|
166 | - public static function getPaymentMethodCapabilities(array $settings): array |
|
167 | - { |
|
168 | - $payment_method_manager = LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
169 | - $payment_method_caps = ['administrator' => []]; |
|
170 | - if (isset($settings['payment_method_paths'])) { |
|
171 | - foreach ($settings['payment_method_paths'] as $payment_method_path) { |
|
172 | - $payment_method_caps = $payment_method_manager->addPaymentMethodCap( |
|
173 | - strtolower(basename($payment_method_path)), |
|
174 | - $payment_method_caps |
|
175 | - ); |
|
176 | - } |
|
177 | - } |
|
178 | - return $payment_method_caps; |
|
179 | - } |
|
154 | + /** |
|
155 | + * returns an array of the caps that get added when a Payment Method is registered |
|
156 | + * |
|
157 | + * @param array $settings |
|
158 | + * @return array |
|
159 | + * @throws DomainException |
|
160 | + * @throws InvalidArgumentException |
|
161 | + * @throws InvalidInterfaceException |
|
162 | + * @throws InvalidDataTypeException |
|
163 | + * @access private Developers do NOT use this method. It's only public for PHP5.3 closure support (see deregister) |
|
164 | + * When we drop support for PHP5.3 this will be made private again. You have been warned. |
|
165 | + */ |
|
166 | + public static function getPaymentMethodCapabilities(array $settings): array |
|
167 | + { |
|
168 | + $payment_method_manager = LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
169 | + $payment_method_caps = ['administrator' => []]; |
|
170 | + if (isset($settings['payment_method_paths'])) { |
|
171 | + foreach ($settings['payment_method_paths'] as $payment_method_path) { |
|
172 | + $payment_method_caps = $payment_method_manager->addPaymentMethodCap( |
|
173 | + strtolower(basename($payment_method_path)), |
|
174 | + $payment_method_caps |
|
175 | + ); |
|
176 | + } |
|
177 | + } |
|
178 | + return $payment_method_caps; |
|
179 | + } |
|
180 | 180 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | // make sure we don't register twice |
63 | - if (isset(self::$_settings[ $addon_name ])) { |
|
63 | + if (isset(self::$_settings[$addon_name])) { |
|
64 | 64 | return true; |
65 | 65 | } |
66 | 66 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | ); |
80 | 80 | } |
81 | 81 | // setup $_settings array from incoming values. |
82 | - self::$_settings[ $addon_name ] = [ |
|
82 | + self::$_settings[$addon_name] = [ |
|
83 | 83 | // array of full server paths to any EES_Shortcodes used by the shortcode |
84 | 84 | 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
85 | 85 | ? (array) $setup_args['shortcode_paths'] |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | CollectionInterface $shortcodes_collection |
137 | 137 | ): CollectionInterface { |
138 | 138 | foreach (self::$_settings as $settings) { |
139 | - if (! empty($settings['shortcode_fqcns'])) { |
|
139 | + if ( ! empty($settings['shortcode_fqcns'])) { |
|
140 | 140 | foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) { |
141 | - if (! class_exists($shortcode_fqcn)) { |
|
141 | + if ( ! class_exists($shortcode_fqcn)) { |
|
142 | 142 | throw new InvalidClassException( |
143 | 143 | sprintf( |
144 | 144 | esc_html__( |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | ) |
150 | 150 | ); |
151 | 151 | } |
152 | - if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) { |
|
152 | + if ( ! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) { |
|
153 | 153 | // register dependencies |
154 | 154 | EE_Dependency_Map::register_dependencies( |
155 | 155 | $shortcode_fqcn, |
@@ -175,6 +175,6 @@ discard block |
||
175 | 175 | */ |
176 | 176 | public static function deregister(string $addon_name = '') |
177 | 177 | { |
178 | - unset(self::$_settings[ $addon_name ]); |
|
178 | + unset(self::$_settings[$addon_name]); |
|
179 | 179 | } |
180 | 180 | } |
@@ -19,163 +19,163 @@ |
||
19 | 19 | */ |
20 | 20 | class EE_Register_Shortcode implements EEI_Plugin_API |
21 | 21 | { |
22 | - /** |
|
23 | - * Holds values for registered shortcodes |
|
24 | - * |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - protected static $_settings = []; |
|
22 | + /** |
|
23 | + * Holds values for registered shortcodes |
|
24 | + * |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + protected static $_settings = []; |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * Method for registering new EE_Shortcodes |
|
32 | - * |
|
33 | - * @param string $addon_name a unique identifier for this set of modules Required. |
|
34 | - * @param array $setup_args an array of arguments provided for registering shortcodes Required. |
|
35 | - * @type array shortcode_paths an array of full server paths to folders containing any EES_Shortcodes |
|
36 | - * @type array shortcode_fqcns an array of fully qualified class names for any new shortcode classes to register. |
|
37 | - * Shortcode classes should extend EspressoShortcode |
|
38 | - * and be properly namespaced so they are autoloaded. |
|
39 | - * @return bool |
|
40 | - * @throws EE_Error |
|
41 | - * @since 4.3.0 |
|
42 | - * @since 4.9.46.rc.025 for the new `shortcode_fqcns` array argument. |
|
43 | - */ |
|
44 | - public static function register(string $addon_name = '', array $setup_args = []): bool |
|
45 | - { |
|
46 | - // required fields MUST be present, so let's make sure they are. |
|
47 | - if ( |
|
48 | - empty($addon_name) |
|
49 | - || ! is_array($setup_args) |
|
50 | - || ( |
|
51 | - empty($setup_args['shortcode_paths']) |
|
52 | - ) |
|
53 | - && empty($setup_args['shortcode_fqcns']) |
|
54 | - ) { |
|
55 | - throw new EE_Error( |
|
56 | - esc_html__( |
|
57 | - 'In order to register Modules with EE_Register_Shortcode::register(), you must include a "shortcode_id" (a unique identifier for this set of shortcodes), and an array containing the following keys: "shortcode_paths" (an array of full server paths to folders that contain shortcodes, or to the shortcode files themselves)', |
|
58 | - 'event_espresso' |
|
59 | - ) |
|
60 | - ); |
|
61 | - } |
|
30 | + /** |
|
31 | + * Method for registering new EE_Shortcodes |
|
32 | + * |
|
33 | + * @param string $addon_name a unique identifier for this set of modules Required. |
|
34 | + * @param array $setup_args an array of arguments provided for registering shortcodes Required. |
|
35 | + * @type array shortcode_paths an array of full server paths to folders containing any EES_Shortcodes |
|
36 | + * @type array shortcode_fqcns an array of fully qualified class names for any new shortcode classes to register. |
|
37 | + * Shortcode classes should extend EspressoShortcode |
|
38 | + * and be properly namespaced so they are autoloaded. |
|
39 | + * @return bool |
|
40 | + * @throws EE_Error |
|
41 | + * @since 4.3.0 |
|
42 | + * @since 4.9.46.rc.025 for the new `shortcode_fqcns` array argument. |
|
43 | + */ |
|
44 | + public static function register(string $addon_name = '', array $setup_args = []): bool |
|
45 | + { |
|
46 | + // required fields MUST be present, so let's make sure they are. |
|
47 | + if ( |
|
48 | + empty($addon_name) |
|
49 | + || ! is_array($setup_args) |
|
50 | + || ( |
|
51 | + empty($setup_args['shortcode_paths']) |
|
52 | + ) |
|
53 | + && empty($setup_args['shortcode_fqcns']) |
|
54 | + ) { |
|
55 | + throw new EE_Error( |
|
56 | + esc_html__( |
|
57 | + 'In order to register Modules with EE_Register_Shortcode::register(), you must include a "shortcode_id" (a unique identifier for this set of shortcodes), and an array containing the following keys: "shortcode_paths" (an array of full server paths to folders that contain shortcodes, or to the shortcode files themselves)', |
|
58 | + 'event_espresso' |
|
59 | + ) |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | |
63 | - // make sure we don't register twice |
|
64 | - if (isset(self::$_settings[ $addon_name ])) { |
|
65 | - return true; |
|
66 | - } |
|
63 | + // make sure we don't register twice |
|
64 | + if (isset(self::$_settings[ $addon_name ])) { |
|
65 | + return true; |
|
66 | + } |
|
67 | 67 | |
68 | - // make sure this was called in the right place! |
|
69 | - if ( |
|
70 | - ! did_action('AHEE__EE_System__load_espresso_addons') |
|
71 | - || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
72 | - ) { |
|
73 | - EE_Error::doing_it_wrong( |
|
74 | - __METHOD__, |
|
75 | - esc_html__( |
|
76 | - 'An attempt to register shortcodes has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register shortcodes.', |
|
77 | - 'event_espresso' |
|
78 | - ), |
|
79 | - '4.3.0' |
|
80 | - ); |
|
81 | - } |
|
82 | - // setup $_settings array from incoming values. |
|
83 | - self::$_settings[ $addon_name ] = [ |
|
84 | - // array of full server paths to any EES_Shortcodes used by the shortcode |
|
85 | - 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
86 | - ? (array) $setup_args['shortcode_paths'] |
|
87 | - : [], |
|
88 | - 'shortcode_fqcns' => isset($setup_args['shortcode_fqcns']) |
|
89 | - ? (array) $setup_args['shortcode_fqcns'] |
|
90 | - : [], |
|
91 | - ]; |
|
92 | - // add to list of shortcodes to be registered |
|
93 | - add_filter( |
|
94 | - 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
|
95 | - ['EE_Register_Shortcode', 'add_shortcodes'] |
|
96 | - ); |
|
68 | + // make sure this was called in the right place! |
|
69 | + if ( |
|
70 | + ! did_action('AHEE__EE_System__load_espresso_addons') |
|
71 | + || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
72 | + ) { |
|
73 | + EE_Error::doing_it_wrong( |
|
74 | + __METHOD__, |
|
75 | + esc_html__( |
|
76 | + 'An attempt to register shortcodes has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register shortcodes.', |
|
77 | + 'event_espresso' |
|
78 | + ), |
|
79 | + '4.3.0' |
|
80 | + ); |
|
81 | + } |
|
82 | + // setup $_settings array from incoming values. |
|
83 | + self::$_settings[ $addon_name ] = [ |
|
84 | + // array of full server paths to any EES_Shortcodes used by the shortcode |
|
85 | + 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
86 | + ? (array) $setup_args['shortcode_paths'] |
|
87 | + : [], |
|
88 | + 'shortcode_fqcns' => isset($setup_args['shortcode_fqcns']) |
|
89 | + ? (array) $setup_args['shortcode_fqcns'] |
|
90 | + : [], |
|
91 | + ]; |
|
92 | + // add to list of shortcodes to be registered |
|
93 | + add_filter( |
|
94 | + 'FHEE__EE_Config__register_shortcodes__shortcodes_to_register', |
|
95 | + ['EE_Register_Shortcode', 'add_shortcodes'] |
|
96 | + ); |
|
97 | 97 | |
98 | - add_filter( |
|
99 | - 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
100 | - ['EE_Register_Shortcode', 'instantiateAndAddToShortcodeCollection'] |
|
101 | - ); |
|
102 | - return true; |
|
103 | - } |
|
98 | + add_filter( |
|
99 | + 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
100 | + ['EE_Register_Shortcode', 'instantiateAndAddToShortcodeCollection'] |
|
101 | + ); |
|
102 | + return true; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * Filters the list of shortcodes to add ours. |
|
108 | - * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg. |
|
109 | - * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey'...) |
|
110 | - * |
|
111 | - * @param array $shortcodes_to_register array of paths to all shortcodes that require registering |
|
112 | - * @return array |
|
113 | - */ |
|
114 | - public static function add_shortcodes(array $shortcodes_to_register): array |
|
115 | - { |
|
116 | - $shortcode_paths = []; |
|
117 | - foreach (self::$_settings as $settings) { |
|
118 | - $shortcode_paths[] = $settings['shortcode_paths']; |
|
119 | - } |
|
120 | - return array_merge($shortcodes_to_register, ...$shortcode_paths); |
|
121 | - } |
|
106 | + /** |
|
107 | + * Filters the list of shortcodes to add ours. |
|
108 | + * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg. |
|
109 | + * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey'...) |
|
110 | + * |
|
111 | + * @param array $shortcodes_to_register array of paths to all shortcodes that require registering |
|
112 | + * @return array |
|
113 | + */ |
|
114 | + public static function add_shortcodes(array $shortcodes_to_register): array |
|
115 | + { |
|
116 | + $shortcode_paths = []; |
|
117 | + foreach (self::$_settings as $settings) { |
|
118 | + $shortcode_paths[] = $settings['shortcode_paths']; |
|
119 | + } |
|
120 | + return array_merge($shortcodes_to_register, ...$shortcode_paths); |
|
121 | + } |
|
122 | 122 | |
123 | 123 | |
124 | - /** |
|
125 | - * Hooks into |
|
126 | - * FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection and |
|
127 | - * registers any provided shortcode fully qualified class names. |
|
128 | - * |
|
129 | - * @param CollectionInterface $shortcodes_collection |
|
130 | - * @return CollectionInterface |
|
131 | - * @throws InvalidArgumentException |
|
132 | - * @throws InvalidClassException |
|
133 | - * @throws InvalidDataTypeException |
|
134 | - * @throws InvalidInterfaceException |
|
135 | - */ |
|
136 | - public static function instantiateAndAddToShortcodeCollection( |
|
137 | - CollectionInterface $shortcodes_collection |
|
138 | - ): CollectionInterface { |
|
139 | - foreach (self::$_settings as $settings) { |
|
140 | - if (! empty($settings['shortcode_fqcns'])) { |
|
141 | - foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) { |
|
142 | - if (! class_exists($shortcode_fqcn)) { |
|
143 | - throw new InvalidClassException( |
|
144 | - sprintf( |
|
145 | - esc_html__( |
|
146 | - 'Are you sure %s is the right fully qualified class name for the shortcode class?', |
|
147 | - 'event_espresso' |
|
148 | - ), |
|
149 | - $shortcode_fqcn |
|
150 | - ) |
|
151 | - ); |
|
152 | - } |
|
153 | - if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) { |
|
154 | - // register dependencies |
|
155 | - EE_Dependency_Map::register_dependencies( |
|
156 | - $shortcode_fqcn, |
|
157 | - [ |
|
158 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
159 | - ] |
|
160 | - ); |
|
161 | - } |
|
162 | - $shortcodes_collection->add(LoaderFactory::getLoader()->getShared($shortcode_fqcn)); |
|
163 | - } |
|
164 | - } |
|
165 | - } |
|
166 | - return $shortcodes_collection; |
|
167 | - } |
|
124 | + /** |
|
125 | + * Hooks into |
|
126 | + * FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection and |
|
127 | + * registers any provided shortcode fully qualified class names. |
|
128 | + * |
|
129 | + * @param CollectionInterface $shortcodes_collection |
|
130 | + * @return CollectionInterface |
|
131 | + * @throws InvalidArgumentException |
|
132 | + * @throws InvalidClassException |
|
133 | + * @throws InvalidDataTypeException |
|
134 | + * @throws InvalidInterfaceException |
|
135 | + */ |
|
136 | + public static function instantiateAndAddToShortcodeCollection( |
|
137 | + CollectionInterface $shortcodes_collection |
|
138 | + ): CollectionInterface { |
|
139 | + foreach (self::$_settings as $settings) { |
|
140 | + if (! empty($settings['shortcode_fqcns'])) { |
|
141 | + foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) { |
|
142 | + if (! class_exists($shortcode_fqcn)) { |
|
143 | + throw new InvalidClassException( |
|
144 | + sprintf( |
|
145 | + esc_html__( |
|
146 | + 'Are you sure %s is the right fully qualified class name for the shortcode class?', |
|
147 | + 'event_espresso' |
|
148 | + ), |
|
149 | + $shortcode_fqcn |
|
150 | + ) |
|
151 | + ); |
|
152 | + } |
|
153 | + if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) { |
|
154 | + // register dependencies |
|
155 | + EE_Dependency_Map::register_dependencies( |
|
156 | + $shortcode_fqcn, |
|
157 | + [ |
|
158 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
159 | + ] |
|
160 | + ); |
|
161 | + } |
|
162 | + $shortcodes_collection->add(LoaderFactory::getLoader()->getShared($shortcode_fqcn)); |
|
163 | + } |
|
164 | + } |
|
165 | + } |
|
166 | + return $shortcodes_collection; |
|
167 | + } |
|
168 | 168 | |
169 | 169 | |
170 | - /** |
|
171 | - * This deregisters a shortcode that was previously registered with a specific $addon_name. |
|
172 | - * |
|
173 | - * @param string $addon_name the name for the shortcode that was previously registered |
|
174 | - * @return void |
|
175 | - * @since 4.3.0 |
|
176 | - */ |
|
177 | - public static function deregister(string $addon_name = '') |
|
178 | - { |
|
179 | - unset(self::$_settings[ $addon_name ]); |
|
180 | - } |
|
170 | + /** |
|
171 | + * This deregisters a shortcode that was previously registered with a specific $addon_name. |
|
172 | + * |
|
173 | + * @param string $addon_name the name for the shortcode that was previously registered |
|
174 | + * @return void |
|
175 | + * @since 4.3.0 |
|
176 | + */ |
|
177 | + public static function deregister(string $addon_name = '') |
|
178 | + { |
|
179 | + unset(self::$_settings[ $addon_name ]); |
|
180 | + } |
|
181 | 181 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | // make sure we don't register twice |
51 | - if (isset(self::$_settings[ $addon_name ])) { |
|
51 | + if (isset(self::$_settings[$addon_name])) { |
|
52 | 52 | return true; |
53 | 53 | } |
54 | 54 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | ); |
68 | 68 | } |
69 | 69 | // setup $_settings array from incoming values. |
70 | - self::$_settings[ $addon_name ] = [ |
|
70 | + self::$_settings[$addon_name] = [ |
|
71 | 71 | // array of full server paths to any EED_Modules used by the module |
72 | 72 | 'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : [], |
73 | 73 | ]; |
@@ -107,6 +107,6 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public static function deregister(string $addon_name = '') |
109 | 109 | { |
110 | - unset(self::$_settings[ $addon_name ]); |
|
110 | + unset(self::$_settings[$addon_name]); |
|
111 | 111 | } |
112 | 112 | } |
@@ -14,98 +14,98 @@ |
||
14 | 14 | */ |
15 | 15 | class EE_Register_Module implements EEI_Plugin_API |
16 | 16 | { |
17 | - /** |
|
18 | - * Holds values for registered modules |
|
19 | - * |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - protected static $_settings = []; |
|
17 | + /** |
|
18 | + * Holds values for registered modules |
|
19 | + * |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + protected static $_settings = []; |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Method for registering new EED_Modules |
|
27 | - * |
|
28 | - * @param string $addon_name a unique identifier for this set of modules Required. |
|
29 | - * @param array $setup_args an array of full server paths to folders containing any EED_Modules, or to the |
|
30 | - * EED_Module files themselves Required. |
|
31 | - * @type array module_paths an array of full server paths to folders containing any EED_Modules, or to the |
|
32 | - * EED_Module files themselves |
|
33 | - * @return bool |
|
34 | - * @throws EE_Error |
|
35 | - * @since 4.3.0 |
|
36 | - */ |
|
37 | - public static function register(string $addon_name = '', array $setup_args = []): bool |
|
38 | - { |
|
39 | - // required fields MUST be present, so let's make sure they are. |
|
40 | - if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['module_paths'])) { |
|
41 | - throw new EE_Error( |
|
42 | - esc_html__( |
|
43 | - 'In order to register Modules with EE_Register_Module::register(), you must include a "module_id" (a unique identifier for this set of modules), and an array containing the following keys: "module_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)', |
|
44 | - 'event_espresso' |
|
45 | - ) |
|
46 | - ); |
|
47 | - } |
|
25 | + /** |
|
26 | + * Method for registering new EED_Modules |
|
27 | + * |
|
28 | + * @param string $addon_name a unique identifier for this set of modules Required. |
|
29 | + * @param array $setup_args an array of full server paths to folders containing any EED_Modules, or to the |
|
30 | + * EED_Module files themselves Required. |
|
31 | + * @type array module_paths an array of full server paths to folders containing any EED_Modules, or to the |
|
32 | + * EED_Module files themselves |
|
33 | + * @return bool |
|
34 | + * @throws EE_Error |
|
35 | + * @since 4.3.0 |
|
36 | + */ |
|
37 | + public static function register(string $addon_name = '', array $setup_args = []): bool |
|
38 | + { |
|
39 | + // required fields MUST be present, so let's make sure they are. |
|
40 | + if (empty($addon_name) || ! is_array($setup_args) || empty($setup_args['module_paths'])) { |
|
41 | + throw new EE_Error( |
|
42 | + esc_html__( |
|
43 | + 'In order to register Modules with EE_Register_Module::register(), you must include a "module_id" (a unique identifier for this set of modules), and an array containing the following keys: "module_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)', |
|
44 | + 'event_espresso' |
|
45 | + ) |
|
46 | + ); |
|
47 | + } |
|
48 | 48 | |
49 | - // make sure we don't register twice |
|
50 | - if (isset(self::$_settings[ $addon_name ])) { |
|
51 | - return true; |
|
52 | - } |
|
49 | + // make sure we don't register twice |
|
50 | + if (isset(self::$_settings[ $addon_name ])) { |
|
51 | + return true; |
|
52 | + } |
|
53 | 53 | |
54 | - // make sure this was called in the right place! |
|
55 | - if ( |
|
56 | - ! did_action('AHEE__EE_System__load_espresso_addons') |
|
57 | - || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
58 | - ) { |
|
59 | - EE_Error::doing_it_wrong( |
|
60 | - __METHOD__, |
|
61 | - esc_html__( |
|
62 | - 'An attempt to register modules has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.', |
|
63 | - 'event_espresso' |
|
64 | - ), |
|
65 | - '4.3.0' |
|
66 | - ); |
|
67 | - } |
|
68 | - // setup $_settings array from incoming values. |
|
69 | - self::$_settings[ $addon_name ] = [ |
|
70 | - // array of full server paths to any EED_Modules used by the module |
|
71 | - 'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : [], |
|
72 | - ]; |
|
73 | - // add to list of modules to be registered |
|
74 | - add_filter( |
|
75 | - 'FHEE__EE_Config__register_modules__modules_to_register', |
|
76 | - ['EE_Register_Module', 'add_modules'] |
|
77 | - ); |
|
78 | - return true; |
|
79 | - } |
|
54 | + // make sure this was called in the right place! |
|
55 | + if ( |
|
56 | + ! did_action('AHEE__EE_System__load_espresso_addons') |
|
57 | + || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
58 | + ) { |
|
59 | + EE_Error::doing_it_wrong( |
|
60 | + __METHOD__, |
|
61 | + esc_html__( |
|
62 | + 'An attempt to register modules has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.', |
|
63 | + 'event_espresso' |
|
64 | + ), |
|
65 | + '4.3.0' |
|
66 | + ); |
|
67 | + } |
|
68 | + // setup $_settings array from incoming values. |
|
69 | + self::$_settings[ $addon_name ] = [ |
|
70 | + // array of full server paths to any EED_Modules used by the module |
|
71 | + 'module_paths' => isset($setup_args['module_paths']) ? (array) $setup_args['module_paths'] : [], |
|
72 | + ]; |
|
73 | + // add to list of modules to be registered |
|
74 | + add_filter( |
|
75 | + 'FHEE__EE_Config__register_modules__modules_to_register', |
|
76 | + ['EE_Register_Module', 'add_modules'] |
|
77 | + ); |
|
78 | + return true; |
|
79 | + } |
|
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * Filters the list of modules to add ours. |
|
84 | - * and they're just full filepaths to FOLDERS containing a module class file. Eg. |
|
85 | - * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey'...) |
|
86 | - * |
|
87 | - * @param array $modules_to_register array of paths to all modules that require registering |
|
88 | - * @return array |
|
89 | - */ |
|
90 | - public static function add_modules(array $modules_to_register): array |
|
91 | - { |
|
92 | - $module_paths = []; |
|
93 | - foreach (self::$_settings as $settings) { |
|
94 | - $module_paths[] = $settings['module_paths']; |
|
95 | - } |
|
96 | - return array_merge($modules_to_register, ...$module_paths); |
|
97 | - } |
|
82 | + /** |
|
83 | + * Filters the list of modules to add ours. |
|
84 | + * and they're just full filepaths to FOLDERS containing a module class file. Eg. |
|
85 | + * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey'...) |
|
86 | + * |
|
87 | + * @param array $modules_to_register array of paths to all modules that require registering |
|
88 | + * @return array |
|
89 | + */ |
|
90 | + public static function add_modules(array $modules_to_register): array |
|
91 | + { |
|
92 | + $module_paths = []; |
|
93 | + foreach (self::$_settings as $settings) { |
|
94 | + $module_paths[] = $settings['module_paths']; |
|
95 | + } |
|
96 | + return array_merge($modules_to_register, ...$module_paths); |
|
97 | + } |
|
98 | 98 | |
99 | 99 | |
100 | - /** |
|
101 | - * This deregisters a module that was previously registered with a specific $addon_name. |
|
102 | - * |
|
103 | - * @param string $addon_name the name for the module that was previously registered |
|
104 | - * @return void |
|
105 | - * @since 4.3.0 |
|
106 | - */ |
|
107 | - public static function deregister(string $addon_name = '') |
|
108 | - { |
|
109 | - unset(self::$_settings[ $addon_name ]); |
|
110 | - } |
|
100 | + /** |
|
101 | + * This deregisters a module that was previously registered with a specific $addon_name. |
|
102 | + * |
|
103 | + * @param string $addon_name the name for the module that was previously registered |
|
104 | + * @return void |
|
105 | + * @since 4.3.0 |
|
106 | + */ |
|
107 | + public static function deregister(string $addon_name = '') |
|
108 | + { |
|
109 | + unset(self::$_settings[ $addon_name ]); |
|
110 | + } |
|
111 | 111 | } |