PluginProbe
EmailKit – Email Customizer for WooCommerce & WP / 1.5.4
EmailKit – Email Customizer for WooCommerce & WP v1.5.4
1.6.9 1.6.8 1.6.7 trunk 1.0.0 1.2.0 1.4.0 1.4.5 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6
emailkit / includes / Admin / EmailKitHooks.php

EmailKitHooks.php in EmailKit – Email Customizer for WooCommerce & WP 1.5.4, at includes/Admin/EmailKitHooks.php

36 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace EmailKit\Admin;
3
4 defined("ABSPATH") || exit;
5
6 class EmailKitHooks {
7
8
9 public function __construct()
10 {
11
12 add_filter('emailkit_shortcode_filter', [$this, 'replace'], 10, 2);
13 }
14
15 public function replace($input){
16
17 // Define the regular expression pattern
18 $pattern = '/<span data-shortcode="{{([\w]+)}}">([\w]+)<\/span>/';
19
20 // Use preg_match_all to find all matches in the input
21 preg_match_all($pattern, $input, $matches, PREG_SET_ORDER);
22
23 // Loop through each match and replace the content inside the span tag
24 foreach ($matches as $match) {
25 $shortcode = $match[1]; // Content inside the data-shortcode attribute
26
27 // Create the replacement string and replace the match in the input
28 $replacement = '<span data-shortcode="{{' . $shortcode . '}}">{{' . strtolower($shortcode) . '}}</span>';
29 $input = str_replace($match[0], $replacement, $input);
30 }
31
32 return $input;
33 }
34
35 }
36