I clean the wordpress code
Dirty code has always bothered me, which is so often contributed by editors in various CMS. In our favorite WordPress engine, there are fewer such problems, but they still exist.. Inserting an image in a P tag feels like a prelude:
Here is the actual code I found on the net, if you have any edits please make:
1 2 3 4 5 6 |
// unautop for images fb_unautop_4_img( $content ) { $content = preg_replace( '/<p>\\s*?(<a rel=\"attachment.*?><img.*?><\\/a>|<img.*?>)?\\s*<\\/p>/s', '<figure>$1</figure>', $content ); return $content; } add_filter( 'the_content', 'fb_unautop_4_img', 99 ) |
The code is pretty primitive., since when adding attributes, it simply will not work.
/*
- Basic web design course;
- Site layout;
- General course on CMS WordPress and continuation of the course on template development;
- Website development in PHP.