I want to know how to change Jetpack infinite-handle HTML markup. I found the default markup in infinity.js in /wp-content/plugins/jetpack/modules/infinite-scroll/ like the following code :
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...
Please see the following code from code above, this is what I want to change.
this.handle = '<div id="infinite-handle"><span><button>' + text.replace( '\\', '' ) + '</button></span></div>';
I found in another thread how to change the text is using the following hooks and it works well :
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 );
The questions is, can I change the this.handle value using the same method like I did when change the text ?
Thanks in advance for your help :)
Yes , you can change the handle value by following,
First dequeue the script.
function wpdocs_dequeue_script() {
wp_dequeue_script( 'the-neverending-homepage' );
}
add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 100 );
Then add the script infinity.js
to theme via wp_enqueue_script function in functions.php and change this.handle to your value.