Add php code to wp_print_scripts?
Is there a way to add inline php code to the editor using wp_print_scripts
? I'm trying to find a way to display text from a php string into a value of input of a block.
Here's my code:
function shapeSpace_print_scripts() {
?
?php $block_yt_url = 'test';?
script
jQuery(document).ready(function ($) {
let $yt_url = false;
$(document).on( click, '#yt_run .acf-button-group', function() {
$(.editor-post-publish-button__button).hide();
$(.acf-block-body div div.acf-block-fields.acf-fields div.acf-field.acf-field-text.acf-field-6260f423f1666).css({'height':'inherit','padding':'16px 20px','overflow':'inherit'});
$(.acf-block-body div div.acf-block-fields.acf-fields div.acf-field.acf-field-text.acf-field-6260f423f1666).val(?php echo $block_yt_url;?);
$('#yt_url .acf-input input').keyup(function(e) {
if(e.keyCode == 13) {
$yt_url = true;
};
if(e.keyCode == 46) {
$yt_url = true;
};
if(e.keyCode == 8) {
$yt_url = true;
};
checkStatus();
});
});
function checkStatus(){
if($yt_url) {
$(.editor-post-publish-button__button).show();
}
}
});
/script
?php
}
add_action('wp_print_scripts', 'shapeSpace_print_scripts');
Topic block-editor advanced-custom-fields functions jquery Wordpress
Category Web