Добавьте кнопку на элементе или добавьте новый раздел на странице редактирования. ⇐ Php

Кемеровские программисты php общаются здесь
Anonymous
Добавьте кнопку на элементе или добавьте новый раздел на странице редактирования.

Сообщение Anonymous »

Я хочу добавить кнопку в Elementor или добавить новый раздел на странице редактирования. В корневом файле моего плагина я просто поставил в очередь только файл js. Я убедился, что файл js загружен идеально, и в консоли я наконец вижу этот console.log('Elementor инициализирован');. Если кто-нибудь может решить проблему, пожалуйста, помогите мне. Для пояснения я просто хочу добавить только кнопку.
Для большей ясности см. изображение
[img]https://i.sstatic.net /82a5AH2T.png[/img]

console.log('custom-button.js loaded');

jQuery(window).on('elementor:init', function() {
console.log('Elementor initialized');

elementor.hooks.addAction('editor/init', function() {
console.log('Editor initialized');

const interval = setInterval(() => {
const targetContainers = document.querySelectorAll('.elementor-add-new-section, .e-view');

console.log('Checking for target containers:', targetContainers);

if (targetContainers.length > 0) {
targetContainers.forEach((container, index) => {
console.log(`Container ${index} found`, container);

if (container.classList.contains('e-view')) {
const buttonDiv = document.createElement('div');
buttonDiv.classList.add('elementor-add-section-area-button');

const newButton = document.createElement('button');
newButton.textContent = 'Add New Section';
newButton.classList.add('button', 'button-primary');

buttonDiv.appendChild(newButton);
container.appendChild(buttonDiv);
console.log('Button added to the editor');

clearInterval(interval);
}
});
} else {
console.log('No matching target containers found yet');
}
}, 500);
});
});


Подробнее здесь: https://stackoverflow.com/questions/791 ... -edit-page

Вернуться в «Php»