Last active
March 20, 2016 20:56
-
-
Save bhalash/b76a93c69a502d2b66e3 to your computer and use it in GitHub Desktop.
WordPress post content content replacement
This file contains hidden or 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
| add_filter('the_content', function($content) { | |
| $bindings = [ | |
| '<img' => ['click: lightbox.show'] | |
| ]; | |
| foreach ($bindings as $tag => $directives) { | |
| $directive = sprintf('%s data-bind="%s" ', $tag, implode(', ', $directives)); | |
| $content = str_replace($tag, $directive, $content); | |
| // <img data-bind="click: lightbox.show" | |
| } | |
| return $content; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment