开发者 | delwinv |
---|---|
更新时间 | 2015年8月27日 22:43 |
PHP版本: | 3.5.0 及以上 |
WordPress版本: | 4.3 |
版权: | GPLv2 |
版权网址: | 版权信息 |
acf-plugin-wysiwyg-styling
folder to your /wp-content/plugins/
directory.Not at all. For the time being ACF doesn't add these classes to the editor, but you can do it either by installing this plugin or by placing the
following code in your functions.php file:
function acf_plugin_wysiwyg_styling() { ?>
<script>
(function($) {
acf.add_filter('wysiwyg_tinymce_settings', function(mceInit, id) {
var mceInitElements = $('#' + mceInit.elements);
var acfEditorField = mceInitElements.closest('.acf-field[data-type="wysiwyg"]');
var fieldKey = acfEditorField.data('key');
var fieldName = acfEditorField.data('name');
var flexContentName = mceInitElements.parents('[data-type="flexible_content"]').first().data('name');
var layoutName = mceInitElements.parents('[data-layout]').first().data('layout');
mceInit.body_class += " acf-field-key-" + fieldKey;
mceInit.body_class += " acf-field-name-" + fieldName;
if (flexContentName) {
mceInit.body_class += " acf-flex-name-" + flexContentName;
}
if (layoutName) {
mceInit.body_class += " acf-layout-" + layoutName;
}
return mceInit;
});
})(jQuery);
</script>
<?php
}
add_action('acf/input/admin_footer', 'acf_plugin_wysiwyg_styling');
Not with this plugin. The prefixes are hard-coded to acf-field-key-, acf-field-name-, acf-flex-name- and acf-layout-. If you wish to change these prefixes, I would suggest not using this plugin and using the code shown above in your functions.php, changing the desired prefixes in the code.
I doubt it. Hopefully the developers of ACF provide this functionality in an upcoming version themselves, since it is quite simple and really should be part of the core function. At that time, this plugin will become redundant. I look forward to that date :-)
Again, this is a plugin to provide very basic functionality that allows for complete targetting of WYSIWYG editors within the ACF framework. I don't plan on adding any functionality to the plugin. But the code is released under GPLv2, so go at it yourself if you so desire!