@@ -15,97 +15,97 @@ |
||
| 15 | 15 | class EE_Register_Widget implements EEI_Plugin_API |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Holds values for registered widgets |
|
| 20 | - * |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - protected static $_settings = []; |
|
| 18 | + /** |
|
| 19 | + * Holds values for registered widgets |
|
| 20 | + * |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + protected static $_settings = []; |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Method for registering new EED_Widgets |
|
| 28 | - * |
|
| 29 | - * @param string $identifier a unique identifier for this set of widgets |
|
| 30 | - * @param array $setup_args an array of arguments provided for registering widgets |
|
| 31 | - * @type array widget_paths an array of full server paths to folders containing any EED_Widgets, or to the |
|
| 32 | - * EED_Widget files themselves |
|
| 33 | - * @return void |
|
| 34 | - * @throws EE_Error |
|
| 35 | - * @since 4.3.0 |
|
| 36 | - */ |
|
| 37 | - public static function register($identifier = '', array $setup_args = []) |
|
| 38 | - { |
|
| 26 | + /** |
|
| 27 | + * Method for registering new EED_Widgets |
|
| 28 | + * |
|
| 29 | + * @param string $identifier a unique identifier for this set of widgets |
|
| 30 | + * @param array $setup_args an array of arguments provided for registering widgets |
|
| 31 | + * @type array widget_paths an array of full server paths to folders containing any EED_Widgets, or to the |
|
| 32 | + * EED_Widget files themselves |
|
| 33 | + * @return void |
|
| 34 | + * @throws EE_Error |
|
| 35 | + * @since 4.3.0 |
|
| 36 | + */ |
|
| 37 | + public static function register($identifier = '', array $setup_args = []) |
|
| 38 | + { |
|
| 39 | 39 | |
| 40 | - // required fields MUST be present, so let's make sure they are. |
|
| 41 | - if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['widget_paths'])) { |
|
| 42 | - throw new EE_Error( |
|
| 43 | - __( |
|
| 44 | - '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)', |
|
| 45 | - 'event_espresso' |
|
| 46 | - ) |
|
| 47 | - ); |
|
| 48 | - } |
|
| 40 | + // required fields MUST be present, so let's make sure they are. |
|
| 41 | + if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['widget_paths'])) { |
|
| 42 | + throw new EE_Error( |
|
| 43 | + __( |
|
| 44 | + '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)', |
|
| 45 | + 'event_espresso' |
|
| 46 | + ) |
|
| 47 | + ); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - // make sure we don't register twice |
|
| 51 | - if (isset(self::$_settings[ $identifier ])) { |
|
| 52 | - return; |
|
| 53 | - } |
|
| 50 | + // make sure we don't register twice |
|
| 51 | + if (isset(self::$_settings[ $identifier ])) { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | 55 | |
| 56 | - // make sure this was called in the right place! |
|
| 57 | - if (! 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 | - __( |
|
| 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[ $identifier ] = [ |
|
| 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 | - } |
|
| 56 | + // make sure this was called in the right place! |
|
| 57 | + if (! 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 | + __( |
|
| 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[ $identifier ] = [ |
|
| 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 | + } |
|
| 80 | 80 | |
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Filters the list of widgets to add ours. |
|
| 84 | - * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg. |
|
| 85 | - * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/widgets/espresso_monkey'...) |
|
| 86 | - * |
|
| 87 | - * @param array $widgets_to_register array of paths to all widgets that require registering |
|
| 88 | - * @return array |
|
| 89 | - */ |
|
| 90 | - public static function add_widgets(array $widgets_to_register = []) |
|
| 91 | - { |
|
| 92 | - foreach (self::$_settings as $settings) { |
|
| 93 | - $widgets_to_register = array_merge($widgets_to_register, $settings['widget_paths']); |
|
| 94 | - } |
|
| 95 | - return $widgets_to_register; |
|
| 96 | - } |
|
| 82 | + /** |
|
| 83 | + * Filters the list of widgets to add ours. |
|
| 84 | + * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg. |
|
| 85 | + * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/widgets/espresso_monkey'...) |
|
| 86 | + * |
|
| 87 | + * @param array $widgets_to_register array of paths to all widgets that require registering |
|
| 88 | + * @return array |
|
| 89 | + */ |
|
| 90 | + public static function add_widgets(array $widgets_to_register = []) |
|
| 91 | + { |
|
| 92 | + foreach (self::$_settings as $settings) { |
|
| 93 | + $widgets_to_register = array_merge($widgets_to_register, $settings['widget_paths']); |
|
| 94 | + } |
|
| 95 | + return $widgets_to_register; |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * This deregisters a widget that was previously registered with a specific $identifier. |
|
| 101 | - * |
|
| 102 | - * @param string $identifier the name for the widget that was previously registered |
|
| 103 | - * @return void |
|
| 104 | - * @since 4.3.0 |
|
| 105 | - * |
|
| 106 | - */ |
|
| 107 | - public static function deregister($identifier = '') |
|
| 108 | - { |
|
| 109 | - unset(self::$_settings[ $identifier ]); |
|
| 110 | - } |
|
| 99 | + /** |
|
| 100 | + * This deregisters a widget that was previously registered with a specific $identifier. |
|
| 101 | + * |
|
| 102 | + * @param string $identifier the name for the widget that was previously registered |
|
| 103 | + * @return void |
|
| 104 | + * @since 4.3.0 |
|
| 105 | + * |
|
| 106 | + */ |
|
| 107 | + public static function deregister($identifier = '') |
|
| 108 | + { |
|
| 109 | + unset(self::$_settings[ $identifier ]); |
|
| 110 | + } |
|
| 111 | 111 | } |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // make sure we don't register twice |
| 51 | - if (isset(self::$_settings[ $identifier ])) { |
|
| 51 | + if (isset(self::$_settings[$identifier])) { |
|
| 52 | 52 | return; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | // make sure this was called in the right place! |
| 57 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 57 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 58 | 58 | || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
| 59 | 59 | ) { |
| 60 | 60 | EE_Error::doing_it_wrong( |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | ); |
| 68 | 68 | } |
| 69 | 69 | // setup $_settings array from incoming values. |
| 70 | - self::$_settings[ $identifier ] = [ |
|
| 70 | + self::$_settings[$identifier] = [ |
|
| 71 | 71 | // array of full server paths to any EED_Widgets used by the widget |
| 72 | 72 | 'widget_paths' => isset($setup_args['widget_paths']) ? (array) $setup_args['widget_paths'] : [], |
| 73 | 73 | ]; |
@@ -106,6 +106,6 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public static function deregister($identifier = '') |
| 108 | 108 | { |
| 109 | - unset(self::$_settings[ $identifier ]); |
|
| 109 | + unset(self::$_settings[$identifier]); |
|
| 110 | 110 | } |
| 111 | 111 | } |
@@ -12,182 +12,182 @@ |
||
| 12 | 12 | { |
| 13 | 13 | |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * holds values for registered messages shortcode libraries |
|
| 17 | - * |
|
| 18 | - * @var array |
|
| 19 | - */ |
|
| 20 | - protected static $_ee_messages_shortcode_registry = []; |
|
| 21 | - |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * Helper method for registering a new shortcodes library class for the messages system. |
|
| 25 | - * |
|
| 26 | - * Note this is not used for adding shortcodes to existing libraries. It's for registering anything |
|
| 27 | - * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class. |
|
| 28 | - * |
|
| 29 | - * @param string $identifier What is the name of this shortcode |
|
| 30 | - * library |
|
| 31 | - * (e.g. 'question_list'); |
|
| 32 | - * @param array $setup_args { |
|
| 33 | - * An array of arguments provided for |
|
| 34 | - * registering the new messages |
|
| 35 | - * shortcode library. |
|
| 36 | - * |
|
| 37 | - * @type array $autoloadpaths An array of paths to add to the |
|
| 38 | - * messages autoloader for the new shortcode library class file. |
|
| 39 | - * @type string $msgr_validator_callback Callback for a method that will |
|
| 40 | - * register the library with the messenger |
|
| 41 | - * _validator_config. Optional. |
|
| 42 | - * @type string $msgr_template_fields_callback Callback for changing adding the |
|
| 43 | - * _template_fields property for |
|
| 44 | - * messenger. For example, the |
|
| 45 | - * shortcode library may add a new |
|
| 46 | - * field to the message templates. |
|
| 47 | - * Optional. |
|
| 48 | - * @type string $valid_shortcodes_callback Callback for message types |
|
| 49 | - * _valid_shortcodes array setup. |
|
| 50 | - * Optional. |
|
| 51 | - * @type array $list_type_shortcodes If there are any specific |
|
| 52 | - * shortcodes with this message shortcode library that should be considered "list type" then include them in |
|
| 53 | - * an array. List Type shortcodes are shortcodes that have a corresponding field that indicates how they are |
|
| 54 | - * parsed. Optional. |
|
| 55 | - * } |
|
| 56 | - * @return void |
|
| 57 | - * @throws EE_Error |
|
| 58 | - * @throws EE_Error |
|
| 59 | - * @since 4.3.0 |
|
| 60 | - * |
|
| 61 | - */ |
|
| 62 | - public static function register($identifier = '', array $setup_args = []) |
|
| 63 | - { |
|
| 64 | - |
|
| 65 | - // required fields MUST be present, so let's make sure they are. |
|
| 66 | - if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) { |
|
| 67 | - throw new EE_Error( |
|
| 68 | - __( |
|
| 69 | - '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"', |
|
| 70 | - 'event_espresso' |
|
| 71 | - ) |
|
| 72 | - ); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - // make sure we don't register twice |
|
| 76 | - if (isset(self::$_ee_messages_shortcode_registry[ $identifier ])) { |
|
| 77 | - return; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - // make sure this was called in the right place! |
|
| 81 | - if (! did_action('EE_Brewing_Regular___messages_caf') |
|
| 82 | - || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
| 83 | - ) { |
|
| 84 | - EE_Error::doing_it_wrong( |
|
| 85 | - __METHOD__, |
|
| 86 | - sprintf( |
|
| 87 | - __( |
|
| 88 | - 'Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).', |
|
| 89 | - 'event_espresso' |
|
| 90 | - ), |
|
| 91 | - $identifier |
|
| 92 | - ), |
|
| 93 | - '4.3.0' |
|
| 94 | - ); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - self::$_ee_messages_shortcode_registry[ $identifier ] = [ |
|
| 98 | - 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
|
| 99 | - 'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes']) |
|
| 100 | - ? (array) $setup_args['list_type_shortcodes'] : [], |
|
| 101 | - ]; |
|
| 102 | - |
|
| 103 | - // add filters |
|
| 104 | - add_filter( |
|
| 105 | - 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
| 106 | - ['EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'], |
|
| 107 | - 10 |
|
| 108 | - ); |
|
| 109 | - |
|
| 110 | - // add below filters if the required callback is provided. |
|
| 111 | - if (! empty($setup_args['msgr_validator_callback'])) { |
|
| 112 | - add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - if (! empty($setup_args['msgr_template_fields_callback'])) { |
|
| 116 | - add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - if (! empty($setup_args['valid_shortcodes_callback'])) { |
|
| 120 | - add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2); |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - if (! empty($setup_args['list_type_shortcodes'])) { |
|
| 124 | - add_filter( |
|
| 125 | - 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', |
|
| 126 | - ['EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'], |
|
| 127 | - 10 |
|
| 128 | - ); |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * This deregisters any messages shortcode library previously registered with the given name. |
|
| 135 | - * |
|
| 136 | - * @param string $identifier name used to register the shortcode library. |
|
| 137 | - * @return void |
|
| 138 | - * @since 4.3.0 |
|
| 139 | - */ |
|
| 140 | - public static function deregister($identifier = '') |
|
| 141 | - { |
|
| 142 | - unset(self::$_ee_messages_shortcode_registry[ $identifier ]); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
| 148 | - * |
|
| 149 | - * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
| 150 | - * @return array |
|
| 151 | - * @since 4.3.0 |
|
| 152 | - * |
|
| 153 | - */ |
|
| 154 | - public static function register_msgs_autoload_paths(array $paths) |
|
| 155 | - { |
|
| 156 | - |
|
| 157 | - if (! empty(self::$_ee_messages_shortcode_registry)) { |
|
| 158 | - foreach (self::$_ee_messages_shortcode_registry as $st_reg) { |
|
| 159 | - if (empty($st_reg['autoloadpaths'])) { |
|
| 160 | - continue; |
|
| 161 | - } |
|
| 162 | - $paths = array_merge($paths, $st_reg['autoloadpaths']); |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - return $paths; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes |
|
| 172 | - * filter which is used to add additional list type shortcodes. |
|
| 173 | - * |
|
| 174 | - * @param array $original_shortcodes |
|
| 175 | - * @return array Modifications to original shortcodes. |
|
| 176 | - * @since 4.3.0 |
|
| 177 | - * |
|
| 178 | - */ |
|
| 179 | - public static function register_list_type_shortcodes(array $original_shortcodes) |
|
| 180 | - { |
|
| 181 | - if (empty(self::$_ee_messages_shortcode_registry)) { |
|
| 182 | - return $original_shortcodes; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - foreach (self::$_ee_messages_shortcode_registry as $sc_reg) { |
|
| 186 | - if (! empty($sc_reg['list_type_shortcodes'])) { |
|
| 187 | - $original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']); |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - return $original_shortcodes; |
|
| 192 | - } |
|
| 15 | + /** |
|
| 16 | + * holds values for registered messages shortcode libraries |
|
| 17 | + * |
|
| 18 | + * @var array |
|
| 19 | + */ |
|
| 20 | + protected static $_ee_messages_shortcode_registry = []; |
|
| 21 | + |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * Helper method for registering a new shortcodes library class for the messages system. |
|
| 25 | + * |
|
| 26 | + * Note this is not used for adding shortcodes to existing libraries. It's for registering anything |
|
| 27 | + * related to registering a new EE_{shortcode_library_name}_Shortcodes.lib.php class. |
|
| 28 | + * |
|
| 29 | + * @param string $identifier What is the name of this shortcode |
|
| 30 | + * library |
|
| 31 | + * (e.g. 'question_list'); |
|
| 32 | + * @param array $setup_args { |
|
| 33 | + * An array of arguments provided for |
|
| 34 | + * registering the new messages |
|
| 35 | + * shortcode library. |
|
| 36 | + * |
|
| 37 | + * @type array $autoloadpaths An array of paths to add to the |
|
| 38 | + * messages autoloader for the new shortcode library class file. |
|
| 39 | + * @type string $msgr_validator_callback Callback for a method that will |
|
| 40 | + * register the library with the messenger |
|
| 41 | + * _validator_config. Optional. |
|
| 42 | + * @type string $msgr_template_fields_callback Callback for changing adding the |
|
| 43 | + * _template_fields property for |
|
| 44 | + * messenger. For example, the |
|
| 45 | + * shortcode library may add a new |
|
| 46 | + * field to the message templates. |
|
| 47 | + * Optional. |
|
| 48 | + * @type string $valid_shortcodes_callback Callback for message types |
|
| 49 | + * _valid_shortcodes array setup. |
|
| 50 | + * Optional. |
|
| 51 | + * @type array $list_type_shortcodes If there are any specific |
|
| 52 | + * shortcodes with this message shortcode library that should be considered "list type" then include them in |
|
| 53 | + * an array. List Type shortcodes are shortcodes that have a corresponding field that indicates how they are |
|
| 54 | + * parsed. Optional. |
|
| 55 | + * } |
|
| 56 | + * @return void |
|
| 57 | + * @throws EE_Error |
|
| 58 | + * @throws EE_Error |
|
| 59 | + * @since 4.3.0 |
|
| 60 | + * |
|
| 61 | + */ |
|
| 62 | + public static function register($identifier = '', array $setup_args = []) |
|
| 63 | + { |
|
| 64 | + |
|
| 65 | + // required fields MUST be present, so let's make sure they are. |
|
| 66 | + if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['autoloadpaths'])) { |
|
| 67 | + throw new EE_Error( |
|
| 68 | + __( |
|
| 69 | + '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"', |
|
| 70 | + 'event_espresso' |
|
| 71 | + ) |
|
| 72 | + ); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + // make sure we don't register twice |
|
| 76 | + if (isset(self::$_ee_messages_shortcode_registry[ $identifier ])) { |
|
| 77 | + return; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + // make sure this was called in the right place! |
|
| 81 | + if (! did_action('EE_Brewing_Regular___messages_caf') |
|
| 82 | + || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
| 83 | + ) { |
|
| 84 | + EE_Error::doing_it_wrong( |
|
| 85 | + __METHOD__, |
|
| 86 | + sprintf( |
|
| 87 | + __( |
|
| 88 | + 'Should be only called on the "EE_Brewing_Regular___messages_caf" hook (Trying to register a library named %s).', |
|
| 89 | + 'event_espresso' |
|
| 90 | + ), |
|
| 91 | + $identifier |
|
| 92 | + ), |
|
| 93 | + '4.3.0' |
|
| 94 | + ); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + self::$_ee_messages_shortcode_registry[ $identifier ] = [ |
|
| 98 | + 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
|
| 99 | + 'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes']) |
|
| 100 | + ? (array) $setup_args['list_type_shortcodes'] : [], |
|
| 101 | + ]; |
|
| 102 | + |
|
| 103 | + // add filters |
|
| 104 | + add_filter( |
|
| 105 | + 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
|
| 106 | + ['EE_Register_Messages_Shortcode_Library', 'register_msgs_autoload_paths'], |
|
| 107 | + 10 |
|
| 108 | + ); |
|
| 109 | + |
|
| 110 | + // add below filters if the required callback is provided. |
|
| 111 | + if (! empty($setup_args['msgr_validator_callback'])) { |
|
| 112 | + add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + if (! empty($setup_args['msgr_template_fields_callback'])) { |
|
| 116 | + add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + if (! empty($setup_args['valid_shortcodes_callback'])) { |
|
| 120 | + add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2); |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + if (! empty($setup_args['list_type_shortcodes'])) { |
|
| 124 | + add_filter( |
|
| 125 | + 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', |
|
| 126 | + ['EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'], |
|
| 127 | + 10 |
|
| 128 | + ); |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * This deregisters any messages shortcode library previously registered with the given name. |
|
| 135 | + * |
|
| 136 | + * @param string $identifier name used to register the shortcode library. |
|
| 137 | + * @return void |
|
| 138 | + * @since 4.3.0 |
|
| 139 | + */ |
|
| 140 | + public static function deregister($identifier = '') |
|
| 141 | + { |
|
| 142 | + unset(self::$_ee_messages_shortcode_registry[ $identifier ]); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * callback for FHEE__EED_Messages___set_messages_paths___MSG_PATHS filter. |
|
| 148 | + * |
|
| 149 | + * @param array $paths array of paths to be checked by EE_messages autoloader. |
|
| 150 | + * @return array |
|
| 151 | + * @since 4.3.0 |
|
| 152 | + * |
|
| 153 | + */ |
|
| 154 | + public static function register_msgs_autoload_paths(array $paths) |
|
| 155 | + { |
|
| 156 | + |
|
| 157 | + if (! empty(self::$_ee_messages_shortcode_registry)) { |
|
| 158 | + foreach (self::$_ee_messages_shortcode_registry as $st_reg) { |
|
| 159 | + if (empty($st_reg['autoloadpaths'])) { |
|
| 160 | + continue; |
|
| 161 | + } |
|
| 162 | + $paths = array_merge($paths, $st_reg['autoloadpaths']); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + return $paths; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * This is the callback for the FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes |
|
| 172 | + * filter which is used to add additional list type shortcodes. |
|
| 173 | + * |
|
| 174 | + * @param array $original_shortcodes |
|
| 175 | + * @return array Modifications to original shortcodes. |
|
| 176 | + * @since 4.3.0 |
|
| 177 | + * |
|
| 178 | + */ |
|
| 179 | + public static function register_list_type_shortcodes(array $original_shortcodes) |
|
| 180 | + { |
|
| 181 | + if (empty(self::$_ee_messages_shortcode_registry)) { |
|
| 182 | + return $original_shortcodes; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + foreach (self::$_ee_messages_shortcode_registry as $sc_reg) { |
|
| 186 | + if (! empty($sc_reg['list_type_shortcodes'])) { |
|
| 187 | + $original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']); |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + return $original_shortcodes; |
|
| 192 | + } |
|
| 193 | 193 | } |
@@ -73,12 +73,12 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | // make sure we don't register twice |
| 76 | - if (isset(self::$_ee_messages_shortcode_registry[ $identifier ])) { |
|
| 76 | + if (isset(self::$_ee_messages_shortcode_registry[$identifier])) { |
|
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // make sure this was called in the right place! |
| 81 | - if (! did_action('EE_Brewing_Regular___messages_caf') |
|
| 81 | + if ( ! did_action('EE_Brewing_Regular___messages_caf') |
|
| 82 | 82 | || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
| 83 | 83 | ) { |
| 84 | 84 | EE_Error::doing_it_wrong( |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | ); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - self::$_ee_messages_shortcode_registry[ $identifier ] = [ |
|
| 97 | + self::$_ee_messages_shortcode_registry[$identifier] = [ |
|
| 98 | 98 | 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
| 99 | 99 | 'list_type_shortcodes' => ! empty($setup_args['list_type_shortcodes']) |
| 100 | 100 | ? (array) $setup_args['list_type_shortcodes'] : [], |
@@ -108,19 +108,19 @@ discard block |
||
| 108 | 108 | ); |
| 109 | 109 | |
| 110 | 110 | // add below filters if the required callback is provided. |
| 111 | - if (! empty($setup_args['msgr_validator_callback'])) { |
|
| 111 | + if ( ! empty($setup_args['msgr_validator_callback'])) { |
|
| 112 | 112 | add_filter('FHEE__EE_messenger__get_validator_config', $setup_args['msgr_validator_callback'], 10, 2); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if (! empty($setup_args['msgr_template_fields_callback'])) { |
|
| 115 | + if ( ! empty($setup_args['msgr_template_fields_callback'])) { |
|
| 116 | 116 | add_filter('FHEE__EE_messenger__get_template_fields', $setup_args['msgr_template_fields_callback'], 10, 2); |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - if (! empty($setup_args['valid_shortcodes_callback'])) { |
|
| 119 | + if ( ! empty($setup_args['valid_shortcodes_callback'])) { |
|
| 120 | 120 | add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', $setup_args['valid_shortcodes_callback'], 10, 2); |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if (! empty($setup_args['list_type_shortcodes'])) { |
|
| 123 | + if ( ! empty($setup_args['list_type_shortcodes'])) { |
|
| 124 | 124 | add_filter( |
| 125 | 125 | 'FHEE__EEH_Parse_Shortcodes___parse_message_template__list_type_shortcodes', |
| 126 | 126 | ['EE_Register_Messages_Shortcode_Library', 'register_list_type_shortcodes'], |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public static function deregister($identifier = '') |
| 141 | 141 | { |
| 142 | - unset(self::$_ee_messages_shortcode_registry[ $identifier ]); |
|
| 142 | + unset(self::$_ee_messages_shortcode_registry[$identifier]); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | public static function register_msgs_autoload_paths(array $paths) |
| 155 | 155 | { |
| 156 | 156 | |
| 157 | - if (! empty(self::$_ee_messages_shortcode_registry)) { |
|
| 157 | + if ( ! empty(self::$_ee_messages_shortcode_registry)) { |
|
| 158 | 158 | foreach (self::$_ee_messages_shortcode_registry as $st_reg) { |
| 159 | 159 | if (empty($st_reg['autoloadpaths'])) { |
| 160 | 160 | continue; |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | foreach (self::$_ee_messages_shortcode_registry as $sc_reg) { |
| 186 | - if (! empty($sc_reg['list_type_shortcodes'])) { |
|
| 186 | + if ( ! empty($sc_reg['list_type_shortcodes'])) { |
|
| 187 | 187 | $original_shortcodes = array_merge($original_shortcodes, $sc_reg['list_type_shortcodes']); |
| 188 | 188 | } |
| 189 | 189 | } |
@@ -12,139 +12,139 @@ |
||
| 12 | 12 | { |
| 13 | 13 | |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Holds registered EE_Admin_Pages |
|
| 17 | - * |
|
| 18 | - * @var array |
|
| 19 | - */ |
|
| 20 | - protected static $_ee_admin_page_registry = []; |
|
| 21 | - |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE |
|
| 25 | - * Admin Page loader system). |
|
| 26 | - * |
|
| 27 | - * @param string $identifier This string represents the basename of the Admin |
|
| 28 | - * Page init. The init file must use this basename |
|
| 29 | - * in its name and class (i.e. |
|
| 30 | - * {page_basename}_Admin_Page_Init.core.php). |
|
| 31 | - * @param array $setup_args { An array of configuration options |
|
| 32 | - * that will be used in different circumstances |
|
| 33 | - * |
|
| 34 | - * @type string $page_path This is the path where the registered admin pages |
|
| 35 | - * reside ( used to setup autoloaders). |
|
| 36 | - * |
|
| 37 | - * } |
|
| 38 | - * @return void |
|
| 39 | - * @throws EE_Error |
|
| 40 | - * @since 4.3.0 |
|
| 41 | - * |
|
| 42 | - */ |
|
| 43 | - public static function register($identifier = '', array $setup_args = []) |
|
| 44 | - { |
|
| 45 | - |
|
| 46 | - // check that an admin_page has not already been registered with that name |
|
| 47 | - if (isset(self::$_ee_admin_page_registry[ $identifier ])) { |
|
| 48 | - throw new EE_Error( |
|
| 49 | - sprintf( |
|
| 50 | - __( |
|
| 51 | - 'An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.', |
|
| 52 | - 'event_espresso' |
|
| 53 | - ), |
|
| 54 | - $identifier |
|
| 55 | - ) |
|
| 56 | - ); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - // required fields MUST be present, so let's make sure they are. |
|
| 60 | - if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['page_path'])) { |
|
| 61 | - throw new EE_Error( |
|
| 62 | - __( |
|
| 63 | - 'In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)', |
|
| 64 | - 'event_espresso' |
|
| 65 | - ) |
|
| 66 | - ); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - // make sure we don't register twice |
|
| 70 | - if (isset(self::$_ee_admin_page_registry[ $identifier ])) { |
|
| 71 | - return; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
| 75 | - EE_Error::doing_it_wrong( |
|
| 76 | - __METHOD__, |
|
| 77 | - sprintf( |
|
| 78 | - __( |
|
| 79 | - 'An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time. Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - $identifier |
|
| 83 | - ), |
|
| 84 | - '4.3' |
|
| 85 | - ); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - // add incoming stuff to our registry property |
|
| 89 | - self::$_ee_admin_page_registry[ $identifier ] = [ |
|
| 90 | - 'page_path' => $setup_args['page_path'], |
|
| 91 | - 'config' => $setup_args, |
|
| 92 | - ]; |
|
| 93 | - |
|
| 94 | - // add filters |
|
| 95 | - |
|
| 96 | - add_filter( |
|
| 97 | - 'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', |
|
| 98 | - ['EE_Register_Admin_Page', 'set_page_basename'], |
|
| 99 | - 10 |
|
| 100 | - ); |
|
| 101 | - add_filter('FHEE__EEH_Autoloader__load_admin_core', ['EE_Register_Admin_Page', 'set_page_path'], 10); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * This deregisters a EE_Admin page that is already registered. Note, this MUST be loaded after the |
|
| 107 | - * page being deregistered is loaded. |
|
| 108 | - * |
|
| 109 | - * @param string $identifier Use whatever string was used to register the admin page. |
|
| 110 | - * @return void |
|
| 111 | - * @since 4.3.0 |
|
| 112 | - * |
|
| 113 | - */ |
|
| 114 | - public static function deregister($identifier = '') |
|
| 115 | - { |
|
| 116 | - unset(self::$_ee_admin_page_registry[ $identifier ]); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * set_page_basename |
|
| 122 | - * |
|
| 123 | - * @param $installed_refs |
|
| 124 | - * @return mixed |
|
| 125 | - */ |
|
| 126 | - public static function set_page_basename($installed_refs) |
|
| 127 | - { |
|
| 128 | - if (! empty(self::$_ee_admin_page_registry)) { |
|
| 129 | - foreach (self::$_ee_admin_page_registry as $basename => $args) { |
|
| 130 | - $installed_refs[ $basename ] = $args['page_path']; |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - return $installed_refs; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * set_page_path |
|
| 139 | - * |
|
| 140 | - * @param $paths |
|
| 141 | - * @return mixed |
|
| 142 | - */ |
|
| 143 | - public static function set_page_path($paths) |
|
| 144 | - { |
|
| 145 | - foreach (self::$_ee_admin_page_registry as $basename => $args) { |
|
| 146 | - $paths[ $basename ] = $args['page_path']; |
|
| 147 | - } |
|
| 148 | - return $paths; |
|
| 149 | - } |
|
| 15 | + /** |
|
| 16 | + * Holds registered EE_Admin_Pages |
|
| 17 | + * |
|
| 18 | + * @var array |
|
| 19 | + */ |
|
| 20 | + protected static $_ee_admin_page_registry = []; |
|
| 21 | + |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE |
|
| 25 | + * Admin Page loader system). |
|
| 26 | + * |
|
| 27 | + * @param string $identifier This string represents the basename of the Admin |
|
| 28 | + * Page init. The init file must use this basename |
|
| 29 | + * in its name and class (i.e. |
|
| 30 | + * {page_basename}_Admin_Page_Init.core.php). |
|
| 31 | + * @param array $setup_args { An array of configuration options |
|
| 32 | + * that will be used in different circumstances |
|
| 33 | + * |
|
| 34 | + * @type string $page_path This is the path where the registered admin pages |
|
| 35 | + * reside ( used to setup autoloaders). |
|
| 36 | + * |
|
| 37 | + * } |
|
| 38 | + * @return void |
|
| 39 | + * @throws EE_Error |
|
| 40 | + * @since 4.3.0 |
|
| 41 | + * |
|
| 42 | + */ |
|
| 43 | + public static function register($identifier = '', array $setup_args = []) |
|
| 44 | + { |
|
| 45 | + |
|
| 46 | + // check that an admin_page has not already been registered with that name |
|
| 47 | + if (isset(self::$_ee_admin_page_registry[ $identifier ])) { |
|
| 48 | + throw new EE_Error( |
|
| 49 | + sprintf( |
|
| 50 | + __( |
|
| 51 | + 'An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.', |
|
| 52 | + 'event_espresso' |
|
| 53 | + ), |
|
| 54 | + $identifier |
|
| 55 | + ) |
|
| 56 | + ); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + // required fields MUST be present, so let's make sure they are. |
|
| 60 | + if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['page_path'])) { |
|
| 61 | + throw new EE_Error( |
|
| 62 | + __( |
|
| 63 | + 'In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)', |
|
| 64 | + 'event_espresso' |
|
| 65 | + ) |
|
| 66 | + ); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + // make sure we don't register twice |
|
| 70 | + if (isset(self::$_ee_admin_page_registry[ $identifier ])) { |
|
| 71 | + return; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
| 75 | + EE_Error::doing_it_wrong( |
|
| 76 | + __METHOD__, |
|
| 77 | + sprintf( |
|
| 78 | + __( |
|
| 79 | + 'An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time. Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + $identifier |
|
| 83 | + ), |
|
| 84 | + '4.3' |
|
| 85 | + ); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + // add incoming stuff to our registry property |
|
| 89 | + self::$_ee_admin_page_registry[ $identifier ] = [ |
|
| 90 | + 'page_path' => $setup_args['page_path'], |
|
| 91 | + 'config' => $setup_args, |
|
| 92 | + ]; |
|
| 93 | + |
|
| 94 | + // add filters |
|
| 95 | + |
|
| 96 | + add_filter( |
|
| 97 | + 'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', |
|
| 98 | + ['EE_Register_Admin_Page', 'set_page_basename'], |
|
| 99 | + 10 |
|
| 100 | + ); |
|
| 101 | + add_filter('FHEE__EEH_Autoloader__load_admin_core', ['EE_Register_Admin_Page', 'set_page_path'], 10); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * This deregisters a EE_Admin page that is already registered. Note, this MUST be loaded after the |
|
| 107 | + * page being deregistered is loaded. |
|
| 108 | + * |
|
| 109 | + * @param string $identifier Use whatever string was used to register the admin page. |
|
| 110 | + * @return void |
|
| 111 | + * @since 4.3.0 |
|
| 112 | + * |
|
| 113 | + */ |
|
| 114 | + public static function deregister($identifier = '') |
|
| 115 | + { |
|
| 116 | + unset(self::$_ee_admin_page_registry[ $identifier ]); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * set_page_basename |
|
| 122 | + * |
|
| 123 | + * @param $installed_refs |
|
| 124 | + * @return mixed |
|
| 125 | + */ |
|
| 126 | + public static function set_page_basename($installed_refs) |
|
| 127 | + { |
|
| 128 | + if (! empty(self::$_ee_admin_page_registry)) { |
|
| 129 | + foreach (self::$_ee_admin_page_registry as $basename => $args) { |
|
| 130 | + $installed_refs[ $basename ] = $args['page_path']; |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + return $installed_refs; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * set_page_path |
|
| 139 | + * |
|
| 140 | + * @param $paths |
|
| 141 | + * @return mixed |
|
| 142 | + */ |
|
| 143 | + public static function set_page_path($paths) |
|
| 144 | + { |
|
| 145 | + foreach (self::$_ee_admin_page_registry as $basename => $args) { |
|
| 146 | + $paths[ $basename ] = $args['page_path']; |
|
| 147 | + } |
|
| 148 | + return $paths; |
|
| 149 | + } |
|
| 150 | 150 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | |
| 46 | 46 | // check that an admin_page has not already been registered with that name |
| 47 | - if (isset(self::$_ee_admin_page_registry[ $identifier ])) { |
|
| 47 | + if (isset(self::$_ee_admin_page_registry[$identifier])) { |
|
| 48 | 48 | throw new EE_Error( |
| 49 | 49 | sprintf( |
| 50 | 50 | __( |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // make sure we don't register twice |
| 70 | - if (isset(self::$_ee_admin_page_registry[ $identifier ])) { |
|
| 70 | + if (isset(self::$_ee_admin_page_registry[$identifier])) { |
|
| 71 | 71 | return; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
| 74 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
| 75 | 75 | EE_Error::doing_it_wrong( |
| 76 | 76 | __METHOD__, |
| 77 | 77 | sprintf( |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | // add incoming stuff to our registry property |
| 89 | - self::$_ee_admin_page_registry[ $identifier ] = [ |
|
| 89 | + self::$_ee_admin_page_registry[$identifier] = [ |
|
| 90 | 90 | 'page_path' => $setup_args['page_path'], |
| 91 | 91 | 'config' => $setup_args, |
| 92 | 92 | ]; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | public static function deregister($identifier = '') |
| 115 | 115 | { |
| 116 | - unset(self::$_ee_admin_page_registry[ $identifier ]); |
|
| 116 | + unset(self::$_ee_admin_page_registry[$identifier]); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | public static function set_page_basename($installed_refs) |
| 127 | 127 | { |
| 128 | - if (! empty(self::$_ee_admin_page_registry)) { |
|
| 128 | + if ( ! empty(self::$_ee_admin_page_registry)) { |
|
| 129 | 129 | foreach (self::$_ee_admin_page_registry as $basename => $args) { |
| 130 | - $installed_refs[ $basename ] = $args['page_path']; |
|
| 130 | + $installed_refs[$basename] = $args['page_path']; |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | return $installed_refs; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | public static function set_page_path($paths) |
| 144 | 144 | { |
| 145 | 145 | foreach (self::$_ee_admin_page_registry as $basename => $args) { |
| 146 | - $paths[ $basename ] = $args['page_path']; |
|
| 146 | + $paths[$basename] = $args['page_path']; |
|
| 147 | 147 | } |
| 148 | 148 | return $paths; |
| 149 | 149 | } |
@@ -15,97 +15,97 @@ |
||
| 15 | 15 | class EE_Register_Data_Migration_Scripts implements EEI_Plugin_API |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Holds values for registered DMSs |
|
| 20 | - * |
|
| 21 | - * @var array[][] |
|
| 22 | - */ |
|
| 23 | - protected static $_settings = array(); |
|
| 18 | + /** |
|
| 19 | + * Holds values for registered DMSs |
|
| 20 | + * |
|
| 21 | + * @var array[][] |
|
| 22 | + */ |
|
| 23 | + protected static $_settings = array(); |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Method for registering new Data Migration Scripts |
|
| 28 | - * |
|
| 29 | - * @since 4.3.0 |
|
| 30 | - * @param string $identifier EE_Addon class name that this set of data migration scripts belongs to |
|
| 31 | - * If EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name |
|
| 32 | - * @param array $setup_args { |
|
| 33 | - * @type string $dms_paths an array of full server paths to folders that contain data migration scripts |
|
| 34 | - * } |
|
| 35 | - * @throws EE_Error |
|
| 36 | - * @return void |
|
| 37 | - */ |
|
| 38 | - public static function register($identifier = '', array $setup_args = []) |
|
| 39 | - { |
|
| 40 | - // required fields MUST be present, so let's make sure they are. |
|
| 41 | - if (empty($identifier) || ! 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[ $identifier ])) { |
|
| 51 | - return; |
|
| 52 | - } |
|
| 53 | - // make sure this was called in the right place! |
|
| 54 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 55 | - || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
| 56 | - ) { |
|
| 57 | - EE_Error::doing_it_wrong( |
|
| 58 | - __METHOD__, |
|
| 59 | - esc_html__( |
|
| 60 | - '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.', |
|
| 61 | - 'event_espresso' |
|
| 62 | - ), |
|
| 63 | - '4.3.0' |
|
| 64 | - ); |
|
| 65 | - } |
|
| 66 | - // setup $_settings array from incoming values. |
|
| 67 | - self::$_settings[ $identifier ] = array( |
|
| 68 | - 'dms_paths' => (array) $setup_args['dms_paths'], |
|
| 69 | - ); |
|
| 70 | - // setup DMS |
|
| 71 | - add_filter( |
|
| 72 | - 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', |
|
| 73 | - array('EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders') |
|
| 74 | - ); |
|
| 75 | - } |
|
| 26 | + /** |
|
| 27 | + * Method for registering new Data Migration Scripts |
|
| 28 | + * |
|
| 29 | + * @since 4.3.0 |
|
| 30 | + * @param string $identifier EE_Addon class name that this set of data migration scripts belongs to |
|
| 31 | + * If EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name |
|
| 32 | + * @param array $setup_args { |
|
| 33 | + * @type string $dms_paths an array of full server paths to folders that contain data migration scripts |
|
| 34 | + * } |
|
| 35 | + * @throws EE_Error |
|
| 36 | + * @return void |
|
| 37 | + */ |
|
| 38 | + public static function register($identifier = '', array $setup_args = []) |
|
| 39 | + { |
|
| 40 | + // required fields MUST be present, so let's make sure they are. |
|
| 41 | + if (empty($identifier) || ! 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[ $identifier ])) { |
|
| 51 | + return; |
|
| 52 | + } |
|
| 53 | + // make sure this was called in the right place! |
|
| 54 | + if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 55 | + || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
| 56 | + ) { |
|
| 57 | + EE_Error::doing_it_wrong( |
|
| 58 | + __METHOD__, |
|
| 59 | + esc_html__( |
|
| 60 | + '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.', |
|
| 61 | + 'event_espresso' |
|
| 62 | + ), |
|
| 63 | + '4.3.0' |
|
| 64 | + ); |
|
| 65 | + } |
|
| 66 | + // setup $_settings array from incoming values. |
|
| 67 | + self::$_settings[ $identifier ] = array( |
|
| 68 | + 'dms_paths' => (array) $setup_args['dms_paths'], |
|
| 69 | + ); |
|
| 70 | + // setup DMS |
|
| 71 | + add_filter( |
|
| 72 | + 'FHEE__EE_Data_Migration_Manager__get_data_migration_script_folders', |
|
| 73 | + array('EE_Register_Data_Migration_Scripts', 'add_data_migration_script_folders') |
|
| 74 | + ); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @param array $dms_paths |
|
| 80 | - * @return array |
|
| 81 | - */ |
|
| 82 | - public static function add_data_migration_script_folders(array $dms_paths = array()) |
|
| 83 | - { |
|
| 84 | - foreach (self::$_settings as $identifier => $settings) { |
|
| 85 | - $wildcards = 0; |
|
| 86 | - foreach ($settings['dms_paths'] as $dms_path) { |
|
| 87 | - // since we are using the addon name for the array key |
|
| 88 | - // we need to ensure that the key is unique, |
|
| 89 | - // so if for some reason an addon has multiple dms paths, |
|
| 90 | - // we append one or more * to the classname |
|
| 91 | - // which will get stripped out later on |
|
| 92 | - $dms_paths[ $identifier . str_repeat('*', $wildcards) ] = $dms_path; |
|
| 93 | - $wildcards++; |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - return $dms_paths; |
|
| 97 | - } |
|
| 78 | + /** |
|
| 79 | + * @param array $dms_paths |
|
| 80 | + * @return array |
|
| 81 | + */ |
|
| 82 | + public static function add_data_migration_script_folders(array $dms_paths = array()) |
|
| 83 | + { |
|
| 84 | + foreach (self::$_settings as $identifier => $settings) { |
|
| 85 | + $wildcards = 0; |
|
| 86 | + foreach ($settings['dms_paths'] as $dms_path) { |
|
| 87 | + // since we are using the addon name for the array key |
|
| 88 | + // we need to ensure that the key is unique, |
|
| 89 | + // so if for some reason an addon has multiple dms paths, |
|
| 90 | + // we append one or more * to the classname |
|
| 91 | + // which will get stripped out later on |
|
| 92 | + $dms_paths[ $identifier . str_repeat('*', $wildcards) ] = $dms_path; |
|
| 93 | + $wildcards++; |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + return $dms_paths; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * This deregisters a set of Data Migration Scripts that were previously registered with a specific dms_id |
|
| 102 | - * |
|
| 103 | - * @since 4.3.0 |
|
| 104 | - * @param string $identifier EE_Addon class name that this set of data migration scripts belongs to |
|
| 105 | - * @return void |
|
| 106 | - */ |
|
| 107 | - public static function deregister($identifier = '') |
|
| 108 | - { |
|
| 109 | - unset(self::$_settings[ $identifier ]); |
|
| 110 | - } |
|
| 100 | + /** |
|
| 101 | + * This deregisters a set of Data Migration Scripts that were previously registered with a specific dms_id |
|
| 102 | + * |
|
| 103 | + * @since 4.3.0 |
|
| 104 | + * @param string $identifier EE_Addon class name that this set of data migration scripts belongs to |
|
| 105 | + * @return void |
|
| 106 | + */ |
|
| 107 | + public static function deregister($identifier = '') |
|
| 108 | + { |
|
| 109 | + unset(self::$_settings[ $identifier ]); |
|
| 110 | + } |
|
| 111 | 111 | } |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | ); |
| 48 | 48 | } |
| 49 | 49 | // make sure we don't register twice |
| 50 | - if (isset(self::$_settings[ $identifier ])) { |
|
| 50 | + if (isset(self::$_settings[$identifier])) { |
|
| 51 | 51 | return; |
| 52 | 52 | } |
| 53 | 53 | // make sure this was called in the right place! |
| 54 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 54 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 55 | 55 | || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
| 56 | 56 | ) { |
| 57 | 57 | EE_Error::doing_it_wrong( |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | ); |
| 65 | 65 | } |
| 66 | 66 | // setup $_settings array from incoming values. |
| 67 | - self::$_settings[ $identifier ] = array( |
|
| 67 | + self::$_settings[$identifier] = array( |
|
| 68 | 68 | 'dms_paths' => (array) $setup_args['dms_paths'], |
| 69 | 69 | ); |
| 70 | 70 | // setup DMS |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | // so if for some reason an addon has multiple dms paths, |
| 90 | 90 | // we append one or more * to the classname |
| 91 | 91 | // which will get stripped out later on |
| 92 | - $dms_paths[ $identifier . str_repeat('*', $wildcards) ] = $dms_path; |
|
| 92 | + $dms_paths[$identifier.str_repeat('*', $wildcards)] = $dms_path; |
|
| 93 | 93 | $wildcards++; |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -106,6 +106,6 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public static function deregister($identifier = '') |
| 108 | 108 | { |
| 109 | - unset(self::$_settings[ $identifier ]); |
|
| 109 | + unset(self::$_settings[$identifier]); |
|
| 110 | 110 | } |
| 111 | 111 | } |
@@ -15,213 +15,213 @@ |
||
| 15 | 15 | class EE_Register_Capabilities implements EEI_Plugin_API |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Holds the settings for a specific registration. |
|
| 20 | - * |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - protected static $_registry = []; |
|
| 18 | + /** |
|
| 19 | + * Holds the settings for a specific registration. |
|
| 20 | + * |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + protected static $_registry = []; |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Used to register capability items with EE core. |
|
| 28 | - * |
|
| 29 | - * @param string $identifier usually will be a class name |
|
| 30 | - * that references capability |
|
| 31 | - * related items setup for |
|
| 32 | - * something. |
|
| 33 | - * @param array $setup_args { |
|
| 34 | - * An array of items related to |
|
| 35 | - * registering capabilities. |
|
| 36 | - * @type array $capabilities An array mapping capability |
|
| 37 | - * strings to core WP Role. |
|
| 38 | - * Something like: array( |
|
| 39 | - * 'administrator' => array( |
|
| 40 | - * 'read_cap', 'edit_cap', |
|
| 41 | - * 'delete_cap'), |
|
| 42 | - * 'author' => |
|
| 43 | - * array( 'read_cap' ) |
|
| 44 | - * ). |
|
| 45 | - * @type array $capability_maps EE_Meta_Capability_Map[] |
|
| 46 | - * @return void |
|
| 47 | - * @throws EE_Error |
|
| 48 | - * @since 4.5.0 |
|
| 49 | - * @see EE_Capabilities.php for php docs on these objects. |
|
| 50 | - * Should be indexed by the |
|
| 51 | - * classname for the capability |
|
| 52 | - * map and values representing |
|
| 53 | - * the arguments for the map. |
|
| 54 | - * } |
|
| 55 | - */ |
|
| 56 | - public static function register($identifier = '', array $setup_args = []) |
|
| 57 | - { |
|
| 58 | - // required fields MUST be present, so let's make sure they are. |
|
| 59 | - if ($identifier === null || ! is_array($setup_args) || empty($setup_args['capabilities'])) { |
|
| 60 | - throw new EE_Error( |
|
| 61 | - __( |
|
| 62 | - 'In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".', |
|
| 63 | - 'event_espresso' |
|
| 64 | - ) |
|
| 65 | - ); |
|
| 66 | - } |
|
| 67 | - // make sure we don't register twice |
|
| 68 | - if (isset(self::$_registry[ $identifier ])) { |
|
| 69 | - return; |
|
| 70 | - } |
|
| 71 | - // make sure this is not registered too late or too early. |
|
| 72 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 73 | - || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
| 74 | - ) { |
|
| 75 | - EE_Error::doing_it_wrong( |
|
| 76 | - __METHOD__, |
|
| 77 | - sprintf( |
|
| 78 | - __( |
|
| 79 | - '%s has been registered too late. Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - $identifier |
|
| 83 | - ), |
|
| 84 | - '4.5.0' |
|
| 85 | - ); |
|
| 86 | - } |
|
| 87 | - // some preliminary sanitization and setting to the $_registry property |
|
| 88 | - self::$_registry[ $identifier ] = [ |
|
| 89 | - 'caps' => isset($setup_args['capabilities']) && is_array($setup_args['capabilities']) |
|
| 90 | - ? $setup_args['capabilities'] |
|
| 91 | - : [], |
|
| 92 | - 'cap_maps' => isset($setup_args['capability_maps']) ? $setup_args['capability_maps'] : [], |
|
| 93 | - ]; |
|
| 94 | - // set initial caps (note that EE_Capabilities takes care of making sure that the caps get added only once) |
|
| 95 | - add_filter( |
|
| 96 | - 'FHEE__EE_Capabilities__addCaps__capabilities_to_add', |
|
| 97 | - ['EE_Register_Capabilities', 'register_capabilities'] |
|
| 98 | - ); |
|
| 99 | - // add filter for cap maps |
|
| 100 | - add_filter( |
|
| 101 | - 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', |
|
| 102 | - ['EE_Register_Capabilities', 'register_cap_maps'] |
|
| 103 | - ); |
|
| 104 | - } |
|
| 26 | + /** |
|
| 27 | + * Used to register capability items with EE core. |
|
| 28 | + * |
|
| 29 | + * @param string $identifier usually will be a class name |
|
| 30 | + * that references capability |
|
| 31 | + * related items setup for |
|
| 32 | + * something. |
|
| 33 | + * @param array $setup_args { |
|
| 34 | + * An array of items related to |
|
| 35 | + * registering capabilities. |
|
| 36 | + * @type array $capabilities An array mapping capability |
|
| 37 | + * strings to core WP Role. |
|
| 38 | + * Something like: array( |
|
| 39 | + * 'administrator' => array( |
|
| 40 | + * 'read_cap', 'edit_cap', |
|
| 41 | + * 'delete_cap'), |
|
| 42 | + * 'author' => |
|
| 43 | + * array( 'read_cap' ) |
|
| 44 | + * ). |
|
| 45 | + * @type array $capability_maps EE_Meta_Capability_Map[] |
|
| 46 | + * @return void |
|
| 47 | + * @throws EE_Error |
|
| 48 | + * @since 4.5.0 |
|
| 49 | + * @see EE_Capabilities.php for php docs on these objects. |
|
| 50 | + * Should be indexed by the |
|
| 51 | + * classname for the capability |
|
| 52 | + * map and values representing |
|
| 53 | + * the arguments for the map. |
|
| 54 | + * } |
|
| 55 | + */ |
|
| 56 | + public static function register($identifier = '', array $setup_args = []) |
|
| 57 | + { |
|
| 58 | + // required fields MUST be present, so let's make sure they are. |
|
| 59 | + if ($identifier === null || ! is_array($setup_args) || empty($setup_args['capabilities'])) { |
|
| 60 | + throw new EE_Error( |
|
| 61 | + __( |
|
| 62 | + 'In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".', |
|
| 63 | + 'event_espresso' |
|
| 64 | + ) |
|
| 65 | + ); |
|
| 66 | + } |
|
| 67 | + // make sure we don't register twice |
|
| 68 | + if (isset(self::$_registry[ $identifier ])) { |
|
| 69 | + return; |
|
| 70 | + } |
|
| 71 | + // make sure this is not registered too late or too early. |
|
| 72 | + if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 73 | + || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
| 74 | + ) { |
|
| 75 | + EE_Error::doing_it_wrong( |
|
| 76 | + __METHOD__, |
|
| 77 | + sprintf( |
|
| 78 | + __( |
|
| 79 | + '%s has been registered too late. Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + $identifier |
|
| 83 | + ), |
|
| 84 | + '4.5.0' |
|
| 85 | + ); |
|
| 86 | + } |
|
| 87 | + // some preliminary sanitization and setting to the $_registry property |
|
| 88 | + self::$_registry[ $identifier ] = [ |
|
| 89 | + 'caps' => isset($setup_args['capabilities']) && is_array($setup_args['capabilities']) |
|
| 90 | + ? $setup_args['capabilities'] |
|
| 91 | + : [], |
|
| 92 | + 'cap_maps' => isset($setup_args['capability_maps']) ? $setup_args['capability_maps'] : [], |
|
| 93 | + ]; |
|
| 94 | + // set initial caps (note that EE_Capabilities takes care of making sure that the caps get added only once) |
|
| 95 | + add_filter( |
|
| 96 | + 'FHEE__EE_Capabilities__addCaps__capabilities_to_add', |
|
| 97 | + ['EE_Register_Capabilities', 'register_capabilities'] |
|
| 98 | + ); |
|
| 99 | + // add filter for cap maps |
|
| 100 | + add_filter( |
|
| 101 | + 'FHEE__EE_Capabilities___set_meta_caps__meta_caps', |
|
| 102 | + ['EE_Register_Capabilities', 'register_cap_maps'] |
|
| 103 | + ); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | 106 | |
| 107 | - /** |
|
| 108 | - * callback for FHEE__EE_Capabilities__init_caps_map__caps filter. |
|
| 109 | - * Takes care of registering additional capabilities to the caps map. Note, that this also on the initial |
|
| 110 | - * registration ensures that new capabilities are added to existing roles. |
|
| 111 | - * |
|
| 112 | - * @param array $incoming_caps The original caps map. |
|
| 113 | - * @return array merged in new caps. |
|
| 114 | - */ |
|
| 115 | - public static function register_capabilities(array $incoming_caps) |
|
| 116 | - { |
|
| 117 | - foreach (self::$_registry as $caps_and_cap_map) { |
|
| 118 | - $incoming_caps = array_merge_recursive($incoming_caps, $caps_and_cap_map['caps']); |
|
| 119 | - } |
|
| 120 | - return $incoming_caps; |
|
| 121 | - } |
|
| 107 | + /** |
|
| 108 | + * callback for FHEE__EE_Capabilities__init_caps_map__caps filter. |
|
| 109 | + * Takes care of registering additional capabilities to the caps map. Note, that this also on the initial |
|
| 110 | + * registration ensures that new capabilities are added to existing roles. |
|
| 111 | + * |
|
| 112 | + * @param array $incoming_caps The original caps map. |
|
| 113 | + * @return array merged in new caps. |
|
| 114 | + */ |
|
| 115 | + public static function register_capabilities(array $incoming_caps) |
|
| 116 | + { |
|
| 117 | + foreach (self::$_registry as $caps_and_cap_map) { |
|
| 118 | + $incoming_caps = array_merge_recursive($incoming_caps, $caps_and_cap_map['caps']); |
|
| 119 | + } |
|
| 120 | + return $incoming_caps; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * Callback for the 'FHEE__EE_Capabilities___set_meta_caps__meta_caps' filter which registers an array of |
|
| 126 | - * capability maps for the WP meta_caps filter called in EE_Capabilities. |
|
| 127 | - * |
|
| 128 | - * @param EE_Meta_Capability_Map[] $cap_maps The existing cap maps array. |
|
| 129 | - * @return EE_Meta_Capability_Map[] |
|
| 130 | - * @throws EE_Error |
|
| 131 | - * @since 4.5.0 |
|
| 132 | - */ |
|
| 133 | - public static function register_cap_maps(array $cap_maps) |
|
| 134 | - { |
|
| 135 | - // loop through and instantiate cap maps. |
|
| 136 | - foreach (self::$_registry as $identifier => $setup) { |
|
| 137 | - if (! isset($setup['cap_maps'])) { |
|
| 138 | - continue; |
|
| 139 | - } |
|
| 140 | - foreach ($setup['cap_maps'] as $cap_class => $args) { |
|
| 124 | + /** |
|
| 125 | + * Callback for the 'FHEE__EE_Capabilities___set_meta_caps__meta_caps' filter which registers an array of |
|
| 126 | + * capability maps for the WP meta_caps filter called in EE_Capabilities. |
|
| 127 | + * |
|
| 128 | + * @param EE_Meta_Capability_Map[] $cap_maps The existing cap maps array. |
|
| 129 | + * @return EE_Meta_Capability_Map[] |
|
| 130 | + * @throws EE_Error |
|
| 131 | + * @since 4.5.0 |
|
| 132 | + */ |
|
| 133 | + public static function register_cap_maps(array $cap_maps) |
|
| 134 | + { |
|
| 135 | + // loop through and instantiate cap maps. |
|
| 136 | + foreach (self::$_registry as $identifier => $setup) { |
|
| 137 | + if (! isset($setup['cap_maps'])) { |
|
| 138 | + continue; |
|
| 139 | + } |
|
| 140 | + foreach ($setup['cap_maps'] as $cap_class => $args) { |
|
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * account for cases where capability maps may be indexed |
|
| 144 | - * numerically to allow for the same map class to be utilized |
|
| 145 | - * In those cases, maps will be setup in an array like: |
|
| 146 | - * array( |
|
| 147 | - * 0 => array( 'EE_Meta_Capability' => array( |
|
| 148 | - * 'ee_edit_cap', array( 'Object_Name', |
|
| 149 | - * 'ee_edit_published_cap', |
|
| 150 | - * 'ee_edit_others_cap', 'ee_edit_private_cap' ) |
|
| 151 | - * ) ) |
|
| 152 | - * 1 => ... |
|
| 153 | - * ) |
|
| 154 | - * instead of: |
|
| 155 | - * array( |
|
| 156 | - * 'EE_Meta_Capability' => array( |
|
| 157 | - * 'ee_edit_cap', array( 'Object_Name', |
|
| 158 | - * 'ee_edit_published_cap', |
|
| 159 | - * 'ee_edit_others_cap', 'ee_edit_private_cap' ) |
|
| 160 | - * ), |
|
| 161 | - * ... |
|
| 162 | - * ) |
|
| 163 | - */ |
|
| 164 | - if (is_numeric($cap_class)) { |
|
| 165 | - $cap_class = key($args); |
|
| 166 | - $args = $args[ $cap_class ]; |
|
| 167 | - } |
|
| 142 | + /** |
|
| 143 | + * account for cases where capability maps may be indexed |
|
| 144 | + * numerically to allow for the same map class to be utilized |
|
| 145 | + * In those cases, maps will be setup in an array like: |
|
| 146 | + * array( |
|
| 147 | + * 0 => array( 'EE_Meta_Capability' => array( |
|
| 148 | + * 'ee_edit_cap', array( 'Object_Name', |
|
| 149 | + * 'ee_edit_published_cap', |
|
| 150 | + * 'ee_edit_others_cap', 'ee_edit_private_cap' ) |
|
| 151 | + * ) ) |
|
| 152 | + * 1 => ... |
|
| 153 | + * ) |
|
| 154 | + * instead of: |
|
| 155 | + * array( |
|
| 156 | + * 'EE_Meta_Capability' => array( |
|
| 157 | + * 'ee_edit_cap', array( 'Object_Name', |
|
| 158 | + * 'ee_edit_published_cap', |
|
| 159 | + * 'ee_edit_others_cap', 'ee_edit_private_cap' ) |
|
| 160 | + * ), |
|
| 161 | + * ... |
|
| 162 | + * ) |
|
| 163 | + */ |
|
| 164 | + if (is_numeric($cap_class)) { |
|
| 165 | + $cap_class = key($args); |
|
| 166 | + $args = $args[ $cap_class ]; |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - if (! class_exists($cap_class)) { |
|
| 170 | - throw new EE_Error( |
|
| 171 | - sprintf( |
|
| 172 | - __( |
|
| 173 | - 'An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments', |
|
| 174 | - 'event_espresso' |
|
| 175 | - ), |
|
| 176 | - $identifier |
|
| 177 | - ) |
|
| 178 | - ); |
|
| 179 | - } |
|
| 169 | + if (! class_exists($cap_class)) { |
|
| 170 | + throw new EE_Error( |
|
| 171 | + sprintf( |
|
| 172 | + __( |
|
| 173 | + 'An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments', |
|
| 174 | + 'event_espresso' |
|
| 175 | + ), |
|
| 176 | + $identifier |
|
| 177 | + ) |
|
| 178 | + ); |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - if (count($args) !== 2) { |
|
| 182 | - throw new EE_Error( |
|
| 183 | - sprintf( |
|
| 184 | - __( |
|
| 185 | - 'An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments. The array should have two values the first being a string and the second an array.', |
|
| 186 | - 'event_espresso' |
|
| 187 | - ), |
|
| 188 | - $identifier |
|
| 189 | - ) |
|
| 190 | - ); |
|
| 191 | - } |
|
| 192 | - $cap_maps[] = new $cap_class($args[0], $args[1]); |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - return $cap_maps; |
|
| 196 | - } |
|
| 181 | + if (count($args) !== 2) { |
|
| 182 | + throw new EE_Error( |
|
| 183 | + sprintf( |
|
| 184 | + __( |
|
| 185 | + 'An addon (%s) has tried to register a capability map improperly. Capability map arrays must be indexed by capability map classname, and an array for the class arguments. The array should have two values the first being a string and the second an array.', |
|
| 186 | + 'event_espresso' |
|
| 187 | + ), |
|
| 188 | + $identifier |
|
| 189 | + ) |
|
| 190 | + ); |
|
| 191 | + } |
|
| 192 | + $cap_maps[] = new $cap_class($args[0], $args[1]); |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + return $cap_maps; |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | 198 | |
| 199 | - /** |
|
| 200 | - * @param string $identifier |
|
| 201 | - * @throws InvalidArgumentException |
|
| 202 | - * @throws InvalidDataTypeException |
|
| 203 | - * @throws InvalidInterfaceException |
|
| 204 | - */ |
|
| 205 | - public static function deregister($identifier = '') |
|
| 206 | - { |
|
| 207 | - if (! empty(self::$_registry[ $identifier ])) { |
|
| 208 | - if (! empty(self::$_registry[ $identifier ]['caps'])) { |
|
| 209 | - // if it's too early to remove capabilities, wait to do this until core is loaded and ready |
|
| 210 | - $caps_to_remove = self::$_registry[ $identifier ]['caps']; |
|
| 211 | - if (did_action('AHEE__EE_System__core_loaded_and_ready')) { |
|
| 212 | - $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
| 213 | - $capabilities->removeCaps($caps_to_remove); |
|
| 214 | - } else { |
|
| 215 | - add_action( |
|
| 216 | - 'AHEE__EE_System__core_loaded_and_ready', |
|
| 217 | - function () use ($caps_to_remove) { |
|
| 218 | - $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
| 219 | - $capabilities->removeCaps($caps_to_remove); |
|
| 220 | - } |
|
| 221 | - ); |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - unset(self::$_registry[ $identifier ]); |
|
| 226 | - } |
|
| 199 | + /** |
|
| 200 | + * @param string $identifier |
|
| 201 | + * @throws InvalidArgumentException |
|
| 202 | + * @throws InvalidDataTypeException |
|
| 203 | + * @throws InvalidInterfaceException |
|
| 204 | + */ |
|
| 205 | + public static function deregister($identifier = '') |
|
| 206 | + { |
|
| 207 | + if (! empty(self::$_registry[ $identifier ])) { |
|
| 208 | + if (! empty(self::$_registry[ $identifier ]['caps'])) { |
|
| 209 | + // if it's too early to remove capabilities, wait to do this until core is loaded and ready |
|
| 210 | + $caps_to_remove = self::$_registry[ $identifier ]['caps']; |
|
| 211 | + if (did_action('AHEE__EE_System__core_loaded_and_ready')) { |
|
| 212 | + $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
| 213 | + $capabilities->removeCaps($caps_to_remove); |
|
| 214 | + } else { |
|
| 215 | + add_action( |
|
| 216 | + 'AHEE__EE_System__core_loaded_and_ready', |
|
| 217 | + function () use ($caps_to_remove) { |
|
| 218 | + $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
| 219 | + $capabilities->removeCaps($caps_to_remove); |
|
| 220 | + } |
|
| 221 | + ); |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + unset(self::$_registry[ $identifier ]); |
|
| 226 | + } |
|
| 227 | 227 | } |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | ); |
| 66 | 66 | } |
| 67 | 67 | // make sure we don't register twice |
| 68 | - if (isset(self::$_registry[ $identifier ])) { |
|
| 68 | + if (isset(self::$_registry[$identifier])) { |
|
| 69 | 69 | return; |
| 70 | 70 | } |
| 71 | 71 | // make sure this is not registered too late or too early. |
| 72 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 72 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 73 | 73 | || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
| 74 | 74 | ) { |
| 75 | 75 | EE_Error::doing_it_wrong( |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | ); |
| 86 | 86 | } |
| 87 | 87 | // some preliminary sanitization and setting to the $_registry property |
| 88 | - self::$_registry[ $identifier ] = [ |
|
| 88 | + self::$_registry[$identifier] = [ |
|
| 89 | 89 | 'caps' => isset($setup_args['capabilities']) && is_array($setup_args['capabilities']) |
| 90 | 90 | ? $setup_args['capabilities'] |
| 91 | 91 | : [], |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | { |
| 135 | 135 | // loop through and instantiate cap maps. |
| 136 | 136 | foreach (self::$_registry as $identifier => $setup) { |
| 137 | - if (! isset($setup['cap_maps'])) { |
|
| 137 | + if ( ! isset($setup['cap_maps'])) { |
|
| 138 | 138 | continue; |
| 139 | 139 | } |
| 140 | 140 | foreach ($setup['cap_maps'] as $cap_class => $args) { |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | */ |
| 164 | 164 | if (is_numeric($cap_class)) { |
| 165 | 165 | $cap_class = key($args); |
| 166 | - $args = $args[ $cap_class ]; |
|
| 166 | + $args = $args[$cap_class]; |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if (! class_exists($cap_class)) { |
|
| 169 | + if ( ! class_exists($cap_class)) { |
|
| 170 | 170 | throw new EE_Error( |
| 171 | 171 | sprintf( |
| 172 | 172 | __( |
@@ -204,17 +204,17 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | public static function deregister($identifier = '') |
| 206 | 206 | { |
| 207 | - if (! empty(self::$_registry[ $identifier ])) { |
|
| 208 | - if (! empty(self::$_registry[ $identifier ]['caps'])) { |
|
| 207 | + if ( ! empty(self::$_registry[$identifier])) { |
|
| 208 | + if ( ! empty(self::$_registry[$identifier]['caps'])) { |
|
| 209 | 209 | // if it's too early to remove capabilities, wait to do this until core is loaded and ready |
| 210 | - $caps_to_remove = self::$_registry[ $identifier ]['caps']; |
|
| 210 | + $caps_to_remove = self::$_registry[$identifier]['caps']; |
|
| 211 | 211 | if (did_action('AHEE__EE_System__core_loaded_and_ready')) { |
| 212 | 212 | $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
| 213 | 213 | $capabilities->removeCaps($caps_to_remove); |
| 214 | 214 | } else { |
| 215 | 215 | add_action( |
| 216 | 216 | 'AHEE__EE_System__core_loaded_and_ready', |
| 217 | - function () use ($caps_to_remove) { |
|
| 217 | + function() use ($caps_to_remove) { |
|
| 218 | 218 | $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
| 219 | 219 | $capabilities->removeCaps($caps_to_remove); |
| 220 | 220 | } |
@@ -222,6 +222,6 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | } |
| 224 | 224 | } |
| 225 | - unset(self::$_registry[ $identifier ]); |
|
| 225 | + unset(self::$_registry[$identifier]); |
|
| 226 | 226 | } |
| 227 | 227 | } |
@@ -11,330 +11,330 @@ |
||
| 11 | 11 | class EE_Register_Messages_Template_Variations implements EEI_Plugin_API |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Holds values for registered variations |
|
| 16 | - * |
|
| 17 | - * @since 4.5.0 |
|
| 18 | - * |
|
| 19 | - * @var array |
|
| 20 | - */ |
|
| 21 | - protected static $_registry = []; |
|
| 14 | + /** |
|
| 15 | + * Holds values for registered variations |
|
| 16 | + * |
|
| 17 | + * @since 4.5.0 |
|
| 18 | + * |
|
| 19 | + * @var array |
|
| 20 | + */ |
|
| 21 | + protected static $_registry = []; |
|
| 22 | 22 | |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Used to register new variations |
|
| 26 | - * |
|
| 27 | - * Variations are attached to template packs and do not typically change any structural layout but merely tweak the |
|
| 28 | - * style of the layout. The most commonly known variation is css. CSS does not affect html structure just the |
|
| 29 | - * style of existing structure. |
|
| 30 | - * |
|
| 31 | - * It's important to remember that when variation files are loaded, the file structure looked for is: |
|
| 32 | - * '{$messenger}_{$messenger_variation_type}_{$variation_slug}.{$extension}'. |
|
| 33 | - * |
|
| 34 | - * - Every variation applies to specific messengers. That's why the variation file includes the messenger name |
|
| 35 | - * it. This ensures that if a template pack the variation is registered with supports multiple variations that |
|
| 36 | - * you can have the correct variation loaded. |
|
| 37 | - * - EE_messengers also implicitly define variation "types" which typically are the context in which a specific |
|
| 38 | - * variation is loaded. For instance the email messenger has: 'inline', which is the css added inline to the |
|
| 39 | - * email templates; 'preview', which is the same css only customized for when emails are previewed; and |
|
| 40 | - * 'wpeditor', which is the same css only customized so that it works with the wpeditor fields for templates to |
|
| 41 | - * give a accurate representation of the style in the wysiwyg editor. This means that for each variation, if |
|
| 42 | - * you want it to be accurately represented in various template contexts you need to have that relevant |
|
| 43 | - * variation file available. |
|
| 44 | - * - $variation_slug is simply the variation slug for that variation. |
|
| 45 | - * - $extension = whatever the extension is for the variation used for the messenger calling it. In MOST cases |
|
| 46 | - * messenger variations are .css files. Note: if your file names are not formatted correctly then they will NOT |
|
| 47 | - * be loaded. The EE messages template pack system will fallback to corresponding default template pack for the |
|
| 48 | - * given messenger or as a last resort (i.e. no default variation for the given messenger) will not load any |
|
| 49 | - * variation (so the template pack would be unstyled) |
|
| 50 | - * |
|
| 51 | - * @see /core/libraries/messages/defaults/default/variations/* for example variation files for the email and html |
|
| 52 | - * messengers. |
|
| 53 | - * |
|
| 54 | - * @param string $identifier unique reference used to describe this variation registry. If |
|
| 55 | - * this ISN'T unique then this method will make it unique (and it |
|
| 56 | - * becomes harder to deregister). |
|
| 57 | - * @param array $setup_args { |
|
| 58 | - * an array of required values for registering the variations. |
|
| 59 | - * @type array $variations { |
|
| 60 | - * An array indexed by template_pack->dbref. and values are an array |
|
| 61 | - * indexed by messenger name and values are an array indexed by |
|
| 62 | - * message_type and values are an array indexed by variation_slug |
|
| 63 | - * and value is the localized label for the variation. Note this |
|
| 64 | - * api reserves the "default" variation name for the default |
|
| 65 | - * template pack so you can't register a default variation. Also, |
|
| 66 | - * try to use unique variation slugs to reference your variations |
|
| 67 | - * because this api checks if any existing variations are in place |
|
| 68 | - * with that name. If there are then subsequent variations for that |
|
| 69 | - * template pack with that same name will fail to register with a |
|
| 70 | - * persistent notice put up for the user. Required. |
|
| 71 | - * 'default' => array( |
|
| 72 | - * 'email' => array( |
|
| 73 | - * 'registration_approved' => array( |
|
| 74 | - * my_ee_addon_blue_lagoon' => __('Blue Lagoon', |
|
| 75 | - * 'text_domain'), |
|
| 76 | - * 'my_ee_addon_red_sunset' => __('Red Sunset', |
|
| 77 | - * 'text_domain') |
|
| 78 | - * ) |
|
| 79 | - * ) |
|
| 80 | - * ) |
|
| 81 | - * } |
|
| 82 | - * @type string $base_path The base path for where all your variations are found. Although |
|
| 83 | - * the full path to your variation files should include |
|
| 84 | - * '/variations/' in it, do not include the |
|
| 85 | - * 'variations/' in this. Required. |
|
| 86 | - * @type string $base_url The base url for where all your variations are found. See note |
|
| 87 | - * above about the 'variations/' string. Required. |
|
| 88 | - * } |
|
| 89 | - * } |
|
| 90 | - * |
|
| 91 | - * @throws EE_Error |
|
| 92 | - * @return void |
|
| 93 | - */ |
|
| 94 | - public static function register($identifier = '', array $setup_args = []) |
|
| 95 | - { |
|
| 24 | + /** |
|
| 25 | + * Used to register new variations |
|
| 26 | + * |
|
| 27 | + * Variations are attached to template packs and do not typically change any structural layout but merely tweak the |
|
| 28 | + * style of the layout. The most commonly known variation is css. CSS does not affect html structure just the |
|
| 29 | + * style of existing structure. |
|
| 30 | + * |
|
| 31 | + * It's important to remember that when variation files are loaded, the file structure looked for is: |
|
| 32 | + * '{$messenger}_{$messenger_variation_type}_{$variation_slug}.{$extension}'. |
|
| 33 | + * |
|
| 34 | + * - Every variation applies to specific messengers. That's why the variation file includes the messenger name |
|
| 35 | + * it. This ensures that if a template pack the variation is registered with supports multiple variations that |
|
| 36 | + * you can have the correct variation loaded. |
|
| 37 | + * - EE_messengers also implicitly define variation "types" which typically are the context in which a specific |
|
| 38 | + * variation is loaded. For instance the email messenger has: 'inline', which is the css added inline to the |
|
| 39 | + * email templates; 'preview', which is the same css only customized for when emails are previewed; and |
|
| 40 | + * 'wpeditor', which is the same css only customized so that it works with the wpeditor fields for templates to |
|
| 41 | + * give a accurate representation of the style in the wysiwyg editor. This means that for each variation, if |
|
| 42 | + * you want it to be accurately represented in various template contexts you need to have that relevant |
|
| 43 | + * variation file available. |
|
| 44 | + * - $variation_slug is simply the variation slug for that variation. |
|
| 45 | + * - $extension = whatever the extension is for the variation used for the messenger calling it. In MOST cases |
|
| 46 | + * messenger variations are .css files. Note: if your file names are not formatted correctly then they will NOT |
|
| 47 | + * be loaded. The EE messages template pack system will fallback to corresponding default template pack for the |
|
| 48 | + * given messenger or as a last resort (i.e. no default variation for the given messenger) will not load any |
|
| 49 | + * variation (so the template pack would be unstyled) |
|
| 50 | + * |
|
| 51 | + * @see /core/libraries/messages/defaults/default/variations/* for example variation files for the email and html |
|
| 52 | + * messengers. |
|
| 53 | + * |
|
| 54 | + * @param string $identifier unique reference used to describe this variation registry. If |
|
| 55 | + * this ISN'T unique then this method will make it unique (and it |
|
| 56 | + * becomes harder to deregister). |
|
| 57 | + * @param array $setup_args { |
|
| 58 | + * an array of required values for registering the variations. |
|
| 59 | + * @type array $variations { |
|
| 60 | + * An array indexed by template_pack->dbref. and values are an array |
|
| 61 | + * indexed by messenger name and values are an array indexed by |
|
| 62 | + * message_type and values are an array indexed by variation_slug |
|
| 63 | + * and value is the localized label for the variation. Note this |
|
| 64 | + * api reserves the "default" variation name for the default |
|
| 65 | + * template pack so you can't register a default variation. Also, |
|
| 66 | + * try to use unique variation slugs to reference your variations |
|
| 67 | + * because this api checks if any existing variations are in place |
|
| 68 | + * with that name. If there are then subsequent variations for that |
|
| 69 | + * template pack with that same name will fail to register with a |
|
| 70 | + * persistent notice put up for the user. Required. |
|
| 71 | + * 'default' => array( |
|
| 72 | + * 'email' => array( |
|
| 73 | + * 'registration_approved' => array( |
|
| 74 | + * my_ee_addon_blue_lagoon' => __('Blue Lagoon', |
|
| 75 | + * 'text_domain'), |
|
| 76 | + * 'my_ee_addon_red_sunset' => __('Red Sunset', |
|
| 77 | + * 'text_domain') |
|
| 78 | + * ) |
|
| 79 | + * ) |
|
| 80 | + * ) |
|
| 81 | + * } |
|
| 82 | + * @type string $base_path The base path for where all your variations are found. Although |
|
| 83 | + * the full path to your variation files should include |
|
| 84 | + * '/variations/' in it, do not include the |
|
| 85 | + * 'variations/' in this. Required. |
|
| 86 | + * @type string $base_url The base url for where all your variations are found. See note |
|
| 87 | + * above about the 'variations/' string. Required. |
|
| 88 | + * } |
|
| 89 | + * } |
|
| 90 | + * |
|
| 91 | + * @throws EE_Error |
|
| 92 | + * @return void |
|
| 93 | + */ |
|
| 94 | + public static function register($identifier = '', array $setup_args = []) |
|
| 95 | + { |
|
| 96 | 96 | |
| 97 | - // check for required params |
|
| 98 | - if (empty($identifier)) { |
|
| 99 | - throw new EE_Error( |
|
| 100 | - __( |
|
| 101 | - 'In order to register variations for a EE_Message_Template_Pack, you must include a value to reference the variations being registered', |
|
| 102 | - 'event_espresso' |
|
| 103 | - ) |
|
| 104 | - ); |
|
| 105 | - } |
|
| 97 | + // check for required params |
|
| 98 | + if (empty($identifier)) { |
|
| 99 | + throw new EE_Error( |
|
| 100 | + __( |
|
| 101 | + 'In order to register variations for a EE_Message_Template_Pack, you must include a value to reference the variations being registered', |
|
| 102 | + 'event_espresso' |
|
| 103 | + ) |
|
| 104 | + ); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - if (! is_array($setup_args) |
|
| 108 | - || empty($setup_args['variations']) |
|
| 109 | - || empty($setup_args['base_path']) |
|
| 110 | - || empty($setup_args['base_url']) |
|
| 111 | - ) { |
|
| 112 | - throw new EE_Error( |
|
| 113 | - __( |
|
| 114 | - 'In order to register variations for a EE_Message_Template_Pack, you must include an array containing the following keys: "variations", "base_path", "base_url", "extension"', |
|
| 115 | - 'event_espresso' |
|
| 116 | - ) |
|
| 117 | - ); |
|
| 118 | - } |
|
| 107 | + if (! is_array($setup_args) |
|
| 108 | + || empty($setup_args['variations']) |
|
| 109 | + || empty($setup_args['base_path']) |
|
| 110 | + || empty($setup_args['base_url']) |
|
| 111 | + ) { |
|
| 112 | + throw new EE_Error( |
|
| 113 | + __( |
|
| 114 | + 'In order to register variations for a EE_Message_Template_Pack, you must include an array containing the following keys: "variations", "base_path", "base_url", "extension"', |
|
| 115 | + 'event_espresso' |
|
| 116 | + ) |
|
| 117 | + ); |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - // make sure we don't register twice |
|
| 121 | - if (isset(self::$_registry[ $identifier ])) { |
|
| 122 | - return; |
|
| 123 | - } |
|
| 120 | + // make sure we don't register twice |
|
| 121 | + if (isset(self::$_registry[ $identifier ])) { |
|
| 122 | + return; |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | - // make sure variation ref is unique. |
|
| 126 | - if (isset(self::$_registry[ $identifier ])) { |
|
| 127 | - $identifier = uniqid() . '_' . $identifier; |
|
| 128 | - } |
|
| 125 | + // make sure variation ref is unique. |
|
| 126 | + if (isset(self::$_registry[ $identifier ])) { |
|
| 127 | + $identifier = uniqid() . '_' . $identifier; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | 130 | |
| 131 | - // make sure this was called in the right place! |
|
| 132 | - if (! did_action('EE_Brewing_Regular___messages_caf') |
|
| 133 | - || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
| 134 | - ) { |
|
| 135 | - EE_Error::doing_it_wrong( |
|
| 136 | - __METHOD__, |
|
| 137 | - sprintf( |
|
| 138 | - __( |
|
| 139 | - 'Messages Templates Variations given the reference "%s" has been attempted to be registered with the EE Messages Template Pack System. It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.', |
|
| 140 | - 'event_espresso' |
|
| 141 | - ), |
|
| 142 | - $identifier |
|
| 143 | - ), |
|
| 144 | - '4.5.0' |
|
| 145 | - ); |
|
| 146 | - } |
|
| 131 | + // make sure this was called in the right place! |
|
| 132 | + if (! did_action('EE_Brewing_Regular___messages_caf') |
|
| 133 | + || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
| 134 | + ) { |
|
| 135 | + EE_Error::doing_it_wrong( |
|
| 136 | + __METHOD__, |
|
| 137 | + sprintf( |
|
| 138 | + __( |
|
| 139 | + 'Messages Templates Variations given the reference "%s" has been attempted to be registered with the EE Messages Template Pack System. It may or may not work because it should be only called on the "EE_Brewing_Regular__messages_caf" hook.', |
|
| 140 | + 'event_espresso' |
|
| 141 | + ), |
|
| 142 | + $identifier |
|
| 143 | + ), |
|
| 144 | + '4.5.0' |
|
| 145 | + ); |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - // validate/sanitize incoming args. |
|
| 149 | - $validated = [ |
|
| 150 | - 'variations' => (array) $setup_args['variations'], |
|
| 151 | - 'base_path' => (string) $setup_args['base_path'], |
|
| 152 | - 'base_url' => (string) $setup_args['base_url'], |
|
| 153 | - ]; |
|
| 148 | + // validate/sanitize incoming args. |
|
| 149 | + $validated = [ |
|
| 150 | + 'variations' => (array) $setup_args['variations'], |
|
| 151 | + 'base_path' => (string) $setup_args['base_path'], |
|
| 152 | + 'base_url' => (string) $setup_args['base_url'], |
|
| 153 | + ]; |
|
| 154 | 154 | |
| 155 | 155 | |
| 156 | - // check that no reserved variation names are in use and also checks if there are already existing variation names for a given template pack. The former will throw an error. The latter will remove the conflicting variation name but still register the others and will add EE_Error notice. |
|
| 157 | - $validated = self::_verify_variations($identifier, $validated); |
|
| 158 | - self::$_registry[ $identifier ] = $validated; |
|
| 156 | + // check that no reserved variation names are in use and also checks if there are already existing variation names for a given template pack. The former will throw an error. The latter will remove the conflicting variation name but still register the others and will add EE_Error notice. |
|
| 157 | + $validated = self::_verify_variations($identifier, $validated); |
|
| 158 | + self::$_registry[ $identifier ] = $validated; |
|
| 159 | 159 | |
| 160 | - add_filter( |
|
| 161 | - 'FHEE__EE_Messages_Template_Pack__get_variations', |
|
| 162 | - ['EE_Register_Messages_Template_Variations', 'get_variations'], |
|
| 163 | - 10, |
|
| 164 | - 4 |
|
| 165 | - ); |
|
| 166 | - add_filter( |
|
| 167 | - 'FHEE__EE_Messages_Template_Pack__get_variation', |
|
| 168 | - ['EE_Register_Messages_Template_Variations', 'get_variation'], |
|
| 169 | - 10, |
|
| 170 | - 8 |
|
| 171 | - ); |
|
| 172 | - } |
|
| 160 | + add_filter( |
|
| 161 | + 'FHEE__EE_Messages_Template_Pack__get_variations', |
|
| 162 | + ['EE_Register_Messages_Template_Variations', 'get_variations'], |
|
| 163 | + 10, |
|
| 164 | + 4 |
|
| 165 | + ); |
|
| 166 | + add_filter( |
|
| 167 | + 'FHEE__EE_Messages_Template_Pack__get_variation', |
|
| 168 | + ['EE_Register_Messages_Template_Variations', 'get_variation'], |
|
| 169 | + 10, |
|
| 170 | + 8 |
|
| 171 | + ); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * Cycles through the variations registered and makes sure there are no reserved variations being registered which |
|
| 177 | - * throws an error. Also checks if there is already a |
|
| 178 | - * |
|
| 179 | - * @param string $identifier the reference for the variations being registered |
|
| 180 | - * @param array $validated_variations The variations setup array that's being registered (and verified). |
|
| 181 | - * @return array |
|
| 182 | - * @throws EE_Error |
|
| 183 | - * @since 4.5.0 |
|
| 184 | - * |
|
| 185 | - */ |
|
| 186 | - private static function _verify_variations($identifier, array $validated_variations) |
|
| 187 | - { |
|
| 188 | - foreach (self::$_registry as $settings) { |
|
| 189 | - foreach ($settings['variations'] as $messenger) { |
|
| 190 | - foreach ($messenger as $all_variations) { |
|
| 191 | - if (isset($all_variations['default'])) { |
|
| 192 | - throw new EE_Error( |
|
| 193 | - sprintf( |
|
| 194 | - __( |
|
| 195 | - 'Variations registered through the EE_Register_Messages_Template_Variations api cannot override the default variation for the default template. Please check the code registering variations with this reference, "%s" and modify.', |
|
| 196 | - 'event_espresso' |
|
| 197 | - ), |
|
| 198 | - $identifier |
|
| 199 | - ) |
|
| 200 | - ); |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - } |
|
| 204 | - } |
|
| 175 | + /** |
|
| 176 | + * Cycles through the variations registered and makes sure there are no reserved variations being registered which |
|
| 177 | + * throws an error. Also checks if there is already a |
|
| 178 | + * |
|
| 179 | + * @param string $identifier the reference for the variations being registered |
|
| 180 | + * @param array $validated_variations The variations setup array that's being registered (and verified). |
|
| 181 | + * @return array |
|
| 182 | + * @throws EE_Error |
|
| 183 | + * @since 4.5.0 |
|
| 184 | + * |
|
| 185 | + */ |
|
| 186 | + private static function _verify_variations($identifier, array $validated_variations) |
|
| 187 | + { |
|
| 188 | + foreach (self::$_registry as $settings) { |
|
| 189 | + foreach ($settings['variations'] as $messenger) { |
|
| 190 | + foreach ($messenger as $all_variations) { |
|
| 191 | + if (isset($all_variations['default'])) { |
|
| 192 | + throw new EE_Error( |
|
| 193 | + sprintf( |
|
| 194 | + __( |
|
| 195 | + 'Variations registered through the EE_Register_Messages_Template_Variations api cannot override the default variation for the default template. Please check the code registering variations with this reference, "%s" and modify.', |
|
| 196 | + 'event_espresso' |
|
| 197 | + ), |
|
| 198 | + $identifier |
|
| 199 | + ) |
|
| 200 | + ); |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - // is there already a variation registered with a given variation slug? |
|
| 207 | - foreach ($validated_variations['variations'] as $template_pack => $messenger) { |
|
| 208 | - foreach ($messenger as $message_type => $variations) { |
|
| 209 | - foreach ($variations as $slug => $label) { |
|
| 210 | - foreach (self::$_registry as $registered_var => $reg_settings) { |
|
| 211 | - if (isset($reg_settings['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ])) { |
|
| 212 | - unset($validated_variations['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ]); |
|
| 213 | - EE_Error::add_error( |
|
| 214 | - sprintf( |
|
| 215 | - __( |
|
| 216 | - 'Unable to register the %s variation for the %s template pack with the %s messenger and %s message_type because a variation with this slug was already registered for this template pack and messenger and message type by an addon using this key %s.', |
|
| 217 | - 'event_espresso' |
|
| 218 | - ), |
|
| 219 | - $label, |
|
| 220 | - $template_pack, |
|
| 221 | - $messenger, |
|
| 222 | - $message_type, |
|
| 223 | - $registered_var |
|
| 224 | - ) |
|
| 225 | - ); |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - return $validated_variations; |
|
| 232 | - } |
|
| 206 | + // is there already a variation registered with a given variation slug? |
|
| 207 | + foreach ($validated_variations['variations'] as $template_pack => $messenger) { |
|
| 208 | + foreach ($messenger as $message_type => $variations) { |
|
| 209 | + foreach ($variations as $slug => $label) { |
|
| 210 | + foreach (self::$_registry as $registered_var => $reg_settings) { |
|
| 211 | + if (isset($reg_settings['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ])) { |
|
| 212 | + unset($validated_variations['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ]); |
|
| 213 | + EE_Error::add_error( |
|
| 214 | + sprintf( |
|
| 215 | + __( |
|
| 216 | + 'Unable to register the %s variation for the %s template pack with the %s messenger and %s message_type because a variation with this slug was already registered for this template pack and messenger and message type by an addon using this key %s.', |
|
| 217 | + 'event_espresso' |
|
| 218 | + ), |
|
| 219 | + $label, |
|
| 220 | + $template_pack, |
|
| 221 | + $messenger, |
|
| 222 | + $message_type, |
|
| 223 | + $registered_var |
|
| 224 | + ) |
|
| 225 | + ); |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + return $validated_variations; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | |
| 235 | - /** |
|
| 236 | - * Callback for the FHEE__EE_Messages_Template_Pack__get_variation filter to ensure registered variations are used. |
|
| 237 | - * |
|
| 238 | - * @param string $variation_path The path generated for the current variation |
|
| 239 | - * @param string $messenger The messenger the variation is for |
|
| 240 | - * @param string $message_type EE_message_type->name |
|
| 241 | - * @param string $type The type of variation being requested |
|
| 242 | - * @param string $variation The slug for the variation being requested |
|
| 243 | - * @param string $file_extension What the file extension is for the variation |
|
| 244 | - * @param bool $url Whether url or path is being returned. |
|
| 245 | - * @param EE_Messages_Template_Pack $template_pack |
|
| 246 | - * |
|
| 247 | - * @return string The path to the requested variation. |
|
| 248 | - * @since 4.5.0 |
|
| 249 | - * |
|
| 250 | - */ |
|
| 251 | - public static function get_variation( |
|
| 252 | - $variation_path, |
|
| 253 | - $messenger, |
|
| 254 | - $message_type, |
|
| 255 | - $type, |
|
| 256 | - $variation, |
|
| 257 | - $file_extension, |
|
| 258 | - $url, |
|
| 259 | - EE_Messages_Template_Pack $template_pack |
|
| 260 | - ) { |
|
| 261 | - // so let's loop through our registered variations and then pull any details matching the request. |
|
| 262 | - foreach (self::$_registry as $registry_settings) { |
|
| 263 | - $base = $url ? $registry_settings['base_url'] : $registry_settings['base_path']; |
|
| 264 | - $file_string = $messenger . '_' . $type . '_' . $variation . $file_extension; |
|
| 265 | - // see if this file exists |
|
| 266 | - if (is_readable($registry_settings['base_path'] . $file_string)) { |
|
| 267 | - return $base . $file_string; |
|
| 268 | - } |
|
| 269 | - } |
|
| 235 | + /** |
|
| 236 | + * Callback for the FHEE__EE_Messages_Template_Pack__get_variation filter to ensure registered variations are used. |
|
| 237 | + * |
|
| 238 | + * @param string $variation_path The path generated for the current variation |
|
| 239 | + * @param string $messenger The messenger the variation is for |
|
| 240 | + * @param string $message_type EE_message_type->name |
|
| 241 | + * @param string $type The type of variation being requested |
|
| 242 | + * @param string $variation The slug for the variation being requested |
|
| 243 | + * @param string $file_extension What the file extension is for the variation |
|
| 244 | + * @param bool $url Whether url or path is being returned. |
|
| 245 | + * @param EE_Messages_Template_Pack $template_pack |
|
| 246 | + * |
|
| 247 | + * @return string The path to the requested variation. |
|
| 248 | + * @since 4.5.0 |
|
| 249 | + * |
|
| 250 | + */ |
|
| 251 | + public static function get_variation( |
|
| 252 | + $variation_path, |
|
| 253 | + $messenger, |
|
| 254 | + $message_type, |
|
| 255 | + $type, |
|
| 256 | + $variation, |
|
| 257 | + $file_extension, |
|
| 258 | + $url, |
|
| 259 | + EE_Messages_Template_Pack $template_pack |
|
| 260 | + ) { |
|
| 261 | + // so let's loop through our registered variations and then pull any details matching the request. |
|
| 262 | + foreach (self::$_registry as $registry_settings) { |
|
| 263 | + $base = $url ? $registry_settings['base_url'] : $registry_settings['base_path']; |
|
| 264 | + $file_string = $messenger . '_' . $type . '_' . $variation . $file_extension; |
|
| 265 | + // see if this file exists |
|
| 266 | + if (is_readable($registry_settings['base_path'] . $file_string)) { |
|
| 267 | + return $base . $file_string; |
|
| 268 | + } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - // no match |
|
| 272 | - return $variation_path; |
|
| 273 | - } |
|
| 271 | + // no match |
|
| 272 | + return $variation_path; |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | 275 | |
| 276 | - /** |
|
| 277 | - * callback for the FHEE__EE_Messages_Template_Pack__get_variations filter. |
|
| 278 | - * |
|
| 279 | - * |
|
| 280 | - * @param array $variations The original contents for the template pack variations property. |
|
| 281 | - * @param string $messenger The messenger requesting the variations. |
|
| 282 | - * @param string $message_type |
|
| 283 | - * @param EE_Messages_Template_Pack $template_pack |
|
| 284 | - * |
|
| 285 | - * @return array new variations array (or existing one if nothing registered) |
|
| 286 | - * @since 4.5.0 |
|
| 287 | - * |
|
| 288 | - * @see $_variation property definition in EE_Messages_Template_Pack |
|
| 289 | - */ |
|
| 290 | - public static function get_variations( |
|
| 291 | - array $variations, |
|
| 292 | - $messenger, |
|
| 293 | - $message_type, |
|
| 294 | - EE_Messages_Template_Pack $template_pack |
|
| 295 | - ) { |
|
| 296 | - // first let's check if we even have registered variations and get out early. |
|
| 297 | - if (empty(self::$_registry)) { |
|
| 298 | - return $variations; |
|
| 299 | - } |
|
| 276 | + /** |
|
| 277 | + * callback for the FHEE__EE_Messages_Template_Pack__get_variations filter. |
|
| 278 | + * |
|
| 279 | + * |
|
| 280 | + * @param array $variations The original contents for the template pack variations property. |
|
| 281 | + * @param string $messenger The messenger requesting the variations. |
|
| 282 | + * @param string $message_type |
|
| 283 | + * @param EE_Messages_Template_Pack $template_pack |
|
| 284 | + * |
|
| 285 | + * @return array new variations array (or existing one if nothing registered) |
|
| 286 | + * @since 4.5.0 |
|
| 287 | + * |
|
| 288 | + * @see $_variation property definition in EE_Messages_Template_Pack |
|
| 289 | + */ |
|
| 290 | + public static function get_variations( |
|
| 291 | + array $variations, |
|
| 292 | + $messenger, |
|
| 293 | + $message_type, |
|
| 294 | + EE_Messages_Template_Pack $template_pack |
|
| 295 | + ) { |
|
| 296 | + // first let's check if we even have registered variations and get out early. |
|
| 297 | + if (empty(self::$_registry)) { |
|
| 298 | + return $variations; |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - // do we have any new variations for the given messenger, $message_type, and template packs |
|
| 302 | - foreach (self::$_registry as $registry_settings) { |
|
| 303 | - // allow for different conditions. |
|
| 304 | - if (empty($messenger)) { |
|
| 305 | - return array_merge($registry_settings['variations'], $variations); |
|
| 306 | - } |
|
| 307 | - if (empty($message_type)) { |
|
| 308 | - if (! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ])) { |
|
| 309 | - return array_merge( |
|
| 310 | - $registry_settings['variations'][ $template_pack->dbref ][ $messenger ], |
|
| 311 | - $variations |
|
| 312 | - ); |
|
| 313 | - } |
|
| 314 | - } else { |
|
| 315 | - if (! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ])) { |
|
| 316 | - return array_merge( |
|
| 317 | - $registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ], |
|
| 318 | - $variations |
|
| 319 | - ); |
|
| 320 | - } |
|
| 321 | - } |
|
| 322 | - } |
|
| 323 | - return $variations; |
|
| 324 | - } |
|
| 301 | + // do we have any new variations for the given messenger, $message_type, and template packs |
|
| 302 | + foreach (self::$_registry as $registry_settings) { |
|
| 303 | + // allow for different conditions. |
|
| 304 | + if (empty($messenger)) { |
|
| 305 | + return array_merge($registry_settings['variations'], $variations); |
|
| 306 | + } |
|
| 307 | + if (empty($message_type)) { |
|
| 308 | + if (! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ])) { |
|
| 309 | + return array_merge( |
|
| 310 | + $registry_settings['variations'][ $template_pack->dbref ][ $messenger ], |
|
| 311 | + $variations |
|
| 312 | + ); |
|
| 313 | + } |
|
| 314 | + } else { |
|
| 315 | + if (! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ])) { |
|
| 316 | + return array_merge( |
|
| 317 | + $registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ], |
|
| 318 | + $variations |
|
| 319 | + ); |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | + return $variations; |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | 326 | |
| 327 | - /** |
|
| 328 | - * This deregisters a variation set that was previously registered with the given slug. |
|
| 329 | - * |
|
| 330 | - * @param string $identifier The name for the variation set that was previously registered. |
|
| 331 | - * |
|
| 332 | - * @return void |
|
| 333 | - * @since 4.5.0 |
|
| 334 | - * |
|
| 335 | - */ |
|
| 336 | - public static function deregister($identifier = '') |
|
| 337 | - { |
|
| 338 | - unset(self::$_registry[ $identifier ]); |
|
| 339 | - } |
|
| 327 | + /** |
|
| 328 | + * This deregisters a variation set that was previously registered with the given slug. |
|
| 329 | + * |
|
| 330 | + * @param string $identifier The name for the variation set that was previously registered. |
|
| 331 | + * |
|
| 332 | + * @return void |
|
| 333 | + * @since 4.5.0 |
|
| 334 | + * |
|
| 335 | + */ |
|
| 336 | + public static function deregister($identifier = '') |
|
| 337 | + { |
|
| 338 | + unset(self::$_registry[ $identifier ]); |
|
| 339 | + } |
|
| 340 | 340 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | ); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if (! is_array($setup_args) |
|
| 107 | + if ( ! is_array($setup_args) |
|
| 108 | 108 | || empty($setup_args['variations']) |
| 109 | 109 | || empty($setup_args['base_path']) |
| 110 | 110 | || empty($setup_args['base_url']) |
@@ -118,18 +118,18 @@ discard block |
||
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | // make sure we don't register twice |
| 121 | - if (isset(self::$_registry[ $identifier ])) { |
|
| 121 | + if (isset(self::$_registry[$identifier])) { |
|
| 122 | 122 | return; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | // make sure variation ref is unique. |
| 126 | - if (isset(self::$_registry[ $identifier ])) { |
|
| 127 | - $identifier = uniqid() . '_' . $identifier; |
|
| 126 | + if (isset(self::$_registry[$identifier])) { |
|
| 127 | + $identifier = uniqid().'_'.$identifier; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | |
| 131 | 131 | // make sure this was called in the right place! |
| 132 | - if (! did_action('EE_Brewing_Regular___messages_caf') |
|
| 132 | + if ( ! did_action('EE_Brewing_Regular___messages_caf') |
|
| 133 | 133 | || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
| 134 | 134 | ) { |
| 135 | 135 | EE_Error::doing_it_wrong( |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | // check that no reserved variation names are in use and also checks if there are already existing variation names for a given template pack. The former will throw an error. The latter will remove the conflicting variation name but still register the others and will add EE_Error notice. |
| 157 | 157 | $validated = self::_verify_variations($identifier, $validated); |
| 158 | - self::$_registry[ $identifier ] = $validated; |
|
| 158 | + self::$_registry[$identifier] = $validated; |
|
| 159 | 159 | |
| 160 | 160 | add_filter( |
| 161 | 161 | 'FHEE__EE_Messages_Template_Pack__get_variations', |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | foreach ($messenger as $message_type => $variations) { |
| 209 | 209 | foreach ($variations as $slug => $label) { |
| 210 | 210 | foreach (self::$_registry as $registered_var => $reg_settings) { |
| 211 | - if (isset($reg_settings['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ])) { |
|
| 212 | - unset($validated_variations['variations'][ $template_pack ][ $messenger ][ $message_type ][ $slug ]); |
|
| 211 | + if (isset($reg_settings['variations'][$template_pack][$messenger][$message_type][$slug])) { |
|
| 212 | + unset($validated_variations['variations'][$template_pack][$messenger][$message_type][$slug]); |
|
| 213 | 213 | EE_Error::add_error( |
| 214 | 214 | sprintf( |
| 215 | 215 | __( |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | // so let's loop through our registered variations and then pull any details matching the request. |
| 262 | 262 | foreach (self::$_registry as $registry_settings) { |
| 263 | 263 | $base = $url ? $registry_settings['base_url'] : $registry_settings['base_path']; |
| 264 | - $file_string = $messenger . '_' . $type . '_' . $variation . $file_extension; |
|
| 264 | + $file_string = $messenger.'_'.$type.'_'.$variation.$file_extension; |
|
| 265 | 265 | // see if this file exists |
| 266 | - if (is_readable($registry_settings['base_path'] . $file_string)) { |
|
| 267 | - return $base . $file_string; |
|
| 266 | + if (is_readable($registry_settings['base_path'].$file_string)) { |
|
| 267 | + return $base.$file_string; |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
@@ -305,16 +305,16 @@ discard block |
||
| 305 | 305 | return array_merge($registry_settings['variations'], $variations); |
| 306 | 306 | } |
| 307 | 307 | if (empty($message_type)) { |
| 308 | - if (! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ])) { |
|
| 308 | + if ( ! empty($registry_settings['variations'][$template_pack->dbref][$messenger])) { |
|
| 309 | 309 | return array_merge( |
| 310 | - $registry_settings['variations'][ $template_pack->dbref ][ $messenger ], |
|
| 310 | + $registry_settings['variations'][$template_pack->dbref][$messenger], |
|
| 311 | 311 | $variations |
| 312 | 312 | ); |
| 313 | 313 | } |
| 314 | 314 | } else { |
| 315 | - if (! empty($registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ])) { |
|
| 315 | + if ( ! empty($registry_settings['variations'][$template_pack->dbref][$messenger][$message_type])) { |
|
| 316 | 316 | return array_merge( |
| 317 | - $registry_settings['variations'][ $template_pack->dbref ][ $messenger ][ $message_type ], |
|
| 317 | + $registry_settings['variations'][$template_pack->dbref][$messenger][$message_type], |
|
| 318 | 318 | $variations |
| 319 | 319 | ); |
| 320 | 320 | } |
@@ -335,6 +335,6 @@ discard block |
||
| 335 | 335 | */ |
| 336 | 336 | public static function deregister($identifier = '') |
| 337 | 337 | { |
| 338 | - unset(self::$_registry[ $identifier ]); |
|
| 338 | + unset(self::$_registry[$identifier]); |
|
| 339 | 339 | } |
| 340 | 340 | } |
@@ -13,55 +13,55 @@ |
||
| 13 | 13 | class EE_Register_Privacy_Policy implements EEI_Plugin_API |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * FQCN for all privacy policy generators |
|
| 18 | - * |
|
| 19 | - * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
| 20 | - */ |
|
| 21 | - protected static $privacy_policies = array(); |
|
| 16 | + /** |
|
| 17 | + * FQCN for all privacy policy generators |
|
| 18 | + * |
|
| 19 | + * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
| 20 | + */ |
|
| 21 | + protected static $privacy_policies = array(); |
|
| 22 | 22 | |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @param string $identifier |
|
| 26 | - * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies, |
|
| 27 | - * OR fully qualified class names of privacy policies |
|
| 28 | - */ |
|
| 29 | - public static function register($identifier = '', array $setup_args = []) |
|
| 30 | - { |
|
| 31 | - self::$privacy_policies[ $identifier ] = $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 | - array('EE_Register_Privacy_Policy', 'addPrivacyPolicies') |
|
| 36 | - ); |
|
| 37 | - } |
|
| 24 | + /** |
|
| 25 | + * @param string $identifier |
|
| 26 | + * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies, |
|
| 27 | + * OR fully qualified class names of privacy policies |
|
| 28 | + */ |
|
| 29 | + public static function register($identifier = '', array $setup_args = []) |
|
| 30 | + { |
|
| 31 | + self::$privacy_policies[ $identifier ] = $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 | + array('EE_Register_Privacy_Policy', 'addPrivacyPolicies') |
|
| 36 | + ); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @param string $identifier |
|
| 42 | - */ |
|
| 43 | - public static function deregister($identifier = '') |
|
| 44 | - { |
|
| 45 | - unset(self::$privacy_policies[ $identifier ]); |
|
| 46 | - } |
|
| 40 | + /** |
|
| 41 | + * @param string $identifier |
|
| 42 | + */ |
|
| 43 | + public static function deregister($identifier = '') |
|
| 44 | + { |
|
| 45 | + unset(self::$privacy_policies[ $identifier ]); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * Adds our privacy policy generators registered by add-ons |
|
| 51 | - * |
|
| 52 | - * @param string[] $privacy_policies |
|
| 53 | - * @return string[] |
|
| 54 | - */ |
|
| 55 | - public static function addPrivacyPolicies(array $privacy_policies) |
|
| 56 | - { |
|
| 57 | - foreach (self::$privacy_policies as $privacy_policies_per_addon) { |
|
| 58 | - $privacy_policies = array_merge( |
|
| 59 | - $privacy_policies, |
|
| 60 | - $privacy_policies_per_addon |
|
| 61 | - ); |
|
| 62 | - } |
|
| 63 | - return $privacy_policies; |
|
| 64 | - } |
|
| 49 | + /** |
|
| 50 | + * Adds our privacy policy generators registered by add-ons |
|
| 51 | + * |
|
| 52 | + * @param string[] $privacy_policies |
|
| 53 | + * @return string[] |
|
| 54 | + */ |
|
| 55 | + public static function addPrivacyPolicies(array $privacy_policies) |
|
| 56 | + { |
|
| 57 | + foreach (self::$privacy_policies as $privacy_policies_per_addon) { |
|
| 58 | + $privacy_policies = array_merge( |
|
| 59 | + $privacy_policies, |
|
| 60 | + $privacy_policies_per_addon |
|
| 61 | + ); |
|
| 62 | + } |
|
| 63 | + return $privacy_policies; |
|
| 64 | + } |
|
| 65 | 65 | } |
| 66 | 66 | // End of file EE_Register_Privacy_Policy.lib.php |
| 67 | 67 | // Location: ${NAMESPACE}/EE_Register_Privacy_Policy.lib.php |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | public static function register($identifier = '', array $setup_args = []) |
| 30 | 30 | { |
| 31 | - self::$privacy_policies[ $identifier ] = $setup_args; |
|
| 31 | + self::$privacy_policies[$identifier] = $setup_args; |
|
| 32 | 32 | // add to list of modules to be registered |
| 33 | 33 | add_filter( |
| 34 | 34 | 'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public static function deregister($identifier = '') |
| 44 | 44 | { |
| 45 | - unset(self::$privacy_policies[ $identifier ]); |
|
| 45 | + unset(self::$privacy_policies[$identifier]); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | |
@@ -19,162 +19,162 @@ |
||
| 19 | 19 | class EE_Register_Payment_Method implements EEI_Plugin_API |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * Holds values for registered payment methods |
|
| 24 | - * |
|
| 25 | - * @var array |
|
| 26 | - */ |
|
| 27 | - protected static $_settings = []; |
|
| 22 | + /** |
|
| 23 | + * Holds values for registered payment methods |
|
| 24 | + * |
|
| 25 | + * @var array |
|
| 26 | + */ |
|
| 27 | + protected static $_settings = []; |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Method for registering new EE_PMT_Base children |
|
| 32 | - * |
|
| 33 | - * @param string $identifier a unique identifier for this set of modules Required. |
|
| 34 | - * @param array $setup_args an array of arguments provided for registering modules Required.{ |
|
| 35 | - * @type string[] $payment_method_paths each element is the folder containing the EE_PMT_Base child class |
|
| 36 | - * (eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains |
|
| 37 | - * the files EE_PMT_Payomatic.pm.php) |
|
| 38 | - * } |
|
| 39 | - * @return void |
|
| 40 | - * @throws EE_Error |
|
| 41 | - * @type array payment_method_paths an array of full server paths to folders containing any EE_PMT_Base |
|
| 42 | - * children, or to the EED_Module files themselves |
|
| 43 | - * @throws InvalidDataTypeException |
|
| 44 | - * @throws DomainException |
|
| 45 | - * @throws InvalidArgumentException |
|
| 46 | - * @throws InvalidInterfaceException |
|
| 47 | - * @throws InvalidDataTypeException |
|
| 48 | - * @since 4.5.0 |
|
| 49 | - */ |
|
| 50 | - public static function register($identifier = '', array $setup_args = []) |
|
| 51 | - { |
|
| 52 | - // required fields MUST be present, so let's make sure they are. |
|
| 53 | - if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['payment_method_paths'])) { |
|
| 54 | - throw new EE_Error( |
|
| 55 | - esc_html__( |
|
| 56 | - '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)', |
|
| 57 | - 'event_espresso' |
|
| 58 | - ) |
|
| 59 | - ); |
|
| 60 | - } |
|
| 61 | - // make sure we don't register twice |
|
| 62 | - if (isset(self::$_settings[ $identifier ])) { |
|
| 63 | - return; |
|
| 64 | - } |
|
| 65 | - // make sure this was called in the right place! |
|
| 66 | - if (! 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[ $identifier ] = [ |
|
| 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[ $identifier ]['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[ $identifier ]) |
|
| 101 | - ); |
|
| 102 | - } |
|
| 103 | - } |
|
| 30 | + /** |
|
| 31 | + * Method for registering new EE_PMT_Base children |
|
| 32 | + * |
|
| 33 | + * @param string $identifier a unique identifier for this set of modules Required. |
|
| 34 | + * @param array $setup_args an array of arguments provided for registering modules Required.{ |
|
| 35 | + * @type string[] $payment_method_paths each element is the folder containing the EE_PMT_Base child class |
|
| 36 | + * (eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains |
|
| 37 | + * the files EE_PMT_Payomatic.pm.php) |
|
| 38 | + * } |
|
| 39 | + * @return void |
|
| 40 | + * @throws EE_Error |
|
| 41 | + * @type array payment_method_paths an array of full server paths to folders containing any EE_PMT_Base |
|
| 42 | + * children, or to the EED_Module files themselves |
|
| 43 | + * @throws InvalidDataTypeException |
|
| 44 | + * @throws DomainException |
|
| 45 | + * @throws InvalidArgumentException |
|
| 46 | + * @throws InvalidInterfaceException |
|
| 47 | + * @throws InvalidDataTypeException |
|
| 48 | + * @since 4.5.0 |
|
| 49 | + */ |
|
| 50 | + public static function register($identifier = '', array $setup_args = []) |
|
| 51 | + { |
|
| 52 | + // required fields MUST be present, so let's make sure they are. |
|
| 53 | + if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['payment_method_paths'])) { |
|
| 54 | + throw new EE_Error( |
|
| 55 | + esc_html__( |
|
| 56 | + '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)', |
|
| 57 | + 'event_espresso' |
|
| 58 | + ) |
|
| 59 | + ); |
|
| 60 | + } |
|
| 61 | + // make sure we don't register twice |
|
| 62 | + if (isset(self::$_settings[ $identifier ])) { |
|
| 63 | + return; |
|
| 64 | + } |
|
| 65 | + // make sure this was called in the right place! |
|
| 66 | + if (! 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[ $identifier ] = [ |
|
| 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[ $identifier ]['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[ $identifier ]) |
|
| 101 | + ); |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Filters the list of payment methods to add ours. |
|
| 108 | - * and they're just full filepaths to FOLDERS containing a payment method class file. Eg. |
|
| 109 | - * |
|
| 110 | - * @param array $payment_method_folders array of paths to all payment methods that require registering |
|
| 111 | - * @return array |
|
| 112 | - */ |
|
| 113 | - public static function add_payment_methods(array $payment_method_folders) |
|
| 114 | - { |
|
| 115 | - foreach (self::$_settings as $settings) { |
|
| 116 | - foreach ($settings['payment_method_paths'] as $payment_method_path) { |
|
| 117 | - $payment_method_folders[] = $payment_method_path; |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - return $payment_method_folders; |
|
| 121 | - } |
|
| 106 | + /** |
|
| 107 | + * Filters the list of payment methods to add ours. |
|
| 108 | + * and they're just full filepaths to FOLDERS containing a payment method class file. Eg. |
|
| 109 | + * |
|
| 110 | + * @param array $payment_method_folders array of paths to all payment methods that require registering |
|
| 111 | + * @return array |
|
| 112 | + */ |
|
| 113 | + public static function add_payment_methods(array $payment_method_folders) |
|
| 114 | + { |
|
| 115 | + foreach (self::$_settings as $settings) { |
|
| 116 | + foreach ($settings['payment_method_paths'] as $payment_method_path) { |
|
| 117 | + $payment_method_folders[] = $payment_method_path; |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + return $payment_method_folders; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | 123 | |
| 124 | - /** |
|
| 125 | - * This deregisters a module that was previously registered with a specific $identifier. |
|
| 126 | - * |
|
| 127 | - * @param string $identifier 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($identifier = '') |
|
| 136 | - { |
|
| 137 | - if (isset(self::$_settings[ $identifier ])) { |
|
| 138 | - // set action for just this module id to delay deregistration until core is loaded and ready. |
|
| 139 | - $module_settings = self::$_settings[ $identifier ]; |
|
| 140 | - unset(self::$_settings[ $identifier ]); |
|
| 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 $identifier. |
|
| 126 | + * |
|
| 127 | + * @param string $identifier 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($identifier = '') |
|
| 136 | + { |
|
| 137 | + if (isset(self::$_settings[ $identifier ])) { |
|
| 138 | + // set action for just this module id to delay deregistration until core is loaded and ready. |
|
| 139 | + $module_settings = self::$_settings[ $identifier ]; |
|
| 140 | + unset(self::$_settings[ $identifier ]); |
|
| 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) |
|
| 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) |
|
| 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 | } |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | 61 | // make sure we don't register twice |
| 62 | - if (isset(self::$_settings[ $identifier ])) { |
|
| 62 | + if (isset(self::$_settings[$identifier])) { |
|
| 63 | 63 | return; |
| 64 | 64 | } |
| 65 | 65 | // make sure this was called in the right place! |
| 66 | - if (! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 66 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 67 | 67 | || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
| 68 | 68 | ) { |
| 69 | 69 | EE_Error::doing_it_wrong( |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | ); |
| 77 | 77 | } |
| 78 | 78 | // setup $_settings array from incoming values. |
| 79 | - self::$_settings[ $identifier ] = [ |
|
| 79 | + self::$_settings[$identifier] = [ |
|
| 80 | 80 | // array of full server paths to any EE_PMT_Base children used |
| 81 | 81 | 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
| 82 | 82 | ? (array) $setup_args['payment_method_paths'] |
@@ -92,12 +92,12 @@ discard block |
||
| 92 | 92 | if (did_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods')) { |
| 93 | 93 | $payment_method_manager = LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
| 94 | 94 | // register payment methods directly |
| 95 | - foreach (self::$_settings[ $identifier ]['payment_method_paths'] as $payment_method_path) { |
|
| 95 | + foreach (self::$_settings[$identifier]['payment_method_paths'] as $payment_method_path) { |
|
| 96 | 96 | $payment_method_manager->register_payment_method($payment_method_path); |
| 97 | 97 | } |
| 98 | 98 | $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
| 99 | 99 | $capabilities->addCaps( |
| 100 | - self::getPaymentMethodCapabilities(self::$_settings[ $identifier ]) |
|
| 100 | + self::getPaymentMethodCapabilities(self::$_settings[$identifier]) |
|
| 101 | 101 | ); |
| 102 | 102 | } |
| 103 | 103 | } |
@@ -134,13 +134,13 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public static function deregister($identifier = '') |
| 136 | 136 | { |
| 137 | - if (isset(self::$_settings[ $identifier ])) { |
|
| 137 | + if (isset(self::$_settings[$identifier])) { |
|
| 138 | 138 | // set action for just this module id to delay deregistration until core is loaded and ready. |
| 139 | - $module_settings = self::$_settings[ $identifier ]; |
|
| 140 | - unset(self::$_settings[ $identifier ]); |
|
| 139 | + $module_settings = self::$_settings[$identifier]; |
|
| 140 | + unset(self::$_settings[$identifier]); |
|
| 141 | 141 | add_action( |
| 142 | 142 | 'AHEE__EE_System__core_loaded_and_ready', |
| 143 | - function () use ($module_settings) { |
|
| 143 | + function() use ($module_settings) { |
|
| 144 | 144 | $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
| 145 | 145 | $capabilities->removeCaps( |
| 146 | 146 | EE_Register_Payment_Method::getPaymentMethodCapabilities($module_settings) |
@@ -12,131 +12,131 @@ |
||
| 12 | 12 | class EE_Register_Model_Extensions implements EEI_Plugin_API |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - protected static $_registry; |
|
| 15 | + protected static $_registry; |
|
| 16 | 16 | |
| 17 | - protected static $_extensions = []; |
|
| 17 | + protected static $_extensions = []; |
|
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * register method for setting up model extensions |
|
| 22 | - * |
|
| 23 | - * @param string $identifier unique id for the extensions being setup |
|
| 24 | - * @param array $setup_args { |
|
| 25 | - * @return void |
|
| 26 | - * @throws EE_Error |
|
| 27 | - * @type array $model_extension_paths array of folders containing DB model extensions, where each file follows |
|
| 28 | - * the models naming convention, which is: |
|
| 29 | - * EEME_{your_plugin_slug}_model_name_extended}.model_ext.php. |
|
| 30 | - * Where {your_plugin_slug} is really anything you want (but something having |
|
| 31 | - * to do with your addon, like 'Calendar' or '3D_View') and |
|
| 32 | - * model_name_extended} is the model extended. |
|
| 33 | - * The class contained in teh file should extend |
|
| 34 | - * EEME_Base_{model_name_extended}.model_ext.php. |
|
| 35 | - * Where {your_plugin_slug} is really anything you want (but something |
|
| 36 | - * having to do with your addon, like 'Calendar' or '3D_View') and |
|
| 37 | - * {model_name_extended} is the model extended. The class contained in teh |
|
| 38 | - * file should extend EEME_Base |
|
| 39 | - * @type array $class_extension_paths array of folders containing DB class extensions, where each file follows |
|
| 40 | - * the model class extension naming convention, which is: |
|
| 41 | - * EEE_{your_plugin_slug}_model_name_extended}.class_ext.php. |
|
| 42 | - * Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc, |
|
| 43 | - * and model_name_extended} is the name of the model extended, eg |
|
| 44 | - * 'Attendee','Event',etc. |
|
| 45 | - * The class contained in the file should extend EEE_Base_Class |
|
| 46 | - * ._{model_name_extended}.class_ext.php. |
|
| 47 | - * Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc, |
|
| 48 | - * and {model_name_extended} is the name of the model extended, eg |
|
| 49 | - * 'Attendee','Event',etc. The class contained in the file should extend |
|
| 50 | - * EEE_Base_Class. |
|
| 51 | - * } |
|
| 52 | - * |
|
| 53 | - */ |
|
| 54 | - public static function register($identifier = '', array $setup_args = []) |
|
| 55 | - { |
|
| 56 | - // required fields MUST be present, so let's make sure they are. |
|
| 57 | - if (empty($identifier) |
|
| 58 | - || ! is_array($setup_args) |
|
| 59 | - || (empty($setup_args['model_extension_paths']) && empty($setup_args['class_extension_paths'])) |
|
| 60 | - ) { |
|
| 61 | - throw new EE_Error( |
|
| 62 | - __( |
|
| 63 | - 'In order to register Model extensions with EE_Register_Model_Extensions::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_extension_paths" (an array of full server paths to folders that contain model extensions), and "class_extension_paths" (an array of full server paths to folders that contain class extensions)', |
|
| 64 | - 'event_espresso' |
|
| 65 | - ) |
|
| 66 | - ); |
|
| 67 | - } |
|
| 20 | + /** |
|
| 21 | + * register method for setting up model extensions |
|
| 22 | + * |
|
| 23 | + * @param string $identifier unique id for the extensions being setup |
|
| 24 | + * @param array $setup_args { |
|
| 25 | + * @return void |
|
| 26 | + * @throws EE_Error |
|
| 27 | + * @type array $model_extension_paths array of folders containing DB model extensions, where each file follows |
|
| 28 | + * the models naming convention, which is: |
|
| 29 | + * EEME_{your_plugin_slug}_model_name_extended}.model_ext.php. |
|
| 30 | + * Where {your_plugin_slug} is really anything you want (but something having |
|
| 31 | + * to do with your addon, like 'Calendar' or '3D_View') and |
|
| 32 | + * model_name_extended} is the model extended. |
|
| 33 | + * The class contained in teh file should extend |
|
| 34 | + * EEME_Base_{model_name_extended}.model_ext.php. |
|
| 35 | + * Where {your_plugin_slug} is really anything you want (but something |
|
| 36 | + * having to do with your addon, like 'Calendar' or '3D_View') and |
|
| 37 | + * {model_name_extended} is the model extended. The class contained in teh |
|
| 38 | + * file should extend EEME_Base |
|
| 39 | + * @type array $class_extension_paths array of folders containing DB class extensions, where each file follows |
|
| 40 | + * the model class extension naming convention, which is: |
|
| 41 | + * EEE_{your_plugin_slug}_model_name_extended}.class_ext.php. |
|
| 42 | + * Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc, |
|
| 43 | + * and model_name_extended} is the name of the model extended, eg |
|
| 44 | + * 'Attendee','Event',etc. |
|
| 45 | + * The class contained in the file should extend EEE_Base_Class |
|
| 46 | + * ._{model_name_extended}.class_ext.php. |
|
| 47 | + * Where {your_plugin_slug} is something like 'Calendar','MailChimp',etc, |
|
| 48 | + * and {model_name_extended} is the name of the model extended, eg |
|
| 49 | + * 'Attendee','Event',etc. The class contained in the file should extend |
|
| 50 | + * EEE_Base_Class. |
|
| 51 | + * } |
|
| 52 | + * |
|
| 53 | + */ |
|
| 54 | + public static function register($identifier = '', array $setup_args = []) |
|
| 55 | + { |
|
| 56 | + // required fields MUST be present, so let's make sure they are. |
|
| 57 | + if (empty($identifier) |
|
| 58 | + || ! is_array($setup_args) |
|
| 59 | + || (empty($setup_args['model_extension_paths']) && empty($setup_args['class_extension_paths'])) |
|
| 60 | + ) { |
|
| 61 | + throw new EE_Error( |
|
| 62 | + __( |
|
| 63 | + 'In order to register Model extensions with EE_Register_Model_Extensions::register(), you must include a "model_id" (a unique identifier for this set of models), and an array containing the following keys: "model_extension_paths" (an array of full server paths to folders that contain model extensions), and "class_extension_paths" (an array of full server paths to folders that contain class extensions)', |
|
| 64 | + 'event_espresso' |
|
| 65 | + ) |
|
| 66 | + ); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - // make sure we don't register twice |
|
| 70 | - if (isset(self::$_registry[ $identifier ])) { |
|
| 71 | - return; |
|
| 72 | - } |
|
| 73 | - // check correct loading |
|
| 74 | - if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
| 75 | - EE_Error::doing_it_wrong( |
|
| 76 | - __METHOD__, |
|
| 77 | - sprintf( |
|
| 78 | - __( |
|
| 79 | - 'An attempt was made to register "%1$s" as a Model extension has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register models.%2$s Hook Status: %2$s "AHEE__EE_System__load_espresso_addons" : %3$s %2$s "AHEE__EE_Admin__loaded" : %4$s%2$s', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - $identifier, |
|
| 83 | - '<br />', |
|
| 84 | - did_action('AHEE__EE_System__load_espresso_addons') ? 'action done' : 'action NOT done', |
|
| 85 | - did_action('AHEE__EE_Admin__loaded') ? 'action done' : 'action NOT done' |
|
| 86 | - ), |
|
| 87 | - '4.3' |
|
| 88 | - ); |
|
| 89 | - } |
|
| 69 | + // make sure we don't register twice |
|
| 70 | + if (isset(self::$_registry[ $identifier ])) { |
|
| 71 | + return; |
|
| 72 | + } |
|
| 73 | + // check correct loading |
|
| 74 | + if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
| 75 | + EE_Error::doing_it_wrong( |
|
| 76 | + __METHOD__, |
|
| 77 | + sprintf( |
|
| 78 | + __( |
|
| 79 | + 'An attempt was made to register "%1$s" as a Model extension has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register models.%2$s Hook Status: %2$s "AHEE__EE_System__load_espresso_addons" : %3$s %2$s "AHEE__EE_Admin__loaded" : %4$s%2$s', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + $identifier, |
|
| 83 | + '<br />', |
|
| 84 | + did_action('AHEE__EE_System__load_espresso_addons') ? 'action done' : 'action NOT done', |
|
| 85 | + did_action('AHEE__EE_Admin__loaded') ? 'action done' : 'action NOT done' |
|
| 86 | + ), |
|
| 87 | + '4.3' |
|
| 88 | + ); |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - self::$_registry[ $identifier ] = $setup_args; |
|
| 92 | - self::$_extensions[ $identifier ] = []; |
|
| 91 | + self::$_registry[ $identifier ] = $setup_args; |
|
| 92 | + self::$_extensions[ $identifier ] = []; |
|
| 93 | 93 | |
| 94 | - if (isset($setup_args['model_extension_paths'])) { |
|
| 95 | - require_once(EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php'); |
|
| 96 | - $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['model_extension_paths']); |
|
| 97 | - // remove all files that are not PHP |
|
| 98 | - foreach ($class_to_filepath_map as $class => $path) { |
|
| 99 | - if (substr($path, strlen($path) - 3) !== 'php') { |
|
| 100 | - unset($class_to_filepath_map[ $class ]); |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - EEH_Autoloader::register_autoloader($class_to_filepath_map); |
|
| 104 | - foreach (array_keys($class_to_filepath_map) as $classname) { |
|
| 105 | - self::$_extensions[ $identifier ]['models'][ $classname ] = new $classname; |
|
| 106 | - } |
|
| 107 | - unset($setup_args['model_extension_paths']); |
|
| 108 | - } |
|
| 109 | - if (isset($setup_args['class_extension_paths'])) { |
|
| 110 | - require_once(EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php'); |
|
| 111 | - $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_extension_paths']); |
|
| 112 | - EEH_Autoloader::register_autoloader($class_to_filepath_map); |
|
| 113 | - foreach (array_keys($class_to_filepath_map) as $classname) { |
|
| 114 | - self::$_extensions[ $identifier ]['classes'][ $classname ] = new $classname; |
|
| 115 | - } |
|
| 116 | - unset($setup_args['class_extension_paths']); |
|
| 117 | - } |
|
| 118 | - foreach ($setup_args as $unknown_key => $unknown_config) { |
|
| 119 | - throw new EE_Error( |
|
| 120 | - sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key) |
|
| 121 | - ); |
|
| 122 | - } |
|
| 123 | - } |
|
| 94 | + if (isset($setup_args['model_extension_paths'])) { |
|
| 95 | + require_once(EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php'); |
|
| 96 | + $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['model_extension_paths']); |
|
| 97 | + // remove all files that are not PHP |
|
| 98 | + foreach ($class_to_filepath_map as $class => $path) { |
|
| 99 | + if (substr($path, strlen($path) - 3) !== 'php') { |
|
| 100 | + unset($class_to_filepath_map[ $class ]); |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + EEH_Autoloader::register_autoloader($class_to_filepath_map); |
|
| 104 | + foreach (array_keys($class_to_filepath_map) as $classname) { |
|
| 105 | + self::$_extensions[ $identifier ]['models'][ $classname ] = new $classname; |
|
| 106 | + } |
|
| 107 | + unset($setup_args['model_extension_paths']); |
|
| 108 | + } |
|
| 109 | + if (isset($setup_args['class_extension_paths'])) { |
|
| 110 | + require_once(EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php'); |
|
| 111 | + $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_extension_paths']); |
|
| 112 | + EEH_Autoloader::register_autoloader($class_to_filepath_map); |
|
| 113 | + foreach (array_keys($class_to_filepath_map) as $classname) { |
|
| 114 | + self::$_extensions[ $identifier ]['classes'][ $classname ] = new $classname; |
|
| 115 | + } |
|
| 116 | + unset($setup_args['class_extension_paths']); |
|
| 117 | + } |
|
| 118 | + foreach ($setup_args as $unknown_key => $unknown_config) { |
|
| 119 | + throw new EE_Error( |
|
| 120 | + sprintf(__("The key '%s' is not a known key for registering a model", "event_espresso"), $unknown_key) |
|
| 121 | + ); |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | 124 | |
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * deregister |
|
| 128 | - * |
|
| 129 | - * @param string $identifier |
|
| 130 | - */ |
|
| 131 | - public static function deregister($identifier = '') |
|
| 132 | - { |
|
| 133 | - if (isset(self::$_registry[ $identifier ])) { |
|
| 134 | - unset(self::$_registry[ $identifier ]); |
|
| 135 | - foreach (self::$_extensions[ $identifier ] as $extension_of_type) { |
|
| 136 | - foreach ($extension_of_type as $extension) { |
|
| 137 | - $extension->deregister(); |
|
| 138 | - } |
|
| 139 | - } |
|
| 140 | - } |
|
| 141 | - } |
|
| 126 | + /** |
|
| 127 | + * deregister |
|
| 128 | + * |
|
| 129 | + * @param string $identifier |
|
| 130 | + */ |
|
| 131 | + public static function deregister($identifier = '') |
|
| 132 | + { |
|
| 133 | + if (isset(self::$_registry[ $identifier ])) { |
|
| 134 | + unset(self::$_registry[ $identifier ]); |
|
| 135 | + foreach (self::$_extensions[ $identifier ] as $extension_of_type) { |
|
| 136 | + foreach ($extension_of_type as $extension) { |
|
| 137 | + $extension->deregister(); |
|
| 138 | + } |
|
| 139 | + } |
|
| 140 | + } |
|
| 141 | + } |
|
| 142 | 142 | } |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // make sure we don't register twice |
| 70 | - if (isset(self::$_registry[ $identifier ])) { |
|
| 70 | + if (isset(self::$_registry[$identifier])) { |
|
| 71 | 71 | return; |
| 72 | 72 | } |
| 73 | 73 | // check correct loading |
| 74 | - if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
| 74 | + if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) { |
|
| 75 | 75 | EE_Error::doing_it_wrong( |
| 76 | 76 | __METHOD__, |
| 77 | 77 | sprintf( |
@@ -88,30 +88,30 @@ discard block |
||
| 88 | 88 | ); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - self::$_registry[ $identifier ] = $setup_args; |
|
| 92 | - self::$_extensions[ $identifier ] = []; |
|
| 91 | + self::$_registry[$identifier] = $setup_args; |
|
| 92 | + self::$_extensions[$identifier] = []; |
|
| 93 | 93 | |
| 94 | 94 | if (isset($setup_args['model_extension_paths'])) { |
| 95 | - require_once(EE_LIBRARIES . 'plugin_api/db/EEME_Base.lib.php'); |
|
| 95 | + require_once(EE_LIBRARIES.'plugin_api/db/EEME_Base.lib.php'); |
|
| 96 | 96 | $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['model_extension_paths']); |
| 97 | 97 | // remove all files that are not PHP |
| 98 | 98 | foreach ($class_to_filepath_map as $class => $path) { |
| 99 | 99 | if (substr($path, strlen($path) - 3) !== 'php') { |
| 100 | - unset($class_to_filepath_map[ $class ]); |
|
| 100 | + unset($class_to_filepath_map[$class]); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | EEH_Autoloader::register_autoloader($class_to_filepath_map); |
| 104 | 104 | foreach (array_keys($class_to_filepath_map) as $classname) { |
| 105 | - self::$_extensions[ $identifier ]['models'][ $classname ] = new $classname; |
|
| 105 | + self::$_extensions[$identifier]['models'][$classname] = new $classname; |
|
| 106 | 106 | } |
| 107 | 107 | unset($setup_args['model_extension_paths']); |
| 108 | 108 | } |
| 109 | 109 | if (isset($setup_args['class_extension_paths'])) { |
| 110 | - require_once(EE_LIBRARIES . 'plugin_api/db/EEE_Base_Class.lib.php'); |
|
| 110 | + require_once(EE_LIBRARIES.'plugin_api/db/EEE_Base_Class.lib.php'); |
|
| 111 | 111 | $class_to_filepath_map = EEH_File::get_contents_of_folders($setup_args['class_extension_paths']); |
| 112 | 112 | EEH_Autoloader::register_autoloader($class_to_filepath_map); |
| 113 | 113 | foreach (array_keys($class_to_filepath_map) as $classname) { |
| 114 | - self::$_extensions[ $identifier ]['classes'][ $classname ] = new $classname; |
|
| 114 | + self::$_extensions[$identifier]['classes'][$classname] = new $classname; |
|
| 115 | 115 | } |
| 116 | 116 | unset($setup_args['class_extension_paths']); |
| 117 | 117 | } |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | public static function deregister($identifier = '') |
| 132 | 132 | { |
| 133 | - if (isset(self::$_registry[ $identifier ])) { |
|
| 134 | - unset(self::$_registry[ $identifier ]); |
|
| 135 | - foreach (self::$_extensions[ $identifier ] as $extension_of_type) { |
|
| 133 | + if (isset(self::$_registry[$identifier])) { |
|
| 134 | + unset(self::$_registry[$identifier]); |
|
| 135 | + foreach (self::$_extensions[$identifier] as $extension_of_type) { |
|
| 136 | 136 | foreach ($extension_of_type as $extension) { |
| 137 | 137 | $extension->deregister(); |
| 138 | 138 | } |