File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -357,11 +357,11 @@ abstract class Hookable
357357 ];
358358
359359 /**
360- * Hook name
360+ * Hooks to register
361361 *
362- * @var string
362+ * @var string|string[]
363363 */
364- protected string $ hookname ;
364+ protected $ hooks ;
365365
366366 /**
367367 * Hook priority
@@ -375,10 +375,15 @@ abstract class Hookable
375375 */
376376 public function __construct ()
377377 {
378- if (!in_array ($ this ->hookname , self ::$ availableHooks )) {
379- throw new Exception ("Invalid hook name: {$ this ->hookname }" );
378+ $ hooks = is_array ($ this ->hooks ) ? $ this ->hooks : [$ this ->hooks ];
379+
380+ foreach ($ hooks as $ hook ) {
381+ if (!in_array ($ hook , self ::$ availableHooks )) {
382+ throw new Exception ("Invalid hook name: {$ hook }" );
383+ }
384+
385+ add_hook ($ hook , $ this ->priority , [$ this , 'hookCallback ' ]);
380386 }
381- add_hook ($ this ->hookname , $ this ->priority , [$ this , 'hookCallback ' ]);
382387 }
383388
384389 /**
You can’t perform that action at this time.
0 commit comments