Created
July 24, 2017 01:53
-
-
Save psorensen/87c7cf091efcd8c368337f24541e1dca to your computer and use it in GitHub Desktop.
Wordpress: Fire event when term is created.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $( document ).ajaxComplete( function( event, xhr, settings ) { | |
| try { | |
| var queryStringArray = settings.data.split('&'); | |
| } catch(e) { | |
| var queryStringArray = {}; | |
| } | |
| // only when | |
| if ( $.inArray( 'action=add-tag', queryStringArray ) !== -1 ) { | |
| const $xml = $( xhr.responseXML ); | |
| const tag_id = $xml.find( 'term_id' ).text() | |
| if ( "" !== tag_id ) { | |
| $( document ).trigger( 'ami-term-created' ); | |
| } | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment