1 | <?php |
||
30 | class WordPoints_Hooks extends WordPoints_App { |
||
31 | |||
32 | /** |
||
33 | * The current mode of the API. |
||
34 | * |
||
35 | * @since 1.0.0 |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $current_mode; |
||
40 | |||
41 | /** |
||
42 | * Register the sub apps when the app is constructed. |
||
43 | * |
||
44 | * @since 1.0.0 |
||
45 | */ |
||
46 | protected function init() { |
||
47 | |||
48 | $sub_apps = $this->sub_apps; |
||
49 | $sub_apps->register( 'router', 'WordPoints_Hook_Router' ); |
||
50 | $sub_apps->register( 'actions', 'WordPoints_Hook_Actions' ); |
||
51 | $sub_apps->register( 'events', 'WordPoints_Hook_Events' ); |
||
52 | $sub_apps->register( 'reactors', 'WordPoints_Class_Registry_Persistent' ); |
||
53 | $sub_apps->register( 'reaction_stores', 'WordPoints_Class_Registry_Children' ); |
||
54 | $sub_apps->register( 'extensions', 'WordPoints_Class_Registry_Persistent' ); |
||
55 | $sub_apps->register( 'conditions', 'WordPoints_Class_Registry_Children' ); |
||
56 | |||
57 | parent::init(); |
||
58 | } |
||
59 | |||
60 | /** |
||
61 | * Gets the current mode that the API is in. |
||
62 | * |
||
63 | * By default 'standard' mode is on, unless in network context (such as in the |
||
64 | * network admin) on multisite, when 'network' mode is the default. |
||
65 | * |
||
66 | * The current mode is used by reactors to determine which reaction type to offer |
||
67 | * access to through the $reactions property. This is allows for generic code for |
||
68 | * handling reactions to reference the $reactions property of the reactor, and |
||
69 | * what type of reactions it will get will be determined based on the current |
||
70 | * mode that is set. |
||
71 | * |
||
72 | * @since 1.0.0 |
||
73 | * |
||
74 | * @return string The slug of the current mode. |
||
75 | */ |
||
76 | public function get_current_mode() { |
||
77 | |||
78 | if ( ! isset( $this->current_mode ) ) { |
||
79 | $this->current_mode = ( wordpoints_is_network_context() ? 'network' : 'standard' ); |
||
80 | } |
||
81 | |||
82 | return $this->current_mode; |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * Sets the current mode of the API. |
||
87 | * |
||
88 | * This function should be used very sparingly. The default mode which is set by |
||
89 | * WordPoints should work for you in most cases. The primary reason that you |
||
90 | * would ever need to set the mode yourself is if you have created your own |
||
91 | * custom mode. Otherwise you probably shouldn't be using this function. |
||
92 | * |
||
93 | * @since 1.0.0 |
||
94 | * |
||
95 | * @param string $mode The slug of the mode to set as the current mode. |
||
96 | */ |
||
97 | public function set_current_mode( $mode ) { |
||
98 | $this->current_mode = $mode; |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Get a reaction storage object. |
||
103 | * |
||
104 | * @since 1.0.0 |
||
105 | * |
||
106 | * @param string $slug The slug of the reaction store to get. |
||
107 | * |
||
108 | * @return WordPoints_Hook_Reaction_StoreI|false The reaction storage object. |
||
109 | */ |
||
110 | public function get_reaction_store( $slug ) { |
||
128 | |||
129 | /** |
||
130 | * Fire an event at each of the reactions. |
||
131 | * |
||
132 | * @since 1.0.0 |
||
133 | * |
||
134 | * @param string $action_type The type of action triggering |
||
135 | * this fire of this event. |
||
136 | * @param string $event_slug The slug of the event. |
||
137 | * @param WordPoints_Hook_Event_Args $event_args The event args. |
||
138 | */ |
||
139 | public function fire( |
||
170 | |||
171 | /** |
||
172 | * Fire for a particular reaction. |
||
173 | * |
||
174 | * @since 1.0.0 |
||
175 | * |
||
176 | * @param WordPoints_Hook_Fire $fire The hook fire object. |
||
177 | */ |
||
178 | protected function fire_reaction( $fire ) { |
||
213 | } |
||
214 | |||
216 |