@@ -1,67 +1,67 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class FrmStylesHelper { |
3 | 3 | |
4 | - public static function jquery_themes() { |
|
5 | - $themes = array( |
|
6 | - 'ui-lightness' => 'UI Lightness', |
|
7 | - 'ui-darkness' => 'UI Darkness', |
|
8 | - 'smoothness' => 'Smoothness', |
|
9 | - 'start' => 'Start', |
|
10 | - 'redmond' => 'Redmond', |
|
11 | - 'sunny' => 'Sunny', |
|
12 | - 'overcast' => 'Overcast', |
|
13 | - 'le-frog' => 'Le Frog', |
|
14 | - 'flick' => 'Flick', |
|
4 | + public static function jquery_themes() { |
|
5 | + $themes = array( |
|
6 | + 'ui-lightness' => 'UI Lightness', |
|
7 | + 'ui-darkness' => 'UI Darkness', |
|
8 | + 'smoothness' => 'Smoothness', |
|
9 | + 'start' => 'Start', |
|
10 | + 'redmond' => 'Redmond', |
|
11 | + 'sunny' => 'Sunny', |
|
12 | + 'overcast' => 'Overcast', |
|
13 | + 'le-frog' => 'Le Frog', |
|
14 | + 'flick' => 'Flick', |
|
15 | 15 | 'pepper-grinder' => 'Pepper Grinder', |
16 | - 'eggplant' => 'Eggplant', |
|
17 | - 'dark-hive' => 'Dark Hive', |
|
18 | - 'cupertino' => 'Cupertino', |
|
19 | - 'south-street' => 'South Street', |
|
20 | - 'blitzer' => 'Blitzer', |
|
21 | - 'humanity' => 'Humanity', |
|
22 | - 'hot-sneaks' => 'Hot Sneaks', |
|
23 | - 'excite-bike' => 'Excite Bike', |
|
24 | - 'vader' => 'Vader', |
|
25 | - 'dot-luv' => 'Dot Luv', |
|
26 | - 'mint-choc' => 'Mint Choc', |
|
27 | - 'black-tie' => 'Black Tie', |
|
28 | - 'trontastic' => 'Trontastic', |
|
29 | - 'swanky-purse' => 'Swanky Purse', |
|
30 | - ); |
|
31 | - |
|
32 | - $themes = apply_filters('frm_jquery_themes', $themes); |
|
33 | - return $themes; |
|
34 | - } |
|
16 | + 'eggplant' => 'Eggplant', |
|
17 | + 'dark-hive' => 'Dark Hive', |
|
18 | + 'cupertino' => 'Cupertino', |
|
19 | + 'south-street' => 'South Street', |
|
20 | + 'blitzer' => 'Blitzer', |
|
21 | + 'humanity' => 'Humanity', |
|
22 | + 'hot-sneaks' => 'Hot Sneaks', |
|
23 | + 'excite-bike' => 'Excite Bike', |
|
24 | + 'vader' => 'Vader', |
|
25 | + 'dot-luv' => 'Dot Luv', |
|
26 | + 'mint-choc' => 'Mint Choc', |
|
27 | + 'black-tie' => 'Black Tie', |
|
28 | + 'trontastic' => 'Trontastic', |
|
29 | + 'swanky-purse' => 'Swanky Purse', |
|
30 | + ); |
|
31 | + |
|
32 | + $themes = apply_filters('frm_jquery_themes', $themes); |
|
33 | + return $themes; |
|
34 | + } |
|
35 | 35 | |
36 | 36 | public static function jquery_css_url( $theme_css ) { |
37 | - if ( $theme_css == -1 ) { |
|
38 | - return; |
|
39 | - } |
|
40 | - |
|
41 | - if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
42 | - $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
43 | - } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
44 | - $css_file = $theme_css; |
|
45 | - } else { |
|
46 | - $uploads = self::get_upload_base(); |
|
37 | + if ( $theme_css == -1 ) { |
|
38 | + return; |
|
39 | + } |
|
40 | + |
|
41 | + if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
42 | + $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
43 | + } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
44 | + $css_file = $theme_css; |
|
45 | + } else { |
|
46 | + $uploads = self::get_upload_base(); |
|
47 | 47 | $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css'; |
48 | - if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
49 | - $css_file = $uploads['baseurl'] . $file_path; |
|
50 | - } else { |
|
48 | + if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
49 | + $css_file = $uploads['baseurl'] . $file_path; |
|
50 | + } else { |
|
51 | 51 | $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css'; |
52 | - } |
|
53 | - } |
|
52 | + } |
|
53 | + } |
|
54 | 54 | |
55 | - return $css_file; |
|
56 | - } |
|
55 | + return $css_file; |
|
56 | + } |
|
57 | 57 | |
58 | - public static function enqueue_jquery_css() { |
|
58 | + public static function enqueue_jquery_css() { |
|
59 | 59 | $form = self::get_form_for_page(); |
60 | 60 | $theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
61 | - if ( $theme_css != -1 ) { |
|
62 | - wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
63 | - } |
|
64 | - } |
|
61 | + if ( $theme_css != -1 ) { |
|
62 | + wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | 66 | public static function get_form_for_page() { |
67 | 67 | global $frm_vars; |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | return $form_id; |
78 | 78 | } |
79 | 79 | |
80 | - public static function get_upload_base() { |
|
81 | - $uploads = wp_upload_dir(); |
|
82 | - if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
83 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
84 | - } |
|
80 | + public static function get_upload_base() { |
|
81 | + $uploads = wp_upload_dir(); |
|
82 | + if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
83 | + $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
84 | + } |
|
85 | 85 | |
86 | - return $uploads; |
|
87 | - } |
|
86 | + return $uploads; |
|
87 | + } |
|
88 | 88 | |
89 | 89 | public static function style_menu( $active = '' ) { |
90 | 90 | ?> |
@@ -94,22 +94,22 @@ discard block |
||
94 | 94 | <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
95 | 95 | </h2> |
96 | 96 | <?php |
97 | - } |
|
97 | + } |
|
98 | 98 | |
99 | - public static function minus_icons() { |
|
100 | - return array( |
|
99 | + public static function minus_icons() { |
|
100 | + return array( |
|
101 | 101 | 0 => array( '-' => '62e', '+' => '62f' ), |
102 | 102 | 1 => array( '-' => '600', '+' => '602' ), |
103 | 103 | 2 => array( '-' => '604', '+' => '603' ), |
104 | 104 | 3 => array( '-' => '633', '+' => '632' ), |
105 | 105 | 4 => array( '-' => '613', '+' => '60f' ), |
106 | - ); |
|
107 | - } |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | |
109 | - public static function arrow_icons() { |
|
110 | - $minus_icons = self::minus_icons(); |
|
109 | + public static function arrow_icons() { |
|
110 | + $minus_icons = self::minus_icons(); |
|
111 | 111 | |
112 | - return array( |
|
112 | + return array( |
|
113 | 113 | 6 => array( '-' => '62d', '+' => '62a' ), |
114 | 114 | 0 => array( '-' => '60d', '+' => '609' ), |
115 | 115 | 1 => array( '-' => '60e', '+' => '60c' ), |
@@ -117,44 +117,44 @@ discard block |
||
117 | 117 | 3 => array( '-' => '62b', '+' => '628' ), |
118 | 118 | 4 => array( '-' => '62c', '+' => '629' ), |
119 | 119 | 5 => array( '-' => '635', '+' => '634' ), |
120 | - 'p0' => $minus_icons[0], |
|
121 | - 'p1' => $minus_icons[1], |
|
122 | - 'p2' => $minus_icons[2], |
|
123 | - 'p3' => $minus_icons[3], |
|
124 | - 'p4' => $minus_icons[4], |
|
125 | - ); |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @since 2.0 |
|
130 | - * @return The class for this icon |
|
131 | - */ |
|
120 | + 'p0' => $minus_icons[0], |
|
121 | + 'p1' => $minus_icons[1], |
|
122 | + 'p2' => $minus_icons[2], |
|
123 | + 'p3' => $minus_icons[3], |
|
124 | + 'p4' => $minus_icons[4], |
|
125 | + ); |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * @since 2.0 |
|
130 | + * @return The class for this icon |
|
131 | + */ |
|
132 | 132 | public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) { |
133 | - if ( 'arrow' == $type && is_numeric($key) ) { |
|
134 | - //frm_arrowup6_icon |
|
133 | + if ( 'arrow' == $type && is_numeric($key) ) { |
|
134 | + //frm_arrowup6_icon |
|
135 | 135 | $arrow = array( '-' => 'down', '+' => 'up' ); |
136 | 136 | $class = 'frm_arrow' . $arrow[ $icon ]; |
137 | - } else { |
|
138 | - //frm_minus1_icon |
|
139 | - $key = str_replace('p', '', $key); |
|
137 | + } else { |
|
138 | + //frm_minus1_icon |
|
139 | + $key = str_replace('p', '', $key); |
|
140 | 140 | $plus = array( '-' => 'minus', '+' => 'plus' ); |
141 | 141 | $class = 'frm_' . $plus[ $icon ]; |
142 | - } |
|
142 | + } |
|
143 | 143 | |
144 | - if ( $key ) { |
|
145 | - $class .= $key; |
|
146 | - } |
|
147 | - $class .= '_icon'; |
|
144 | + if ( $key ) { |
|
145 | + $class .= $key; |
|
146 | + } |
|
147 | + $class .= '_icon'; |
|
148 | 148 | |
149 | - return $class; |
|
150 | - } |
|
149 | + return $class; |
|
150 | + } |
|
151 | 151 | |
152 | 152 | public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) { |
153 | 153 | $function_name = $type . '_icons'; |
154 | 154 | $icons = self::$function_name(); |
155 | 155 | unset( $function_name ); |
156 | 156 | |
157 | - $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
|
157 | + $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
|
158 | 158 | ?> |
159 | 159 | <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
160 | 160 | <?php foreach ( $icons as $key => $icon ) { ?> |
@@ -187,24 +187,24 @@ discard block |
||
187 | 187 | </ul> |
188 | 188 | </div> |
189 | 189 | <?php |
190 | - } |
|
190 | + } |
|
191 | 191 | |
192 | 192 | public static function hex2rgb( $hex ) { |
193 | - $hex = str_replace('#', '', $hex); |
|
193 | + $hex = str_replace('#', '', $hex); |
|
194 | 194 | |
195 | - if ( strlen($hex) == 3 ) { |
|
195 | + if ( strlen($hex) == 3 ) { |
|
196 | 196 | $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) ); |
197 | 197 | $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) ); |
198 | 198 | $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) ); |
199 | - } else { |
|
199 | + } else { |
|
200 | 200 | $r = hexdec( substr( $hex, 0, 2 ) ); |
201 | 201 | $g = hexdec( substr( $hex, 2, 2 ) ); |
202 | 202 | $b = hexdec( substr( $hex, 4, 2 ) ); |
203 | - } |
|
203 | + } |
|
204 | 204 | $rgb = array( $r, $g, $b ); |
205 | - return implode(',', $rgb); // returns the rgb values separated by commas |
|
206 | - //return $rgb; // returns an array with the rgb values |
|
207 | - } |
|
205 | + return implode(',', $rgb); // returns the rgb values separated by commas |
|
206 | + //return $rgb; // returns an array with the rgb values |
|
207 | + } |
|
208 | 208 | |
209 | 209 | /** |
210 | 210 | * @since 2.3 |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | if ( self::previewing_style() ) { |
214 | 214 | if ( isset( $_GET['frm_style_setting'] ) ) { |
215 | 215 | $settings = $_GET['frm_style_setting']['post_content']; |
216 | - } else { |
|
217 | - $settings = $_GET; |
|
218 | - } |
|
216 | + } else { |
|
217 | + $settings = $_GET; |
|
218 | + } |
|
219 | 219 | |
220 | 220 | $style_name = FrmAppHelper::simple_get( 'style_name', 'sanitize_title' ); |
221 | 221 | $settings['style_class'] = ''; |
222 | 222 | if ( ! empty( $style_name ) ) { |
223 | 223 | $settings['style_class'] = $style_name . '.'; |
224 | - } |
|
224 | + } |
|
225 | 225 | } else { |
226 | - $settings = $style->post_content; |
|
226 | + $settings = $style->post_content; |
|
227 | 227 | $settings['style_class'] = 'frm_style_' . $style->post_name . '.'; |
228 | 228 | } |
229 | 229 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | 'swanky-purse' => 'Swanky Purse', |
30 | 30 | ); |
31 | 31 | |
32 | - $themes = apply_filters('frm_jquery_themes', $themes); |
|
32 | + $themes = apply_filters( 'frm_jquery_themes', $themes ); |
|
33 | 33 | return $themes; |
34 | 34 | } |
35 | 35 | |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | |
41 | 41 | if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
42 | 42 | $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
43 | - } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
43 | + } else if ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) { |
|
44 | 44 | $css_file = $theme_css; |
45 | 45 | } else { |
46 | 46 | $uploads = self::get_upload_base(); |
47 | 47 | $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css'; |
48 | - if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
48 | + if ( file_exists( $uploads['basedir'] . $file_path ) ) { |
|
49 | 49 | $css_file = $uploads['baseurl'] . $file_path; |
50 | 50 | } else { |
51 | 51 | $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css'; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $form = self::get_form_for_page(); |
60 | 60 | $theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
61 | 61 | if ( $theme_css != -1 ) { |
62 | - wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
62 | + wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() ); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | |
80 | 80 | public static function get_upload_base() { |
81 | 81 | $uploads = wp_upload_dir(); |
82 | - if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
83 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
82 | + if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) { |
|
83 | + $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $uploads; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | <h2 class="nav-tab-wrapper"> |
92 | 92 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Edit Styles', 'formidable' ) ?></a> |
93 | 93 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Manage Form Styles', 'formidable' ) ?></a> |
94 | - <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
|
94 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
|
95 | 95 | </h2> |
96 | 96 | <?php |
97 | 97 | } |
@@ -130,15 +130,15 @@ discard block |
||
130 | 130 | * @return The class for this icon |
131 | 131 | */ |
132 | 132 | public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) { |
133 | - if ( 'arrow' == $type && is_numeric($key) ) { |
|
133 | + if ( 'arrow' == $type && is_numeric( $key ) ) { |
|
134 | 134 | //frm_arrowup6_icon |
135 | 135 | $arrow = array( '-' => 'down', '+' => 'up' ); |
136 | - $class = 'frm_arrow' . $arrow[ $icon ]; |
|
136 | + $class = 'frm_arrow' . $arrow[$icon]; |
|
137 | 137 | } else { |
138 | 138 | //frm_minus1_icon |
139 | - $key = str_replace('p', '', $key); |
|
139 | + $key = str_replace( 'p', '', $key ); |
|
140 | 140 | $plus = array( '-' => 'minus', '+' => 'plus' ); |
141 | - $class = 'frm_' . $plus[ $icon ]; |
|
141 | + $class = 'frm_' . $plus[$icon]; |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | if ( $key ) { |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | |
157 | 157 | $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
158 | 158 | ?> |
159 | - <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
|
159 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
|
160 | 160 | <?php foreach ( $icons as $key => $icon ) { ?> |
161 | - <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>> |
|
161 | + <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>> |
|
162 | 162 | <?php echo '' . $icon['+'] . '; ' . $icon['-'] . ';'; ?> |
163 | 163 | </option> |
164 | 164 | <?php } ?> |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | |
167 | 167 | <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select"> |
168 | 168 | <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button"> |
169 | - <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i> |
|
170 | - <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i> |
|
169 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i> |
|
170 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i> |
|
171 | 171 | <b class="caret"></b> |
172 | 172 | </button> |
173 | 173 | <ul class="multiselect-container frm-dropdown-menu"> |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | public static function hex2rgb( $hex ) { |
193 | - $hex = str_replace('#', '', $hex); |
|
193 | + $hex = str_replace( '#', '', $hex ); |
|
194 | 194 | |
195 | - if ( strlen($hex) == 3 ) { |
|
195 | + if ( strlen( $hex ) == 3 ) { |
|
196 | 196 | $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) ); |
197 | 197 | $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) ); |
198 | 198 | $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) ); |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $b = hexdec( substr( $hex, 4, 2 ) ); |
203 | 203 | } |
204 | 204 | $rgb = array( $r, $g, $b ); |
205 | - return implode(',', $rgb); // returns the rgb values separated by commas |
|
205 | + return implode( ',', $rgb ); // returns the rgb values separated by commas |
|
206 | 206 | //return $rgb; // returns an array with the rgb values |
207 | 207 | } |
208 | 208 | |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | |
234 | 234 | $checkbox_opts = array( 'important_style', 'auto_width', 'submit_style', 'collapse_icon', 'center_form' ); |
235 | 235 | foreach ( $checkbox_opts as $opt ) { |
236 | - if ( ! isset( $settings[ $opt ] ) ) { |
|
237 | - $settings[ $opt ] = 0; |
|
236 | + if ( ! isset( $settings[$opt] ) ) { |
|
237 | + $settings[$opt] = 0; |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $colors = self::allow_color_override(); |
251 | 251 | foreach ( $colors as $css => $opts ) { |
252 | 252 | foreach ( $opts as $opt ) { |
253 | - self::get_color_output( $css, $settings[ $opt ] ); |
|
253 | + self::get_color_output( $css, $settings[$opt] ); |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | } |
@@ -6,10 +6,10 @@ discard block |
||
6 | 6 | protected $field; |
7 | 7 | |
8 | 8 | public function prepare_items() { |
9 | - global $per_page; |
|
9 | + global $per_page; |
|
10 | 10 | |
11 | 11 | $per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' ); |
12 | - $form_id = $this->params['form']; |
|
12 | + $form_id = $this->params['form']; |
|
13 | 13 | |
14 | 14 | $default_orderby = 'id'; |
15 | 15 | $default_order = 'DESC'; |
@@ -21,25 +21,25 @@ discard block |
||
21 | 21 | |
22 | 22 | $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
23 | 23 | |
24 | - if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
|
25 | - $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
|
26 | - $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); |
|
27 | - } |
|
24 | + if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
|
25 | + $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
|
26 | + $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid ); |
|
27 | + } |
|
28 | 28 | |
29 | - $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
|
30 | - if ( strpos($orderby, 'meta') !== false ) { |
|
31 | - $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
|
29 | + $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
|
30 | + if ( strpos($orderby, 'meta') !== false ) { |
|
31 | + $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
|
32 | 32 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
33 | - } |
|
33 | + } |
|
34 | 34 | |
35 | 35 | $order = isset( $_REQUEST['order'] ) ? sanitize_title( $_REQUEST['order'] ) : $default_order; |
36 | 36 | $order = ' ORDER BY ' . $orderby . ' ' . $order; |
37 | 37 | |
38 | - $page = $this->get_pagenum(); |
|
38 | + $page = $this->get_pagenum(); |
|
39 | 39 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
40 | 40 | |
41 | 41 | $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false ); |
42 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
42 | + $total_items = FrmEntry::getRecordCount($s_query); |
|
43 | 43 | |
44 | 44 | $this->set_pagination_args( array( |
45 | 45 | 'total_items' => $total_items, |
@@ -48,17 +48,17 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | public function no_items() { |
51 | - $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
|
52 | - if ( ! empty($s) ) { |
|
53 | - _e( 'No Entries Found', 'formidable' ); |
|
54 | - return; |
|
55 | - } |
|
56 | - |
|
57 | - $form_id = $form = $this->params['form']; |
|
58 | - if ( $form_id ) { |
|
59 | - $form = FrmForm::getOne($form_id); |
|
60 | - } |
|
61 | - $colspan = $this->get_column_count(); |
|
51 | + $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
|
52 | + if ( ! empty($s) ) { |
|
53 | + _e( 'No Entries Found', 'formidable' ); |
|
54 | + return; |
|
55 | + } |
|
56 | + |
|
57 | + $form_id = $form = $this->params['form']; |
|
58 | + if ( $form_id ) { |
|
59 | + $form = FrmForm::getOne($form_id); |
|
60 | + } |
|
61 | + $colspan = $this->get_column_count(); |
|
62 | 62 | |
63 | 63 | include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php' ); |
64 | 64 | } |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | - * Gets the name of the primary column in the Entries screen |
|
72 | - * |
|
73 | - * @since 2.0.14 |
|
74 | - * |
|
75 | - * @return string $primary_column |
|
76 | - */ |
|
71 | + * Gets the name of the primary column in the Entries screen |
|
72 | + * |
|
73 | + * @since 2.0.14 |
|
74 | + * |
|
75 | + * @return string $primary_column |
|
76 | + */ |
|
77 | 77 | protected function get_primary_column_name() { |
78 | 78 | $columns = get_column_headers( $this->screen ); |
79 | 79 | $hidden = get_hidden_columns( $this->screen ); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | $this->get_actions( $actions, $item, $view_link ); |
99 | 99 | |
100 | - $action_links = $this->row_actions( $actions ); |
|
100 | + $action_links = $this->row_actions( $actions ); |
|
101 | 101 | |
102 | 102 | // Set up the checkbox ( because the user is editable, otherwise its empty ) |
103 | 103 | $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />"; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | $r = "<tr id='item-action-{$item->id}'$style>"; |
106 | 106 | |
107 | 107 | list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
108 | - $action_col = false; |
|
108 | + $action_col = false; |
|
109 | 109 | |
110 | 110 | foreach ( $columns as $column_name => $column_display_name ) { |
111 | 111 | $class = $column_name . ' column-' . $column_name; |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | if ( in_array( $column_name, $hidden ) ) { |
118 | 118 | $class .= ' frm_hidden'; |
119 | 119 | } else if ( ! $action_col && ! in_array( $column_name, array( 'cb', 'id', 'form_id', 'post_id' ) ) ) { |
120 | - $action_col = $column_name; |
|
121 | - } |
|
120 | + $action_col = $column_name; |
|
121 | + } |
|
122 | 122 | |
123 | 123 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
124 | 124 | unset($class); |
@@ -134,30 +134,30 @@ discard block |
||
134 | 134 | case 'ip': |
135 | 135 | case 'id': |
136 | 136 | case 'item_key': |
137 | - $val = $item->{$col_name}; |
|
138 | - break; |
|
137 | + $val = $item->{$col_name}; |
|
138 | + break; |
|
139 | 139 | case 'name': |
140 | 140 | case 'description': |
141 | - $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
142 | - break; |
|
141 | + $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
142 | + break; |
|
143 | 143 | case 'created_at': |
144 | 144 | case 'updated_at': |
145 | - $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
145 | + $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
146 | 146 | $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>'; |
147 | 147 | break; |
148 | 148 | case 'is_draft': |
149 | - $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
150 | - break; |
|
149 | + $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
150 | + break; |
|
151 | 151 | case 'form_id': |
152 | - $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
153 | - break; |
|
152 | + $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
153 | + break; |
|
154 | 154 | case 'post_id': |
155 | - $val = FrmAppHelper::post_edit_link($item->post_id); |
|
156 | - break; |
|
155 | + $val = FrmAppHelper::post_edit_link($item->post_id); |
|
156 | + break; |
|
157 | 157 | case 'user_id': |
158 | - $user = get_userdata($item->user_id); |
|
159 | - $val = $user->user_login; |
|
160 | - break; |
|
158 | + $user = get_userdata($item->user_id); |
|
159 | + $val = $user->user_login; |
|
160 | + break; |
|
161 | 161 | default: |
162 | 162 | $val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) ); |
163 | 163 | if ( $val === false ) { |
@@ -167,15 +167,15 @@ discard block |
||
167 | 167 | } |
168 | 168 | |
169 | 169 | if ( isset( $val ) ) { |
170 | - $r .= "<td $attributes>"; |
|
170 | + $r .= "<td $attributes>"; |
|
171 | 171 | if ( $column_name == $action_col ) { |
172 | 172 | $edit_link = '?page=formidable-entries&frm_action=edit&id=' . $item->id; |
173 | 173 | $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> '; |
174 | - $r .= $action_links; |
|
174 | + $r .= $action_links; |
|
175 | 175 | } else { |
176 | - $r .= $val; |
|
177 | - } |
|
178 | - $r .= '</td>'; |
|
176 | + $r .= $val; |
|
177 | + } |
|
178 | + $r .= '</td>'; |
|
179 | 179 | } |
180 | 180 | unset($val); |
181 | 181 | } |
@@ -184,19 +184,19 @@ discard block |
||
184 | 184 | return $r; |
185 | 185 | } |
186 | 186 | |
187 | - /** |
|
188 | - * @param string $view_link |
|
189 | - */ |
|
190 | - private function get_actions( &$actions, $item, $view_link ) { |
|
187 | + /** |
|
188 | + * @param string $view_link |
|
189 | + */ |
|
190 | + private function get_actions( &$actions, $item, $view_link ) { |
|
191 | 191 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
192 | 192 | |
193 | - if ( current_user_can('frm_delete_entries') ) { |
|
193 | + if ( current_user_can('frm_delete_entries') ) { |
|
194 | 194 | $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
195 | 195 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
196 | - } |
|
196 | + } |
|
197 | 197 | |
198 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
199 | - } |
|
198 | + $actions = apply_filters('frm_row_actions', $actions, $item); |
|
199 | + } |
|
200 | 200 | |
201 | 201 | private function get_column_value( $item, &$val ) { |
202 | 202 | $col_name = $this->column_name; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | $s_query['it.form_id'] = $form_id; |
20 | 20 | } |
21 | 21 | |
22 | - $s = isset( $_REQUEST['s'] ) ? stripslashes($_REQUEST['s']) : ''; |
|
22 | + $s = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : ''; |
|
23 | 23 | |
24 | 24 | if ( $s != '' && FrmAppHelper::pro_is_installed() ) { |
25 | 25 | $fid = isset( $_REQUEST['fid'] ) ? sanitize_title( $_REQUEST['fid'] ) : ''; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | } |
28 | 28 | |
29 | 29 | $orderby = isset( $_REQUEST['orderby'] ) ? sanitize_title( $_REQUEST['orderby'] ) : $default_orderby; |
30 | - if ( strpos($orderby, 'meta') !== false ) { |
|
30 | + if ( strpos( $orderby, 'meta' ) !== false ) { |
|
31 | 31 | $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) ); |
32 | 32 | $orderby .= in_array( $order_field_type, array( 'number', 'scale' ) ) ? ' +0 ' : ''; |
33 | 33 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | $start = (int) isset( $_REQUEST['start'] ) ? absint( $_REQUEST['start'] ) : ( ( $page - 1 ) * $per_page ); |
40 | 40 | |
41 | 41 | $this->items = FrmEntry::getAll( $s_query, $order, ' LIMIT ' . $start . ',' . $per_page, true, false ); |
42 | - $total_items = FrmEntry::getRecordCount($s_query); |
|
42 | + $total_items = FrmEntry::getRecordCount( $s_query ); |
|
43 | 43 | |
44 | 44 | $this->set_pagination_args( array( |
45 | 45 | 'total_items' => $total_items, |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | |
50 | 50 | public function no_items() { |
51 | 51 | $s = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; |
52 | - if ( ! empty($s) ) { |
|
52 | + if ( ! empty( $s ) ) { |
|
53 | 53 | _e( 'No Entries Found', 'formidable' ); |
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | 57 | $form_id = $form = $this->params['form']; |
58 | 58 | if ( $form_id ) { |
59 | - $form = FrmForm::getOne($form_id); |
|
59 | + $form = FrmForm::getOne( $form_id ); |
|
60 | 60 | } |
61 | 61 | $colspan = $this->get_column_count(); |
62 | 62 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | $r = "<tr id='item-action-{$item->id}'$style>"; |
106 | 106 | |
107 | - list( $columns, $hidden, , $primary ) = $this->get_column_info(); |
|
107 | + list( $columns, $hidden,, $primary ) = $this->get_column_info(); |
|
108 | 108 | $action_col = false; |
109 | 109 | |
110 | 110 | foreach ( $columns as $column_name => $column_display_name ) { |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | $attributes = 'class="' . esc_attr( $class ) . '"'; |
124 | - unset($class); |
|
124 | + unset( $class ); |
|
125 | 125 | $attributes .= ' data-colname="' . $column_display_name . '"'; |
126 | 126 | |
127 | 127 | $col_name = preg_replace( '/^(' . $this->params['form'] . '_)/', '', $column_name ); |
@@ -138,24 +138,24 @@ discard block |
||
138 | 138 | break; |
139 | 139 | case 'name': |
140 | 140 | case 'description': |
141 | - $val = FrmAppHelper::truncate(strip_tags($item->{$col_name}), 100); |
|
141 | + $val = FrmAppHelper::truncate( strip_tags( $item->{$col_name}), 100 ); |
|
142 | 142 | break; |
143 | 143 | case 'created_at': |
144 | 144 | case 'updated_at': |
145 | - $date = FrmAppHelper::get_formatted_time($item->{$col_name}); |
|
145 | + $date = FrmAppHelper::get_formatted_time( $item->{$col_name}); |
|
146 | 146 | $val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>'; |
147 | 147 | break; |
148 | 148 | case 'is_draft': |
149 | - $val = empty($item->is_draft) ? __( 'No') : __( 'Yes'); |
|
149 | + $val = empty( $item->is_draft ) ? __( 'No' ) : __( 'Yes' ); |
|
150 | 150 | break; |
151 | 151 | case 'form_id': |
152 | - $val = FrmFormsHelper::edit_form_link($item->form_id); |
|
152 | + $val = FrmFormsHelper::edit_form_link( $item->form_id ); |
|
153 | 153 | break; |
154 | 154 | case 'post_id': |
155 | - $val = FrmAppHelper::post_edit_link($item->post_id); |
|
155 | + $val = FrmAppHelper::post_edit_link( $item->post_id ); |
|
156 | 156 | break; |
157 | 157 | case 'user_id': |
158 | - $user = get_userdata($item->user_id); |
|
158 | + $user = get_userdata( $item->user_id ); |
|
159 | 159 | $val = $user->user_login; |
160 | 160 | break; |
161 | 161 | default: |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | } |
178 | 178 | $r .= '</td>'; |
179 | 179 | } |
180 | - unset($val); |
|
180 | + unset( $val ); |
|
181 | 181 | } |
182 | 182 | $r .= '</tr>'; |
183 | 183 | |
@@ -190,12 +190,12 @@ discard block |
||
190 | 190 | private function get_actions( &$actions, $item, $view_link ) { |
191 | 191 | $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>'; |
192 | 192 | |
193 | - if ( current_user_can('frm_delete_entries') ) { |
|
193 | + if ( current_user_can( 'frm_delete_entries' ) ) { |
|
194 | 194 | $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form']; |
195 | 195 | $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" onclick="return confirm(\'' . esc_attr( __( 'Are you sure you want to delete that?', 'formidable' ) ) . '\')">' . __( 'Delete' ) . '</a>'; |
196 | 196 | } |
197 | 197 | |
198 | - $actions = apply_filters('frm_row_actions', $actions, $item); |
|
198 | + $actions = apply_filters( 'frm_row_actions', $actions, $item ); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | private function get_column_value( $item, &$val ) { |
@@ -1,261 +1,261 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('ABSPATH') ) { |
3 | - die('You are not allowed to call this page directly.'); |
|
3 | + die('You are not allowed to call this page directly.'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | class FrmForm { |
7 | 7 | |
8 | - /** |
|
9 | - * @return int|boolean id on success or false on failure |
|
10 | - */ |
|
11 | - public static function create( $values ) { |
|
12 | - global $wpdb; |
|
8 | + /** |
|
9 | + * @return int|boolean id on success or false on failure |
|
10 | + */ |
|
11 | + public static function create( $values ) { |
|
12 | + global $wpdb; |
|
13 | 13 | |
14 | - $new_values = array( |
|
14 | + $new_values = array( |
|
15 | 15 | 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
16 | - 'name' => $values['name'], |
|
17 | - 'description' => $values['description'], |
|
18 | - 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
19 | - 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
20 | - 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
16 | + 'name' => $values['name'], |
|
17 | + 'description' => $values['description'], |
|
18 | + 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
19 | + 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
20 | + 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
21 | 21 | 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0, |
22 | - 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
23 | - 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
24 | - 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
25 | - ); |
|
22 | + 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
23 | + 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
24 | + 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
25 | + ); |
|
26 | 26 | |
27 | 27 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
28 | 28 | FrmFormsHelper::fill_form_options( $options, $values ); |
29 | 29 | |
30 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
31 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
32 | - $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
30 | + $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
31 | + $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
32 | + $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
33 | 33 | |
34 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
35 | - $new_values['options'] = serialize($options); |
|
34 | + $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
35 | + $new_values['options'] = serialize($options); |
|
36 | 36 | |
37 | - //if(isset($values['id']) && is_numeric($values['id'])) |
|
38 | - // $new_values['id'] = $values['id']; |
|
37 | + //if(isset($values['id']) && is_numeric($values['id'])) |
|
38 | + // $new_values['id'] = $values['id']; |
|
39 | 39 | |
40 | 40 | $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
41 | 41 | |
42 | - $id = $wpdb->insert_id; |
|
42 | + $id = $wpdb->insert_id; |
|
43 | 43 | |
44 | 44 | // Clear form caching |
45 | 45 | self::clear_form_cache(); |
46 | 46 | |
47 | - return $id; |
|
48 | - } |
|
47 | + return $id; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @return int|boolean ID on success or false on failure |
|
52 | - */ |
|
53 | - public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) { |
|
54 | - global $wpdb; |
|
50 | + /** |
|
51 | + * @return int|boolean ID on success or false on failure |
|
52 | + */ |
|
53 | + public static function duplicate( $id, $template = false, $copy_keys = false, $blog_id = false ) { |
|
54 | + global $wpdb; |
|
55 | 55 | |
56 | - $values = self::getOne( $id, $blog_id ); |
|
57 | - if ( ! $values ) { |
|
58 | - return false; |
|
59 | - } |
|
56 | + $values = self::getOne( $id, $blog_id ); |
|
57 | + if ( ! $values ) { |
|
58 | + return false; |
|
59 | + } |
|
60 | 60 | |
61 | - $new_key = $copy_keys ? $values->form_key : ''; |
|
61 | + $new_key = $copy_keys ? $values->form_key : ''; |
|
62 | 62 | |
63 | - $new_values = array( |
|
63 | + $new_values = array( |
|
64 | 64 | 'form_key' => FrmAppHelper::get_unique_key( $new_key, $wpdb->prefix . 'frm_forms', 'form_key' ), |
65 | - 'name' => $values->name, |
|
66 | - 'description' => $values->description, |
|
67 | - 'status' => $template ? 'published' : 'draft', |
|
68 | - 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
|
69 | - 'editable' => $values->editable ? $values->editable : 0, |
|
70 | - 'created_at' => current_time('mysql', 1), |
|
71 | - 'is_template' => $template ? 1 : 0, |
|
72 | - ); |
|
73 | - |
|
74 | - if ( $blog_id ) { |
|
75 | - $new_values['status'] = 'published'; |
|
76 | - $new_options = maybe_unserialize($values->options); |
|
77 | - $new_options['email_to'] = get_option('admin_email'); |
|
78 | - $new_options['copy'] = false; |
|
79 | - $new_values['options'] = $new_options; |
|
80 | - } else { |
|
81 | - $new_values['options'] = $values->options; |
|
82 | - } |
|
83 | - |
|
84 | - if ( is_array($new_values['options']) ) { |
|
85 | - $new_values['options'] = serialize($new_values['options']); |
|
86 | - } |
|
65 | + 'name' => $values->name, |
|
66 | + 'description' => $values->description, |
|
67 | + 'status' => $template ? 'published' : 'draft', |
|
68 | + 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
|
69 | + 'editable' => $values->editable ? $values->editable : 0, |
|
70 | + 'created_at' => current_time('mysql', 1), |
|
71 | + 'is_template' => $template ? 1 : 0, |
|
72 | + ); |
|
73 | + |
|
74 | + if ( $blog_id ) { |
|
75 | + $new_values['status'] = 'published'; |
|
76 | + $new_options = maybe_unserialize($values->options); |
|
77 | + $new_options['email_to'] = get_option('admin_email'); |
|
78 | + $new_options['copy'] = false; |
|
79 | + $new_values['options'] = $new_options; |
|
80 | + } else { |
|
81 | + $new_values['options'] = $values->options; |
|
82 | + } |
|
83 | + |
|
84 | + if ( is_array($new_values['options']) ) { |
|
85 | + $new_values['options'] = serialize($new_values['options']); |
|
86 | + } |
|
87 | 87 | |
88 | 88 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
89 | 89 | |
90 | - if ( $query_results ) { |
|
90 | + if ( $query_results ) { |
|
91 | 91 | // Clear form caching |
92 | 92 | self::clear_form_cache(); |
93 | 93 | |
94 | - $form_id = $wpdb->insert_id; |
|
95 | - FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
94 | + $form_id = $wpdb->insert_id; |
|
95 | + FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
96 | 96 | |
97 | - // update form settings after fields are created |
|
97 | + // update form settings after fields are created |
|
98 | 98 | do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) ); |
99 | - return $form_id; |
|
100 | - } |
|
99 | + return $form_id; |
|
100 | + } |
|
101 | 101 | |
102 | - return false; |
|
103 | - } |
|
102 | + return false; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | public static function after_duplicate( $form_id, $values ) { |
106 | - $new_opts = $values['options'] = maybe_unserialize($values['options']); |
|
106 | + $new_opts = $values['options'] = maybe_unserialize($values['options']); |
|
107 | 107 | |
108 | - if ( isset($new_opts['success_msg']) ) { |
|
109 | - $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
110 | - } |
|
108 | + if ( isset($new_opts['success_msg']) ) { |
|
109 | + $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
110 | + } |
|
111 | 111 | |
112 | - $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
112 | + $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
113 | 113 | |
114 | - if ( $new_opts != $values['options'] ) { |
|
115 | - global $wpdb; |
|
114 | + if ( $new_opts != $values['options'] ) { |
|
115 | + global $wpdb; |
|
116 | 116 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $new_opts ) ), array( 'id' => $form_id ) ); |
117 | - } |
|
118 | - } |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * @return int|boolean |
|
122 | - */ |
|
123 | - public static function update( $id, $values, $create_link = false ) { |
|
124 | - global $wpdb; |
|
120 | + /** |
|
121 | + * @return int|boolean |
|
122 | + */ |
|
123 | + public static function update( $id, $values, $create_link = false ) { |
|
124 | + global $wpdb; |
|
125 | 125 | |
126 | - if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) { |
|
127 | - $values['status'] = 'published'; |
|
128 | - } |
|
126 | + if ( ! isset( $values['status'] ) && ( $create_link || isset( $values['options'] ) || isset( $values['item_meta'] ) || isset( $values['field_options'] ) ) ) { |
|
127 | + $values['status'] = 'published'; |
|
128 | + } |
|
129 | 129 | |
130 | - if ( isset($values['form_key']) ) { |
|
130 | + if ( isset($values['form_key']) ) { |
|
131 | 131 | $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id ); |
132 | - } |
|
132 | + } |
|
133 | 133 | |
134 | 134 | $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
135 | 135 | |
136 | - $new_values = self::set_update_options( array(), $values); |
|
136 | + $new_values = self::set_update_options( array(), $values); |
|
137 | 137 | |
138 | - foreach ( $values as $value_key => $value ) { |
|
138 | + foreach ( $values as $value_key => $value ) { |
|
139 | 139 | if ( $value_key && in_array( $value_key, $form_fields ) ) { |
140 | 140 | $new_values[ $value_key ] = $value; |
141 | - } |
|
142 | - } |
|
141 | + } |
|
142 | + } |
|
143 | 143 | |
144 | - if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) { |
|
145 | - $new_values['status'] = $values['new_status']; |
|
146 | - } |
|
144 | + if ( isset( $values['new_status'] ) && ! empty( $values['new_status'] ) ) { |
|
145 | + $new_values['status'] = $values['new_status']; |
|
146 | + } |
|
147 | 147 | |
148 | - if ( ! empty( $new_values ) ) { |
|
148 | + if ( ! empty( $new_values ) ) { |
|
149 | 149 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $id ) ); |
150 | - if ( $query_results ) { |
|
150 | + if ( $query_results ) { |
|
151 | 151 | self::clear_form_cache(); |
152 | - } |
|
153 | - } else { |
|
154 | - $query_results = true; |
|
155 | - } |
|
156 | - unset($new_values); |
|
152 | + } |
|
153 | + } else { |
|
154 | + $query_results = true; |
|
155 | + } |
|
156 | + unset($new_values); |
|
157 | 157 | |
158 | - $values = self::update_fields($id, $values); |
|
158 | + $values = self::update_fields($id, $values); |
|
159 | 159 | |
160 | 160 | do_action( 'frm_update_form', $id, $values ); |
161 | 161 | do_action( 'frm_update_form_' . $id, $values ); |
162 | 162 | |
163 | - return $query_results; |
|
164 | - } |
|
163 | + return $query_results; |
|
164 | + } |
|
165 | 165 | |
166 | - /** |
|
167 | - * @return array |
|
168 | - */ |
|
166 | + /** |
|
167 | + * @return array |
|
168 | + */ |
|
169 | 169 | public static function set_update_options( $new_values, $values ) { |
170 | - if ( ! isset($values['options']) ) { |
|
171 | - return $new_values; |
|
172 | - } |
|
170 | + if ( ! isset($values['options']) ) { |
|
171 | + return $new_values; |
|
172 | + } |
|
173 | 173 | |
174 | 174 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
175 | 175 | FrmFormsHelper::fill_form_options( $options, $values ); |
176 | 176 | |
177 | - $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
178 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
179 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
180 | - $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
177 | + $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
178 | + $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
179 | + $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
180 | + $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
181 | 181 | |
182 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
183 | - $new_values['options'] = serialize($options); |
|
182 | + $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
183 | + $new_values['options'] = serialize($options); |
|
184 | 184 | |
185 | - return $new_values; |
|
186 | - } |
|
185 | + return $new_values; |
|
186 | + } |
|
187 | 187 | |
188 | 188 | |
189 | - /** |
|
190 | - * @return array |
|
191 | - */ |
|
189 | + /** |
|
190 | + * @return array |
|
191 | + */ |
|
192 | 192 | public static function update_fields( $id, $values ) { |
193 | 193 | |
194 | - if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
195 | - return $values; |
|
196 | - } |
|
194 | + if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
195 | + return $values; |
|
196 | + } |
|
197 | 197 | |
198 | - $all_fields = FrmField::get_all_for_form($id); |
|
199 | - if ( empty($all_fields) ) { |
|
200 | - return $values; |
|
201 | - } |
|
198 | + $all_fields = FrmField::get_all_for_form($id); |
|
199 | + if ( empty($all_fields) ) { |
|
200 | + return $values; |
|
201 | + } |
|
202 | 202 | |
203 | - if ( ! isset($values['item_meta']) ) { |
|
204 | - $values['item_meta'] = array(); |
|
205 | - } |
|
203 | + if ( ! isset($values['item_meta']) ) { |
|
204 | + $values['item_meta'] = array(); |
|
205 | + } |
|
206 | 206 | |
207 | - $field_array = array(); |
|
208 | - $existing_keys = array_keys($values['item_meta']); |
|
209 | - foreach ( $all_fields as $fid ) { |
|
210 | - if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
207 | + $field_array = array(); |
|
208 | + $existing_keys = array_keys($values['item_meta']); |
|
209 | + foreach ( $all_fields as $fid ) { |
|
210 | + if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
211 | 211 | $values['item_meta'][ $fid->id ] = ''; |
212 | - } |
|
212 | + } |
|
213 | 213 | $field_array[ $fid->id ] = $fid; |
214 | - } |
|
215 | - unset($all_fields); |
|
214 | + } |
|
215 | + unset($all_fields); |
|
216 | 216 | |
217 | - foreach ( $values['item_meta'] as $field_id => $default_value ) { |
|
217 | + foreach ( $values['item_meta'] as $field_id => $default_value ) { |
|
218 | 218 | if ( isset( $field_array[ $field_id ] ) ) { |
219 | 219 | $field = $field_array[ $field_id ]; |
220 | - } else { |
|
221 | - $field = FrmField::getOne($field_id); |
|
222 | - } |
|
220 | + } else { |
|
221 | + $field = FrmField::getOne($field_id); |
|
222 | + } |
|
223 | 223 | |
224 | - if ( ! $field ) { |
|
225 | - continue; |
|
226 | - } |
|
224 | + if ( ! $field ) { |
|
225 | + continue; |
|
226 | + } |
|
227 | 227 | |
228 | 228 | $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ); |
229 | 229 | if ( $is_settings_page ) { |
230 | - //updating the settings page |
|
230 | + //updating the settings page |
|
231 | 231 | if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
232 | 232 | $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
233 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
233 | + $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
234 | 234 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
235 | - } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
|
236 | - $prev_opts = $field->field_options; |
|
237 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
238 | - if ( $prev_opts != $field->field_options ) { |
|
235 | + } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
|
236 | + $prev_opts = $field->field_options; |
|
237 | + $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
238 | + if ( $prev_opts != $field->field_options ) { |
|
239 | 239 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
240 | - } |
|
241 | - unset($prev_opts); |
|
242 | - } |
|
243 | - } |
|
240 | + } |
|
241 | + unset($prev_opts); |
|
242 | + } |
|
243 | + } |
|
244 | 244 | |
245 | 245 | if ( $is_settings_page && ! defined( 'WP_IMPORTING' ) ) { |
246 | - continue; |
|
247 | - } |
|
246 | + continue; |
|
247 | + } |
|
248 | 248 | |
249 | - //updating the form |
|
249 | + //updating the form |
|
250 | 250 | $update_options = FrmFieldsHelper::get_default_field_opts( $field->type, $field, true ); |
251 | 251 | unset( $update_options['custom_html'] ); // don't check for POST html |
252 | 252 | $update_options = apply_filters( 'frm_field_options_to_update', $update_options ); |
253 | 253 | |
254 | 254 | foreach ( $update_options as $opt => $default ) { |
255 | 255 | $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default; |
256 | - } |
|
256 | + } |
|
257 | 257 | |
258 | - $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
258 | + $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
259 | 259 | $default_value = maybe_serialize( $values['item_meta'][ $field_id ] ); |
260 | 260 | |
261 | 261 | $new_field = array( |
@@ -267,12 +267,12 @@ discard block |
||
267 | 267 | |
268 | 268 | FrmField::update( $field_id, $new_field ); |
269 | 269 | |
270 | - FrmField::delete_form_transient($field->form_id); |
|
271 | - } |
|
270 | + FrmField::delete_form_transient($field->form_id); |
|
271 | + } |
|
272 | 272 | self::clear_form_cache(); |
273 | 273 | |
274 | - return $values; |
|
275 | - } |
|
274 | + return $values; |
|
275 | + } |
|
276 | 276 | |
277 | 277 | private static function prepare_field_update_values( $field, $values, &$new_field ) { |
278 | 278 | $field_cols = array( |
@@ -285,113 +285,113 @@ discard block |
||
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
288 | - /** |
|
289 | - * @param string $status |
|
290 | - * @return int|boolean |
|
291 | - */ |
|
288 | + /** |
|
289 | + * @param string $status |
|
290 | + * @return int|boolean |
|
291 | + */ |
|
292 | 292 | public static function set_status( $id, $status ) { |
293 | - if ( 'trash' == $status ) { |
|
294 | - return self::trash($id); |
|
295 | - } |
|
293 | + if ( 'trash' == $status ) { |
|
294 | + return self::trash($id); |
|
295 | + } |
|
296 | 296 | |
297 | 297 | $statuses = array( 'published', 'draft', 'trash' ); |
298 | - if ( ! in_array( $status, $statuses ) ) { |
|
299 | - return false; |
|
300 | - } |
|
298 | + if ( ! in_array( $status, $statuses ) ) { |
|
299 | + return false; |
|
300 | + } |
|
301 | 301 | |
302 | - global $wpdb; |
|
302 | + global $wpdb; |
|
303 | 303 | |
304 | - if ( is_array($id) ) { |
|
304 | + if ( is_array($id) ) { |
|
305 | 305 | $where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 ); |
306 | 306 | FrmDb::get_where_clause_and_values( $where ); |
307 | 307 | array_unshift( $where['values'], $status ); |
308 | 308 | |
309 | 309 | $query_results = $wpdb->query( $wpdb->prepare( 'UPDATE ' . $wpdb->prefix . 'frm_forms SET status = %s ' . $where['where'], $where['values'] ) ); |
310 | - } else { |
|
310 | + } else { |
|
311 | 311 | $query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'id' => $id ) ); |
312 | 312 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'status' => $status ), array( 'parent_form_id' => $id ) ); |
313 | - } |
|
313 | + } |
|
314 | 314 | |
315 | - if ( $query_results ) { |
|
315 | + if ( $query_results ) { |
|
316 | 316 | self::clear_form_cache(); |
317 | - } |
|
317 | + } |
|
318 | 318 | |
319 | - return $query_results; |
|
320 | - } |
|
319 | + return $query_results; |
|
320 | + } |
|
321 | 321 | |
322 | - /** |
|
323 | - * @return int|boolean |
|
324 | - */ |
|
322 | + /** |
|
323 | + * @return int|boolean |
|
324 | + */ |
|
325 | 325 | public static function trash( $id ) { |
326 | - if ( ! EMPTY_TRASH_DAYS ) { |
|
327 | - return self::destroy( $id ); |
|
328 | - } |
|
326 | + if ( ! EMPTY_TRASH_DAYS ) { |
|
327 | + return self::destroy( $id ); |
|
328 | + } |
|
329 | 329 | |
330 | - $form = self::getOne($id); |
|
331 | - if ( ! $form ) { |
|
332 | - return false; |
|
333 | - } |
|
330 | + $form = self::getOne($id); |
|
331 | + if ( ! $form ) { |
|
332 | + return false; |
|
333 | + } |
|
334 | 334 | |
335 | - $options = $form->options; |
|
336 | - $options['trash_time'] = time(); |
|
335 | + $options = $form->options; |
|
336 | + $options['trash_time'] = time(); |
|
337 | 337 | |
338 | - global $wpdb; |
|
339 | - $query_results = $wpdb->update( |
|
338 | + global $wpdb; |
|
339 | + $query_results = $wpdb->update( |
|
340 | 340 | $wpdb->prefix . 'frm_forms', |
341 | 341 | array( 'status' => 'trash', 'options' => serialize( $options ) ), |
342 | 342 | array( 'id' => $id ) |
343 | - ); |
|
343 | + ); |
|
344 | 344 | |
345 | - $wpdb->update( |
|
345 | + $wpdb->update( |
|
346 | 346 | $wpdb->prefix . 'frm_forms', |
347 | 347 | array( 'status' => 'trash', 'options' => serialize( $options ) ), |
348 | 348 | array( 'parent_form_id' => $id ) |
349 | - ); |
|
349 | + ); |
|
350 | 350 | |
351 | - if ( $query_results ) { |
|
351 | + if ( $query_results ) { |
|
352 | 352 | self::clear_form_cache(); |
353 | - } |
|
353 | + } |
|
354 | 354 | |
355 | - return $query_results; |
|
356 | - } |
|
355 | + return $query_results; |
|
356 | + } |
|
357 | 357 | |
358 | - /** |
|
359 | - * @return int|boolean |
|
360 | - */ |
|
358 | + /** |
|
359 | + * @return int|boolean |
|
360 | + */ |
|
361 | 361 | public static function destroy( $id ) { |
362 | - global $wpdb; |
|
362 | + global $wpdb; |
|
363 | 363 | |
364 | - $form = self::getOne($id); |
|
365 | - if ( ! $form ) { |
|
366 | - return false; |
|
367 | - } |
|
364 | + $form = self::getOne($id); |
|
365 | + if ( ! $form ) { |
|
366 | + return false; |
|
367 | + } |
|
368 | 368 | $id = $form->id; |
369 | 369 | |
370 | - // Disconnect the entries from this form |
|
370 | + // Disconnect the entries from this form |
|
371 | 371 | $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) ); |
372 | - foreach ( $entries as $entry_id ) { |
|
373 | - FrmEntry::destroy($entry_id); |
|
374 | - unset($entry_id); |
|
375 | - } |
|
372 | + foreach ( $entries as $entry_id ) { |
|
373 | + FrmEntry::destroy($entry_id); |
|
374 | + unset($entry_id); |
|
375 | + } |
|
376 | 376 | |
377 | - // Disconnect the fields from this form |
|
377 | + // Disconnect the fields from this form |
|
378 | 378 | $wpdb->query( $wpdb->prepare( 'DELETE fi FROM ' . $wpdb->prefix . 'frm_fields AS fi LEFT JOIN ' . $wpdb->prefix . 'frm_forms fr ON (fi.form_id = fr.id) WHERE fi.form_id=%d OR parent_form_id=%d', $id, $id ) ); |
379 | 379 | |
380 | 380 | $query_results = $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_forms WHERE id=%d OR parent_form_id=%d', $id, $id ) ); |
381 | - if ( $query_results ) { |
|
382 | - // Delete all form actions linked to this form |
|
383 | - $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
384 | - $action_control->destroy($id, 'all'); |
|
381 | + if ( $query_results ) { |
|
382 | + // Delete all form actions linked to this form |
|
383 | + $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
|
384 | + $action_control->destroy($id, 'all'); |
|
385 | 385 | |
386 | 386 | // Clear form caching |
387 | 387 | self::clear_form_cache(); |
388 | 388 | |
389 | 389 | do_action( 'frm_destroy_form', $id ); |
390 | 390 | do_action( 'frm_destroy_form_' . $id ); |
391 | - } |
|
391 | + } |
|
392 | 392 | |
393 | - return $query_results; |
|
394 | - } |
|
393 | + return $query_results; |
|
394 | + } |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Delete trashed forms based on how long they have been trashed |
@@ -423,49 +423,49 @@ discard block |
||
423 | 423 | return $count; |
424 | 424 | } |
425 | 425 | |
426 | - /** |
|
427 | - * @return string form name |
|
428 | - */ |
|
429 | - public static function &getName( $id ) { |
|
430 | - global $wpdb; |
|
431 | - |
|
432 | - $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
433 | - if ( $form ) { |
|
434 | - $r = stripslashes($form->name); |
|
435 | - return $r; |
|
436 | - } |
|
437 | - |
|
438 | - $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
|
439 | - $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
|
440 | - $r = stripslashes($r); |
|
441 | - |
|
442 | - return $r; |
|
443 | - } |
|
444 | - |
|
445 | - /** |
|
446 | - * @param string $key |
|
447 | - * @return int form id |
|
448 | - */ |
|
426 | + /** |
|
427 | + * @return string form name |
|
428 | + */ |
|
429 | + public static function &getName( $id ) { |
|
430 | + global $wpdb; |
|
431 | + |
|
432 | + $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
433 | + if ( $form ) { |
|
434 | + $r = stripslashes($form->name); |
|
435 | + return $r; |
|
436 | + } |
|
437 | + |
|
438 | + $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
|
439 | + $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
|
440 | + $r = stripslashes($r); |
|
441 | + |
|
442 | + return $r; |
|
443 | + } |
|
444 | + |
|
445 | + /** |
|
446 | + * @param string $key |
|
447 | + * @return int form id |
|
448 | + */ |
|
449 | 449 | public static function &getIdByKey( $key ) { |
450 | - $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) ); |
|
451 | - return $id; |
|
452 | - } |
|
453 | - |
|
454 | - /** |
|
455 | - * @param int $id |
|
456 | - * @return string form key |
|
457 | - */ |
|
450 | + $id = FrmDb::get_var( 'frm_forms', array( 'form_key' => sanitize_title( $key ) ) ); |
|
451 | + return $id; |
|
452 | + } |
|
453 | + |
|
454 | + /** |
|
455 | + * @param int $id |
|
456 | + * @return string form key |
|
457 | + */ |
|
458 | 458 | public static function &getKeyById( $id ) { |
459 | - $id = (int) $id; |
|
460 | - $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
461 | - if ( $cache ) { |
|
462 | - return $cache->form_key; |
|
463 | - } |
|
459 | + $id = (int) $id; |
|
460 | + $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
461 | + if ( $cache ) { |
|
462 | + return $cache->form_key; |
|
463 | + } |
|
464 | 464 | |
465 | - $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' ); |
|
465 | + $key = FrmDb::get_var( 'frm_forms', array( 'id' => $id ), 'form_key' ); |
|
466 | 466 | |
467 | - return $key; |
|
468 | - } |
|
467 | + return $key; |
|
468 | + } |
|
469 | 469 | |
470 | 470 | /** |
471 | 471 | * If $form is numeric, get the form object |
@@ -478,47 +478,47 @@ discard block |
||
478 | 478 | } |
479 | 479 | } |
480 | 480 | |
481 | - /** |
|
482 | - * @return object form |
|
483 | - */ |
|
484 | - public static function getOne( $id, $blog_id = false ) { |
|
485 | - global $wpdb; |
|
481 | + /** |
|
482 | + * @return object form |
|
483 | + */ |
|
484 | + public static function getOne( $id, $blog_id = false ) { |
|
485 | + global $wpdb; |
|
486 | 486 | |
487 | - if ( $blog_id && is_multisite() ) { |
|
488 | - global $wpmuBaseTablePrefix; |
|
487 | + if ( $blog_id && is_multisite() ) { |
|
488 | + global $wpmuBaseTablePrefix; |
|
489 | 489 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix . $blog_id . '_' : $wpdb->get_blog_prefix( $blog_id ); |
490 | 490 | |
491 | 491 | $table_name = $prefix . 'frm_forms'; |
492 | - } else { |
|
492 | + } else { |
|
493 | 493 | $table_name = $wpdb->prefix . 'frm_forms'; |
494 | - $cache = wp_cache_get($id, 'frm_form'); |
|
495 | - if ( $cache ) { |
|
496 | - if ( isset($cache->options) ) { |
|
497 | - $cache->options = maybe_unserialize($cache->options); |
|
498 | - } |
|
494 | + $cache = wp_cache_get($id, 'frm_form'); |
|
495 | + if ( $cache ) { |
|
496 | + if ( isset($cache->options) ) { |
|
497 | + $cache->options = maybe_unserialize($cache->options); |
|
498 | + } |
|
499 | 499 | |
500 | - return stripslashes_deep($cache); |
|
501 | - } |
|
502 | - } |
|
500 | + return stripslashes_deep($cache); |
|
501 | + } |
|
502 | + } |
|
503 | 503 | |
504 | - if ( is_numeric($id) ) { |
|
505 | - $where = array( 'id' => $id ); |
|
506 | - } else { |
|
507 | - $where = array( 'form_key' => $id ); |
|
508 | - } |
|
504 | + if ( is_numeric($id) ) { |
|
505 | + $where = array( 'id' => $id ); |
|
506 | + } else { |
|
507 | + $where = array( 'form_key' => $id ); |
|
508 | + } |
|
509 | 509 | |
510 | - $results = FrmDb::get_row( $table_name, $where ); |
|
510 | + $results = FrmDb::get_row( $table_name, $where ); |
|
511 | 511 | |
512 | - if ( isset($results->options) ) { |
|
512 | + if ( isset($results->options) ) { |
|
513 | 513 | FrmAppHelper::set_cache( $results->id, $results, 'frm_form' ); |
514 | - $results->options = maybe_unserialize($results->options); |
|
515 | - } |
|
516 | - return stripslashes_deep($results); |
|
517 | - } |
|
518 | - |
|
519 | - /** |
|
520 | - * @return object|array of objects |
|
521 | - */ |
|
514 | + $results->options = maybe_unserialize($results->options); |
|
515 | + } |
|
516 | + return stripslashes_deep($results); |
|
517 | + } |
|
518 | + |
|
519 | + /** |
|
520 | + * @return object|array of objects |
|
521 | + */ |
|
522 | 522 | public static function getAll( $where = array(), $order_by = '', $limit = '' ) { |
523 | 523 | if ( is_array( $where ) && ! empty( $where ) ) { |
524 | 524 | $results = FrmDb::get_results( 'frm_forms', $where, '*', array( 'order_by' => $order_by, 'limit' => $limit ) ); |
@@ -542,8 +542,8 @@ discard block |
||
542 | 542 | $results = reset( $results ); |
543 | 543 | } |
544 | 544 | |
545 | - return stripslashes_deep($results); |
|
546 | - } |
|
545 | + return stripslashes_deep($results); |
|
546 | + } |
|
547 | 547 | |
548 | 548 | /** |
549 | 549 | * Get all published forms |
@@ -561,47 +561,47 @@ discard block |
||
561 | 561 | return $forms; |
562 | 562 | } |
563 | 563 | |
564 | - /** |
|
565 | - * @return int count of forms |
|
566 | - */ |
|
567 | - public static function &get_count() { |
|
568 | - global $wpdb; |
|
564 | + /** |
|
565 | + * @return int count of forms |
|
566 | + */ |
|
567 | + public static function &get_count() { |
|
568 | + global $wpdb; |
|
569 | 569 | |
570 | - $cache_key = 'frm_form_counts'; |
|
570 | + $cache_key = 'frm_form_counts'; |
|
571 | 571 | |
572 | - $counts = wp_cache_get( $cache_key, 'frm_form' ); |
|
573 | - if ( false !== $counts ) { |
|
574 | - return $counts; |
|
575 | - } |
|
572 | + $counts = wp_cache_get( $cache_key, 'frm_form' ); |
|
573 | + if ( false !== $counts ) { |
|
574 | + return $counts; |
|
575 | + } |
|
576 | 576 | |
577 | - $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' ); |
|
577 | + $results = (array) FrmDb::get_results( 'frm_forms', array( 'or' => 1, 'parent_form_id' => null, 'parent_form_id <' => 0 ), 'status, is_template' ); |
|
578 | 578 | |
579 | 579 | $statuses = array( 'published', 'draft', 'template', 'trash' ); |
580 | - $counts = array_fill_keys( $statuses, 0 ); |
|
580 | + $counts = array_fill_keys( $statuses, 0 ); |
|
581 | 581 | |
582 | - foreach ( $results as $row ) { |
|
583 | - if ( 'trash' != $row->status ) { |
|
584 | - if ( $row->is_template ) { |
|
582 | + foreach ( $results as $row ) { |
|
583 | + if ( 'trash' != $row->status ) { |
|
584 | + if ( $row->is_template ) { |
|
585 | 585 | $counts['template']++; |
586 | - } else { |
|
586 | + } else { |
|
587 | 587 | $counts['published']++; |
588 | - } |
|
589 | - } else { |
|
588 | + } |
|
589 | + } else { |
|
590 | 590 | $counts['trash']++; |
591 | - } |
|
591 | + } |
|
592 | 592 | |
593 | - if ( 'draft' == $row->status ) { |
|
593 | + if ( 'draft' == $row->status ) { |
|
594 | 594 | $counts['draft']++; |
595 | - } |
|
595 | + } |
|
596 | 596 | |
597 | - unset($row); |
|
598 | - } |
|
597 | + unset($row); |
|
598 | + } |
|
599 | 599 | |
600 | - $counts = (object) $counts; |
|
600 | + $counts = (object) $counts; |
|
601 | 601 | FrmAppHelper::set_cache( $cache_key, $counts, 'frm_form' ); |
602 | 602 | |
603 | - return $counts; |
|
604 | - } |
|
603 | + return $counts; |
|
604 | + } |
|
605 | 605 | |
606 | 606 | /** |
607 | 607 | * Clear form caching |
@@ -614,14 +614,14 @@ discard block |
||
614 | 614 | FrmAppHelper::cache_delete_group( 'frm_form' ); |
615 | 615 | } |
616 | 616 | |
617 | - /** |
|
618 | - * @return array of errors |
|
619 | - */ |
|
617 | + /** |
|
618 | + * @return array of errors |
|
619 | + */ |
|
620 | 620 | public static function validate( $values ) { |
621 | - $errors = array(); |
|
621 | + $errors = array(); |
|
622 | 622 | |
623 | - return apply_filters('frm_validate_form', $errors, $values); |
|
624 | - } |
|
623 | + return apply_filters('frm_validate_form', $errors, $values); |
|
624 | + } |
|
625 | 625 | |
626 | 626 | public static function get_params( $form = null ) { |
627 | 627 | global $frm_vars; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined('ABSPATH') ) { |
|
3 | - die('You are not allowed to call this page directly.'); |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + die( 'You are not allowed to call this page directly.' ); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | class FrmForm { |
@@ -15,24 +15,24 @@ discard block |
||
15 | 15 | 'form_key' => FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key' ), |
16 | 16 | 'name' => $values['name'], |
17 | 17 | 'description' => $values['description'], |
18 | - 'status' => isset($values['status']) ? $values['status'] : 'draft', |
|
19 | - 'logged_in' => isset($values['logged_in']) ? $values['logged_in'] : 0, |
|
20 | - 'is_template' => isset($values['is_template']) ? (int) $values['is_template'] : 0, |
|
18 | + 'status' => isset( $values['status'] ) ? $values['status'] : 'draft', |
|
19 | + 'logged_in' => isset( $values['logged_in'] ) ? $values['logged_in'] : 0, |
|
20 | + 'is_template' => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0, |
|
21 | 21 | 'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0, |
22 | - 'editable' => isset($values['editable']) ? (int) $values['editable'] : 0, |
|
23 | - 'default_template' => isset($values['default_template']) ? (int) $values['default_template'] : 0, |
|
24 | - 'created_at' => isset($values['created_at']) ? $values['created_at'] : current_time('mysql', 1), |
|
22 | + 'editable' => isset( $values['editable'] ) ? (int) $values['editable'] : 0, |
|
23 | + 'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0, |
|
24 | + 'created_at' => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ), |
|
25 | 25 | ); |
26 | 26 | |
27 | 27 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
28 | 28 | FrmFormsHelper::fill_form_options( $options, $values ); |
29 | 29 | |
30 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
31 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
32 | - $options['submit_html'] = isset($values['options']['submit_html']) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
30 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); |
|
31 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); |
|
32 | + $options['submit_html'] = isset( $values['options']['submit_html'] ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); |
|
33 | 33 | |
34 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
35 | - $new_values['options'] = serialize($options); |
|
34 | + $options = apply_filters( 'frm_form_options_before_update', $options, $values ); |
|
35 | + $new_values['options'] = serialize( $options ); |
|
36 | 36 | |
37 | 37 | //if(isset($values['id']) && is_numeric($values['id'])) |
38 | 38 | // $new_values['id'] = $values['id']; |
@@ -67,22 +67,22 @@ discard block |
||
67 | 67 | 'status' => $template ? 'published' : 'draft', |
68 | 68 | 'logged_in' => $values->logged_in ? $values->logged_in : 0, |
69 | 69 | 'editable' => $values->editable ? $values->editable : 0, |
70 | - 'created_at' => current_time('mysql', 1), |
|
70 | + 'created_at' => current_time( 'mysql', 1 ), |
|
71 | 71 | 'is_template' => $template ? 1 : 0, |
72 | 72 | ); |
73 | 73 | |
74 | 74 | if ( $blog_id ) { |
75 | 75 | $new_values['status'] = 'published'; |
76 | - $new_options = maybe_unserialize($values->options); |
|
77 | - $new_options['email_to'] = get_option('admin_email'); |
|
76 | + $new_options = maybe_unserialize( $values->options ); |
|
77 | + $new_options['email_to'] = get_option( 'admin_email' ); |
|
78 | 78 | $new_options['copy'] = false; |
79 | 79 | $new_values['options'] = $new_options; |
80 | 80 | } else { |
81 | 81 | $new_values['options'] = $values->options; |
82 | 82 | } |
83 | 83 | |
84 | - if ( is_array($new_values['options']) ) { |
|
85 | - $new_values['options'] = serialize($new_values['options']); |
|
84 | + if ( is_array( $new_values['options'] ) ) { |
|
85 | + $new_values['options'] = serialize( $new_values['options'] ); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $query_results = $wpdb->insert( $wpdb->prefix . 'frm_forms', $new_values ); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | self::clear_form_cache(); |
93 | 93 | |
94 | 94 | $form_id = $wpdb->insert_id; |
95 | - FrmField::duplicate($id, $form_id, $copy_keys, $blog_id); |
|
95 | + FrmField::duplicate( $id, $form_id, $copy_keys, $blog_id ); |
|
96 | 96 | |
97 | 97 | // update form settings after fields are created |
98 | 98 | do_action( 'frm_after_duplicate_form', $form_id, $new_values, array( 'old_id' => $id ) ); |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | public static function after_duplicate( $form_id, $values ) { |
106 | - $new_opts = $values['options'] = maybe_unserialize($values['options']); |
|
106 | + $new_opts = $values['options'] = maybe_unserialize( $values['options'] ); |
|
107 | 107 | |
108 | - if ( isset($new_opts['success_msg']) ) { |
|
109 | - $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids($new_opts['success_msg']); |
|
108 | + if ( isset( $new_opts['success_msg'] ) ) { |
|
109 | + $new_opts['success_msg'] = FrmFieldsHelper::switch_field_ids( $new_opts['success_msg'] ); |
|
110 | 110 | } |
111 | 111 | |
112 | - $new_opts = apply_filters('frm_after_duplicate_form_values', $new_opts, $form_id); |
|
112 | + $new_opts = apply_filters( 'frm_after_duplicate_form_values', $new_opts, $form_id ); |
|
113 | 113 | |
114 | 114 | if ( $new_opts != $values['options'] ) { |
115 | 115 | global $wpdb; |
@@ -127,17 +127,17 @@ discard block |
||
127 | 127 | $values['status'] = 'published'; |
128 | 128 | } |
129 | 129 | |
130 | - if ( isset($values['form_key']) ) { |
|
130 | + if ( isset( $values['form_key'] ) ) { |
|
131 | 131 | $values['form_key'] = FrmAppHelper::get_unique_key( $values['form_key'], $wpdb->prefix . 'frm_forms', 'form_key', $id ); |
132 | 132 | } |
133 | 133 | |
134 | 134 | $form_fields = array( 'form_key', 'name', 'description', 'status', 'parent_form_id' ); |
135 | 135 | |
136 | - $new_values = self::set_update_options( array(), $values); |
|
136 | + $new_values = self::set_update_options( array(), $values ); |
|
137 | 137 | |
138 | 138 | foreach ( $values as $value_key => $value ) { |
139 | 139 | if ( $value_key && in_array( $value_key, $form_fields ) ) { |
140 | - $new_values[ $value_key ] = $value; |
|
140 | + $new_values[$value_key] = $value; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
@@ -153,9 +153,9 @@ discard block |
||
153 | 153 | } else { |
154 | 154 | $query_results = true; |
155 | 155 | } |
156 | - unset($new_values); |
|
156 | + unset( $new_values ); |
|
157 | 157 | |
158 | - $values = self::update_fields($id, $values); |
|
158 | + $values = self::update_fields( $id, $values ); |
|
159 | 159 | |
160 | 160 | do_action( 'frm_update_form', $id, $values ); |
161 | 161 | do_action( 'frm_update_form_' . $id, $values ); |
@@ -167,20 +167,20 @@ discard block |
||
167 | 167 | * @return array |
168 | 168 | */ |
169 | 169 | public static function set_update_options( $new_values, $values ) { |
170 | - if ( ! isset($values['options']) ) { |
|
170 | + if ( ! isset( $values['options'] ) ) { |
|
171 | 171 | return $new_values; |
172 | 172 | } |
173 | 173 | |
174 | 174 | $options = isset( $values['options'] ) ? (array) $values['options'] : array(); |
175 | 175 | FrmFormsHelper::fill_form_options( $options, $values ); |
176 | 176 | |
177 | - $options['custom_style'] = isset($values['options']['custom_style']) ? $values['options']['custom_style'] : 0; |
|
178 | - $options['before_html'] = isset($values['options']['before_html']) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html('before'); |
|
179 | - $options['after_html'] = isset($values['options']['after_html']) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html('after'); |
|
180 | - $options['submit_html'] = (isset($values['options']['submit_html']) && $values['options']['submit_html'] != '') ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html('submit'); |
|
177 | + $options['custom_style'] = isset( $values['options']['custom_style'] ) ? $values['options']['custom_style'] : 0; |
|
178 | + $options['before_html'] = isset( $values['options']['before_html'] ) ? $values['options']['before_html'] : FrmFormsHelper::get_default_html( 'before' ); |
|
179 | + $options['after_html'] = isset( $values['options']['after_html'] ) ? $values['options']['after_html'] : FrmFormsHelper::get_default_html( 'after' ); |
|
180 | + $options['submit_html'] = ( isset( $values['options']['submit_html'] ) && $values['options']['submit_html'] != '' ) ? $values['options']['submit_html'] : FrmFormsHelper::get_default_html( 'submit' ); |
|
181 | 181 | |
182 | - $options = apply_filters('frm_form_options_before_update', $options, $values); |
|
183 | - $new_values['options'] = serialize($options); |
|
182 | + $options = apply_filters( 'frm_form_options_before_update', $options, $values ); |
|
183 | + $new_values['options'] = serialize( $options ); |
|
184 | 184 | |
185 | 185 | return $new_values; |
186 | 186 | } |
@@ -191,54 +191,54 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public static function update_fields( $id, $values ) { |
193 | 193 | |
194 | - if ( ! isset($values['options']) && ! isset($values['item_meta']) && ! isset($values['field_options']) ) { |
|
194 | + if ( ! isset( $values['options'] ) && ! isset( $values['item_meta'] ) && ! isset( $values['field_options'] ) ) { |
|
195 | 195 | return $values; |
196 | 196 | } |
197 | 197 | |
198 | - $all_fields = FrmField::get_all_for_form($id); |
|
199 | - if ( empty($all_fields) ) { |
|
198 | + $all_fields = FrmField::get_all_for_form( $id ); |
|
199 | + if ( empty( $all_fields ) ) { |
|
200 | 200 | return $values; |
201 | 201 | } |
202 | 202 | |
203 | - if ( ! isset($values['item_meta']) ) { |
|
203 | + if ( ! isset( $values['item_meta'] ) ) { |
|
204 | 204 | $values['item_meta'] = array(); |
205 | 205 | } |
206 | 206 | |
207 | 207 | $field_array = array(); |
208 | - $existing_keys = array_keys($values['item_meta']); |
|
208 | + $existing_keys = array_keys( $values['item_meta'] ); |
|
209 | 209 | foreach ( $all_fields as $fid ) { |
210 | - if ( ! in_array($fid->id, $existing_keys) && ( isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted']) ) || isset($values['options']) ) { |
|
211 | - $values['item_meta'][ $fid->id ] = ''; |
|
210 | + if ( ! in_array( $fid->id, $existing_keys ) && ( isset( $values['frm_fields_submitted'] ) && in_array( $fid->id, $values['frm_fields_submitted'] ) ) || isset( $values['options'] ) ) { |
|
211 | + $values['item_meta'][$fid->id] = ''; |
|
212 | 212 | } |
213 | - $field_array[ $fid->id ] = $fid; |
|
213 | + $field_array[$fid->id] = $fid; |
|
214 | 214 | } |
215 | - unset($all_fields); |
|
215 | + unset( $all_fields ); |
|
216 | 216 | |
217 | 217 | foreach ( $values['item_meta'] as $field_id => $default_value ) { |
218 | - if ( isset( $field_array[ $field_id ] ) ) { |
|
219 | - $field = $field_array[ $field_id ]; |
|
218 | + if ( isset( $field_array[$field_id] ) ) { |
|
219 | + $field = $field_array[$field_id]; |
|
220 | 220 | } else { |
221 | - $field = FrmField::getOne($field_id); |
|
221 | + $field = FrmField::getOne( $field_id ); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | if ( ! $field ) { |
225 | 225 | continue; |
226 | 226 | } |
227 | 227 | |
228 | - $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ); |
|
228 | + $is_settings_page = ( isset( $values['options'] ) || isset( $values['field_options']['custom_html_' . $field_id] ) ); |
|
229 | 229 | if ( $is_settings_page ) { |
230 | 230 | //updating the settings page |
231 | - if ( isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ) { |
|
232 | - $field->field_options['custom_html'] = isset( $values['field_options'][ 'custom_html_' . $field_id ] ) ? $values['field_options'][ 'custom_html_' . $field_id ] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
|
233 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
231 | + if ( isset( $values['field_options']['custom_html_' . $field_id] ) ) { |
|
232 | + $field->field_options['custom_html'] = isset( $values['field_options']['custom_html_' . $field_id] ) ? $values['field_options']['custom_html_' . $field_id] : ( isset( $field->field_options['custom_html'] ) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html( $field->type ) ); |
|
233 | + $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values ); |
|
234 | 234 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
235 | 235 | } else if ( $field->type == 'hidden' || $field->type == 'user_id' ) { |
236 | 236 | $prev_opts = $field->field_options; |
237 | - $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values); |
|
237 | + $field->field_options = apply_filters( 'frm_update_form_field_options', $field->field_options, $field, $values ); |
|
238 | 238 | if ( $prev_opts != $field->field_options ) { |
239 | 239 | FrmField::update( $field_id, array( 'field_options' => $field->field_options ) ); |
240 | 240 | } |
241 | - unset($prev_opts); |
|
241 | + unset( $prev_opts ); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | $update_options = apply_filters( 'frm_field_options_to_update', $update_options ); |
253 | 253 | |
254 | 254 | foreach ( $update_options as $opt => $default ) { |
255 | - $field->field_options[ $opt ] = isset( $values['field_options'][ $opt . '_' . $field_id ] ) ? trim( sanitize_text_field( $values['field_options'][ $opt . '_' . $field_id ] ) ) : $default; |
|
255 | + $field->field_options[$opt] = isset( $values['field_options'][$opt . '_' . $field_id] ) ? trim( sanitize_text_field( $values['field_options'][$opt . '_' . $field_id] ) ) : $default; |
|
256 | 256 | } |
257 | 257 | |
258 | - $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values); |
|
259 | - $default_value = maybe_serialize( $values['item_meta'][ $field_id ] ); |
|
258 | + $field->field_options = apply_filters( 'frm_update_field_options', $field->field_options, $field, $values ); |
|
259 | + $default_value = maybe_serialize( $values['item_meta'][$field_id] ); |
|
260 | 260 | |
261 | 261 | $new_field = array( |
262 | 262 | 'field_options' => $field->field_options, |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | |
268 | 268 | FrmField::update( $field_id, $new_field ); |
269 | 269 | |
270 | - FrmField::delete_form_transient($field->form_id); |
|
270 | + FrmField::delete_form_transient( $field->form_id ); |
|
271 | 271 | } |
272 | 272 | self::clear_form_cache(); |
273 | 273 | |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | ); |
282 | 282 | foreach ( $field_cols as $col => $default ) { |
283 | 283 | $default = ( $default == '' ) ? $field->{$col} : $default; |
284 | - $new_field[ $col ] = isset( $values['field_options'][ $col . '_' . $field->id ] ) ? $values['field_options'][ $col . '_' . $field->id ] : $default; |
|
284 | + $new_field[$col] = isset( $values['field_options'][$col . '_' . $field->id] ) ? $values['field_options'][$col . '_' . $field->id] : $default; |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
@@ -291,17 +291,17 @@ discard block |
||
291 | 291 | */ |
292 | 292 | public static function set_status( $id, $status ) { |
293 | 293 | if ( 'trash' == $status ) { |
294 | - return self::trash($id); |
|
294 | + return self::trash( $id ); |
|
295 | 295 | } |
296 | 296 | |
297 | - $statuses = array( 'published', 'draft', 'trash' ); |
|
297 | + $statuses = array( 'published', 'draft', 'trash' ); |
|
298 | 298 | if ( ! in_array( $status, $statuses ) ) { |
299 | 299 | return false; |
300 | 300 | } |
301 | 301 | |
302 | 302 | global $wpdb; |
303 | 303 | |
304 | - if ( is_array($id) ) { |
|
304 | + if ( is_array( $id ) ) { |
|
305 | 305 | $where = array( 'id' => $id, 'parent_form_id' => $id, 'or' => 1 ); |
306 | 306 | FrmDb::get_where_clause_and_values( $where ); |
307 | 307 | array_unshift( $where['values'], $status ); |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | return self::destroy( $id ); |
328 | 328 | } |
329 | 329 | |
330 | - $form = self::getOne($id); |
|
330 | + $form = self::getOne( $id ); |
|
331 | 331 | if ( ! $form ) { |
332 | 332 | return false; |
333 | 333 | } |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | public static function destroy( $id ) { |
362 | 362 | global $wpdb; |
363 | 363 | |
364 | - $form = self::getOne($id); |
|
364 | + $form = self::getOne( $id ); |
|
365 | 365 | if ( ! $form ) { |
366 | 366 | return false; |
367 | 367 | } |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | // Disconnect the entries from this form |
371 | 371 | $entries = FrmDb::get_col( $wpdb->prefix . 'frm_items', array( 'form_id' => $id ) ); |
372 | 372 | foreach ( $entries as $entry_id ) { |
373 | - FrmEntry::destroy($entry_id); |
|
374 | - unset($entry_id); |
|
373 | + FrmEntry::destroy( $entry_id ); |
|
374 | + unset( $entry_id ); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | // Disconnect the fields from this form |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | if ( $query_results ) { |
382 | 382 | // Delete all form actions linked to this form |
383 | 383 | $action_control = FrmFormActionsController::get_form_actions( 'email' ); |
384 | - $action_control->destroy($id, 'all'); |
|
384 | + $action_control->destroy( $id, 'all' ); |
|
385 | 385 | |
386 | 386 | // Clear form caching |
387 | 387 | self::clear_form_cache(); |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | $form->options = maybe_unserialize( $form->options ); |
416 | 416 | if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) { |
417 | 417 | self::destroy( $form->id ); |
418 | - $count++; |
|
418 | + $count ++; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | unset( $form ); |
@@ -429,15 +429,15 @@ discard block |
||
429 | 429 | public static function &getName( $id ) { |
430 | 430 | global $wpdb; |
431 | 431 | |
432 | - $form = FrmAppHelper::check_cache($id, 'frm_form'); |
|
432 | + $form = FrmAppHelper::check_cache( $id, 'frm_form' ); |
|
433 | 433 | if ( $form ) { |
434 | - $r = stripslashes($form->name); |
|
434 | + $r = stripslashes( $form->name ); |
|
435 | 435 | return $r; |
436 | 436 | } |
437 | 437 | |
438 | 438 | $query_key = is_numeric( $id ) ? 'id' : 'form_key'; |
439 | 439 | $r = FrmDb::get_var( 'frm_forms', array( $query_key => $id ), 'name' ); |
440 | - $r = stripslashes($r); |
|
440 | + $r = stripslashes( $r ); |
|
441 | 441 | |
442 | 442 | return $r; |
443 | 443 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | */ |
458 | 458 | public static function &getKeyById( $id ) { |
459 | 459 | $id = (int) $id; |
460 | - $cache = FrmAppHelper::check_cache($id, 'frm_form'); |
|
460 | + $cache = FrmAppHelper::check_cache( $id, 'frm_form' ); |
|
461 | 461 | if ( $cache ) { |
462 | 462 | return $cache->form_key; |
463 | 463 | } |
@@ -491,17 +491,17 @@ discard block |
||
491 | 491 | $table_name = $prefix . 'frm_forms'; |
492 | 492 | } else { |
493 | 493 | $table_name = $wpdb->prefix . 'frm_forms'; |
494 | - $cache = wp_cache_get($id, 'frm_form'); |
|
494 | + $cache = wp_cache_get( $id, 'frm_form' ); |
|
495 | 495 | if ( $cache ) { |
496 | - if ( isset($cache->options) ) { |
|
497 | - $cache->options = maybe_unserialize($cache->options); |
|
496 | + if ( isset( $cache->options ) ) { |
|
497 | + $cache->options = maybe_unserialize( $cache->options ); |
|
498 | 498 | } |
499 | 499 | |
500 | - return stripslashes_deep($cache); |
|
500 | + return stripslashes_deep( $cache ); |
|
501 | 501 | } |
502 | 502 | } |
503 | 503 | |
504 | - if ( is_numeric($id) ) { |
|
504 | + if ( is_numeric( $id ) ) { |
|
505 | 505 | $where = array( 'id' => $id ); |
506 | 506 | } else { |
507 | 507 | $where = array( 'form_key' => $id ); |
@@ -509,11 +509,11 @@ discard block |
||
509 | 509 | |
510 | 510 | $results = FrmDb::get_row( $table_name, $where ); |
511 | 511 | |
512 | - if ( isset($results->options) ) { |
|
512 | + if ( isset( $results->options ) ) { |
|
513 | 513 | FrmAppHelper::set_cache( $results->id, $results, 'frm_form' ); |
514 | - $results->options = maybe_unserialize($results->options); |
|
514 | + $results->options = maybe_unserialize( $results->options ); |
|
515 | 515 | } |
516 | - return stripslashes_deep($results); |
|
516 | + return stripslashes_deep( $results ); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | /** |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | $results = reset( $results ); |
543 | 543 | } |
544 | 544 | |
545 | - return stripslashes_deep($results); |
|
545 | + return stripslashes_deep( $results ); |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | /** |
@@ -582,19 +582,19 @@ discard block |
||
582 | 582 | foreach ( $results as $row ) { |
583 | 583 | if ( 'trash' != $row->status ) { |
584 | 584 | if ( $row->is_template ) { |
585 | - $counts['template']++; |
|
585 | + $counts['template'] ++; |
|
586 | 586 | } else { |
587 | - $counts['published']++; |
|
587 | + $counts['published'] ++; |
|
588 | 588 | } |
589 | 589 | } else { |
590 | - $counts['trash']++; |
|
590 | + $counts['trash'] ++; |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | if ( 'draft' == $row->status ) { |
594 | - $counts['draft']++; |
|
594 | + $counts['draft'] ++; |
|
595 | 595 | } |
596 | 596 | |
597 | - unset($row); |
|
597 | + unset( $row ); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | $counts = (object) $counts; |
@@ -620,7 +620,7 @@ discard block |
||
620 | 620 | public static function validate( $values ) { |
621 | 621 | $errors = array(); |
622 | 622 | |
623 | - return apply_filters('frm_validate_form', $errors, $values); |
|
623 | + return apply_filters( 'frm_validate_form', $errors, $values ); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | public static function get_params( $form = null ) { |
@@ -632,11 +632,11 @@ discard block |
||
632 | 632 | self::maybe_get_form( $form ); |
633 | 633 | } |
634 | 634 | |
635 | - if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][ $form->id ] ) ) { |
|
636 | - return $frm_vars['form_params'][ $form->id ]; |
|
635 | + if ( isset( $frm_vars['form_params'] ) && is_array( $frm_vars['form_params'] ) && isset( $frm_vars['form_params'][$form->id] ) ) { |
|
636 | + return $frm_vars['form_params'][$form->id]; |
|
637 | 637 | } |
638 | 638 | |
639 | - $action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action'; |
|
639 | + $action_var = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
640 | 640 | $action = apply_filters( 'frm_show_new_entry_page', FrmAppHelper::get_param( $action_var, 'new', 'get', 'sanitize_title' ), $form ); |
641 | 641 | |
642 | 642 | $default_values = array( |
@@ -654,15 +654,15 @@ discard block |
||
654 | 654 | //if there are two forms on the same page, make sure not to submit both |
655 | 655 | foreach ( $default_values as $var => $default ) { |
656 | 656 | if ( $var == 'action' ) { |
657 | - $values[ $var ] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
657 | + $values[$var] = FrmAppHelper::get_param( $action_var, $default, 'get', 'sanitize_title' ); |
|
658 | 658 | } else { |
659 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
659 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
660 | 660 | } |
661 | 661 | unset( $var, $default ); |
662 | 662 | } |
663 | 663 | } else { |
664 | 664 | foreach ( $default_values as $var => $default ) { |
665 | - $values[ $var ] = $default; |
|
665 | + $values[$var] = $default; |
|
666 | 666 | unset( $var, $default ); |
667 | 667 | } |
668 | 668 | } |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | public static function list_page_params() { |
678 | 678 | $values = array(); |
679 | 679 | foreach ( array( 'template' => 0, 'id' => '', 'paged' => 1, 'form' => '', 'search' => '', 'sort' => '', 'sdir' => '' ) as $var => $default ) { |
680 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
680 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | return $values; |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | 'field_id' => '', 'search' => '', 'sort' => '', 'sdir' => '', 'fid' => '', |
698 | 698 | 'keep_post' => '', |
699 | 699 | ) as $var => $default ) { |
700 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default ); |
|
700 | + $values[$var] = FrmAppHelper::get_param( $var, $default ); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | return $values; |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | |
706 | 706 | public static function get_current_form_id( $default_form = 'none' ) { |
707 | 707 | if ( 'first' == $default_form ) { |
708 | - var_dump(debug_backtrace()); |
|
708 | + var_dump( debug_backtrace() ); |
|
709 | 709 | $form = self::get_current_form(); |
710 | 710 | } else { |
711 | 711 | $form = self::maybe_get_current_form(); |
@@ -755,16 +755,16 @@ discard block |
||
755 | 755 | $small_form = new stdClass(); |
756 | 756 | foreach ( array( 'id', 'form_key', 'name' ) as $var ) { |
757 | 757 | $small_form->{$var} = $form->{$var}; |
758 | - unset($var); |
|
758 | + unset( $var ); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | $frm_vars['forms_loaded'][] = $small_form; |
762 | 762 | |
763 | - if ( $this_load && empty($global_load) ) { |
|
763 | + if ( $this_load && empty( $global_load ) ) { |
|
764 | 764 | $global_load = $frm_vars['load_css'] = true; |
765 | 765 | } |
766 | 766 | |
767 | - return ( ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) && $global_load ); |
|
767 | + return ( ( ! isset( $frm_vars['css_loaded'] ) || ! $frm_vars['css_loaded'] ) && $global_load ); |
|
768 | 768 | } |
769 | 769 | |
770 | 770 | public static function show_submit( $form ) { |
@@ -778,6 +778,6 @@ discard block |
||
778 | 778 | */ |
779 | 779 | public static function get_option( $atts ) { |
780 | 780 | $form = $atts['form']; |
781 | - return isset( $form->options[ $atts['option'] ] ) ? $form->options[ $atts['option'] ] : $atts['default']; |
|
781 | + return isset( $form->options[$atts['option']] ) ? $form->options[$atts['option']] : $atts['default']; |
|
782 | 782 | } |
783 | 783 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | if ( ! self::skip_field( $atts, $f ) ) { |
53 | 53 | self::fill_entry_values( $atts, $f, $values ); |
54 | 54 | } |
55 | - unset($f); |
|
55 | + unset( $f ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | self::fill_entry_user_info( $atts, $values ); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | 'type' => $f->type, |
122 | 122 | ); |
123 | 123 | |
124 | - $values[ $f->id ] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f ); |
|
124 | + $values[$f->id] = apply_filters( 'frm_field_shortcodes_for_default_html_email', $field_shortcodes, $f ); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | public static function fill_entry_values( $atts, $f, array &$values ) { |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | |
141 | 141 | $atts['field'] = $f; |
142 | 142 | |
143 | - if ( $atts['entry'] && ! isset( $atts['entry']->metas[ $f->id ] ) ) { |
|
143 | + if ( $atts['entry'] && ! isset( $atts['entry']->metas[$f->id] ) ) { |
|
144 | 144 | // In case include_blank is set |
145 | - $atts['entry']->metas[ $f->id ] = ''; |
|
145 | + $atts['entry']->metas[$f->id] = ''; |
|
146 | 146 | $atts['entry'] = apply_filters( 'frm_prepare_entry_content', $atts['entry'], array( 'field' => $atts['field'] ) ); |
147 | 147 | self::fill_values_from_entry( $atts, $values ); |
148 | 148 | } |
@@ -169,15 +169,15 @@ discard block |
||
169 | 169 | self::maybe_strip_html( $atts['plain_text'], $val ); |
170 | 170 | |
171 | 171 | if ( $atts['format'] != 'text' ) { |
172 | - $values[ $f->field_key ] = $val; |
|
172 | + $values[$f->field_key] = $val; |
|
173 | 173 | if ( $atts['entry'] && $f->type != 'textarea' ) { |
174 | - $prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] ); |
|
174 | + $prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] ); |
|
175 | 175 | if ( $prev_val != $val ) { |
176 | - $values[ $f->field_key . '-value' ] = $prev_val; |
|
176 | + $values[$f->field_key . '-value'] = $prev_val; |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | } else { |
180 | - $values[ $f->id ] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type ); |
|
180 | + $values[$f->id] = array( 'label' => $f->name, 'val' => $val, 'type' => $f->type ); |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | private static function get_field_value( $atts, &$val ) { |
189 | 189 | $f = $atts['field']; |
190 | 190 | if ( $atts['entry'] ) { |
191 | - $prev_val = maybe_unserialize( $atts['entry']->metas[ $f->id ] ); |
|
191 | + $prev_val = maybe_unserialize( $atts['entry']->metas[$f->id] ); |
|
192 | 192 | $meta = array( 'item_id' => $atts['id'], 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type ); |
193 | 193 | |
194 | 194 | //This filter applies to the default-message shortcode and frm-show-entry shortcode only |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | return; |
245 | 245 | } |
246 | 246 | |
247 | - $data = self::get_entry_description_data( $atts ); |
|
247 | + $data = self::get_entry_description_data( $atts ); |
|
248 | 248 | |
249 | 249 | if ( $atts['default_email'] ) { |
250 | 250 | $atts['entry']->ip = '[ip]'; |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers |
332 | 332 | |
333 | 333 | // see how many we have |
334 | - $i = count($matches['browser']); |
|
334 | + $i = count( $matches['browser'] ); |
|
335 | 335 | if ( $i != 1 ) { |
336 | 336 | //we will have two since we are not using 'other' argument yet |
337 | 337 | //see if version is before or after the name |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | self::convert_entry_to_content( $values, $atts, $content ); |
357 | 357 | |
358 | 358 | if ( 'text' == $atts['format'] ) { |
359 | - $content = implode('', $content); |
|
359 | + $content = implode( '', $content ); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | if ( $atts['clickable'] ) { |
@@ -409,11 +409,11 @@ discard block |
||
409 | 409 | |
410 | 410 | // merge defaults, global settings, and shortcode options |
411 | 411 | foreach ( $default_settings as $key => $setting ) { |
412 | - if ( $atts[ $key ] != '' ) { |
|
412 | + if ( $atts[$key] != '' ) { |
|
413 | 413 | continue; |
414 | 414 | } |
415 | 415 | |
416 | - $atts[ $key ] = $setting; |
|
416 | + $atts[$key] = $setting; |
|
417 | 417 | unset( $key, $setting ); |
418 | 418 | } |
419 | 419 | } |