Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'admin_footer-post.php', function () {
- ?>
- <script type="text/javascript">
- (function ($) {
- wp.hooks.addFilter('rank_math_content', 'rank-math', function (content) {
- return content.replace(/\[woodmart_title\s+([^\]]+)\]/g, function (match, attrString) {
- const parseAttributes = (str) => {
- const attrs = {};
- const regex = /(\w+)=(["'])(.*?)\2/g;
- let m;
- while ((m = regex.exec(str)) !== null) {
- attrs[m[1]] = m[3];
- }
- return attrs;
- };
- const attrs = parseAttributes(attrString);
- const tag = attrs.tag || 'h4';
- if (attrs.title) {
- const wrappedTitle = `<${tag}>${attrs.title}</${tag}>`;
- const newAttrString = attrString.replace(/title=(["'])(.*?)\1/, `title="${wrappedTitle}"`);
- return `[woodmart_title ${newAttrString}]`;
- }
- return match;
- });
- }, 9);
- })(jQuery);
- </script>
- <?php
- });
Advertisement
Add Comment
Please, Sign In to add comment