PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / trunk
JetFormBuilder — Dynamic Blocks Form Builder vtrunk
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / classes / regexp-tools.php
jetformbuilder / includes / classes Last commit date
arguments 1 year ago arrayable 2 years ago filters 1 year ago http 2 years ago macro-constants 2 years ago post 1 year ago resources 2 months ago theme 2 years ago value-normalizers 1 month ago attributes-trait.php 2 years ago base-attributes-trait.php 2 years ago builder-helper.php 1 year ago compatibility.php 2 years ago date-tools.php 2 years ago gallery.php 2 years ago get-icon-trait.php 2 years ago get-template-trait.php 2 years ago html-attributes-trait.php 2 years ago instance-trait.php 2 years ago regexp-tools.php 2 years ago tools.php 2 weeks ago
regexp-tools.php
78 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Classes;
5
6 // If this file is called directly, abort.
7 if ( ! defined( 'WPINC' ) ) {
8 die;
9 }
10
11 class Regexp_Tools {
12
13 private $field_names_regexp = array();
14 private $macro_exist = false;
15
16 public function has_macro( $value ): bool {
17 if ( ! is_scalar( $value ) || ! is_string( $value ) ) {
18 return false;
19 }
20
21 if ( preg_match( '/%[\w\-]+::.*?%/', $value ) ) {
22 return true;
23 }
24
25 $this->macro_exist = false;
26
27 preg_replace_callback_array(
28 $this->field_names_regexp,
29 $value
30 );
31
32 return $this->macro_exist;
33 }
34
35 public function set_field_names( array $names ) {
36 foreach ( $names as $name => $counter ) {
37 $this->field_names_regexp[ "/%({$name}).*?%/" ] = array( $this, 'regexp_replace_callback' );
38 }
39 }
40
41 /**
42 * @param array $matches
43 *
44 * @return mixed
45 */
46 private function regexp_replace_callback( array $matches ) {
47 $this->macro_exist = true;
48
49 return $matches[0];
50 }
51
52 /**
53 * @param string $content
54 *
55 * @return array
56 */
57 public function get_form_ids_from_shortcode( string $content ): array {
58 $matches = array();
59
60 preg_match_all( '/\[jet_fb_form.*?form_id="(\d+)"/', $content, $matches );
61
62 return $matches[1] ?? array();
63 }
64
65 public function get_form_ids_from_block( string $content ): array {
66 $matches = array();
67
68 preg_match_all(
69 '/<!-- wp:jet\-forms\/form\-block.*?"form_id":(\d+)/',
70 $content,
71 $matches
72 );
73
74 return $matches[1] ?? array();
75 }
76
77 }
78