我想知道如何更改Jetpack无限句柄HTML标记。我在/wp-content/plugins/jetpack/modules/infinite-scroll/中的infinity.js中找到了默认标记,如下所示:
Scroller = function( settings ) {
var self = this;
// Initialize our variables
this.id = settings.id;
this.body = $( document.body );
this.window = $( window );
this.element = $( '#' + settings.id );
this.wrapperClass = settings.wrapper_class;
this.ready = true;
this.disabled = false;
this.page = 1;
this.offset = settings.offset;
this.currentday = settings.currentday;
this.order = settings.order;
this.throttle = false;
this.handle = '<div id="infinite-handle"><span><button>' + text.replace( '\\', '' ) + '</button></span></div>';
this.click_handle = settings.click_handle;
this.google_analytics = settings.google_analytics;
this.history = settings.history;
this.origURL = window.location.href;
this.pageCache = {};
etc...请看下面的代码从上面的代码,这是我想要改变的。
this.handle = '<div id="infinite-handle"><span><button>' + text.replace( '\\', '' ) + '</button></span></div>';在另一个线程中,我发现如何使用以下钩子来更改文本,它运行得很好:
function filter_jetpack_infinite_scroll_js_settings( $settings ) {
$settings['text'] = __( 'Load more...', 'i18n' );
return $settings;
}
add_filter( 'infinite_scroll_js_settings', 'filter_jetpack_infinite_scroll_js_settings', 100 );问题是,我是否可以使用与更改文本时相同的方法更改this.handle值?
谢谢你的帮助:)
发布于 2017-06-16 12:11:00
是的,您可以通过以下方式更改句柄值,
首先,将脚本排出队列。
function wpdocs_dequeue_script() {
wp_dequeue_script( 'the-neverending-homepage' );
}
add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 100 );然后通过infinity.js中的wp_enqueue_script函数将脚本functions.php添加到主题中,并将this.handle更改为您的值。
https://stackoverflow.com/questions/44588676
复制相似问题