Created
May 17, 2023 15:28
-
-
Save TudorSfatosu/94437a0c6d06a51e0b477722ebd17245 to your computer and use it in GitHub Desktop.
This file contains 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 | |
/* | |
* ----------------------------------------------------------------------------- | |
* Advanced Custom Fields Modifications | |
* ----------------------------------------------------------------------------- | |
*/ | |
// Only the style is working, the script is not, it might introduce bugs, but it less likely as the scroll is always active in the textarea. | |
function PREFIX_apply_acf_modifications() { | |
?> | |
<style> | |
.acf-editor-wrap textarea { | |
max-height: 150px; | |
} | |
</style> | |
<script> | |
(function($) { | |
// (filter called before the tinyMCE instance is created) | |
acf.add_filter('wysiwyg_tinymce_settings', function(mceInit, id, $field) { | |
// enable autoresizing of the WYSIWYG editor | |
mceInit.wp_autoresize_on = true; | |
return mceInit; | |
}); | |
// (action called when a WYSIWYG tinymce element has been initialized) | |
acf.add_action('wysiwyg_tinymce_init', function(ed, id, mceInit, $field) { | |
// reduce tinymce's min-height settings | |
ed.settings.autoresize_min_height = 50; | |
// reduce iframe's 'height' style to match tinymce settings | |
$('.acf-editor-wrap textarea').css('height', '150px'); | |
}); | |
})(jQuery) | |
</script> | |
<?php | |
} | |
/* | |
* ----------------------------------------------------------------------------- | |
* WordPress hooks | |
* ----------------------------------------------------------------------------- | |
*/ | |
add_action('acf/input/admin_footer', 'PREFIX_apply_acf_modifications'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment