@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public static $plug_version = '3.01.01'; |
| 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 | - } |
|
| 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 | 25 | |
| 26 | 26 | public static function plugin_folder() { |
| 27 | 27 | return basename( self::plugin_path() ); |
@@ -31,29 +31,29 @@ discard block |
||
| 31 | 31 | return dirname( dirname( dirname( __FILE__ ) ) ); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public static function plugin_url() { |
|
| 35 | - //prevously FRM_URL constant |
|
| 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 | - */ |
|
| 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 | 57 | public static function site_name() { |
| 58 | 58 | return get_option( 'blogname' ); |
| 59 | 59 | } |
@@ -71,14 +71,14 @@ 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 | - */ |
|
| 74 | + /** |
|
| 75 | + * Get the Formidable settings |
|
| 76 | + * |
|
| 77 | + * @since 2.0 |
|
| 78 | + * |
|
| 79 | + * @param None |
|
| 80 | + * @return FrmSettings $frm_setings |
|
| 81 | + */ |
|
| 82 | 82 | public static function get_settings() { |
| 83 | 83 | global $frm_settings; |
| 84 | 84 | if ( empty( $frm_settings ) ) { |
@@ -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 ) { |
|
| 244 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 245 | 245 | $ip = trim( $ip ); // just to be safe |
| 246 | 246 | |
| 247 | 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 | - } |
|
| 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 = '' ) { |
|
| 256 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 257 | 257 | if ( strpos( $param, '[' ) ) { |
| 258 | 258 | $params = explode( '[', $param ); |
| 259 | - $param = $params[0]; |
|
| 260 | - } |
|
| 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( |
@@ -285,8 +285,8 @@ discard block |
||
| 285 | 285 | } |
| 286 | 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 | /** |
| 390 | 390 | * @deprecated 3.01 |
@@ -514,39 +514,39 @@ discard block |
||
| 514 | 514 | ); |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - /** |
|
| 518 | - * Used when switching the action for a bulk action |
|
| 519 | - * @since 2.0 |
|
| 520 | - */ |
|
| 517 | + /** |
|
| 518 | + * Used when switching the action for a bulk action |
|
| 519 | + * @since 2.0 |
|
| 520 | + */ |
|
| 521 | 521 | public static function remove_get_action() { |
| 522 | 522 | if ( ! isset( $_GET ) ) { |
| 523 | 523 | return; |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 527 | - if ( ! empty( $new_action ) ) { |
|
| 526 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 527 | + if ( ! empty( $new_action ) ) { |
|
| 528 | 528 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 529 | - } |
|
| 530 | - } |
|
| 529 | + } |
|
| 530 | + } |
|
| 531 | 531 | |
| 532 | - /** |
|
| 533 | - * Check the WP query for a parameter |
|
| 534 | - * |
|
| 535 | - * @since 2.0 |
|
| 536 | - * @return string|array |
|
| 537 | - */ |
|
| 538 | - public static function get_query_var( $value, $param ) { |
|
| 539 | - if ( $value != '' ) { |
|
| 540 | - return $value; |
|
| 541 | - } |
|
| 532 | + /** |
|
| 533 | + * Check the WP query for a parameter |
|
| 534 | + * |
|
| 535 | + * @since 2.0 |
|
| 536 | + * @return string|array |
|
| 537 | + */ |
|
| 538 | + public static function get_query_var( $value, $param ) { |
|
| 539 | + if ( $value != '' ) { |
|
| 540 | + return $value; |
|
| 541 | + } |
|
| 542 | 542 | |
| 543 | - global $wp_query; |
|
| 544 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 545 | - $value = $wp_query->query_vars[ $param ]; |
|
| 546 | - } |
|
| 543 | + global $wp_query; |
|
| 544 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 545 | + $value = $wp_query->query_vars[ $param ]; |
|
| 546 | + } |
|
| 547 | 547 | |
| 548 | - return $value; |
|
| 549 | - } |
|
| 548 | + return $value; |
|
| 549 | + } |
|
| 550 | 550 | |
| 551 | 551 | /** |
| 552 | 552 | * @since 3.0 |
@@ -568,16 +568,16 @@ discard block |
||
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - /** |
|
| 572 | - * @param string $type |
|
| 573 | - */ |
|
| 574 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 575 | - // only load the form hooks once |
|
| 571 | + /** |
|
| 572 | + * @param string $type |
|
| 573 | + */ |
|
| 574 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 575 | + // only load the form hooks once |
|
| 576 | 576 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 577 | - if ( ! $hooks_loaded ) { |
|
| 577 | + if ( ! $hooks_loaded ) { |
|
| 578 | 578 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 579 | - } |
|
| 580 | - } |
|
| 579 | + } |
|
| 580 | + } |
|
| 581 | 581 | |
| 582 | 582 | /** |
| 583 | 583 | * Save all front-end js scripts into a single file |
@@ -599,29 +599,29 @@ discard block |
||
| 599 | 599 | $new_file->combine_files( $files ); |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - /** |
|
| 603 | - * Check a value from a shortcode to see if true or false. |
|
| 604 | - * True when value is 1, true, 'true', 'yes' |
|
| 605 | - * |
|
| 606 | - * @since 1.07.10 |
|
| 607 | - * |
|
| 608 | - * @param string $value The value to compare |
|
| 609 | - * @return boolean True or False |
|
| 610 | - */ |
|
| 602 | + /** |
|
| 603 | + * Check a value from a shortcode to see if true or false. |
|
| 604 | + * True when value is 1, true, 'true', 'yes' |
|
| 605 | + * |
|
| 606 | + * @since 1.07.10 |
|
| 607 | + * |
|
| 608 | + * @param string $value The value to compare |
|
| 609 | + * @return boolean True or False |
|
| 610 | + */ |
|
| 611 | 611 | public static function is_true( $value ) { |
| 612 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 613 | - } |
|
| 612 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 613 | + } |
|
| 614 | 614 | |
| 615 | - /** |
|
| 616 | - * Used to filter shortcode in text widgets |
|
| 615 | + /** |
|
| 616 | + * Used to filter shortcode in text widgets |
|
| 617 | 617 | * |
| 618 | 618 | * @deprecated 2.5.4 |
| 619 | 619 | * @codeCoverageIgnore |
| 620 | - */ |
|
| 621 | - public static function widget_text_filter_callback( $matches ) { |
|
| 620 | + */ |
|
| 621 | + public static function widget_text_filter_callback( $matches ) { |
|
| 622 | 622 | _deprecated_function( __METHOD__, '2.5.4' ); |
| 623 | - return do_shortcode( $matches[0] ); |
|
| 624 | - } |
|
| 623 | + return do_shortcode( $matches[0] ); |
|
| 624 | + } |
|
| 625 | 625 | |
| 626 | 626 | public static function get_pages() { |
| 627 | 627 | return get_posts( array( |
@@ -633,10 +633,10 @@ discard block |
||
| 633 | 633 | ) ); |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 637 | - $pages = self::get_pages(); |
|
| 636 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 637 | + $pages = self::get_pages(); |
|
| 638 | 638 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 639 | - ?> |
|
| 639 | + ?> |
|
| 640 | 640 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
| 641 | 641 | <option value=""> </option> |
| 642 | 642 | <?php foreach ( $pages as $page ) { ?> |
@@ -646,16 +646,16 @@ discard block |
||
| 646 | 646 | <?php } ?> |
| 647 | 647 | </select> |
| 648 | 648 | <?php |
| 649 | - } |
|
| 649 | + } |
|
| 650 | 650 | |
| 651 | 651 | public static function post_edit_link( $post_id ) { |
| 652 | 652 | $post = get_post( $post_id ); |
| 653 | - if ( $post ) { |
|
| 653 | + if ( $post ) { |
|
| 654 | 654 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 655 | 655 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 656 | - } |
|
| 657 | - return ''; |
|
| 658 | - } |
|
| 656 | + } |
|
| 657 | + return ''; |
|
| 658 | + } |
|
| 659 | 659 | |
| 660 | 660 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 661 | 661 | ?> |
@@ -666,73 +666,73 @@ discard block |
||
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | public static function roles_options( $capability ) { |
| 669 | - global $frm_vars; |
|
| 669 | + global $frm_vars; |
|
| 670 | 670 | if ( isset( $frm_vars['editable_roles'] ) ) { |
| 671 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 672 | - } else { |
|
| 673 | - $editable_roles = get_editable_roles(); |
|
| 674 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 675 | - } |
|
| 671 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 672 | + } else { |
|
| 673 | + $editable_roles = get_editable_roles(); |
|
| 674 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 675 | + } |
|
| 676 | 676 | |
| 677 | - foreach ( $editable_roles as $role => $details ) { |
|
| 677 | + foreach ( $editable_roles as $role => $details ) { |
|
| 678 | 678 | $name = translate_user_role( $details['name'] ); |
| 679 | 679 | ?> |
| 680 | 680 | <option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option> |
| 681 | 681 | <?php |
| 682 | 682 | unset( $role, $details ); |
| 683 | - } |
|
| 684 | - } |
|
| 683 | + } |
|
| 684 | + } |
|
| 685 | 685 | |
| 686 | 686 | public static function frm_capabilities( $type = 'auto' ) { |
| 687 | - $cap = array( |
|
| 688 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 689 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 690 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 691 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 692 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 693 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 694 | - ); |
|
| 687 | + $cap = array( |
|
| 688 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 689 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 690 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 691 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 692 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 693 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 694 | + ); |
|
| 695 | 695 | |
| 696 | 696 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 697 | - return $cap; |
|
| 698 | - } |
|
| 697 | + return $cap; |
|
| 698 | + } |
|
| 699 | 699 | |
| 700 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 701 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 702 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 703 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 700 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 701 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 702 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 703 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 704 | 704 | |
| 705 | - return $cap; |
|
| 706 | - } |
|
| 705 | + return $cap; |
|
| 706 | + } |
|
| 707 | 707 | |
| 708 | 708 | public static function user_has_permission( $needed_role ) { |
| 709 | - if ( $needed_role == '-1' ) { |
|
| 710 | - return false; |
|
| 709 | + if ( $needed_role == '-1' ) { |
|
| 710 | + return false; |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 714 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 715 | - return true; |
|
| 716 | - } |
|
| 713 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 714 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 715 | + return true; |
|
| 716 | + } |
|
| 717 | 717 | |
| 718 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 719 | - foreach ( $roles as $role ) { |
|
| 718 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 719 | + foreach ( $roles as $role ) { |
|
| 720 | 720 | if ( current_user_can( $role ) ) { |
| 721 | - return true; |
|
| 721 | + return true; |
|
| 722 | 722 | } |
| 723 | - if ( $role == $needed_role ) { |
|
| 724 | - break; |
|
| 723 | + if ( $role == $needed_role ) { |
|
| 724 | + break; |
|
| 725 | 725 | } |
| 726 | - } |
|
| 727 | - return false; |
|
| 728 | - } |
|
| 729 | - |
|
| 730 | - /** |
|
| 731 | - * Make sure administrators can see Formidable menu |
|
| 732 | - * |
|
| 733 | - * @since 2.0 |
|
| 734 | - */ |
|
| 735 | - public static function maybe_add_permissions() { |
|
| 726 | + } |
|
| 727 | + return false; |
|
| 728 | + } |
|
| 729 | + |
|
| 730 | + /** |
|
| 731 | + * Make sure administrators can see Formidable menu |
|
| 732 | + * |
|
| 733 | + * @since 2.0 |
|
| 734 | + */ |
|
| 735 | + public static function maybe_add_permissions() { |
|
| 736 | 736 | self::force_capability( 'frm_view_entries' ); |
| 737 | 737 | |
| 738 | 738 | if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
@@ -741,12 +741,12 @@ discard block |
||
| 741 | 741 | |
| 742 | 742 | $user_id = get_current_user_id(); |
| 743 | 743 | $user = new WP_User( $user_id ); |
| 744 | - $frm_roles = self::frm_capabilities(); |
|
| 745 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 744 | + $frm_roles = self::frm_capabilities(); |
|
| 745 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 746 | 746 | $user->add_cap( $frm_role ); |
| 747 | 747 | unset( $frm_role, $frm_role_description ); |
| 748 | - } |
|
| 749 | - } |
|
| 748 | + } |
|
| 749 | + } |
|
| 750 | 750 | |
| 751 | 751 | /** |
| 752 | 752 | * Make sure admins have permission to see the menu items |
@@ -762,28 +762,28 @@ discard block |
||
| 762 | 762 | } |
| 763 | 763 | } |
| 764 | 764 | |
| 765 | - /** |
|
| 766 | - * Check if the user has permision for action. |
|
| 767 | - * Return permission message and stop the action if no permission |
|
| 768 | - * @since 2.0 |
|
| 769 | - * @param string $permission |
|
| 770 | - */ |
|
| 765 | + /** |
|
| 766 | + * Check if the user has permision for action. |
|
| 767 | + * Return permission message and stop the action if no permission |
|
| 768 | + * @since 2.0 |
|
| 769 | + * @param string $permission |
|
| 770 | + */ |
|
| 771 | 771 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 772 | 772 | $permission_error = self::permission_nonce_error( $permission ); |
| 773 | - if ( $permission_error !== false ) { |
|
| 774 | - if ( 'hide' == $show_message ) { |
|
| 775 | - $permission_error = ''; |
|
| 776 | - } |
|
| 773 | + if ( $permission_error !== false ) { |
|
| 774 | + if ( 'hide' == $show_message ) { |
|
| 775 | + $permission_error = ''; |
|
| 776 | + } |
|
| 777 | 777 | wp_die( $permission_error ); |
| 778 | - } |
|
| 779 | - } |
|
| 780 | - |
|
| 781 | - /** |
|
| 782 | - * Check user permission and nonce |
|
| 783 | - * @since 2.0 |
|
| 784 | - * @param string $permission |
|
| 785 | - * @return false|string The permission message or false if allowed |
|
| 786 | - */ |
|
| 778 | + } |
|
| 779 | + } |
|
| 780 | + |
|
| 781 | + /** |
|
| 782 | + * Check user permission and nonce |
|
| 783 | + * @since 2.0 |
|
| 784 | + * @param string $permission |
|
| 785 | + * @return false|string The permission message or false if allowed |
|
| 786 | + */ |
|
| 787 | 787 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 788 | 788 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 789 | 789 | $frm_settings = self::get_settings(); |
@@ -792,22 +792,22 @@ discard block |
||
| 792 | 792 | |
| 793 | 793 | $error = false; |
| 794 | 794 | if ( empty( $nonce_name ) ) { |
| 795 | - return $error; |
|
| 796 | - } |
|
| 795 | + return $error; |
|
| 796 | + } |
|
| 797 | 797 | |
| 798 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 799 | - $frm_settings = self::get_settings(); |
|
| 800 | - $error = $frm_settings->admin_permission; |
|
| 801 | - } |
|
| 798 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 799 | + $frm_settings = self::get_settings(); |
|
| 800 | + $error = $frm_settings->admin_permission; |
|
| 801 | + } |
|
| 802 | 802 | |
| 803 | - return $error; |
|
| 804 | - } |
|
| 803 | + return $error; |
|
| 804 | + } |
|
| 805 | 805 | |
| 806 | - public static function checked( $values, $current ) { |
|
| 806 | + public static function checked( $values, $current ) { |
|
| 807 | 807 | if ( self::check_selected( $values, $current ) ) { |
| 808 | - echo ' checked="checked"'; |
|
| 808 | + echo ' checked="checked"'; |
|
| 809 | 809 | } |
| 810 | - } |
|
| 810 | + } |
|
| 811 | 811 | |
| 812 | 812 | public static function check_selected( $values, $current ) { |
| 813 | 813 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -845,24 +845,24 @@ discard block |
||
| 845 | 845 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | - /** |
|
| 849 | - * Flatten a multi-dimensional array |
|
| 850 | - */ |
|
| 848 | + /** |
|
| 849 | + * Flatten a multi-dimensional array |
|
| 850 | + */ |
|
| 851 | 851 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 852 | - $return = array(); |
|
| 853 | - foreach ( $array as $key => $value ) { |
|
| 852 | + $return = array(); |
|
| 853 | + foreach ( $array as $key => $value ) { |
|
| 854 | 854 | if ( is_array( $value ) ) { |
| 855 | 855 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 856 | - } else { |
|
| 856 | + } else { |
|
| 857 | 857 | if ( $keys == 'keep' ) { |
| 858 | 858 | $return[ $key ] = $value; |
| 859 | 859 | } else { |
| 860 | 860 | $return[] = $value; |
| 861 | 861 | } |
| 862 | - } |
|
| 863 | - } |
|
| 864 | - return $return; |
|
| 865 | - } |
|
| 862 | + } |
|
| 863 | + } |
|
| 864 | + return $return; |
|
| 865 | + } |
|
| 866 | 866 | |
| 867 | 867 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 868 | 868 | $safe_text = str_replace( '"', '"', $text ); |
@@ -873,10 +873,10 @@ discard block |
||
| 873 | 873 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 874 | 874 | } |
| 875 | 875 | |
| 876 | - /** |
|
| 877 | - * Add auto paragraphs to text areas |
|
| 878 | - * @since 2.0 |
|
| 879 | - */ |
|
| 876 | + /** |
|
| 877 | + * Add auto paragraphs to text areas |
|
| 878 | + * @since 2.0 |
|
| 879 | + */ |
|
| 880 | 880 | public static function use_wpautop( $content ) { |
| 881 | 881 | if ( apply_filters( 'frm_use_wpautop', true ) ) { |
| 882 | 882 | $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
@@ -885,26 +885,26 @@ discard block |
||
| 885 | 885 | } |
| 886 | 886 | |
| 887 | 887 | public static function replace_quotes( $val ) { |
| 888 | - //Replace double quotes |
|
| 888 | + //Replace double quotes |
|
| 889 | 889 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 890 | - //Replace single quotes |
|
| 891 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 892 | - return $val; |
|
| 893 | - } |
|
| 894 | - |
|
| 895 | - /** |
|
| 896 | - * @since 2.0 |
|
| 897 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 898 | - */ |
|
| 899 | - public static function jquery_ui_base_url() { |
|
| 890 | + //Replace single quotes |
|
| 891 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 892 | + return $val; |
|
| 893 | + } |
|
| 894 | + |
|
| 895 | + /** |
|
| 896 | + * @since 2.0 |
|
| 897 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 898 | + */ |
|
| 899 | + public static function jquery_ui_base_url() { |
|
| 900 | 900 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 901 | 901 | $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
| 902 | - return $url; |
|
| 903 | - } |
|
| 902 | + return $url; |
|
| 903 | + } |
|
| 904 | 904 | |
| 905 | - /** |
|
| 906 | - * @param string $handle |
|
| 907 | - */ |
|
| 905 | + /** |
|
| 906 | + * @param string $handle |
|
| 907 | + */ |
|
| 908 | 908 | public static function script_version( $handle, $default = 0 ) { |
| 909 | 909 | global $wp_scripts; |
| 910 | 910 | if ( ! $wp_scripts ) { |
@@ -926,12 +926,12 @@ discard block |
||
| 926 | 926 | |
| 927 | 927 | public static function js_redirect( $url ) { |
| 928 | 928 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 929 | - } |
|
| 929 | + } |
|
| 930 | 930 | |
| 931 | 931 | public static function get_user_id_param( $user_id ) { |
| 932 | 932 | if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
| 933 | - return $user_id; |
|
| 934 | - } |
|
| 933 | + return $user_id; |
|
| 934 | + } |
|
| 935 | 935 | |
| 936 | 936 | $user_id = sanitize_text_field( $user_id ); |
| 937 | 937 | if ( $user_id == 'current' ) { |
@@ -943,14 +943,14 @@ discard block |
||
| 943 | 943 | $user = get_user_by( 'login', $user_id ); |
| 944 | 944 | } |
| 945 | 945 | |
| 946 | - if ( $user ) { |
|
| 947 | - $user_id = $user->ID; |
|
| 948 | - } |
|
| 946 | + if ( $user ) { |
|
| 947 | + $user_id = $user->ID; |
|
| 948 | + } |
|
| 949 | 949 | unset( $user ); |
| 950 | - } |
|
| 950 | + } |
|
| 951 | 951 | |
| 952 | - return $user_id; |
|
| 953 | - } |
|
| 952 | + return $user_id; |
|
| 953 | + } |
|
| 954 | 954 | |
| 955 | 955 | public static function get_file_contents( $filename, $atts = array() ) { |
| 956 | 956 | if ( ! is_file( $filename ) ) { |
@@ -965,28 +965,28 @@ discard block |
||
| 965 | 965 | return $contents; |
| 966 | 966 | } |
| 967 | 967 | |
| 968 | - /** |
|
| 969 | - * @param string $table_name |
|
| 970 | - * @param string $column |
|
| 968 | + /** |
|
| 969 | + * @param string $table_name |
|
| 970 | + * @param string $column |
|
| 971 | 971 | * @param int $id |
| 972 | 972 | * @param int $num_chars |
| 973 | - */ |
|
| 974 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 975 | - $key = ''; |
|
| 973 | + */ |
|
| 974 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 975 | + $key = ''; |
|
| 976 | 976 | |
| 977 | - if ( ! empty( $name ) ) { |
|
| 977 | + if ( ! empty( $name ) ) { |
|
| 978 | 978 | $key = sanitize_key( $name ); |
| 979 | - } |
|
| 979 | + } |
|
| 980 | 980 | |
| 981 | 981 | if ( empty( $key ) ) { |
| 982 | 982 | $max_slug_value = pow( 36, $num_chars ); |
| 983 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 983 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 984 | 984 | $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
| 985 | - } |
|
| 985 | + } |
|
| 986 | 986 | |
| 987 | 987 | if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 988 | 988 | $key = $key . 'a'; |
| 989 | - } |
|
| 989 | + } |
|
| 990 | 990 | |
| 991 | 991 | $key_check = FrmDb::get_var( $table_name, array( |
| 992 | 992 | $column => $key, |
@@ -994,7 +994,7 @@ discard block |
||
| 994 | 994 | ), $column ); |
| 995 | 995 | |
| 996 | 996 | if ( $key_check || is_numeric( $key_check ) ) { |
| 997 | - $suffix = 2; |
|
| 997 | + $suffix = 2; |
|
| 998 | 998 | do { |
| 999 | 999 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 1000 | 1000 | $key_check = FrmDb::get_var( $table_name, array( |
@@ -1004,19 +1004,19 @@ discard block |
||
| 1004 | 1004 | $suffix++; |
| 1005 | 1005 | } while ( $key_check || is_numeric( $key_check ) ); |
| 1006 | 1006 | $key = $alt_post_name; |
| 1007 | - } |
|
| 1008 | - return $key; |
|
| 1009 | - } |
|
| 1010 | - |
|
| 1011 | - /** |
|
| 1012 | - * Editing a Form or Entry |
|
| 1013 | - * @param string $table |
|
| 1014 | - * @return bool|array |
|
| 1015 | - */ |
|
| 1016 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1017 | - if ( ! $record ) { |
|
| 1018 | - return false; |
|
| 1019 | - } |
|
| 1007 | + } |
|
| 1008 | + return $key; |
|
| 1009 | + } |
|
| 1010 | + |
|
| 1011 | + /** |
|
| 1012 | + * Editing a Form or Entry |
|
| 1013 | + * @param string $table |
|
| 1014 | + * @return bool|array |
|
| 1015 | + */ |
|
| 1016 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1017 | + if ( ! $record ) { |
|
| 1018 | + return false; |
|
| 1019 | + } |
|
| 1020 | 1020 | |
| 1021 | 1021 | if ( empty( $post_values ) ) { |
| 1022 | 1022 | $post_values = stripslashes_deep( $_POST ); |
@@ -1039,14 +1039,14 @@ discard block |
||
| 1039 | 1039 | |
| 1040 | 1040 | self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) ); |
| 1041 | 1041 | |
| 1042 | - if ( $table == 'entries' ) { |
|
| 1043 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1044 | - } else if ( $table == 'forms' ) { |
|
| 1045 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1046 | - } |
|
| 1042 | + if ( $table == 'entries' ) { |
|
| 1043 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1044 | + } else if ( $table == 'forms' ) { |
|
| 1045 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1046 | + } |
|
| 1047 | 1047 | |
| 1048 | - return $values; |
|
| 1049 | - } |
|
| 1048 | + return $values; |
|
| 1049 | + } |
|
| 1050 | 1050 | |
| 1051 | 1051 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 1052 | 1052 | if ( ! empty( $fields ) ) { |
@@ -1059,46 +1059,46 @@ discard block |
||
| 1059 | 1059 | } |
| 1060 | 1060 | |
| 1061 | 1061 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1062 | - $post_values = $args['post_values']; |
|
| 1062 | + $post_values = $args['post_values']; |
|
| 1063 | 1063 | |
| 1064 | - if ( $args['default'] ) { |
|
| 1065 | - $meta_value = $field->default_value; |
|
| 1066 | - } else { |
|
| 1064 | + if ( $args['default'] ) { |
|
| 1065 | + $meta_value = $field->default_value; |
|
| 1066 | + } else { |
|
| 1067 | 1067 | if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
| 1068 | 1068 | if ( ! isset( $field->field_options['custom_field'] ) ) { |
| 1069 | - $field->field_options['custom_field'] = ''; |
|
| 1070 | - } |
|
| 1069 | + $field->field_options['custom_field'] = ''; |
|
| 1070 | + } |
|
| 1071 | 1071 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( |
| 1072 | 1072 | 'truncate' => false, |
| 1073 | 1073 | 'type' => $field->type, |
| 1074 | 1074 | 'form_id' => $field->form_id, |
| 1075 | 1075 | 'field' => $field, |
| 1076 | 1076 | ) ); |
| 1077 | - } else { |
|
| 1077 | + } else { |
|
| 1078 | 1078 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1079 | - } |
|
| 1080 | - } |
|
| 1079 | + } |
|
| 1080 | + } |
|
| 1081 | 1081 | |
| 1082 | 1082 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1083 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1083 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1084 | 1084 | |
| 1085 | 1085 | $field_array = self::start_field_array( $field ); |
| 1086 | 1086 | $field_array['value'] = $new_value; |
| 1087 | 1087 | $field_array['type'] = apply_filters( 'frm_field_type', $field_type, $field, $new_value ); |
| 1088 | 1088 | $field_array['parent_form_id'] = $args['parent_form_id']; |
| 1089 | 1089 | |
| 1090 | - $args['field_type'] = $field_type; |
|
| 1090 | + $args['field_type'] = $field_type; |
|
| 1091 | 1091 | |
| 1092 | 1092 | FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args ); |
| 1093 | 1093 | |
| 1094 | 1094 | if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
| 1095 | - $field_array['unique_msg'] = ''; |
|
| 1096 | - } |
|
| 1095 | + $field_array['unique_msg'] = ''; |
|
| 1096 | + } |
|
| 1097 | 1097 | |
| 1098 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1098 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1099 | 1099 | |
| 1100 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1101 | - } |
|
| 1100 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1101 | + } |
|
| 1102 | 1102 | |
| 1103 | 1103 | /** |
| 1104 | 1104 | * @since 3.0 |
@@ -1119,20 +1119,20 @@ discard block |
||
| 1119 | 1119 | ); |
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | - /** |
|
| 1123 | - * @param string $table |
|
| 1124 | - */ |
|
| 1122 | + /** |
|
| 1123 | + * @param string $table |
|
| 1124 | + */ |
|
| 1125 | 1125 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1126 | - if ( $table == 'entries' ) { |
|
| 1127 | - $form = $record->form_id; |
|
| 1126 | + if ( $table == 'entries' ) { |
|
| 1127 | + $form = $record->form_id; |
|
| 1128 | 1128 | FrmForm::maybe_get_form( $form ); |
| 1129 | - } else { |
|
| 1130 | - $form = $record; |
|
| 1131 | - } |
|
| 1129 | + } else { |
|
| 1130 | + $form = $record; |
|
| 1131 | + } |
|
| 1132 | 1132 | |
| 1133 | - if ( ! $form ) { |
|
| 1134 | - return; |
|
| 1135 | - } |
|
| 1133 | + if ( ! $form ) { |
|
| 1134 | + return; |
|
| 1135 | + } |
|
| 1136 | 1136 | |
| 1137 | 1137 | $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
| 1138 | 1138 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
@@ -1141,26 +1141,26 @@ discard block |
||
| 1141 | 1141 | return; |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | - foreach ( $form->options as $opt => $value ) { |
|
| 1145 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1146 | - } |
|
| 1144 | + foreach ( $form->options as $opt => $value ) { |
|
| 1145 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1146 | + } |
|
| 1147 | 1147 | |
| 1148 | 1148 | self::fill_form_defaults( $post_values, $values ); |
| 1149 | - } |
|
| 1149 | + } |
|
| 1150 | 1150 | |
| 1151 | - /** |
|
| 1152 | - * Set to POST value or default |
|
| 1153 | - */ |
|
| 1151 | + /** |
|
| 1152 | + * Set to POST value or default |
|
| 1153 | + */ |
|
| 1154 | 1154 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1155 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1155 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1156 | 1156 | |
| 1157 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1158 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1157 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1158 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1159 | 1159 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1160 | - } |
|
| 1160 | + } |
|
| 1161 | 1161 | |
| 1162 | 1162 | unset( $opt, $default ); |
| 1163 | - } |
|
| 1163 | + } |
|
| 1164 | 1164 | |
| 1165 | 1165 | if ( ! isset( $values['custom_style'] ) ) { |
| 1166 | 1166 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1169,10 +1169,10 @@ discard block |
||
| 1169 | 1169 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1170 | 1170 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1171 | 1171 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1172 | - } |
|
| 1172 | + } |
|
| 1173 | 1173 | unset( $h ); |
| 1174 | - } |
|
| 1175 | - } |
|
| 1174 | + } |
|
| 1175 | + } |
|
| 1176 | 1176 | |
| 1177 | 1177 | /** |
| 1178 | 1178 | * @since 2.2.10 |
@@ -1195,33 +1195,33 @@ discard block |
||
| 1195 | 1195 | if ( $possible_email_field ) { |
| 1196 | 1196 | $class .= 'show_frm_not_email_to'; |
| 1197 | 1197 | } |
| 1198 | - ?> |
|
| 1198 | + ?> |
|
| 1199 | 1199 | <li> |
| 1200 | 1200 | <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> |
| 1201 | 1201 | <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> |
| 1202 | 1202 | <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> |
| 1203 | 1203 | </li> |
| 1204 | 1204 | <?php |
| 1205 | - } |
|
| 1205 | + } |
|
| 1206 | 1206 | |
| 1207 | 1207 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1208 | - if ( is_array( $str ) ) { |
|
| 1209 | - return ''; |
|
| 1208 | + if ( is_array( $str ) ) { |
|
| 1209 | + return ''; |
|
| 1210 | 1210 | } |
| 1211 | 1211 | |
| 1212 | - $length = (int) $length; |
|
| 1212 | + $length = (int) $length; |
|
| 1213 | 1213 | $str = wp_strip_all_tags( $str ); |
| 1214 | 1214 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1215 | 1215 | |
| 1216 | 1216 | if ( $length == 0 ) { |
| 1217 | - return ''; |
|
| 1218 | - } else if ( $length <= 10 ) { |
|
| 1217 | + return ''; |
|
| 1218 | + } else if ( $length <= 10 ) { |
|
| 1219 | 1219 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1220 | 1220 | return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
| 1221 | - } |
|
| 1221 | + } |
|
| 1222 | 1222 | |
| 1223 | - $sub = ''; |
|
| 1224 | - $len = 0; |
|
| 1223 | + $sub = ''; |
|
| 1224 | + $len = 0; |
|
| 1225 | 1225 | |
| 1226 | 1226 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1227 | 1227 | |
@@ -1229,21 +1229,21 @@ discard block |
||
| 1229 | 1229 | $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
| 1230 | 1230 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1231 | 1231 | if ( $total_len > $length && str_word_count( $sub ) ) { |
| 1232 | - break; |
|
| 1233 | - } |
|
| 1232 | + break; |
|
| 1233 | + } |
|
| 1234 | 1234 | |
| 1235 | - $sub .= $part; |
|
| 1235 | + $sub .= $part; |
|
| 1236 | 1236 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1237 | 1237 | |
| 1238 | 1238 | if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
| 1239 | - break; |
|
| 1240 | - } |
|
| 1239 | + break; |
|
| 1240 | + } |
|
| 1241 | 1241 | |
| 1242 | 1242 | unset( $total_len, $word ); |
| 1243 | - } |
|
| 1243 | + } |
|
| 1244 | 1244 | |
| 1245 | 1245 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
| 1246 | - } |
|
| 1246 | + } |
|
| 1247 | 1247 | |
| 1248 | 1248 | public static function mb_function( $function_names, $args ) { |
| 1249 | 1249 | $mb_function_name = $function_names[0]; |
@@ -1256,17 +1256,17 @@ discard block |
||
| 1256 | 1256 | |
| 1257 | 1257 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1258 | 1258 | if ( empty( $date ) ) { |
| 1259 | - return $date; |
|
| 1260 | - } |
|
| 1259 | + return $date; |
|
| 1260 | + } |
|
| 1261 | 1261 | |
| 1262 | 1262 | if ( empty( $date_format ) ) { |
| 1263 | 1263 | $date_format = get_option( 'date_format' ); |
| 1264 | 1264 | } |
| 1265 | 1265 | |
| 1266 | 1266 | if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
| 1267 | - $frmpro_settings = new FrmProSettings(); |
|
| 1267 | + $frmpro_settings = new FrmProSettings(); |
|
| 1268 | 1268 | $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
| 1269 | - } |
|
| 1269 | + } |
|
| 1270 | 1270 | |
| 1271 | 1271 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1272 | 1272 | |
@@ -1275,8 +1275,8 @@ discard block |
||
| 1275 | 1275 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1276 | 1276 | } |
| 1277 | 1277 | |
| 1278 | - return $formatted; |
|
| 1279 | - } |
|
| 1278 | + return $formatted; |
|
| 1279 | + } |
|
| 1280 | 1280 | |
| 1281 | 1281 | private static function add_time_to_date( $time_format, $date ) { |
| 1282 | 1282 | if ( empty( $time_format ) ) { |
@@ -1358,32 +1358,32 @@ discard block |
||
| 1358 | 1358 | ); |
| 1359 | 1359 | } |
| 1360 | 1360 | |
| 1361 | - // Pagination Methods |
|
| 1361 | + // Pagination Methods |
|
| 1362 | 1362 | |
| 1363 | - /** |
|
| 1364 | - * @param integer $current_p |
|
| 1365 | - */ |
|
| 1363 | + /** |
|
| 1364 | + * @param integer $current_p |
|
| 1365 | + */ |
|
| 1366 | 1366 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1367 | 1367 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | - /** |
|
| 1371 | - * @param integer $current_p |
|
| 1372 | - */ |
|
| 1373 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1374 | - if ( $current_p == 1 ) { |
|
| 1375 | - return 1; |
|
| 1376 | - } else { |
|
| 1377 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1378 | - } |
|
| 1379 | - } |
|
| 1370 | + /** |
|
| 1371 | + * @param integer $current_p |
|
| 1372 | + */ |
|
| 1373 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1374 | + if ( $current_p == 1 ) { |
|
| 1375 | + return 1; |
|
| 1376 | + } else { |
|
| 1377 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1378 | + } |
|
| 1379 | + } |
|
| 1380 | 1380 | |
| 1381 | 1381 | /** |
| 1382 | 1382 | * @return array |
| 1383 | 1383 | */ |
| 1384 | 1384 | public static function json_to_array( $json_vars ) { |
| 1385 | - $vars = array(); |
|
| 1386 | - foreach ( $json_vars as $jv ) { |
|
| 1385 | + $vars = array(); |
|
| 1386 | + foreach ( $json_vars as $jv ) { |
|
| 1387 | 1387 | $jv_name = explode( '[', $jv['name'] ); |
| 1388 | 1388 | $last = count( $jv_name ) - 1; |
| 1389 | 1389 | foreach ( $jv_name as $p => $n ) { |
@@ -1400,77 +1400,77 @@ discard block |
||
| 1400 | 1400 | $l3 = $name; |
| 1401 | 1401 | } |
| 1402 | 1402 | |
| 1403 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1403 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1404 | 1404 | |
| 1405 | - switch ( $p ) { |
|
| 1406 | - case 0: |
|
| 1407 | - $l1 = $name; |
|
| 1408 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1405 | + switch ( $p ) { |
|
| 1406 | + case 0: |
|
| 1407 | + $l1 = $name; |
|
| 1408 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1409 | 1409 | break; |
| 1410 | 1410 | |
| 1411 | - case 1: |
|
| 1412 | - $l2 = $name; |
|
| 1413 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1411 | + case 1: |
|
| 1412 | + $l2 = $name; |
|
| 1413 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1414 | 1414 | break; |
| 1415 | 1415 | |
| 1416 | - case 2: |
|
| 1417 | - $l3 = $name; |
|
| 1418 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1416 | + case 2: |
|
| 1417 | + $l3 = $name; |
|
| 1418 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1419 | 1419 | break; |
| 1420 | 1420 | |
| 1421 | - case 3: |
|
| 1422 | - $l4 = $name; |
|
| 1423 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1424 | - } |
|
| 1421 | + case 3: |
|
| 1422 | + $l4 = $name; |
|
| 1423 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1424 | + } |
|
| 1425 | 1425 | |
| 1426 | 1426 | unset( $this_val, $n ); |
| 1427 | - } |
|
| 1427 | + } |
|
| 1428 | 1428 | |
| 1429 | 1429 | unset( $last, $jv ); |
| 1430 | - } |
|
| 1431 | - |
|
| 1432 | - return $vars; |
|
| 1433 | - } |
|
| 1434 | - |
|
| 1435 | - /** |
|
| 1436 | - * @param string $name |
|
| 1437 | - * @param string $l1 |
|
| 1438 | - */ |
|
| 1439 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1440 | - if ( $name == '' ) { |
|
| 1441 | - $vars[] = $val; |
|
| 1442 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1443 | - $vars[ $l1 ] = $val; |
|
| 1444 | - } |
|
| 1445 | - } |
|
| 1430 | + } |
|
| 1431 | + |
|
| 1432 | + return $vars; |
|
| 1433 | + } |
|
| 1434 | + |
|
| 1435 | + /** |
|
| 1436 | + * @param string $name |
|
| 1437 | + * @param string $l1 |
|
| 1438 | + */ |
|
| 1439 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1440 | + if ( $name == '' ) { |
|
| 1441 | + $vars[] = $val; |
|
| 1442 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1443 | + $vars[ $l1 ] = $val; |
|
| 1444 | + } |
|
| 1445 | + } |
|
| 1446 | 1446 | |
| 1447 | 1447 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1448 | - $tooltips = array( |
|
| 1449 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1450 | - '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' ), |
|
| 1451 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1452 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1453 | - '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' ), |
|
| 1454 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1455 | - '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() ) ), |
|
| 1456 | - ); |
|
| 1457 | - |
|
| 1458 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1459 | - return; |
|
| 1460 | - } |
|
| 1461 | - |
|
| 1462 | - if ( 'open' == $class ) { |
|
| 1463 | - echo ' frm_help"'; |
|
| 1464 | - } else { |
|
| 1465 | - echo ' class="frm_help"'; |
|
| 1466 | - } |
|
| 1448 | + $tooltips = array( |
|
| 1449 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1450 | + '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' ), |
|
| 1451 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1452 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1453 | + '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' ), |
|
| 1454 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1455 | + '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() ) ), |
|
| 1456 | + ); |
|
| 1457 | + |
|
| 1458 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1459 | + return; |
|
| 1460 | + } |
|
| 1461 | + |
|
| 1462 | + if ( 'open' == $class ) { |
|
| 1463 | + echo ' frm_help"'; |
|
| 1464 | + } else { |
|
| 1465 | + echo ' class="frm_help"'; |
|
| 1466 | + } |
|
| 1467 | 1467 | |
| 1468 | 1468 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1469 | 1469 | |
| 1470 | - if ( 'open' != $class ) { |
|
| 1471 | - echo '"'; |
|
| 1472 | - } |
|
| 1473 | - } |
|
| 1470 | + if ( 'open' != $class ) { |
|
| 1471 | + echo '"'; |
|
| 1472 | + } |
|
| 1473 | + } |
|
| 1474 | 1474 | |
| 1475 | 1475 | /** |
| 1476 | 1476 | * Add the current_page class to that page in the form nav |
@@ -1486,35 +1486,35 @@ discard block |
||
| 1486 | 1486 | } |
| 1487 | 1487 | } |
| 1488 | 1488 | |
| 1489 | - /** |
|
| 1490 | - * Prepare and json_encode post content |
|
| 1491 | - * |
|
| 1492 | - * @since 2.0 |
|
| 1493 | - * |
|
| 1494 | - * @param array $post_content |
|
| 1495 | - * @return string $post_content ( json encoded array ) |
|
| 1496 | - */ |
|
| 1497 | - public static function prepare_and_encode( $post_content ) { |
|
| 1498 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1489 | + /** |
|
| 1490 | + * Prepare and json_encode post content |
|
| 1491 | + * |
|
| 1492 | + * @since 2.0 |
|
| 1493 | + * |
|
| 1494 | + * @param array $post_content |
|
| 1495 | + * @return string $post_content ( json encoded array ) |
|
| 1496 | + */ |
|
| 1497 | + public static function prepare_and_encode( $post_content ) { |
|
| 1498 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1499 | 1499 | foreach ( $post_content as $key => $val ) { |
| 1500 | 1500 | // Replace problematic characters (like ") |
| 1501 | 1501 | $val = str_replace( '"', '"', $val ); |
| 1502 | 1502 | |
| 1503 | 1503 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1504 | - unset( $key, $val ); |
|
| 1505 | - } |
|
| 1504 | + unset( $key, $val ); |
|
| 1505 | + } |
|
| 1506 | 1506 | |
| 1507 | - // json_encode the array |
|
| 1508 | - $post_content = json_encode( $post_content ); |
|
| 1507 | + // json_encode the array |
|
| 1508 | + $post_content = json_encode( $post_content ); |
|
| 1509 | 1509 | |
| 1510 | - // add extra slashes for \r\n since WP strips them |
|
| 1510 | + // add extra slashes for \r\n since WP strips them |
|
| 1511 | 1511 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1512 | 1512 | |
| 1513 | - // allow for " |
|
| 1514 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1513 | + // allow for " |
|
| 1514 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1515 | 1515 | |
| 1516 | - return $post_content; |
|
| 1517 | - } |
|
| 1516 | + return $post_content; |
|
| 1517 | + } |
|
| 1518 | 1518 | |
| 1519 | 1519 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1520 | 1520 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1537,63 +1537,63 @@ discard block |
||
| 1537 | 1537 | |
| 1538 | 1538 | public static function maybe_json_decode( $string ) { |
| 1539 | 1539 | if ( is_array( $string ) ) { |
| 1540 | - return $string; |
|
| 1541 | - } |
|
| 1540 | + return $string; |
|
| 1541 | + } |
|
| 1542 | 1542 | |
| 1543 | 1543 | $new_string = json_decode( $string, true ); |
| 1544 | 1544 | if ( function_exists( 'json_last_error' ) ) { |
| 1545 | 1545 | // php 5.3+ |
| 1546 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1547 | - $string = $new_string; |
|
| 1548 | - } |
|
| 1546 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1547 | + $string = $new_string; |
|
| 1548 | + } |
|
| 1549 | 1549 | } elseif ( isset( $new_string ) ) { |
| 1550 | 1550 | // php < 5.3 fallback |
| 1551 | - $string = $new_string; |
|
| 1552 | - } |
|
| 1553 | - return $string; |
|
| 1554 | - } |
|
| 1555 | - |
|
| 1556 | - /** |
|
| 1557 | - * @since 1.07.10 |
|
| 1558 | - * |
|
| 1559 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1560 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1561 | - */ |
|
| 1551 | + $string = $new_string; |
|
| 1552 | + } |
|
| 1553 | + return $string; |
|
| 1554 | + } |
|
| 1555 | + |
|
| 1556 | + /** |
|
| 1557 | + * @since 1.07.10 |
|
| 1558 | + * |
|
| 1559 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1560 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1561 | + */ |
|
| 1562 | 1562 | public static function maybe_highlight_menu( $post_type ) { |
| 1563 | - global $post; |
|
| 1563 | + global $post; |
|
| 1564 | 1564 | |
| 1565 | 1565 | if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
| 1566 | - return; |
|
| 1567 | - } |
|
| 1566 | + return; |
|
| 1567 | + } |
|
| 1568 | 1568 | |
| 1569 | 1569 | if ( is_object( $post ) && $post->post_type != $post_type ) { |
| 1570 | - return; |
|
| 1571 | - } |
|
| 1570 | + return; |
|
| 1571 | + } |
|
| 1572 | 1572 | |
| 1573 | - self::load_admin_wide_js(); |
|
| 1574 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1575 | - } |
|
| 1573 | + self::load_admin_wide_js(); |
|
| 1574 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1575 | + } |
|
| 1576 | 1576 | |
| 1577 | - /** |
|
| 1578 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1579 | - * @since 2.0 |
|
| 1580 | - */ |
|
| 1577 | + /** |
|
| 1578 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1579 | + * @since 2.0 |
|
| 1580 | + */ |
|
| 1581 | 1581 | public static function load_admin_wide_js( $load = true ) { |
| 1582 | - $version = FrmAppHelper::plugin_version(); |
|
| 1582 | + $version = FrmAppHelper::plugin_version(); |
|
| 1583 | 1583 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1584 | 1584 | |
| 1585 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1585 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1586 | 1586 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1587 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1587 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1588 | 1588 | 'url' => FrmAppHelper::plugin_url(), |
| 1589 | 1589 | 'loading' => __( 'Loading…' ), |
| 1590 | 1590 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
| 1591 | - ) ); |
|
| 1591 | + ) ); |
|
| 1592 | 1592 | |
| 1593 | 1593 | if ( $load ) { |
| 1594 | 1594 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1595 | 1595 | } |
| 1596 | - } |
|
| 1596 | + } |
|
| 1597 | 1597 | |
| 1598 | 1598 | /** |
| 1599 | 1599 | * @since 2.0.9 |
@@ -1602,9 +1602,9 @@ discard block |
||
| 1602 | 1602 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1603 | 1603 | } |
| 1604 | 1604 | |
| 1605 | - /** |
|
| 1606 | - * @param string $location |
|
| 1607 | - */ |
|
| 1605 | + /** |
|
| 1606 | + * @param string $location |
|
| 1607 | + */ |
|
| 1608 | 1608 | public static function localize_script( $location ) { |
| 1609 | 1609 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1610 | 1610 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1664,27 +1664,27 @@ discard block |
||
| 1664 | 1664 | } |
| 1665 | 1665 | } |
| 1666 | 1666 | |
| 1667 | - /** |
|
| 1667 | + /** |
|
| 1668 | 1668 | * echo the message on the plugins listing page |
| 1669 | - * @since 1.07.10 |
|
| 1670 | - * |
|
| 1671 | - * @param float $min_version The version the add-on requires |
|
| 1672 | - */ |
|
| 1669 | + * @since 1.07.10 |
|
| 1670 | + * |
|
| 1671 | + * @param float $min_version The version the add-on requires |
|
| 1672 | + */ |
|
| 1673 | 1673 | public static function min_version_notice( $min_version ) { |
| 1674 | - $frm_version = self::plugin_version(); |
|
| 1674 | + $frm_version = self::plugin_version(); |
|
| 1675 | 1675 | |
| 1676 | - // check if Formidable meets minimum requirements |
|
| 1676 | + // check if Formidable meets minimum requirements |
|
| 1677 | 1677 | if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
| 1678 | - return; |
|
| 1679 | - } |
|
| 1678 | + return; |
|
| 1679 | + } |
|
| 1680 | 1680 | |
| 1681 | 1681 | $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
| 1682 | 1682 | 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">' . |
| 1683 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1684 | - '</div></td></tr>'; |
|
| 1685 | - } |
|
| 1683 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1684 | + '</div></td></tr>'; |
|
| 1685 | + } |
|
| 1686 | 1686 | |
| 1687 | - public static function locales( $type = 'date' ) { |
|
| 1687 | + public static function locales( $type = 'date' ) { |
|
| 1688 | 1688 | $locales = array( |
| 1689 | 1689 | 'en' => __( 'English', 'formidable' ), |
| 1690 | 1690 | '' => __( 'English/Western', 'formidable' ), |
@@ -1763,8 +1763,8 @@ discard block |
||
| 1763 | 1763 | $locales = array_diff_key( $locales, array_flip( $unset ) ); |
| 1764 | 1764 | $locales = apply_filters( 'frm_locales', $locales ); |
| 1765 | 1765 | |
| 1766 | - return $locales; |
|
| 1767 | - } |
|
| 1766 | + return $locales; |
|
| 1767 | + } |
|
| 1768 | 1768 | |
| 1769 | 1769 | /** |
| 1770 | 1770 | * Prepare and save settings in styles and actions |