PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 3.06.06
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v3.06.06
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 +15 -81 6.283.06.06 View file →
@@ -1,12 +1,9 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - die( 'You are not allowed to call this page directly.' );
4 -}
5 -
6 2 /**
7 3 * @since 2.02.12
8 4 */
5 +
9 6 class FrmShortcodeHelper {
10 7
11 8 /**
12 9 * Get the shortcode attributes in key/value pairs from a string
@@ -11,9 +8,8 @@
11 8 /**
12 9 * Get the shortcode attributes in key/value pairs from a string
13 10 *
14 11 * @since 2.02.12
15 - *
16 12 * @param string $text
17 13 *
18 14 * @return array
19 15 */
@@ -18,15 +14,14 @@
18 14 * @return array
19 15 */
20 16 public static function get_shortcode_attribute_array( $text ) {
21 17 $atts = array();
22 -
23 18 if ( $text !== '' ) {
24 19 $atts = shortcode_parse_atts( $text );
25 20 }
26 21
27 22 if ( ! is_array( $atts ) ) {
28 - return array();
23 + $atts = array();
29 24 }
30 25
31 26 return $atts;
32 27 }
@@ -31,66 +26,13 @@
31 26 return $atts;
32 27 }
33 28
34 29 /**
35 - * Returns shortcodes that are shown/hidden based on the context.
36 - *
37 - * @since 6.16.3
38 - *
39 - * @return array
40 - */
41 - public static function get_contextual_shortcodes() {
42 - return array(
43 - 'address' => array(
44 - 'admin_email' => __( 'Admin email', 'formidable' ),
45 - 'default-from-email' => __( 'Default from email', 'formidable' ),
46 - 'default-email' => __( 'Default email', 'formidable' ),
47 - ),
48 - 'body' => array(
49 - 'default-message' => __( 'Default Msg', 'formidable' ),
50 - 'default-html' => __( 'Default HTML', 'formidable' ),
51 - 'default-plain' => __( 'Default Plain', 'formidable' ),
52 - ),
53 - );
54 - }
55 -
56 - /**
57 - * Get contextual shortcodes.
58 - *
59 - * @since 6.16.3
60 - *
61 - * @return array
62 - */
63 - public static function get_contextual_shortcode_values() {
64 - $contextual_shortcodes = self::get_contextual_shortcodes();
65 - return array_merge( $contextual_shortcodes['address'], $contextual_shortcodes['body'] );
66 - }
67 -
68 - /**
69 - * Get flattened format of contextual shortcodes.
70 - *
71 - * @since 6.16.3
72 - *
73 - * @return array
74 - */
75 - public static function get_contextual_codes() {
76 - $contextual_shortcodes = self::get_contextual_shortcodes();
77 - $result = array();
78 -
79 - foreach ( $contextual_shortcodes as $type => $shortcodes ) {
80 - $result[ $type ] = array_keys( $shortcodes );
81 - }
82 -
83 - return $result;
84 - }
85 -
86 - /**
87 30 * Get the name of the shortcode from the regEx
88 31 *
89 32 * @since 3.0
90 - *
91 33 * @param array $shortcodes
92 - * @param int $short_key The position in the shortcodes array.
34 + * @param int $short_key The position in the shortcodes array
93 35 * @param array $args
94 36 *
95 37 * @return string
96 38 */
@@ -102,45 +44,37 @@
102 44 'conditional_check' => false,
103 45 'foreach' => false,
104 46 )
105 47 );
106 -
107 48 if ( ( $args['conditional'] || $args['foreach'] ) && ! $args['conditional_check'] ) {
108 49 $args['conditional_check'] = true;
109 50 }
110 51
111 52 $prefix = '';
112 -
113 53 if ( $args['conditional_check'] ) {
114 54 if ( $args['conditional'] ) {
115 55 $prefix = 'if ';
116 - } elseif ( $args['foreach'] ) {
56 + } else if ( $args['foreach'] ) {
117 57 $prefix = 'foreach ';
118 58 }
119 59 }
120 60
121 61 $with_tags = $args['conditional_check'] ? 3 : 2;
122 -
123 - if ( empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
124 - return $shortcodes[ $with_tags - 1 ][ $short_key ];
62 + if ( ! empty( $shortcodes[ $with_tags ][ $short_key ] ) ) {
63 + $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
64 + $tag = str_replace( ']', '', $tag );
65 + $tag = str_replace( chr( 194 ) . chr( 160 ), ' ', $tag );
66 + $tags = preg_split( '/\s+/', $tag, 2 );
67 + if ( is_array( $tags ) ) {
68 + $tag = $tags[0];
69 + }
70 + } else {
71 + $tag = $shortcodes[ $with_tags - 1 ][ $short_key ];
125 72 }
126 73
127 - $tag = str_replace( '[' . $prefix, '', $shortcodes[0][ $short_key ] );
128 - $tag = str_replace( ']', '', $tag );
129 - $tag = str_replace( chr( 194 ) . chr( 160 ), ' ', $tag );
130 - $tags = preg_split( '/\s+/', $tag, 2 );
131 -
132 - return is_array( $tags ) ? $tags[0] : $tag;
74 + return $tag;
133 75 }
134 76
135 - /**
136 - * @param bool $no_vars
137 - * @param string $code
138 - * @param string $replace_with
139 - * @param string $html
140 - *
141 - * @return void
142 - */
143 77 public static function remove_inline_conditions( $no_vars, $code, $replace_with, &$html ) {
144 78 if ( $no_vars ) {
145 79 $html = str_replace( '[if ' . $code . ']', '', $html );
146 80 $html = str_replace( '[/if ' . $code . ']', '', $html );