# wp-coder/4.5.2/assets/js/template.js

WP Coder – Insert &amp; Manage Code Snippets, version 4.5.2. 36 lines.

- Page: https://pluginprobe.com/plugins/wp-coder/4.5.2/code/assets/js/template.js
- Raw: https://pluginprobe.com/plugins/wp-coder/4.5.2/raw/assets/js/template.js
- Modified: 2026-10-02T10:58:16+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-coder/4.5.2/code/assets/js/template.js#L10-L20`.

```javascript
'use strict';

const template = function () {
    const template = document.getElementById('clone-dereg-fields');

    if (!template) {
        return false;
    }

    const box = document.getElementById('dereg-handle');
    const addBtn = document.getElementById('add-handle');
    const removeBtn = document.getElementById('remove-handle');

    addBtn.addEventListener('click', (event) => {
        event.preventDefault();
        const clone = template.content.cloneNode(true);
        const container = document.getElementById('dereg-handle');
        const targetElement = document.querySelector('#dereg-handle .wowp-btn-actions');
        container.insertBefore(clone, targetElement);
    });

    removeBtn.addEventListener('click', (event) => {
        event.preventDefault();
        const parentElement = document.getElementById('dereg-handle');
        const lastChild = parentElement.querySelector('.wowp-fields-group:nth-last-child(2)');
        if (lastChild) {
            lastChild.remove();
        }
    });
}


document.addEventListener('DOMContentLoaded', function () {
    new template;

});
```
