@@ -13,50 +13,50 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public static $plug_version = '3.0.05'; |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @since 1.07.02 |
|
| 18 | - * |
|
| 19 | - * @param none |
|
| 20 | - * @return string The version of this plugin |
|
| 21 | - */ |
|
| 22 | - public static function plugin_version() { |
|
| 23 | - return self::$plug_version; |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - public static function plugin_folder() { |
|
| 27 | - return basename(self::plugin_path()); |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - public static function plugin_path() { |
|
| 31 | - return dirname(dirname(dirname(__FILE__))); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - public static function plugin_url() { |
|
| 35 | - //prevously FRM_URL constant |
|
| 16 | + /** |
|
| 17 | + * @since 1.07.02 |
|
| 18 | + * |
|
| 19 | + * @param none |
|
| 20 | + * @return string The version of this plugin |
|
| 21 | + */ |
|
| 22 | + public static function plugin_version() { |
|
| 23 | + return self::$plug_version; |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + public static function plugin_folder() { |
|
| 27 | + return basename(self::plugin_path()); |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + public static function plugin_path() { |
|
| 31 | + return dirname(dirname(dirname(__FILE__))); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + public static function plugin_url() { |
|
| 35 | + //prevously FRM_URL constant |
|
| 36 | 36 | return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | public static function relative_plugin_url() { |
| 40 | 40 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @return string Site URL |
|
| 45 | - */ |
|
| 46 | - public static function site_url() { |
|
| 47 | - return site_url(); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * Get the name of this site |
|
| 52 | - * Used for [sitename] shortcode |
|
| 53 | - * |
|
| 54 | - * @since 2.0 |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 57 | - public static function site_name() { |
|
| 58 | - return get_option('blogname'); |
|
| 59 | - } |
|
| 43 | + /** |
|
| 44 | + * @return string Site URL |
|
| 45 | + */ |
|
| 46 | + public static function site_url() { |
|
| 47 | + return site_url(); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * Get the name of this site |
|
| 52 | + * Used for [sitename] shortcode |
|
| 53 | + * |
|
| 54 | + * @since 2.0 |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | + public static function site_name() { |
|
| 58 | + return get_option('blogname'); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | 61 | public static function make_affiliate_url( $url ) { |
| 62 | 62 | $affiliate_id = self::get_affiliate(); |
@@ -71,21 +71,21 @@ discard block |
||
| 71 | 71 | return absint( apply_filters( 'frm_affiliate_id', 0 ) ); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Get the Formidable settings |
|
| 76 | - * |
|
| 77 | - * @since 2.0 |
|
| 78 | - * |
|
| 79 | - * @param None |
|
| 80 | - * @return FrmSettings $frm_setings |
|
| 81 | - */ |
|
| 82 | - public static function get_settings() { |
|
| 83 | - global $frm_settings; |
|
| 84 | - if ( empty($frm_settings) ) { |
|
| 85 | - $frm_settings = new FrmSettings(); |
|
| 86 | - } |
|
| 87 | - return $frm_settings; |
|
| 88 | - } |
|
| 74 | + /** |
|
| 75 | + * Get the Formidable settings |
|
| 76 | + * |
|
| 77 | + * @since 2.0 |
|
| 78 | + * |
|
| 79 | + * @param None |
|
| 80 | + * @return FrmSettings $frm_setings |
|
| 81 | + */ |
|
| 82 | + public static function get_settings() { |
|
| 83 | + global $frm_settings; |
|
| 84 | + if ( empty($frm_settings) ) { |
|
| 85 | + $frm_settings = new FrmSettings(); |
|
| 86 | + } |
|
| 87 | + return $frm_settings; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | public static function get_menu_name() { |
| 91 | 91 | $frm_settings = FrmAppHelper::get_settings(); |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | return ! $frm_settings->no_ips; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public static function pro_is_installed() { |
|
| 104 | - return apply_filters('frm_pro_installed', false); |
|
| 105 | - } |
|
| 103 | + public static function pro_is_installed() { |
|
| 104 | + return apply_filters('frm_pro_installed', false); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | public static function is_formidable_admin() { |
| 108 | 108 | $page = self::simple_get( 'page', 'sanitize_title' ); |
@@ -119,50 +119,50 @@ discard block |
||
| 119 | 119 | return $is_formidable; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - /** |
|
| 123 | - * Check for certain page in Formidable settings |
|
| 124 | - * |
|
| 125 | - * @since 2.0 |
|
| 126 | - * |
|
| 127 | - * @param string $page The name of the page to check |
|
| 128 | - * @return boolean |
|
| 129 | - */ |
|
| 122 | + /** |
|
| 123 | + * Check for certain page in Formidable settings |
|
| 124 | + * |
|
| 125 | + * @since 2.0 |
|
| 126 | + * |
|
| 127 | + * @param string $page The name of the page to check |
|
| 128 | + * @return boolean |
|
| 129 | + */ |
|
| 130 | 130 | public static function is_admin_page( $page = 'formidable' ) { |
| 131 | - global $pagenow; |
|
| 131 | + global $pagenow; |
|
| 132 | 132 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 133 | - if ( $pagenow ) { |
|
| 133 | + if ( $pagenow ) { |
|
| 134 | 134 | // allow this to be true during ajax load i.e. ajax form builder loading |
| 135 | 135 | return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page; |
| 136 | - } |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | return is_admin() && $get_page == $page; |
| 139 | - } |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * Check for the form preview page |
|
| 143 | - * |
|
| 144 | - * @since 2.0 |
|
| 145 | - * |
|
| 146 | - * @param None |
|
| 147 | - * @return boolean |
|
| 148 | - */ |
|
| 149 | - public static function is_preview_page() { |
|
| 150 | - global $pagenow; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * Check for the form preview page |
|
| 143 | + * |
|
| 144 | + * @since 2.0 |
|
| 145 | + * |
|
| 146 | + * @param None |
|
| 147 | + * @return boolean |
|
| 148 | + */ |
|
| 149 | + public static function is_preview_page() { |
|
| 150 | + global $pagenow; |
|
| 151 | 151 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
| 152 | 152 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 153 | - } |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Check for ajax except the form preview page |
|
| 157 | - * |
|
| 158 | - * @since 2.0 |
|
| 159 | - * |
|
| 160 | - * @param None |
|
| 161 | - * @return boolean |
|
| 162 | - */ |
|
| 163 | - public static function doing_ajax() { |
|
| 164 | - return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 165 | - } |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Check for ajax except the form preview page |
|
| 157 | + * |
|
| 158 | + * @since 2.0 |
|
| 159 | + * |
|
| 160 | + * @param None |
|
| 161 | + * @return boolean |
|
| 162 | + */ |
|
| 163 | + public static function doing_ajax() { |
|
| 164 | + return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | 167 | public static function js_suffix() { |
| 168 | 168 | return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
@@ -189,81 +189,81 @@ discard block |
||
| 189 | 189 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * Check if on an admin page |
|
| 194 | - * |
|
| 195 | - * @since 2.0 |
|
| 196 | - * |
|
| 197 | - * @param None |
|
| 198 | - * @return boolean |
|
| 199 | - */ |
|
| 200 | - public static function is_admin() { |
|
| 201 | - return is_admin() && ! self::wp_doing_ajax(); |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - /** |
|
| 205 | - * Check if value contains blank value or empty array |
|
| 206 | - * |
|
| 207 | - * @since 2.0 |
|
| 208 | - * @param mixed $value - value to check |
|
| 192 | + /** |
|
| 193 | + * Check if on an admin page |
|
| 194 | + * |
|
| 195 | + * @since 2.0 |
|
| 196 | + * |
|
| 197 | + * @param None |
|
| 198 | + * @return boolean |
|
| 199 | + */ |
|
| 200 | + public static function is_admin() { |
|
| 201 | + return is_admin() && ! self::wp_doing_ajax(); |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + /** |
|
| 205 | + * Check if value contains blank value or empty array |
|
| 206 | + * |
|
| 207 | + * @since 2.0 |
|
| 208 | + * @param mixed $value - value to check |
|
| 209 | 209 | * @param string |
| 210 | - * @return boolean |
|
| 211 | - */ |
|
| 212 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 213 | - return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 217 | - return ! self::is_empty_value( $value, $empty ); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Get any value from the $_SERVER |
|
| 222 | - * |
|
| 223 | - * @since 2.0 |
|
| 224 | - * @param string $value |
|
| 225 | - * @return string |
|
| 226 | - */ |
|
| 210 | + * @return boolean |
|
| 211 | + */ |
|
| 212 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 213 | + return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 217 | + return ! self::is_empty_value( $value, $empty ); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Get any value from the $_SERVER |
|
| 222 | + * |
|
| 223 | + * @since 2.0 |
|
| 224 | + * @param string $value |
|
| 225 | + * @return string |
|
| 226 | + */ |
|
| 227 | 227 | public static function get_server_value( $value ) { |
| 228 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Check for the IP address in several places |
|
| 233 | - * Used by [ip] shortcode |
|
| 234 | - * |
|
| 235 | - * @return string The IP address of the current user |
|
| 236 | - */ |
|
| 237 | - public static function get_ip_address() { |
|
| 228 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Check for the IP address in several places |
|
| 233 | + * Used by [ip] shortcode |
|
| 234 | + * |
|
| 235 | + * @return string The IP address of the current user |
|
| 236 | + */ |
|
| 237 | + public static function get_ip_address() { |
|
| 238 | 238 | $ip = ''; |
| 239 | 239 | foreach ( array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR' ) as $key ) { |
| 240 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 241 | - continue; |
|
| 242 | - } |
|
| 240 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 241 | + continue; |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 245 | - $ip = trim($ip); // just to be safe |
|
| 244 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 245 | + $ip = trim($ip); // just to be safe |
|
| 246 | 246 | |
| 247 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 248 | - return sanitize_text_field( $ip ); |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - } |
|
| 247 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 248 | + return sanitize_text_field( $ip ); |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | 253 | return sanitize_text_field( $ip ); |
| 254 | - } |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 257 | - if ( strpos($param, '[') ) { |
|
| 258 | - $params = explode('[', $param); |
|
| 259 | - $param = $params[0]; |
|
| 260 | - } |
|
| 256 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 257 | + if ( strpos($param, '[') ) { |
|
| 258 | + $params = explode('[', $param); |
|
| 259 | + $param = $params[0]; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | 262 | if ( $src == 'get' ) { |
| 263 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 264 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 265 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 266 | - } |
|
| 263 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 264 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 265 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 266 | + } |
|
| 267 | 267 | self::sanitize_value( $sanitize, $value ); |
| 268 | 268 | } else { |
| 269 | 269 | $value = self::get_simple_request( array( |
@@ -275,18 +275,18 @@ discard block |
||
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 278 | - foreach ( $params as $k => $p ) { |
|
| 279 | - if ( ! $k || ! is_array($value) ) { |
|
| 280 | - continue; |
|
| 281 | - } |
|
| 278 | + foreach ( $params as $k => $p ) { |
|
| 279 | + if ( ! $k || ! is_array($value) ) { |
|
| 280 | + continue; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | - $p = trim($p, ']'); |
|
| 284 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 285 | - } |
|
| 286 | - } |
|
| 283 | + $p = trim($p, ']'); |
|
| 284 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - return $value; |
|
| 289 | - } |
|
| 288 | + return $value; |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | 291 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
| 292 | 292 | return self::get_simple_request( array( |
@@ -350,12 +350,12 @@ discard block |
||
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 354 | - * |
|
| 355 | - * @since 2.0.8 |
|
| 356 | - * @param string $value |
|
| 357 | - * @return string $value |
|
| 358 | - */ |
|
| 353 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 354 | + * |
|
| 355 | + * @since 2.0.8 |
|
| 356 | + * @param string $value |
|
| 357 | + * @return string $value |
|
| 358 | + */ |
|
| 359 | 359 | public static function preserve_backslashes( $value ) { |
| 360 | 360 | // If backslashes have already been added, don't add them again |
| 361 | 361 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -377,14 +377,14 @@ discard block |
||
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | |
| 380 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 381 | - $temp_values = $values; |
|
| 382 | - foreach ( $temp_values as $k => $val ) { |
|
| 383 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 380 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 381 | + $temp_values = $values; |
|
| 382 | + foreach ( $temp_values as $k => $val ) { |
|
| 383 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 384 | 384 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 385 | - } |
|
| 386 | - } |
|
| 387 | - } |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + } |
|
| 388 | 388 | |
| 389 | 389 | public static function sanitize_array( &$values ) { |
| 390 | 390 | $temp_values = $values; |
@@ -512,39 +512,39 @@ discard block |
||
| 512 | 512 | ); |
| 513 | 513 | } |
| 514 | 514 | |
| 515 | - /** |
|
| 516 | - * Used when switching the action for a bulk action |
|
| 517 | - * @since 2.0 |
|
| 518 | - */ |
|
| 519 | - public static function remove_get_action() { |
|
| 520 | - if ( ! isset($_GET) ) { |
|
| 521 | - return; |
|
| 522 | - } |
|
| 515 | + /** |
|
| 516 | + * Used when switching the action for a bulk action |
|
| 517 | + * @since 2.0 |
|
| 518 | + */ |
|
| 519 | + public static function remove_get_action() { |
|
| 520 | + if ( ! isset($_GET) ) { |
|
| 521 | + return; |
|
| 522 | + } |
|
| 523 | 523 | |
| 524 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 525 | - if ( ! empty( $new_action ) ) { |
|
| 524 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 525 | + if ( ! empty( $new_action ) ) { |
|
| 526 | 526 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 527 | - } |
|
| 528 | - } |
|
| 527 | + } |
|
| 528 | + } |
|
| 529 | 529 | |
| 530 | - /** |
|
| 531 | - * Check the WP query for a parameter |
|
| 532 | - * |
|
| 533 | - * @since 2.0 |
|
| 534 | - * @return string|array |
|
| 535 | - */ |
|
| 536 | - public static function get_query_var( $value, $param ) { |
|
| 537 | - if ( $value != '' ) { |
|
| 538 | - return $value; |
|
| 539 | - } |
|
| 530 | + /** |
|
| 531 | + * Check the WP query for a parameter |
|
| 532 | + * |
|
| 533 | + * @since 2.0 |
|
| 534 | + * @return string|array |
|
| 535 | + */ |
|
| 536 | + public static function get_query_var( $value, $param ) { |
|
| 537 | + if ( $value != '' ) { |
|
| 538 | + return $value; |
|
| 539 | + } |
|
| 540 | 540 | |
| 541 | - global $wp_query; |
|
| 542 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 543 | - $value = $wp_query->query_vars[ $param ]; |
|
| 544 | - } |
|
| 541 | + global $wp_query; |
|
| 542 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 543 | + $value = $wp_query->query_vars[ $param ]; |
|
| 544 | + } |
|
| 545 | 545 | |
| 546 | - return $value; |
|
| 547 | - } |
|
| 546 | + return $value; |
|
| 547 | + } |
|
| 548 | 548 | |
| 549 | 549 | /** |
| 550 | 550 | * @since 3.0 |
@@ -566,16 +566,16 @@ discard block |
||
| 566 | 566 | } |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - /** |
|
| 570 | - * @param string $type |
|
| 571 | - */ |
|
| 572 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 573 | - // only load the form hooks once |
|
| 569 | + /** |
|
| 570 | + * @param string $type |
|
| 571 | + */ |
|
| 572 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 573 | + // only load the form hooks once |
|
| 574 | 574 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 575 | - if ( ! $hooks_loaded ) { |
|
| 575 | + if ( ! $hooks_loaded ) { |
|
| 576 | 576 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 577 | - } |
|
| 578 | - } |
|
| 577 | + } |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | 580 | /** |
| 581 | 581 | * Save all front-end js scripts into a single file |
@@ -597,26 +597,26 @@ discard block |
||
| 597 | 597 | $new_file->combine_files( $files ); |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - /** |
|
| 601 | - * Check a value from a shortcode to see if true or false. |
|
| 602 | - * True when value is 1, true, 'true', 'yes' |
|
| 603 | - * |
|
| 604 | - * @since 1.07.10 |
|
| 605 | - * |
|
| 606 | - * @param string $value The value to compare |
|
| 607 | - * @return boolean True or False |
|
| 608 | - */ |
|
| 600 | + /** |
|
| 601 | + * Check a value from a shortcode to see if true or false. |
|
| 602 | + * True when value is 1, true, 'true', 'yes' |
|
| 603 | + * |
|
| 604 | + * @since 1.07.10 |
|
| 605 | + * |
|
| 606 | + * @param string $value The value to compare |
|
| 607 | + * @return boolean True or False |
|
| 608 | + */ |
|
| 609 | 609 | public static function is_true( $value ) { |
| 610 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 611 | - } |
|
| 610 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 611 | + } |
|
| 612 | 612 | |
| 613 | - /** |
|
| 614 | - * Used to filter shortcode in text widgets |
|
| 615 | - */ |
|
| 616 | - public static function widget_text_filter_callback( $matches ) { |
|
| 613 | + /** |
|
| 614 | + * Used to filter shortcode in text widgets |
|
| 615 | + */ |
|
| 616 | + public static function widget_text_filter_callback( $matches ) { |
|
| 617 | 617 | _deprecated_function( __METHOD__, '2.5.4' ); |
| 618 | - return do_shortcode( $matches[0] ); |
|
| 619 | - } |
|
| 618 | + return do_shortcode( $matches[0] ); |
|
| 619 | + } |
|
| 620 | 620 | |
| 621 | 621 | public static function get_pages() { |
| 622 | 622 | return get_posts( array( |
@@ -628,10 +628,10 @@ discard block |
||
| 628 | 628 | ) ); |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 632 | - $pages = self::get_pages(); |
|
| 631 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 632 | + $pages = self::get_pages(); |
|
| 633 | 633 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 634 | - ?> |
|
| 634 | + ?> |
|
| 635 | 635 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
| 636 | 636 | <option value=""> </option> |
| 637 | 637 | <?php foreach ( $pages as $page ) { ?> |
@@ -641,16 +641,16 @@ discard block |
||
| 641 | 641 | <?php } ?> |
| 642 | 642 | </select> |
| 643 | 643 | <?php |
| 644 | - } |
|
| 644 | + } |
|
| 645 | 645 | |
| 646 | 646 | public static function post_edit_link( $post_id ) { |
| 647 | - $post = get_post($post_id); |
|
| 648 | - if ( $post ) { |
|
| 647 | + $post = get_post($post_id); |
|
| 648 | + if ( $post ) { |
|
| 649 | 649 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 650 | 650 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 651 | - } |
|
| 652 | - return ''; |
|
| 653 | - } |
|
| 651 | + } |
|
| 652 | + return ''; |
|
| 653 | + } |
|
| 654 | 654 | |
| 655 | 655 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 656 | 656 | ?> |
@@ -661,87 +661,87 @@ discard block |
||
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | public static function roles_options( $capability ) { |
| 664 | - global $frm_vars; |
|
| 665 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 666 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 667 | - } else { |
|
| 668 | - $editable_roles = get_editable_roles(); |
|
| 669 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 670 | - } |
|
| 671 | - |
|
| 672 | - foreach ( $editable_roles as $role => $details ) { |
|
| 664 | + global $frm_vars; |
|
| 665 | + if ( isset($frm_vars['editable_roles']) ) { |
|
| 666 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 667 | + } else { |
|
| 668 | + $editable_roles = get_editable_roles(); |
|
| 669 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 670 | + } |
|
| 671 | + |
|
| 672 | + foreach ( $editable_roles as $role => $details ) { |
|
| 673 | 673 | $name = translate_user_role( $details['name'] ); |
| 674 | 674 | ?> |
| 675 | 675 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
| 676 | 676 | <?php |
| 677 | - unset($role, $details); |
|
| 678 | - } |
|
| 679 | - } |
|
| 677 | + unset($role, $details); |
|
| 678 | + } |
|
| 679 | + } |
|
| 680 | 680 | |
| 681 | 681 | public static function frm_capabilities( $type = 'auto' ) { |
| 682 | - $cap = array( |
|
| 683 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 684 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 685 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 686 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 687 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 688 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 689 | - ); |
|
| 682 | + $cap = array( |
|
| 683 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 684 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 685 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 686 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 687 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 688 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 689 | + ); |
|
| 690 | 690 | |
| 691 | 691 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 692 | - return $cap; |
|
| 693 | - } |
|
| 692 | + return $cap; |
|
| 693 | + } |
|
| 694 | 694 | |
| 695 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 696 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 697 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 698 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 695 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 696 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 697 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 698 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 699 | 699 | |
| 700 | - return $cap; |
|
| 701 | - } |
|
| 700 | + return $cap; |
|
| 701 | + } |
|
| 702 | 702 | |
| 703 | 703 | public static function user_has_permission( $needed_role ) { |
| 704 | - if ( $needed_role == '-1' ) { |
|
| 705 | - return false; |
|
| 704 | + if ( $needed_role == '-1' ) { |
|
| 705 | + return false; |
|
| 706 | 706 | } |
| 707 | 707 | |
| 708 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 709 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 710 | - return true; |
|
| 711 | - } |
|
| 708 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 709 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 710 | + return true; |
|
| 711 | + } |
|
| 712 | 712 | |
| 713 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 714 | - foreach ( $roles as $role ) { |
|
| 713 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 714 | + foreach ( $roles as $role ) { |
|
| 715 | 715 | if ( current_user_can( $role ) ) { |
| 716 | - return true; |
|
| 716 | + return true; |
|
| 717 | 717 | } |
| 718 | - if ( $role == $needed_role ) { |
|
| 719 | - break; |
|
| 718 | + if ( $role == $needed_role ) { |
|
| 719 | + break; |
|
| 720 | 720 | } |
| 721 | - } |
|
| 722 | - return false; |
|
| 723 | - } |
|
| 724 | - |
|
| 725 | - /** |
|
| 726 | - * Make sure administrators can see Formidable menu |
|
| 727 | - * |
|
| 728 | - * @since 2.0 |
|
| 729 | - */ |
|
| 730 | - public static function maybe_add_permissions() { |
|
| 721 | + } |
|
| 722 | + return false; |
|
| 723 | + } |
|
| 724 | + |
|
| 725 | + /** |
|
| 726 | + * Make sure administrators can see Formidable menu |
|
| 727 | + * |
|
| 728 | + * @since 2.0 |
|
| 729 | + */ |
|
| 730 | + public static function maybe_add_permissions() { |
|
| 731 | 731 | self::force_capability( 'frm_view_entries' ); |
| 732 | 732 | |
| 733 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 734 | - return; |
|
| 735 | - } |
|
| 733 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 734 | + return; |
|
| 735 | + } |
|
| 736 | 736 | |
| 737 | 737 | $user_id = get_current_user_id(); |
| 738 | 738 | $user = new WP_User( $user_id ); |
| 739 | - $frm_roles = self::frm_capabilities(); |
|
| 740 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 739 | + $frm_roles = self::frm_capabilities(); |
|
| 740 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 741 | 741 | $user->add_cap( $frm_role ); |
| 742 | - unset($frm_role, $frm_role_description); |
|
| 743 | - } |
|
| 744 | - } |
|
| 742 | + unset($frm_role, $frm_role_description); |
|
| 743 | + } |
|
| 744 | + } |
|
| 745 | 745 | |
| 746 | 746 | /** |
| 747 | 747 | * Make sure admins have permission to see the menu items |
@@ -757,28 +757,28 @@ discard block |
||
| 757 | 757 | } |
| 758 | 758 | } |
| 759 | 759 | |
| 760 | - /** |
|
| 761 | - * Check if the user has permision for action. |
|
| 762 | - * Return permission message and stop the action if no permission |
|
| 763 | - * @since 2.0 |
|
| 764 | - * @param string $permission |
|
| 765 | - */ |
|
| 760 | + /** |
|
| 761 | + * Check if the user has permision for action. |
|
| 762 | + * Return permission message and stop the action if no permission |
|
| 763 | + * @since 2.0 |
|
| 764 | + * @param string $permission |
|
| 765 | + */ |
|
| 766 | 766 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 767 | - $permission_error = self::permission_nonce_error($permission); |
|
| 768 | - if ( $permission_error !== false ) { |
|
| 769 | - if ( 'hide' == $show_message ) { |
|
| 770 | - $permission_error = ''; |
|
| 771 | - } |
|
| 772 | - wp_die($permission_error); |
|
| 773 | - } |
|
| 774 | - } |
|
| 775 | - |
|
| 776 | - /** |
|
| 777 | - * Check user permission and nonce |
|
| 778 | - * @since 2.0 |
|
| 779 | - * @param string $permission |
|
| 780 | - * @return false|string The permission message or false if allowed |
|
| 781 | - */ |
|
| 767 | + $permission_error = self::permission_nonce_error($permission); |
|
| 768 | + if ( $permission_error !== false ) { |
|
| 769 | + if ( 'hide' == $show_message ) { |
|
| 770 | + $permission_error = ''; |
|
| 771 | + } |
|
| 772 | + wp_die($permission_error); |
|
| 773 | + } |
|
| 774 | + } |
|
| 775 | + |
|
| 776 | + /** |
|
| 777 | + * Check user permission and nonce |
|
| 778 | + * @since 2.0 |
|
| 779 | + * @param string $permission |
|
| 780 | + * @return false|string The permission message or false if allowed |
|
| 781 | + */ |
|
| 782 | 782 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 783 | 783 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 784 | 784 | $frm_settings = self::get_settings(); |
@@ -786,23 +786,23 @@ discard block |
||
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | $error = false; |
| 789 | - if ( empty($nonce_name) ) { |
|
| 790 | - return $error; |
|
| 791 | - } |
|
| 789 | + if ( empty($nonce_name) ) { |
|
| 790 | + return $error; |
|
| 791 | + } |
|
| 792 | 792 | |
| 793 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 794 | - $frm_settings = self::get_settings(); |
|
| 795 | - $error = $frm_settings->admin_permission; |
|
| 796 | - } |
|
| 793 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 794 | + $frm_settings = self::get_settings(); |
|
| 795 | + $error = $frm_settings->admin_permission; |
|
| 796 | + } |
|
| 797 | 797 | |
| 798 | - return $error; |
|
| 799 | - } |
|
| 798 | + return $error; |
|
| 799 | + } |
|
| 800 | 800 | |
| 801 | - public static function checked( $values, $current ) { |
|
| 801 | + public static function checked( $values, $current ) { |
|
| 802 | 802 | if ( self::check_selected( $values, $current ) ) { |
| 803 | - echo ' checked="checked"'; |
|
| 803 | + echo ' checked="checked"'; |
|
| 804 | 804 | } |
| 805 | - } |
|
| 805 | + } |
|
| 806 | 806 | |
| 807 | 807 | public static function check_selected( $values, $current ) { |
| 808 | 808 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -840,24 +840,24 @@ discard block |
||
| 840 | 840 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 841 | 841 | } |
| 842 | 842 | |
| 843 | - /** |
|
| 844 | - * Flatten a multi-dimensional array |
|
| 845 | - */ |
|
| 843 | + /** |
|
| 844 | + * Flatten a multi-dimensional array |
|
| 845 | + */ |
|
| 846 | 846 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 847 | - $return = array(); |
|
| 848 | - foreach ( $array as $key => $value ) { |
|
| 849 | - if ( is_array($value) ) { |
|
| 847 | + $return = array(); |
|
| 848 | + foreach ( $array as $key => $value ) { |
|
| 849 | + if ( is_array($value) ) { |
|
| 850 | 850 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 851 | - } else { |
|
| 851 | + } else { |
|
| 852 | 852 | if ( $keys == 'keep' ) { |
| 853 | 853 | $return[ $key ] = $value; |
| 854 | 854 | } else { |
| 855 | 855 | $return[] = $value; |
| 856 | 856 | } |
| 857 | - } |
|
| 858 | - } |
|
| 859 | - return $return; |
|
| 860 | - } |
|
| 857 | + } |
|
| 858 | + } |
|
| 859 | + return $return; |
|
| 860 | + } |
|
| 861 | 861 | |
| 862 | 862 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 863 | 863 | $safe_text = str_replace( '"', '"', $text ); |
@@ -868,38 +868,38 @@ discard block |
||
| 868 | 868 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - /** |
|
| 872 | - * Add auto paragraphs to text areas |
|
| 873 | - * @since 2.0 |
|
| 874 | - */ |
|
| 871 | + /** |
|
| 872 | + * Add auto paragraphs to text areas |
|
| 873 | + * @since 2.0 |
|
| 874 | + */ |
|
| 875 | 875 | public static function use_wpautop( $content ) { |
| 876 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 877 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 878 | - } |
|
| 879 | - return $content; |
|
| 880 | - } |
|
| 876 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 877 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 878 | + } |
|
| 879 | + return $content; |
|
| 880 | + } |
|
| 881 | 881 | |
| 882 | 882 | public static function replace_quotes( $val ) { |
| 883 | - //Replace double quotes |
|
| 883 | + //Replace double quotes |
|
| 884 | 884 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 885 | - //Replace single quotes |
|
| 886 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 887 | - return $val; |
|
| 888 | - } |
|
| 889 | - |
|
| 890 | - /** |
|
| 891 | - * @since 2.0 |
|
| 892 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 893 | - */ |
|
| 894 | - public static function jquery_ui_base_url() { |
|
| 885 | + //Replace single quotes |
|
| 886 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 887 | + return $val; |
|
| 888 | + } |
|
| 889 | + |
|
| 890 | + /** |
|
| 891 | + * @since 2.0 |
|
| 892 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 893 | + */ |
|
| 894 | + public static function jquery_ui_base_url() { |
|
| 895 | 895 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 896 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 897 | - return $url; |
|
| 898 | - } |
|
| 896 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 897 | + return $url; |
|
| 898 | + } |
|
| 899 | 899 | |
| 900 | - /** |
|
| 901 | - * @param string $handle |
|
| 902 | - */ |
|
| 900 | + /** |
|
| 901 | + * @param string $handle |
|
| 902 | + */ |
|
| 903 | 903 | public static function script_version( $handle, $default = 0 ) { |
| 904 | 904 | global $wp_scripts; |
| 905 | 905 | if ( ! $wp_scripts ) { |
@@ -921,75 +921,75 @@ discard block |
||
| 921 | 921 | |
| 922 | 922 | public static function js_redirect( $url ) { |
| 923 | 923 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 924 | - } |
|
| 924 | + } |
|
| 925 | 925 | |
| 926 | 926 | public static function get_user_id_param( $user_id ) { |
| 927 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 928 | - return $user_id; |
|
| 929 | - } |
|
| 927 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 928 | + return $user_id; |
|
| 929 | + } |
|
| 930 | 930 | |
| 931 | 931 | $user_id = sanitize_text_field( $user_id ); |
| 932 | 932 | if ( $user_id == 'current' ) { |
| 933 | 933 | $user_id = get_current_user_id(); |
| 934 | 934 | } else { |
| 935 | - if ( is_email($user_id) ) { |
|
| 936 | - $user = get_user_by('email', $user_id); |
|
| 937 | - } else { |
|
| 938 | - $user = get_user_by('login', $user_id); |
|
| 939 | - } |
|
| 935 | + if ( is_email($user_id) ) { |
|
| 936 | + $user = get_user_by('email', $user_id); |
|
| 937 | + } else { |
|
| 938 | + $user = get_user_by('login', $user_id); |
|
| 939 | + } |
|
| 940 | 940 | |
| 941 | - if ( $user ) { |
|
| 942 | - $user_id = $user->ID; |
|
| 943 | - } |
|
| 944 | - unset($user); |
|
| 945 | - } |
|
| 941 | + if ( $user ) { |
|
| 942 | + $user_id = $user->ID; |
|
| 943 | + } |
|
| 944 | + unset($user); |
|
| 945 | + } |
|
| 946 | 946 | |
| 947 | - return $user_id; |
|
| 948 | - } |
|
| 947 | + return $user_id; |
|
| 948 | + } |
|
| 949 | 949 | |
| 950 | 950 | public static function get_file_contents( $filename, $atts = array() ) { |
| 951 | - if ( ! is_file($filename) ) { |
|
| 952 | - return false; |
|
| 953 | - } |
|
| 954 | - |
|
| 955 | - extract($atts); |
|
| 956 | - ob_start(); |
|
| 957 | - include($filename); |
|
| 958 | - $contents = ob_get_contents(); |
|
| 959 | - ob_end_clean(); |
|
| 960 | - return $contents; |
|
| 961 | - } |
|
| 962 | - |
|
| 963 | - /** |
|
| 964 | - * @param string $table_name |
|
| 965 | - * @param string $column |
|
| 951 | + if ( ! is_file($filename) ) { |
|
| 952 | + return false; |
|
| 953 | + } |
|
| 954 | + |
|
| 955 | + extract($atts); |
|
| 956 | + ob_start(); |
|
| 957 | + include($filename); |
|
| 958 | + $contents = ob_get_contents(); |
|
| 959 | + ob_end_clean(); |
|
| 960 | + return $contents; |
|
| 961 | + } |
|
| 962 | + |
|
| 963 | + /** |
|
| 964 | + * @param string $table_name |
|
| 965 | + * @param string $column |
|
| 966 | 966 | * @param int $id |
| 967 | 967 | * @param int $num_chars |
| 968 | - */ |
|
| 969 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 970 | - $key = ''; |
|
| 968 | + */ |
|
| 969 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 970 | + $key = ''; |
|
| 971 | 971 | |
| 972 | - if ( ! empty( $name ) ) { |
|
| 973 | - $key = sanitize_key($name); |
|
| 974 | - } |
|
| 972 | + if ( ! empty( $name ) ) { |
|
| 973 | + $key = sanitize_key($name); |
|
| 974 | + } |
|
| 975 | 975 | |
| 976 | 976 | if ( empty( $key ) ) { |
| 977 | - $max_slug_value = pow(36, $num_chars); |
|
| 978 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 979 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 980 | - } |
|
| 977 | + $max_slug_value = pow(36, $num_chars); |
|
| 978 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 979 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 980 | + } |
|
| 981 | 981 | |
| 982 | 982 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 983 | 983 | $key = $key . 'a'; |
| 984 | - } |
|
| 984 | + } |
|
| 985 | 985 | |
| 986 | 986 | $key_check = FrmDb::get_var( $table_name, array( |
| 987 | 987 | $column => $key, |
| 988 | 988 | 'ID !' => $id, |
| 989 | 989 | ), $column ); |
| 990 | 990 | |
| 991 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 992 | - $suffix = 2; |
|
| 991 | + if ( $key_check || is_numeric($key_check) ) { |
|
| 992 | + $suffix = 2; |
|
| 993 | 993 | do { |
| 994 | 994 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 995 | 995 | $key_check = FrmDb::get_var( $table_name, array( |
@@ -999,23 +999,23 @@ discard block |
||
| 999 | 999 | $suffix++; |
| 1000 | 1000 | } while ( $key_check || is_numeric( $key_check ) ); |
| 1001 | 1001 | $key = $alt_post_name; |
| 1002 | - } |
|
| 1003 | - return $key; |
|
| 1004 | - } |
|
| 1005 | - |
|
| 1006 | - /** |
|
| 1007 | - * Editing a Form or Entry |
|
| 1008 | - * @param string $table |
|
| 1009 | - * @return bool|array |
|
| 1010 | - */ |
|
| 1011 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1012 | - if ( ! $record ) { |
|
| 1013 | - return false; |
|
| 1014 | - } |
|
| 1015 | - |
|
| 1016 | - if ( empty($post_values) ) { |
|
| 1017 | - $post_values = stripslashes_deep($_POST); |
|
| 1018 | - } |
|
| 1002 | + } |
|
| 1003 | + return $key; |
|
| 1004 | + } |
|
| 1005 | + |
|
| 1006 | + /** |
|
| 1007 | + * Editing a Form or Entry |
|
| 1008 | + * @param string $table |
|
| 1009 | + * @return bool|array |
|
| 1010 | + */ |
|
| 1011 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1012 | + if ( ! $record ) { |
|
| 1013 | + return false; |
|
| 1014 | + } |
|
| 1015 | + |
|
| 1016 | + if ( empty($post_values) ) { |
|
| 1017 | + $post_values = stripslashes_deep($_POST); |
|
| 1018 | + } |
|
| 1019 | 1019 | |
| 1020 | 1020 | $values = array( |
| 1021 | 1021 | 'id' => $record->id, |
@@ -1023,25 +1023,25 @@ discard block |
||
| 1023 | 1023 | ); |
| 1024 | 1024 | |
| 1025 | 1025 | foreach ( array( 'name', 'description' ) as $var ) { |
| 1026 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 1026 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 1027 | 1027 | $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
| 1028 | - unset($var, $default_val); |
|
| 1029 | - } |
|
| 1028 | + unset($var, $default_val); |
|
| 1029 | + } |
|
| 1030 | 1030 | |
| 1031 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 1031 | + $values['description'] = self::use_wpautop($values['description']); |
|
| 1032 | 1032 | |
| 1033 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1033 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1034 | 1034 | |
| 1035 | 1035 | self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) ); |
| 1036 | 1036 | |
| 1037 | - if ( $table == 'entries' ) { |
|
| 1038 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1039 | - } else if ( $table == 'forms' ) { |
|
| 1040 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1041 | - } |
|
| 1037 | + if ( $table == 'entries' ) { |
|
| 1038 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1039 | + } else if ( $table == 'forms' ) { |
|
| 1040 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1041 | + } |
|
| 1042 | 1042 | |
| 1043 | - return $values; |
|
| 1044 | - } |
|
| 1043 | + return $values; |
|
| 1044 | + } |
|
| 1045 | 1045 | |
| 1046 | 1046 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 1047 | 1047 | if ( ! empty( $fields ) ) { |
@@ -1054,46 +1054,46 @@ discard block |
||
| 1054 | 1054 | } |
| 1055 | 1055 | |
| 1056 | 1056 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1057 | - $post_values = $args['post_values']; |
|
| 1058 | - |
|
| 1059 | - if ( $args['default'] ) { |
|
| 1060 | - $meta_value = $field->default_value; |
|
| 1061 | - } else { |
|
| 1062 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1063 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1064 | - $field->field_options['custom_field'] = ''; |
|
| 1065 | - } |
|
| 1057 | + $post_values = $args['post_values']; |
|
| 1058 | + |
|
| 1059 | + if ( $args['default'] ) { |
|
| 1060 | + $meta_value = $field->default_value; |
|
| 1061 | + } else { |
|
| 1062 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1063 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1064 | + $field->field_options['custom_field'] = ''; |
|
| 1065 | + } |
|
| 1066 | 1066 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( |
| 1067 | 1067 | 'truncate' => false, |
| 1068 | 1068 | 'type' => $field->type, |
| 1069 | 1069 | 'form_id' => $field->form_id, |
| 1070 | 1070 | 'field' => $field, |
| 1071 | 1071 | ) ); |
| 1072 | - } else { |
|
| 1072 | + } else { |
|
| 1073 | 1073 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1074 | - } |
|
| 1075 | - } |
|
| 1074 | + } |
|
| 1075 | + } |
|
| 1076 | 1076 | |
| 1077 | 1077 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1078 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1078 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1079 | 1079 | |
| 1080 | 1080 | $field_array = self::start_field_array( $field ); |
| 1081 | 1081 | $field_array['value'] = $new_value; |
| 1082 | 1082 | $field_array['type'] = apply_filters( 'frm_field_type', $field_type, $field, $new_value ); |
| 1083 | 1083 | $field_array['parent_form_id'] = $args['parent_form_id']; |
| 1084 | 1084 | |
| 1085 | - $args['field_type'] = $field_type; |
|
| 1085 | + $args['field_type'] = $field_type; |
|
| 1086 | 1086 | |
| 1087 | 1087 | FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args ); |
| 1088 | 1088 | |
| 1089 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1090 | - $field_array['unique_msg'] = ''; |
|
| 1091 | - } |
|
| 1089 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1090 | + $field_array['unique_msg'] = ''; |
|
| 1091 | + } |
|
| 1092 | 1092 | |
| 1093 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1093 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1094 | 1094 | |
| 1095 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1096 | - } |
|
| 1095 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1096 | + } |
|
| 1097 | 1097 | |
| 1098 | 1098 | /** |
| 1099 | 1099 | * @since 3.0 |
@@ -1114,48 +1114,48 @@ discard block |
||
| 1114 | 1114 | ); |
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | - /** |
|
| 1118 | - * @param string $table |
|
| 1119 | - */ |
|
| 1117 | + /** |
|
| 1118 | + * @param string $table |
|
| 1119 | + */ |
|
| 1120 | 1120 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1121 | - if ( $table == 'entries' ) { |
|
| 1122 | - $form = $record->form_id; |
|
| 1121 | + if ( $table == 'entries' ) { |
|
| 1122 | + $form = $record->form_id; |
|
| 1123 | 1123 | FrmForm::maybe_get_form( $form ); |
| 1124 | - } else { |
|
| 1125 | - $form = $record; |
|
| 1126 | - } |
|
| 1124 | + } else { |
|
| 1125 | + $form = $record; |
|
| 1126 | + } |
|
| 1127 | 1127 | |
| 1128 | - if ( ! $form ) { |
|
| 1129 | - return; |
|
| 1130 | - } |
|
| 1128 | + if ( ! $form ) { |
|
| 1129 | + return; |
|
| 1130 | + } |
|
| 1131 | 1131 | |
| 1132 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1132 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1133 | 1133 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1134 | 1134 | |
| 1135 | - if ( ! is_array($form->options) ) { |
|
| 1136 | - return; |
|
| 1137 | - } |
|
| 1135 | + if ( ! is_array($form->options) ) { |
|
| 1136 | + return; |
|
| 1137 | + } |
|
| 1138 | 1138 | |
| 1139 | - foreach ( $form->options as $opt => $value ) { |
|
| 1140 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1141 | - } |
|
| 1139 | + foreach ( $form->options as $opt => $value ) { |
|
| 1140 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1141 | + } |
|
| 1142 | 1142 | |
| 1143 | - self::fill_form_defaults($post_values, $values); |
|
| 1144 | - } |
|
| 1143 | + self::fill_form_defaults($post_values, $values); |
|
| 1144 | + } |
|
| 1145 | 1145 | |
| 1146 | - /** |
|
| 1147 | - * Set to POST value or default |
|
| 1148 | - */ |
|
| 1146 | + /** |
|
| 1147 | + * Set to POST value or default |
|
| 1148 | + */ |
|
| 1149 | 1149 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1150 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1150 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1151 | 1151 | |
| 1152 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1153 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1152 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1153 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1154 | 1154 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1155 | - } |
|
| 1155 | + } |
|
| 1156 | 1156 | |
| 1157 | - unset($opt, $defaut); |
|
| 1158 | - } |
|
| 1157 | + unset($opt, $defaut); |
|
| 1158 | + } |
|
| 1159 | 1159 | |
| 1160 | 1160 | if ( ! isset( $values['custom_style'] ) ) { |
| 1161 | 1161 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1164,10 +1164,10 @@ discard block |
||
| 1164 | 1164 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1165 | 1165 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1166 | 1166 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1167 | - } |
|
| 1168 | - unset($h); |
|
| 1169 | - } |
|
| 1170 | - } |
|
| 1167 | + } |
|
| 1168 | + unset($h); |
|
| 1169 | + } |
|
| 1170 | + } |
|
| 1171 | 1171 | |
| 1172 | 1172 | /** |
| 1173 | 1173 | * @since 2.2.10 |
@@ -1190,55 +1190,55 @@ discard block |
||
| 1190 | 1190 | if ( $possible_email_field ) { |
| 1191 | 1191 | $class .= 'show_frm_not_email_to'; |
| 1192 | 1192 | } |
| 1193 | - ?> |
|
| 1193 | + ?> |
|
| 1194 | 1194 | <li> |
| 1195 | 1195 | <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> |
| 1196 | 1196 | <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> |
| 1197 | 1197 | <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> |
| 1198 | 1198 | </li> |
| 1199 | 1199 | <?php |
| 1200 | - } |
|
| 1200 | + } |
|
| 1201 | 1201 | |
| 1202 | 1202 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1203 | - if ( is_array( $str ) ) { |
|
| 1204 | - return ''; |
|
| 1203 | + if ( is_array( $str ) ) { |
|
| 1204 | + return ''; |
|
| 1205 | 1205 | } |
| 1206 | 1206 | |
| 1207 | - $length = (int) $length; |
|
| 1207 | + $length = (int) $length; |
|
| 1208 | 1208 | $str = wp_strip_all_tags( $str ); |
| 1209 | 1209 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1210 | 1210 | |
| 1211 | 1211 | if ( $length == 0 ) { |
| 1212 | - return ''; |
|
| 1213 | - } else if ( $length <= 10 ) { |
|
| 1212 | + return ''; |
|
| 1213 | + } else if ( $length <= 10 ) { |
|
| 1214 | 1214 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1215 | 1215 | return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
| 1216 | - } |
|
| 1216 | + } |
|
| 1217 | 1217 | |
| 1218 | - $sub = ''; |
|
| 1219 | - $len = 0; |
|
| 1218 | + $sub = ''; |
|
| 1219 | + $len = 0; |
|
| 1220 | 1220 | |
| 1221 | 1221 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1222 | 1222 | |
| 1223 | 1223 | foreach ( $words as $word ) { |
| 1224 | 1224 | $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
| 1225 | 1225 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1226 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1227 | - break; |
|
| 1228 | - } |
|
| 1226 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1227 | + break; |
|
| 1228 | + } |
|
| 1229 | 1229 | |
| 1230 | - $sub .= $part; |
|
| 1230 | + $sub .= $part; |
|
| 1231 | 1231 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1232 | 1232 | |
| 1233 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1234 | - break; |
|
| 1235 | - } |
|
| 1233 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1234 | + break; |
|
| 1235 | + } |
|
| 1236 | 1236 | |
| 1237 | - unset($total_len, $word); |
|
| 1238 | - } |
|
| 1237 | + unset($total_len, $word); |
|
| 1238 | + } |
|
| 1239 | 1239 | |
| 1240 | 1240 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
| 1241 | - } |
|
| 1241 | + } |
|
| 1242 | 1242 | |
| 1243 | 1243 | public static function mb_function( $function_names, $args ) { |
| 1244 | 1244 | $mb_function_name = $function_names[0]; |
@@ -1250,18 +1250,18 @@ discard block |
||
| 1250 | 1250 | } |
| 1251 | 1251 | |
| 1252 | 1252 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1253 | - if ( empty($date) ) { |
|
| 1254 | - return $date; |
|
| 1255 | - } |
|
| 1253 | + if ( empty($date) ) { |
|
| 1254 | + return $date; |
|
| 1255 | + } |
|
| 1256 | 1256 | |
| 1257 | - if ( empty($date_format) ) { |
|
| 1258 | - $date_format = get_option('date_format'); |
|
| 1259 | - } |
|
| 1257 | + if ( empty($date_format) ) { |
|
| 1258 | + $date_format = get_option('date_format'); |
|
| 1259 | + } |
|
| 1260 | 1260 | |
| 1261 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1262 | - $frmpro_settings = new FrmProSettings(); |
|
| 1263 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1264 | - } |
|
| 1261 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1262 | + $frmpro_settings = new FrmProSettings(); |
|
| 1263 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1264 | + } |
|
| 1265 | 1265 | |
| 1266 | 1266 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1267 | 1267 | |
@@ -1270,8 +1270,8 @@ discard block |
||
| 1270 | 1270 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | - return $formatted; |
|
| 1274 | - } |
|
| 1273 | + return $formatted; |
|
| 1274 | + } |
|
| 1275 | 1275 | |
| 1276 | 1276 | private static function add_time_to_date( $time_format, $date ) { |
| 1277 | 1277 | if ( empty( $time_format ) ) { |
@@ -1353,119 +1353,119 @@ discard block |
||
| 1353 | 1353 | ); |
| 1354 | 1354 | } |
| 1355 | 1355 | |
| 1356 | - // Pagination Methods |
|
| 1356 | + // Pagination Methods |
|
| 1357 | 1357 | |
| 1358 | - /** |
|
| 1359 | - * @param integer $current_p |
|
| 1360 | - */ |
|
| 1358 | + /** |
|
| 1359 | + * @param integer $current_p |
|
| 1360 | + */ |
|
| 1361 | 1361 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1362 | 1362 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | - /** |
|
| 1366 | - * @param integer $current_p |
|
| 1367 | - */ |
|
| 1368 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1369 | - if ( $current_p == 1 ) { |
|
| 1370 | - return 1; |
|
| 1371 | - } else { |
|
| 1372 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1373 | - } |
|
| 1374 | - } |
|
| 1365 | + /** |
|
| 1366 | + * @param integer $current_p |
|
| 1367 | + */ |
|
| 1368 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1369 | + if ( $current_p == 1 ) { |
|
| 1370 | + return 1; |
|
| 1371 | + } else { |
|
| 1372 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1373 | + } |
|
| 1374 | + } |
|
| 1375 | 1375 | |
| 1376 | 1376 | /** |
| 1377 | 1377 | * @return array |
| 1378 | 1378 | */ |
| 1379 | 1379 | public static function json_to_array( $json_vars ) { |
| 1380 | - $vars = array(); |
|
| 1381 | - foreach ( $json_vars as $jv ) { |
|
| 1382 | - $jv_name = explode('[', $jv['name']); |
|
| 1383 | - $last = count($jv_name) - 1; |
|
| 1384 | - foreach ( $jv_name as $p => $n ) { |
|
| 1385 | - $name = trim($n, ']'); |
|
| 1386 | - if ( ! isset($l1) ) { |
|
| 1387 | - $l1 = $name; |
|
| 1388 | - } |
|
| 1389 | - |
|
| 1390 | - if ( ! isset($l2) ) { |
|
| 1391 | - $l2 = $name; |
|
| 1392 | - } |
|
| 1393 | - |
|
| 1394 | - if ( ! isset($l3) ) { |
|
| 1395 | - $l3 = $name; |
|
| 1396 | - } |
|
| 1397 | - |
|
| 1398 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1399 | - |
|
| 1400 | - switch ( $p ) { |
|
| 1401 | - case 0: |
|
| 1402 | - $l1 = $name; |
|
| 1403 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1380 | + $vars = array(); |
|
| 1381 | + foreach ( $json_vars as $jv ) { |
|
| 1382 | + $jv_name = explode('[', $jv['name']); |
|
| 1383 | + $last = count($jv_name) - 1; |
|
| 1384 | + foreach ( $jv_name as $p => $n ) { |
|
| 1385 | + $name = trim($n, ']'); |
|
| 1386 | + if ( ! isset($l1) ) { |
|
| 1387 | + $l1 = $name; |
|
| 1388 | + } |
|
| 1389 | + |
|
| 1390 | + if ( ! isset($l2) ) { |
|
| 1391 | + $l2 = $name; |
|
| 1392 | + } |
|
| 1393 | + |
|
| 1394 | + if ( ! isset($l3) ) { |
|
| 1395 | + $l3 = $name; |
|
| 1396 | + } |
|
| 1397 | + |
|
| 1398 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1399 | + |
|
| 1400 | + switch ( $p ) { |
|
| 1401 | + case 0: |
|
| 1402 | + $l1 = $name; |
|
| 1403 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1404 | 1404 | break; |
| 1405 | 1405 | |
| 1406 | - case 1: |
|
| 1407 | - $l2 = $name; |
|
| 1408 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1406 | + case 1: |
|
| 1407 | + $l2 = $name; |
|
| 1408 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1409 | 1409 | break; |
| 1410 | 1410 | |
| 1411 | - case 2: |
|
| 1412 | - $l3 = $name; |
|
| 1413 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1411 | + case 2: |
|
| 1412 | + $l3 = $name; |
|
| 1413 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1414 | 1414 | break; |
| 1415 | 1415 | |
| 1416 | - case 3: |
|
| 1417 | - $l4 = $name; |
|
| 1418 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1419 | - } |
|
| 1416 | + case 3: |
|
| 1417 | + $l4 = $name; |
|
| 1418 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1419 | + } |
|
| 1420 | 1420 | |
| 1421 | - unset($this_val, $n); |
|
| 1422 | - } |
|
| 1421 | + unset($this_val, $n); |
|
| 1422 | + } |
|
| 1423 | 1423 | |
| 1424 | - unset($last, $jv); |
|
| 1425 | - } |
|
| 1424 | + unset($last, $jv); |
|
| 1425 | + } |
|
| 1426 | 1426 | |
| 1427 | - return $vars; |
|
| 1428 | - } |
|
| 1427 | + return $vars; |
|
| 1428 | + } |
|
| 1429 | 1429 | |
| 1430 | - /** |
|
| 1431 | - * @param string $name |
|
| 1432 | - * @param string $l1 |
|
| 1433 | - */ |
|
| 1434 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1435 | - if ( $name == '' ) { |
|
| 1436 | - $vars[] = $val; |
|
| 1437 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1438 | - $vars[ $l1 ] = $val; |
|
| 1439 | - } |
|
| 1440 | - } |
|
| 1430 | + /** |
|
| 1431 | + * @param string $name |
|
| 1432 | + * @param string $l1 |
|
| 1433 | + */ |
|
| 1434 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1435 | + if ( $name == '' ) { |
|
| 1436 | + $vars[] = $val; |
|
| 1437 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1438 | + $vars[ $l1 ] = $val; |
|
| 1439 | + } |
|
| 1440 | + } |
|
| 1441 | 1441 | |
| 1442 | 1442 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1443 | - $tooltips = array( |
|
| 1444 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1445 | - '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' ), |
|
| 1446 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1447 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1448 | - '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' ), |
|
| 1449 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1450 | - '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() ) ), |
|
| 1451 | - ); |
|
| 1452 | - |
|
| 1453 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1454 | - return; |
|
| 1455 | - } |
|
| 1456 | - |
|
| 1457 | - if ( 'open' == $class ) { |
|
| 1458 | - echo ' frm_help"'; |
|
| 1459 | - } else { |
|
| 1460 | - echo ' class="frm_help"'; |
|
| 1461 | - } |
|
| 1443 | + $tooltips = array( |
|
| 1444 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1445 | + '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' ), |
|
| 1446 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1447 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1448 | + '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' ), |
|
| 1449 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1450 | + '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() ) ), |
|
| 1451 | + ); |
|
| 1452 | + |
|
| 1453 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1454 | + return; |
|
| 1455 | + } |
|
| 1456 | + |
|
| 1457 | + if ( 'open' == $class ) { |
|
| 1458 | + echo ' frm_help"'; |
|
| 1459 | + } else { |
|
| 1460 | + echo ' class="frm_help"'; |
|
| 1461 | + } |
|
| 1462 | 1462 | |
| 1463 | 1463 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1464 | 1464 | |
| 1465 | - if ( 'open' != $class ) { |
|
| 1466 | - echo '"'; |
|
| 1467 | - } |
|
| 1468 | - } |
|
| 1465 | + if ( 'open' != $class ) { |
|
| 1466 | + echo '"'; |
|
| 1467 | + } |
|
| 1468 | + } |
|
| 1469 | 1469 | |
| 1470 | 1470 | /** |
| 1471 | 1471 | * Add the current_page class to that page in the form nav |
@@ -1481,35 +1481,35 @@ discard block |
||
| 1481 | 1481 | } |
| 1482 | 1482 | } |
| 1483 | 1483 | |
| 1484 | - /** |
|
| 1485 | - * Prepare and json_encode post content |
|
| 1486 | - * |
|
| 1487 | - * @since 2.0 |
|
| 1488 | - * |
|
| 1489 | - * @param array $post_content |
|
| 1490 | - * @return string $post_content ( json encoded array ) |
|
| 1491 | - */ |
|
| 1492 | - public static function prepare_and_encode( $post_content ) { |
|
| 1493 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1484 | + /** |
|
| 1485 | + * Prepare and json_encode post content |
|
| 1486 | + * |
|
| 1487 | + * @since 2.0 |
|
| 1488 | + * |
|
| 1489 | + * @param array $post_content |
|
| 1490 | + * @return string $post_content ( json encoded array ) |
|
| 1491 | + */ |
|
| 1492 | + public static function prepare_and_encode( $post_content ) { |
|
| 1493 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1494 | 1494 | foreach ( $post_content as $key => $val ) { |
| 1495 | 1495 | // Replace problematic characters (like ") |
| 1496 | 1496 | $val = str_replace( '"', '"', $val ); |
| 1497 | 1497 | |
| 1498 | 1498 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1499 | - unset( $key, $val ); |
|
| 1500 | - } |
|
| 1499 | + unset( $key, $val ); |
|
| 1500 | + } |
|
| 1501 | 1501 | |
| 1502 | - // json_encode the array |
|
| 1503 | - $post_content = json_encode( $post_content ); |
|
| 1502 | + // json_encode the array |
|
| 1503 | + $post_content = json_encode( $post_content ); |
|
| 1504 | 1504 | |
| 1505 | - // add extra slashes for \r\n since WP strips them |
|
| 1505 | + // add extra slashes for \r\n since WP strips them |
|
| 1506 | 1506 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1507 | 1507 | |
| 1508 | - // allow for " |
|
| 1509 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1508 | + // allow for " |
|
| 1509 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1510 | 1510 | |
| 1511 | - return $post_content; |
|
| 1512 | - } |
|
| 1511 | + return $post_content; |
|
| 1512 | + } |
|
| 1513 | 1513 | |
| 1514 | 1514 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1515 | 1515 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1531,64 +1531,64 @@ discard block |
||
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | 1533 | public static function maybe_json_decode( $string ) { |
| 1534 | - if ( is_array($string) ) { |
|
| 1535 | - return $string; |
|
| 1536 | - } |
|
| 1534 | + if ( is_array($string) ) { |
|
| 1535 | + return $string; |
|
| 1536 | + } |
|
| 1537 | 1537 | |
| 1538 | - $new_string = json_decode($string, true); |
|
| 1539 | - if ( function_exists('json_last_error') ) { |
|
| 1538 | + $new_string = json_decode($string, true); |
|
| 1539 | + if ( function_exists('json_last_error') ) { |
|
| 1540 | 1540 | // php 5.3+ |
| 1541 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1542 | - $string = $new_string; |
|
| 1543 | - } |
|
| 1544 | - } else if ( isset($new_string) ) { |
|
| 1541 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1542 | + $string = $new_string; |
|
| 1543 | + } |
|
| 1544 | + } else if ( isset($new_string) ) { |
|
| 1545 | 1545 | // php < 5.3 fallback |
| 1546 | - $string = $new_string; |
|
| 1547 | - } |
|
| 1548 | - return $string; |
|
| 1549 | - } |
|
| 1550 | - |
|
| 1551 | - /** |
|
| 1552 | - * @since 1.07.10 |
|
| 1553 | - * |
|
| 1554 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1555 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1556 | - */ |
|
| 1546 | + $string = $new_string; |
|
| 1547 | + } |
|
| 1548 | + return $string; |
|
| 1549 | + } |
|
| 1550 | + |
|
| 1551 | + /** |
|
| 1552 | + * @since 1.07.10 |
|
| 1553 | + * |
|
| 1554 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1555 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1556 | + */ |
|
| 1557 | 1557 | public static function maybe_highlight_menu( $post_type ) { |
| 1558 | - global $post; |
|
| 1558 | + global $post; |
|
| 1559 | 1559 | |
| 1560 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1561 | - return; |
|
| 1562 | - } |
|
| 1560 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1561 | + return; |
|
| 1562 | + } |
|
| 1563 | 1563 | |
| 1564 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1565 | - return; |
|
| 1566 | - } |
|
| 1564 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1565 | + return; |
|
| 1566 | + } |
|
| 1567 | 1567 | |
| 1568 | - self::load_admin_wide_js(); |
|
| 1569 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1570 | - } |
|
| 1568 | + self::load_admin_wide_js(); |
|
| 1569 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1570 | + } |
|
| 1571 | 1571 | |
| 1572 | - /** |
|
| 1573 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1574 | - * @since 2.0 |
|
| 1575 | - */ |
|
| 1572 | + /** |
|
| 1573 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1574 | + * @since 2.0 |
|
| 1575 | + */ |
|
| 1576 | 1576 | public static function load_admin_wide_js( $load = true ) { |
| 1577 | - $version = FrmAppHelper::plugin_version(); |
|
| 1577 | + $version = FrmAppHelper::plugin_version(); |
|
| 1578 | 1578 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1579 | 1579 | |
| 1580 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1580 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1581 | 1581 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1582 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1582 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1583 | 1583 | 'url' => FrmAppHelper::plugin_url(), |
| 1584 | 1584 | 'loading' => __( 'Loading…' ), |
| 1585 | 1585 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
| 1586 | - ) ); |
|
| 1586 | + ) ); |
|
| 1587 | 1587 | |
| 1588 | 1588 | if ( $load ) { |
| 1589 | 1589 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1590 | 1590 | } |
| 1591 | - } |
|
| 1591 | + } |
|
| 1592 | 1592 | |
| 1593 | 1593 | /** |
| 1594 | 1594 | * @since 2.0.9 |
@@ -1597,9 +1597,9 @@ discard block |
||
| 1597 | 1597 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1598 | 1598 | } |
| 1599 | 1599 | |
| 1600 | - /** |
|
| 1601 | - * @param string $location |
|
| 1602 | - */ |
|
| 1600 | + /** |
|
| 1601 | + * @param string $location |
|
| 1602 | + */ |
|
| 1603 | 1603 | public static function localize_script( $location ) { |
| 1604 | 1604 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1605 | 1605 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1655,27 +1655,27 @@ discard block |
||
| 1655 | 1655 | } |
| 1656 | 1656 | } |
| 1657 | 1657 | |
| 1658 | - /** |
|
| 1658 | + /** |
|
| 1659 | 1659 | * echo the message on the plugins listing page |
| 1660 | - * @since 1.07.10 |
|
| 1661 | - * |
|
| 1662 | - * @param float $min_version The version the add-on requires |
|
| 1663 | - */ |
|
| 1660 | + * @since 1.07.10 |
|
| 1661 | + * |
|
| 1662 | + * @param float $min_version The version the add-on requires |
|
| 1663 | + */ |
|
| 1664 | 1664 | public static function min_version_notice( $min_version ) { |
| 1665 | - $frm_version = self::plugin_version(); |
|
| 1665 | + $frm_version = self::plugin_version(); |
|
| 1666 | 1666 | |
| 1667 | - // check if Formidable meets minimum requirements |
|
| 1668 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1669 | - return; |
|
| 1670 | - } |
|
| 1667 | + // check if Formidable meets minimum requirements |
|
| 1668 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1669 | + return; |
|
| 1670 | + } |
|
| 1671 | 1671 | |
| 1672 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1672 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1673 | 1673 | 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">' . |
| 1674 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1675 | - '</div></td></tr>'; |
|
| 1676 | - } |
|
| 1674 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1675 | + '</div></td></tr>'; |
|
| 1676 | + } |
|
| 1677 | 1677 | |
| 1678 | - public static function locales( $type = 'date' ) { |
|
| 1678 | + public static function locales( $type = 'date' ) { |
|
| 1679 | 1679 | $locales = array( |
| 1680 | 1680 | 'en' => __( 'English', 'formidable' ), |
| 1681 | 1681 | '' => __( 'English/Western', 'formidable' ), |
@@ -1751,11 +1751,11 @@ discard block |
||
| 1751 | 1751 | $unset = array( 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', 'es-419', 'tr' ); |
| 1752 | 1752 | } |
| 1753 | 1753 | |
| 1754 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1755 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1754 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1755 | + $locales = apply_filters('frm_locales', $locales); |
|
| 1756 | 1756 | |
| 1757 | - return $locales; |
|
| 1758 | - } |
|
| 1757 | + return $locales; |
|
| 1758 | + } |
|
| 1759 | 1759 | |
| 1760 | 1760 | /** |
| 1761 | 1761 | * Prepare and save settings in styles and actions |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | return $charset_collate; |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - private function create_tables() { |
|
| 86 | - $charset_collate = $this->collation(); |
|
| 87 | - $sql = array(); |
|
| 85 | + private function create_tables() { |
|
| 86 | + $charset_collate = $this->collation(); |
|
| 87 | + $sql = array(); |
|
| 88 | 88 | |
| 89 | - /* Create/Upgrade Fields Table */ |
|
| 89 | + /* Create/Upgrade Fields Table */ |
|
| 90 | 90 | $sql[] = 'CREATE TABLE ' . $this->fields . ' ( |
| 91 | 91 | id BIGINT(20) NOT NULL auto_increment, |
| 92 | 92 | field_key varchar(100) default NULL, |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | UNIQUE KEY field_key (field_key) |
| 106 | 106 | )'; |
| 107 | 107 | |
| 108 | - /* Create/Upgrade Forms Table */ |
|
| 108 | + /* Create/Upgrade Forms Table */ |
|
| 109 | 109 | $sql[] = 'CREATE TABLE ' . $this->forms . ' ( |
| 110 | 110 | id int(11) NOT NULL auto_increment, |
| 111 | 111 | form_key varchar(100) default NULL, |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | UNIQUE KEY form_key (form_key) |
| 124 | 124 | )'; |
| 125 | 125 | |
| 126 | - /* Create/Upgrade Items Table */ |
|
| 126 | + /* Create/Upgrade Items Table */ |
|
| 127 | 127 | $sql[] = 'CREATE TABLE ' . $this->entries . ' ( |
| 128 | 128 | id BIGINT(20) NOT NULL auto_increment, |
| 129 | 129 | item_key varchar(100) default NULL, |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | UNIQUE KEY item_key (item_key) |
| 147 | 147 | )'; |
| 148 | 148 | |
| 149 | - /* Create/Upgrade Meta Table */ |
|
| 149 | + /* Create/Upgrade Meta Table */ |
|
| 150 | 150 | $sql[] = 'CREATE TABLE ' . $this->entry_metas . ' ( |
| 151 | 151 | id BIGINT(20) NOT NULL auto_increment, |
| 152 | 152 | meta_value longtext default NULL, |
@@ -158,16 +158,16 @@ discard block |
||
| 158 | 158 | KEY item_id (item_id) |
| 159 | 159 | )'; |
| 160 | 160 | |
| 161 | - foreach ( $sql as $q ) { |
|
| 161 | + foreach ( $sql as $q ) { |
|
| 162 | 162 | if ( function_exists( 'dbDelta' ) ) { |
| 163 | 163 | dbDelta( $q . $charset_collate . ';' ); |
| 164 | 164 | } else { |
| 165 | 165 | global $wpdb; |
| 166 | 166 | $wpdb->query( $q . $charset_collate ); |
| 167 | 167 | } |
| 168 | - unset($q); |
|
| 169 | - } |
|
| 170 | - } |
|
| 168 | + unset($q); |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | 172 | private function maybe_create_contact_form() { |
| 173 | 173 | $template_id = FrmForm::get_id_by_key( 'contact' ); |
@@ -209,31 +209,31 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - public function uninstall() { |
|
| 212 | + public function uninstall() { |
|
| 213 | 213 | if ( ! current_user_can( 'administrator' ) ) { |
| 214 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 215 | - wp_die($frm_settings->admin_permission); |
|
| 216 | - } |
|
| 214 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 215 | + wp_die($frm_settings->admin_permission); |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - global $wpdb, $wp_roles; |
|
| 218 | + global $wpdb, $wp_roles; |
|
| 219 | 219 | |
| 220 | 220 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); |
| 221 | 221 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); |
| 222 | 222 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); |
| 223 | 223 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); |
| 224 | 224 | |
| 225 | - delete_option('frm_options'); |
|
| 226 | - delete_option('frm_db_version'); |
|
| 227 | - |
|
| 228 | - //delete roles |
|
| 229 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 230 | - $roles = get_editable_roles(); |
|
| 231 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 232 | - foreach ( $roles as $role => $details ) { |
|
| 233 | - $wp_roles->remove_cap( $role, $frm_role ); |
|
| 234 | - unset($role, $details); |
|
| 235 | - } |
|
| 236 | - unset($frm_role, $frm_role_description); |
|
| 225 | + delete_option('frm_options'); |
|
| 226 | + delete_option('frm_db_version'); |
|
| 227 | + |
|
| 228 | + //delete roles |
|
| 229 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 230 | + $roles = get_editable_roles(); |
|
| 231 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 232 | + foreach ( $roles as $role => $details ) { |
|
| 233 | + $wp_roles->remove_cap( $role, $frm_role ); |
|
| 234 | + unset($role, $details); |
|
| 235 | + } |
|
| 236 | + unset($frm_role, $frm_role_description); |
|
| 237 | 237 | } |
| 238 | 238 | unset($roles, $frm_roles); |
| 239 | 239 | |
@@ -257,9 +257,9 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); |
| 259 | 259 | |
| 260 | - do_action('frm_after_uninstall'); |
|
| 261 | - return true; |
|
| 262 | - } |
|
| 260 | + do_action('frm_after_uninstall'); |
|
| 261 | + return true; |
|
| 262 | + } |
|
| 263 | 263 | |
| 264 | 264 | /** |
| 265 | 265 | * Reverse migration 17 -- Divide by 9 |
@@ -370,14 +370,14 @@ discard block |
||
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - /** |
|
| 374 | - * Change field size from character to pixel -- Multiply by 9 |
|
| 375 | - */ |
|
| 376 | - private function migrate_to_17() { |
|
| 377 | - global $wpdb; |
|
| 373 | + /** |
|
| 374 | + * Change field size from character to pixel -- Multiply by 9 |
|
| 375 | + */ |
|
| 376 | + private function migrate_to_17() { |
|
| 377 | + global $wpdb; |
|
| 378 | 378 | $pixel_conversion = 9; |
| 379 | 379 | |
| 380 | - // Get query arguments |
|
| 380 | + // Get query arguments |
|
| 381 | 381 | $field_types = array( 'textarea', 'text', 'number', 'email', 'url', 'rte', 'date', 'phone', 'password', 'image', 'tag', 'file' ); |
| 382 | 382 | $query = array( |
| 383 | 383 | 'type' => $field_types, |
@@ -385,137 +385,137 @@ discard block |
||
| 385 | 385 | 'field_options not like' => 's:4:"size";s:0:', |
| 386 | 386 | ); |
| 387 | 387 | |
| 388 | - // Get results |
|
| 388 | + // Get results |
|
| 389 | 389 | $fields = FrmDb::get_results( $this->fields, $query, 'id, field_options' ); |
| 390 | 390 | |
| 391 | - $updated = 0; |
|
| 392 | - foreach ( $fields as $f ) { |
|
| 393 | - $f->field_options = maybe_unserialize($f->field_options); |
|
| 394 | - if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 395 | - continue; |
|
| 396 | - } |
|
| 391 | + $updated = 0; |
|
| 392 | + foreach ( $fields as $f ) { |
|
| 393 | + $f->field_options = maybe_unserialize($f->field_options); |
|
| 394 | + if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 395 | + continue; |
|
| 396 | + } |
|
| 397 | 397 | |
| 398 | 398 | $f->field_options['size'] = round( $pixel_conversion * (int) $f->field_options['size'] ); |
| 399 | - $f->field_options['size'] .= 'px'; |
|
| 400 | - $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
|
| 401 | - if ( $u ) { |
|
| 402 | - $updated++; |
|
| 403 | - } |
|
| 404 | - unset($f); |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - // Change the characters in widgets to pixels |
|
| 408 | - $widgets = get_option('widget_frm_show_form'); |
|
| 409 | - if ( empty($widgets) ) { |
|
| 410 | - return; |
|
| 411 | - } |
|
| 412 | - |
|
| 413 | - $widgets = maybe_unserialize($widgets); |
|
| 414 | - foreach ( $widgets as $k => $widget ) { |
|
| 415 | - if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 416 | - continue; |
|
| 417 | - } |
|
| 399 | + $f->field_options['size'] .= 'px'; |
|
| 400 | + $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
|
| 401 | + if ( $u ) { |
|
| 402 | + $updated++; |
|
| 403 | + } |
|
| 404 | + unset($f); |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + // Change the characters in widgets to pixels |
|
| 408 | + $widgets = get_option('widget_frm_show_form'); |
|
| 409 | + if ( empty($widgets) ) { |
|
| 410 | + return; |
|
| 411 | + } |
|
| 412 | + |
|
| 413 | + $widgets = maybe_unserialize($widgets); |
|
| 414 | + foreach ( $widgets as $k => $widget ) { |
|
| 415 | + if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 416 | + continue; |
|
| 417 | + } |
|
| 418 | 418 | $size = round( $pixel_conversion * (int) $widget['size'] ); |
| 419 | - $size .= 'px'; |
|
| 419 | + $size .= 'px'; |
|
| 420 | 420 | $widgets[ $k ]['size'] = $size; |
| 421 | - } |
|
| 422 | - update_option('widget_frm_show_form', $widgets); |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - /** |
|
| 426 | - * Migrate post and email notification settings into actions |
|
| 427 | - */ |
|
| 428 | - private function migrate_to_16() { |
|
| 429 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' ); |
|
| 430 | - |
|
| 431 | - /** |
|
| 432 | - * Old email settings format: |
|
| 433 | - * email_to: Email or field id |
|
| 434 | - * also_email_to: array of fields ids |
|
| 435 | - * reply_to: Email, field id, 'custom' |
|
| 436 | - * cust_reply_to: string |
|
| 437 | - * reply_to_name: field id, 'custom' |
|
| 438 | - * cust_reply_to_name: string |
|
| 439 | - * plain_text: 0|1 |
|
| 440 | - * email_message: string or '' |
|
| 441 | - * email_subject: string or '' |
|
| 442 | - * inc_user_info: 0|1 |
|
| 443 | - * update_email: 0, 1, 2 |
|
| 444 | - * |
|
| 445 | - * Old autoresponder settings format: |
|
| 446 | - * auto_responder: 0|1 |
|
| 447 | - * ar_email_message: string or '' |
|
| 448 | - * ar_email_to: field id |
|
| 449 | - * ar_plain_text: 0|1 |
|
| 450 | - * ar_reply_to_name: string |
|
| 451 | - * ar_reply_to: string |
|
| 452 | - * ar_email_subject: string |
|
| 453 | - * ar_update_email: 0, 1, 2 |
|
| 454 | - * |
|
| 455 | - * New email settings: |
|
| 456 | - * post_content: json settings |
|
| 457 | - * post_title: form id |
|
| 458 | - * post_excerpt: message |
|
| 459 | - * |
|
| 460 | - */ |
|
| 461 | - |
|
| 462 | - foreach ( $forms as $form ) { |
|
| 421 | + } |
|
| 422 | + update_option('widget_frm_show_form', $widgets); |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + /** |
|
| 426 | + * Migrate post and email notification settings into actions |
|
| 427 | + */ |
|
| 428 | + private function migrate_to_16() { |
|
| 429 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' ); |
|
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * Old email settings format: |
|
| 433 | + * email_to: Email or field id |
|
| 434 | + * also_email_to: array of fields ids |
|
| 435 | + * reply_to: Email, field id, 'custom' |
|
| 436 | + * cust_reply_to: string |
|
| 437 | + * reply_to_name: field id, 'custom' |
|
| 438 | + * cust_reply_to_name: string |
|
| 439 | + * plain_text: 0|1 |
|
| 440 | + * email_message: string or '' |
|
| 441 | + * email_subject: string or '' |
|
| 442 | + * inc_user_info: 0|1 |
|
| 443 | + * update_email: 0, 1, 2 |
|
| 444 | + * |
|
| 445 | + * Old autoresponder settings format: |
|
| 446 | + * auto_responder: 0|1 |
|
| 447 | + * ar_email_message: string or '' |
|
| 448 | + * ar_email_to: field id |
|
| 449 | + * ar_plain_text: 0|1 |
|
| 450 | + * ar_reply_to_name: string |
|
| 451 | + * ar_reply_to: string |
|
| 452 | + * ar_email_subject: string |
|
| 453 | + * ar_update_email: 0, 1, 2 |
|
| 454 | + * |
|
| 455 | + * New email settings: |
|
| 456 | + * post_content: json settings |
|
| 457 | + * post_title: form id |
|
| 458 | + * post_excerpt: message |
|
| 459 | + * |
|
| 460 | + */ |
|
| 461 | + |
|
| 462 | + foreach ( $forms as $form ) { |
|
| 463 | 463 | if ( $form->is_template && $form->default_template ) { |
| 464 | 464 | // don't migrate the default templates since the email will be added anyway |
| 465 | 465 | continue; |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - // Format form options |
|
| 469 | - $form_options = maybe_unserialize($form->options); |
|
| 468 | + // Format form options |
|
| 469 | + $form_options = maybe_unserialize($form->options); |
|
| 470 | 470 | |
| 471 | - // Migrate settings to actions |
|
| 472 | - FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
|
| 473 | - } |
|
| 474 | - } |
|
| 471 | + // Migrate settings to actions |
|
| 472 | + FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
|
| 473 | + } |
|
| 474 | + } |
|
| 475 | 475 | |
| 476 | - private function migrate_to_11() { |
|
| 477 | - global $wpdb; |
|
| 476 | + private function migrate_to_11() { |
|
| 477 | + global $wpdb; |
|
| 478 | 478 | |
| 479 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 479 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 480 | 480 | |
| 481 | - $sending = __( 'Sending', 'formidable' ); |
|
| 481 | + $sending = __( 'Sending', 'formidable' ); |
|
| 482 | 482 | $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; |
| 483 | - $old_default_html = <<<DEFAULT_HTML |
|
| 483 | + $old_default_html = <<<DEFAULT_HTML |
|
| 484 | 484 | <div class="frm_submit"> |
| 485 | 485 | [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button] |
| 486 | 486 | <input type="submit" value="[button_label]" [button_action] /> |
| 487 | 487 | <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" /> |
| 488 | 488 | </div> |
| 489 | 489 | DEFAULT_HTML; |
| 490 | - unset($sending, $img); |
|
| 490 | + unset($sending, $img); |
|
| 491 | 491 | |
| 492 | - $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 493 | - $draft_link = FrmFormsHelper::get_draft_link(); |
|
| 492 | + $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 493 | + $draft_link = FrmFormsHelper::get_draft_link(); |
|
| 494 | 494 | foreach ( $forms as $form ) { |
| 495 | - $form->options = maybe_unserialize($form->options); |
|
| 496 | - if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 497 | - continue; |
|
| 498 | - } |
|
| 495 | + $form->options = maybe_unserialize($form->options); |
|
| 496 | + if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 497 | + continue; |
|
| 498 | + } |
|
| 499 | 499 | |
| 500 | - if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |
|
| 501 | - $form->options['submit_html'] = $new_default_html; |
|
| 500 | + if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |
|
| 501 | + $form->options['submit_html'] = $new_default_html; |
|
| 502 | 502 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 503 | 503 | } else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) { |
| 504 | 504 | $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] ); |
| 505 | 505 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 506 | - } |
|
| 507 | - unset($form); |
|
| 508 | - } |
|
| 509 | - unset($forms); |
|
| 510 | - } |
|
| 506 | + } |
|
| 507 | + unset($form); |
|
| 508 | + } |
|
| 509 | + unset($forms); |
|
| 510 | + } |
|
| 511 | 511 | |
| 512 | - private function migrate_to_6() { |
|
| 513 | - global $wpdb; |
|
| 512 | + private function migrate_to_6() { |
|
| 513 | + global $wpdb; |
|
| 514 | 514 | |
| 515 | 515 | $no_save = array_merge( FrmField::no_save_fields(), array( 'form', 'hidden', 'user_id' ) ); |
| 516 | 516 | $fields = FrmDb::get_results( $this->fields, array( 'type NOT' => $no_save ), 'id, field_options' ); |
| 517 | 517 | |
| 518 | - $default_html = <<<DEFAULT_HTML |
|
| 518 | + $default_html = <<<DEFAULT_HTML |
|
| 519 | 519 | <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]"> |
| 520 | 520 | <label class="frm_pos_[label_position]">[field_name] |
| 521 | 521 | <span class="frm_required">[required_label]</span> |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | </div> |
| 526 | 526 | DEFAULT_HTML; |
| 527 | 527 | |
| 528 | - $old_default_html = <<<DEFAULT_HTML |
|
| 528 | + $old_default_html = <<<DEFAULT_HTML |
|
| 529 | 529 | <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]"> |
| 530 | 530 | <label class="frm_pos_[label_position]">[field_name] |
| 531 | 531 | <span class="frm_required">[required_label]</span> |
@@ -535,27 +535,27 @@ discard block |
||
| 535 | 535 | </div> |
| 536 | 536 | DEFAULT_HTML; |
| 537 | 537 | |
| 538 | - $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 539 | - foreach ( $fields as $field ) { |
|
| 540 | - $field->field_options = maybe_unserialize($field->field_options); |
|
| 538 | + $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 539 | + foreach ( $fields as $field ) { |
|
| 540 | + $field->field_options = maybe_unserialize($field->field_options); |
|
| 541 | 541 | $html = FrmField::get_option( $field, 'custom_html' ); |
| 542 | 542 | if ( $html == $default_html || $html == $old_default_html ) { |
| 543 | - $field->field_options['custom_html'] = $new_default_html; |
|
| 543 | + $field->field_options['custom_html'] = $new_default_html; |
|
| 544 | 544 | $wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) ); |
| 545 | - } |
|
| 546 | - unset($field); |
|
| 547 | - } |
|
| 548 | - unset($default_html, $old_default_html, $fields); |
|
| 549 | - } |
|
| 545 | + } |
|
| 546 | + unset($field); |
|
| 547 | + } |
|
| 548 | + unset($default_html, $old_default_html, $fields); |
|
| 549 | + } |
|
| 550 | 550 | |
| 551 | 551 | /** |
| 552 | 552 | * Adds user id to the entry |
| 553 | 553 | */ |
| 554 | - private function migrate_to_4() { |
|
| 555 | - global $wpdb; |
|
| 554 | + private function migrate_to_4() { |
|
| 555 | + global $wpdb; |
|
| 556 | 556 | $user_ids = FrmEntryMeta::getAll( array( 'fi.type' => 'user_id' ) ); |
| 557 | - foreach ( $user_ids as $user_id ) { |
|
| 557 | + foreach ( $user_ids as $user_id ) { |
|
| 558 | 558 | $wpdb->update( $this->entries, array( 'user_id' => $user_id->meta_value ), array( 'id' => $user_id->item_id ) ); |
| 559 | - } |
|
| 560 | - } |
|
| 559 | + } |
|
| 560 | + } |
|
| 561 | 561 | } |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | public $entry_metas; |
| 8 | 8 | |
| 9 | 9 | public function __construct() { |
| 10 | - if ( ! defined('ABSPATH') ) { |
|
| 11 | - die('You are not allowed to call this page directly.'); |
|
| 10 | + if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | + die( 'You are not allowed to call this page directly.' ); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | global $wpdb; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - do_action('frm_after_install'); |
|
| 54 | + do_action( 'frm_after_install' ); |
|
| 55 | 55 | |
| 56 | 56 | $frm_vars['doing_upgrade'] = false; |
| 57 | 57 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | global $wpdb; |
| 166 | 166 | $wpdb->query( $q . $charset_collate ); |
| 167 | 167 | } |
| 168 | - unset($q); |
|
| 168 | + unset( $q ); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | public function uninstall() { |
| 213 | 213 | if ( ! current_user_can( 'administrator' ) ) { |
| 214 | 214 | $frm_settings = FrmAppHelper::get_settings(); |
| 215 | - wp_die($frm_settings->admin_permission); |
|
| 215 | + wp_die( $frm_settings->admin_permission ); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | global $wpdb, $wp_roles; |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); |
| 223 | 223 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); |
| 224 | 224 | |
| 225 | - delete_option('frm_options'); |
|
| 226 | - delete_option('frm_db_version'); |
|
| 225 | + delete_option( 'frm_options' ); |
|
| 226 | + delete_option( 'frm_db_version' ); |
|
| 227 | 227 | |
| 228 | 228 | //delete roles |
| 229 | 229 | $frm_roles = FrmAppHelper::frm_capabilities(); |
@@ -231,11 +231,11 @@ discard block |
||
| 231 | 231 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 232 | 232 | foreach ( $roles as $role => $details ) { |
| 233 | 233 | $wp_roles->remove_cap( $role, $frm_role ); |
| 234 | - unset($role, $details); |
|
| 234 | + unset( $role, $details ); |
|
| 235 | 235 | } |
| 236 | - unset($frm_role, $frm_role_description); |
|
| 236 | + unset( $frm_role, $frm_role_description ); |
|
| 237 | 237 | } |
| 238 | - unset($roles, $frm_roles); |
|
| 238 | + unset( $roles, $frm_roles ); |
|
| 239 | 239 | |
| 240 | 240 | // delete actions, views, and styles |
| 241 | 241 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); |
| 259 | 259 | |
| 260 | - do_action('frm_after_uninstall'); |
|
| 260 | + do_action( 'frm_after_uninstall' ); |
|
| 261 | 261 | return true; |
| 262 | 262 | } |
| 263 | 263 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | continue; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - $widgets[ $k ]['size'] = $size; |
|
| 312 | + $widgets[$k]['size'] = $size; |
|
| 313 | 313 | } |
| 314 | 314 | update_option( 'widget_frm_show_form', $widgets ); |
| 315 | 315 | } |
@@ -390,8 +390,8 @@ discard block |
||
| 390 | 390 | |
| 391 | 391 | $updated = 0; |
| 392 | 392 | foreach ( $fields as $f ) { |
| 393 | - $f->field_options = maybe_unserialize($f->field_options); |
|
| 394 | - if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 393 | + $f->field_options = maybe_unserialize( $f->field_options ); |
|
| 394 | + if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) { |
|
| 395 | 395 | continue; |
| 396 | 396 | } |
| 397 | 397 | |
@@ -399,27 +399,27 @@ discard block |
||
| 399 | 399 | $f->field_options['size'] .= 'px'; |
| 400 | 400 | $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
| 401 | 401 | if ( $u ) { |
| 402 | - $updated++; |
|
| 402 | + $updated ++; |
|
| 403 | 403 | } |
| 404 | - unset($f); |
|
| 404 | + unset( $f ); |
|
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | // Change the characters in widgets to pixels |
| 408 | - $widgets = get_option('widget_frm_show_form'); |
|
| 409 | - if ( empty($widgets) ) { |
|
| 408 | + $widgets = get_option( 'widget_frm_show_form' ); |
|
| 409 | + if ( empty( $widgets ) ) { |
|
| 410 | 410 | return; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - $widgets = maybe_unserialize($widgets); |
|
| 413 | + $widgets = maybe_unserialize( $widgets ); |
|
| 414 | 414 | foreach ( $widgets as $k => $widget ) { |
| 415 | - if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 415 | + if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) { |
|
| 416 | 416 | continue; |
| 417 | 417 | } |
| 418 | 418 | $size = round( $pixel_conversion * (int) $widget['size'] ); |
| 419 | 419 | $size .= 'px'; |
| 420 | - $widgets[ $k ]['size'] = $size; |
|
| 420 | + $widgets[$k]['size'] = $size; |
|
| 421 | 421 | } |
| 422 | - update_option('widget_frm_show_form', $widgets); |
|
| 422 | + update_option( 'widget_frm_show_form', $widgets ); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | /** |
@@ -466,7 +466,7 @@ discard block |
||
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | // Format form options |
| 469 | - $form_options = maybe_unserialize($form->options); |
|
| 469 | + $form_options = maybe_unserialize( $form->options ); |
|
| 470 | 470 | |
| 471 | 471 | // Migrate settings to actions |
| 472 | 472 | FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | private function migrate_to_11() { |
| 477 | 477 | global $wpdb; |
| 478 | 478 | |
| 479 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 479 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options' ); |
|
| 480 | 480 | |
| 481 | 481 | $sending = __( 'Sending', 'formidable' ); |
| 482 | 482 | $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; |
@@ -487,13 +487,13 @@ discard block |
||
| 487 | 487 | <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" /> |
| 488 | 488 | </div> |
| 489 | 489 | DEFAULT_HTML; |
| 490 | - unset($sending, $img); |
|
| 490 | + unset( $sending, $img ); |
|
| 491 | 491 | |
| 492 | - $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 492 | + $new_default_html = FrmFormsHelper::get_default_html( 'submit' ); |
|
| 493 | 493 | $draft_link = FrmFormsHelper::get_draft_link(); |
| 494 | 494 | foreach ( $forms as $form ) { |
| 495 | - $form->options = maybe_unserialize($form->options); |
|
| 496 | - if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 495 | + $form->options = maybe_unserialize( $form->options ); |
|
| 496 | + if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) { |
|
| 497 | 497 | continue; |
| 498 | 498 | } |
| 499 | 499 | |
@@ -504,9 +504,9 @@ discard block |
||
| 504 | 504 | $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] ); |
| 505 | 505 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 506 | 506 | } |
| 507 | - unset($form); |
|
| 507 | + unset( $form ); |
|
| 508 | 508 | } |
| 509 | - unset($forms); |
|
| 509 | + unset( $forms ); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | private function migrate_to_6() { |
@@ -535,17 +535,17 @@ discard block |
||
| 535 | 535 | </div> |
| 536 | 536 | DEFAULT_HTML; |
| 537 | 537 | |
| 538 | - $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 538 | + $new_default_html = FrmFieldsHelper::get_default_html( 'text' ); |
|
| 539 | 539 | foreach ( $fields as $field ) { |
| 540 | - $field->field_options = maybe_unserialize($field->field_options); |
|
| 540 | + $field->field_options = maybe_unserialize( $field->field_options ); |
|
| 541 | 541 | $html = FrmField::get_option( $field, 'custom_html' ); |
| 542 | 542 | if ( $html == $default_html || $html == $old_default_html ) { |
| 543 | 543 | $field->field_options['custom_html'] = $new_default_html; |
| 544 | 544 | $wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) ); |
| 545 | 545 | } |
| 546 | - unset($field); |
|
| 546 | + unset( $field ); |
|
| 547 | 547 | } |
| 548 | - unset($default_html, $old_default_html, $fields); |
|
| 548 | + unset( $default_html, $old_default_html, $fields ); |
|
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | /** |