17
17
*/
18
18
class MslsPostTag extends MslsMain {
19
19
20
- protected int $ excution_counter = 0 ;
20
+ const EDIT_ACTION = 'msls_post_tag_edit_input ' ;
21
+ const ADD_ACTION = 'msls_post_tag_add_input ' ;
21
22
22
23
/**
23
24
* Suggest
@@ -97,6 +98,10 @@ public static function init(): void {
97
98
* @param string $taxonomy
98
99
*/
99
100
public function add_input ( string $ taxonomy ): void {
101
+ if ( did_action ( self ::ADD_ACTION ) ) {
102
+ return ;
103
+ }
104
+
100
105
$ title_format = '<h3>%s</h3>
101
106
<input type="hidden" name="msls_post_type" id="msls_post_type" value="%s"/>
102
107
<input type="hidden" name="msls_action" id="msls_action" value="suggest_terms"/> ' ;
@@ -108,6 +113,8 @@ public function add_input( string $taxonomy ): void {
108
113
echo '<div class="form-field"> ' ;
109
114
$ this ->the_input ( null , $ title_format , $ item_format );
110
115
echo '</div> ' ;
116
+
117
+ do_action ( self ::ADD_ACTION , $ taxonomy );
111
118
}
112
119
113
120
/**
@@ -117,6 +124,10 @@ public function add_input( string $taxonomy ): void {
117
124
* @param string $taxonomy
118
125
*/
119
126
public function edit_input ( \WP_Term $ tag , string $ taxonomy ): void {
127
+ if ( did_action ( self ::EDIT_ACTION ) ) {
128
+ return ;
129
+ }
130
+
120
131
$ title_format = '<tr>
121
132
<th colspan="2">
122
133
<strong>%s</strong>
@@ -136,6 +147,8 @@ public function edit_input( \WP_Term $tag, string $taxonomy ): void {
136
147
</tr> ' ;
137
148
138
149
$ this ->the_input ( $ tag , $ title_format , $ item_format );
150
+
151
+ do_action ( self ::EDIT_ACTION , $ tag , $ taxonomy );
139
152
}
140
153
141
154
/**
@@ -150,10 +163,6 @@ public function edit_input( \WP_Term $tag, string $taxonomy ): void {
150
163
* @return boolean
151
164
*/
152
165
public function the_input ( ?\WP_Term $ tag , string $ title_format , string $ item_format ): bool {
153
- if ( $ this ->already_executed () ) {
154
- return false ;
155
- }
156
-
157
166
$ blogs = $ this ->collection ->get ();
158
167
if ( $ blogs ) {
159
168
$ term_id = $ tag ->term_id ?? 0 ;
@@ -261,14 +270,4 @@ protected function get_select_title(): string {
261
270
__ ( 'Multisite Language Switcher ' , 'multisite-language-switcher ' )
262
271
);
263
272
}
264
-
265
- protected function already_executed (): bool {
266
- if ( $ this ->excution_counter > 0 ) {
267
- return true ;
268
- }
269
-
270
- ++$ this ->excution_counter ;
271
-
272
- return false ;
273
- }
274
273
}
0 commit comments