PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.32
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.32
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/helpers/FrmShortcodeHelper.php +71 -16 6.36.32 View file →
@@ -5,9 +5,8 @@
5 5
6 6 /**
7 7 * @since 2.02.12
8 8 */
9 -
10 9 class FrmShortcodeHelper {
11 10
12 11 /**
13 12 * Get the shortcode attributes in key/value pairs from a string
@@ -19,17 +18,65 @@
19 18 * @return array
20 19 */
21 20 public static function get_shortcode_attribute_array( $text ) {
22 21 $atts = array();
22 +
23 23 if ( $text !== '' ) {
24 24 $atts = shortcode_parse_atts( $text );
25 25 }
26 26
27 - if ( ! is_array( $atts ) ) {
28 - $atts = array();
27 + return is_array( $atts ) ? $atts : array();
28 + }
29 +
30 + /**
31 + * Returns shortcodes that are shown/hidden based on the context.
32 + *
33 + * @since 6.16.3
34 + *
35 + * @return array
36 + */
37 + public static function get_contextual_shortcodes() {
38 + return array(
39 + 'address' => array(
40 + 'admin_email' => __( 'Admin email', 'formidable' ),
41 + 'default-from-email' => __( 'Default from email', 'formidable' ),
42 + 'default-email' => __( 'Default email', 'formidable' ),
43 + ),
44 + 'body' => array(
45 + 'default-message' => __( 'Default Msg', 'formidable' ),
46 + 'default-html' => __( 'Default HTML', 'formidable' ),
47 + 'default-plain' => __( 'Default Plain', 'formidable' ),
48 + ),
49 + );
50 + }
51 +
52 + /**
53 + * Get contextual shortcodes.
54 + *
55 + * @since 6.16.3
56 + *
57 + * @return array
58 + */
59 + public static function get_contextual_shortcode_values() {
60 + $contextual_shortcodes = self::get_contextual_shortcodes();
61 + return array_merge( $contextual_shortcodes['address'], $contextual_shortcodes['body'] );
62 + }
63 +
64 + /**
65 + * Get flattened format of contextual shortcodes.
66 + *
67 + * @since 6.16.3
68 + *
69 + * @return array
70 + */
71 + public static function get_contextual_codes() {
72 + $result = array();
73 +
74 + foreach ( self::get_contextual_shortcodes() as $type => $shortcodes ) {
75 + $result[ $type ] = array_keys( $shortcodes );
29 76 }
30 77
31 - return $atts;
78 + return $result;
32 79 }
33 80
34 81 /**
35 82 * Get the name of the shortcode from the regEx
@@ -36,9 +83,9 @@
36 83 *
37 84 * @since 3.0
38 85 *
39 86 * @param array $shortcodes
40 - * @param int $short_key The position in the shortcodes array
87 + * @param int $short_key The position in the shortcodes array.
41 88 * @param array $args
42 89 *
43 90 * @return string
44 91 */
@@ -50,13 +97,15 @@
50 97 'conditional_check' => false,
51 98 'foreach' => false,
52 99 )
53 100 );
101 +
54 102 if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
55 103 $args['conditional_check'] = true;
56 104 }
57 105
58 106 $prefix = '';
107 +
59 108 if ( $args['conditional_check'] ) {
60 109 if ( $args['conditional'] ) {
61 110 $prefix = 'if ';
62 111 } elseif ( $args['foreach'] ) {
@@ -64,23 +113,29 @@
64 113 }
65 114 }
66 115
67 116 $with_tags = $args['conditional_check'] ? 3 : 2;
68 - if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
69 - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
70 - $tag = str_replace( ']', '', $tag );
71 - $tag = str_replace( chr( 194 ) . chr( 160 ), ' ', $tag );
72 - $tags = preg_split( '/\s+/', $tag, 2 );
73 - if ( is_array( $tags ) ) {
74 - $tag = $tags[0];
75 - }
76 - } else {
77 - $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
117 +
118 + if ( empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
119 + return $shortcodes[ $with_tags - 1 ][ $short_key ];
78 120 }
79 121
80 - return $tag;
122 + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
123 + $tag = str_replace( ']', '', $tag );
124 + $tag = str_replace( chr( 194 ) . chr( 160 ), ' ', $tag );
125 + $tags = preg_split( '/\s+/', $tag, 2 );
126 +
127 + return is_array( $tags ) ? $tags[0] : $tag;
81 128 }
82 129
130 + /**
131 + * @param bool $no_vars
132 + * @param string $code
133 + * @param string $replace_with
134 + * @param string $html
135 + *
136 + * @return void
137 + */
83 138 public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
84 139 if ( $no_vars ) {
85 140 $html = str_replace( '[if ' . $code . ']', '', $html );
86 141 $html = str_replace( '[/if ' . $code . ']', '', $html );