PluginProbe
EmailKit – Email Customizer for WooCommerce & WP / 1.2.0
EmailKit – Email Customizer for WooCommerce & WP v1.2.0
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.2.0, at includes/Admin/EmailKitHooks.php

37 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
16 public function replace($input){
17
18 // Define the regular expression pattern
19 $pattern = '/<span data-shortcode="{{([\w]+)}}">([\w]+)<\/span>/';
20
21 // Use preg_match_all to find all matches in the input
22 preg_match_all($pattern, $input, $matches, PREG_SET_ORDER);
23
24 // Loop through each match and replace the content inside the span tag
25 foreach ($matches as $match) {
26 $shortcode = $match[1]; // Content inside the data-shortcode attribute
27
28 // Create the replacement string and replace the match in the input
29 $replacement = '<span data-shortcode="{{' . $shortcode . '}}">{{' . strtolower($shortcode) . '}}</span>';
30 $input = str_replace($match[0], $replacement, $input);
31 }
32
33 return $input;
34 }
35
36 }
37