1717 */
1818class MslsPostTag extends MslsMain {
1919
20- protected int $ excution_counter = 0 ;
20+ const EDIT_ACTION = 'msls_post_tag_edit_input ' ;
21+ const ADD_ACTION = 'msls_post_tag_add_input ' ;
2122
2223 /**
2324 * Suggest
@@ -97,6 +98,10 @@ public static function init(): void {
9798 * @param string $taxonomy
9899 */
99100 public function add_input ( string $ taxonomy ): void {
101+ if ( did_action ( self ::ADD_ACTION ) ) {
102+ return ;
103+ }
104+
100105 $ title_format = '<h3>%s</h3>
101106 <input type="hidden" name="msls_post_type" id="msls_post_type" value="%s"/>
102107 <input type="hidden" name="msls_action" id="msls_action" value="suggest_terms"/> ' ;
@@ -108,6 +113,8 @@ public function add_input( string $taxonomy ): void {
108113 echo '<div class="form-field"> ' ;
109114 $ this ->the_input ( null , $ title_format , $ item_format );
110115 echo '</div> ' ;
116+
117+ do_action ( self ::ADD_ACTION , $ taxonomy );
111118 }
112119
113120 /**
@@ -117,6 +124,10 @@ public function add_input( string $taxonomy ): void {
117124 * @param string $taxonomy
118125 */
119126 public function edit_input ( \WP_Term $ tag , string $ taxonomy ): void {
127+ if ( did_action ( self ::EDIT_ACTION ) ) {
128+ return ;
129+ }
130+
120131 $ title_format = '<tr>
121132 <th colspan="2">
122133 <strong>%s</strong>
@@ -136,6 +147,8 @@ public function edit_input( \WP_Term $tag, string $taxonomy ): void {
136147 </tr> ' ;
137148
138149 $ this ->the_input ( $ tag , $ title_format , $ item_format );
150+
151+ do_action ( self ::EDIT_ACTION , $ tag , $ taxonomy );
139152 }
140153
141154 /**
@@ -150,10 +163,6 @@ public function edit_input( \WP_Term $tag, string $taxonomy ): void {
150163 * @return boolean
151164 */
152165 public function the_input ( ?\WP_Term $ tag , string $ title_format , string $ item_format ): bool {
153- if ( $ this ->already_executed () ) {
154- return false ;
155- }
156-
157166 $ blogs = $ this ->collection ->get ();
158167 if ( $ blogs ) {
159168 $ term_id = $ tag ->term_id ?? 0 ;
@@ -261,14 +270,4 @@ protected function get_select_title(): string {
261270 __ ( 'Multisite Language Switcher ' , 'multisite-language-switcher ' )
262271 );
263272 }
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- }
274273}
0 commit comments