Created
December 3, 2024 15:45
-
-
Save MjHead/1d7bc2f72949b86bd2d923c72b0741e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'admin_footer', function() { | |
?> | |
<script> | |
class JetEngineCheckboxSEO { | |
constructor() { | |
if ( ! window.rankMathEditor ) { | |
return; | |
} | |
let self = this; | |
jQuery( document ).on( 'input change', '.cx-checkbox-input', () => { | |
window.rankMathEditor.refresh( 'content' ); | |
} ); | |
wp.hooks.addFilter( 'rank_math_content', 'jet-engine-checkbox-seo', ( content ) => { | |
jQuery( '.cx-control-checkbox' ).each( ( groupIndex, groupEl ) => { | |
let $grEl = jQuery( groupEl ); | |
let selectedItems = []; | |
$grEl.find( 'input[checked]' ).each( ( itemIndex, itemEl ) => { | |
selectedItems.push( jQuery( itemEl ).siblings( '.cx-checkbox-label' ).text() ); | |
} ); | |
if ( selectedItems.length ) { | |
content += '\n' + $grEl.find( '.cx-control__title' ).text() + ': ' + selectedItems.join( ", " ); | |
} | |
} ); | |
return content; | |
} ); | |
} | |
getContent( content ) { | |
return content; | |
} | |
} | |
window.addEventListener( "load", ( event ) => { | |
new JetEngineCheckboxSEO(); | |
} ); | |
</script> | |
<?php | |
}, 999 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment