@@ -12,123 +12,123 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public static $plug_version = '2.0.19b3'; |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @since 1.07.02 |
|
| 17 | - * |
|
| 18 | - * @param none |
|
| 19 | - * @return string The version of this plugin |
|
| 20 | - */ |
|
| 21 | - public static function plugin_version() { |
|
| 22 | - return self::$plug_version; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public static function plugin_folder() { |
|
| 26 | - return basename(self::plugin_path()); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public static function plugin_path() { |
|
| 30 | - return dirname(dirname(dirname(__FILE__))); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public static function plugin_url() { |
|
| 34 | - //prevously FRM_URL constant |
|
| 35 | - return plugins_url( '', self::plugin_path() .'/formidable.php' ); |
|
| 36 | - } |
|
| 15 | + /** |
|
| 16 | + * @since 1.07.02 |
|
| 17 | + * |
|
| 18 | + * @param none |
|
| 19 | + * @return string The version of this plugin |
|
| 20 | + */ |
|
| 21 | + public static function plugin_version() { |
|
| 22 | + return self::$plug_version; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public static function plugin_folder() { |
|
| 26 | + return basename(self::plugin_path()); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public static function plugin_path() { |
|
| 30 | + return dirname(dirname(dirname(__FILE__))); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public static function plugin_url() { |
|
| 34 | + //prevously FRM_URL constant |
|
| 35 | + return plugins_url( '', self::plugin_path() .'/formidable.php' ); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | public static function relative_plugin_url() { |
| 39 | 39 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @return string Site URL |
|
| 44 | - */ |
|
| 45 | - public static function site_url() { |
|
| 46 | - return site_url(); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Get the name of this site |
|
| 51 | - * Used for [sitename] shortcode |
|
| 52 | - * |
|
| 53 | - * @since 2.0 |
|
| 54 | - * @return string |
|
| 55 | - */ |
|
| 56 | - public static function site_name() { |
|
| 57 | - return get_option('blogname'); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Get the Formidable settings |
|
| 62 | - * |
|
| 63 | - * @since 2.0 |
|
| 64 | - * |
|
| 65 | - * @param None |
|
| 66 | - * @return FrmSettings $frm_setings |
|
| 67 | - */ |
|
| 68 | - public static function get_settings() { |
|
| 69 | - global $frm_settings; |
|
| 70 | - if ( empty($frm_settings) ) { |
|
| 71 | - $frm_settings = new FrmSettings(); |
|
| 72 | - } |
|
| 73 | - return $frm_settings; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Show a message in place of pro features |
|
| 78 | - * |
|
| 79 | - * @since 2.0 |
|
| 80 | - */ |
|
| 42 | + /** |
|
| 43 | + * @return string Site URL |
|
| 44 | + */ |
|
| 45 | + public static function site_url() { |
|
| 46 | + return site_url(); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Get the name of this site |
|
| 51 | + * Used for [sitename] shortcode |
|
| 52 | + * |
|
| 53 | + * @since 2.0 |
|
| 54 | + * @return string |
|
| 55 | + */ |
|
| 56 | + public static function site_name() { |
|
| 57 | + return get_option('blogname'); |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Get the Formidable settings |
|
| 62 | + * |
|
| 63 | + * @since 2.0 |
|
| 64 | + * |
|
| 65 | + * @param None |
|
| 66 | + * @return FrmSettings $frm_setings |
|
| 67 | + */ |
|
| 68 | + public static function get_settings() { |
|
| 69 | + global $frm_settings; |
|
| 70 | + if ( empty($frm_settings) ) { |
|
| 71 | + $frm_settings = new FrmSettings(); |
|
| 72 | + } |
|
| 73 | + return $frm_settings; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Show a message in place of pro features |
|
| 78 | + * |
|
| 79 | + * @since 2.0 |
|
| 80 | + */ |
|
| 81 | 81 | public static function update_message( $features, $class = '' ) { |
| 82 | 82 | _deprecated_function( __FUNCTION__, '2.0.19' ); |
| 83 | - } |
|
| 84 | - |
|
| 85 | - public static function pro_is_installed() { |
|
| 86 | - return apply_filters('frm_pro_installed', false); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * Check for certain page in Formidable settings |
|
| 91 | - * |
|
| 92 | - * @since 2.0 |
|
| 93 | - * |
|
| 94 | - * @param string $page The name of the page to check |
|
| 95 | - * @return boolean |
|
| 96 | - */ |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + public static function pro_is_installed() { |
|
| 86 | + return apply_filters('frm_pro_installed', false); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * Check for certain page in Formidable settings |
|
| 91 | + * |
|
| 92 | + * @since 2.0 |
|
| 93 | + * |
|
| 94 | + * @param string $page The name of the page to check |
|
| 95 | + * @return boolean |
|
| 96 | + */ |
|
| 97 | 97 | public static function is_admin_page( $page = 'formidable' ) { |
| 98 | - global $pagenow; |
|
| 98 | + global $pagenow; |
|
| 99 | 99 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 100 | - if ( $pagenow ) { |
|
| 100 | + if ( $pagenow ) { |
|
| 101 | 101 | return $pagenow == 'admin.php' && $get_page == $page; |
| 102 | - } |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | return is_admin() && $get_page == $page; |
| 105 | - } |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * Check for the form preview page |
|
| 109 | - * |
|
| 110 | - * @since 2.0 |
|
| 111 | - * |
|
| 112 | - * @param None |
|
| 113 | - * @return boolean |
|
| 114 | - */ |
|
| 115 | - public static function is_preview_page() { |
|
| 116 | - global $pagenow; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * Check for the form preview page |
|
| 109 | + * |
|
| 110 | + * @since 2.0 |
|
| 111 | + * |
|
| 112 | + * @param None |
|
| 113 | + * @return boolean |
|
| 114 | + */ |
|
| 115 | + public static function is_preview_page() { |
|
| 116 | + global $pagenow; |
|
| 117 | 117 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
| 118 | 118 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 119 | - } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - /** |
|
| 122 | - * Check for ajax except the form preview page |
|
| 123 | - * |
|
| 124 | - * @since 2.0 |
|
| 125 | - * |
|
| 126 | - * @param None |
|
| 127 | - * @return boolean |
|
| 128 | - */ |
|
| 129 | - public static function doing_ajax() { |
|
| 130 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 131 | - } |
|
| 121 | + /** |
|
| 122 | + * Check for ajax except the form preview page |
|
| 123 | + * |
|
| 124 | + * @since 2.0 |
|
| 125 | + * |
|
| 126 | + * @param None |
|
| 127 | + * @return boolean |
|
| 128 | + */ |
|
| 129 | + public static function doing_ajax() { |
|
| 130 | + return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | /** |
| 134 | 134 | * @since 2.0.8 |
@@ -138,101 +138,101 @@ discard block |
||
| 138 | 138 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - /** |
|
| 142 | - * Check if on an admin page |
|
| 143 | - * |
|
| 144 | - * @since 2.0 |
|
| 145 | - * |
|
| 146 | - * @param None |
|
| 147 | - * @return boolean |
|
| 148 | - */ |
|
| 149 | - public static function is_admin() { |
|
| 150 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * Check if value contains blank value or empty array |
|
| 155 | - * |
|
| 156 | - * @since 2.0 |
|
| 157 | - * @param $value - value to check |
|
| 158 | - * @return boolean |
|
| 159 | - */ |
|
| 160 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 161 | - return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 165 | - return ! self::is_empty_value( $value, $empty ); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * Get any value from the $_SERVER |
|
| 170 | - * |
|
| 171 | - * @since 2.0 |
|
| 172 | - * @param string $value |
|
| 173 | - * @return string |
|
| 174 | - */ |
|
| 141 | + /** |
|
| 142 | + * Check if on an admin page |
|
| 143 | + * |
|
| 144 | + * @since 2.0 |
|
| 145 | + * |
|
| 146 | + * @param None |
|
| 147 | + * @return boolean |
|
| 148 | + */ |
|
| 149 | + public static function is_admin() { |
|
| 150 | + return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * Check if value contains blank value or empty array |
|
| 155 | + * |
|
| 156 | + * @since 2.0 |
|
| 157 | + * @param $value - value to check |
|
| 158 | + * @return boolean |
|
| 159 | + */ |
|
| 160 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 161 | + return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 165 | + return ! self::is_empty_value( $value, $empty ); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * Get any value from the $_SERVER |
|
| 170 | + * |
|
| 171 | + * @since 2.0 |
|
| 172 | + * @param string $value |
|
| 173 | + * @return string |
|
| 174 | + */ |
|
| 175 | 175 | public static function get_server_value( $value ) { |
| 176 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * Check for the IP address in several places |
|
| 181 | - * Used by [ip] shortcode |
|
| 182 | - * |
|
| 183 | - * @return string The IP address of the current user |
|
| 184 | - */ |
|
| 185 | - public static function get_ip_address() { |
|
| 176 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * Check for the IP address in several places |
|
| 181 | + * Used by [ip] shortcode |
|
| 182 | + * |
|
| 183 | + * @return string The IP address of the current user |
|
| 184 | + */ |
|
| 185 | + public static function get_ip_address() { |
|
| 186 | 186 | $ip = ''; |
| 187 | - foreach ( array( |
|
| 188 | - 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 189 | - 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
| 190 | - ) as $key ) { |
|
| 191 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 192 | - continue; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 196 | - $ip = trim($ip); // just to be safe |
|
| 197 | - |
|
| 198 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 199 | - return $ip; |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - } |
|
| 187 | + foreach ( array( |
|
| 188 | + 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 189 | + 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
| 190 | + ) as $key ) { |
|
| 191 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 192 | + continue; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 196 | + $ip = trim($ip); // just to be safe |
|
| 197 | + |
|
| 198 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 199 | + return $ip; |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | return sanitize_text_field( $ip ); |
| 205 | - } |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 208 | - if ( strpos($param, '[') ) { |
|
| 209 | - $params = explode('[', $param); |
|
| 210 | - $param = $params[0]; |
|
| 211 | - } |
|
| 207 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 208 | + if ( strpos($param, '[') ) { |
|
| 209 | + $params = explode('[', $param); |
|
| 210 | + $param = $params[0]; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | 213 | if ( $src == 'get' ) { |
| 214 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 215 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 216 | - $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
| 217 | - } |
|
| 214 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 215 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 216 | + $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
| 217 | + } |
|
| 218 | 218 | self::sanitize_value( $sanitize, $value ); |
| 219 | 219 | } else { |
| 220 | - $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
| 221 | - } |
|
| 220 | + $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | 223 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 224 | - foreach ( $params as $k => $p ) { |
|
| 225 | - if ( ! $k || ! is_array($value) ) { |
|
| 226 | - continue; |
|
| 227 | - } |
|
| 224 | + foreach ( $params as $k => $p ) { |
|
| 225 | + if ( ! $k || ! is_array($value) ) { |
|
| 226 | + continue; |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - $p = trim($p, ']'); |
|
| 230 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 231 | - } |
|
| 232 | - } |
|
| 229 | + $p = trim($p, ']'); |
|
| 230 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - return $value; |
|
| 235 | - } |
|
| 234 | + return $value; |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | 237 | /** |
| 238 | 238 | * |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) { |
| 255 | 255 | return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
| 256 | - } |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | 259 | * Get a GET/POST/REQUEST value and sanitize it |
@@ -287,12 +287,12 @@ discard block |
||
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
| 290 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 291 | - * |
|
| 292 | - * @since 2.0.8 |
|
| 293 | - * @param string $value |
|
| 294 | - * @return string $value |
|
| 295 | - */ |
|
| 290 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 291 | + * |
|
| 292 | + * @since 2.0.8 |
|
| 293 | + * @param string $value |
|
| 294 | + * @return string $value |
|
| 295 | + */ |
|
| 296 | 296 | public static function preserve_backslashes( $value ) { |
| 297 | 297 | // If backslashes have already been added, don't add them again |
| 298 | 298 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -311,14 +311,14 @@ discard block |
||
| 311 | 311 | } |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 315 | - $temp_values = $values; |
|
| 316 | - foreach ( $temp_values as $k => $val ) { |
|
| 317 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 314 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 315 | + $temp_values = $values; |
|
| 316 | + foreach ( $temp_values as $k => $val ) { |
|
| 317 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 318 | 318 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 319 | - } |
|
| 320 | - } |
|
| 321 | - } |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | 323 | public static function sanitize_array( &$values ) { |
| 324 | 324 | $temp_values = $values; |
@@ -333,12 +333,12 @@ discard block |
||
| 333 | 333 | */ |
| 334 | 334 | public static function kses( $value, $allowed = array() ) { |
| 335 | 335 | $html = array( |
| 336 | - 'a' => array( |
|
| 336 | + 'a' => array( |
|
| 337 | 337 | 'href' => array(), |
| 338 | 338 | 'title' => array(), |
| 339 | 339 | 'id' => array(), |
| 340 | 340 | 'class' => array(), |
| 341 | - ), |
|
| 341 | + ), |
|
| 342 | 342 | ); |
| 343 | 343 | |
| 344 | 344 | $allowed_html = array(); |
@@ -349,176 +349,176 @@ discard block |
||
| 349 | 349 | return wp_kses( $value, $allowed_html ); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | - /** |
|
| 353 | - * Used when switching the action for a bulk action |
|
| 354 | - * @since 2.0 |
|
| 355 | - */ |
|
| 356 | - public static function remove_get_action() { |
|
| 357 | - if ( ! isset($_GET) ) { |
|
| 358 | - return; |
|
| 359 | - } |
|
| 352 | + /** |
|
| 353 | + * Used when switching the action for a bulk action |
|
| 354 | + * @since 2.0 |
|
| 355 | + */ |
|
| 356 | + public static function remove_get_action() { |
|
| 357 | + if ( ! isset($_GET) ) { |
|
| 358 | + return; |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 362 | - if ( ! empty( $new_action ) ) { |
|
| 361 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 362 | + if ( ! empty( $new_action ) ) { |
|
| 363 | 363 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 364 | - } |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - /** |
|
| 368 | - * Check the WP query for a parameter |
|
| 369 | - * |
|
| 370 | - * @since 2.0 |
|
| 371 | - * @return string|array |
|
| 372 | - */ |
|
| 373 | - public static function get_query_var( $value, $param ) { |
|
| 374 | - if ( $value != '' ) { |
|
| 375 | - return $value; |
|
| 376 | - } |
|
| 377 | - |
|
| 378 | - global $wp_query; |
|
| 379 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 380 | - $value = $wp_query->query_vars[ $param ]; |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - return $value; |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * @param string $type |
|
| 388 | - */ |
|
| 389 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 390 | - // only load the form hooks once |
|
| 391 | - $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object); |
|
| 392 | - if ( ! $hooks_loaded ) { |
|
| 393 | - do_action('frm_load_'. $type .'_hooks'); |
|
| 394 | - } |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - /** |
|
| 398 | - * Check cache before fetching values and saving to cache |
|
| 399 | - * |
|
| 400 | - * @since 2.0 |
|
| 401 | - * |
|
| 402 | - * @param string $cache_key The unique name for this cache |
|
| 403 | - * @param string $group The name of the cache group |
|
| 404 | - * @param string $query If blank, don't run a db call |
|
| 405 | - * @param string $type The wpdb function to use with this query |
|
| 406 | - * @return mixed $results The cache or query results |
|
| 407 | - */ |
|
| 408 | - public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
| 409 | - $results = wp_cache_get($cache_key, $group); |
|
| 410 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 411 | - return $results; |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - if ( 'get_posts' == $type ) { |
|
| 415 | - $results = get_posts($query); |
|
| 416 | - } else { |
|
| 417 | - global $wpdb; |
|
| 418 | - $results = $wpdb->{$type}($query); |
|
| 419 | - } |
|
| 364 | + } |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + /** |
|
| 368 | + * Check the WP query for a parameter |
|
| 369 | + * |
|
| 370 | + * @since 2.0 |
|
| 371 | + * @return string|array |
|
| 372 | + */ |
|
| 373 | + public static function get_query_var( $value, $param ) { |
|
| 374 | + if ( $value != '' ) { |
|
| 375 | + return $value; |
|
| 376 | + } |
|
| 377 | + |
|
| 378 | + global $wp_query; |
|
| 379 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 380 | + $value = $wp_query->query_vars[ $param ]; |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + return $value; |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * @param string $type |
|
| 388 | + */ |
|
| 389 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 390 | + // only load the form hooks once |
|
| 391 | + $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object); |
|
| 392 | + if ( ! $hooks_loaded ) { |
|
| 393 | + do_action('frm_load_'. $type .'_hooks'); |
|
| 394 | + } |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + /** |
|
| 398 | + * Check cache before fetching values and saving to cache |
|
| 399 | + * |
|
| 400 | + * @since 2.0 |
|
| 401 | + * |
|
| 402 | + * @param string $cache_key The unique name for this cache |
|
| 403 | + * @param string $group The name of the cache group |
|
| 404 | + * @param string $query If blank, don't run a db call |
|
| 405 | + * @param string $type The wpdb function to use with this query |
|
| 406 | + * @return mixed $results The cache or query results |
|
| 407 | + */ |
|
| 408 | + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
| 409 | + $results = wp_cache_get($cache_key, $group); |
|
| 410 | + if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 411 | + return $results; |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + if ( 'get_posts' == $type ) { |
|
| 415 | + $results = get_posts($query); |
|
| 416 | + } else { |
|
| 417 | + global $wpdb; |
|
| 418 | + $results = $wpdb->{$type}($query); |
|
| 419 | + } |
|
| 420 | 420 | |
| 421 | 421 | if ( ! self::prevent_caching() ) { |
| 422 | 422 | wp_cache_set( $cache_key, $results, $group, $time ); |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - return $results; |
|
| 426 | - } |
|
| 425 | + return $results; |
|
| 426 | + } |
|
| 427 | 427 | |
| 428 | - /** |
|
| 429 | - * Data that should be stored for a long time can be stored in a transient. |
|
| 430 | - * First check the cache, then check the transient |
|
| 431 | - * @since 2.0 |
|
| 432 | - * @return mixed The cached value or false |
|
| 433 | - */ |
|
| 428 | + /** |
|
| 429 | + * Data that should be stored for a long time can be stored in a transient. |
|
| 430 | + * First check the cache, then check the transient |
|
| 431 | + * @since 2.0 |
|
| 432 | + * @return mixed The cached value or false |
|
| 433 | + */ |
|
| 434 | 434 | public static function check_cache_and_transient( $cache_key ) { |
| 435 | - // check caching layer first |
|
| 436 | - $results = self::check_cache( $cache_key ); |
|
| 437 | - if ( $results ) { |
|
| 438 | - return $results; |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - // then check the transient |
|
| 442 | - $results = get_transient($cache_key); |
|
| 443 | - if ( $results ) { |
|
| 444 | - wp_cache_set($cache_key, $results); |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - return $results; |
|
| 448 | - } |
|
| 449 | - |
|
| 450 | - /** |
|
| 451 | - * @since 2.0 |
|
| 452 | - * @param string $cache_key |
|
| 453 | - */ |
|
| 435 | + // check caching layer first |
|
| 436 | + $results = self::check_cache( $cache_key ); |
|
| 437 | + if ( $results ) { |
|
| 438 | + return $results; |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + // then check the transient |
|
| 442 | + $results = get_transient($cache_key); |
|
| 443 | + if ( $results ) { |
|
| 444 | + wp_cache_set($cache_key, $results); |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + return $results; |
|
| 448 | + } |
|
| 449 | + |
|
| 450 | + /** |
|
| 451 | + * @since 2.0 |
|
| 452 | + * @param string $cache_key |
|
| 453 | + */ |
|
| 454 | 454 | public static function delete_cache_and_transient( $cache_key ) { |
| 455 | - delete_transient($cache_key); |
|
| 456 | - wp_cache_delete($cache_key); |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - /** |
|
| 460 | - * Delete all caching in a single group |
|
| 461 | - * |
|
| 462 | - * @since 2.0 |
|
| 463 | - * |
|
| 464 | - * @param string $group The name of the cache group |
|
| 465 | - * @return boolean True or False |
|
| 466 | - */ |
|
| 455 | + delete_transient($cache_key); |
|
| 456 | + wp_cache_delete($cache_key); |
|
| 457 | + } |
|
| 458 | + |
|
| 459 | + /** |
|
| 460 | + * Delete all caching in a single group |
|
| 461 | + * |
|
| 462 | + * @since 2.0 |
|
| 463 | + * |
|
| 464 | + * @param string $group The name of the cache group |
|
| 465 | + * @return boolean True or False |
|
| 466 | + */ |
|
| 467 | 467 | public static function cache_delete_group( $group ) { |
| 468 | - global $wp_object_cache; |
|
| 469 | - |
|
| 470 | - if ( isset( $wp_object_cache->cache[ $group ] ) ) { |
|
| 471 | - foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { |
|
| 472 | - wp_cache_delete($k, $group); |
|
| 473 | - } |
|
| 474 | - return true; |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - return false; |
|
| 478 | - } |
|
| 479 | - |
|
| 480 | - /** |
|
| 481 | - * Check a value from a shortcode to see if true or false. |
|
| 482 | - * True when value is 1, true, 'true', 'yes' |
|
| 483 | - * |
|
| 484 | - * @since 1.07.10 |
|
| 485 | - * |
|
| 486 | - * @param string $value The value to compare |
|
| 487 | - * @return boolean True or False |
|
| 488 | - */ |
|
| 468 | + global $wp_object_cache; |
|
| 469 | + |
|
| 470 | + if ( isset( $wp_object_cache->cache[ $group ] ) ) { |
|
| 471 | + foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { |
|
| 472 | + wp_cache_delete($k, $group); |
|
| 473 | + } |
|
| 474 | + return true; |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + return false; |
|
| 478 | + } |
|
| 479 | + |
|
| 480 | + /** |
|
| 481 | + * Check a value from a shortcode to see if true or false. |
|
| 482 | + * True when value is 1, true, 'true', 'yes' |
|
| 483 | + * |
|
| 484 | + * @since 1.07.10 |
|
| 485 | + * |
|
| 486 | + * @param string $value The value to compare |
|
| 487 | + * @return boolean True or False |
|
| 488 | + */ |
|
| 489 | 489 | public static function is_true( $value ) { |
| 490 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 491 | - } |
|
| 490 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 491 | + } |
|
| 492 | 492 | |
| 493 | - /** |
|
| 494 | - * Used to filter shortcode in text widgets |
|
| 495 | - */ |
|
| 496 | - public static function widget_text_filter_callback( $matches ) { |
|
| 497 | - return do_shortcode( $matches[0] ); |
|
| 498 | - } |
|
| 493 | + /** |
|
| 494 | + * Used to filter shortcode in text widgets |
|
| 495 | + */ |
|
| 496 | + public static function widget_text_filter_callback( $matches ) { |
|
| 497 | + return do_shortcode( $matches[0] ); |
|
| 498 | + } |
|
| 499 | 499 | |
| 500 | 500 | public static function load_scripts( $scripts ) { |
| 501 | - _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
|
| 502 | - foreach ( (array) $scripts as $s ) { |
|
| 503 | - wp_enqueue_script($s); |
|
| 504 | - } |
|
| 505 | - } |
|
| 501 | + _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
|
| 502 | + foreach ( (array) $scripts as $s ) { |
|
| 503 | + wp_enqueue_script($s); |
|
| 504 | + } |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | 507 | public static function load_styles( $styles ) { |
| 508 | - _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
|
| 509 | - foreach ( (array) $styles as $s ) { |
|
| 510 | - wp_enqueue_style($s); |
|
| 511 | - } |
|
| 512 | - } |
|
| 508 | + _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
|
| 509 | + foreach ( (array) $styles as $s ) { |
|
| 510 | + wp_enqueue_style($s); |
|
| 511 | + } |
|
| 512 | + } |
|
| 513 | 513 | |
| 514 | - public static function get_pages() { |
|
| 514 | + public static function get_pages() { |
|
| 515 | 515 | return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
| 516 | - } |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 519 | - $pages = self::get_pages(); |
|
| 518 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 519 | + $pages = self::get_pages(); |
|
| 520 | 520 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 521 | - ?> |
|
| 521 | + ?> |
|
| 522 | 522 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
| 523 | 523 | <option value=""> </option> |
| 524 | 524 | <?php foreach ( $pages as $page ) { ?> |
@@ -528,107 +528,107 @@ discard block |
||
| 528 | 528 | <?php } ?> |
| 529 | 529 | </select> |
| 530 | 530 | <?php |
| 531 | - } |
|
| 531 | + } |
|
| 532 | 532 | |
| 533 | 533 | public static function post_edit_link( $post_id ) { |
| 534 | - $post = get_post($post_id); |
|
| 535 | - if ( $post ) { |
|
| 536 | - return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>'; |
|
| 537 | - } |
|
| 538 | - return ''; |
|
| 539 | - } |
|
| 534 | + $post = get_post($post_id); |
|
| 535 | + if ( $post ) { |
|
| 536 | + return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>'; |
|
| 537 | + } |
|
| 538 | + return ''; |
|
| 539 | + } |
|
| 540 | 540 | |
| 541 | 541 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 542 | - ?> |
|
| 542 | + ?> |
|
| 543 | 543 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
| 544 | - echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
| 545 | - ?> class="frm_multiselect"> |
|
| 544 | + echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
| 545 | + ?> class="frm_multiselect"> |
|
| 546 | 546 | <?php self::roles_options($capability); ?> |
| 547 | 547 | </select> |
| 548 | 548 | <?php |
| 549 | - } |
|
| 549 | + } |
|
| 550 | 550 | |
| 551 | 551 | public static function roles_options( $capability ) { |
| 552 | - global $frm_vars; |
|
| 553 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 554 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 555 | - } else { |
|
| 556 | - $editable_roles = get_editable_roles(); |
|
| 557 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - foreach ( $editable_roles as $role => $details ) { |
|
| 561 | - $name = translate_user_role($details['name'] ); ?> |
|
| 552 | + global $frm_vars; |
|
| 553 | + if ( isset($frm_vars['editable_roles']) ) { |
|
| 554 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 555 | + } else { |
|
| 556 | + $editable_roles = get_editable_roles(); |
|
| 557 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + foreach ( $editable_roles as $role => $details ) { |
|
| 561 | + $name = translate_user_role($details['name'] ); ?> |
|
| 562 | 562 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
| 563 | 563 | <?php |
| 564 | - unset($role, $details); |
|
| 565 | - } |
|
| 566 | - } |
|
| 564 | + unset($role, $details); |
|
| 565 | + } |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | 568 | public static function frm_capabilities( $type = 'auto' ) { |
| 569 | - $cap = array( |
|
| 570 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 571 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 572 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 573 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 574 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 575 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 576 | - ); |
|
| 569 | + $cap = array( |
|
| 570 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 571 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 572 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 573 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 574 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 575 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 576 | + ); |
|
| 577 | 577 | |
| 578 | 578 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 579 | - return $cap; |
|
| 580 | - } |
|
| 579 | + return $cap; |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 583 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 584 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 585 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 582 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 583 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 584 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 585 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 586 | 586 | |
| 587 | - return $cap; |
|
| 588 | - } |
|
| 587 | + return $cap; |
|
| 588 | + } |
|
| 589 | 589 | |
| 590 | 590 | public static function user_has_permission( $needed_role ) { |
| 591 | - if ( $needed_role == '-1' ) { |
|
| 592 | - return false; |
|
| 591 | + if ( $needed_role == '-1' ) { |
|
| 592 | + return false; |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 596 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 597 | - return true; |
|
| 598 | - } |
|
| 595 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 596 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 597 | + return true; |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 601 | - foreach ( $roles as $role ) { |
|
| 600 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 601 | + foreach ( $roles as $role ) { |
|
| 602 | 602 | if ( current_user_can( $role ) ) { |
| 603 | - return true; |
|
| 603 | + return true; |
|
| 604 | 604 | } |
| 605 | - if ( $role == $needed_role ) { |
|
| 606 | - break; |
|
| 605 | + if ( $role == $needed_role ) { |
|
| 606 | + break; |
|
| 607 | 607 | } |
| 608 | - } |
|
| 609 | - return false; |
|
| 610 | - } |
|
| 611 | - |
|
| 612 | - /** |
|
| 613 | - * Make sure administrators can see Formidable menu |
|
| 614 | - * |
|
| 615 | - * @since 2.0 |
|
| 616 | - */ |
|
| 617 | - public static function maybe_add_permissions() { |
|
| 608 | + } |
|
| 609 | + return false; |
|
| 610 | + } |
|
| 611 | + |
|
| 612 | + /** |
|
| 613 | + * Make sure administrators can see Formidable menu |
|
| 614 | + * |
|
| 615 | + * @since 2.0 |
|
| 616 | + */ |
|
| 617 | + public static function maybe_add_permissions() { |
|
| 618 | 618 | self::force_capability( 'frm_view_entries' ); |
| 619 | 619 | |
| 620 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 621 | - return; |
|
| 622 | - } |
|
| 620 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 621 | + return; |
|
| 622 | + } |
|
| 623 | 623 | |
| 624 | 624 | $user_id = get_current_user_id(); |
| 625 | 625 | $user = new WP_User( $user_id ); |
| 626 | - $frm_roles = self::frm_capabilities(); |
|
| 627 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 626 | + $frm_roles = self::frm_capabilities(); |
|
| 627 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 628 | 628 | $user->add_cap( $frm_role ); |
| 629 | - unset($frm_role, $frm_role_description); |
|
| 630 | - } |
|
| 631 | - } |
|
| 629 | + unset($frm_role, $frm_role_description); |
|
| 630 | + } |
|
| 631 | + } |
|
| 632 | 632 | |
| 633 | 633 | /** |
| 634 | 634 | * Make sure admins have permission to see the menu items |
@@ -644,28 +644,28 @@ discard block |
||
| 644 | 644 | } |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - /** |
|
| 648 | - * Check if the user has permision for action. |
|
| 649 | - * Return permission message and stop the action if no permission |
|
| 650 | - * @since 2.0 |
|
| 651 | - * @param string $permission |
|
| 652 | - */ |
|
| 647 | + /** |
|
| 648 | + * Check if the user has permision for action. |
|
| 649 | + * Return permission message and stop the action if no permission |
|
| 650 | + * @since 2.0 |
|
| 651 | + * @param string $permission |
|
| 652 | + */ |
|
| 653 | 653 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 654 | - $permission_error = self::permission_nonce_error($permission); |
|
| 655 | - if ( $permission_error !== false ) { |
|
| 656 | - if ( 'hide' == $show_message ) { |
|
| 657 | - $permission_error = ''; |
|
| 658 | - } |
|
| 659 | - wp_die($permission_error); |
|
| 660 | - } |
|
| 661 | - } |
|
| 662 | - |
|
| 663 | - /** |
|
| 664 | - * Check user permission and nonce |
|
| 665 | - * @since 2.0 |
|
| 666 | - * @param string $permission |
|
| 667 | - * @return false|string The permission message or false if allowed |
|
| 668 | - */ |
|
| 654 | + $permission_error = self::permission_nonce_error($permission); |
|
| 655 | + if ( $permission_error !== false ) { |
|
| 656 | + if ( 'hide' == $show_message ) { |
|
| 657 | + $permission_error = ''; |
|
| 658 | + } |
|
| 659 | + wp_die($permission_error); |
|
| 660 | + } |
|
| 661 | + } |
|
| 662 | + |
|
| 663 | + /** |
|
| 664 | + * Check user permission and nonce |
|
| 665 | + * @since 2.0 |
|
| 666 | + * @param string $permission |
|
| 667 | + * @return false|string The permission message or false if allowed |
|
| 668 | + */ |
|
| 669 | 669 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 670 | 670 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 671 | 671 | $frm_settings = self::get_settings(); |
@@ -673,75 +673,75 @@ discard block |
||
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | $error = false; |
| 676 | - if ( empty($nonce_name) ) { |
|
| 677 | - return $error; |
|
| 678 | - } |
|
| 676 | + if ( empty($nonce_name) ) { |
|
| 677 | + return $error; |
|
| 678 | + } |
|
| 679 | 679 | |
| 680 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 681 | - $frm_settings = self::get_settings(); |
|
| 682 | - $error = $frm_settings->admin_permission; |
|
| 683 | - } |
|
| 680 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 681 | + $frm_settings = self::get_settings(); |
|
| 682 | + $error = $frm_settings->admin_permission; |
|
| 683 | + } |
|
| 684 | 684 | |
| 685 | - return $error; |
|
| 686 | - } |
|
| 685 | + return $error; |
|
| 686 | + } |
|
| 687 | 687 | |
| 688 | - public static function checked( $values, $current ) { |
|
| 688 | + public static function checked( $values, $current ) { |
|
| 689 | 689 | if ( self::check_selected( $values, $current ) ) { |
| 690 | - echo ' checked="checked"'; |
|
| 690 | + echo ' checked="checked"'; |
|
| 691 | 691 | } |
| 692 | - } |
|
| 692 | + } |
|
| 693 | 693 | |
| 694 | 694 | public static function check_selected( $values, $current ) { |
| 695 | - $values = self::recursive_function_map( $values, 'trim' ); |
|
| 696 | - $current = trim($current); |
|
| 697 | - |
|
| 698 | - return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current ); |
|
| 699 | - } |
|
| 700 | - |
|
| 701 | - /** |
|
| 702 | - * Check if current field option is an "other" option |
|
| 703 | - * |
|
| 704 | - * @since 2.0 |
|
| 705 | - * |
|
| 706 | - * @param string $opt_key |
|
| 707 | - * @return boolean Returns true if current field option is an "Other" option |
|
| 708 | - */ |
|
| 709 | - public static function is_other_opt( $opt_key ) { |
|
| 710 | - _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
| 711 | - return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
| 712 | - } |
|
| 713 | - |
|
| 714 | - /** |
|
| 715 | - * Get value that belongs in "Other" text box |
|
| 716 | - * |
|
| 717 | - * @since 2.0 |
|
| 718 | - * |
|
| 719 | - * @param string $opt_key |
|
| 720 | - * @param array $field |
|
| 721 | - * @return string $other_val |
|
| 722 | - */ |
|
| 723 | - public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
| 695 | + $values = self::recursive_function_map( $values, 'trim' ); |
|
| 696 | + $current = trim($current); |
|
| 697 | + |
|
| 698 | + return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current ); |
|
| 699 | + } |
|
| 700 | + |
|
| 701 | + /** |
|
| 702 | + * Check if current field option is an "other" option |
|
| 703 | + * |
|
| 704 | + * @since 2.0 |
|
| 705 | + * |
|
| 706 | + * @param string $opt_key |
|
| 707 | + * @return boolean Returns true if current field option is an "Other" option |
|
| 708 | + */ |
|
| 709 | + public static function is_other_opt( $opt_key ) { |
|
| 710 | + _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
| 711 | + return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
| 712 | + } |
|
| 713 | + |
|
| 714 | + /** |
|
| 715 | + * Get value that belongs in "Other" text box |
|
| 716 | + * |
|
| 717 | + * @since 2.0 |
|
| 718 | + * |
|
| 719 | + * @param string $opt_key |
|
| 720 | + * @param array $field |
|
| 721 | + * @return string $other_val |
|
| 722 | + */ |
|
| 723 | + public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
| 724 | 724 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' ); |
| 725 | 725 | return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) ); |
| 726 | - } |
|
| 727 | - |
|
| 728 | - /** |
|
| 729 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 730 | - * Intended for front-end use |
|
| 731 | - * |
|
| 732 | - * @since 2.0 |
|
| 733 | - * |
|
| 734 | - * @param array $field |
|
| 735 | - * @param boolean $other_opt |
|
| 736 | - * @param string $checked |
|
| 737 | - * @param array $args should include opt_key and field name |
|
| 738 | - * @return string $other_val |
|
| 739 | - */ |
|
| 740 | - public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
| 726 | + } |
|
| 727 | + |
|
| 728 | + /** |
|
| 729 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 730 | + * Intended for front-end use |
|
| 731 | + * |
|
| 732 | + * @since 2.0 |
|
| 733 | + * |
|
| 734 | + * @param array $field |
|
| 735 | + * @param boolean $other_opt |
|
| 736 | + * @param string $checked |
|
| 737 | + * @param array $args should include opt_key and field name |
|
| 738 | + * @return string $other_val |
|
| 739 | + */ |
|
| 740 | + public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
| 741 | 741 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' ); |
| 742 | 742 | $args['field'] = $field; |
| 743 | 743 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
| 744 | - } |
|
| 744 | + } |
|
| 745 | 745 | |
| 746 | 746 | public static function recursive_function_map( $value, $function ) { |
| 747 | 747 | if ( is_array( $value ) ) { |
@@ -771,334 +771,334 @@ discard block |
||
| 771 | 771 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - /** |
|
| 775 | - * Flatten a multi-dimensional array |
|
| 776 | - */ |
|
| 774 | + /** |
|
| 775 | + * Flatten a multi-dimensional array |
|
| 776 | + */ |
|
| 777 | 777 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 778 | - $return = array(); |
|
| 779 | - foreach ( $array as $key => $value ) { |
|
| 780 | - if ( is_array($value) ) { |
|
| 778 | + $return = array(); |
|
| 779 | + foreach ( $array as $key => $value ) { |
|
| 780 | + if ( is_array($value) ) { |
|
| 781 | 781 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 782 | - } else { |
|
| 782 | + } else { |
|
| 783 | 783 | if ( $keys == 'keep' ) { |
| 784 | 784 | $return[ $key ] = $value; |
| 785 | 785 | } else { |
| 786 | 786 | $return[] = $value; |
| 787 | 787 | } |
| 788 | - } |
|
| 789 | - } |
|
| 790 | - return $return; |
|
| 791 | - } |
|
| 792 | - |
|
| 793 | - public static function esc_textarea( $text ) { |
|
| 794 | - $safe_text = str_replace('"', '"', $text); |
|
| 795 | - $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
|
| 796 | - return apply_filters( 'esc_textarea', $safe_text, $text ); |
|
| 797 | - } |
|
| 798 | - |
|
| 799 | - /** |
|
| 800 | - * Add auto paragraphs to text areas |
|
| 801 | - * @since 2.0 |
|
| 802 | - */ |
|
| 788 | + } |
|
| 789 | + } |
|
| 790 | + return $return; |
|
| 791 | + } |
|
| 792 | + |
|
| 793 | + public static function esc_textarea( $text ) { |
|
| 794 | + $safe_text = str_replace('"', '"', $text); |
|
| 795 | + $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
|
| 796 | + return apply_filters( 'esc_textarea', $safe_text, $text ); |
|
| 797 | + } |
|
| 798 | + |
|
| 799 | + /** |
|
| 800 | + * Add auto paragraphs to text areas |
|
| 801 | + * @since 2.0 |
|
| 802 | + */ |
|
| 803 | 803 | public static function use_wpautop( $content ) { |
| 804 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 805 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 806 | - } |
|
| 807 | - return $content; |
|
| 808 | - } |
|
| 804 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 805 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 806 | + } |
|
| 807 | + return $content; |
|
| 808 | + } |
|
| 809 | 809 | |
| 810 | 810 | public static function replace_quotes( $val ) { |
| 811 | - //Replace double quotes |
|
| 811 | + //Replace double quotes |
|
| 812 | 812 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 813 | - //Replace single quotes |
|
| 814 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 815 | - return $val; |
|
| 816 | - } |
|
| 817 | - |
|
| 818 | - /** |
|
| 819 | - * @since 2.0 |
|
| 820 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 821 | - */ |
|
| 822 | - public static function jquery_ui_base_url() { |
|
| 823 | - $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core'); |
|
| 824 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 825 | - return $url; |
|
| 826 | - } |
|
| 827 | - |
|
| 828 | - /** |
|
| 829 | - * @param string $handle |
|
| 830 | - */ |
|
| 813 | + //Replace single quotes |
|
| 814 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 815 | + return $val; |
|
| 816 | + } |
|
| 817 | + |
|
| 818 | + /** |
|
| 819 | + * @since 2.0 |
|
| 820 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 821 | + */ |
|
| 822 | + public static function jquery_ui_base_url() { |
|
| 823 | + $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core'); |
|
| 824 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 825 | + return $url; |
|
| 826 | + } |
|
| 827 | + |
|
| 828 | + /** |
|
| 829 | + * @param string $handle |
|
| 830 | + */ |
|
| 831 | 831 | public static function script_version( $handle ) { |
| 832 | - global $wp_scripts; |
|
| 833 | - if ( ! $wp_scripts ) { |
|
| 834 | - return false; |
|
| 835 | - } |
|
| 832 | + global $wp_scripts; |
|
| 833 | + if ( ! $wp_scripts ) { |
|
| 834 | + return false; |
|
| 835 | + } |
|
| 836 | 836 | |
| 837 | - $ver = 0; |
|
| 837 | + $ver = 0; |
|
| 838 | 838 | |
| 839 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
| 840 | - return $ver; |
|
| 841 | - } |
|
| 839 | + if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
| 840 | + return $ver; |
|
| 841 | + } |
|
| 842 | 842 | |
| 843 | - $query = $wp_scripts->registered[ $handle ]; |
|
| 844 | - if ( is_object( $query ) ) { |
|
| 845 | - $ver = $query->ver; |
|
| 846 | - } |
|
| 843 | + $query = $wp_scripts->registered[ $handle ]; |
|
| 844 | + if ( is_object( $query ) ) { |
|
| 845 | + $ver = $query->ver; |
|
| 846 | + } |
|
| 847 | 847 | |
| 848 | - return $ver; |
|
| 849 | - } |
|
| 848 | + return $ver; |
|
| 849 | + } |
|
| 850 | 850 | |
| 851 | 851 | public static function js_redirect( $url ) { |
| 852 | 852 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 853 | - } |
|
| 853 | + } |
|
| 854 | 854 | |
| 855 | 855 | public static function get_user_id_param( $user_id ) { |
| 856 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 857 | - return $user_id; |
|
| 858 | - } |
|
| 856 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 857 | + return $user_id; |
|
| 858 | + } |
|
| 859 | 859 | |
| 860 | 860 | if ( $user_id == 'current' ) { |
| 861 | - $user_ID = get_current_user_id(); |
|
| 862 | - $user_id = $user_ID; |
|
| 861 | + $user_ID = get_current_user_id(); |
|
| 862 | + $user_id = $user_ID; |
|
| 863 | 863 | } else { |
| 864 | - if ( is_email($user_id) ) { |
|
| 865 | - $user = get_user_by('email', $user_id); |
|
| 866 | - } else { |
|
| 867 | - $user = get_user_by('login', $user_id); |
|
| 868 | - } |
|
| 864 | + if ( is_email($user_id) ) { |
|
| 865 | + $user = get_user_by('email', $user_id); |
|
| 866 | + } else { |
|
| 867 | + $user = get_user_by('login', $user_id); |
|
| 868 | + } |
|
| 869 | 869 | |
| 870 | - if ( $user ) { |
|
| 871 | - $user_id = $user->ID; |
|
| 872 | - } |
|
| 873 | - unset($user); |
|
| 874 | - } |
|
| 870 | + if ( $user ) { |
|
| 871 | + $user_id = $user->ID; |
|
| 872 | + } |
|
| 873 | + unset($user); |
|
| 874 | + } |
|
| 875 | 875 | |
| 876 | - return $user_id; |
|
| 877 | - } |
|
| 876 | + return $user_id; |
|
| 877 | + } |
|
| 878 | 878 | |
| 879 | 879 | public static function get_file_contents( $filename, $atts = array() ) { |
| 880 | - if ( ! is_file($filename) ) { |
|
| 881 | - return false; |
|
| 882 | - } |
|
| 883 | - |
|
| 884 | - extract($atts); |
|
| 885 | - ob_start(); |
|
| 886 | - include($filename); |
|
| 887 | - $contents = ob_get_contents(); |
|
| 888 | - ob_end_clean(); |
|
| 889 | - return $contents; |
|
| 890 | - } |
|
| 891 | - |
|
| 892 | - /** |
|
| 893 | - * @param string $table_name |
|
| 894 | - * @param string $column |
|
| 895 | - */ |
|
| 896 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 6 ) { |
|
| 897 | - global $wpdb; |
|
| 898 | - |
|
| 899 | - $key = ''; |
|
| 900 | - |
|
| 901 | - if ( ! empty( $name ) ) { |
|
| 902 | - $key = sanitize_key($name); |
|
| 903 | - } |
|
| 880 | + if ( ! is_file($filename) ) { |
|
| 881 | + return false; |
|
| 882 | + } |
|
| 883 | + |
|
| 884 | + extract($atts); |
|
| 885 | + ob_start(); |
|
| 886 | + include($filename); |
|
| 887 | + $contents = ob_get_contents(); |
|
| 888 | + ob_end_clean(); |
|
| 889 | + return $contents; |
|
| 890 | + } |
|
| 891 | + |
|
| 892 | + /** |
|
| 893 | + * @param string $table_name |
|
| 894 | + * @param string $column |
|
| 895 | + */ |
|
| 896 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 6 ) { |
|
| 897 | + global $wpdb; |
|
| 898 | + |
|
| 899 | + $key = ''; |
|
| 900 | + |
|
| 901 | + if ( ! empty( $name ) ) { |
|
| 902 | + $key = sanitize_key($name); |
|
| 903 | + } |
|
| 904 | 904 | |
| 905 | 905 | if ( empty( $key ) ) { |
| 906 | - $max_slug_value = pow(36, $num_chars); |
|
| 907 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 908 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 909 | - } |
|
| 906 | + $max_slug_value = pow(36, $num_chars); |
|
| 907 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 908 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 909 | + } |
|
| 910 | 910 | |
| 911 | 911 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 912 | - $key = $key .'a'; |
|
| 913 | - } |
|
| 912 | + $key = $key .'a'; |
|
| 913 | + } |
|
| 914 | 914 | |
| 915 | 915 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
| 916 | 916 | |
| 917 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 918 | - $suffix = 2; |
|
| 917 | + if ( $key_check || is_numeric($key_check) ) { |
|
| 918 | + $suffix = 2; |
|
| 919 | 919 | do { |
| 920 | 920 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 921 | 921 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
| 922 | 922 | $suffix++; |
| 923 | 923 | } while ($key_check || is_numeric($key_check)); |
| 924 | 924 | $key = $alt_post_name; |
| 925 | - } |
|
| 926 | - return $key; |
|
| 927 | - } |
|
| 928 | - |
|
| 929 | - /** |
|
| 930 | - * Editing a Form or Entry |
|
| 931 | - * @param string $table |
|
| 932 | - * @return bool|array |
|
| 933 | - */ |
|
| 934 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 935 | - if ( ! $record ) { |
|
| 936 | - return false; |
|
| 937 | - } |
|
| 938 | - |
|
| 939 | - global $frm_vars; |
|
| 940 | - |
|
| 941 | - if ( empty($post_values) ) { |
|
| 942 | - $post_values = stripslashes_deep($_POST); |
|
| 943 | - } |
|
| 925 | + } |
|
| 926 | + return $key; |
|
| 927 | + } |
|
| 928 | + |
|
| 929 | + /** |
|
| 930 | + * Editing a Form or Entry |
|
| 931 | + * @param string $table |
|
| 932 | + * @return bool|array |
|
| 933 | + */ |
|
| 934 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 935 | + if ( ! $record ) { |
|
| 936 | + return false; |
|
| 937 | + } |
|
| 938 | + |
|
| 939 | + global $frm_vars; |
|
| 940 | + |
|
| 941 | + if ( empty($post_values) ) { |
|
| 942 | + $post_values = stripslashes_deep($_POST); |
|
| 943 | + } |
|
| 944 | 944 | |
| 945 | 945 | $values = array( 'id' => $record->id, 'fields' => array() ); |
| 946 | 946 | |
| 947 | 947 | foreach ( array( 'name', 'description' ) as $var ) { |
| 948 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 949 | - $values[ $var ] = self::get_param( $var, $default_val ); |
|
| 950 | - unset($var, $default_val); |
|
| 951 | - } |
|
| 952 | - |
|
| 953 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 954 | - $frm_settings = self::get_settings(); |
|
| 955 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
| 956 | - |
|
| 957 | - foreach ( (array) $fields as $field ) { |
|
| 958 | - // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
| 959 | - if ( ! $is_form_builder ) { |
|
| 960 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 961 | - } |
|
| 948 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 949 | + $values[ $var ] = self::get_param( $var, $default_val ); |
|
| 950 | + unset($var, $default_val); |
|
| 951 | + } |
|
| 952 | + |
|
| 953 | + $values['description'] = self::use_wpautop($values['description']); |
|
| 954 | + $frm_settings = self::get_settings(); |
|
| 955 | + $is_form_builder = self::is_admin_page('formidable' ); |
|
| 956 | + |
|
| 957 | + foreach ( (array) $fields as $field ) { |
|
| 958 | + // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
| 959 | + if ( ! $is_form_builder ) { |
|
| 960 | + $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 961 | + } |
|
| 962 | 962 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
| 963 | 963 | self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
| 964 | - } |
|
| 964 | + } |
|
| 965 | 965 | |
| 966 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 966 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
| 967 | 967 | |
| 968 | - if ( $table == 'entries' ) { |
|
| 969 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 970 | - } else if ( $table == 'forms' ) { |
|
| 971 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 972 | - } |
|
| 968 | + if ( $table == 'entries' ) { |
|
| 969 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 970 | + } else if ( $table == 'forms' ) { |
|
| 971 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 972 | + } |
|
| 973 | 973 | |
| 974 | - return $values; |
|
| 975 | - } |
|
| 974 | + return $values; |
|
| 975 | + } |
|
| 976 | 976 | |
| 977 | 977 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 978 | - $post_values = $args['post_values']; |
|
| 979 | - |
|
| 980 | - if ( $args['default'] ) { |
|
| 981 | - $meta_value = $field->default_value; |
|
| 982 | - } else { |
|
| 983 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 984 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 985 | - $field->field_options['custom_field'] = ''; |
|
| 986 | - } |
|
| 978 | + $post_values = $args['post_values']; |
|
| 979 | + |
|
| 980 | + if ( $args['default'] ) { |
|
| 981 | + $meta_value = $field->default_value; |
|
| 982 | + } else { |
|
| 983 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 984 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
| 985 | + $field->field_options['custom_field'] = ''; |
|
| 986 | + } |
|
| 987 | 987 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
| 988 | - } else { |
|
| 988 | + } else { |
|
| 989 | 989 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 990 | - } |
|
| 991 | - } |
|
| 992 | - |
|
| 993 | - $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type; |
|
| 994 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 995 | - |
|
| 996 | - $field_array = array( |
|
| 997 | - 'id' => $field->id, |
|
| 998 | - 'value' => $new_value, |
|
| 999 | - 'default_value' => $field->default_value, |
|
| 1000 | - 'name' => $field->name, |
|
| 1001 | - 'description' => $field->description, |
|
| 1002 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1003 | - 'options' => $field->options, |
|
| 1004 | - 'required' => $field->required, |
|
| 1005 | - 'field_key' => $field->field_key, |
|
| 1006 | - 'field_order' => $field->field_order, |
|
| 1007 | - 'form_id' => $field->form_id, |
|
| 990 | + } |
|
| 991 | + } |
|
| 992 | + |
|
| 993 | + $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type; |
|
| 994 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 995 | + |
|
| 996 | + $field_array = array( |
|
| 997 | + 'id' => $field->id, |
|
| 998 | + 'value' => $new_value, |
|
| 999 | + 'default_value' => $field->default_value, |
|
| 1000 | + 'name' => $field->name, |
|
| 1001 | + 'description' => $field->description, |
|
| 1002 | + 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1003 | + 'options' => $field->options, |
|
| 1004 | + 'required' => $field->required, |
|
| 1005 | + 'field_key' => $field->field_key, |
|
| 1006 | + 'field_order' => $field->field_order, |
|
| 1007 | + 'form_id' => $field->form_id, |
|
| 1008 | 1008 | 'parent_form_id' => $args['parent_form_id'], |
| 1009 | - ); |
|
| 1009 | + ); |
|
| 1010 | 1010 | |
| 1011 | - $args['field_type'] = $field_type; |
|
| 1012 | - self::fill_field_opts($field, $field_array, $args); |
|
| 1011 | + $args['field_type'] = $field_type; |
|
| 1012 | + self::fill_field_opts($field, $field_array, $args); |
|
| 1013 | 1013 | |
| 1014 | - $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); |
|
| 1014 | + $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); |
|
| 1015 | 1015 | |
| 1016 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1017 | - $field_array['unique_msg'] = ''; |
|
| 1018 | - } |
|
| 1016 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1017 | + $field_array['unique_msg'] = ''; |
|
| 1018 | + } |
|
| 1019 | 1019 | |
| 1020 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1020 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1021 | 1021 | |
| 1022 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1023 | - } |
|
| 1022 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1023 | + } |
|
| 1024 | 1024 | |
| 1025 | 1025 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
| 1026 | - $post_values = $args['post_values']; |
|
| 1027 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1028 | - |
|
| 1029 | - foreach ( $opt_defaults as $opt => $default_opt ) { |
|
| 1030 | - $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt .'_'. $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt .'_'. $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
| 1031 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1032 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1033 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1034 | - if ( $args['field_type'] == 'captcha' ) { |
|
| 1035 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1036 | - } else { |
|
| 1037 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1038 | - } |
|
| 1039 | - } |
|
| 1040 | - } |
|
| 1041 | - |
|
| 1042 | - if ( $field_array['custom_html'] == '' ) { |
|
| 1043 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1044 | - } |
|
| 1045 | - } |
|
| 1046 | - |
|
| 1047 | - /** |
|
| 1048 | - * @param string $table |
|
| 1049 | - */ |
|
| 1026 | + $post_values = $args['post_values']; |
|
| 1027 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1028 | + |
|
| 1029 | + foreach ( $opt_defaults as $opt => $default_opt ) { |
|
| 1030 | + $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt .'_'. $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt .'_'. $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
| 1031 | + if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1032 | + $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1033 | + } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1034 | + if ( $args['field_type'] == 'captcha' ) { |
|
| 1035 | + $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1036 | + } else { |
|
| 1037 | + $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1038 | + } |
|
| 1039 | + } |
|
| 1040 | + } |
|
| 1041 | + |
|
| 1042 | + if ( $field_array['custom_html'] == '' ) { |
|
| 1043 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1044 | + } |
|
| 1045 | + } |
|
| 1046 | + |
|
| 1047 | + /** |
|
| 1048 | + * @param string $table |
|
| 1049 | + */ |
|
| 1050 | 1050 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1051 | - if ( $table == 'entries' ) { |
|
| 1052 | - $form = $record->form_id; |
|
| 1051 | + if ( $table == 'entries' ) { |
|
| 1052 | + $form = $record->form_id; |
|
| 1053 | 1053 | FrmForm::maybe_get_form( $form ); |
| 1054 | - } else { |
|
| 1055 | - $form = $record; |
|
| 1056 | - } |
|
| 1054 | + } else { |
|
| 1055 | + $form = $record; |
|
| 1056 | + } |
|
| 1057 | 1057 | |
| 1058 | - if ( ! $form ) { |
|
| 1059 | - return; |
|
| 1060 | - } |
|
| 1058 | + if ( ! $form ) { |
|
| 1059 | + return; |
|
| 1060 | + } |
|
| 1061 | 1061 | |
| 1062 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1062 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1063 | 1063 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1064 | 1064 | |
| 1065 | - if ( ! is_array($form->options) ) { |
|
| 1066 | - return; |
|
| 1067 | - } |
|
| 1065 | + if ( ! is_array($form->options) ) { |
|
| 1066 | + return; |
|
| 1067 | + } |
|
| 1068 | 1068 | |
| 1069 | - foreach ( $form->options as $opt => $value ) { |
|
| 1070 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1071 | - } |
|
| 1069 | + foreach ( $form->options as $opt => $value ) { |
|
| 1070 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1071 | + } |
|
| 1072 | 1072 | |
| 1073 | - self::fill_form_defaults($post_values, $values); |
|
| 1074 | - } |
|
| 1073 | + self::fill_form_defaults($post_values, $values); |
|
| 1074 | + } |
|
| 1075 | 1075 | |
| 1076 | - /** |
|
| 1077 | - * Set to POST value or default |
|
| 1078 | - */ |
|
| 1076 | + /** |
|
| 1077 | + * Set to POST value or default |
|
| 1078 | + */ |
|
| 1079 | 1079 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1080 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1080 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1081 | 1081 | |
| 1082 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1083 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1082 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1083 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1084 | 1084 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1085 | - } |
|
| 1085 | + } |
|
| 1086 | 1086 | |
| 1087 | - unset($opt, $defaut); |
|
| 1088 | - } |
|
| 1087 | + unset($opt, $defaut); |
|
| 1088 | + } |
|
| 1089 | 1089 | |
| 1090 | - if ( ! isset($values['custom_style']) ) { |
|
| 1091 | - $frm_settings = self::get_settings(); |
|
| 1090 | + if ( ! isset($values['custom_style']) ) { |
|
| 1091 | + $frm_settings = self::get_settings(); |
|
| 1092 | 1092 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
| 1093 | - } |
|
| 1093 | + } |
|
| 1094 | 1094 | |
| 1095 | 1095 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1096 | - if ( ! isset( $values[ $h .'_html' ] ) ) { |
|
| 1097 | - $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1098 | - } |
|
| 1099 | - unset($h); |
|
| 1100 | - } |
|
| 1101 | - } |
|
| 1096 | + if ( ! isset( $values[ $h .'_html' ] ) ) { |
|
| 1097 | + $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1098 | + } |
|
| 1099 | + unset($h); |
|
| 1100 | + } |
|
| 1101 | + } |
|
| 1102 | 1102 | |
| 1103 | 1103 | public static function get_meta_value( $field_id, $entry ) { |
| 1104 | 1104 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmEntryMeta::get_meta_value' ); |
@@ -1106,69 +1106,69 @@ discard block |
||
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | 1108 | public static function insert_opt_html( $args ) { |
| 1109 | - $class = ''; |
|
| 1110 | - if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
| 1111 | - $class .= 'show_frm_not_email_to'; |
|
| 1112 | - } |
|
| 1113 | - ?> |
|
| 1109 | + $class = ''; |
|
| 1110 | + if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
| 1111 | + $class .= 'show_frm_not_email_to'; |
|
| 1112 | + } |
|
| 1113 | + ?> |
|
| 1114 | 1114 | <li> |
| 1115 | 1115 | <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
| 1116 | 1116 | <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
| 1117 | 1117 | <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
| 1118 | 1118 | </li> |
| 1119 | 1119 | <?php |
| 1120 | - } |
|
| 1120 | + } |
|
| 1121 | 1121 | |
| 1122 | - public static function get_us_states() { |
|
| 1123 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' ); |
|
| 1124 | - return FrmFieldsHelper::get_us_states(); |
|
| 1125 | - } |
|
| 1122 | + public static function get_us_states() { |
|
| 1123 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_us_states' ); |
|
| 1124 | + return FrmFieldsHelper::get_us_states(); |
|
| 1125 | + } |
|
| 1126 | 1126 | |
| 1127 | - public static function get_countries() { |
|
| 1128 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' ); |
|
| 1129 | - return FrmFieldsHelper::get_countries(); |
|
| 1130 | - } |
|
| 1127 | + public static function get_countries() { |
|
| 1128 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmFieldsHelper::get_countries' ); |
|
| 1129 | + return FrmFieldsHelper::get_countries(); |
|
| 1130 | + } |
|
| 1131 | 1131 | |
| 1132 | 1132 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1133 | - if ( is_array( $str ) ) { |
|
| 1134 | - return; |
|
| 1133 | + if ( is_array( $str ) ) { |
|
| 1134 | + return; |
|
| 1135 | 1135 | } |
| 1136 | 1136 | |
| 1137 | - $length = (int) $length; |
|
| 1137 | + $length = (int) $length; |
|
| 1138 | 1138 | $str = wp_strip_all_tags( $str ); |
| 1139 | 1139 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1140 | 1140 | |
| 1141 | 1141 | if ( $length == 0 ) { |
| 1142 | - return ''; |
|
| 1143 | - } else if ( $length <= 10 ) { |
|
| 1142 | + return ''; |
|
| 1143 | + } else if ( $length <= 10 ) { |
|
| 1144 | 1144 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1145 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1146 | - } |
|
| 1145 | + return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1146 | + } |
|
| 1147 | 1147 | |
| 1148 | - $sub = ''; |
|
| 1149 | - $len = 0; |
|
| 1148 | + $sub = ''; |
|
| 1149 | + $len = 0; |
|
| 1150 | 1150 | |
| 1151 | 1151 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1152 | 1152 | |
| 1153 | 1153 | foreach ( $words as $word ) { |
| 1154 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1154 | + $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1155 | 1155 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1156 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1157 | - break; |
|
| 1158 | - } |
|
| 1156 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1157 | + break; |
|
| 1158 | + } |
|
| 1159 | 1159 | |
| 1160 | - $sub .= $part; |
|
| 1160 | + $sub .= $part; |
|
| 1161 | 1161 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1162 | 1162 | |
| 1163 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1164 | - break; |
|
| 1165 | - } |
|
| 1163 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1164 | + break; |
|
| 1165 | + } |
|
| 1166 | 1166 | |
| 1167 | - unset($total_len, $word); |
|
| 1168 | - } |
|
| 1167 | + unset($total_len, $word); |
|
| 1168 | + } |
|
| 1169 | 1169 | |
| 1170 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1171 | - } |
|
| 1170 | + return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1171 | + } |
|
| 1172 | 1172 | |
| 1173 | 1173 | public static function mb_function( $function_names, $args ) { |
| 1174 | 1174 | $mb_function_name = $function_names[0]; |
@@ -1180,18 +1180,18 @@ discard block |
||
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1183 | - if ( empty($date) ) { |
|
| 1184 | - return $date; |
|
| 1185 | - } |
|
| 1183 | + if ( empty($date) ) { |
|
| 1184 | + return $date; |
|
| 1185 | + } |
|
| 1186 | 1186 | |
| 1187 | - if ( empty($date_format) ) { |
|
| 1188 | - $date_format = get_option('date_format'); |
|
| 1189 | - } |
|
| 1187 | + if ( empty($date_format) ) { |
|
| 1188 | + $date_format = get_option('date_format'); |
|
| 1189 | + } |
|
| 1190 | 1190 | |
| 1191 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1192 | - $frmpro_settings = new FrmProSettings(); |
|
| 1193 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1194 | - } |
|
| 1191 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1192 | + $frmpro_settings = new FrmProSettings(); |
|
| 1193 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1194 | + } |
|
| 1195 | 1195 | |
| 1196 | 1196 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1197 | 1197 | |
@@ -1200,8 +1200,8 @@ discard block |
||
| 1200 | 1200 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | - return $formatted; |
|
| 1204 | - } |
|
| 1203 | + return $formatted; |
|
| 1204 | + } |
|
| 1205 | 1205 | |
| 1206 | 1206 | private static function add_time_to_date( $time_format, $date ) { |
| 1207 | 1207 | if ( empty( $time_format ) ) { |
@@ -1225,117 +1225,117 @@ discard block |
||
| 1225 | 1225 | return date_i18n( $date_format, strtotime( $date ) ); |
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | - /** |
|
| 1229 | - * @return string The time ago in words |
|
| 1230 | - */ |
|
| 1231 | - public static function human_time_diff( $from, $to = '' ) { |
|
| 1232 | - if ( empty($to) ) { |
|
| 1233 | - $to = time(); |
|
| 1234 | - } |
|
| 1235 | - |
|
| 1236 | - // Array of time period chunks |
|
| 1237 | - $chunks = array( |
|
| 1238 | - array( 60 * 60 * 24 * 365, __( 'year', 'formidable' ), __( 'years', 'formidable' ) ), |
|
| 1239 | - array( 60 * 60 * 24 * 30, __( 'month', 'formidable' ), __( 'months', 'formidable' ) ), |
|
| 1240 | - array( 60 * 60 * 24 * 7, __( 'week', 'formidable' ), __( 'weeks', 'formidable' ) ), |
|
| 1241 | - array( 60 * 60 * 24, __( 'day', 'formidable' ), __( 'days', 'formidable' ) ), |
|
| 1242 | - array( 60 * 60, __( 'hour', 'formidable' ), __( 'hours', 'formidable' ) ), |
|
| 1243 | - array( 60, __( 'minute', 'formidable' ), __( 'minutes', 'formidable' ) ), |
|
| 1244 | - array( 1, __( 'second', 'formidable' ), __( 'seconds', 'formidable' ) ), |
|
| 1245 | - ); |
|
| 1246 | - |
|
| 1247 | - // Difference in seconds |
|
| 1248 | - $diff = (int) ($to - $from); |
|
| 1249 | - |
|
| 1250 | - // Something went wrong with date calculation and we ended up with a negative date. |
|
| 1228 | + /** |
|
| 1229 | + * @return string The time ago in words |
|
| 1230 | + */ |
|
| 1231 | + public static function human_time_diff( $from, $to = '' ) { |
|
| 1232 | + if ( empty($to) ) { |
|
| 1233 | + $to = time(); |
|
| 1234 | + } |
|
| 1235 | + |
|
| 1236 | + // Array of time period chunks |
|
| 1237 | + $chunks = array( |
|
| 1238 | + array( 60 * 60 * 24 * 365, __( 'year', 'formidable' ), __( 'years', 'formidable' ) ), |
|
| 1239 | + array( 60 * 60 * 24 * 30, __( 'month', 'formidable' ), __( 'months', 'formidable' ) ), |
|
| 1240 | + array( 60 * 60 * 24 * 7, __( 'week', 'formidable' ), __( 'weeks', 'formidable' ) ), |
|
| 1241 | + array( 60 * 60 * 24, __( 'day', 'formidable' ), __( 'days', 'formidable' ) ), |
|
| 1242 | + array( 60 * 60, __( 'hour', 'formidable' ), __( 'hours', 'formidable' ) ), |
|
| 1243 | + array( 60, __( 'minute', 'formidable' ), __( 'minutes', 'formidable' ) ), |
|
| 1244 | + array( 1, __( 'second', 'formidable' ), __( 'seconds', 'formidable' ) ), |
|
| 1245 | + ); |
|
| 1246 | + |
|
| 1247 | + // Difference in seconds |
|
| 1248 | + $diff = (int) ($to - $from); |
|
| 1249 | + |
|
| 1250 | + // Something went wrong with date calculation and we ended up with a negative date. |
|
| 1251 | 1251 | if ( $diff < 1 ) { |
| 1252 | 1252 | return '0 ' . __( 'seconds', 'formidable' ); |
| 1253 | - } |
|
| 1253 | + } |
|
| 1254 | 1254 | |
| 1255 | - /** |
|
| 1256 | - * We only want to output one chunks of time here, eg: |
|
| 1257 | - * x years |
|
| 1258 | - * xx months |
|
| 1259 | - * so there's only one bit of calculation below: |
|
| 1260 | - */ |
|
| 1255 | + /** |
|
| 1256 | + * We only want to output one chunks of time here, eg: |
|
| 1257 | + * x years |
|
| 1258 | + * xx months |
|
| 1259 | + * so there's only one bit of calculation below: |
|
| 1260 | + */ |
|
| 1261 | 1261 | |
| 1262 | - $count = 0; |
|
| 1262 | + $count = 0; |
|
| 1263 | 1263 | |
| 1264 | - //Step one: the first chunk |
|
| 1264 | + //Step one: the first chunk |
|
| 1265 | 1265 | for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) { |
| 1266 | - $seconds = $chunks[ $i ][0]; |
|
| 1267 | - |
|
| 1268 | - // Finding the biggest chunk (if the chunk fits, break) |
|
| 1269 | - if ( ( $count = floor($diff / $seconds) ) != 0 ) { |
|
| 1270 | - break; |
|
| 1271 | - } |
|
| 1272 | - } |
|
| 1273 | - |
|
| 1274 | - // Set output var |
|
| 1275 | - $output = ( 1 == $count ) ? '1 '. $chunks[ $i ][1] : $count . ' ' . $chunks[ $i ][2]; |
|
| 1276 | - |
|
| 1277 | - if ( ! (int) trim( $output ) ) { |
|
| 1278 | - $output = '0 ' . __( 'seconds', 'formidable' ); |
|
| 1279 | - } |
|
| 1280 | - |
|
| 1281 | - return $output; |
|
| 1282 | - } |
|
| 1283 | - |
|
| 1284 | - /** |
|
| 1285 | - * Added for < WP 4.0 compatability |
|
| 1286 | - * |
|
| 1287 | - * @since 1.07.10 |
|
| 1288 | - * |
|
| 1289 | - * @param string $term The value to escape |
|
| 1290 | - * @return string The escaped value |
|
| 1291 | - */ |
|
| 1266 | + $seconds = $chunks[ $i ][0]; |
|
| 1267 | + |
|
| 1268 | + // Finding the biggest chunk (if the chunk fits, break) |
|
| 1269 | + if ( ( $count = floor($diff / $seconds) ) != 0 ) { |
|
| 1270 | + break; |
|
| 1271 | + } |
|
| 1272 | + } |
|
| 1273 | + |
|
| 1274 | + // Set output var |
|
| 1275 | + $output = ( 1 == $count ) ? '1 '. $chunks[ $i ][1] : $count . ' ' . $chunks[ $i ][2]; |
|
| 1276 | + |
|
| 1277 | + if ( ! (int) trim( $output ) ) { |
|
| 1278 | + $output = '0 ' . __( 'seconds', 'formidable' ); |
|
| 1279 | + } |
|
| 1280 | + |
|
| 1281 | + return $output; |
|
| 1282 | + } |
|
| 1283 | + |
|
| 1284 | + /** |
|
| 1285 | + * Added for < WP 4.0 compatability |
|
| 1286 | + * |
|
| 1287 | + * @since 1.07.10 |
|
| 1288 | + * |
|
| 1289 | + * @param string $term The value to escape |
|
| 1290 | + * @return string The escaped value |
|
| 1291 | + */ |
|
| 1292 | 1292 | public static function esc_like( $term ) { |
| 1293 | - global $wpdb; |
|
| 1294 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1293 | + global $wpdb; |
|
| 1294 | + if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1295 | 1295 | // WP 4.0 |
| 1296 | - $term = $wpdb->esc_like( $term ); |
|
| 1297 | - } else { |
|
| 1298 | - $term = like_escape( $term ); |
|
| 1299 | - } |
|
| 1296 | + $term = $wpdb->esc_like( $term ); |
|
| 1297 | + } else { |
|
| 1298 | + $term = like_escape( $term ); |
|
| 1299 | + } |
|
| 1300 | 1300 | |
| 1301 | - return $term; |
|
| 1302 | - } |
|
| 1301 | + return $term; |
|
| 1302 | + } |
|
| 1303 | 1303 | |
| 1304 | - /** |
|
| 1305 | - * @param string $order_query |
|
| 1306 | - */ |
|
| 1304 | + /** |
|
| 1305 | + * @param string $order_query |
|
| 1306 | + */ |
|
| 1307 | 1307 | public static function esc_order( $order_query ) { |
| 1308 | - if ( empty($order_query) ) { |
|
| 1309 | - return ''; |
|
| 1310 | - } |
|
| 1311 | - |
|
| 1312 | - // remove ORDER BY before santizing |
|
| 1313 | - $order_query = strtolower($order_query); |
|
| 1314 | - if ( strpos($order_query, 'order by') !== false ) { |
|
| 1315 | - $order_query = str_replace('order by', '', $order_query); |
|
| 1316 | - } |
|
| 1317 | - |
|
| 1318 | - $order_query = explode(' ', trim($order_query)); |
|
| 1319 | - |
|
| 1320 | - $order_fields = array( |
|
| 1321 | - 'id', 'form_key', 'name', 'description', |
|
| 1322 | - 'parent_form_id', 'logged_in', 'is_template', |
|
| 1323 | - 'default_template', 'status', 'created_at', |
|
| 1324 | - ); |
|
| 1325 | - |
|
| 1326 | - $order = trim(trim(reset($order_query), ',')); |
|
| 1327 | - if ( ! in_array($order, $order_fields) ) { |
|
| 1328 | - return ''; |
|
| 1329 | - } |
|
| 1330 | - |
|
| 1331 | - $order_by = ''; |
|
| 1332 | - if ( count($order_query) > 1 ) { |
|
| 1308 | + if ( empty($order_query) ) { |
|
| 1309 | + return ''; |
|
| 1310 | + } |
|
| 1311 | + |
|
| 1312 | + // remove ORDER BY before santizing |
|
| 1313 | + $order_query = strtolower($order_query); |
|
| 1314 | + if ( strpos($order_query, 'order by') !== false ) { |
|
| 1315 | + $order_query = str_replace('order by', '', $order_query); |
|
| 1316 | + } |
|
| 1317 | + |
|
| 1318 | + $order_query = explode(' ', trim($order_query)); |
|
| 1319 | + |
|
| 1320 | + $order_fields = array( |
|
| 1321 | + 'id', 'form_key', 'name', 'description', |
|
| 1322 | + 'parent_form_id', 'logged_in', 'is_template', |
|
| 1323 | + 'default_template', 'status', 'created_at', |
|
| 1324 | + ); |
|
| 1325 | + |
|
| 1326 | + $order = trim(trim(reset($order_query), ',')); |
|
| 1327 | + if ( ! in_array($order, $order_fields) ) { |
|
| 1328 | + return ''; |
|
| 1329 | + } |
|
| 1330 | + |
|
| 1331 | + $order_by = ''; |
|
| 1332 | + if ( count($order_query) > 1 ) { |
|
| 1333 | 1333 | $order_by = end( $order_query ); |
| 1334 | 1334 | self::esc_order_by( $order_by ); |
| 1335 | - } |
|
| 1335 | + } |
|
| 1336 | 1336 | |
| 1337 | - return ' ORDER BY '. $order . ' '. $order_by; |
|
| 1338 | - } |
|
| 1337 | + return ' ORDER BY '. $order . ' '. $order_by; |
|
| 1338 | + } |
|
| 1339 | 1339 | |
| 1340 | 1340 | /** |
| 1341 | 1341 | * Make sure this is ordering by either ASC or DESC |
@@ -1347,183 +1347,183 @@ discard block |
||
| 1347 | 1347 | } |
| 1348 | 1348 | } |
| 1349 | 1349 | |
| 1350 | - /** |
|
| 1351 | - * @param string $limit |
|
| 1352 | - */ |
|
| 1350 | + /** |
|
| 1351 | + * @param string $limit |
|
| 1352 | + */ |
|
| 1353 | 1353 | public static function esc_limit( $limit ) { |
| 1354 | - if ( empty($limit) ) { |
|
| 1355 | - return ''; |
|
| 1356 | - } |
|
| 1357 | - |
|
| 1358 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1359 | - if ( is_numeric($limit) ) { |
|
| 1360 | - return ' LIMIT '. $limit; |
|
| 1361 | - } |
|
| 1362 | - |
|
| 1363 | - $limit = explode(',', trim($limit)); |
|
| 1364 | - foreach ( $limit as $k => $l ) { |
|
| 1365 | - if ( is_numeric( $l ) ) { |
|
| 1366 | - $limit[ $k ] = $l; |
|
| 1367 | - } |
|
| 1368 | - } |
|
| 1369 | - |
|
| 1370 | - $limit = implode(',', $limit); |
|
| 1371 | - return ' LIMIT '. $limit; |
|
| 1372 | - } |
|
| 1373 | - |
|
| 1374 | - /** |
|
| 1375 | - * Get an array of values ready to go through $wpdb->prepare |
|
| 1376 | - * @since 2.0 |
|
| 1377 | - */ |
|
| 1378 | - public static function prepare_array_values( $array, $type = '%s' ) { |
|
| 1379 | - $placeholders = array_fill(0, count($array), $type); |
|
| 1380 | - return implode(', ', $placeholders); |
|
| 1381 | - } |
|
| 1382 | - |
|
| 1383 | - public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
| 1384 | - if ( empty($where) ) { |
|
| 1385 | - return ''; |
|
| 1386 | - } |
|
| 1354 | + if ( empty($limit) ) { |
|
| 1355 | + return ''; |
|
| 1356 | + } |
|
| 1357 | + |
|
| 1358 | + $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1359 | + if ( is_numeric($limit) ) { |
|
| 1360 | + return ' LIMIT '. $limit; |
|
| 1361 | + } |
|
| 1362 | + |
|
| 1363 | + $limit = explode(',', trim($limit)); |
|
| 1364 | + foreach ( $limit as $k => $l ) { |
|
| 1365 | + if ( is_numeric( $l ) ) { |
|
| 1366 | + $limit[ $k ] = $l; |
|
| 1367 | + } |
|
| 1368 | + } |
|
| 1369 | + |
|
| 1370 | + $limit = implode(',', $limit); |
|
| 1371 | + return ' LIMIT '. $limit; |
|
| 1372 | + } |
|
| 1373 | + |
|
| 1374 | + /** |
|
| 1375 | + * Get an array of values ready to go through $wpdb->prepare |
|
| 1376 | + * @since 2.0 |
|
| 1377 | + */ |
|
| 1378 | + public static function prepare_array_values( $array, $type = '%s' ) { |
|
| 1379 | + $placeholders = array_fill(0, count($array), $type); |
|
| 1380 | + return implode(', ', $placeholders); |
|
| 1381 | + } |
|
| 1382 | + |
|
| 1383 | + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
| 1384 | + if ( empty($where) ) { |
|
| 1385 | + return ''; |
|
| 1386 | + } |
|
| 1387 | 1387 | |
| 1388 | 1388 | if ( is_array( $where ) ) { |
| 1389 | - global $wpdb; |
|
| 1390 | - FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
| 1389 | + global $wpdb; |
|
| 1390 | + FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
| 1391 | 1391 | $where = $wpdb->prepare( $where['where'], $where['values'] ); |
| 1392 | 1392 | } else { |
| 1393 | - $where = $starts_with . $where; |
|
| 1394 | - } |
|
| 1393 | + $where = $starts_with . $where; |
|
| 1394 | + } |
|
| 1395 | 1395 | |
| 1396 | - return $where; |
|
| 1397 | - } |
|
| 1396 | + return $where; |
|
| 1397 | + } |
|
| 1398 | 1398 | |
| 1399 | - // Pagination Methods |
|
| 1399 | + // Pagination Methods |
|
| 1400 | 1400 | |
| 1401 | - /** |
|
| 1402 | - * @param integer $current_p |
|
| 1403 | - */ |
|
| 1401 | + /** |
|
| 1402 | + * @param integer $current_p |
|
| 1403 | + */ |
|
| 1404 | 1404 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1405 | 1405 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1406 | 1406 | } |
| 1407 | 1407 | |
| 1408 | - /** |
|
| 1409 | - * @param integer $current_p |
|
| 1410 | - */ |
|
| 1411 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1412 | - if ( $current_p == 1 ) { |
|
| 1413 | - return 1; |
|
| 1414 | - } else { |
|
| 1415 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1416 | - } |
|
| 1417 | - } |
|
| 1418 | - |
|
| 1419 | - /** |
|
| 1420 | - * @param string $table_name |
|
| 1421 | - */ |
|
| 1422 | - public static function &getRecordCount( $where = '', $table_name ) { |
|
| 1423 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' ); |
|
| 1424 | - $count = FrmDb::get_count( $table_name, $where ); |
|
| 1425 | - return $count; |
|
| 1426 | - } |
|
| 1427 | - |
|
| 1428 | - public static function get_referer_info() { |
|
| 1429 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
|
| 1430 | - return self::get_server_value('HTTP_REFERER'); |
|
| 1431 | - } |
|
| 1408 | + /** |
|
| 1409 | + * @param integer $current_p |
|
| 1410 | + */ |
|
| 1411 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1412 | + if ( $current_p == 1 ) { |
|
| 1413 | + return 1; |
|
| 1414 | + } else { |
|
| 1415 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1416 | + } |
|
| 1417 | + } |
|
| 1418 | + |
|
| 1419 | + /** |
|
| 1420 | + * @param string $table_name |
|
| 1421 | + */ |
|
| 1422 | + public static function &getRecordCount( $where = '', $table_name ) { |
|
| 1423 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmDb::get_count' ); |
|
| 1424 | + $count = FrmDb::get_count( $table_name, $where ); |
|
| 1425 | + return $count; |
|
| 1426 | + } |
|
| 1427 | + |
|
| 1428 | + public static function get_referer_info() { |
|
| 1429 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
|
| 1430 | + return self::get_server_value('HTTP_REFERER'); |
|
| 1431 | + } |
|
| 1432 | 1432 | |
| 1433 | 1433 | /** |
| 1434 | 1434 | * @return array |
| 1435 | 1435 | */ |
| 1436 | 1436 | public static function json_to_array( $json_vars ) { |
| 1437 | - $vars = array(); |
|
| 1438 | - foreach ( $json_vars as $jv ) { |
|
| 1439 | - $jv_name = explode('[', $jv['name']); |
|
| 1440 | - $last = count($jv_name) - 1; |
|
| 1441 | - foreach ( $jv_name as $p => $n ) { |
|
| 1442 | - $name = trim($n, ']'); |
|
| 1443 | - if ( ! isset($l1) ) { |
|
| 1444 | - $l1 = $name; |
|
| 1445 | - } |
|
| 1446 | - |
|
| 1447 | - if ( ! isset($l2) ) { |
|
| 1448 | - $l2 = $name; |
|
| 1449 | - } |
|
| 1450 | - |
|
| 1451 | - if ( ! isset($l3) ) { |
|
| 1452 | - $l3 = $name; |
|
| 1453 | - } |
|
| 1454 | - |
|
| 1455 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1456 | - |
|
| 1457 | - switch ( $p ) { |
|
| 1458 | - case 0: |
|
| 1459 | - $l1 = $name; |
|
| 1460 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1461 | - break; |
|
| 1462 | - |
|
| 1463 | - case 1: |
|
| 1464 | - $l2 = $name; |
|
| 1465 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1466 | - break; |
|
| 1467 | - |
|
| 1468 | - case 2: |
|
| 1469 | - $l3 = $name; |
|
| 1470 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1471 | - break; |
|
| 1472 | - |
|
| 1473 | - case 3: |
|
| 1474 | - $l4 = $name; |
|
| 1475 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1476 | - break; |
|
| 1477 | - } |
|
| 1478 | - |
|
| 1479 | - unset($this_val, $n); |
|
| 1480 | - } |
|
| 1481 | - |
|
| 1482 | - unset($last, $jv); |
|
| 1483 | - } |
|
| 1484 | - |
|
| 1485 | - return $vars; |
|
| 1486 | - } |
|
| 1487 | - |
|
| 1488 | - /** |
|
| 1489 | - * @param string $name |
|
| 1490 | - * @param string $l1 |
|
| 1491 | - */ |
|
| 1492 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1493 | - if ( $name == '' ) { |
|
| 1494 | - $vars[] = $val; |
|
| 1495 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1496 | - $vars[ $l1 ] = $val; |
|
| 1497 | - } |
|
| 1498 | - } |
|
| 1437 | + $vars = array(); |
|
| 1438 | + foreach ( $json_vars as $jv ) { |
|
| 1439 | + $jv_name = explode('[', $jv['name']); |
|
| 1440 | + $last = count($jv_name) - 1; |
|
| 1441 | + foreach ( $jv_name as $p => $n ) { |
|
| 1442 | + $name = trim($n, ']'); |
|
| 1443 | + if ( ! isset($l1) ) { |
|
| 1444 | + $l1 = $name; |
|
| 1445 | + } |
|
| 1446 | + |
|
| 1447 | + if ( ! isset($l2) ) { |
|
| 1448 | + $l2 = $name; |
|
| 1449 | + } |
|
| 1450 | + |
|
| 1451 | + if ( ! isset($l3) ) { |
|
| 1452 | + $l3 = $name; |
|
| 1453 | + } |
|
| 1454 | + |
|
| 1455 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1456 | + |
|
| 1457 | + switch ( $p ) { |
|
| 1458 | + case 0: |
|
| 1459 | + $l1 = $name; |
|
| 1460 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1461 | + break; |
|
| 1462 | + |
|
| 1463 | + case 1: |
|
| 1464 | + $l2 = $name; |
|
| 1465 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1466 | + break; |
|
| 1467 | + |
|
| 1468 | + case 2: |
|
| 1469 | + $l3 = $name; |
|
| 1470 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1471 | + break; |
|
| 1472 | + |
|
| 1473 | + case 3: |
|
| 1474 | + $l4 = $name; |
|
| 1475 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1476 | + break; |
|
| 1477 | + } |
|
| 1478 | + |
|
| 1479 | + unset($this_val, $n); |
|
| 1480 | + } |
|
| 1481 | + |
|
| 1482 | + unset($last, $jv); |
|
| 1483 | + } |
|
| 1484 | + |
|
| 1485 | + return $vars; |
|
| 1486 | + } |
|
| 1487 | + |
|
| 1488 | + /** |
|
| 1489 | + * @param string $name |
|
| 1490 | + * @param string $l1 |
|
| 1491 | + */ |
|
| 1492 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1493 | + if ( $name == '' ) { |
|
| 1494 | + $vars[] = $val; |
|
| 1495 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1496 | + $vars[ $l1 ] = $val; |
|
| 1497 | + } |
|
| 1498 | + } |
|
| 1499 | 1499 | |
| 1500 | 1500 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1501 | - $tooltips = array( |
|
| 1502 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1503 | - 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1504 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1505 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1506 | - 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1507 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1508 | - 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1509 | - ); |
|
| 1510 | - |
|
| 1511 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1512 | - return; |
|
| 1513 | - } |
|
| 1514 | - |
|
| 1515 | - if ( 'open' == $class ) { |
|
| 1516 | - echo ' frm_help"'; |
|
| 1517 | - } else { |
|
| 1518 | - echo ' class="frm_help"'; |
|
| 1519 | - } |
|
| 1520 | - |
|
| 1521 | - echo ' title="'. esc_attr( $tooltips[ $name ] ); |
|
| 1522 | - |
|
| 1523 | - if ( 'open' != $class ) { |
|
| 1524 | - echo '"'; |
|
| 1525 | - } |
|
| 1526 | - } |
|
| 1501 | + $tooltips = array( |
|
| 1502 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1503 | + 'email_to' => __( 'Add one or more recipient addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected]. [admin_email] is the address set in WP General Settings.', 'formidable' ), |
|
| 1504 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1505 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1506 | + 'reply_to' => __( 'If you would like a different reply to address than the "from" address, add a single address here. FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1507 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1508 | + 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
|
| 1509 | + ); |
|
| 1510 | + |
|
| 1511 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1512 | + return; |
|
| 1513 | + } |
|
| 1514 | + |
|
| 1515 | + if ( 'open' == $class ) { |
|
| 1516 | + echo ' frm_help"'; |
|
| 1517 | + } else { |
|
| 1518 | + echo ' class="frm_help"'; |
|
| 1519 | + } |
|
| 1520 | + |
|
| 1521 | + echo ' title="'. esc_attr( $tooltips[ $name ] ); |
|
| 1522 | + |
|
| 1523 | + if ( 'open' != $class ) { |
|
| 1524 | + echo '"'; |
|
| 1525 | + } |
|
| 1526 | + } |
|
| 1527 | 1527 | |
| 1528 | 1528 | /** |
| 1529 | 1529 | * Add the current_page class to that page in the form nav |
@@ -1539,35 +1539,35 @@ discard block |
||
| 1539 | 1539 | } |
| 1540 | 1540 | } |
| 1541 | 1541 | |
| 1542 | - /** |
|
| 1543 | - * Prepare and json_encode post content |
|
| 1544 | - * |
|
| 1545 | - * @since 2.0 |
|
| 1546 | - * |
|
| 1547 | - * @param array $post_content |
|
| 1548 | - * @return string $post_content ( json encoded array ) |
|
| 1549 | - */ |
|
| 1550 | - public static function prepare_and_encode( $post_content ) { |
|
| 1551 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1542 | + /** |
|
| 1543 | + * Prepare and json_encode post content |
|
| 1544 | + * |
|
| 1545 | + * @since 2.0 |
|
| 1546 | + * |
|
| 1547 | + * @param array $post_content |
|
| 1548 | + * @return string $post_content ( json encoded array ) |
|
| 1549 | + */ |
|
| 1550 | + public static function prepare_and_encode( $post_content ) { |
|
| 1551 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1552 | 1552 | foreach ( $post_content as $key => $val ) { |
| 1553 | 1553 | // Replace problematic characters (like ") |
| 1554 | 1554 | $val = str_replace( '"', '"', $val ); |
| 1555 | 1555 | |
| 1556 | 1556 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1557 | - unset( $key, $val ); |
|
| 1558 | - } |
|
| 1557 | + unset( $key, $val ); |
|
| 1558 | + } |
|
| 1559 | 1559 | |
| 1560 | - // json_encode the array |
|
| 1561 | - $post_content = json_encode( $post_content ); |
|
| 1560 | + // json_encode the array |
|
| 1561 | + $post_content = json_encode( $post_content ); |
|
| 1562 | 1562 | |
| 1563 | - // add extra slashes for \r\n since WP strips them |
|
| 1563 | + // add extra slashes for \r\n since WP strips them |
|
| 1564 | 1564 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1565 | 1565 | |
| 1566 | - // allow for " |
|
| 1567 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1566 | + // allow for " |
|
| 1567 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1568 | 1568 | |
| 1569 | - return $post_content; |
|
| 1570 | - } |
|
| 1569 | + return $post_content; |
|
| 1570 | + } |
|
| 1571 | 1571 | |
| 1572 | 1572 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1573 | 1573 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1635,64 +1635,64 @@ discard block |
||
| 1635 | 1635 | } |
| 1636 | 1636 | |
| 1637 | 1637 | public static function maybe_json_decode( $string ) { |
| 1638 | - if ( is_array($string) ) { |
|
| 1639 | - return $string; |
|
| 1640 | - } |
|
| 1638 | + if ( is_array($string) ) { |
|
| 1639 | + return $string; |
|
| 1640 | + } |
|
| 1641 | 1641 | |
| 1642 | - $new_string = json_decode($string, true); |
|
| 1643 | - if ( function_exists('json_last_error') ) { |
|
| 1642 | + $new_string = json_decode($string, true); |
|
| 1643 | + if ( function_exists('json_last_error') ) { |
|
| 1644 | 1644 | // php 5.3+ |
| 1645 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1646 | - $string = $new_string; |
|
| 1647 | - } |
|
| 1648 | - } else if ( isset($new_string) ) { |
|
| 1645 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1646 | + $string = $new_string; |
|
| 1647 | + } |
|
| 1648 | + } else if ( isset($new_string) ) { |
|
| 1649 | 1649 | // php < 5.3 fallback |
| 1650 | - $string = $new_string; |
|
| 1651 | - } |
|
| 1652 | - return $string; |
|
| 1653 | - } |
|
| 1654 | - |
|
| 1655 | - /** |
|
| 1656 | - * @since 1.07.10 |
|
| 1657 | - * |
|
| 1658 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1659 | - * @return echo The javascript to open and highlight the Formidable menu |
|
| 1660 | - */ |
|
| 1650 | + $string = $new_string; |
|
| 1651 | + } |
|
| 1652 | + return $string; |
|
| 1653 | + } |
|
| 1654 | + |
|
| 1655 | + /** |
|
| 1656 | + * @since 1.07.10 |
|
| 1657 | + * |
|
| 1658 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1659 | + * @return echo The javascript to open and highlight the Formidable menu |
|
| 1660 | + */ |
|
| 1661 | 1661 | public static function maybe_highlight_menu( $post_type ) { |
| 1662 | - global $post, $pagenow; |
|
| 1662 | + global $post, $pagenow; |
|
| 1663 | 1663 | |
| 1664 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1665 | - return; |
|
| 1666 | - } |
|
| 1664 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1665 | + return; |
|
| 1666 | + } |
|
| 1667 | 1667 | |
| 1668 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1669 | - return; |
|
| 1670 | - } |
|
| 1668 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1669 | + return; |
|
| 1670 | + } |
|
| 1671 | 1671 | |
| 1672 | - self::load_admin_wide_js(); |
|
| 1673 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1674 | - } |
|
| 1672 | + self::load_admin_wide_js(); |
|
| 1673 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1674 | + } |
|
| 1675 | 1675 | |
| 1676 | - /** |
|
| 1677 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1678 | - * @since 2.0 |
|
| 1679 | - */ |
|
| 1676 | + /** |
|
| 1677 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1678 | + * @since 2.0 |
|
| 1679 | + */ |
|
| 1680 | 1680 | public static function load_admin_wide_js( $load = true ) { |
| 1681 | - $version = FrmAppHelper::plugin_version(); |
|
| 1681 | + $version = FrmAppHelper::plugin_version(); |
|
| 1682 | 1682 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1683 | 1683 | |
| 1684 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1684 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1685 | 1685 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1686 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1686 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1687 | 1687 | 'url' => FrmAppHelper::plugin_url(), |
| 1688 | 1688 | 'loading' => __( 'Loading…' ), |
| 1689 | 1689 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
| 1690 | - ) ); |
|
| 1690 | + ) ); |
|
| 1691 | 1691 | |
| 1692 | 1692 | if ( $load ) { |
| 1693 | 1693 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1694 | 1694 | } |
| 1695 | - } |
|
| 1695 | + } |
|
| 1696 | 1696 | |
| 1697 | 1697 | /** |
| 1698 | 1698 | * @since 2.0.9 |
@@ -1701,9 +1701,9 @@ discard block |
||
| 1701 | 1701 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1702 | 1702 | } |
| 1703 | 1703 | |
| 1704 | - /** |
|
| 1705 | - * @param string $location |
|
| 1706 | - */ |
|
| 1704 | + /** |
|
| 1705 | + * @param string $location |
|
| 1706 | + */ |
|
| 1707 | 1707 | public static function localize_script( $location ) { |
| 1708 | 1708 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1709 | 1709 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1753,81 +1753,81 @@ discard block |
||
| 1753 | 1753 | } |
| 1754 | 1754 | } |
| 1755 | 1755 | |
| 1756 | - /** |
|
| 1757 | - * @since 1.07.10 |
|
| 1758 | - * |
|
| 1759 | - * @param float $min_version The version the add-on requires |
|
| 1760 | - * @return echo The message on the plugins listing page |
|
| 1761 | - */ |
|
| 1756 | + /** |
|
| 1757 | + * @since 1.07.10 |
|
| 1758 | + * |
|
| 1759 | + * @param float $min_version The version the add-on requires |
|
| 1760 | + * @return echo The message on the plugins listing page |
|
| 1761 | + */ |
|
| 1762 | 1762 | public static function min_version_notice( $min_version ) { |
| 1763 | - $frm_version = self::plugin_version(); |
|
| 1763 | + $frm_version = self::plugin_version(); |
|
| 1764 | 1764 | |
| 1765 | - // check if Formidable meets minimum requirements |
|
| 1766 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1767 | - return; |
|
| 1768 | - } |
|
| 1765 | + // check if Formidable meets minimum requirements |
|
| 1766 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1767 | + return; |
|
| 1768 | + } |
|
| 1769 | 1769 | |
| 1770 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1770 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1771 | 1771 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
| 1772 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1773 | - '</div></td></tr>'; |
|
| 1774 | - } |
|
| 1775 | - |
|
| 1776 | - public static function locales( $type = 'date' ) { |
|
| 1777 | - $locales = array( |
|
| 1778 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1779 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1780 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1781 | - 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
| 1782 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1783 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1784 | - 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
| 1785 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1786 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1787 | - 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
| 1788 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1789 | - 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
| 1790 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1791 | - 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
| 1792 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1793 | - 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
| 1794 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1795 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1796 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1797 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1798 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1799 | - 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
| 1800 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1801 | - 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
| 1802 | - 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
| 1803 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1804 | - 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
| 1805 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1806 | - 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
| 1807 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1808 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1809 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1810 | - ); |
|
| 1811 | - |
|
| 1812 | - if ( $type == 'captcha' ) { |
|
| 1813 | - // remove the languages unavailable for the captcha |
|
| 1814 | - $unset = array( |
|
| 1815 | - '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
| 1816 | - 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
| 1817 | - 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
| 1818 | - ); |
|
| 1819 | - } else { |
|
| 1820 | - // remove the languages unavailable for the datepicker |
|
| 1821 | - $unset = array( |
|
| 1822 | - 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
| 1823 | - 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
| 1824 | - 'es-419', 'tr', |
|
| 1825 | - ); |
|
| 1826 | - } |
|
| 1827 | - |
|
| 1828 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1829 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1830 | - |
|
| 1831 | - return $locales; |
|
| 1832 | - } |
|
| 1772 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1773 | + '</div></td></tr>'; |
|
| 1774 | + } |
|
| 1775 | + |
|
| 1776 | + public static function locales( $type = 'date' ) { |
|
| 1777 | + $locales = array( |
|
| 1778 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1779 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1780 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1781 | + 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
| 1782 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1783 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1784 | + 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
| 1785 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1786 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1787 | + 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
| 1788 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1789 | + 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
| 1790 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1791 | + 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
| 1792 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1793 | + 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
| 1794 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1795 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1796 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1797 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1798 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1799 | + 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
| 1800 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1801 | + 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
| 1802 | + 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
| 1803 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1804 | + 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
| 1805 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1806 | + 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
| 1807 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1808 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1809 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1810 | + ); |
|
| 1811 | + |
|
| 1812 | + if ( $type == 'captcha' ) { |
|
| 1813 | + // remove the languages unavailable for the captcha |
|
| 1814 | + $unset = array( |
|
| 1815 | + '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
| 1816 | + 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
| 1817 | + 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
| 1818 | + ); |
|
| 1819 | + } else { |
|
| 1820 | + // remove the languages unavailable for the datepicker |
|
| 1821 | + $unset = array( |
|
| 1822 | + 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
| 1823 | + 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
| 1824 | + 'es-419', 'tr', |
|
| 1825 | + ); |
|
| 1826 | + } |
|
| 1827 | + |
|
| 1828 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1829 | + $locales = apply_filters('frm_locales', $locales); |
|
| 1830 | + |
|
| 1831 | + return $locales; |
|
| 1832 | + } |
|
| 1833 | 1833 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -23,16 +23,16 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public static function plugin_folder() { |
| 26 | - return basename(self::plugin_path()); |
|
| 26 | + return basename( self::plugin_path() ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public static function plugin_path() { |
| 30 | - return dirname(dirname(dirname(__FILE__))); |
|
| 30 | + return dirname( dirname( dirname( __FILE__ ) ) ); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public static function plugin_url() { |
| 34 | 34 | //prevously FRM_URL constant |
| 35 | - return plugins_url( '', self::plugin_path() .'/formidable.php' ); |
|
| 35 | + return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public static function relative_plugin_url() { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @return string |
| 55 | 55 | */ |
| 56 | 56 | public static function site_name() { |
| 57 | - return get_option('blogname'); |
|
| 57 | + return get_option( 'blogname' ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | /** |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public static function get_settings() { |
| 69 | 69 | global $frm_settings; |
| 70 | - if ( empty($frm_settings) ) { |
|
| 70 | + if ( empty( $frm_settings ) ) { |
|
| 71 | 71 | $frm_settings = new FrmSettings(); |
| 72 | 72 | } |
| 73 | 73 | return $frm_settings; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | public static function pro_is_installed() { |
| 86 | - return apply_filters('frm_pro_installed', false); |
|
| 86 | + return apply_filters( 'frm_pro_installed', false ); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @return boolean |
| 128 | 128 | */ |
| 129 | 129 | public static function doing_ajax() { |
| 130 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 130 | + return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page(); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * @return boolean |
| 148 | 148 | */ |
| 149 | 149 | public static function is_admin() { |
| 150 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 150 | + return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | /** |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | * @return string |
| 174 | 174 | */ |
| 175 | 175 | public static function get_server_value( $value ) { |
| 176 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 176 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -188,14 +188,14 @@ discard block |
||
| 188 | 188 | 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
| 189 | 189 | 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
| 190 | 190 | ) as $key ) { |
| 191 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 191 | + if ( ! isset( $_SERVER[$key] ) ) { |
|
| 192 | 192 | continue; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 196 | - $ip = trim($ip); // just to be safe |
|
| 195 | + foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { |
|
| 196 | + $ip = trim( $ip ); // just to be safe |
|
| 197 | 197 | |
| 198 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 198 | + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
|
| 199 | 199 | return $ip; |
| 200 | 200 | } |
| 201 | 201 | } |
@@ -205,15 +205,15 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
| 208 | - if ( strpos($param, '[') ) { |
|
| 209 | - $params = explode('[', $param); |
|
| 208 | + if ( strpos( $param, '[' ) ) { |
|
| 209 | + $params = explode( '[', $param ); |
|
| 210 | 210 | $param = $params[0]; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | if ( $src == 'get' ) { |
| 214 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 215 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 216 | - $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[ $param ] ) ) ); |
|
| 214 | + $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default ); |
|
| 215 | + if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) { |
|
| 216 | + $value = stripslashes_deep( htmlspecialchars_decode( urldecode( $_GET[$param] ) ) ); |
|
| 217 | 217 | } |
| 218 | 218 | self::sanitize_value( $sanitize, $value ); |
| 219 | 219 | } else { |
@@ -222,12 +222,12 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 224 | 224 | foreach ( $params as $k => $p ) { |
| 225 | - if ( ! $k || ! is_array($value) ) { |
|
| 225 | + if ( ! $k || ! is_array( $value ) ) { |
|
| 226 | 226 | continue; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | - $p = trim($p, ']'); |
|
| 230 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 229 | + $p = trim( $p, ']' ); |
|
| 230 | + $value = isset( $value[$p] ) ? $value[$p] : $default; |
|
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | |
@@ -269,16 +269,16 @@ discard block |
||
| 269 | 269 | |
| 270 | 270 | $value = $args['default']; |
| 271 | 271 | if ( $args['type'] == 'get' ) { |
| 272 | - if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
|
| 273 | - $value = $_GET[ $args['param'] ]; |
|
| 272 | + if ( $_GET && isset( $_GET[$args['param']] ) ) { |
|
| 273 | + $value = $_GET[$args['param']]; |
|
| 274 | 274 | } |
| 275 | 275 | } else if ( $args['type'] == 'post' ) { |
| 276 | - if ( isset( $_POST[ $args['param'] ] ) ) { |
|
| 277 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); |
|
| 276 | + if ( isset( $_POST[$args['param']] ) ) { |
|
| 277 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); |
|
| 278 | 278 | } |
| 279 | 279 | } else { |
| 280 | - if ( isset( $_REQUEST[ $args['param'] ] ) ) { |
|
| 281 | - $value = $_REQUEST[ $args['param'] ]; |
|
| 280 | + if ( isset( $_REQUEST[$args['param']] ) ) { |
|
| 281 | + $value = $_REQUEST[$args['param']]; |
|
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | |
@@ -314,8 +314,8 @@ discard block |
||
| 314 | 314 | public static function sanitize_request( $sanitize_method, &$values ) { |
| 315 | 315 | $temp_values = $values; |
| 316 | 316 | foreach ( $temp_values as $k => $val ) { |
| 317 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 318 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
|
| 317 | + if ( isset( $sanitize_method[$k] ) ) { |
|
| 318 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); |
|
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | } |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | public static function sanitize_array( &$values ) { |
| 324 | 324 | $temp_values = $values; |
| 325 | 325 | foreach ( $temp_values as $k => $val ) { |
| 326 | - $values[ $k ] = wp_kses_post( $val ); |
|
| 326 | + $values[$k] = wp_kses_post( $val ); |
|
| 327 | 327 | } |
| 328 | 328 | } |
| 329 | 329 | |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | $allowed_html = array(); |
| 345 | 345 | foreach ( $allowed as $a ) { |
| 346 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); |
|
| 346 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | return wp_kses( $value, $allowed_html ); |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @since 2.0 |
| 355 | 355 | */ |
| 356 | 356 | public static function remove_get_action() { |
| 357 | - if ( ! isset($_GET) ) { |
|
| 357 | + if ( ! isset( $_GET ) ) { |
|
| 358 | 358 | return; |
| 359 | 359 | } |
| 360 | 360 | |
@@ -376,8 +376,8 @@ discard block |
||
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | global $wp_query; |
| 379 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 380 | - $value = $wp_query->query_vars[ $param ]; |
|
| 379 | + if ( isset( $wp_query->query_vars[$param] ) ) { |
|
| 380 | + $value = $wp_query->query_vars[$param]; |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | return $value; |
@@ -388,9 +388,9 @@ discard block |
||
| 388 | 388 | */ |
| 389 | 389 | public static function trigger_hook_load( $type, $object = null ) { |
| 390 | 390 | // only load the form hooks once |
| 391 | - $hooks_loaded = apply_filters('frm_'. $type .'_hooks_loaded', false, $object); |
|
| 391 | + $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
|
| 392 | 392 | if ( ! $hooks_loaded ) { |
| 393 | - do_action('frm_load_'. $type .'_hooks'); |
|
| 393 | + do_action( 'frm_load_' . $type . '_hooks' ); |
|
| 394 | 394 | } |
| 395 | 395 | } |
| 396 | 396 | |
@@ -406,16 +406,16 @@ discard block |
||
| 406 | 406 | * @return mixed $results The cache or query results |
| 407 | 407 | */ |
| 408 | 408 | public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
| 409 | - $results = wp_cache_get($cache_key, $group); |
|
| 410 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 409 | + $results = wp_cache_get( $cache_key, $group ); |
|
| 410 | + if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) { |
|
| 411 | 411 | return $results; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | if ( 'get_posts' == $type ) { |
| 415 | - $results = get_posts($query); |
|
| 415 | + $results = get_posts( $query ); |
|
| 416 | 416 | } else { |
| 417 | 417 | global $wpdb; |
| 418 | - $results = $wpdb->{$type}($query); |
|
| 418 | + $results = $wpdb->{$type}( $query ); |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | if ( ! self::prevent_caching() ) { |
@@ -439,9 +439,9 @@ discard block |
||
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | // then check the transient |
| 442 | - $results = get_transient($cache_key); |
|
| 442 | + $results = get_transient( $cache_key ); |
|
| 443 | 443 | if ( $results ) { |
| 444 | - wp_cache_set($cache_key, $results); |
|
| 444 | + wp_cache_set( $cache_key, $results ); |
|
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | return $results; |
@@ -452,8 +452,8 @@ discard block |
||
| 452 | 452 | * @param string $cache_key |
| 453 | 453 | */ |
| 454 | 454 | public static function delete_cache_and_transient( $cache_key ) { |
| 455 | - delete_transient($cache_key); |
|
| 456 | - wp_cache_delete($cache_key); |
|
| 455 | + delete_transient( $cache_key ); |
|
| 456 | + wp_cache_delete( $cache_key ); |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
@@ -467,9 +467,9 @@ discard block |
||
| 467 | 467 | public static function cache_delete_group( $group ) { |
| 468 | 468 | global $wp_object_cache; |
| 469 | 469 | |
| 470 | - if ( isset( $wp_object_cache->cache[ $group ] ) ) { |
|
| 471 | - foreach ( $wp_object_cache->cache[ $group ] as $k => $v ) { |
|
| 472 | - wp_cache_delete($k, $group); |
|
| 470 | + if ( isset( $wp_object_cache->cache[$group] ) ) { |
|
| 471 | + foreach ( $wp_object_cache->cache[$group] as $k => $v ) { |
|
| 472 | + wp_cache_delete( $k, $group ); |
|
| 473 | 473 | } |
| 474 | 474 | return true; |
| 475 | 475 | } |
@@ -500,29 +500,29 @@ discard block |
||
| 500 | 500 | public static function load_scripts( $scripts ) { |
| 501 | 501 | _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_script' ); |
| 502 | 502 | foreach ( (array) $scripts as $s ) { |
| 503 | - wp_enqueue_script($s); |
|
| 503 | + wp_enqueue_script( $s ); |
|
| 504 | 504 | } |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | public static function load_styles( $styles ) { |
| 508 | 508 | _deprecated_function( __FUNCTION__, '2.0', 'wp_enqueue_style' ); |
| 509 | 509 | foreach ( (array) $styles as $s ) { |
| 510 | - wp_enqueue_style($s); |
|
| 510 | + wp_enqueue_style( $s ); |
|
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | public static function get_pages() { |
| 515 | - return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
| 515 | + return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
| 519 | 519 | $pages = self::get_pages(); |
| 520 | 520 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 521 | 521 | ?> |
| 522 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
|
| 522 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
|
| 523 | 523 | <option value=""> </option> |
| 524 | 524 | <?php foreach ( $pages as $page ) { ?> |
| 525 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
| 525 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
| 526 | 526 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> |
| 527 | 527 | </option> |
| 528 | 528 | <?php } ?> |
@@ -531,26 +531,26 @@ discard block |
||
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | public static function post_edit_link( $post_id ) { |
| 534 | - $post = get_post($post_id); |
|
| 534 | + $post = get_post( $post_id ); |
|
| 535 | 535 | if ( $post ) { |
| 536 | - return '<a href="'. esc_url(admin_url('post.php') .'?post='. $post_id .'&action=edit') .'">'. self::truncate($post->post_title, 50) .'</a>'; |
|
| 536 | + return '<a href="' . esc_url( admin_url( 'post.php' ) . '?post=' . $post_id . '&action=edit' ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
|
| 537 | 537 | } |
| 538 | 538 | return ''; |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 542 | 542 | ?> |
| 543 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
|
| 543 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php |
|
| 544 | 544 | echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
| 545 | 545 | ?> class="frm_multiselect"> |
| 546 | - <?php self::roles_options($capability); ?> |
|
| 546 | + <?php self::roles_options( $capability ); ?> |
|
| 547 | 547 | </select> |
| 548 | 548 | <?php |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | public static function roles_options( $capability ) { |
| 552 | 552 | global $frm_vars; |
| 553 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 553 | + if ( isset( $frm_vars['editable_roles'] ) ) { |
|
| 554 | 554 | $editable_roles = $frm_vars['editable_roles']; |
| 555 | 555 | } else { |
| 556 | 556 | $editable_roles = get_editable_roles(); |
@@ -558,10 +558,10 @@ discard block |
||
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | foreach ( $editable_roles as $role => $details ) { |
| 561 | - $name = translate_user_role($details['name'] ); ?> |
|
| 562 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
|
| 561 | + $name = translate_user_role( $details['name'] ); ?> |
|
| 562 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> |
|
| 563 | 563 | <?php |
| 564 | - unset($role, $details); |
|
| 564 | + unset( $role, $details ); |
|
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | public static function maybe_add_permissions() { |
| 618 | 618 | self::force_capability( 'frm_view_entries' ); |
| 619 | 619 | |
| 620 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 620 | + if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
|
| 621 | 621 | return; |
| 622 | 622 | } |
| 623 | 623 | |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | $frm_roles = self::frm_capabilities(); |
| 627 | 627 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 628 | 628 | $user->add_cap( $frm_role ); |
| 629 | - unset($frm_role, $frm_role_description); |
|
| 629 | + unset( $frm_role, $frm_role_description ); |
|
| 630 | 630 | } |
| 631 | 631 | } |
| 632 | 632 | |
@@ -651,12 +651,12 @@ discard block |
||
| 651 | 651 | * @param string $permission |
| 652 | 652 | */ |
| 653 | 653 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 654 | - $permission_error = self::permission_nonce_error($permission); |
|
| 654 | + $permission_error = self::permission_nonce_error( $permission ); |
|
| 655 | 655 | if ( $permission_error !== false ) { |
| 656 | 656 | if ( 'hide' == $show_message ) { |
| 657 | 657 | $permission_error = ''; |
| 658 | 658 | } |
| 659 | - wp_die($permission_error); |
|
| 659 | + wp_die( $permission_error ); |
|
| 660 | 660 | } |
| 661 | 661 | } |
| 662 | 662 | |
@@ -673,11 +673,11 @@ discard block |
||
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | $error = false; |
| 676 | - if ( empty($nonce_name) ) { |
|
| 676 | + if ( empty( $nonce_name ) ) { |
|
| 677 | 677 | return $error; |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 680 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
| 681 | 681 | $frm_settings = self::get_settings(); |
| 682 | 682 | $error = $frm_settings->admin_permission; |
| 683 | 683 | } |
@@ -693,9 +693,9 @@ discard block |
||
| 693 | 693 | |
| 694 | 694 | public static function check_selected( $values, $current ) { |
| 695 | 695 | $values = self::recursive_function_map( $values, 'trim' ); |
| 696 | - $current = trim($current); |
|
| 696 | + $current = trim( $current ); |
|
| 697 | 697 | |
| 698 | - return ( is_array($values) && in_array($current, $values) ) || ( ! is_array($values) && $values == $current ); |
|
| 698 | + return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | /** |
@@ -756,7 +756,7 @@ discard block |
||
| 756 | 756 | } else { |
| 757 | 757 | foreach ( $value as $k => $v ) { |
| 758 | 758 | if ( ! is_array( $v ) ) { |
| 759 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
| 759 | + $value[$k] = call_user_func( $original_function, $v ); |
|
| 760 | 760 | } |
| 761 | 761 | } |
| 762 | 762 | } |
@@ -777,11 +777,11 @@ discard block |
||
| 777 | 777 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 778 | 778 | $return = array(); |
| 779 | 779 | foreach ( $array as $key => $value ) { |
| 780 | - if ( is_array($value) ) { |
|
| 780 | + if ( is_array( $value ) ) { |
|
| 781 | 781 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 782 | 782 | } else { |
| 783 | 783 | if ( $keys == 'keep' ) { |
| 784 | - $return[ $key ] = $value; |
|
| 784 | + $return[$key] = $value; |
|
| 785 | 785 | } else { |
| 786 | 786 | $return[] = $value; |
| 787 | 787 | } |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | } |
| 792 | 792 | |
| 793 | 793 | public static function esc_textarea( $text ) { |
| 794 | - $safe_text = str_replace('"', '"', $text); |
|
| 794 | + $safe_text = str_replace( '"', '"', $text ); |
|
| 795 | 795 | $safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES ); |
| 796 | 796 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 797 | 797 | } |
@@ -801,8 +801,8 @@ discard block |
||
| 801 | 801 | * @since 2.0 |
| 802 | 802 | */ |
| 803 | 803 | public static function use_wpautop( $content ) { |
| 804 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 805 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 804 | + if ( apply_filters( 'frm_use_wpautop', true ) ) { |
|
| 805 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
|
| 806 | 806 | } |
| 807 | 807 | return $content; |
| 808 | 808 | } |
@@ -820,8 +820,8 @@ discard block |
||
| 820 | 820 | * @return string The base Google APIS url for the current version of jQuery UI |
| 821 | 821 | */ |
| 822 | 822 | public static function jquery_ui_base_url() { |
| 823 | - $url = 'http'. ( is_ssl() ? 's' : '' ) .'://ajax.googleapis.com/ajax/libs/jqueryui/'. self::script_version('jquery-ui-core'); |
|
| 824 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 823 | + $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core' ); |
|
| 824 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
|
| 825 | 825 | return $url; |
| 826 | 826 | } |
| 827 | 827 | |
@@ -836,11 +836,11 @@ discard block |
||
| 836 | 836 | |
| 837 | 837 | $ver = 0; |
| 838 | 838 | |
| 839 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
| 839 | + if ( ! isset( $wp_scripts->registered[$handle] ) ) { |
|
| 840 | 840 | return $ver; |
| 841 | 841 | } |
| 842 | 842 | |
| 843 | - $query = $wp_scripts->registered[ $handle ]; |
|
| 843 | + $query = $wp_scripts->registered[$handle]; |
|
| 844 | 844 | if ( is_object( $query ) ) { |
| 845 | 845 | $ver = $query->ver; |
| 846 | 846 | } |
@@ -853,7 +853,7 @@ discard block |
||
| 853 | 853 | } |
| 854 | 854 | |
| 855 | 855 | public static function get_user_id_param( $user_id ) { |
| 856 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 856 | + if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
|
| 857 | 857 | return $user_id; |
| 858 | 858 | } |
| 859 | 859 | |
@@ -861,29 +861,29 @@ discard block |
||
| 861 | 861 | $user_ID = get_current_user_id(); |
| 862 | 862 | $user_id = $user_ID; |
| 863 | 863 | } else { |
| 864 | - if ( is_email($user_id) ) { |
|
| 865 | - $user = get_user_by('email', $user_id); |
|
| 864 | + if ( is_email( $user_id ) ) { |
|
| 865 | + $user = get_user_by( 'email', $user_id ); |
|
| 866 | 866 | } else { |
| 867 | - $user = get_user_by('login', $user_id); |
|
| 867 | + $user = get_user_by( 'login', $user_id ); |
|
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | if ( $user ) { |
| 871 | 871 | $user_id = $user->ID; |
| 872 | 872 | } |
| 873 | - unset($user); |
|
| 873 | + unset( $user ); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | return $user_id; |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | 879 | public static function get_file_contents( $filename, $atts = array() ) { |
| 880 | - if ( ! is_file($filename) ) { |
|
| 880 | + if ( ! is_file( $filename ) ) { |
|
| 881 | 881 | return false; |
| 882 | 882 | } |
| 883 | 883 | |
| 884 | - extract($atts); |
|
| 884 | + extract( $atts ); |
|
| 885 | 885 | ob_start(); |
| 886 | - include($filename); |
|
| 886 | + include( $filename ); |
|
| 887 | 887 | $contents = ob_get_contents(); |
| 888 | 888 | ob_end_clean(); |
| 889 | 889 | return $contents; |
@@ -899,28 +899,28 @@ discard block |
||
| 899 | 899 | $key = ''; |
| 900 | 900 | |
| 901 | 901 | if ( ! empty( $name ) ) { |
| 902 | - $key = sanitize_key($name); |
|
| 902 | + $key = sanitize_key( $name ); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | if ( empty( $key ) ) { |
| 906 | - $max_slug_value = pow(36, $num_chars); |
|
| 906 | + $max_slug_value = pow( 36, $num_chars ); |
|
| 907 | 907 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
| 908 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 908 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
| 909 | 909 | } |
| 910 | 910 | |
| 911 | - if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
| 912 | - $key = $key .'a'; |
|
| 911 | + if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
| 912 | + $key = $key . 'a'; |
|
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
| 916 | 916 | |
| 917 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 917 | + if ( $key_check || is_numeric( $key_check ) ) { |
|
| 918 | 918 | $suffix = 2; |
| 919 | 919 | do { |
| 920 | 920 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 921 | 921 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
| 922 | - $suffix++; |
|
| 923 | - } while ($key_check || is_numeric($key_check)); |
|
| 922 | + $suffix ++; |
|
| 923 | + } while ( $key_check || is_numeric( $key_check ) ); |
|
| 924 | 924 | $key = $alt_post_name; |
| 925 | 925 | } |
| 926 | 926 | return $key; |
@@ -938,32 +938,32 @@ discard block |
||
| 938 | 938 | |
| 939 | 939 | global $frm_vars; |
| 940 | 940 | |
| 941 | - if ( empty($post_values) ) { |
|
| 942 | - $post_values = stripslashes_deep($_POST); |
|
| 941 | + if ( empty( $post_values ) ) { |
|
| 942 | + $post_values = stripslashes_deep( $_POST ); |
|
| 943 | 943 | } |
| 944 | 944 | |
| 945 | 945 | $values = array( 'id' => $record->id, 'fields' => array() ); |
| 946 | 946 | |
| 947 | 947 | foreach ( array( 'name', 'description' ) as $var ) { |
| 948 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 949 | - $values[ $var ] = self::get_param( $var, $default_val ); |
|
| 950 | - unset($var, $default_val); |
|
| 948 | + $default_val = isset( $record->{$var}) ? $record->{$var} : ''; |
|
| 949 | + $values[$var] = self::get_param( $var, $default_val ); |
|
| 950 | + unset( $var, $default_val ); |
|
| 951 | 951 | } |
| 952 | 952 | |
| 953 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 953 | + $values['description'] = self::use_wpautop( $values['description'] ); |
|
| 954 | 954 | $frm_settings = self::get_settings(); |
| 955 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
| 955 | + $is_form_builder = self::is_admin_page( 'formidable' ); |
|
| 956 | 956 | |
| 957 | 957 | foreach ( (array) $fields as $field ) { |
| 958 | 958 | // Make sure to filter default values (for placeholder text), but not on the form builder page |
| 959 | 959 | if ( ! $is_form_builder ) { |
| 960 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 960 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
|
| 961 | 961 | } |
| 962 | 962 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
| 963 | - self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
| 963 | + self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
| 964 | 964 | } |
| 965 | 965 | |
| 966 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 966 | + self::fill_form_opts( $record, $table, $post_values, $values ); |
|
| 967 | 967 | |
| 968 | 968 | if ( $table == 'entries' ) { |
| 969 | 969 | $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
@@ -980,8 +980,8 @@ discard block |
||
| 980 | 980 | if ( $args['default'] ) { |
| 981 | 981 | $meta_value = $field->default_value; |
| 982 | 982 | } else { |
| 983 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 984 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 983 | + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
|
| 984 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
| 985 | 985 | $field->field_options['custom_field'] = ''; |
| 986 | 986 | } |
| 987 | 987 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
@@ -990,8 +990,8 @@ discard block |
||
| 990 | 990 | } |
| 991 | 991 | } |
| 992 | 992 | |
| 993 | - $field_type = isset( $post_values['field_options'][ 'type_'. $field->id ] ) ? $post_values['field_options'][ 'type_'. $field->id ] : $field->type; |
|
| 994 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 993 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; |
|
| 994 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; |
|
| 995 | 995 | |
| 996 | 996 | $field_array = array( |
| 997 | 997 | 'id' => $field->id, |
@@ -999,7 +999,7 @@ discard block |
||
| 999 | 999 | 'default_value' => $field->default_value, |
| 1000 | 1000 | 'name' => $field->name, |
| 1001 | 1001 | 'description' => $field->description, |
| 1002 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1002 | + 'type' => apply_filters( 'frm_field_type', $field_type, $field, $new_value ), |
|
| 1003 | 1003 | 'options' => $field->options, |
| 1004 | 1004 | 'required' => $field->required, |
| 1005 | 1005 | 'field_key' => $field->field_key, |
@@ -1009,38 +1009,38 @@ discard block |
||
| 1009 | 1009 | ); |
| 1010 | 1010 | |
| 1011 | 1011 | $args['field_type'] = $field_type; |
| 1012 | - self::fill_field_opts($field, $field_array, $args); |
|
| 1012 | + self::fill_field_opts( $field, $field_array, $args ); |
|
| 1013 | 1013 | |
| 1014 | - $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']); |
|
| 1014 | + $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'] ); |
|
| 1015 | 1015 | |
| 1016 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1016 | + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
|
| 1017 | 1017 | $field_array['unique_msg'] = ''; |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | 1020 | $field_array = array_merge( $field->field_options, $field_array ); |
| 1021 | 1021 | |
| 1022 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1022 | + $values['fields'][$field->id] = $field_array; |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
| 1026 | 1026 | $post_values = $args['post_values']; |
| 1027 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1027 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
| 1028 | 1028 | |
| 1029 | 1029 | foreach ( $opt_defaults as $opt => $default_opt ) { |
| 1030 | - $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt .'_'. $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt .'_'. $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
| 1031 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1032 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1033 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1030 | + $field_array[$opt] = ( $post_values && isset( $post_values['field_options'][$opt . '_' . $field->id] ) ) ? maybe_unserialize( $post_values['field_options'][$opt . '_' . $field->id] ) : ( isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default_opt ); |
|
| 1031 | + if ( $opt == 'blank' && $field_array[$opt] == '' ) { |
|
| 1032 | + $field_array[$opt] = $args['frm_settings']->blank_msg; |
|
| 1033 | + } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) { |
|
| 1034 | 1034 | if ( $args['field_type'] == 'captcha' ) { |
| 1035 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1035 | + $field_array[$opt] = $args['frm_settings']->re_msg; |
|
| 1036 | 1036 | } else { |
| 1037 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1037 | + $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1038 | 1038 | } |
| 1039 | 1039 | } |
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | if ( $field_array['custom_html'] == '' ) { |
| 1043 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1043 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] ); |
|
| 1044 | 1044 | } |
| 1045 | 1045 | } |
| 1046 | 1046 | |
@@ -1059,18 +1059,18 @@ discard block |
||
| 1059 | 1059 | return; |
| 1060 | 1060 | } |
| 1061 | 1061 | |
| 1062 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1062 | + $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
|
| 1063 | 1063 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1064 | 1064 | |
| 1065 | - if ( ! is_array($form->options) ) { |
|
| 1065 | + if ( ! is_array( $form->options ) ) { |
|
| 1066 | 1066 | return; |
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | 1069 | foreach ( $form->options as $opt => $value ) { |
| 1070 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1070 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; |
|
| 1071 | 1071 | } |
| 1072 | 1072 | |
| 1073 | - self::fill_form_defaults($post_values, $values); |
|
| 1073 | + self::fill_form_defaults( $post_values, $values ); |
|
| 1074 | 1074 | } |
| 1075 | 1075 | |
| 1076 | 1076 | /** |
@@ -1080,23 +1080,23 @@ discard block |
||
| 1080 | 1080 | $form_defaults = FrmFormsHelper::get_default_opts(); |
| 1081 | 1081 | |
| 1082 | 1082 | foreach ( $form_defaults as $opt => $default ) { |
| 1083 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1084 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
|
| 1083 | + if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { |
|
| 1084 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; |
|
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | - unset($opt, $defaut); |
|
| 1087 | + unset( $opt, $defaut ); |
|
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | - if ( ! isset($values['custom_style']) ) { |
|
| 1090 | + if ( ! isset( $values['custom_style'] ) ) { |
|
| 1091 | 1091 | $frm_settings = self::get_settings(); |
| 1092 | 1092 | $values['custom_style'] = ( $post_values && isset( $post_values['options']['custom_style'] ) ) ? absint( $_POST['options']['custom_style'] ) : ( $frm_settings->load_style != 'none' ); |
| 1093 | 1093 | } |
| 1094 | 1094 | |
| 1095 | 1095 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1096 | - if ( ! isset( $values[ $h .'_html' ] ) ) { |
|
| 1097 | - $values[ $h .'_html' ] = ( isset( $post_values['options'][ $h .'_html' ] ) ? $post_values['options'][ $h .'_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1096 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
| 1097 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1098 | 1098 | } |
| 1099 | - unset($h); |
|
| 1099 | + unset( $h ); |
|
| 1100 | 1100 | } |
| 1101 | 1101 | } |
| 1102 | 1102 | |
@@ -1112,9 +1112,9 @@ discard block |
||
| 1112 | 1112 | } |
| 1113 | 1113 | ?> |
| 1114 | 1114 | <li> |
| 1115 | - <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['id']) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
|
| 1116 | - <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr($class) ?>" data-code="<?php echo esc_attr($args['key']) ?>" >[<?php echo esc_attr( self::truncate($args['key'], 10) ) ?>]</a> |
|
| 1117 | - <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr($args['id']) ?>" ><?php echo esc_attr( self::truncate($args['name'], 60) ) ?></a> |
|
| 1115 | + <a href="javascript:void(0)" class="frmids frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" >[<?php echo esc_attr( $args['id'] ) ?>]</a> |
|
| 1116 | + <a href="javascript:void(0)" class="frmkeys frm_insert_code alignright <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['key'] ) ?>" >[<?php echo esc_attr( self::truncate( $args['key'], 10 ) ) ?>]</a> |
|
| 1117 | + <a href="javascript:void(0)" class="frm_insert_code <?php echo esc_attr( $class ) ?>" data-code="<?php echo esc_attr( $args['id'] ) ?>" ><?php echo esc_attr( self::truncate( $args['name'], 60 ) ) ?></a> |
|
| 1118 | 1118 | </li> |
| 1119 | 1119 | <?php |
| 1120 | 1120 | } |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | return ''; |
| 1143 | 1143 | } else if ( $length <= 10 ) { |
| 1144 | 1144 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1145 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1145 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
|
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | 1148 | $sub = ''; |
@@ -1151,23 +1151,23 @@ discard block |
||
| 1151 | 1151 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1152 | 1152 | |
| 1153 | 1153 | foreach ( $words as $word ) { |
| 1154 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1154 | + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
|
| 1155 | 1155 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1156 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1156 | + if ( $total_len > $length && str_word_count( $sub ) ) { |
|
| 1157 | 1157 | break; |
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | $sub .= $part; |
| 1161 | 1161 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1162 | 1162 | |
| 1163 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1163 | + if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
|
| 1164 | 1164 | break; |
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | - unset($total_len, $word); |
|
| 1167 | + unset( $total_len, $word ); |
|
| 1168 | 1168 | } |
| 1169 | 1169 | |
| 1170 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1170 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
|
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | 1173 | public static function mb_function( $function_names, $args ) { |
@@ -1180,17 +1180,17 @@ discard block |
||
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1183 | - if ( empty($date) ) { |
|
| 1183 | + if ( empty( $date ) ) { |
|
| 1184 | 1184 | return $date; |
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | - if ( empty($date_format) ) { |
|
| 1188 | - $date_format = get_option('date_format'); |
|
| 1187 | + if ( empty( $date_format ) ) { |
|
| 1188 | + $date_format = get_option( 'date_format' ); |
|
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1191 | + if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
|
| 1192 | 1192 | $frmpro_settings = new FrmProSettings(); |
| 1193 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1193 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
|
| 1194 | 1194 | } |
| 1195 | 1195 | |
| 1196 | 1196 | $formatted = self::get_localized_date( $date_format, $date ); |
@@ -1205,7 +1205,7 @@ discard block |
||
| 1205 | 1205 | |
| 1206 | 1206 | private static function add_time_to_date( $time_format, $date ) { |
| 1207 | 1207 | if ( empty( $time_format ) ) { |
| 1208 | - $time_format = get_option('time_format'); |
|
| 1208 | + $time_format = get_option( 'time_format' ); |
|
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | 1211 | $trimmed_format = trim( $time_format ); |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | * @return string The time ago in words |
| 1230 | 1230 | */ |
| 1231 | 1231 | public static function human_time_diff( $from, $to = '' ) { |
| 1232 | - if ( empty($to) ) { |
|
| 1232 | + if ( empty( $to ) ) { |
|
| 1233 | 1233 | $to = time(); |
| 1234 | 1234 | } |
| 1235 | 1235 | |
@@ -1245,7 +1245,7 @@ discard block |
||
| 1245 | 1245 | ); |
| 1246 | 1246 | |
| 1247 | 1247 | // Difference in seconds |
| 1248 | - $diff = (int) ($to - $from); |
|
| 1248 | + $diff = (int) ( $to - $from ); |
|
| 1249 | 1249 | |
| 1250 | 1250 | // Something went wrong with date calculation and we ended up with a negative date. |
| 1251 | 1251 | if ( $diff < 1 ) { |
@@ -1262,17 +1262,17 @@ discard block |
||
| 1262 | 1262 | $count = 0; |
| 1263 | 1263 | |
| 1264 | 1264 | //Step one: the first chunk |
| 1265 | - for ( $i = 0, $j = count( $chunks ); $i < $j; $i++ ) { |
|
| 1266 | - $seconds = $chunks[ $i ][0]; |
|
| 1265 | + for ( $i = 0, $j = count( $chunks ); $i < $j; $i ++ ) { |
|
| 1266 | + $seconds = $chunks[$i][0]; |
|
| 1267 | 1267 | |
| 1268 | 1268 | // Finding the biggest chunk (if the chunk fits, break) |
| 1269 | - if ( ( $count = floor($diff / $seconds) ) != 0 ) { |
|
| 1269 | + if ( ( $count = floor( $diff / $seconds ) ) != 0 ) { |
|
| 1270 | 1270 | break; |
| 1271 | 1271 | } |
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | 1274 | // Set output var |
| 1275 | - $output = ( 1 == $count ) ? '1 '. $chunks[ $i ][1] : $count . ' ' . $chunks[ $i ][2]; |
|
| 1275 | + $output = ( 1 == $count ) ? '1 ' . $chunks[$i][1] : $count . ' ' . $chunks[$i][2]; |
|
| 1276 | 1276 | |
| 1277 | 1277 | if ( ! (int) trim( $output ) ) { |
| 1278 | 1278 | $output = '0 ' . __( 'seconds', 'formidable' ); |
@@ -1291,7 +1291,7 @@ discard block |
||
| 1291 | 1291 | */ |
| 1292 | 1292 | public static function esc_like( $term ) { |
| 1293 | 1293 | global $wpdb; |
| 1294 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1294 | + if ( method_exists( $wpdb, 'esc_like' ) ) { |
|
| 1295 | 1295 | // WP 4.0 |
| 1296 | 1296 | $term = $wpdb->esc_like( $term ); |
| 1297 | 1297 | } else { |
@@ -1305,17 +1305,17 @@ discard block |
||
| 1305 | 1305 | * @param string $order_query |
| 1306 | 1306 | */ |
| 1307 | 1307 | public static function esc_order( $order_query ) { |
| 1308 | - if ( empty($order_query) ) { |
|
| 1308 | + if ( empty( $order_query ) ) { |
|
| 1309 | 1309 | return ''; |
| 1310 | 1310 | } |
| 1311 | 1311 | |
| 1312 | 1312 | // remove ORDER BY before santizing |
| 1313 | - $order_query = strtolower($order_query); |
|
| 1314 | - if ( strpos($order_query, 'order by') !== false ) { |
|
| 1315 | - $order_query = str_replace('order by', '', $order_query); |
|
| 1313 | + $order_query = strtolower( $order_query ); |
|
| 1314 | + if ( strpos( $order_query, 'order by' ) !== false ) { |
|
| 1315 | + $order_query = str_replace( 'order by', '', $order_query ); |
|
| 1316 | 1316 | } |
| 1317 | 1317 | |
| 1318 | - $order_query = explode(' ', trim($order_query)); |
|
| 1318 | + $order_query = explode( ' ', trim( $order_query ) ); |
|
| 1319 | 1319 | |
| 1320 | 1320 | $order_fields = array( |
| 1321 | 1321 | 'id', 'form_key', 'name', 'description', |
@@ -1323,18 +1323,18 @@ discard block |
||
| 1323 | 1323 | 'default_template', 'status', 'created_at', |
| 1324 | 1324 | ); |
| 1325 | 1325 | |
| 1326 | - $order = trim(trim(reset($order_query), ',')); |
|
| 1327 | - if ( ! in_array($order, $order_fields) ) { |
|
| 1326 | + $order = trim( trim( reset( $order_query ), ',' ) ); |
|
| 1327 | + if ( ! in_array( $order, $order_fields ) ) { |
|
| 1328 | 1328 | return ''; |
| 1329 | 1329 | } |
| 1330 | 1330 | |
| 1331 | 1331 | $order_by = ''; |
| 1332 | - if ( count($order_query) > 1 ) { |
|
| 1332 | + if ( count( $order_query ) > 1 ) { |
|
| 1333 | 1333 | $order_by = end( $order_query ); |
| 1334 | 1334 | self::esc_order_by( $order_by ); |
| 1335 | 1335 | } |
| 1336 | 1336 | |
| 1337 | - return ' ORDER BY '. $order . ' '. $order_by; |
|
| 1337 | + return ' ORDER BY ' . $order . ' ' . $order_by; |
|
| 1338 | 1338 | } |
| 1339 | 1339 | |
| 1340 | 1340 | /** |
@@ -1351,24 +1351,24 @@ discard block |
||
| 1351 | 1351 | * @param string $limit |
| 1352 | 1352 | */ |
| 1353 | 1353 | public static function esc_limit( $limit ) { |
| 1354 | - if ( empty($limit) ) { |
|
| 1354 | + if ( empty( $limit ) ) { |
|
| 1355 | 1355 | return ''; |
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1359 | - if ( is_numeric($limit) ) { |
|
| 1360 | - return ' LIMIT '. $limit; |
|
| 1358 | + $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) ); |
|
| 1359 | + if ( is_numeric( $limit ) ) { |
|
| 1360 | + return ' LIMIT ' . $limit; |
|
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | - $limit = explode(',', trim($limit)); |
|
| 1363 | + $limit = explode( ',', trim( $limit ) ); |
|
| 1364 | 1364 | foreach ( $limit as $k => $l ) { |
| 1365 | 1365 | if ( is_numeric( $l ) ) { |
| 1366 | - $limit[ $k ] = $l; |
|
| 1366 | + $limit[$k] = $l; |
|
| 1367 | 1367 | } |
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | - $limit = implode(',', $limit); |
|
| 1371 | - return ' LIMIT '. $limit; |
|
| 1370 | + $limit = implode( ',', $limit ); |
|
| 1371 | + return ' LIMIT ' . $limit; |
|
| 1372 | 1372 | } |
| 1373 | 1373 | |
| 1374 | 1374 | /** |
@@ -1376,12 +1376,12 @@ discard block |
||
| 1376 | 1376 | * @since 2.0 |
| 1377 | 1377 | */ |
| 1378 | 1378 | public static function prepare_array_values( $array, $type = '%s' ) { |
| 1379 | - $placeholders = array_fill(0, count($array), $type); |
|
| 1380 | - return implode(', ', $placeholders); |
|
| 1379 | + $placeholders = array_fill( 0, count( $array ), $type ); |
|
| 1380 | + return implode( ', ', $placeholders ); |
|
| 1381 | 1381 | } |
| 1382 | 1382 | |
| 1383 | 1383 | public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
| 1384 | - if ( empty($where) ) { |
|
| 1384 | + if ( empty( $where ) ) { |
|
| 1385 | 1385 | return ''; |
| 1386 | 1386 | } |
| 1387 | 1387 | |
@@ -1427,7 +1427,7 @@ discard block |
||
| 1427 | 1427 | |
| 1428 | 1428 | public static function get_referer_info() { |
| 1429 | 1429 | _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::get_server_value' ); |
| 1430 | - return self::get_server_value('HTTP_REFERER'); |
|
| 1430 | + return self::get_server_value( 'HTTP_REFERER' ); |
|
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | /** |
@@ -1436,19 +1436,19 @@ discard block |
||
| 1436 | 1436 | public static function json_to_array( $json_vars ) { |
| 1437 | 1437 | $vars = array(); |
| 1438 | 1438 | foreach ( $json_vars as $jv ) { |
| 1439 | - $jv_name = explode('[', $jv['name']); |
|
| 1440 | - $last = count($jv_name) - 1; |
|
| 1439 | + $jv_name = explode( '[', $jv['name'] ); |
|
| 1440 | + $last = count( $jv_name ) - 1; |
|
| 1441 | 1441 | foreach ( $jv_name as $p => $n ) { |
| 1442 | - $name = trim($n, ']'); |
|
| 1443 | - if ( ! isset($l1) ) { |
|
| 1442 | + $name = trim( $n, ']' ); |
|
| 1443 | + if ( ! isset( $l1 ) ) { |
|
| 1444 | 1444 | $l1 = $name; |
| 1445 | 1445 | } |
| 1446 | 1446 | |
| 1447 | - if ( ! isset($l2) ) { |
|
| 1447 | + if ( ! isset( $l2 ) ) { |
|
| 1448 | 1448 | $l2 = $name; |
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | - if ( ! isset($l3) ) { |
|
| 1451 | + if ( ! isset( $l3 ) ) { |
|
| 1452 | 1452 | $l3 = $name; |
| 1453 | 1453 | } |
| 1454 | 1454 | |
@@ -1462,24 +1462,24 @@ discard block |
||
| 1462 | 1462 | |
| 1463 | 1463 | case 1: |
| 1464 | 1464 | $l2 = $name; |
| 1465 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1465 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
| 1466 | 1466 | break; |
| 1467 | 1467 | |
| 1468 | 1468 | case 2: |
| 1469 | 1469 | $l3 = $name; |
| 1470 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1470 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
| 1471 | 1471 | break; |
| 1472 | 1472 | |
| 1473 | 1473 | case 3: |
| 1474 | 1474 | $l4 = $name; |
| 1475 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1475 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
| 1476 | 1476 | break; |
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | - unset($this_val, $n); |
|
| 1479 | + unset( $this_val, $n ); |
|
| 1480 | 1480 | } |
| 1481 | 1481 | |
| 1482 | - unset($last, $jv); |
|
| 1482 | + unset( $last, $jv ); |
|
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | 1485 | return $vars; |
@@ -1492,8 +1492,8 @@ discard block |
||
| 1492 | 1492 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
| 1493 | 1493 | if ( $name == '' ) { |
| 1494 | 1494 | $vars[] = $val; |
| 1495 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1496 | - $vars[ $l1 ] = $val; |
|
| 1495 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
| 1496 | + $vars[$l1] = $val; |
|
| 1497 | 1497 | } |
| 1498 | 1498 | } |
| 1499 | 1499 | |
@@ -1508,7 +1508,7 @@ discard block |
||
| 1508 | 1508 | 'email_subject' => esc_attr( sprintf( __( 'If you leave the subject blank, the default will be used: %1$s Form submitted on %2$s', 'formidable' ), $form_name, self::site_name() ) ), |
| 1509 | 1509 | ); |
| 1510 | 1510 | |
| 1511 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1511 | + if ( ! isset( $tooltips[$name] ) ) { |
|
| 1512 | 1512 | return; |
| 1513 | 1513 | } |
| 1514 | 1514 | |
@@ -1518,7 +1518,7 @@ discard block |
||
| 1518 | 1518 | echo ' class="frm_help"'; |
| 1519 | 1519 | } |
| 1520 | 1520 | |
| 1521 | - echo ' title="'. esc_attr( $tooltips[ $name ] ); |
|
| 1521 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
| 1522 | 1522 | |
| 1523 | 1523 | if ( 'open' != $class ) { |
| 1524 | 1524 | echo '"'; |
@@ -1570,13 +1570,13 @@ discard block |
||
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | 1572 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1573 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
| 1573 | + if ( ! isset( $post_content[$key] ) ) { |
|
| 1574 | 1574 | return; |
| 1575 | 1575 | } |
| 1576 | 1576 | |
| 1577 | 1577 | if ( is_array( $val ) ) { |
| 1578 | 1578 | foreach ( $val as $k1 => $v1 ) { |
| 1579 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
| 1579 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
| 1580 | 1580 | unset( $k1, $v1 ); |
| 1581 | 1581 | } |
| 1582 | 1582 | } else { |
@@ -1584,7 +1584,7 @@ discard block |
||
| 1584 | 1584 | $val = stripslashes( $val ); |
| 1585 | 1585 | |
| 1586 | 1586 | // Add backslashes before double quotes and forward slashes only |
| 1587 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
| 1587 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
| 1588 | 1588 | } |
| 1589 | 1589 | } |
| 1590 | 1590 | |
@@ -1601,7 +1601,7 @@ discard block |
||
| 1601 | 1601 | $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] ); |
| 1602 | 1602 | |
| 1603 | 1603 | if ( empty( $settings['ID'] ) ) { |
| 1604 | - unset( $settings['ID']); |
|
| 1604 | + unset( $settings['ID'] ); |
|
| 1605 | 1605 | } |
| 1606 | 1606 | |
| 1607 | 1607 | // delete all caches for this group |
@@ -1635,17 +1635,17 @@ discard block |
||
| 1635 | 1635 | } |
| 1636 | 1636 | |
| 1637 | 1637 | public static function maybe_json_decode( $string ) { |
| 1638 | - if ( is_array($string) ) { |
|
| 1638 | + if ( is_array( $string ) ) { |
|
| 1639 | 1639 | return $string; |
| 1640 | 1640 | } |
| 1641 | 1641 | |
| 1642 | - $new_string = json_decode($string, true); |
|
| 1643 | - if ( function_exists('json_last_error') ) { |
|
| 1642 | + $new_string = json_decode( $string, true ); |
|
| 1643 | + if ( function_exists( 'json_last_error' ) ) { |
|
| 1644 | 1644 | // php 5.3+ |
| 1645 | 1645 | if ( json_last_error() == JSON_ERROR_NONE ) { |
| 1646 | 1646 | $string = $new_string; |
| 1647 | 1647 | } |
| 1648 | - } else if ( isset($new_string) ) { |
|
| 1648 | + } else if ( isset( $new_string ) ) { |
|
| 1649 | 1649 | // php < 5.3 fallback |
| 1650 | 1650 | $string = $new_string; |
| 1651 | 1651 | } |
@@ -1661,11 +1661,11 @@ discard block |
||
| 1661 | 1661 | public static function maybe_highlight_menu( $post_type ) { |
| 1662 | 1662 | global $post, $pagenow; |
| 1663 | 1663 | |
| 1664 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1664 | + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1665 | 1665 | return; |
| 1666 | 1666 | } |
| 1667 | 1667 | |
| 1668 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1668 | + if ( is_object( $post ) && $post->post_type != $post_type ) { |
|
| 1669 | 1669 | return; |
| 1670 | 1670 | } |
| 1671 | 1671 | |
@@ -1763,11 +1763,11 @@ discard block |
||
| 1763 | 1763 | $frm_version = self::plugin_version(); |
| 1764 | 1764 | |
| 1765 | 1765 | // check if Formidable meets minimum requirements |
| 1766 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1766 | + if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
|
| 1767 | 1767 | return; |
| 1768 | 1768 | } |
| 1769 | 1769 | |
| 1770 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1770 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
| 1771 | 1771 | echo '<tr class="plugin-update-tr active"><th colspan="' . absint( $wp_list_table->get_column_count() ) . '" class="check-column plugin-update colspanchange"><div class="update-message">' . |
| 1772 | 1772 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
| 1773 | 1773 | '</div></td></tr>'; |
@@ -1775,38 +1775,38 @@ discard block |
||
| 1775 | 1775 | |
| 1776 | 1776 | public static function locales( $type = 'date' ) { |
| 1777 | 1777 | $locales = array( |
| 1778 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1779 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1780 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1778 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1779 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1780 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1781 | 1781 | 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
| 1782 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1783 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1782 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1783 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1784 | 1784 | 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
| 1785 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1786 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1785 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1786 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1787 | 1787 | 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
| 1788 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1788 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1789 | 1789 | 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
| 1790 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1790 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1791 | 1791 | 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
| 1792 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1792 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1793 | 1793 | 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
| 1794 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1795 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1796 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1797 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1798 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1794 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1795 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1796 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1797 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1798 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1799 | 1799 | 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
| 1800 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1800 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1801 | 1801 | 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
| 1802 | 1802 | 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
| 1803 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1803 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1804 | 1804 | 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
| 1805 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1805 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1806 | 1806 | 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
| 1807 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1808 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1809 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1807 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1808 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1809 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1810 | 1810 | ); |
| 1811 | 1811 | |
| 1812 | 1812 | if ( $type == 'captcha' ) { |
@@ -1825,8 +1825,8 @@ discard block |
||
| 1825 | 1825 | ); |
| 1826 | 1826 | } |
| 1827 | 1827 | |
| 1828 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1829 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1828 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); |
|
| 1829 | + $locales = apply_filters( 'frm_locales', $locales ); |
|
| 1830 | 1830 | |
| 1831 | 1831 | return $locales; |
| 1832 | 1832 | } |
@@ -2,132 +2,132 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmFieldsController { |
| 4 | 4 | |
| 5 | - public static function load_field() { |
|
| 6 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 5 | + public static function load_field() { |
|
| 6 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 7 | 7 | |
| 8 | - $fields = $_POST['field']; |
|
| 9 | - if ( empty( $fields ) ) { |
|
| 10 | - wp_die(); |
|
| 11 | - } |
|
| 8 | + $fields = $_POST['field']; |
|
| 9 | + if ( empty( $fields ) ) { |
|
| 10 | + wp_die(); |
|
| 11 | + } |
|
| 12 | 12 | |
| 13 | - $_GET['page'] = 'formidable'; |
|
| 14 | - $fields = stripslashes_deep( $fields ); |
|
| 13 | + $_GET['page'] = 'formidable'; |
|
| 14 | + $fields = stripslashes_deep( $fields ); |
|
| 15 | 15 | |
| 16 | - $ajax = true; |
|
| 16 | + $ajax = true; |
|
| 17 | 17 | $values = array( 'id' => FrmAppHelper::get_post_param( 'form_id', '', 'absint' ) ); |
| 18 | - $path = FrmAppHelper::plugin_path(); |
|
| 19 | - $field_html = array(); |
|
| 20 | - |
|
| 21 | - foreach ( $fields as $field ) { |
|
| 22 | - $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 23 | - $field = json_decode( $field, true ); |
|
| 24 | - if ( ! isset( $field['id'] ) ) { |
|
| 25 | - // this field may have already been loaded |
|
| 26 | - continue; |
|
| 27 | - } |
|
| 18 | + $path = FrmAppHelper::plugin_path(); |
|
| 19 | + $field_html = array(); |
|
| 20 | + |
|
| 21 | + foreach ( $fields as $field ) { |
|
| 22 | + $field = htmlspecialchars_decode( nl2br( $field ) ); |
|
| 23 | + $field = json_decode( $field, true ); |
|
| 24 | + if ( ! isset( $field['id'] ) ) { |
|
| 25 | + // this field may have already been loaded |
|
| 26 | + continue; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - $field_id = absint( $field['id'] ); |
|
| 29 | + $field_id = absint( $field['id'] ); |
|
| 30 | 30 | |
| 31 | - if ( ! isset( $field['value'] ) ) { |
|
| 32 | - $field['value'] = ''; |
|
| 33 | - } |
|
| 31 | + if ( ! isset( $field['value'] ) ) { |
|
| 32 | + $field['value'] = ''; |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - $field_name = 'item_meta['. $field_id .']'; |
|
| 36 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 35 | + $field_name = 'item_meta['. $field_id .']'; |
|
| 36 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 37 | 37 | |
| 38 | - ob_start(); |
|
| 39 | - include($path .'/classes/views/frm-forms/add_field.php'); |
|
| 40 | - $field_html[ $field_id ] = ob_get_contents(); |
|
| 41 | - ob_end_clean(); |
|
| 42 | - } |
|
| 38 | + ob_start(); |
|
| 39 | + include($path .'/classes/views/frm-forms/add_field.php'); |
|
| 40 | + $field_html[ $field_id ] = ob_get_contents(); |
|
| 41 | + ob_end_clean(); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - unset($path); |
|
| 44 | + unset($path); |
|
| 45 | 45 | |
| 46 | - echo json_encode($field_html); |
|
| 46 | + echo json_encode($field_html); |
|
| 47 | 47 | |
| 48 | - wp_die(); |
|
| 49 | - } |
|
| 48 | + wp_die(); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - public static function create() { |
|
| 52 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 51 | + public static function create() { |
|
| 52 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 53 | 53 | |
| 54 | 54 | $field_type = FrmAppHelper::get_post_param( 'field', '', 'sanitize_text_field' ); |
| 55 | 55 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 56 | 56 | |
| 57 | - $field = self::include_new_field($field_type, $form_id); |
|
| 57 | + $field = self::include_new_field($field_type, $form_id); |
|
| 58 | 58 | |
| 59 | - // this hook will allow for multiple fields to be added at once |
|
| 60 | - do_action('frm_after_field_created', $field, $form_id); |
|
| 59 | + // this hook will allow for multiple fields to be added at once |
|
| 60 | + do_action('frm_after_field_created', $field, $form_id); |
|
| 61 | 61 | |
| 62 | - wp_die(); |
|
| 63 | - } |
|
| 62 | + wp_die(); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @param integer $form_id |
|
| 67 | - */ |
|
| 65 | + /** |
|
| 66 | + * @param integer $form_id |
|
| 67 | + */ |
|
| 68 | 68 | public static function include_new_field( $field_type, $form_id ) { |
| 69 | - $values = array(); |
|
| 70 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 71 | - $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 72 | - } |
|
| 69 | + $values = array(); |
|
| 70 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 71 | + $values['post_type'] = FrmProFormsHelper::post_type($form_id); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
| 75 | - $field_id = FrmField::create( $field_values ); |
|
| 74 | + $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id)); |
|
| 75 | + $field_id = FrmField::create( $field_values ); |
|
| 76 | 76 | |
| 77 | - if ( ! $field_id ) { |
|
| 78 | - return false; |
|
| 79 | - } |
|
| 77 | + if ( ! $field_id ) { |
|
| 78 | + return false; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - $field = self::include_single_field($field_id, $values, $form_id); |
|
| 81 | + $field = self::include_single_field($field_id, $values, $form_id); |
|
| 82 | 82 | |
| 83 | - return $field; |
|
| 84 | - } |
|
| 83 | + return $field; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - public static function update_form_id() { |
|
| 87 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 86 | + public static function update_form_id() { |
|
| 87 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 88 | 88 | |
| 89 | 89 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 90 | 90 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 91 | 91 | |
| 92 | - if ( ! $field_id || ! $form_id ) { |
|
| 93 | - wp_die(); |
|
| 94 | - } |
|
| 92 | + if ( ! $field_id || ! $form_id ) { |
|
| 93 | + wp_die(); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | $updated = FrmField::update( $field_id, compact( 'form_id' ) ); |
| 97 | 97 | echo absint( $updated ); |
| 98 | 98 | |
| 99 | - wp_die(); |
|
| 100 | - } |
|
| 99 | + wp_die(); |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | 102 | public static function edit_name( $field = 'name', $id = '' ) { |
| 103 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 103 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 104 | 104 | |
| 105 | - if ( empty($field) ) { |
|
| 106 | - $field = 'name'; |
|
| 107 | - } |
|
| 105 | + if ( empty($field) ) { |
|
| 106 | + $field = 'name'; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - if ( empty($id) ) { |
|
| 109 | + if ( empty($id) ) { |
|
| 110 | 110 | $id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 111 | 111 | $id = str_replace( 'field_label_', '', $id ); |
| 112 | - } |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | 114 | $value = FrmAppHelper::get_post_param( 'update_value', '', 'wp_kses_post' ); |
| 115 | 115 | $value = trim( $value ); |
| 116 | - if ( trim(strip_tags($value)) == '' ) { |
|
| 117 | - // set blank value if there is no content |
|
| 118 | - $value = ''; |
|
| 119 | - } |
|
| 116 | + if ( trim(strip_tags($value)) == '' ) { |
|
| 117 | + // set blank value if there is no content |
|
| 118 | + $value = ''; |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | FrmField::update( $id, array( $field => $value ) ); |
| 122 | 122 | |
| 123 | 123 | do_action( 'frm_after_update_field_' . $field, compact( 'id', 'value' ) ); |
| 124 | 124 | |
| 125 | 125 | echo stripslashes( wp_kses_post( $value ) ); |
| 126 | - wp_die(); |
|
| 127 | - } |
|
| 126 | + wp_die(); |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - public static function update_ajax_option() { |
|
| 130 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 129 | + public static function update_ajax_option() { |
|
| 130 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 131 | 131 | |
| 132 | 132 | $field_id = FrmAppHelper::get_post_param( 'field', 0, 'absint' ); |
| 133 | 133 | if ( ! $field_id ) { |
@@ -137,151 +137,151 @@ discard block |
||
| 137 | 137 | $field = FrmField::getOne( $field_id ); |
| 138 | 138 | |
| 139 | 139 | foreach ( array( 'clear_on_focus', 'separate_value', 'default_blank' ) as $val ) { |
| 140 | - if ( isset($_POST[ $val ]) ) { |
|
| 140 | + if ( isset($_POST[ $val ]) ) { |
|
| 141 | 141 | // all three of these options are boolean |
| 142 | 142 | $new_val = FrmAppHelper::get_post_param( $val, 0, 'absint' ); |
| 143 | 143 | |
| 144 | - if ( $val == 'separate_value' ) { |
|
| 144 | + if ( $val == 'separate_value' ) { |
|
| 145 | 145 | $new_val = FrmField::is_option_true( $field, $val ) ? 0 : 1; |
| 146 | - } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - $field->field_options[ $val ] = $new_val; |
|
| 149 | - unset($new_val); |
|
| 150 | - } |
|
| 151 | - unset($val); |
|
| 152 | - } |
|
| 148 | + $field->field_options[ $val ] = $new_val; |
|
| 149 | + unset($new_val); |
|
| 150 | + } |
|
| 151 | + unset($val); |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - FrmField::update( $field_id, array( |
|
| 155 | - 'field_options' => $field->field_options, |
|
| 154 | + FrmField::update( $field_id, array( |
|
| 155 | + 'field_options' => $field->field_options, |
|
| 156 | 156 | 'form_id' => $field->form_id, |
| 157 | - ) ); |
|
| 158 | - wp_die(); |
|
| 159 | - } |
|
| 157 | + ) ); |
|
| 158 | + wp_die(); |
|
| 159 | + } |
|
| 160 | 160 | |
| 161 | - public static function duplicate() { |
|
| 162 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 161 | + public static function duplicate() { |
|
| 162 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 163 | 163 | |
| 164 | - global $wpdb; |
|
| 164 | + global $wpdb; |
|
| 165 | 165 | |
| 166 | 166 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 167 | 167 | $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' ); |
| 168 | 168 | |
| 169 | 169 | $copy_field = FrmField::getOne( $field_id ); |
| 170 | - if ( ! $copy_field ) { |
|
| 171 | - wp_die(); |
|
| 172 | - } |
|
| 170 | + if ( ! $copy_field ) { |
|
| 171 | + wp_die(); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - do_action('frm_duplicate_field', $copy_field, $form_id); |
|
| 175 | - do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id); |
|
| 174 | + do_action('frm_duplicate_field', $copy_field, $form_id); |
|
| 175 | + do_action('frm_duplicate_field_'. $copy_field->type, $copy_field, $form_id); |
|
| 176 | 176 | |
| 177 | - $values = array( 'id' => $form_id ); |
|
| 178 | - FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 177 | + $values = array( 'id' => $form_id ); |
|
| 178 | + FrmFieldsHelper::fill_field( $values, $copy_field, $form_id ); |
|
| 179 | 179 | |
| 180 | 180 | $field_count = FrmDb::get_count( $wpdb->prefix .'frm_fields fi LEFT JOIN '. $wpdb->prefix .'frm_forms fr ON (fi.form_id = fr.id)', array( 'or' => 1, 'fr.id' => $form_id, 'fr.parent_form_id' => $form_id ) ); |
| 181 | 181 | |
| 182 | - $values['field_order'] = $field_count + 1; |
|
| 182 | + $values['field_order'] = $field_count + 1; |
|
| 183 | 183 | |
| 184 | - if ( ! $field_id = FrmField::create($values) ) { |
|
| 185 | - wp_die(); |
|
| 186 | - } |
|
| 184 | + if ( ! $field_id = FrmField::create($values) ) { |
|
| 185 | + wp_die(); |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - self::include_single_field($field_id, $values); |
|
| 188 | + self::include_single_field($field_id, $values); |
|
| 189 | 189 | |
| 190 | - wp_die(); |
|
| 191 | - } |
|
| 190 | + wp_die(); |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - /** |
|
| 194 | - * Load a single field in the form builder along with all needed variables |
|
| 195 | - */ |
|
| 196 | - public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 197 | - $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 198 | - $field_name = 'item_meta['. $field_id .']'; |
|
| 199 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 200 | - $id = $form_id ? $form_id : $field['form_id']; |
|
| 201 | - if ( $field['type'] == 'html' ) { |
|
| 202 | - $field['stop_filter'] = true; |
|
| 203 | - } |
|
| 193 | + /** |
|
| 194 | + * Load a single field in the form builder along with all needed variables |
|
| 195 | + */ |
|
| 196 | + public static function include_single_field( $field_id, $values, $form_id = 0 ) { |
|
| 197 | + $field = FrmFieldsHelper::setup_edit_vars(FrmField::getOne($field_id)); |
|
| 198 | + $field_name = 'item_meta['. $field_id .']'; |
|
| 199 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 200 | + $id = $form_id ? $form_id : $field['form_id']; |
|
| 201 | + if ( $field['type'] == 'html' ) { |
|
| 202 | + $field['stop_filter'] = true; |
|
| 203 | + } |
|
| 204 | 204 | |
| 205 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php'); |
|
| 205 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php'); |
|
| 206 | 206 | |
| 207 | - return $field; |
|
| 208 | - } |
|
| 207 | + return $field; |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - public static function destroy() { |
|
| 211 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 210 | + public static function destroy() { |
|
| 211 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 212 | 212 | |
| 213 | 213 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 214 | 214 | FrmField::destroy( $field_id ); |
| 215 | - wp_die(); |
|
| 216 | - } |
|
| 215 | + wp_die(); |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - /* Field Options */ |
|
| 218 | + /* Field Options */ |
|
| 219 | 219 | |
| 220 | - //Add Single Option or Other Option |
|
| 221 | - public static function add_option() { |
|
| 222 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 220 | + //Add Single Option or Other Option |
|
| 221 | + public static function add_option() { |
|
| 222 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 223 | 223 | |
| 224 | 224 | $id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 225 | 225 | $opt_type = FrmAppHelper::get_post_param( 'opt_type', '', 'sanitize_text_field' ); |
| 226 | 226 | |
| 227 | - //Get the field |
|
| 228 | - $field = FrmField::getOne($id); |
|
| 227 | + //Get the field |
|
| 228 | + $field = FrmField::getOne($id); |
|
| 229 | 229 | |
| 230 | 230 | if ( ! empty( $field->options ) ) { |
| 231 | 231 | $keys = array_keys( $field->options ); |
| 232 | - $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 233 | - } else { |
|
| 234 | - $last = 0; |
|
| 235 | - } |
|
| 236 | - $opt_key = $last + 1; |
|
| 232 | + $last = str_replace( 'other_', '', end( $keys ) ); |
|
| 233 | + } else { |
|
| 234 | + $last = 0; |
|
| 235 | + } |
|
| 236 | + $opt_key = $last + 1; |
|
| 237 | 237 | |
| 238 | - if ( 'other' == $opt_type ) { |
|
| 238 | + if ( 'other' == $opt_type ) { |
|
| 239 | 239 | $opt = esc_html__( 'Other', 'formidable' ); |
| 240 | - $other_val = ''; |
|
| 241 | - $opt_key = 'other_' . $opt_key; |
|
| 242 | - |
|
| 243 | - //Update value of "other" in DB |
|
| 244 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 245 | - $field_options['other'] = 1; |
|
| 246 | - FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 247 | - } else { |
|
| 240 | + $other_val = ''; |
|
| 241 | + $opt_key = 'other_' . $opt_key; |
|
| 242 | + |
|
| 243 | + //Update value of "other" in DB |
|
| 244 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 245 | + $field_options['other'] = 1; |
|
| 246 | + FrmField::update( $id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
|
| 247 | + } else { |
|
| 248 | 248 | $first_opt = reset( $field->options ); |
| 249 | 249 | $next_opt = count( $field->options ); |
| 250 | - if ( $first_opt != '' ) { |
|
| 251 | - $next_opt++; |
|
| 252 | - } |
|
| 253 | - $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt; |
|
| 254 | - unset($next_opt); |
|
| 255 | - } |
|
| 256 | - $field_val = $opt; |
|
| 250 | + if ( $first_opt != '' ) { |
|
| 251 | + $next_opt++; |
|
| 252 | + } |
|
| 253 | + $opt = esc_html__( 'Option', 'formidable' ) .' '. $next_opt; |
|
| 254 | + unset($next_opt); |
|
| 255 | + } |
|
| 256 | + $field_val = $opt; |
|
| 257 | 257 | $field->options[ $opt_key ] = $opt; |
| 258 | 258 | |
| 259 | - //Update options in DB |
|
| 259 | + //Update options in DB |
|
| 260 | 260 | FrmField::update( $id, array( 'options' => $field->options ) ); |
| 261 | 261 | |
| 262 | - $field_data = $field; |
|
| 263 | - $field = array( |
|
| 264 | - 'type' => $field_data->type, |
|
| 265 | - 'id' => $id, |
|
| 266 | - 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 267 | - 'form_id' => $field_data->form_id, |
|
| 268 | - 'field_key' => $field_data->field_key, |
|
| 269 | - ); |
|
| 270 | - |
|
| 271 | - $field_name = 'item_meta['. $id .']'; |
|
| 272 | - $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 273 | - $checked = ''; |
|
| 274 | - |
|
| 275 | - if ( 'other' == $opt_type ) { |
|
| 276 | - require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php'); |
|
| 277 | - } else { |
|
| 278 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php'); |
|
| 279 | - } |
|
| 280 | - wp_die(); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - public static function edit_option() { |
|
| 284 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 262 | + $field_data = $field; |
|
| 263 | + $field = array( |
|
| 264 | + 'type' => $field_data->type, |
|
| 265 | + 'id' => $id, |
|
| 266 | + 'separate_value' => isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0, |
|
| 267 | + 'form_id' => $field_data->form_id, |
|
| 268 | + 'field_key' => $field_data->field_key, |
|
| 269 | + ); |
|
| 270 | + |
|
| 271 | + $field_name = 'item_meta['. $id .']'; |
|
| 272 | + $html_id = FrmFieldsHelper::get_html_id($field); |
|
| 273 | + $checked = ''; |
|
| 274 | + |
|
| 275 | + if ( 'other' == $opt_type ) { |
|
| 276 | + require(FrmAppHelper::plugin_path() .'/pro/classes/views/frmpro-fields/other-option.php'); |
|
| 277 | + } else { |
|
| 278 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php'); |
|
| 279 | + } |
|
| 280 | + wp_die(); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + public static function edit_option() { |
|
| 284 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 285 | 285 | |
| 286 | 286 | $element_id = FrmAppHelper::get_post_param( 'element_id', '', 'sanitize_title' ); |
| 287 | 287 | $ids = explode( '-', $element_id ); |
@@ -289,42 +289,42 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | $orig_update_value = $update_value = trim( FrmAppHelper::get_post_param( 'update_value' ) ); |
| 291 | 291 | if ( strpos( $element_id, 'key_' ) ) { |
| 292 | - $new_value = $update_value; |
|
| 293 | - } else { |
|
| 294 | - $new_label = $update_value; |
|
| 295 | - } |
|
| 292 | + $new_value = $update_value; |
|
| 293 | + } else { |
|
| 294 | + $new_label = $update_value; |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | - $field = FrmField::getOne($id); |
|
| 298 | - $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 297 | + $field = FrmField::getOne($id); |
|
| 298 | + $separate_values = FrmField::is_option_true( $field, 'separate_value' ); |
|
| 299 | 299 | |
| 300 | - $this_opt_id = end($ids); |
|
| 300 | + $this_opt_id = end($ids); |
|
| 301 | 301 | $this_opt = (array) $field->options[ $this_opt_id ]; |
| 302 | - $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ? true : false ); |
|
| 302 | + $other_opt = ( $this_opt_id && strpos( $this_opt_id, 'other') !== false ? true : false ); |
|
| 303 | 303 | |
| 304 | - $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 305 | - $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 304 | + $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt); |
|
| 305 | + $value = isset($this_opt['value']) ? $this_opt['value'] : ''; |
|
| 306 | 306 | |
| 307 | - if ( ! isset( $new_label ) ) { |
|
| 308 | - $new_label = $label; |
|
| 309 | - } |
|
| 307 | + if ( ! isset( $new_label ) ) { |
|
| 308 | + $new_label = $label; |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | - if ( isset($new_value) || isset($value) ) { |
|
| 312 | - $update_value = isset($new_value) ? $new_value : $value; |
|
| 313 | - } |
|
| 311 | + if ( isset($new_value) || isset($value) ) { |
|
| 312 | + $update_value = isset($new_value) ? $new_value : $value; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | 315 | if ( $update_value != $new_label && $other_opt === false && $separate_values ) { |
| 316 | 316 | $field->options[ $this_opt_id ] = array( 'value' => $update_value, 'label' => $new_label ); |
| 317 | - } else { |
|
| 317 | + } else { |
|
| 318 | 318 | $field->options[ $this_opt_id ] = $orig_update_value; |
| 319 | - } |
|
| 319 | + } |
|
| 320 | 320 | |
| 321 | 321 | FrmField::update( $field->id, array( 'options' => $field->options ) ); |
| 322 | 322 | echo ( $orig_update_value == '' ) ? esc_html__( '(Blank)', 'formidable' ) : stripslashes( $orig_update_value ); |
| 323 | - wp_die(); |
|
| 324 | - } |
|
| 323 | + wp_die(); |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | - public static function delete_option() { |
|
| 327 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 326 | + public static function delete_option() { |
|
| 327 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 328 | 328 | |
| 329 | 329 | $field_id = FrmAppHelper::get_post_param( 'field_id', 0, 'absint' ); |
| 330 | 330 | $field = FrmField::getOne( $field_id ); |
@@ -332,339 +332,339 @@ discard block |
||
| 332 | 332 | $opt_key = FrmAppHelper::get_post_param( 'opt_key', 0, 'sanitize_title' ); |
| 333 | 333 | |
| 334 | 334 | $options = $field->options; |
| 335 | - unset( $options[ $opt_key ] ); |
|
| 336 | - $response = array( 'other' => true ); |
|
| 335 | + unset( $options[ $opt_key ] ); |
|
| 336 | + $response = array( 'other' => true ); |
|
| 337 | 337 | |
| 338 | - //If the deleted option is an "other" option |
|
| 338 | + //If the deleted option is an "other" option |
|
| 339 | 339 | if ( FrmFieldsHelper::is_other_opt( $opt_key ) ) { |
| 340 | - //Assume all other options are gone, unless proven otherwise |
|
| 341 | - $other = false; |
|
| 340 | + //Assume all other options are gone, unless proven otherwise |
|
| 341 | + $other = false; |
|
| 342 | 342 | |
| 343 | - //Check if all other options are really gone |
|
| 344 | - foreach ( $options as $o_key => $o_val ) { |
|
| 345 | - //If there is still an other option in the field, set other to true |
|
| 343 | + //Check if all other options are really gone |
|
| 344 | + foreach ( $options as $o_key => $o_val ) { |
|
| 345 | + //If there is still an other option in the field, set other to true |
|
| 346 | 346 | if ( FrmFieldsHelper::is_other_opt( $o_key ) ) { |
| 347 | - $other = true; |
|
| 348 | - break; |
|
| 349 | - } |
|
| 350 | - unset( $o_key, $o_val ); |
|
| 351 | - } |
|
| 352 | - |
|
| 353 | - //If all other options are gone |
|
| 354 | - if ( false === $other ) { |
|
| 355 | - $field_options = maybe_unserialize( $field->field_options ); |
|
| 356 | - $field_options['other'] = 0; |
|
| 347 | + $other = true; |
|
| 348 | + break; |
|
| 349 | + } |
|
| 350 | + unset( $o_key, $o_val ); |
|
| 351 | + } |
|
| 352 | + |
|
| 353 | + //If all other options are gone |
|
| 354 | + if ( false === $other ) { |
|
| 355 | + $field_options = maybe_unserialize( $field->field_options ); |
|
| 356 | + $field_options['other'] = 0; |
|
| 357 | 357 | FrmField::update( $field_id, array( 'field_options' => maybe_serialize( $field_options ) ) ); |
| 358 | - $response = array( 'other' => false ); |
|
| 359 | - } |
|
| 360 | - } |
|
| 361 | - echo json_encode( $response ); |
|
| 358 | + $response = array( 'other' => false ); |
|
| 359 | + } |
|
| 360 | + } |
|
| 361 | + echo json_encode( $response ); |
|
| 362 | 362 | |
| 363 | 363 | FrmField::update( $field_id, array( 'options' => maybe_serialize( $options ) ) ); |
| 364 | 364 | |
| 365 | - wp_die(); |
|
| 366 | - } |
|
| 365 | + wp_die(); |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - public static function import_choices() { |
|
| 369 | - if ( ! current_user_can( 'frm_edit_forms' ) ) { |
|
| 370 | - wp_die(); |
|
| 371 | - } |
|
| 368 | + public static function import_choices() { |
|
| 369 | + if ( ! current_user_can( 'frm_edit_forms' ) ) { |
|
| 370 | + wp_die(); |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | 373 | $field_id = absint( $_REQUEST['field_id'] ); |
| 374 | 374 | |
| 375 | - global $current_screen, $hook_suffix; |
|
| 375 | + global $current_screen, $hook_suffix; |
|
| 376 | 376 | |
| 377 | - // Catch plugins that include admin-header.php before admin.php completes. |
|
| 378 | - if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 379 | - $hook_suffix = ''; |
|
| 380 | - set_current_screen(); |
|
| 381 | - } |
|
| 377 | + // Catch plugins that include admin-header.php before admin.php completes. |
|
| 378 | + if ( empty( $current_screen ) && function_exists( 'set_current_screen' ) ) { |
|
| 379 | + $hook_suffix = ''; |
|
| 380 | + set_current_screen(); |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 384 | - register_admin_color_schemes(); |
|
| 385 | - } |
|
| 383 | + if ( function_exists( 'register_admin_color_schemes' ) ) { |
|
| 384 | + register_admin_color_schemes(); |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | - $hook_suffix = $admin_body_class = ''; |
|
| 387 | + $hook_suffix = $admin_body_class = ''; |
|
| 388 | 388 | |
| 389 | - if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 390 | - $admin_body_class .= ' folded'; |
|
| 391 | - } |
|
| 389 | + if ( get_user_setting( 'mfold' ) == 'f' ) { |
|
| 390 | + $admin_body_class .= ' folded'; |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | - if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 394 | - $admin_body_class .= ' admin-bar'; |
|
| 395 | - } |
|
| 393 | + if ( function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() ) { |
|
| 394 | + $admin_body_class .= ' admin-bar'; |
|
| 395 | + } |
|
| 396 | 396 | |
| 397 | - if ( is_rtl() ) { |
|
| 398 | - $admin_body_class .= ' rtl'; |
|
| 399 | - } |
|
| 397 | + if ( is_rtl() ) { |
|
| 398 | + $admin_body_class .= ' rtl'; |
|
| 399 | + } |
|
| 400 | 400 | |
| 401 | - $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 402 | - $prepop = array(); |
|
| 403 | - FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 401 | + $admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' ); |
|
| 402 | + $prepop = array(); |
|
| 403 | + FrmFieldsHelper::get_bulk_prefilled_opts($prepop); |
|
| 404 | 404 | |
| 405 | - $field = FrmField::getOne($field_id); |
|
| 405 | + $field = FrmField::getOne($field_id); |
|
| 406 | 406 | |
| 407 | - wp_enqueue_script( 'utils' ); |
|
| 408 | - wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' ); |
|
| 409 | - FrmAppHelper::load_admin_wide_js(); |
|
| 407 | + wp_enqueue_script( 'utils' ); |
|
| 408 | + wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css' ); |
|
| 409 | + FrmAppHelper::load_admin_wide_js(); |
|
| 410 | 410 | |
| 411 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php'); |
|
| 412 | - wp_die(); |
|
| 413 | - } |
|
| 411 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php'); |
|
| 412 | + wp_die(); |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | - public static function import_options() { |
|
| 416 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 415 | + public static function import_options() { |
|
| 416 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 417 | 417 | |
| 418 | - if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 419 | - return; |
|
| 420 | - } |
|
| 418 | + if ( ! is_admin() || ! current_user_can('frm_edit_forms') ) { |
|
| 419 | + return; |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | 422 | $field_id = absint( $_POST['field_id'] ); |
| 423 | - $field = FrmField::getOne($field_id); |
|
| 423 | + $field = FrmField::getOne($field_id); |
|
| 424 | 424 | |
| 425 | 425 | if ( ! in_array( $field->type, array( 'radio', 'checkbox', 'select' ) ) ) { |
| 426 | - return; |
|
| 427 | - } |
|
| 428 | - |
|
| 429 | - $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 430 | - $opts = stripslashes_deep($_POST['opts']); |
|
| 431 | - $opts = explode("\n", rtrim($opts, "\n")); |
|
| 432 | - if ( $field['separate_value'] ) { |
|
| 433 | - foreach ( $opts as $opt_key => $opt ) { |
|
| 434 | - if ( strpos($opt, '|') !== false ) { |
|
| 435 | - $vals = explode('|', $opt); |
|
| 436 | - if ( $vals[0] != $vals[1] ) { |
|
| 437 | - $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 438 | - } |
|
| 439 | - unset($vals); |
|
| 440 | - } |
|
| 441 | - unset($opt_key, $opt); |
|
| 442 | - } |
|
| 443 | - } |
|
| 444 | - |
|
| 445 | - //Keep other options after bulk update |
|
| 446 | - if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 447 | - $other_array = array(); |
|
| 448 | - foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 449 | - if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 450 | - $other_array[ $opt_key ] = $opt; |
|
| 451 | - } |
|
| 452 | - unset($opt_key, $opt); |
|
| 453 | - } |
|
| 454 | - if ( ! empty($other_array) ) { |
|
| 455 | - $opts = array_merge( $opts, $other_array); |
|
| 456 | - } |
|
| 457 | - } |
|
| 458 | - |
|
| 459 | - FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 460 | - |
|
| 461 | - $field['options'] = $opts; |
|
| 462 | - $field_name = $field['name']; |
|
| 463 | - |
|
| 464 | - // Get html_id which will be used in single-option.php |
|
| 465 | - $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 466 | - |
|
| 467 | - if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 468 | - require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php'); |
|
| 469 | - } else { |
|
| 470 | - FrmFieldsHelper::show_single_option($field); |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - wp_die(); |
|
| 474 | - } |
|
| 475 | - |
|
| 476 | - public static function update_order() { |
|
| 477 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 426 | + return; |
|
| 427 | + } |
|
| 428 | + |
|
| 429 | + $field = FrmFieldsHelper::setup_edit_vars($field); |
|
| 430 | + $opts = stripslashes_deep($_POST['opts']); |
|
| 431 | + $opts = explode("\n", rtrim($opts, "\n")); |
|
| 432 | + if ( $field['separate_value'] ) { |
|
| 433 | + foreach ( $opts as $opt_key => $opt ) { |
|
| 434 | + if ( strpos($opt, '|') !== false ) { |
|
| 435 | + $vals = explode('|', $opt); |
|
| 436 | + if ( $vals[0] != $vals[1] ) { |
|
| 437 | + $opts[ $opt_key ] = array( 'label' => trim( $vals[0] ), 'value' => trim( $vals[1] ) ); |
|
| 438 | + } |
|
| 439 | + unset($vals); |
|
| 440 | + } |
|
| 441 | + unset($opt_key, $opt); |
|
| 442 | + } |
|
| 443 | + } |
|
| 444 | + |
|
| 445 | + //Keep other options after bulk update |
|
| 446 | + if ( isset( $field['field_options']['other'] ) && $field['field_options']['other'] == true ) { |
|
| 447 | + $other_array = array(); |
|
| 448 | + foreach ( $field['options'] as $opt_key => $opt ) { |
|
| 449 | + if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) { |
|
| 450 | + $other_array[ $opt_key ] = $opt; |
|
| 451 | + } |
|
| 452 | + unset($opt_key, $opt); |
|
| 453 | + } |
|
| 454 | + if ( ! empty($other_array) ) { |
|
| 455 | + $opts = array_merge( $opts, $other_array); |
|
| 456 | + } |
|
| 457 | + } |
|
| 458 | + |
|
| 459 | + FrmField::update( $field_id, array( 'options' => maybe_serialize( $opts ) ) ); |
|
| 460 | + |
|
| 461 | + $field['options'] = $opts; |
|
| 462 | + $field_name = $field['name']; |
|
| 463 | + |
|
| 464 | + // Get html_id which will be used in single-option.php |
|
| 465 | + $html_id = FrmFieldsHelper::get_html_id( $field ); |
|
| 466 | + |
|
| 467 | + if ( $field['type'] == 'radio' || $field['type'] == 'checkbox' ) { |
|
| 468 | + require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php'); |
|
| 469 | + } else { |
|
| 470 | + FrmFieldsHelper::show_single_option($field); |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + wp_die(); |
|
| 474 | + } |
|
| 475 | + |
|
| 476 | + public static function update_order() { |
|
| 477 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 478 | 478 | $fields = FrmAppHelper::get_post_param( 'frm_field_id' ); |
| 479 | 479 | foreach ( (array) $fields as $position => $item ) { |
| 480 | 480 | FrmField::update( absint( $item ), array( 'field_order' => absint( $position ) ) ); |
| 481 | 481 | } |
| 482 | - wp_die(); |
|
| 483 | - } |
|
| 482 | + wp_die(); |
|
| 483 | + } |
|
| 484 | 484 | |
| 485 | 485 | public static function change_type( $type ) { |
| 486 | - $type_switch = array( |
|
| 487 | - 'scale' => 'radio', |
|
| 488 | - '10radio' => 'radio', |
|
| 489 | - 'rte' => 'textarea', |
|
| 490 | - 'website' => 'url', |
|
| 491 | - ); |
|
| 492 | - if ( isset( $type_switch[ $type ] ) ) { |
|
| 493 | - $type = $type_switch[ $type ]; |
|
| 494 | - } |
|
| 486 | + $type_switch = array( |
|
| 487 | + 'scale' => 'radio', |
|
| 488 | + '10radio' => 'radio', |
|
| 489 | + 'rte' => 'textarea', |
|
| 490 | + 'website' => 'url', |
|
| 491 | + ); |
|
| 492 | + if ( isset( $type_switch[ $type ] ) ) { |
|
| 493 | + $type = $type_switch[ $type ]; |
|
| 494 | + } |
|
| 495 | 495 | |
| 496 | 496 | $frm_field_selection = FrmField::field_selection(); |
| 497 | - $types = array_keys($frm_field_selection); |
|
| 498 | - if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 499 | - $type = 'text'; |
|
| 500 | - } |
|
| 497 | + $types = array_keys($frm_field_selection); |
|
| 498 | + if ( ! in_array($type, $types) && $type != 'captcha' ) { |
|
| 499 | + $type = 'text'; |
|
| 500 | + } |
|
| 501 | 501 | |
| 502 | - return $type; |
|
| 503 | - } |
|
| 502 | + return $type; |
|
| 503 | + } |
|
| 504 | 504 | |
| 505 | 505 | public static function display_field_options( $display ) { |
| 506 | 506 | switch ( $display['type'] ) { |
| 507 | - case 'captcha': |
|
| 508 | - $display['required'] = false; |
|
| 509 | - $display['invalid'] = true; |
|
| 510 | - $display['default_blank'] = false; |
|
| 507 | + case 'captcha': |
|
| 508 | + $display['required'] = false; |
|
| 509 | + $display['invalid'] = true; |
|
| 510 | + $display['default_blank'] = false; |
|
| 511 | 511 | $display['captcha_size'] = true; |
| 512 | - break; |
|
| 513 | - case 'radio': |
|
| 514 | - $display['default_blank'] = false; |
|
| 515 | - break; |
|
| 516 | - case 'text': |
|
| 517 | - case 'textarea': |
|
| 518 | - $display['size'] = true; |
|
| 519 | - $display['clear_on_focus'] = true; |
|
| 520 | - break; |
|
| 521 | - case 'select': |
|
| 522 | - $display['size'] = true; |
|
| 523 | - break; |
|
| 524 | - case 'url': |
|
| 525 | - case 'website': |
|
| 526 | - case 'email': |
|
| 527 | - $display['size'] = true; |
|
| 528 | - $display['clear_on_focus'] = true; |
|
| 529 | - $display['invalid'] = true; |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - return $display; |
|
| 533 | - } |
|
| 534 | - |
|
| 535 | - public static function input_html( $field, $echo = true ) { |
|
| 536 | - $class = array(); //$field['type']; |
|
| 537 | - self::add_input_classes($field, $class); |
|
| 538 | - |
|
| 539 | - $add_html = array(); |
|
| 540 | - self::add_html_size($field, $add_html); |
|
| 541 | - self::add_html_length($field, $add_html); |
|
| 542 | - self::add_html_placeholder($field, $add_html, $class); |
|
| 512 | + break; |
|
| 513 | + case 'radio': |
|
| 514 | + $display['default_blank'] = false; |
|
| 515 | + break; |
|
| 516 | + case 'text': |
|
| 517 | + case 'textarea': |
|
| 518 | + $display['size'] = true; |
|
| 519 | + $display['clear_on_focus'] = true; |
|
| 520 | + break; |
|
| 521 | + case 'select': |
|
| 522 | + $display['size'] = true; |
|
| 523 | + break; |
|
| 524 | + case 'url': |
|
| 525 | + case 'website': |
|
| 526 | + case 'email': |
|
| 527 | + $display['size'] = true; |
|
| 528 | + $display['clear_on_focus'] = true; |
|
| 529 | + $display['invalid'] = true; |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + return $display; |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + public static function input_html( $field, $echo = true ) { |
|
| 536 | + $class = array(); //$field['type']; |
|
| 537 | + self::add_input_classes($field, $class); |
|
| 538 | + |
|
| 539 | + $add_html = array(); |
|
| 540 | + self::add_html_size($field, $add_html); |
|
| 541 | + self::add_html_length($field, $add_html); |
|
| 542 | + self::add_html_placeholder($field, $add_html, $class); |
|
| 543 | 543 | //self::add_validation_messages( $field, $add_html ); uncomment this when the js validation is complete |
| 544 | 544 | |
| 545 | - $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 545 | + $class = apply_filters('frm_field_classes', implode(' ', $class), $field); |
|
| 546 | 546 | |
| 547 | 547 | FrmFormsHelper::add_html_attr( $class, 'class', $add_html ); |
| 548 | 548 | |
| 549 | - self::add_shortcodes_to_html($field, $add_html); |
|
| 549 | + self::add_shortcodes_to_html($field, $add_html); |
|
| 550 | 550 | |
| 551 | 551 | $add_html = apply_filters( 'frm_field_extra_html', $add_html, $field ); |
| 552 | 552 | $add_html = ' ' . implode( ' ', $add_html ) . ' '; |
| 553 | 553 | |
| 554 | - if ( $echo ) { |
|
| 555 | - echo $add_html; |
|
| 556 | - } |
|
| 554 | + if ( $echo ) { |
|
| 555 | + echo $add_html; |
|
| 556 | + } |
|
| 557 | 557 | |
| 558 | - return $add_html; |
|
| 559 | - } |
|
| 558 | + return $add_html; |
|
| 559 | + } |
|
| 560 | 560 | |
| 561 | 561 | private static function add_input_classes( $field, array &$class ) { |
| 562 | - if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 563 | - $class[] = $field['input_class']; |
|
| 564 | - } |
|
| 562 | + if ( isset($field['input_class']) && ! empty($field['input_class']) ) { |
|
| 563 | + $class[] = $field['input_class']; |
|
| 564 | + } |
|
| 565 | 565 | |
| 566 | - if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 567 | - return; |
|
| 568 | - } |
|
| 566 | + if ( $field['type'] == 'hidden' || $field['type'] == 'user_id' ) { |
|
| 567 | + return; |
|
| 568 | + } |
|
| 569 | 569 | |
| 570 | - global $frm_vars; |
|
| 570 | + global $frm_vars; |
|
| 571 | 571 | if ( is_admin() && ! FrmAppHelper::is_preview_page() && ! in_array( $field['type'], array( 'scale', 'radio', 'checkbox', 'data' ) ) ) { |
| 572 | - $class[] = 'dyn_default_value'; |
|
| 573 | - } |
|
| 572 | + $class[] = 'dyn_default_value'; |
|
| 573 | + } |
|
| 574 | 574 | |
| 575 | - if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 576 | - $class[] = 'auto_width'; |
|
| 577 | - } |
|
| 578 | - } |
|
| 575 | + if ( isset($field['size']) && $field['size'] > 0 ) { |
|
| 576 | + $class[] = 'auto_width'; |
|
| 577 | + } |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | 580 | private static function add_html_size( $field, array &$add_html ) { |
| 581 | 581 | if ( ! isset( $field['size'] ) || $field['size'] <= 0 || in_array( $field['type'], array( 'select', 'data', 'time', 'hidden' ) ) ) { |
| 582 | - return; |
|
| 583 | - } |
|
| 582 | + return; |
|
| 583 | + } |
|
| 584 | 584 | |
| 585 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 586 | - return; |
|
| 587 | - } |
|
| 585 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 586 | + return; |
|
| 587 | + } |
|
| 588 | 588 | |
| 589 | - if ( is_numeric($field['size']) ) { |
|
| 590 | - $field['size'] .= 'px'; |
|
| 591 | - } |
|
| 589 | + if ( is_numeric($field['size']) ) { |
|
| 590 | + $field['size'] .= 'px'; |
|
| 591 | + } |
|
| 592 | 592 | |
| 593 | - $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 594 | - // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 595 | - $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"'; |
|
| 593 | + $important = apply_filters('frm_use_important_width', 1, $field); |
|
| 594 | + // Note: This inline styling must stay since we cannot realistically set a class for every possible field size |
|
| 595 | + $add_html['style'] = 'style="width:'. esc_attr( $field['size'] ) . ( $important ? ' !important' : '' ) .'"'; |
|
| 596 | 596 | |
| 597 | - self::add_html_cols($field, $add_html); |
|
| 598 | - } |
|
| 597 | + self::add_html_cols($field, $add_html); |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | 600 | private static function add_html_cols( $field, array &$add_html ) { |
| 601 | 601 | if ( ! in_array( $field['type'], array( 'textarea', 'rte' ) ) ) { |
| 602 | - return; |
|
| 603 | - } |
|
| 602 | + return; |
|
| 603 | + } |
|
| 604 | 604 | |
| 605 | - // convert to cols for textareas |
|
| 606 | - $calc = array( |
|
| 607 | - '' => 9, |
|
| 608 | - 'px' => 9, |
|
| 609 | - 'rem' => 0.444, |
|
| 610 | - 'em' => 0.544, |
|
| 611 | - ); |
|
| 605 | + // convert to cols for textareas |
|
| 606 | + $calc = array( |
|
| 607 | + '' => 9, |
|
| 608 | + 'px' => 9, |
|
| 609 | + 'rem' => 0.444, |
|
| 610 | + 'em' => 0.544, |
|
| 611 | + ); |
|
| 612 | 612 | |
| 613 | - // include "col" for valid html |
|
| 614 | - $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 613 | + // include "col" for valid html |
|
| 614 | + $unit = trim(preg_replace('/[0-9]+/', '', $field['size'])); |
|
| 615 | 615 | |
| 616 | - if ( ! isset( $calc[ $unit ] ) ) { |
|
| 617 | - return; |
|
| 618 | - } |
|
| 616 | + if ( ! isset( $calc[ $unit ] ) ) { |
|
| 617 | + return; |
|
| 618 | + } |
|
| 619 | 619 | |
| 620 | - $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 620 | + $size = (float) str_replace( $unit, '', $field['size'] ) / $calc[ $unit ]; |
|
| 621 | 621 | |
| 622 | 622 | $add_html['cols'] = 'cols="' . absint( $size ) . '"'; |
| 623 | - } |
|
| 623 | + } |
|
| 624 | 624 | |
| 625 | 625 | private static function add_html_length( $field, array &$add_html ) { |
| 626 | - // check for max setting and if this field accepts maxlength |
|
| 626 | + // check for max setting and if this field accepts maxlength |
|
| 627 | 627 | if ( FrmField::is_option_empty( $field, 'max' ) || in_array( $field['type'], array( 'textarea', 'rte', 'hidden' ) ) ) { |
| 628 | - return; |
|
| 629 | - } |
|
| 628 | + return; |
|
| 629 | + } |
|
| 630 | 630 | |
| 631 | - if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 632 | - // don't load on form builder page |
|
| 633 | - return; |
|
| 634 | - } |
|
| 631 | + if ( FrmAppHelper::is_admin_page('formidable' ) ) { |
|
| 632 | + // don't load on form builder page |
|
| 633 | + return; |
|
| 634 | + } |
|
| 635 | 635 | |
| 636 | 636 | $add_html['maxlength'] = 'maxlength="' . esc_attr( $field['max'] ) . '"'; |
| 637 | - } |
|
| 637 | + } |
|
| 638 | 638 | |
| 639 | 639 | private static function add_html_placeholder( $field, array &$add_html, array &$class ) { |
| 640 | 640 | if ( empty( $field['default_value'] ) || FrmAppHelper::is_admin_page( 'formidable' ) ) { |
| 641 | 641 | return; |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | - if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 644 | + if ( ! FrmField::is_option_true( $field, 'clear_on_focus' ) ) { |
|
| 645 | 645 | if ( is_array( $field['default_value'] ) ) { |
| 646 | 646 | $field['default_value'] = json_encode( $field['default_value'] ); |
| 647 | 647 | } |
| 648 | 648 | $add_html['data-frmval'] = 'data-frmval="' . esc_attr( $field['default_value'] ) . '"'; |
| 649 | - return; |
|
| 650 | - } |
|
| 649 | + return; |
|
| 650 | + } |
|
| 651 | 651 | |
| 652 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 652 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 653 | 653 | |
| 654 | 654 | if ( $frm_settings->use_html && ! in_array( $field['type'], array( 'select', 'radio', 'checkbox', 'hidden' ) ) ) { |
| 655 | - // use HMTL5 placeholder with js fallback |
|
| 656 | - $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"'; |
|
| 657 | - wp_enqueue_script('jquery-placeholder'); |
|
| 658 | - } else if ( ! $frm_settings->use_html ) { |
|
| 655 | + // use HMTL5 placeholder with js fallback |
|
| 656 | + $add_html['placeholder'] = 'placeholder="'. esc_attr($field['default_value']) .'"'; |
|
| 657 | + wp_enqueue_script('jquery-placeholder'); |
|
| 658 | + } else if ( ! $frm_settings->use_html ) { |
|
| 659 | 659 | $val = str_replace( array( "\r\n", "\n" ), '\r', addslashes( str_replace( ''', "'", esc_attr( $field['default_value'] ) ) ) ); |
| 660 | - $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"'; |
|
| 661 | - $class[] = 'frm_toggle_default'; |
|
| 660 | + $add_html['data-frmval'] = 'data-frmval="'. esc_attr($val) .'"'; |
|
| 661 | + $class[] = 'frm_toggle_default'; |
|
| 662 | 662 | |
| 663 | - if ( $field['value'] == $field['default_value'] ) { |
|
| 664 | - $class[] = 'frm_default'; |
|
| 665 | - } |
|
| 666 | - } |
|
| 667 | - } |
|
| 663 | + if ( $field['value'] == $field['default_value'] ) { |
|
| 664 | + $class[] = 'frm_default'; |
|
| 665 | + } |
|
| 666 | + } |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | 669 | private static function add_validation_messages( $field, array &$add_html ) { |
| 670 | 670 | if ( FrmField::is_required( $field ) ) { |
@@ -685,44 +685,44 @@ discard block |
||
| 685 | 685 | } |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | - private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 689 | - if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 690 | - return; |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 694 | - if ( 'opt' === $k ) { |
|
| 695 | - continue; |
|
| 696 | - } |
|
| 697 | - |
|
| 698 | - if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 699 | - $add_html[] = $v; |
|
| 700 | - } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 701 | - $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] ); |
|
| 702 | - } else { |
|
| 688 | + private static function add_shortcodes_to_html( $field, array &$add_html ) { |
|
| 689 | + if ( FrmField::is_option_empty( $field, 'shortcodes' ) ) { |
|
| 690 | + return; |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + foreach ( $field['shortcodes'] as $k => $v ) { |
|
| 694 | + if ( 'opt' === $k ) { |
|
| 695 | + continue; |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + if ( is_numeric($k) && strpos($v, '=') ) { |
|
| 699 | + $add_html[] = $v; |
|
| 700 | + } else if ( ! empty( $k ) && isset( $add_html[ $k ] ) ) { |
|
| 701 | + $add_html[ $k ] = str_replace( $k .'="', $k .'="'. $v, $add_html[ $k ] ); |
|
| 702 | + } else { |
|
| 703 | 703 | $add_html[ $k ] = $k . '="' . esc_attr( $v ) . '"'; |
| 704 | - } |
|
| 705 | - |
|
| 706 | - unset($k, $v); |
|
| 707 | - } |
|
| 708 | - } |
|
| 709 | - |
|
| 710 | - public static function check_value( $opt, $opt_key, $field ) { |
|
| 711 | - if ( is_array( $opt ) ) { |
|
| 712 | - if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 713 | - $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 714 | - } else { |
|
| 715 | - $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 716 | - } |
|
| 717 | - } |
|
| 718 | - return $opt; |
|
| 719 | - } |
|
| 704 | + } |
|
| 705 | + |
|
| 706 | + unset($k, $v); |
|
| 707 | + } |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + public static function check_value( $opt, $opt_key, $field ) { |
|
| 711 | + if ( is_array( $opt ) ) { |
|
| 712 | + if ( FrmField::is_option_true( $field, 'separate_value' ) ) { |
|
| 713 | + $opt = isset( $opt['value'] ) ? $opt['value'] : ( isset( $opt['label'] ) ? $opt['label'] : reset( $opt ) ); |
|
| 714 | + } else { |
|
| 715 | + $opt = isset( $opt['label'] ) ? $opt['label'] : reset( $opt ); |
|
| 716 | + } |
|
| 717 | + } |
|
| 718 | + return $opt; |
|
| 719 | + } |
|
| 720 | 720 | |
| 721 | 721 | public static function check_label( $opt ) { |
| 722 | - if ( is_array($opt) ) { |
|
| 723 | - $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 724 | - } |
|
| 722 | + if ( is_array($opt) ) { |
|
| 723 | + $opt = (isset($opt['label']) ? $opt['label'] : reset($opt)); |
|
| 724 | + } |
|
| 725 | 725 | |
| 726 | - return $opt; |
|
| 727 | - } |
|
| 726 | + return $opt; |
|
| 727 | + } |
|
| 728 | 728 | } |
@@ -1,21 +1,21 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmStylesController { |
| 4 | - public static $post_type = 'frm_styles'; |
|
| 5 | - public static $screen = 'formidable_page_formidable-styles'; |
|
| 6 | - |
|
| 7 | - public static function load_pro_hooks() { |
|
| 8 | - if ( FrmAppHelper::pro_is_installed() ) { |
|
| 9 | - FrmProStylesController::load_pro_hooks(); |
|
| 10 | - } |
|
| 11 | - } |
|
| 12 | - |
|
| 13 | - public static function register_post_types() { |
|
| 14 | - register_post_type( self::$post_type, array( |
|
| 15 | - 'label' => __( 'Styles', 'formidable' ), |
|
| 16 | - 'public' => false, |
|
| 17 | - 'show_ui' => false, |
|
| 18 | - 'capability_type' => 'page', |
|
| 4 | + public static $post_type = 'frm_styles'; |
|
| 5 | + public static $screen = 'formidable_page_formidable-styles'; |
|
| 6 | + |
|
| 7 | + public static function load_pro_hooks() { |
|
| 8 | + if ( FrmAppHelper::pro_is_installed() ) { |
|
| 9 | + FrmProStylesController::load_pro_hooks(); |
|
| 10 | + } |
|
| 11 | + } |
|
| 12 | + |
|
| 13 | + public static function register_post_types() { |
|
| 14 | + register_post_type( self::$post_type, array( |
|
| 15 | + 'label' => __( 'Styles', 'formidable' ), |
|
| 16 | + 'public' => false, |
|
| 17 | + 'show_ui' => false, |
|
| 18 | + 'capability_type' => 'page', |
|
| 19 | 19 | 'capabilities' => array( |
| 20 | 20 | 'edit_post' => 'frm_change_settings', |
| 21 | 21 | 'edit_posts' => 'frm_change_settings', |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | 'delete_posts' => 'frm_change_settings', |
| 26 | 26 | 'read_private_posts' => 'read_private_posts', |
| 27 | 27 | ), |
| 28 | - 'supports' => array( |
|
| 28 | + 'supports' => array( |
|
| 29 | 29 | 'title', |
| 30 | - ), |
|
| 31 | - 'has_archive' => false, |
|
| 32 | - 'labels' => array( |
|
| 30 | + ), |
|
| 31 | + 'has_archive' => false, |
|
| 32 | + 'labels' => array( |
|
| 33 | 33 | 'name' => __( 'Styles', 'formidable' ), |
| 34 | 34 | 'singular_name' => __( 'Style', 'formidable' ), |
| 35 | 35 | 'menu_name' => __( 'Style', 'formidable' ), |
@@ -37,31 +37,31 @@ discard block |
||
| 37 | 37 | 'add_new_item' => __( 'Create a New Style', 'formidable' ), |
| 38 | 38 | 'edit_item' => __( 'Edit Style', 'formidable' ), |
| 39 | 39 | ), |
| 40 | - ) ); |
|
| 41 | - } |
|
| 40 | + ) ); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public static function menu() { |
|
| 44 | - add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route'); |
|
| 45 | - } |
|
| 43 | + public static function menu() { |
|
| 44 | + add_submenu_page('formidable', 'Formidable | '. __( 'Styles', 'formidable' ), __( 'Styles', 'formidable' ), 'frm_change_settings', 'formidable-styles', 'FrmStylesController::route'); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public static function admin_init() { |
|
| 48 | - if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
| 49 | - return; |
|
| 50 | - } |
|
| 47 | + public static function admin_init() { |
|
| 48 | + if ( ! FrmAppHelper::is_admin_page('formidable-styles') ) { |
|
| 49 | + return; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - self::load_pro_hooks(); |
|
| 53 | - wp_enqueue_script('jquery-ui-datepicker'); |
|
| 52 | + self::load_pro_hooks(); |
|
| 53 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
| 54 | 54 | |
| 55 | - $version = FrmAppHelper::plugin_version(); |
|
| 55 | + $version = FrmAppHelper::plugin_version(); |
|
| 56 | 56 | wp_enqueue_script( 'jquery-frm-themepicker', FrmAppHelper::plugin_url() . '/js/jquery/jquery-ui-themepicker.js', array( 'jquery' ), $version ); |
| 57 | 57 | |
| 58 | - wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css'); |
|
| 58 | + wp_enqueue_style('frm-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_css'); |
|
| 59 | 59 | |
| 60 | - $style = apply_filters('frm_style_head', false); |
|
| 61 | - if ( $style ) { |
|
| 62 | - wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content)); |
|
| 63 | - } |
|
| 64 | - } |
|
| 60 | + $style = apply_filters('frm_style_head', false); |
|
| 61 | + if ( $style ) { |
|
| 62 | + wp_enqueue_style('frm-single-custom-theme', admin_url('admin-ajax.php') .'?action=frmpro_load_css&flat=1&'. http_build_query($style->post_content)); |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | public static function enqueue_css( $register = 'enqueue' ) { |
| 67 | 67 | global $frm_vars; |
@@ -128,227 +128,227 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | public static function new_style( $return = '' ) { |
| 131 | - self::load_styler('default'); |
|
| 132 | - } |
|
| 131 | + self::load_styler('default'); |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | 134 | public static function duplicate() { |
| 135 | 135 | self::load_styler('default'); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | public static function edit( $style_id = false, $message = '' ) { |
| 139 | - if ( ! $style_id ) { |
|
| 139 | + if ( ! $style_id ) { |
|
| 140 | 140 | $style_id = FrmAppHelper::get_param( 'id', '', 'get', 'absint' ); |
| 141 | - if ( empty($style_id) ) { |
|
| 142 | - $style_id = 'default'; |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - if ( 'default' == $style_id ) { |
|
| 147 | - $style = 'default'; |
|
| 148 | - } else { |
|
| 149 | - $frm_style = new FrmStyle($style_id); |
|
| 150 | - $style = $frm_style->get_one(); |
|
| 151 | - $style = $style->ID; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - self::load_styler($style, $message); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - public static function save() { |
|
| 158 | - $frm_style = new FrmStyle(); |
|
| 159 | - $message = ''; |
|
| 141 | + if ( empty($style_id) ) { |
|
| 142 | + $style_id = 'default'; |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + if ( 'default' == $style_id ) { |
|
| 147 | + $style = 'default'; |
|
| 148 | + } else { |
|
| 149 | + $frm_style = new FrmStyle($style_id); |
|
| 150 | + $style = $frm_style->get_one(); |
|
| 151 | + $style = $style->ID; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + self::load_styler($style, $message); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + public static function save() { |
|
| 158 | + $frm_style = new FrmStyle(); |
|
| 159 | + $message = ''; |
|
| 160 | 160 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_title' ); |
| 161 | 161 | $style_nonce = FrmAppHelper::get_post_param( 'frm_style', '', 'sanitize_text_field' ); |
| 162 | 162 | |
| 163 | 163 | if ( $post_id !== false && wp_verify_nonce( $style_nonce, 'frm_style_nonce' ) ) { |
| 164 | - $id = $frm_style->update($post_id); |
|
| 165 | - if ( empty($post_id) && ! empty($id) ) { |
|
| 166 | - // set the post id to the new style so it will be loaded for editing |
|
| 167 | - $post_id = reset($id); |
|
| 168 | - } |
|
| 169 | - // include the CSS that includes this style |
|
| 164 | + $id = $frm_style->update($post_id); |
|
| 165 | + if ( empty($post_id) && ! empty($id) ) { |
|
| 166 | + // set the post id to the new style so it will be loaded for editing |
|
| 167 | + $post_id = reset($id); |
|
| 168 | + } |
|
| 169 | + // include the CSS that includes this style |
|
| 170 | 170 | echo '<link href="' . esc_url( admin_url( 'admin-ajax.php' ) . '?action=frmpro_css' ) . '" type="text/css" rel="Stylesheet" class="frm-custom-theme" />'; |
| 171 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
| 172 | - } |
|
| 171 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | - return self::edit($post_id, $message); |
|
| 175 | - } |
|
| 174 | + return self::edit($post_id, $message); |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | 177 | public static function load_styler( $style, $message = '' ) { |
| 178 | - global $frm_settings; |
|
| 178 | + global $frm_settings; |
|
| 179 | 179 | |
| 180 | - $frm_style = new FrmStyle(); |
|
| 181 | - $styles = $frm_style->get_all(); |
|
| 180 | + $frm_style = new FrmStyle(); |
|
| 181 | + $styles = $frm_style->get_all(); |
|
| 182 | 182 | |
| 183 | - if ( is_numeric($style) ) { |
|
| 184 | - $style = $styles[ $style ]; |
|
| 185 | - } else if ( 'default' == $style ) { |
|
| 186 | - $style = $frm_style->get_default_style($styles); |
|
| 187 | - } |
|
| 183 | + if ( is_numeric($style) ) { |
|
| 184 | + $style = $styles[ $style ]; |
|
| 185 | + } else if ( 'default' == $style ) { |
|
| 186 | + $style = $frm_style->get_default_style($styles); |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - self::add_meta_boxes(); |
|
| 189 | + self::add_meta_boxes(); |
|
| 190 | 190 | |
| 191 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php'); |
|
| 192 | - } |
|
| 191 | + include(FrmAppHelper::plugin_path() .'/classes/views/styles/show.php'); |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | 194 | /** |
| 195 | 195 | * @param string $message |
| 196 | 196 | * @param array|object $forms |
| 197 | 197 | */ |
| 198 | 198 | private static function manage( $message = '', $forms = array() ) { |
| 199 | - $frm_style = new FrmStyle(); |
|
| 200 | - $styles = $frm_style->get_all(); |
|
| 201 | - $default_style = $frm_style->get_default_style($styles); |
|
| 199 | + $frm_style = new FrmStyle(); |
|
| 200 | + $styles = $frm_style->get_all(); |
|
| 201 | + $default_style = $frm_style->get_default_style($styles); |
|
| 202 | 202 | |
| 203 | - if ( empty($forms) ) { |
|
| 204 | - $forms = FrmForm::get_published_forms(); |
|
| 205 | - } |
|
| 203 | + if ( empty($forms) ) { |
|
| 204 | + $forms = FrmForm::get_published_forms(); |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php'); |
|
| 208 | - } |
|
| 207 | + include(FrmAppHelper::plugin_path() .'/classes/views/styles/manage.php'); |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - private static function manage_styles() { |
|
| 210 | + private static function manage_styles() { |
|
| 211 | 211 | $style_nonce = FrmAppHelper::get_post_param( 'frm_manage_style', '', 'sanitize_text_field' ); |
| 212 | 212 | if ( ! $_POST || ! isset( $_POST['style'] ) || ! wp_verify_nonce( $style_nonce, 'frm_manage_style_nonce' ) ) { |
| 213 | - return self::manage(); |
|
| 214 | - } |
|
| 213 | + return self::manage(); |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - global $wpdb; |
|
| 216 | + global $wpdb; |
|
| 217 | 217 | |
| 218 | 218 | $forms = FrmForm::get_published_forms(); |
| 219 | - foreach ( $forms as $form ) { |
|
| 220 | - if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
| 221 | - continue; |
|
| 222 | - } |
|
| 219 | + foreach ( $forms as $form ) { |
|
| 220 | + if ( $_POST['style'][ $form->id ] == $_POST['prev_style'][ $form->id ] ) { |
|
| 221 | + continue; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
| 224 | + $form->options['custom_style'] = $_POST['style'][ $form->id ]; |
|
| 225 | 225 | |
| 226 | 226 | $wpdb->update( $wpdb->prefix . 'frm_forms', array( 'options' => maybe_serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 227 | - unset($form); |
|
| 228 | - } |
|
| 227 | + unset($form); |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
| 231 | - return self::manage($message, $forms); |
|
| 232 | - } |
|
| 230 | + $message = __( 'Your form styles have been saved.', 'formidable' ); |
|
| 231 | + return self::manage($message, $forms); |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | - public static function custom_css( $message = '', $style = null ) { |
|
| 235 | - wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
| 236 | - wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
| 237 | - wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
|
| 234 | + public static function custom_css( $message = '', $style = null ) { |
|
| 235 | + wp_enqueue_style('codemirror', FrmAppHelper::plugin_url() . '/css/codemirror.css'); |
|
| 236 | + wp_enqueue_script('codemirror', FrmAppHelper::plugin_url() . '/js/codemirror/codemirror.js', array(), '4.7'); |
|
| 237 | + wp_enqueue_script( 'codemirror-css', FrmAppHelper::plugin_url() . '/js/codemirror/css.js', array( 'codemirror' ), '4.7' ); |
|
| 238 | 238 | |
| 239 | - if ( ! isset($style) ) { |
|
| 240 | - $frm_style = new FrmStyle(); |
|
| 241 | - $style = $frm_style->get_default_style(); |
|
| 242 | - } |
|
| 239 | + if ( ! isset($style) ) { |
|
| 240 | + $frm_style = new FrmStyle(); |
|
| 241 | + $style = $frm_style->get_default_style(); |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php'); |
|
| 245 | - } |
|
| 244 | + include(FrmAppHelper::plugin_path() .'/classes/views/styles/custom_css.php'); |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - public static function save_css() { |
|
| 248 | - $frm_style = new FrmStyle(); |
|
| 247 | + public static function save_css() { |
|
| 248 | + $frm_style = new FrmStyle(); |
|
| 249 | 249 | |
| 250 | - $message = ''; |
|
| 250 | + $message = ''; |
|
| 251 | 251 | $post_id = FrmAppHelper::get_post_param( 'ID', false, 'sanitize_text_field' ); |
| 252 | 252 | $nonce = FrmAppHelper::get_post_param( 'frm_custom_css', '', 'sanitize_text_field' ); |
| 253 | 253 | if ( wp_verify_nonce( $nonce, 'frm_custom_css_nonce' ) ) { |
| 254 | - $frm_style->update($post_id); |
|
| 255 | - $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
| 256 | - } |
|
| 254 | + $frm_style->update($post_id); |
|
| 255 | + $message = __( 'Your styling settings have been saved.', 'formidable' ); |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | - return self::custom_css($message); |
|
| 259 | - } |
|
| 258 | + return self::custom_css($message); |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - public static function route() { |
|
| 261 | + public static function route() { |
|
| 262 | 262 | $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' ); |
| 263 | 263 | |
| 264 | - switch ( $action ) { |
|
| 265 | - case 'edit': |
|
| 266 | - case 'save': |
|
| 267 | - case 'manage': |
|
| 268 | - case 'manage_styles': |
|
| 269 | - case 'custom_css': |
|
| 270 | - case 'save_css': |
|
| 264 | + switch ( $action ) { |
|
| 265 | + case 'edit': |
|
| 266 | + case 'save': |
|
| 267 | + case 'manage': |
|
| 268 | + case 'manage_styles': |
|
| 269 | + case 'custom_css': |
|
| 270 | + case 'save_css': |
|
| 271 | 271 | return self::$action(); |
| 272 | - default: |
|
| 273 | - do_action( 'frm_style_action_route', $action ); |
|
| 274 | - if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
| 275 | - return; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
| 279 | - return self::$action(); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - return self::edit(); |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - public static function reset_styling() { |
|
| 287 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 288 | - |
|
| 289 | - $frm_style = new FrmStyle(); |
|
| 290 | - $defaults = $frm_style->get_defaults(); |
|
| 291 | - |
|
| 292 | - echo json_encode( $defaults ); |
|
| 293 | - wp_die(); |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - public static function change_styling() { |
|
| 297 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 298 | - |
|
| 299 | - $frm_style = new FrmStyle(); |
|
| 300 | - $defaults = $frm_style->get_defaults(); |
|
| 301 | - |
|
| 302 | - // remove the # from the colors |
|
| 303 | - foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
| 304 | - if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
| 305 | - $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
| 306 | - } |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - echo '<style type="text/css">'; |
|
| 310 | - include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php'); |
|
| 311 | - echo '</style>'; |
|
| 312 | - wp_die(); |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - private static function add_meta_boxes() { |
|
| 316 | - |
|
| 317 | - // setup meta boxes |
|
| 318 | - $meta_boxes = array( |
|
| 319 | - 'general' => __( 'General', 'formidable' ), |
|
| 320 | - 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
| 321 | - 'field-description' => __( 'Field Description', 'formidable' ), |
|
| 322 | - 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
| 323 | - 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
| 324 | - 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
| 325 | - 'section-fields' => __( 'Section Fields', 'formidable' ), |
|
| 326 | - 'date-fields' => __( 'Date Fields', 'formidable' ), |
|
| 327 | - 'buttons' => __( 'Buttons', 'formidable' ), |
|
| 328 | - 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
| 329 | - ); |
|
| 330 | - |
|
| 331 | - foreach ( $meta_boxes as $nicename => $name ) { |
|
| 332 | - add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
|
| 333 | - unset($nicename, $name); |
|
| 334 | - } |
|
| 335 | - } |
|
| 272 | + default: |
|
| 273 | + do_action( 'frm_style_action_route', $action ); |
|
| 274 | + if ( apply_filters( 'frm_style_stop_action_route', false, $action ) ) { |
|
| 275 | + return; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + if ( 'new_style' == $action || 'duplicate' == $action ) { |
|
| 279 | + return self::$action(); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + return self::edit(); |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + public static function reset_styling() { |
|
| 287 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 288 | + |
|
| 289 | + $frm_style = new FrmStyle(); |
|
| 290 | + $defaults = $frm_style->get_defaults(); |
|
| 291 | + |
|
| 292 | + echo json_encode( $defaults ); |
|
| 293 | + wp_die(); |
|
| 294 | + } |
|
| 295 | + |
|
| 296 | + public static function change_styling() { |
|
| 297 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 298 | + |
|
| 299 | + $frm_style = new FrmStyle(); |
|
| 300 | + $defaults = $frm_style->get_defaults(); |
|
| 301 | + |
|
| 302 | + // remove the # from the colors |
|
| 303 | + foreach ( $_GET['frm_style_setting']['post_content'] as $k => $v ) { |
|
| 304 | + if ( ! is_array($v) && strpos($v, '#') === 0 ) { |
|
| 305 | + $_GET['frm_style_setting']['post_content'][ $k ] = str_replace( '#', '', $v ); |
|
| 306 | + } |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + echo '<style type="text/css">'; |
|
| 310 | + include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php'); |
|
| 311 | + echo '</style>'; |
|
| 312 | + wp_die(); |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + private static function add_meta_boxes() { |
|
| 316 | + |
|
| 317 | + // setup meta boxes |
|
| 318 | + $meta_boxes = array( |
|
| 319 | + 'general' => __( 'General', 'formidable' ), |
|
| 320 | + 'field-labels' => __( 'Field Labels', 'formidable' ), |
|
| 321 | + 'field-description' => __( 'Field Description', 'formidable' ), |
|
| 322 | + 'field-colors' => __( 'Field Colors', 'formidable' ), |
|
| 323 | + 'field-sizes' => __( 'Field Settings', 'formidable' ), |
|
| 324 | + 'check-box-radio-fields' => __( 'Check Box & Radio Fields', 'formidable' ), |
|
| 325 | + 'section-fields' => __( 'Section Fields', 'formidable' ), |
|
| 326 | + 'date-fields' => __( 'Date Fields', 'formidable' ), |
|
| 327 | + 'buttons' => __( 'Buttons', 'formidable' ), |
|
| 328 | + 'form-messages' => __( 'Form Messages', 'formidable' ), |
|
| 329 | + ); |
|
| 330 | + |
|
| 331 | + foreach ( $meta_boxes as $nicename => $name ) { |
|
| 332 | + add_meta_box( $nicename .'-style', $name, 'FrmStylesController::include_style_section', self::$screen, 'side', 'default', $nicename ); |
|
| 333 | + unset($nicename, $name); |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | 336 | |
| 337 | 337 | public static function include_style_section( $atts, $sec ) { |
| 338 | - extract($atts); |
|
| 338 | + extract($atts); |
|
| 339 | 339 | $current_tab = FrmAppHelper::simple_get( 'page-tab', 'sanitize_title', 'default' ); |
| 340 | - include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php'); |
|
| 341 | - } |
|
| 340 | + include(FrmAppHelper::plugin_path() .'/classes/views/styles/_'. $sec['args'] .'.php'); |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | - public static function load_css() { |
|
| 344 | - header('Content-type: text/css'); |
|
| 343 | + public static function load_css() { |
|
| 344 | + header('Content-type: text/css'); |
|
| 345 | 345 | |
| 346 | - $frm_style = new FrmStyle(); |
|
| 347 | - $defaults = $frm_style->get_defaults(); |
|
| 346 | + $frm_style = new FrmStyle(); |
|
| 347 | + $defaults = $frm_style->get_defaults(); |
|
| 348 | 348 | |
| 349 | - include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php'); |
|
| 350 | - wp_die(); |
|
| 351 | - } |
|
| 349 | + include(FrmAppHelper::plugin_path() .'/css/_single_theme.css.php'); |
|
| 350 | + wp_die(); |
|
| 351 | + } |
|
| 352 | 352 | |
| 353 | 353 | public static function load_saved_css() { |
| 354 | 354 | $css = get_transient( 'frmpro_css' ); |
@@ -357,142 +357,142 @@ discard block |
||
| 357 | 357 | wp_die(); |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - /** |
|
| 361 | - * Check if the Formidable styling should be loaded, |
|
| 362 | - * then enqueue it for the footer |
|
| 363 | - * @since 2.0 |
|
| 364 | - */ |
|
| 365 | - public static function enqueue_style() { |
|
| 366 | - global $frm_vars; |
|
| 367 | - |
|
| 368 | - if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
| 369 | - // the CSS has already been loaded |
|
| 370 | - return; |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 374 | - if ( $frm_settings->load_style != 'none' ) { |
|
| 375 | - wp_enqueue_style( 'formidable' ); |
|
| 376 | - $frm_vars['css_loaded'] = true; |
|
| 377 | - } |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - // Get the stylesheets for the form settings page |
|
| 381 | - public static function get_style_opts() { |
|
| 382 | - $frm_style = new FrmStyle(); |
|
| 383 | - $styles = $frm_style->get_all(); |
|
| 384 | - |
|
| 385 | - return $styles; |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - public static function get_form_style( $form = 'default' ) { |
|
| 389 | - $style = FrmFormsHelper::get_form_style( $form ); |
|
| 390 | - |
|
| 391 | - if ( empty( $style ) || 1 == $style ) { |
|
| 392 | - $style = 'default'; |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - $frm_style = new FrmStyle( $style ); |
|
| 396 | - return $frm_style->get_one(); |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - /** |
|
| 400 | - * @param string $class |
|
| 401 | - * @param string $style |
|
| 402 | - */ |
|
| 360 | + /** |
|
| 361 | + * Check if the Formidable styling should be loaded, |
|
| 362 | + * then enqueue it for the footer |
|
| 363 | + * @since 2.0 |
|
| 364 | + */ |
|
| 365 | + public static function enqueue_style() { |
|
| 366 | + global $frm_vars; |
|
| 367 | + |
|
| 368 | + if ( isset( $frm_vars['css_loaded'] ) && $frm_vars['css_loaded'] ) { |
|
| 369 | + // the CSS has already been loaded |
|
| 370 | + return; |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 374 | + if ( $frm_settings->load_style != 'none' ) { |
|
| 375 | + wp_enqueue_style( 'formidable' ); |
|
| 376 | + $frm_vars['css_loaded'] = true; |
|
| 377 | + } |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + // Get the stylesheets for the form settings page |
|
| 381 | + public static function get_style_opts() { |
|
| 382 | + $frm_style = new FrmStyle(); |
|
| 383 | + $styles = $frm_style->get_all(); |
|
| 384 | + |
|
| 385 | + return $styles; |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + public static function get_form_style( $form = 'default' ) { |
|
| 389 | + $style = FrmFormsHelper::get_form_style( $form ); |
|
| 390 | + |
|
| 391 | + if ( empty( $style ) || 1 == $style ) { |
|
| 392 | + $style = 'default'; |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + $frm_style = new FrmStyle( $style ); |
|
| 396 | + return $frm_style->get_one(); |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + /** |
|
| 400 | + * @param string $class |
|
| 401 | + * @param string $style |
|
| 402 | + */ |
|
| 403 | 403 | public static function get_form_style_class( $class, $style ) { |
| 404 | - if ( 1 == $style ) { |
|
| 405 | - $style = 'default'; |
|
| 406 | - } |
|
| 404 | + if ( 1 == $style ) { |
|
| 405 | + $style = 'default'; |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - $frm_style = new FrmStyle($style); |
|
| 409 | - $style = $frm_style->get_one(); |
|
| 408 | + $frm_style = new FrmStyle($style); |
|
| 409 | + $style = $frm_style->get_one(); |
|
| 410 | 410 | |
| 411 | - if ( $style ) { |
|
| 412 | - $class .= ' frm_style_'. $style->post_name; |
|
| 413 | - } |
|
| 411 | + if ( $style ) { |
|
| 412 | + $class .= ' frm_style_'. $style->post_name; |
|
| 413 | + } |
|
| 414 | 414 | |
| 415 | - return $class; |
|
| 416 | - } |
|
| 415 | + return $class; |
|
| 416 | + } |
|
| 417 | 417 | |
| 418 | - /** |
|
| 419 | - * @param string $val |
|
| 420 | - */ |
|
| 418 | + /** |
|
| 419 | + * @param string $val |
|
| 420 | + */ |
|
| 421 | 421 | public static function get_style_val( $val, $form = 'default' ) { |
| 422 | - $style = self::get_form_style($form); |
|
| 423 | - if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
| 424 | - return $style->post_content[ $val ]; |
|
| 425 | - } |
|
| 426 | - } |
|
| 422 | + $style = self::get_form_style($form); |
|
| 423 | + if ( $style && isset( $style->post_content[ $val ] ) ) { |
|
| 424 | + return $style->post_content[ $val ]; |
|
| 425 | + } |
|
| 426 | + } |
|
| 427 | 427 | |
| 428 | 428 | public static function show_entry_styles( $default_styles ) { |
| 429 | - $frm_style = new FrmStyle('default'); |
|
| 430 | - $style = $frm_style->get_one(); |
|
| 431 | - |
|
| 432 | - if ( ! $style ) { |
|
| 433 | - return $default_styles; |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - foreach ( $default_styles as $name => $val ) { |
|
| 437 | - $setting = $name; |
|
| 438 | - if ( 'border_width' == $name ) { |
|
| 439 | - $setting = 'field_border_width'; |
|
| 440 | - } else if ( 'alt_bg_color' == $name ) { |
|
| 441 | - $setting = 'bg_color_active'; |
|
| 442 | - } |
|
| 443 | - $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
| 444 | - unset($name, $val); |
|
| 445 | - } |
|
| 446 | - |
|
| 447 | - return $default_styles; |
|
| 448 | - } |
|
| 429 | + $frm_style = new FrmStyle('default'); |
|
| 430 | + $style = $frm_style->get_one(); |
|
| 431 | + |
|
| 432 | + if ( ! $style ) { |
|
| 433 | + return $default_styles; |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + foreach ( $default_styles as $name => $val ) { |
|
| 437 | + $setting = $name; |
|
| 438 | + if ( 'border_width' == $name ) { |
|
| 439 | + $setting = 'field_border_width'; |
|
| 440 | + } else if ( 'alt_bg_color' == $name ) { |
|
| 441 | + $setting = 'bg_color_active'; |
|
| 442 | + } |
|
| 443 | + $default_styles[ $name ] = $style->post_content[ $setting ]; |
|
| 444 | + unset($name, $val); |
|
| 445 | + } |
|
| 446 | + |
|
| 447 | + return $default_styles; |
|
| 448 | + } |
|
| 449 | 449 | |
| 450 | 450 | public static function &important_style( $important, $field ) { |
| 451 | - $important = self::get_style_val('important_style', $field['form_id']); |
|
| 452 | - return $important; |
|
| 453 | - } |
|
| 451 | + $important = self::get_style_val('important_style', $field['form_id']); |
|
| 452 | + return $important; |
|
| 453 | + } |
|
| 454 | 454 | |
| 455 | - /** |
|
| 456 | - * Fallback for WP < 3.6 |
|
| 457 | - */ |
|
| 458 | - public static function do_accordion_sections( $screen, $context, $object ) { |
|
| 459 | - if ( function_exists( 'do_accordion_sections' ) ) { |
|
| 460 | - return do_accordion_sections( $screen, $context, $object ); |
|
| 461 | - } |
|
| 455 | + /** |
|
| 456 | + * Fallback for WP < 3.6 |
|
| 457 | + */ |
|
| 458 | + public static function do_accordion_sections( $screen, $context, $object ) { |
|
| 459 | + if ( function_exists( 'do_accordion_sections' ) ) { |
|
| 460 | + return do_accordion_sections( $screen, $context, $object ); |
|
| 461 | + } |
|
| 462 | 462 | |
| 463 | - global $wp_meta_boxes; |
|
| 463 | + global $wp_meta_boxes; |
|
| 464 | 464 | |
| 465 | - $screen = 'formidable_page_formidable-styles'; |
|
| 466 | - $screen = convert_to_screen( $screen ); |
|
| 465 | + $screen = 'formidable_page_formidable-styles'; |
|
| 466 | + $screen = convert_to_screen( $screen ); |
|
| 467 | 467 | |
| 468 | - $page = $screen->id; |
|
| 468 | + $page = $screen->id; |
|
| 469 | 469 | |
| 470 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
| 471 | - ?> |
|
| 470 | + $hidden = get_hidden_meta_boxes( $screen ); |
|
| 471 | + ?> |
|
| 472 | 472 | <div id="side-sortables" class="accordion-container"> |
| 473 | 473 | <?php |
| 474 | - $i = 0; |
|
| 475 | - $first_open = false; |
|
| 476 | - do { |
|
| 474 | + $i = 0; |
|
| 475 | + $first_open = false; |
|
| 476 | + do { |
|
| 477 | 477 | if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[ $page ] ) || ! isset( $wp_meta_boxes[ $page ][ $context ] ) ) { |
| 478 | 478 | break; |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | - foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
| 482 | - if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 483 | - foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 484 | - if ( false == $box || ! $box['title'] ) { |
|
| 485 | - continue; |
|
| 481 | + foreach ( array( 'high', 'core', 'default', 'low' ) as $priority ) { |
|
| 482 | + if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ] ) ) { |
|
| 483 | + foreach ( $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { |
|
| 484 | + if ( false == $box || ! $box['title'] ) { |
|
| 485 | + continue; |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - $i++; |
|
| 489 | - $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
| 488 | + $i++; |
|
| 489 | + $hidden_class = in_array( $box['id'], $hidden ) ? 'hide-if-js' : ''; |
|
| 490 | 490 | |
| 491 | - if ( ! $first_open && empty( $hidden_class ) ) { |
|
| 492 | - $first_open = true; |
|
| 493 | - } |
|
| 491 | + if ( ! $first_open && empty( $hidden_class ) ) { |
|
| 492 | + $first_open = true; |
|
| 493 | + } |
|
| 494 | 494 | |
| 495 | - ?> |
|
| 495 | + ?> |
|
| 496 | 496 | <div class="postbox <?php echo esc_attr( $box['id'] ); ?>"> |
| 497 | 497 | <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'formidable' ) ?>"><br/></div> |
| 498 | 498 | <h3 class='hndle'><span><?php echo esc_html( $box['title'] ); ?></span></h3> |
@@ -503,13 +503,13 @@ discard block |
||
| 503 | 503 | </div><!-- .accordion-section-content --> |
| 504 | 504 | </div><!-- .postbox --> |
| 505 | 505 | <?php |
| 506 | - } |
|
| 507 | - } |
|
| 508 | - } |
|
| 509 | - } while ( 0 ); |
|
| 510 | - ?> |
|
| 506 | + } |
|
| 507 | + } |
|
| 508 | + } |
|
| 509 | + } while ( 0 ); |
|
| 510 | + ?> |
|
| 511 | 511 | </div><!-- .accordion-container --> |
| 512 | 512 | <?php |
| 513 | - return $i; |
|
| 514 | - } |
|
| 513 | + return $i; |
|
| 514 | + } |
|
| 515 | 515 | } |
@@ -1,91 +1,91 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmHooksController { |
| 4 | - /** |
|
| 5 | - * Trigger plugin-wide hook loading |
|
| 6 | - */ |
|
| 7 | - public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
| 8 | - $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
| 9 | - |
|
| 10 | - $trigger_hooks = $hooks; |
|
| 11 | - $hooks = (array) $hooks; |
|
| 12 | - |
|
| 13 | - if ( 'load_hooks' == $trigger_hooks ) { |
|
| 14 | - if ( is_admin() ) { |
|
| 15 | - $hooks[] = 'load_admin_hooks'; |
|
| 16 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 17 | - $hooks[] = 'load_ajax_hooks'; |
|
| 18 | - $hooks[] = 'load_form_hooks'; |
|
| 19 | - } |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - if ( is_multisite() ) { |
|
| 23 | - $hooks[] = 'load_multisite_hooks'; |
|
| 24 | - } |
|
| 25 | - } else { |
|
| 26 | - // Make sure the hooks are only triggered once |
|
| 27 | - add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
| 28 | - } |
|
| 29 | - unset( $trigger_hooks ); |
|
| 30 | - |
|
| 31 | - // Instansiate Controllers |
|
| 32 | - foreach ( $controllers as $c ) { |
|
| 33 | - foreach ( $hooks as $hook ) { |
|
| 4 | + /** |
|
| 5 | + * Trigger plugin-wide hook loading |
|
| 6 | + */ |
|
| 7 | + public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
| 8 | + $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
| 9 | + |
|
| 10 | + $trigger_hooks = $hooks; |
|
| 11 | + $hooks = (array) $hooks; |
|
| 12 | + |
|
| 13 | + if ( 'load_hooks' == $trigger_hooks ) { |
|
| 14 | + if ( is_admin() ) { |
|
| 15 | + $hooks[] = 'load_admin_hooks'; |
|
| 16 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 17 | + $hooks[] = 'load_ajax_hooks'; |
|
| 18 | + $hooks[] = 'load_form_hooks'; |
|
| 19 | + } |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + if ( is_multisite() ) { |
|
| 23 | + $hooks[] = 'load_multisite_hooks'; |
|
| 24 | + } |
|
| 25 | + } else { |
|
| 26 | + // Make sure the hooks are only triggered once |
|
| 27 | + add_filter( 'frm' . str_replace( 'load', '', $trigger_hooks ) . '_loaded', '__return_true' ); |
|
| 28 | + } |
|
| 29 | + unset( $trigger_hooks ); |
|
| 30 | + |
|
| 31 | + // Instansiate Controllers |
|
| 32 | + foreach ( $controllers as $c ) { |
|
| 33 | + foreach ( $hooks as $hook ) { |
|
| 34 | 34 | call_user_func( array( $c, $hook ) ); |
| 35 | 35 | unset( $hook ); |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | unset( $c ); |
| 38 | - } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public static function trigger_load_form_hooks() { |
|
| 43 | - self::trigger_load_hook( 'load_form_hooks' ); |
|
| 44 | - } |
|
| 42 | + public static function trigger_load_form_hooks() { |
|
| 43 | + self::trigger_load_hook( 'load_form_hooks' ); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | public static function load_hooks() { |
| 47 | - if ( ! is_admin() ) { |
|
| 48 | - add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
| 52 | - add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); |
|
| 53 | - |
|
| 54 | - // Entries controller |
|
| 55 | - add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
| 56 | - add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); |
|
| 57 | - add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
| 58 | - add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 ); |
|
| 59 | - add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 ); |
|
| 60 | - |
|
| 61 | - // Form Actions Controller |
|
| 62 | - add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
| 47 | + if ( ! is_admin() ) { |
|
| 48 | + add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
| 52 | + add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); |
|
| 53 | + |
|
| 54 | + // Entries controller |
|
| 55 | + add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
| 56 | + add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); |
|
| 57 | + add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
| 58 | + add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 ); |
|
| 59 | + add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 ); |
|
| 60 | + |
|
| 61 | + // Form Actions Controller |
|
| 62 | + add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
| 63 | 63 | add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 ); |
| 64 | 64 | |
| 65 | - // Forms Controller |
|
| 66 | - add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
| 65 | + // Forms Controller |
|
| 66 | + add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
| 67 | 67 | add_action( 'init', 'FrmFormsController::front_head' ); |
| 68 | - add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
| 69 | - add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
| 70 | - add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
| 68 | + add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
| 69 | + add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
| 70 | + add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
| 71 | 71 | add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 ); |
| 72 | 72 | |
| 73 | 73 | add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' ); |
| 74 | 74 | |
| 75 | - // Form Shortcodes |
|
| 76 | - add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
| 75 | + // Form Shortcodes |
|
| 76 | + add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
| 77 | 77 | |
| 78 | - // Styles Controller |
|
| 79 | - add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
| 80 | - add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
| 81 | - add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
| 82 | - add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
| 83 | - } |
|
| 78 | + // Styles Controller |
|
| 79 | + add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
| 80 | + add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
| 81 | + add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
| 82 | + add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | public static function load_admin_hooks() { |
| 86 | - add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
| 87 | - add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
| 88 | - add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
| 86 | + add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
| 87 | + add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
| 88 | + add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
| 89 | 89 | add_action( 'admin_init', 'FrmAppController::admin_init', 11 ); |
| 90 | 90 | add_filter( 'admin_body_class', 'FrmAppController::wp_admin_body_class' ); |
| 91 | 91 | add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' ); |
@@ -94,120 +94,120 @@ discard block |
||
| 94 | 94 | // Addons Controller |
| 95 | 95 | add_action( 'admin_menu', 'FrmAddonsController::menu', 100 ); |
| 96 | 96 | |
| 97 | - // Entries Controller |
|
| 98 | - add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
| 99 | - add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
| 100 | - add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
| 101 | - add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
| 102 | - add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
| 97 | + // Entries Controller |
|
| 98 | + add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
| 99 | + add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
| 100 | + add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
| 101 | + add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
| 102 | + add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
| 103 | 103 | |
| 104 | - // Fields Controller |
|
| 105 | - add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
| 104 | + // Fields Controller |
|
| 105 | + add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
| 106 | 106 | |
| 107 | - // Form Actions Controller |
|
| 108 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 109 | - add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
| 110 | - } |
|
| 111 | - add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
| 107 | + // Form Actions Controller |
|
| 108 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 109 | + add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
| 110 | + } |
|
| 111 | + add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
| 112 | 112 | |
| 113 | - // Forms Controller |
|
| 114 | - add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
| 115 | - add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
| 113 | + // Forms Controller |
|
| 114 | + add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
| 115 | + add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
| 116 | 116 | |
| 117 | - add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
| 118 | - add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
| 117 | + add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
| 118 | + add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
| 119 | 119 | add_action( 'media_buttons', 'FrmFormsController::insert_form_button' ); |
| 120 | 120 | |
| 121 | - // Forms Model |
|
| 122 | - add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
| 121 | + // Forms Model |
|
| 122 | + add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
| 123 | 123 | |
| 124 | - // Settings Controller |
|
| 125 | - add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
| 126 | - add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
| 124 | + // Settings Controller |
|
| 125 | + add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
| 126 | + add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
| 127 | 127 | |
| 128 | - // Styles Controller |
|
| 129 | - add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 130 | - add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 128 | + // Styles Controller |
|
| 129 | + add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 130 | + add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 131 | 131 | |
| 132 | - // XML Controller |
|
| 133 | - add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 134 | - } |
|
| 132 | + // XML Controller |
|
| 133 | + add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | 136 | public static function load_ajax_hooks() { |
| 137 | 137 | add_action( 'wp_ajax_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
| 138 | 138 | add_action( 'wp_ajax_nopriv_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
| 139 | 139 | add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' ); |
| 140 | - add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 141 | - add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 140 | + add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 141 | + add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 142 | 142 | |
| 143 | 143 | // Addons Controller |
| 144 | 144 | add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
| 145 | 145 | add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
| 146 | 146 | |
| 147 | - // Fields Controller |
|
| 148 | - add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 149 | - add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 150 | - add_action( 'wp_ajax_frm_update_field_form_id', 'FrmFieldsController::update_form_id' ); |
|
| 151 | - add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
| 152 | - add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 153 | - add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 154 | - add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 155 | - add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 156 | - add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' ); |
|
| 157 | - add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' ); |
|
| 158 | - add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 159 | - add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 160 | - add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 161 | - |
|
| 162 | - // Form Actions Controller |
|
| 163 | - add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 164 | - add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 165 | - |
|
| 166 | - // Forms Controller |
|
| 147 | + // Fields Controller |
|
| 148 | + add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 149 | + add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 150 | + add_action( 'wp_ajax_frm_update_field_form_id', 'FrmFieldsController::update_form_id' ); |
|
| 151 | + add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
| 152 | + add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 153 | + add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 154 | + add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 155 | + add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 156 | + add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' ); |
|
| 157 | + add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' ); |
|
| 158 | + add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 159 | + add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 160 | + add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 161 | + |
|
| 162 | + // Form Actions Controller |
|
| 163 | + add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 164 | + add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 165 | + |
|
| 166 | + // Forms Controller |
|
| 167 | 167 | add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' ); |
| 168 | 168 | add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' ); |
| 169 | 169 | add_action( 'wp_ajax_frm_form_key_in_place_edit', 'FrmFormsController::edit_key' ); |
| 170 | 170 | add_action( 'wp_ajax_frm_form_desc_in_place_edit', 'FrmFormsController::edit_description' ); |
| 171 | - add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 172 | - add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 173 | - add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 174 | - add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 175 | - |
|
| 176 | - // Styles Controller |
|
| 177 | - add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 178 | - add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 179 | - add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 180 | - add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 171 | + add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 172 | + add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 173 | + add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 174 | + add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 175 | + |
|
| 176 | + // Styles Controller |
|
| 177 | + add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 178 | + add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 179 | + add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 180 | + add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 181 | 181 | add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 182 | 182 | add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 183 | 183 | |
| 184 | - // XML Controller |
|
| 185 | - add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 186 | - } |
|
| 184 | + // XML Controller |
|
| 185 | + add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | 188 | public static function load_form_hooks() { |
| 189 | - // Fields Controller |
|
| 190 | - add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 191 | - add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 192 | - add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 193 | - add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 189 | + // Fields Controller |
|
| 190 | + add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 191 | + add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 192 | + add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 193 | + add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 194 | 194 | |
| 195 | 195 | // Forms Controller |
| 196 | 196 | add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' ); |
| 197 | 197 | |
| 198 | - // Styles Controller |
|
| 199 | - add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 200 | - } |
|
| 198 | + // Styles Controller |
|
| 199 | + add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | 202 | public static function load_view_hooks() { |
| 203 | - // Hooks go here when a view is loaded |
|
| 204 | - } |
|
| 203 | + // Hooks go here when a view is loaded |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | 206 | public static function load_multisite_hooks() { |
| 207 | 207 | add_action( 'init', 'FrmAppController::front_head' ); |
| 208 | 208 | add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' ); |
| 209 | 209 | |
| 210 | - // drop tables when mu site is deleted |
|
| 211 | - add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 212 | - } |
|
| 210 | + // drop tables when mu site is deleted |
|
| 211 | + add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 212 | + } |
|
| 213 | 213 | } |
@@ -3,14 +3,14 @@ discard block |
||
| 3 | 3 | class FrmAppController { |
| 4 | 4 | |
| 5 | 5 | public static function menu() { |
| 6 | - FrmAppHelper::maybe_add_permissions(); |
|
| 7 | - if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
| 8 | - return; |
|
| 9 | - } |
|
| 6 | + FrmAppHelper::maybe_add_permissions(); |
|
| 7 | + if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
| 8 | + return; |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 12 | - add_menu_page( 'Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', self::get_menu_position() ); |
|
| 13 | - } |
|
| 11 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 12 | + add_menu_page( 'Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() . '/images/form_16.png', self::get_menu_position() ); |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | private static function get_menu_position() { |
| 16 | 16 | $count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) ); |
@@ -19,39 +19,39 @@ discard block |
||
| 19 | 19 | return $pos; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public static function load_wp_admin_style() { |
|
| 23 | - FrmAppHelper::load_font_style(); |
|
| 24 | - } |
|
| 22 | + public static function load_wp_admin_style() { |
|
| 23 | + FrmAppHelper::load_font_style(); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) { |
| 27 | - global $pagenow, $frm_vars; |
|
| 27 | + global $pagenow, $frm_vars; |
|
| 28 | 28 | |
| 29 | 29 | $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
| 30 | - if ( empty( $show_nav ) ) { |
|
| 31 | - return; |
|
| 32 | - } |
|
| 30 | + if ( empty( $show_nav ) ) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | 34 | $current_page = isset( $_GET['page'] ) ? FrmAppHelper::simple_get( 'page', 'sanitize_title' ) : FrmAppHelper::simple_get( 'post_type', 'sanitize_title', 'None' ); |
| 35 | 35 | if ( $pagenow == 'post.php' || $pagenow == 'post-new.php' ) { |
| 36 | 36 | $current_page = 'frm_display'; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if ( $form ) { |
|
| 39 | + if ( $form ) { |
|
| 40 | 40 | FrmForm::maybe_get_form( $form ); |
| 41 | 41 | |
| 42 | - if ( is_object( $form ) ) { |
|
| 43 | - $id = $form->id; |
|
| 44 | - } |
|
| 45 | - } |
|
| 42 | + if ( is_object( $form ) ) { |
|
| 43 | + $id = $form->id; |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - if ( ! isset( $id ) ) { |
|
| 48 | - $form = $id = false; |
|
| 49 | - } |
|
| 47 | + if ( ! isset( $id ) ) { |
|
| 48 | + $form = $id = false; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | $nav_items = self::get_form_nav_items( $id ); |
| 52 | 52 | |
| 53 | - include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); |
|
| 54 | - } |
|
| 53 | + include( FrmAppHelper::plugin_path() . '/classes/views/shared/form-nav.php' ); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | private static function get_form_nav_items( $id ) { |
| 57 | 57 | $nav_items = array( |
@@ -82,26 +82,26 @@ discard block |
||
| 82 | 82 | return $nav_items; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - // Adds a settings link to the plugins page |
|
| 86 | - public static function settings_link( $links ) { |
|
| 85 | + // Adds a settings link to the plugins page |
|
| 86 | + public static function settings_link( $links ) { |
|
| 87 | 87 | $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
| 88 | - array_unshift( $links, $settings ); |
|
| 88 | + array_unshift( $links, $settings ); |
|
| 89 | 89 | |
| 90 | - return $links; |
|
| 91 | - } |
|
| 90 | + return $links; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - public static function pro_get_started_headline() { |
|
| 94 | - // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 95 | - if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 96 | - return; |
|
| 97 | - } |
|
| 93 | + public static function pro_get_started_headline() { |
|
| 94 | + // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 95 | + if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 96 | + return; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) { |
| 100 | - FrmAppHelper::load_admin_wide_js(); |
|
| 100 | + FrmAppHelper::load_admin_wide_js(); |
|
| 101 | 101 | |
| 102 | - // user is authorized, but running free version |
|
| 103 | - $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
| 104 | - ?> |
|
| 102 | + // user is authorized, but running free version |
|
| 103 | + $inst_install_url = 'https://formidablepro.com/knowledgebase/install-formidable-forms/'; |
|
| 104 | + ?> |
|
| 105 | 105 | <div class="error" class="frm_previous_install"> |
| 106 | 106 | <?php |
| 107 | 107 | echo wp_kses_post( apply_filters( 'frm_pro_update_msg', |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | ) ); ?> |
| 114 | 114 | </div> |
| 115 | 115 | <?php |
| 116 | - } |
|
| 117 | - } |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | 119 | /** |
| 120 | 120 | * If there are CURL problems on this server, wp_remote_post won't work for installing |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - public static function admin_js() { |
|
| 159 | + public static function admin_js() { |
|
| 160 | 160 | $version = FrmAppHelper::plugin_version(); |
| 161 | 161 | FrmAppHelper::load_admin_wide_js( false ); |
| 162 | 162 | |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | 'bootstrap_tooltip', 'bootstrap-multiselect', |
| 168 | 168 | ), $version, true ); |
| 169 | 169 | wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version ); |
| 170 | - wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 170 | + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 171 | 171 | |
| 172 | 172 | // load multselect js |
| 173 | 173 | wp_register_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array( 'jquery', 'bootstrap_tooltip' ), '0.9.8', true ); |
@@ -178,78 +178,78 @@ discard block |
||
| 178 | 178 | global $pagenow; |
| 179 | 179 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) { |
| 180 | 180 | |
| 181 | - wp_enqueue_script( 'admin-widgets' ); |
|
| 182 | - wp_enqueue_style( 'widgets' ); |
|
| 183 | - wp_enqueue_script( 'formidable' ); |
|
| 184 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 181 | + wp_enqueue_script( 'admin-widgets' ); |
|
| 182 | + wp_enqueue_style( 'widgets' ); |
|
| 183 | + wp_enqueue_script( 'formidable' ); |
|
| 184 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 185 | 185 | FrmAppHelper::localize_script( 'admin' ); |
| 186 | 186 | |
| 187 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 188 | - add_thickbox(); |
|
| 187 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 188 | + add_thickbox(); |
|
| 189 | 189 | |
| 190 | - wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 190 | + wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 191 | 191 | |
| 192 | - } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 193 | - if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 194 | - $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 192 | + } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 193 | + if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 194 | + $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 195 | 195 | } else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
| 196 | 196 | $post = get_post( absint( $_REQUEST['post'] ) ); |
| 197 | - if ( ! $post ) { |
|
| 198 | - return; |
|
| 199 | - } |
|
| 200 | - $post_type = $post->post_type; |
|
| 201 | - } else { |
|
| 202 | - return; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - if ( $post_type == 'frm_display' ) { |
|
| 206 | - wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 207 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 208 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 197 | + if ( ! $post ) { |
|
| 198 | + return; |
|
| 199 | + } |
|
| 200 | + $post_type = $post->post_type; |
|
| 201 | + } else { |
|
| 202 | + return; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + if ( $post_type == 'frm_display' ) { |
|
| 206 | + wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 207 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 208 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 209 | 209 | FrmAppHelper::localize_script( 'admin' ); |
| 210 | - } |
|
| 211 | - } else if ( $pagenow == 'widgets.php' ) { |
|
| 212 | - FrmAppHelper::load_admin_wide_js(); |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - public static function wp_admin_body_class( $classes ) { |
|
| 217 | - global $wp_version; |
|
| 218 | - //we need this class everywhere in the admin for the menu |
|
| 219 | - if ( version_compare( $wp_version, '3.7.2', '>' ) ) { |
|
| 220 | - $classes .= ' frm_38_trigger'; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - return $classes; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - public static function load_lang() { |
|
| 227 | - load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - /** |
|
| 231 | - * Filter shortcodes in text widgets |
|
| 232 | - */ |
|
| 233 | - public static function widget_text_filter( $content ) { |
|
| 234 | - $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
| 235 | - return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - public static function widget_text_filter_callback( $matches ) { |
|
| 239 | - _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' ); |
|
| 240 | - return FrmAppHelper::widget_text_filter_callback( $matches ); |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - public static function front_head() { |
|
| 244 | - if ( is_multisite() ) { |
|
| 245 | - $old_db_version = get_option( 'frm_db_version' ); |
|
| 246 | - $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
| 247 | - if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
| 248 | - ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
| 249 | - self::install( $old_db_version ); |
|
| 250 | - } |
|
| 251 | - } |
|
| 252 | - } |
|
| 210 | + } |
|
| 211 | + } else if ( $pagenow == 'widgets.php' ) { |
|
| 212 | + FrmAppHelper::load_admin_wide_js(); |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + public static function wp_admin_body_class( $classes ) { |
|
| 217 | + global $wp_version; |
|
| 218 | + //we need this class everywhere in the admin for the menu |
|
| 219 | + if ( version_compare( $wp_version, '3.7.2', '>' ) ) { |
|
| 220 | + $classes .= ' frm_38_trigger'; |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + return $classes; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + public static function load_lang() { |
|
| 227 | + load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + /** |
|
| 231 | + * Filter shortcodes in text widgets |
|
| 232 | + */ |
|
| 233 | + public static function widget_text_filter( $content ) { |
|
| 234 | + $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
| 235 | + return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + public static function widget_text_filter_callback( $matches ) { |
|
| 239 | + _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' ); |
|
| 240 | + return FrmAppHelper::widget_text_filter_callback( $matches ); |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + public static function front_head() { |
|
| 244 | + if ( is_multisite() ) { |
|
| 245 | + $old_db_version = get_option( 'frm_db_version' ); |
|
| 246 | + $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false; |
|
| 247 | + if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) || |
|
| 248 | + ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) { |
|
| 249 | + self::install( $old_db_version ); |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | 254 | public static function localize_script( $location ) { |
| 255 | 255 | _deprecated_function( __FUNCTION__, '2.0.9', 'FrmAppHelper::localize_script' ); |
@@ -309,72 +309,72 @@ discard block |
||
| 309 | 309 | wp_die(); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - public static function activation_install() { |
|
| 313 | - FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 314 | - FrmFormActionsController::actions_init(); |
|
| 315 | - self::install(); |
|
| 316 | - } |
|
| 312 | + public static function activation_install() { |
|
| 313 | + FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 314 | + FrmFormActionsController::actions_init(); |
|
| 315 | + self::install(); |
|
| 316 | + } |
|
| 317 | 317 | |
| 318 | - public static function install( $old_db_version = false ) { |
|
| 319 | - $frmdb = new FrmDb(); |
|
| 320 | - $frmdb->upgrade( $old_db_version ); |
|
| 321 | - } |
|
| 318 | + public static function install( $old_db_version = false ) { |
|
| 319 | + $frmdb = new FrmDb(); |
|
| 320 | + $frmdb->upgrade( $old_db_version ); |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | - public static function uninstall() { |
|
| 324 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 323 | + public static function uninstall() { |
|
| 324 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 325 | 325 | |
| 326 | - if ( current_user_can( 'administrator' ) ) { |
|
| 327 | - $frmdb = new FrmDb(); |
|
| 328 | - $frmdb->uninstall(); |
|
| 326 | + if ( current_user_can( 'administrator' ) ) { |
|
| 327 | + $frmdb = new FrmDb(); |
|
| 328 | + $frmdb->uninstall(); |
|
| 329 | 329 | |
| 330 | 330 | //disable the plugin and redirect after uninstall so the tables don't get added right back |
| 331 | 331 | deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false ); |
| 332 | 332 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
| 333 | - } else { |
|
| 334 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 335 | - wp_die( $frm_settings->admin_permission ); |
|
| 336 | - } |
|
| 337 | - wp_die(); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - public static function drop_tables( $tables ) { |
|
| 341 | - global $wpdb; |
|
| 342 | - $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 343 | - $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 344 | - $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 345 | - $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 346 | - return $tables; |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 350 | - public static function page_route( $content ) { |
|
| 351 | - global $post; |
|
| 352 | - |
|
| 353 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 354 | - if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 355 | - $content = FrmFormsController::page_preview(); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - return $content; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - public static function deauthorize() { |
|
| 362 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 363 | - |
|
| 364 | - delete_option( 'frmpro-credentials' ); |
|
| 365 | - delete_option( 'frmpro-authorized' ); |
|
| 366 | - delete_site_option( 'frmpro-credentials' ); |
|
| 367 | - delete_site_option( 'frmpro-authorized' ); |
|
| 368 | - wp_die(); |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - public static function get_form_shortcode( $atts ) { |
|
| 372 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 373 | - return FrmFormsController::get_form_shortcode( $atts ); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - public static function get_postbox_class() { |
|
| 377 | - _deprecated_function( __FUNCTION__, '2.0' ); |
|
| 378 | - return 'postbox-container'; |
|
| 379 | - } |
|
| 333 | + } else { |
|
| 334 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 335 | + wp_die( $frm_settings->admin_permission ); |
|
| 336 | + } |
|
| 337 | + wp_die(); |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + public static function drop_tables( $tables ) { |
|
| 341 | + global $wpdb; |
|
| 342 | + $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 343 | + $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 344 | + $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 345 | + $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 346 | + return $tables; |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 350 | + public static function page_route( $content ) { |
|
| 351 | + global $post; |
|
| 352 | + |
|
| 353 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 354 | + if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 355 | + $content = FrmFormsController::page_preview(); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + return $content; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + public static function deauthorize() { |
|
| 362 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 363 | + |
|
| 364 | + delete_option( 'frmpro-credentials' ); |
|
| 365 | + delete_option( 'frmpro-authorized' ); |
|
| 366 | + delete_site_option( 'frmpro-credentials' ); |
|
| 367 | + delete_site_option( 'frmpro-authorized' ); |
|
| 368 | + wp_die(); |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + public static function get_form_shortcode( $atts ) { |
|
| 372 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 373 | + return FrmFormsController::get_form_shortcode( $atts ); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + public static function get_postbox_class() { |
|
| 377 | + _deprecated_function( __FUNCTION__, '2.0' ); |
|
| 378 | + return 'postbox-container'; |
|
| 379 | + } |
|
| 380 | 380 | } |
@@ -42,51 +42,51 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | if ( $f->type == 'data' ) { |
| 44 | 44 | //get all fields from linked form |
| 45 | - if ( isset($f->field_options['form_select']) && is_numeric($f->field_options['form_select']) ) { |
|
| 46 | - $linked_form = FrmDb::get_var( $wpdb->prefix .'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' ); |
|
| 47 | - if ( ! in_array( $linked_form, $linked_forms ) ) { |
|
| 48 | - $linked_forms[] = $linked_form; |
|
| 45 | + if ( isset($f->field_options['form_select']) && is_numeric($f->field_options['form_select']) ) { |
|
| 46 | + $linked_form = FrmDb::get_var( $wpdb->prefix .'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' ); |
|
| 47 | + if ( ! in_array( $linked_form, $linked_forms ) ) { |
|
| 48 | + $linked_forms[] = $linked_form; |
|
| 49 | 49 | $linked_fields = FrmField::getAll( array( 'fi.type not' => FrmField::no_save_fields(), 'fi.form_id' => $linked_form ) ); |
| 50 | - $ldfe = ''; |
|
| 50 | + $ldfe = ''; |
|
| 51 | 51 | if ( $linked_fields ) { |
| 52 | 52 | foreach ( $linked_fields as $linked_field ) { |
| 53 | - FrmAppHelper::insert_opt_html( array( 'id' => $f->id . ' show=' . $linked_field->id, 'key' => $f->field_key . ' show=' . $linked_field->field_key, 'name' => $linked_field->name, 'type' => $linked_field->type ) ); |
|
| 54 | - |
|
| 55 | - $ldfe = $linked_field->id; |
|
| 56 | - unset($linked_field); |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - $dfe = $f->id; |
|
| 62 | - } |
|
| 63 | - unset($f); |
|
| 64 | - } |
|
| 65 | - } ?> |
|
| 53 | + FrmAppHelper::insert_opt_html( array( 'id' => $f->id . ' show=' . $linked_field->id, 'key' => $f->field_key . ' show=' . $linked_field->field_key, 'name' => $linked_field->name, 'type' => $linked_field->type ) ); |
|
| 54 | + |
|
| 55 | + $ldfe = $linked_field->id; |
|
| 56 | + unset($linked_field); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + $dfe = $f->id; |
|
| 62 | + } |
|
| 63 | + unset($f); |
|
| 64 | + } |
|
| 65 | + } ?> |
|
| 66 | 66 | </ul> |
| 67 | 67 | |
| 68 | 68 | <?php _e( 'Helpers', 'formidable' ) ?>: |
| 69 | 69 | <ul class="frm_code_list"> |
| 70 | 70 | <?php |
| 71 | - $col = 'one'; |
|
| 71 | + $col = 'one'; |
|
| 72 | 72 | foreach ( $entry_shortcodes as $skey => $sname ) { |
| 73 | 73 | if ( empty( $skey ) ) { |
| 74 | - $col = 'one'; |
|
| 75 | - echo '<li class="clear frm_block"></li>'; |
|
| 76 | - continue; |
|
| 77 | - } |
|
| 78 | - ?> |
|
| 74 | + $col = 'one'; |
|
| 75 | + echo '<li class="clear frm_block"></li>'; |
|
| 76 | + continue; |
|
| 77 | + } |
|
| 78 | + ?> |
|
| 79 | 79 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 80 | 80 | <a href="javascript:void(0)" class="frmbutton button <?php |
| 81 | 81 | echo ( in_array( $skey, array( 'siteurl', 'sitename', 'entry_count' ) ) ) ? 'show_before_content show_after_content' : ''; |
| 82 | - echo ( strpos( $skey, 'default-' ) === 0 ) ? 'hide_frm_not_email_subject' : ''; |
|
| 83 | - ?> frm_insert_code" data-code="<?php echo esc_attr( $skey ) ?>"><?php echo esc_html( $sname ) ?></a> |
|
| 82 | + echo ( strpos( $skey, 'default-' ) === 0 ) ? 'hide_frm_not_email_subject' : ''; |
|
| 83 | + ?> frm_insert_code" data-code="<?php echo esc_attr( $skey ) ?>"><?php echo esc_html( $sname ) ?></a> |
|
| 84 | 84 | </li> |
| 85 | 85 | <?php |
| 86 | - $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
| 87 | - unset($skey, $sname); |
|
| 88 | - } |
|
| 89 | - ?> |
|
| 86 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
| 87 | + unset($skey, $sname); |
|
| 88 | + } |
|
| 89 | + ?> |
|
| 90 | 90 | </ul> |
| 91 | 91 | </div> |
| 92 | 92 | |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | <ul class="alignleft"><li><?php _e( 'Fields from your form', 'formidable' ) ?>:</li></ul> |
| 100 | 100 | <ul class="frm_code_list frm_full_width"> |
| 101 | 101 | <?php if ( ! empty( $fields ) ) { |
| 102 | - foreach ( $fields as $f ) { |
|
| 102 | + foreach ( $fields as $f ) { |
|
| 103 | 103 | if ( FrmField::is_no_save_field( $f->type ) || ( $f->type == 'data' && ( ! isset( $f->field_options['data_type'] ) || $f->field_options['data_type'] == 'data' || $f->field_options['data_type'] == '' ) ) ) { |
| 104 | - continue; |
|
| 105 | - } |
|
| 106 | - ?> |
|
| 104 | + continue; |
|
| 105 | + } |
|
| 106 | + ?> |
|
| 107 | 107 | <li> |
| 108 | 108 | <a href="javascript:void(0)" class="frmids alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->id ) ?>]<?php esc_attr_e( 'Conditional text here', 'formidable' ) ?>[/if <?php echo esc_attr( $f->id ) ?>">[if <?php echo (int) $f->id ?>]</a> |
| 109 | 109 | <a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->field_key ) ?>]something[/if <?php echo esc_attr( $f->field_key ) ?>">[if <?php echo FrmAppHelper::truncate($f->field_key, 10) ?>]</a> |
@@ -111,30 +111,30 @@ discard block |
||
| 111 | 111 | </li> |
| 112 | 112 | <?php |
| 113 | 113 | |
| 114 | - if ( $f->type == 'user_id' ) { |
|
| 115 | - $uid = $f; |
|
| 116 | - } else if ( $f->type == 'file' ) { |
|
| 117 | - $file = $f; |
|
| 118 | - } |
|
| 119 | - unset($f); |
|
| 120 | - } |
|
| 121 | - } ?> |
|
| 114 | + if ( $f->type == 'user_id' ) { |
|
| 115 | + $uid = $f; |
|
| 116 | + } else if ( $f->type == 'file' ) { |
|
| 117 | + $file = $f; |
|
| 118 | + } |
|
| 119 | + unset($f); |
|
| 120 | + } |
|
| 121 | + } ?> |
|
| 122 | 122 | </ul> |
| 123 | 123 | |
| 124 | 124 | <p class="howto"><?php _e( 'Click a button below to insert sample logic into your view', 'formidable' ) ?></p> |
| 125 | 125 | <ul class="frm_code_list"> |
| 126 | 126 | <?php |
| 127 | - $col = 'one'; |
|
| 127 | + $col = 'one'; |
|
| 128 | 128 | foreach ( $cond_shortcodes as $skey => $sname ) { |
| 129 | - ?> |
|
| 129 | + ?> |
|
| 130 | 130 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 131 | 131 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="if 125 <?php echo esc_attr($skey) ?>][/if 125"><?php echo esc_html( $sname ) ?></a> |
| 132 | 132 | </li> |
| 133 | 133 | <?php |
| 134 | - $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
| 135 | - unset($skey, $sname); |
|
| 136 | - } |
|
| 137 | - ?> |
|
| 134 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
| 135 | + unset($skey, $sname); |
|
| 136 | + } |
|
| 137 | + ?> |
|
| 138 | 138 | </ul> |
| 139 | 139 | </div> |
| 140 | 140 | <?php } ?> |
@@ -142,17 +142,17 @@ discard block |
||
| 142 | 142 | <div id="frm-adv-info-tab" class="tabs-panel"> |
| 143 | 143 | <ul class="frm_code_list"> |
| 144 | 144 | <?php |
| 145 | - $col = 'one'; |
|
| 145 | + $col = 'one'; |
|
| 146 | 146 | foreach ( $adv_shortcodes as $skey => $sname ) { |
| 147 | - ?> |
|
| 147 | + ?> |
|
| 148 | 148 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 149 | 149 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code <?php echo is_array( $sname ) ? 'frm_help' : ''; ?>" data-code="125 <?php echo esc_attr( $skey ) ?>" <?php echo is_array( $sname ) ? 'title="'. esc_attr( $sname['title'] ) .'"' : ''; ?>><?php echo is_array( $sname ) ? $sname['label'] : $sname; ?></a> |
| 150 | 150 | </li> |
| 151 | 151 | <?php |
| 152 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 153 | - unset($skey, $sname); |
|
| 154 | - } |
|
| 155 | - ?> |
|
| 152 | + $col = ($col == 'one') ? 'two' : 'one'; |
|
| 153 | + unset($skey, $sname); |
|
| 154 | + } |
|
| 155 | + ?> |
|
| 156 | 156 | <?php if ( isset($file) ) { ?> |
| 157 | 157 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 158 | 158 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> size=thumbnail html=1"><?php _e( 'Image Size', 'formidable' ) ?></a> |
@@ -169,8 +169,8 @@ discard block |
||
| 169 | 169 | <div class="clear"></div> |
| 170 | 170 | <?php |
| 171 | 171 | |
| 172 | - if ( isset($uid) && ! empty($user_fields) ) { |
|
| 173 | - $col = 'one'; ?> |
|
| 172 | + if ( isset($uid) && ! empty($user_fields) ) { |
|
| 173 | + $col = 'one'; ?> |
|
| 174 | 174 | <p class="howto"><?php _e( 'Insert user information', 'formidable' ) ?></p> |
| 175 | 175 | <ul class="frm_code_list"> |
| 176 | 176 | <?php foreach ( $user_fields as $uk => $uf ) { ?> |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $uid->id . ' show="' . $uk . '"' ) ?>"><?php echo esc_html( $uf ) ?></a> |
| 179 | 179 | </li> |
| 180 | 180 | <?php |
| 181 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 182 | - unset($uf, $uk); |
|
| 183 | - } |
|
| 184 | - unset($uid); ?> |
|
| 181 | + $col = ($col == 'one') ? 'two' : 'one'; |
|
| 182 | + unset($uf, $uk); |
|
| 183 | + } |
|
| 184 | + unset($uid); ?> |
|
| 185 | 185 | </ul> |
| 186 | 186 | <?php } |
| 187 | 187 | |
| 188 | - if ( isset($repeat_field) ) { ?> |
|
| 188 | + if ( isset($repeat_field) ) { ?> |
|
| 189 | 189 | <div class="clear"></div> |
| 190 | 190 | <p class="howto"><?php _e( 'Repeating field options', 'formidable' ) ?></p> |
| 191 | 191 | <ul class="frm_code_list"> |
@@ -194,9 +194,9 @@ discard block |
||
| 194 | 194 | </li> |
| 195 | 195 | </ul> |
| 196 | 196 | <?php |
| 197 | - } |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - if ( isset($dfe) ) { ?> |
|
| 199 | + if ( isset($dfe) ) { ?> |
|
| 200 | 200 | |
| 201 | 201 | <div class="clear"></div> |
| 202 | 202 | <p class="howto"><?php _e( 'Dynamic field options', 'formidable' ) ?></p> |
@@ -215,8 +215,8 @@ discard block |
||
| 215 | 215 | </div> |
| 216 | 216 | |
| 217 | 217 | <?php |
| 218 | - if ( $settings_tab ) { |
|
| 219 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/mb_html_tab.php'); |
|
| 220 | - } |
|
| 221 | - ?> |
|
| 218 | + if ( $settings_tab ) { |
|
| 219 | + include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/mb_html_tab.php'); |
|
| 220 | + } |
|
| 221 | + ?> |
|
| 222 | 222 | </div> |
@@ -42,8 +42,8 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | if ( $f->type == 'data' ) { |
| 44 | 44 | //get all fields from linked form |
| 45 | - if ( isset($f->field_options['form_select']) && is_numeric($f->field_options['form_select']) ) { |
|
| 46 | - $linked_form = FrmDb::get_var( $wpdb->prefix .'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' ); |
|
| 45 | + if ( isset( $f->field_options['form_select'] ) && is_numeric( $f->field_options['form_select'] ) ) { |
|
| 46 | + $linked_form = FrmDb::get_var( $wpdb->prefix . 'frm_fields', array( 'id' => $f->field_options['form_select'] ), 'form_id' ); |
|
| 47 | 47 | if ( ! in_array( $linked_form, $linked_forms ) ) { |
| 48 | 48 | $linked_forms[] = $linked_form; |
| 49 | 49 | $linked_fields = FrmField::getAll( array( 'fi.type not' => FrmField::no_save_fields(), 'fi.form_id' => $linked_form ) ); |
@@ -53,14 +53,14 @@ discard block |
||
| 53 | 53 | FrmAppHelper::insert_opt_html( array( 'id' => $f->id . ' show=' . $linked_field->id, 'key' => $f->field_key . ' show=' . $linked_field->field_key, 'name' => $linked_field->name, 'type' => $linked_field->type ) ); |
| 54 | 54 | |
| 55 | 55 | $ldfe = $linked_field->id; |
| 56 | - unset($linked_field); |
|
| 56 | + unset( $linked_field ); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | $dfe = $f->id; |
| 62 | 62 | } |
| 63 | - unset($f); |
|
| 63 | + unset( $f ); |
|
| 64 | 64 | } |
| 65 | 65 | } ?> |
| 66 | 66 | </ul> |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | </li> |
| 85 | 85 | <?php |
| 86 | 86 | $col = ( $col == 'one' ) ? 'two' : 'one'; |
| 87 | - unset($skey, $sname); |
|
| 87 | + unset( $skey, $sname ); |
|
| 88 | 88 | } |
| 89 | 89 | ?> |
| 90 | 90 | </ul> |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | ?> |
| 107 | 107 | <li> |
| 108 | 108 | <a href="javascript:void(0)" class="frmids alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->id ) ?>]<?php esc_attr_e( 'Conditional text here', 'formidable' ) ?>[/if <?php echo esc_attr( $f->id ) ?>">[if <?php echo (int) $f->id ?>]</a> |
| 109 | - <a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->field_key ) ?>]something[/if <?php echo esc_attr( $f->field_key ) ?>">[if <?php echo FrmAppHelper::truncate($f->field_key, 10) ?>]</a> |
|
| 110 | - <a href="javascript:void(0)" class="frm_insert_code" data-code="<?php echo esc_attr($f->id) ?>"><?php echo FrmAppHelper::truncate($f->name, 60) ?></a> |
|
| 109 | + <a href="javascript:void(0)" class="frmkeys alignright frm_insert_code" data-code="if <?php echo esc_attr( $f->field_key ) ?>]something[/if <?php echo esc_attr( $f->field_key ) ?>">[if <?php echo FrmAppHelper::truncate( $f->field_key, 10 ) ?>]</a> |
|
| 110 | + <a href="javascript:void(0)" class="frm_insert_code" data-code="<?php echo esc_attr( $f->id ) ?>"><?php echo FrmAppHelper::truncate( $f->name, 60 ) ?></a> |
|
| 111 | 111 | </li> |
| 112 | 112 | <?php |
| 113 | 113 | |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | } else if ( $f->type == 'file' ) { |
| 117 | 117 | $file = $f; |
| 118 | 118 | } |
| 119 | - unset($f); |
|
| 119 | + unset( $f ); |
|
| 120 | 120 | } |
| 121 | 121 | } ?> |
| 122 | 122 | </ul> |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | foreach ( $cond_shortcodes as $skey => $sname ) { |
| 129 | 129 | ?> |
| 130 | 130 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 131 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="if 125 <?php echo esc_attr($skey) ?>][/if 125"><?php echo esc_html( $sname ) ?></a> |
|
| 131 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="if 125 <?php echo esc_attr( $skey ) ?>][/if 125"><?php echo esc_html( $sname ) ?></a> |
|
| 132 | 132 | </li> |
| 133 | 133 | <?php |
| 134 | 134 | $col = ( $col == 'one' ) ? 'two' : 'one'; |
| 135 | - unset($skey, $sname); |
|
| 135 | + unset( $skey, $sname ); |
|
| 136 | 136 | } |
| 137 | 137 | ?> |
| 138 | 138 | </ul> |
@@ -146,22 +146,22 @@ discard block |
||
| 146 | 146 | foreach ( $adv_shortcodes as $skey => $sname ) { |
| 147 | 147 | ?> |
| 148 | 148 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 149 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code <?php echo is_array( $sname ) ? 'frm_help' : ''; ?>" data-code="125 <?php echo esc_attr( $skey ) ?>" <?php echo is_array( $sname ) ? 'title="'. esc_attr( $sname['title'] ) .'"' : ''; ?>><?php echo is_array( $sname ) ? $sname['label'] : $sname; ?></a> |
|
| 149 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code <?php echo is_array( $sname ) ? 'frm_help' : ''; ?>" data-code="125 <?php echo esc_attr( $skey ) ?>" <?php echo is_array( $sname ) ? 'title="' . esc_attr( $sname['title'] ) . '"' : ''; ?>><?php echo is_array( $sname ) ? $sname['label'] : $sname; ?></a> |
|
| 150 | 150 | </li> |
| 151 | 151 | <?php |
| 152 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 153 | - unset($skey, $sname); |
|
| 152 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
| 153 | + unset( $skey, $sname ); |
|
| 154 | 154 | } |
| 155 | 155 | ?> |
| 156 | - <?php if ( isset($file) ) { ?> |
|
| 156 | + <?php if ( isset( $file ) ) { ?> |
|
| 157 | 157 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 158 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> size=thumbnail html=1"><?php _e( 'Image Size', 'formidable' ) ?></a> |
|
| 158 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ) ?> size=thumbnail html=1"><?php _e( 'Image Size', 'formidable' ) ?></a> |
|
| 159 | 159 | </li> |
| 160 | - <li class="frm_col_<?php echo $col = (($col == 'one') ? 'two' : 'one') ?>"> |
|
| 161 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> show=id"><?php _e( 'Image ID', 'formidable' ) ?></a> |
|
| 160 | + <li class="frm_col_<?php echo $col = ( ( $col == 'one' ) ? 'two' : 'one' ) ?>"> |
|
| 161 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ) ?> show=id"><?php _e( 'Image ID', 'formidable' ) ?></a> |
|
| 162 | 162 | </li> |
| 163 | - <li class="frm_col_<?php echo $col = (($col == 'one') ? 'two' : 'one') ?>"> |
|
| 164 | - <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr($file->id) ?> show=label"><?php _e( 'Image Name', 'formidable' ) ?></a> |
|
| 163 | + <li class="frm_col_<?php echo $col = ( ( $col == 'one' ) ? 'two' : 'one' ) ?>"> |
|
| 164 | + <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $file->id ) ?> show=label"><?php _e( 'Image Name', 'formidable' ) ?></a> |
|
| 165 | 165 | </li> |
| 166 | 166 | <?php } ?> |
| 167 | 167 | </ul> |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | <div class="clear"></div> |
| 170 | 170 | <?php |
| 171 | 171 | |
| 172 | - if ( isset($uid) && ! empty($user_fields) ) { |
|
| 172 | + if ( isset( $uid ) && ! empty( $user_fields ) ) { |
|
| 173 | 173 | $col = 'one'; ?> |
| 174 | 174 | <p class="howto"><?php _e( 'Insert user information', 'formidable' ) ?></p> |
| 175 | 175 | <ul class="frm_code_list"> |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $uid->id . ' show="' . $uk . '"' ) ?>"><?php echo esc_html( $uf ) ?></a> |
| 179 | 179 | </li> |
| 180 | 180 | <?php |
| 181 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 182 | - unset($uf, $uk); |
|
| 181 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
| 182 | + unset( $uf, $uk ); |
|
| 183 | 183 | } |
| 184 | - unset($uid); ?> |
|
| 184 | + unset( $uid ); ?> |
|
| 185 | 185 | </ul> |
| 186 | 186 | <?php } |
| 187 | 187 | |
| 188 | - if ( isset($repeat_field) ) { ?> |
|
| 188 | + if ( isset( $repeat_field ) ) { ?> |
|
| 189 | 189 | <div class="clear"></div> |
| 190 | 190 | <p class="howto"><?php _e( 'Repeating field options', 'formidable' ) ?></p> |
| 191 | 191 | <ul class="frm_code_list"> |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | <?php |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - if ( isset($dfe) ) { ?> |
|
| 199 | + if ( isset( $dfe ) ) { ?> |
|
| 200 | 200 | |
| 201 | 201 | <div class="clear"></div> |
| 202 | 202 | <p class="howto"><?php _e( 'Dynamic field options', 'formidable' ) ?></p> |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | <li class="frm_col_one"> |
| 205 | 205 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $dfe . ' show="created-at"' ) ?>"><?php _e( 'Creation Date', 'formidable' ) ?></a> |
| 206 | 206 | </li> |
| 207 | - <?php if ( isset($ldfe) ) { ?> |
|
| 207 | + <?php if ( isset( $ldfe ) ) { ?> |
|
| 208 | 208 | <li class="frm_col_two"> |
| 209 | 209 | <a href="javascript:void(0)" class="frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $dfe . ' show="' . $ldfe . '"' ) ?>"><?php _e( 'Field From Entry', 'formidable' ) ?></a> |
| 210 | 210 | </li> |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | |
| 217 | 217 | <?php |
| 218 | 218 | if ( $settings_tab ) { |
| 219 | - include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/mb_html_tab.php'); |
|
| 219 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/mb_html_tab.php' ); |
|
| 220 | 220 | } |
| 221 | 221 | ?> |
| 222 | 222 | </div> |
@@ -1,63 +1,63 @@ |
||
| 1 | 1 | <table class="form-table frm-no-margin"> |
| 2 | 2 | <tr> |
| 3 | - <th><label <?php FrmAppHelper::maybe_add_tooltip('email_to') ?>><?php _e( 'To', 'formidable' ) ?></label> |
|
| 3 | + <th><label <?php FrmAppHelper::maybe_add_tooltip( 'email_to' ) ?>><?php _e( 'To', 'formidable' ) ?></label> |
|
| 4 | 4 | </th> |
| 5 | - <td><input type="text" name="<?php echo esc_attr( $this->get_field_name('email_to') ) ?>" value="<?php echo esc_attr( $form_action->post_content['email_to'] ); ?>" class="frm_not_email_to frm_email_blur large-text <?php FrmAppHelper::maybe_add_tooltip('email_to', 'open') ?>" id="<?php echo esc_attr( $this->get_field_id('email_to') ) ?>" /> |
|
| 5 | + <td><input type="text" name="<?php echo esc_attr( $this->get_field_name( 'email_to' ) ) ?>" value="<?php echo esc_attr( $form_action->post_content['email_to'] ); ?>" class="frm_not_email_to frm_email_blur large-text <?php FrmAppHelper::maybe_add_tooltip( 'email_to', 'open' ) ?>" id="<?php echo esc_attr( $this->get_field_id( 'email_to' ) ) ?>" /> |
|
| 6 | 6 | </td> |
| 7 | 7 | <td class="frm_bcc_cc_container"> |
| 8 | 8 | <a href="javascript:void(0)" class="button frm_email_buttons frm_bcc_button <?php |
| 9 | - echo ( ! empty($form_action->post_content['bcc']) ? 'frm_hidden' : '' ); |
|
| 9 | + echo ( ! empty( $form_action->post_content['bcc'] ) ? 'frm_hidden' : '' ); |
|
| 10 | 10 | ?>" data-emailrow="bcc"><?php _e( 'BCC', 'formidable' ) ?></a> |
| 11 | 11 | <a href="javascript:void(0)" class="button frm_email_buttons frm_cc_button <?php |
| 12 | - echo ( ! empty($form_action->post_content['cc']) ? 'frm_hidden' : '' ); |
|
| 12 | + echo ( ! empty( $form_action->post_content['cc'] ) ? 'frm_hidden' : '' ); |
|
| 13 | 13 | ?>" data-emailrow="cc"><?php _e( 'CC', 'formidable' ) ?></a> |
| 14 | 14 | </td> |
| 15 | 15 | </tr> |
| 16 | -<tr id="frm_cc_row" class="<?php echo empty( $form_action->post_content['cc'] ) ? 'frm_hidden' : ''; ?>" > |
|
| 17 | - <th><label <?php FrmAppHelper::maybe_add_tooltip('cc') ?>><?php _e( 'CC', 'formidable' ) ?></label> |
|
| 16 | +<tr id="frm_cc_row" class="<?php echo empty( $form_action->post_content['cc'] ) ? 'frm_hidden' : ''; ?>" > |
|
| 17 | + <th><label <?php FrmAppHelper::maybe_add_tooltip( 'cc' ) ?>><?php _e( 'CC', 'formidable' ) ?></label> |
|
| 18 | 18 | </th> |
| 19 | 19 | <td class="frm_right_addon"> |
| 20 | - <input type="text" name="<?php echo esc_attr( $this->get_field_name('cc') ) ?>" value="<?php echo esc_attr( $form_action->post_content['cc'] ); ?>" class="frm_not_email_to large-text <?php FrmAppHelper::maybe_add_tooltip('cc', 'open') ?>" id="<?php echo esc_attr( $this->get_field_id('cc') ) ?>" /> |
|
| 20 | + <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'cc' ) ) ?>" value="<?php echo esc_attr( $form_action->post_content['cc'] ); ?>" class="frm_not_email_to large-text <?php FrmAppHelper::maybe_add_tooltip( 'cc', 'open' ) ?>" id="<?php echo esc_attr( $this->get_field_id( 'cc' ) ) ?>" /> |
|
| 21 | 21 | <a href="javascript:void(0)" class="frm_icon_font frm_remove_field frm_cancel1_icon" data-emailrow="cc"></a> |
| 22 | 22 | </td> |
| 23 | 23 | <td></td> |
| 24 | 24 | </tr> |
| 25 | -<tr id="frm_bcc_row" class="<?php echo empty( $form_action->post_content['bcc'] ) ? 'frm_hidden' : ''; ?>" > |
|
| 26 | - <th><label <?php FrmAppHelper::maybe_add_tooltip('bcc') ?>><?php _e( 'BCC', 'formidable' ) ?></label> |
|
| 25 | +<tr id="frm_bcc_row" class="<?php echo empty( $form_action->post_content['bcc'] ) ? 'frm_hidden' : ''; ?>" > |
|
| 26 | + <th><label <?php FrmAppHelper::maybe_add_tooltip( 'bcc' ) ?>><?php _e( 'BCC', 'formidable' ) ?></label> |
|
| 27 | 27 | </th> |
| 28 | 28 | <td class="frm_right_addon"> |
| 29 | - <input type="text" name="<?php echo esc_attr( $this->get_field_name('bcc') ) ?>" value="<?php echo esc_attr( $form_action->post_content['bcc'] ); ?>" class="frm_not_email_to large-text <?php FrmAppHelper::maybe_add_tooltip('bcc', 'open') ?>" id="<?php echo esc_attr( $this->get_field_id('bcc') ) ?>" /> |
|
| 29 | + <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'bcc' ) ) ?>" value="<?php echo esc_attr( $form_action->post_content['bcc'] ); ?>" class="frm_not_email_to large-text <?php FrmAppHelper::maybe_add_tooltip( 'bcc', 'open' ) ?>" id="<?php echo esc_attr( $this->get_field_id( 'bcc' ) ) ?>" /> |
|
| 30 | 30 | <a href="javascript:void(0)" class="frm_icon_font frm_remove_field frm_cancel1_icon" data-emailrow="bcc"></a> |
| 31 | 31 | </td> |
| 32 | 32 | <td></td> |
| 33 | 33 | </tr> |
| 34 | -<tr id="frm_reply_to_row" class="<?php echo empty( $form_action->post_content['reply_to'] ) ? 'frm_hidden' : ''; ?>"> |
|
| 35 | - <th><label <?php FrmAppHelper::maybe_add_tooltip('reply_to') ?>><?php _e( 'Reply to', 'formidable' ) ?></label> |
|
| 34 | +<tr id="frm_reply_to_row" class="<?php echo empty( $form_action->post_content['reply_to'] ) ? 'frm_hidden' : ''; ?>"> |
|
| 35 | + <th><label <?php FrmAppHelper::maybe_add_tooltip( 'reply_to' ) ?>><?php _e( 'Reply to', 'formidable' ) ?></label> |
|
| 36 | 36 | </th> |
| 37 | 37 | <td class="frm_right_addon"> |
| 38 | - <input type="text" name="<?php echo esc_attr( $this->get_field_name('reply_to') ) ?>" value="<?php echo esc_attr( $form_action->post_content['reply_to'] ); ?>" class="frm_not_email_to large-text <?php FrmAppHelper::maybe_add_tooltip('reply_to', 'open') ?>" id="<?php echo esc_attr( $this->get_field_id('reply_to') ) ?>" /> |
|
| 38 | + <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'reply_to' ) ) ?>" value="<?php echo esc_attr( $form_action->post_content['reply_to'] ); ?>" class="frm_not_email_to large-text <?php FrmAppHelper::maybe_add_tooltip( 'reply_to', 'open' ) ?>" id="<?php echo esc_attr( $this->get_field_id( 'reply_to' ) ) ?>" /> |
|
| 39 | 39 | <a href="javascript:void(0)" class="frm_icon_font frm_remove_field frm_cancel1_icon" data-emailrow="reply_to"></a> |
| 40 | 40 | </td> |
| 41 | 41 | <td></td> |
| 42 | 42 | </tr> |
| 43 | 43 | <tr> |
| 44 | - <th><label <?php FrmAppHelper::maybe_add_tooltip('from') ?>><?php _e( 'From', 'formidable' ) ?></label></th> |
|
| 45 | - <td><input type="text" name="<?php echo esc_attr( $this->get_field_name('from') ) ?>" value="<?php echo esc_attr( $form_action->post_content['from'] ); ?>" class="frm_not_email_to frm_email_blur large-text <?php FrmAppHelper::maybe_add_tooltip('from', 'open') ?>" id="<?php echo esc_attr( $this->get_field_id('from') ) ?>" /> |
|
| 44 | + <th><label <?php FrmAppHelper::maybe_add_tooltip( 'from' ) ?>><?php _e( 'From', 'formidable' ) ?></label></th> |
|
| 45 | + <td><input type="text" name="<?php echo esc_attr( $this->get_field_name( 'from' ) ) ?>" value="<?php echo esc_attr( $form_action->post_content['from'] ); ?>" class="frm_not_email_to frm_email_blur large-text <?php FrmAppHelper::maybe_add_tooltip( 'from', 'open' ) ?>" id="<?php echo esc_attr( $this->get_field_id( 'from' ) ) ?>" /> |
|
| 46 | 46 | </td> |
| 47 | - <td><a href="javascript:void(0)" class="button frm_email_buttons frm_reply_to_button <?php echo ( ! empty( $form_action->post_content['reply_to'] ) ? 'frm_hidden' : '' ) ?>" data-emailrow="reply_to"><?php _e( 'Reply To', 'formidable' ) ?></a></td> |
|
| 47 | + <td><a href="javascript:void(0)" class="button frm_email_buttons frm_reply_to_button <?php echo ( ! empty( $form_action->post_content['reply_to'] ) ? 'frm_hidden' : '' ) ?>" data-emailrow="reply_to"><?php _e( 'Reply To', 'formidable' ) ?></a></td> |
|
| 48 | 48 | </tr> |
| 49 | 49 | <tr> |
| 50 | 50 | <td colspan="3" class="frm_no_top_padding"> |
| 51 | - <p><label <?php FrmAppHelper::maybe_add_tooltip('email_subject', '', $form->name) ?>><?php _e( 'Subject', 'formidable' ) ?></label><br/> |
|
| 52 | - <input type="text" name="<?php echo esc_attr( $this->get_field_name('email_subject') ) ?>" class="frm_not_email_subject large-text <?php FrmAppHelper::maybe_add_tooltip('email_subject', 'open', $form->name) ?>" id="<?php echo esc_attr( $this->get_field_id('email_subject') ) ?>" size="55" value="<?php echo esc_attr( $form_action->post_content['email_subject'] ); ?>" /></p> |
|
| 51 | + <p><label <?php FrmAppHelper::maybe_add_tooltip( 'email_subject', '', $form->name ) ?>><?php _e( 'Subject', 'formidable' ) ?></label><br/> |
|
| 52 | + <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'email_subject' ) ) ?>" class="frm_not_email_subject large-text <?php FrmAppHelper::maybe_add_tooltip( 'email_subject', 'open', $form->name ) ?>" id="<?php echo esc_attr( $this->get_field_id( 'email_subject' ) ) ?>" size="55" value="<?php echo esc_attr( $form_action->post_content['email_subject'] ); ?>" /></p> |
|
| 53 | 53 | |
| 54 | 54 | <p><label><?php _e( 'Message', 'formidable' ) ?> </label><br/> |
| 55 | - <textarea name="<?php echo esc_attr( $this->get_field_name('email_message') ) ?>" class="frm_not_email_message large-text" id="<?php echo esc_attr( $this->get_field_id('email_message') ) ?>" cols="50" rows="5"><?php echo FrmAppHelper::esc_textarea($form_action->post_content['email_message']) ?></textarea></p> |
|
| 55 | + <textarea name="<?php echo esc_attr( $this->get_field_name( 'email_message' ) ) ?>" class="frm_not_email_message large-text" id="<?php echo esc_attr( $this->get_field_id( 'email_message' ) ) ?>" cols="50" rows="5"><?php echo FrmAppHelper::esc_textarea( $form_action->post_content['email_message'] ) ?></textarea></p> |
|
| 56 | 56 | |
| 57 | 57 | <h4><?php _e( 'Options', 'formidable' ) ?> </h4> |
| 58 | - <label for="<?php echo esc_attr( $this->get_field_id('inc_user_info') ) ?>"><input type="checkbox" name="<?php echo esc_attr( $this->get_field_name('inc_user_info') ) ?>" class="frm_not_inc_user_info" id="<?php echo esc_attr( $this->get_field_id('inc_user_info') ) ?>" value="1" <?php checked( $form_action->post_content['inc_user_info'], 1 ); ?> /> <?php _e( 'Append IP Address, Browser, and Referring URL to message', 'formidable' ) ?></label> |
|
| 58 | + <label for="<?php echo esc_attr( $this->get_field_id( 'inc_user_info' ) ) ?>"><input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'inc_user_info' ) ) ?>" class="frm_not_inc_user_info" id="<?php echo esc_attr( $this->get_field_id( 'inc_user_info' ) ) ?>" value="1" <?php checked( $form_action->post_content['inc_user_info'], 1 ); ?> /> <?php _e( 'Append IP Address, Browser, and Referring URL to message', 'formidable' ) ?></label> |
|
| 59 | 59 | |
| 60 | - <p><label for="<?php echo esc_attr( $this->get_field_id('plain_text') ) ?>"><input type="checkbox" name="<?php echo esc_attr( $this->get_field_name('plain_text') ) ?>" id="<?php echo esc_attr( $this->get_field_id('plain_text') ) ?>" value="1" <?php checked( $form_action->post_content['plain_text'], 1 ); ?> /> <?php _e( 'Send Emails in Plain Text', 'formidable' ) ?></label></p> |
|
| 60 | + <p><label for="<?php echo esc_attr( $this->get_field_id( 'plain_text' ) ) ?>"><input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'plain_text' ) ) ?>" id="<?php echo esc_attr( $this->get_field_id( 'plain_text' ) ) ?>" value="1" <?php checked( $form_action->post_content['plain_text'], 1 ); ?> /> <?php _e( 'Send Emails in Plain Text', 'formidable' ) ?></label></p> |
|
| 61 | 61 | </td> |
| 62 | 62 | </tr> |
| 63 | 63 | </table> |