Собственно для чего это. Если надо разместить, к примеру, микроразметку в визуальном редакторе, то после ставок кода
<span itemprop="streetAddress">номер дома, улица</span> <span itemprop="postalCode">почтовый индекс</span> <span itemprop="addressLocality">город, страна</span>
на выходе получим
номер дома, улица почтовый индекс город, страна
то есть, редактор сделал валидацию кода и очистил, по его мнению лишний код, а нам такое не нужно.
Как с этим бороться
Вставляем в файл функции темы (functions.php), следующий код
function my_adds_alls_elements($init) { if(current_user_can('unfiltered_html')) { $init['extended_valid_elements'] = 'span[*],div[*]'; } return $init; } add_filter('tiny_mce_before_init', 'my_adds_alls_elements', 20);
В данном случае убираю валидацию с тегов span и div.
div так же очищается если не отключить валидацию, а он часто нужен для микроразметки
Пример
номер дома, улица
почтовый индекс
город, страна
почтовый индекс
город, страна
Использую классический редактор
Appreciating the hard work you put into your website and detailed information you provide.
It’s great to come across a blog every once in a while that isn’t
the same old rehashed information. Wonderful read!
I’ve bookmarked your site and I’m adding your RSS feeds to my Google account.
This website truly has all of the information I needed about this subject and didn’t know
who to ask.
Pretty! This has been an extremely wonderful
post. Many thanks for supplying this information.
Simply desire to say your article is as astounding. The clarity
in your put up is just great and i can suppose you are a
professional in this subject. Well with your permission allow me to grasp your RSS feed to stay up to date with
drawing close post. Thanks one million and please
continue the rewarding work.
Thanks for the Feedback
At this time it looks like Movable Type is the preferred blogging
platform out there right now. (from what I’ve read) Is that what you’re using on your blog?
Blog on cms WordPress Blog.
if I will work with «Movable Type», I will definitely write about this platform
Very nice post. I just stumbled upon your weblog and wished to say that I’ve truly
enjoyed surfing around your blog posts. After all I will be subscribing to your rss
feed and I hope you write again very soon!
Howdy are using WordPress for your blog platform?
I’m new to the blog world but I’m trying to get started and set up my own. Do you need any coding expertise to make your own blog?
Any help would be greatly appreciated!
I was more than happy to uncover this site. I wanted to thank you
for ones time just for this fantastic read!! I definitely appreciated every bit of it and
I have you book-marked to check out new stuff on your web site.
Thanks for finally talking about >Отключаем удаление пустых
span тегов в визуальном редакторе (WordPress) — Грабли <Loved it!
I apologise, but, in my opinion, you are not right. I can defend the position. Write to me in PM, we will communicate.
Данный код — рабочий. Я использовал вордпресс 5.2.2 и классический редактор вместо нового блочно редактора.
Для демонстрации, что все-таки код рабочий, на странице разместил в примере кусок со span, где прописал атрибуты, и добавил в эту функцию в функции темы.
Возможно у вас есть другой вариант решения данной проблемы
Поздравляю, мне кажется это блестящая мысль
Some times its a pain in the ass to read what website owners wrote but this website is really user friendly! .
of course like your web-site however you need to test the spelling on several of your posts.
Many of them are rife with spelling issues and I find it
very bothersome to inform the truth nevertheless I will certainly come back again.
Спасибо за отзыв, учту ваше замечание.
Woah! I’m really digging the template/theme of this
blog. It’s simple, yet effective. A lot of times it’s very difficult to
get that «perfect balance» between usability and visual
appeal. I must say you’ve done a very good job with this.
In addition, the blog loads very fast for me on Firefox.
Exceptional Blog!