script.js
35 lines
| 1 | /** |
| 2 | * REST API無効化ページのボタンの処理 |
| 3 | * |
| 4 | * @package REST API無効化ページボタン |
| 5 | */ |
| 6 | document.addEventListener( |
| 7 | 'DOMContentLoaded', |
| 8 | function() |
| 9 | { |
| 10 | let disableRestApiExclude = document.querySelector( '#disable_rest_api_exclude' ); |
| 11 | let activePlugins = document.querySelector( '#active-plugins' ); |
| 12 | if ( activePlugins ) { |
| 13 | let btnExcludeList = activePlugins.querySelectorAll( '.btn-exclude' ); |
| 14 | btnExcludeList.forEach( |
| 15 | function(btnExclude) |
| 16 | { |
| 17 | btnExclude.addEventListener( |
| 18 | 'click', |
| 19 | function() |
| 20 | { |
| 21 | let li = this.closest( 'li' ); |
| 22 | if ( disableRestApiExclude.value === '' ) { |
| 23 | disableRestApiExclude.value += li.querySelector( 'span' ).textContent; |
| 24 | } else { |
| 25 | disableRestApiExclude.value += String.fromCharCode( 10 ) + li.querySelector( 'span' ).textContent; |
| 26 | } |
| 27 | li.parentNode.removeChild( li ); |
| 28 | } |
| 29 | ); |
| 30 | } |
| 31 | ); |
| 32 | } |
| 33 | } |
| 34 | ); |
| 35 |