You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.1 KiB

/**
* 自定义器控制脚本
* 用于增强自定义器界面的用户体验
*/
// 立即定义全局测试函数,确保在控制台中可用
window.testGalleryControls = function() {
if (typeof $ !== 'undefined') {
var galleryWrappers = $('.gallery-control-wrapper');
var selectButtons = $('.gallery-select-button');
var clearButtons = $('.gallery-clear-button');
return {
wrappers: galleryWrappers.length,
selectButtons: selectButtons.length,
clearButtons: clearButtons.length,
mediaAvailable: typeof wp !== 'undefined' && typeof wp.media !== 'undefined',
customizeAvailable: typeof wp !== 'undefined' && typeof wp.customize !== 'undefined'
};
} else {
return { error: 'jQuery not available' };
}
};
window.triggerGallerySelect = function() {
if (typeof $ === 'undefined') {
return false;
}
var selectButton = $('.gallery-select-button').first();
if (selectButton.length > 0) {
selectButton.trigger('click');
return true;
} else {
return false;
}
};
(function($) {
'use strict';
// 当自定义器准备就绪时执行
wp.customize.bind('ready', function() {
// 确保媒体库已加载
if (typeof wp.media === 'undefined') {
// Error handling silently
}
// 强制初始化媒体库
if (typeof wp.media !== 'undefined') {
wp.media.view.settings.post.id = 0;
}
// 添加Banner面板的帮助信息
var bannerPanel = wp.customize.panel('nenghui_banner_panel');
// if (bannerPanel) {
// bannerPanel.container.find('.accordion-section-title').after(
// '<p class="description customize-panel-description">' +
// '配置完成后,您可以在任何文章或页面中使用短代码 <code>[nenghui_banner]</code> 来显示Banner轮播。' +
// '</p>'
// );
// }
// 添加Banner Title面板的帮助信息
var bannerTitlePanel = wp.customize.panel('nenghui_banner_title_panel');
// if (bannerTitlePanel) {
// bannerTitlePanel.container.find('.accordion-section-title').after(
// '<p class="description customize-panel-description">' +
// '配置完成后,您可以在任何文章或页面中使用短代码 <code>[nenghui_banner_title]</code> 来显示Banner标题区块。' +
// '</p>'
// );
// }
// 添加Futures面板的帮助信息
var futuresPanel = wp.customize.panel('nenghui_futures_panel');
// if (futuresPanel) {
// futuresPanel.container.find('.accordion-section-title').after(
// '<p class="description customize-panel-description">' +
// '配置完成后,您可以在任何文章或页面中使用短代码 <code>[nenghui_futures]</code> 来显示Futures区块。' +
// '</p>'
// );
// }
});
})(jQuery);