@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public static $plug_version = '3.06.06'; |
| 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 | } |
@@ -107,14 +107,14 @@ discard block |
||
| 107 | 107 | return add_query_arg( $query_args, $page ) . $anchor; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - /** |
|
| 111 | - * Get the Formidable settings |
|
| 112 | - * |
|
| 113 | - * @since 2.0 |
|
| 114 | - * |
|
| 115 | - * @param array $args - May include the form id when values need translation. |
|
| 116 | - * @return FrmSettings $frm_setings |
|
| 117 | - */ |
|
| 110 | + /** |
|
| 111 | + * Get the Formidable settings |
|
| 112 | + * |
|
| 113 | + * @since 2.0 |
|
| 114 | + * |
|
| 115 | + * @param array $args - May include the form id when values need translation. |
|
| 116 | + * @return FrmSettings $frm_setings |
|
| 117 | + */ |
|
| 118 | 118 | public static function get_settings( $args = array() ) { |
| 119 | 119 | global $frm_settings; |
| 120 | 120 | if ( empty( $frm_settings ) ) { |
@@ -179,50 +179,50 @@ discard block |
||
| 179 | 179 | return $is_formidable; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - /** |
|
| 183 | - * Check for certain page in Formidable settings |
|
| 184 | - * |
|
| 185 | - * @since 2.0 |
|
| 186 | - * |
|
| 187 | - * @param string $page The name of the page to check |
|
| 188 | - * @return boolean |
|
| 189 | - */ |
|
| 182 | + /** |
|
| 183 | + * Check for certain page in Formidable settings |
|
| 184 | + * |
|
| 185 | + * @since 2.0 |
|
| 186 | + * |
|
| 187 | + * @param string $page The name of the page to check |
|
| 188 | + * @return boolean |
|
| 189 | + */ |
|
| 190 | 190 | public static function is_admin_page( $page = 'formidable' ) { |
| 191 | - global $pagenow; |
|
| 191 | + global $pagenow; |
|
| 192 | 192 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 193 | - if ( $pagenow ) { |
|
| 193 | + if ( $pagenow ) { |
|
| 194 | 194 | // allow this to be true during ajax load i.e. ajax form builder loading |
| 195 | 195 | return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page; |
| 196 | - } |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | 198 | return is_admin() && $get_page == $page; |
| 199 | - } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * Check for the form preview page |
|
| 203 | - * |
|
| 204 | - * @since 2.0 |
|
| 205 | - * |
|
| 206 | - * @param None |
|
| 207 | - * @return boolean |
|
| 208 | - */ |
|
| 209 | - public static function is_preview_page() { |
|
| 210 | - global $pagenow; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * Check for the form preview page |
|
| 203 | + * |
|
| 204 | + * @since 2.0 |
|
| 205 | + * |
|
| 206 | + * @param None |
|
| 207 | + * @return boolean |
|
| 208 | + */ |
|
| 209 | + public static function is_preview_page() { |
|
| 210 | + global $pagenow; |
|
| 211 | 211 | $action = self::simple_get( 'action', 'sanitize_title' ); |
| 212 | 212 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 213 | - } |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * Check for ajax except the form preview page |
|
| 217 | - * |
|
| 218 | - * @since 2.0 |
|
| 219 | - * |
|
| 220 | - * @param None |
|
| 221 | - * @return boolean |
|
| 222 | - */ |
|
| 223 | - public static function doing_ajax() { |
|
| 224 | - return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 225 | - } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * Check for ajax except the form preview page |
|
| 217 | + * |
|
| 218 | + * @since 2.0 |
|
| 219 | + * |
|
| 220 | + * @param None |
|
| 221 | + * @return boolean |
|
| 222 | + */ |
|
| 223 | + public static function doing_ajax() { |
|
| 224 | + return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | 227 | public static function js_suffix() { |
| 228 | 228 | return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
@@ -250,52 +250,52 @@ discard block |
||
| 250 | 250 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - /** |
|
| 254 | - * Check if on an admin page |
|
| 255 | - * |
|
| 256 | - * @since 2.0 |
|
| 257 | - * |
|
| 258 | - * @param None |
|
| 259 | - * @return boolean |
|
| 260 | - */ |
|
| 261 | - public static function is_admin() { |
|
| 262 | - return is_admin() && ! self::wp_doing_ajax(); |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - /** |
|
| 266 | - * Check if value contains blank value or empty array |
|
| 267 | - * |
|
| 268 | - * @since 2.0 |
|
| 269 | - * @param mixed $value - value to check |
|
| 253 | + /** |
|
| 254 | + * Check if on an admin page |
|
| 255 | + * |
|
| 256 | + * @since 2.0 |
|
| 257 | + * |
|
| 258 | + * @param None |
|
| 259 | + * @return boolean |
|
| 260 | + */ |
|
| 261 | + public static function is_admin() { |
|
| 262 | + return is_admin() && ! self::wp_doing_ajax(); |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + /** |
|
| 266 | + * Check if value contains blank value or empty array |
|
| 267 | + * |
|
| 268 | + * @since 2.0 |
|
| 269 | + * @param mixed $value - value to check |
|
| 270 | 270 | * @param string |
| 271 | - * @return boolean |
|
| 272 | - */ |
|
| 273 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 274 | - return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 278 | - return ! self::is_empty_value( $value, $empty ); |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - /** |
|
| 282 | - * Get any value from the $_SERVER |
|
| 283 | - * |
|
| 284 | - * @since 2.0 |
|
| 285 | - * @param string $value |
|
| 286 | - * @return string |
|
| 287 | - */ |
|
| 271 | + * @return boolean |
|
| 272 | + */ |
|
| 273 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 274 | + return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 278 | + return ! self::is_empty_value( $value, $empty ); |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + /** |
|
| 282 | + * Get any value from the $_SERVER |
|
| 283 | + * |
|
| 284 | + * @since 2.0 |
|
| 285 | + * @param string $value |
|
| 286 | + * @return string |
|
| 287 | + */ |
|
| 288 | 288 | public static function get_server_value( $value ) { |
| 289 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - /** |
|
| 293 | - * Check for the IP address in several places |
|
| 294 | - * Used by [ip] shortcode |
|
| 295 | - * |
|
| 296 | - * @return string The IP address of the current user |
|
| 297 | - */ |
|
| 298 | - public static function get_ip_address() { |
|
| 289 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + /** |
|
| 293 | + * Check for the IP address in several places |
|
| 294 | + * Used by [ip] shortcode |
|
| 295 | + * |
|
| 296 | + * @return string The IP address of the current user |
|
| 297 | + */ |
|
| 298 | + public static function get_ip_address() { |
|
| 299 | 299 | $ip_options = array( |
| 300 | 300 | 'HTTP_CLIENT_IP', |
| 301 | 301 | 'HTTP_CF_CONNECTING_IP', |
@@ -309,33 +309,33 @@ discard block |
||
| 309 | 309 | ); |
| 310 | 310 | $ip = ''; |
| 311 | 311 | foreach ( $ip_options as $key ) { |
| 312 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 313 | - continue; |
|
| 314 | - } |
|
| 312 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 313 | + continue; |
|
| 314 | + } |
|
| 315 | 315 | |
| 316 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 316 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 317 | 317 | $ip = trim( $ip ); // just to be safe |
| 318 | 318 | |
| 319 | 319 | if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
| 320 | - return sanitize_text_field( $ip ); |
|
| 321 | - } |
|
| 322 | - } |
|
| 323 | - } |
|
| 320 | + return sanitize_text_field( $ip ); |
|
| 321 | + } |
|
| 322 | + } |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | 325 | return sanitize_text_field( $ip ); |
| 326 | - } |
|
| 326 | + } |
|
| 327 | 327 | |
| 328 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 328 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 329 | 329 | if ( strpos( $param, '[' ) ) { |
| 330 | 330 | $params = explode( '[', $param ); |
| 331 | - $param = $params[0]; |
|
| 332 | - } |
|
| 331 | + $param = $params[0]; |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | 334 | if ( $src == 'get' ) { |
| 335 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 336 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 337 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 338 | - } |
|
| 335 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 336 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 337 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 338 | + } |
|
| 339 | 339 | self::sanitize_value( $sanitize, $value ); |
| 340 | 340 | } else { |
| 341 | 341 | $value = self::get_simple_request( |
@@ -359,8 +359,8 @@ discard block |
||
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - return $value; |
|
| 363 | - } |
|
| 362 | + return $value; |
|
| 363 | + } |
|
| 364 | 364 | |
| 365 | 365 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
| 366 | 366 | return self::get_simple_request( |
@@ -428,12 +428,12 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | /** |
| 431 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 432 | - * |
|
| 433 | - * @since 2.0.8 |
|
| 434 | - * @param string $value |
|
| 435 | - * @return string $value |
|
| 436 | - */ |
|
| 431 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 432 | + * |
|
| 433 | + * @since 2.0.8 |
|
| 434 | + * @param string $value |
|
| 435 | + * @return string $value |
|
| 436 | + */ |
|
| 437 | 437 | public static function preserve_backslashes( $value ) { |
| 438 | 438 | // If backslashes have already been added, don't add them again |
| 439 | 439 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -455,14 +455,14 @@ discard block |
||
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 459 | - $temp_values = $values; |
|
| 460 | - foreach ( $temp_values as $k => $val ) { |
|
| 461 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 458 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 459 | + $temp_values = $values; |
|
| 460 | + foreach ( $temp_values as $k => $val ) { |
|
| 461 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 462 | 462 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 463 | - } |
|
| 464 | - } |
|
| 465 | - } |
|
| 463 | + } |
|
| 464 | + } |
|
| 465 | + } |
|
| 466 | 466 | |
| 467 | 467 | /** |
| 468 | 468 | * Sanitize the value, and allow some HTML |
@@ -599,40 +599,40 @@ discard block |
||
| 599 | 599 | ); |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | - /** |
|
| 603 | - * Used when switching the action for a bulk action |
|
| 602 | + /** |
|
| 603 | + * Used when switching the action for a bulk action |
|
| 604 | 604 | * |
| 605 | - * @since 2.0 |
|
| 606 | - */ |
|
| 605 | + * @since 2.0 |
|
| 606 | + */ |
|
| 607 | 607 | public static function remove_get_action() { |
| 608 | 608 | if ( ! isset( $_GET ) ) { |
| 609 | 609 | return; |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 613 | - if ( ! empty( $new_action ) ) { |
|
| 612 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 613 | + if ( ! empty( $new_action ) ) { |
|
| 614 | 614 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', self::get_server_value( 'REQUEST_URI' ) ); |
| 615 | - } |
|
| 616 | - } |
|
| 615 | + } |
|
| 616 | + } |
|
| 617 | 617 | |
| 618 | - /** |
|
| 619 | - * Check the WP query for a parameter |
|
| 620 | - * |
|
| 621 | - * @since 2.0 |
|
| 622 | - * @return string|array |
|
| 623 | - */ |
|
| 624 | - public static function get_query_var( $value, $param ) { |
|
| 625 | - if ( $value != '' ) { |
|
| 626 | - return $value; |
|
| 627 | - } |
|
| 618 | + /** |
|
| 619 | + * Check the WP query for a parameter |
|
| 620 | + * |
|
| 621 | + * @since 2.0 |
|
| 622 | + * @return string|array |
|
| 623 | + */ |
|
| 624 | + public static function get_query_var( $value, $param ) { |
|
| 625 | + if ( $value != '' ) { |
|
| 626 | + return $value; |
|
| 627 | + } |
|
| 628 | 628 | |
| 629 | - global $wp_query; |
|
| 630 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 631 | - $value = $wp_query->query_vars[ $param ]; |
|
| 632 | - } |
|
| 629 | + global $wp_query; |
|
| 630 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 631 | + $value = $wp_query->query_vars[ $param ]; |
|
| 632 | + } |
|
| 633 | 633 | |
| 634 | - return $value; |
|
| 635 | - } |
|
| 634 | + return $value; |
|
| 635 | + } |
|
| 636 | 636 | |
| 637 | 637 | /** |
| 638 | 638 | * @since 3.0 |
@@ -684,16 +684,16 @@ discard block |
||
| 684 | 684 | <?php |
| 685 | 685 | } |
| 686 | 686 | |
| 687 | - /** |
|
| 688 | - * @param string $type |
|
| 689 | - */ |
|
| 690 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 691 | - // only load the form hooks once |
|
| 687 | + /** |
|
| 688 | + * @param string $type |
|
| 689 | + */ |
|
| 690 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 691 | + // only load the form hooks once |
|
| 692 | 692 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 693 | - if ( ! $hooks_loaded ) { |
|
| 693 | + if ( ! $hooks_loaded ) { |
|
| 694 | 694 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 695 | - } |
|
| 696 | - } |
|
| 695 | + } |
|
| 696 | + } |
|
| 697 | 697 | |
| 698 | 698 | /** |
| 699 | 699 | * Save all front-end js scripts into a single file |
@@ -718,18 +718,18 @@ discard block |
||
| 718 | 718 | $new_file->combine_files( $files ); |
| 719 | 719 | } |
| 720 | 720 | |
| 721 | - /** |
|
| 722 | - * Check a value from a shortcode to see if true or false. |
|
| 723 | - * True when value is 1, true, 'true', 'yes' |
|
| 724 | - * |
|
| 725 | - * @since 1.07.10 |
|
| 726 | - * |
|
| 727 | - * @param string $value The value to compare |
|
| 728 | - * @return boolean True or False |
|
| 729 | - */ |
|
| 721 | + /** |
|
| 722 | + * Check a value from a shortcode to see if true or false. |
|
| 723 | + * True when value is 1, true, 'true', 'yes' |
|
| 724 | + * |
|
| 725 | + * @since 1.07.10 |
|
| 726 | + * |
|
| 727 | + * @param string $value The value to compare |
|
| 728 | + * @return boolean True or False |
|
| 729 | + */ |
|
| 730 | 730 | public static function is_true( $value ) { |
| 731 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 732 | - } |
|
| 731 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 732 | + } |
|
| 733 | 733 | |
| 734 | 734 | public static function get_pages() { |
| 735 | 735 | $query = array( |
@@ -742,10 +742,10 @@ discard block |
||
| 742 | 742 | return get_posts( $query ); |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 746 | - $pages = self::get_pages(); |
|
| 745 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 746 | + $pages = self::get_pages(); |
|
| 747 | 747 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 748 | - ?> |
|
| 748 | + ?> |
|
| 749 | 749 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
| 750 | 750 | <option value=""> </option> |
| 751 | 751 | <?php foreach ( $pages as $page ) { ?> |
@@ -755,16 +755,16 @@ discard block |
||
| 755 | 755 | <?php } ?> |
| 756 | 756 | </select> |
| 757 | 757 | <?php |
| 758 | - } |
|
| 758 | + } |
|
| 759 | 759 | |
| 760 | 760 | public static function post_edit_link( $post_id ) { |
| 761 | 761 | $post = get_post( $post_id ); |
| 762 | - if ( $post ) { |
|
| 762 | + if ( $post ) { |
|
| 763 | 763 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 764 | 764 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 765 | - } |
|
| 766 | - return ''; |
|
| 767 | - } |
|
| 765 | + } |
|
| 766 | + return ''; |
|
| 767 | + } |
|
| 768 | 768 | |
| 769 | 769 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 770 | 770 | ?> |
@@ -775,73 +775,73 @@ discard block |
||
| 775 | 775 | } |
| 776 | 776 | |
| 777 | 777 | public static function roles_options( $capability ) { |
| 778 | - global $frm_vars; |
|
| 778 | + global $frm_vars; |
|
| 779 | 779 | if ( isset( $frm_vars['editable_roles'] ) ) { |
| 780 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 781 | - } else { |
|
| 782 | - $editable_roles = get_editable_roles(); |
|
| 783 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 784 | - } |
|
| 780 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 781 | + } else { |
|
| 782 | + $editable_roles = get_editable_roles(); |
|
| 783 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 784 | + } |
|
| 785 | 785 | |
| 786 | - foreach ( $editable_roles as $role => $details ) { |
|
| 786 | + foreach ( $editable_roles as $role => $details ) { |
|
| 787 | 787 | $name = translate_user_role( $details['name'] ); |
| 788 | 788 | ?> |
| 789 | 789 | <option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option> |
| 790 | 790 | <?php |
| 791 | 791 | unset( $role, $details ); |
| 792 | - } |
|
| 793 | - } |
|
| 792 | + } |
|
| 793 | + } |
|
| 794 | 794 | |
| 795 | 795 | public static function frm_capabilities( $type = 'auto' ) { |
| 796 | - $cap = array( |
|
| 797 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 798 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 799 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 800 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 801 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 802 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 803 | - ); |
|
| 796 | + $cap = array( |
|
| 797 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 798 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 799 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 800 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 801 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 802 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 803 | + ); |
|
| 804 | 804 | |
| 805 | 805 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 806 | - return $cap; |
|
| 807 | - } |
|
| 806 | + return $cap; |
|
| 807 | + } |
|
| 808 | 808 | |
| 809 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 810 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 811 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 812 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 809 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 810 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 811 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 812 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 813 | 813 | |
| 814 | - return $cap; |
|
| 815 | - } |
|
| 814 | + return $cap; |
|
| 815 | + } |
|
| 816 | 816 | |
| 817 | 817 | public static function user_has_permission( $needed_role ) { |
| 818 | - if ( $needed_role == '-1' ) { |
|
| 819 | - return false; |
|
| 818 | + if ( $needed_role == '-1' ) { |
|
| 819 | + return false; |
|
| 820 | 820 | } |
| 821 | 821 | |
| 822 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 823 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 824 | - return true; |
|
| 825 | - } |
|
| 822 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 823 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 824 | + return true; |
|
| 825 | + } |
|
| 826 | 826 | |
| 827 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 828 | - foreach ( $roles as $role ) { |
|
| 827 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 828 | + foreach ( $roles as $role ) { |
|
| 829 | 829 | if ( current_user_can( $role ) ) { |
| 830 | - return true; |
|
| 830 | + return true; |
|
| 831 | 831 | } |
| 832 | - if ( $role == $needed_role ) { |
|
| 833 | - break; |
|
| 832 | + if ( $role == $needed_role ) { |
|
| 833 | + break; |
|
| 834 | 834 | } |
| 835 | - } |
|
| 836 | - return false; |
|
| 837 | - } |
|
| 838 | - |
|
| 839 | - /** |
|
| 840 | - * Make sure administrators can see Formidable menu |
|
| 841 | - * |
|
| 842 | - * @since 2.0 |
|
| 843 | - */ |
|
| 844 | - public static function maybe_add_permissions() { |
|
| 835 | + } |
|
| 836 | + return false; |
|
| 837 | + } |
|
| 838 | + |
|
| 839 | + /** |
|
| 840 | + * Make sure administrators can see Formidable menu |
|
| 841 | + * |
|
| 842 | + * @since 2.0 |
|
| 843 | + */ |
|
| 844 | + public static function maybe_add_permissions() { |
|
| 845 | 845 | self::force_capability( 'frm_view_entries' ); |
| 846 | 846 | |
| 847 | 847 | if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
@@ -850,12 +850,12 @@ discard block |
||
| 850 | 850 | |
| 851 | 851 | $user_id = get_current_user_id(); |
| 852 | 852 | $user = new WP_User( $user_id ); |
| 853 | - $frm_roles = self::frm_capabilities(); |
|
| 854 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 853 | + $frm_roles = self::frm_capabilities(); |
|
| 854 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 855 | 855 | $user->add_cap( $frm_role ); |
| 856 | 856 | unset( $frm_role, $frm_role_description ); |
| 857 | - } |
|
| 858 | - } |
|
| 857 | + } |
|
| 858 | + } |
|
| 859 | 859 | |
| 860 | 860 | /** |
| 861 | 861 | * Make sure admins have permission to see the menu items |
@@ -872,30 +872,30 @@ discard block |
||
| 872 | 872 | } |
| 873 | 873 | } |
| 874 | 874 | |
| 875 | - /** |
|
| 876 | - * Check if the user has permision for action. |
|
| 877 | - * Return permission message and stop the action if no permission |
|
| 875 | + /** |
|
| 876 | + * Check if the user has permision for action. |
|
| 877 | + * Return permission message and stop the action if no permission |
|
| 878 | 878 | * |
| 879 | - * @since 2.0 |
|
| 880 | - * @param string $permission |
|
| 881 | - */ |
|
| 879 | + * @since 2.0 |
|
| 880 | + * @param string $permission |
|
| 881 | + */ |
|
| 882 | 882 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 883 | 883 | $permission_error = self::permission_nonce_error( $permission ); |
| 884 | - if ( $permission_error !== false ) { |
|
| 885 | - if ( 'hide' == $show_message ) { |
|
| 886 | - $permission_error = ''; |
|
| 887 | - } |
|
| 884 | + if ( $permission_error !== false ) { |
|
| 885 | + if ( 'hide' == $show_message ) { |
|
| 886 | + $permission_error = ''; |
|
| 887 | + } |
|
| 888 | 888 | wp_die( esc_html( $permission_error ) ); |
| 889 | - } |
|
| 890 | - } |
|
| 889 | + } |
|
| 890 | + } |
|
| 891 | 891 | |
| 892 | - /** |
|
| 893 | - * Check user permission and nonce |
|
| 892 | + /** |
|
| 893 | + * Check user permission and nonce |
|
| 894 | 894 | * |
| 895 | - * @since 2.0 |
|
| 896 | - * @param string $permission |
|
| 897 | - * @return false|string The permission message or false if allowed |
|
| 898 | - */ |
|
| 895 | + * @since 2.0 |
|
| 896 | + * @param string $permission |
|
| 897 | + * @return false|string The permission message or false if allowed |
|
| 898 | + */ |
|
| 899 | 899 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 900 | 900 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 901 | 901 | $frm_settings = self::get_settings(); |
@@ -904,22 +904,22 @@ discard block |
||
| 904 | 904 | |
| 905 | 905 | $error = false; |
| 906 | 906 | if ( empty( $nonce_name ) ) { |
| 907 | - return $error; |
|
| 908 | - } |
|
| 907 | + return $error; |
|
| 908 | + } |
|
| 909 | 909 | |
| 910 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 911 | - $frm_settings = self::get_settings(); |
|
| 912 | - $error = $frm_settings->admin_permission; |
|
| 913 | - } |
|
| 910 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 911 | + $frm_settings = self::get_settings(); |
|
| 912 | + $error = $frm_settings->admin_permission; |
|
| 913 | + } |
|
| 914 | 914 | |
| 915 | - return $error; |
|
| 916 | - } |
|
| 915 | + return $error; |
|
| 916 | + } |
|
| 917 | 917 | |
| 918 | - public static function checked( $values, $current ) { |
|
| 918 | + public static function checked( $values, $current ) { |
|
| 919 | 919 | if ( self::check_selected( $values, $current ) ) { |
| 920 | - echo ' checked="checked"'; |
|
| 920 | + echo ' checked="checked"'; |
|
| 921 | 921 | } |
| 922 | - } |
|
| 922 | + } |
|
| 923 | 923 | |
| 924 | 924 | public static function check_selected( $values, $current ) { |
| 925 | 925 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -957,24 +957,24 @@ discard block |
||
| 957 | 957 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 958 | 958 | } |
| 959 | 959 | |
| 960 | - /** |
|
| 961 | - * Flatten a multi-dimensional array |
|
| 962 | - */ |
|
| 960 | + /** |
|
| 961 | + * Flatten a multi-dimensional array |
|
| 962 | + */ |
|
| 963 | 963 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 964 | - $return = array(); |
|
| 965 | - foreach ( $array as $key => $value ) { |
|
| 964 | + $return = array(); |
|
| 965 | + foreach ( $array as $key => $value ) { |
|
| 966 | 966 | if ( is_array( $value ) ) { |
| 967 | 967 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 968 | - } else { |
|
| 968 | + } else { |
|
| 969 | 969 | if ( $keys == 'keep' ) { |
| 970 | 970 | $return[ $key ] = $value; |
| 971 | 971 | } else { |
| 972 | 972 | $return[] = $value; |
| 973 | 973 | } |
| 974 | - } |
|
| 975 | - } |
|
| 976 | - return $return; |
|
| 977 | - } |
|
| 974 | + } |
|
| 975 | + } |
|
| 976 | + return $return; |
|
| 977 | + } |
|
| 978 | 978 | |
| 979 | 979 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 980 | 980 | $safe_text = str_replace( '"', '"', $text ); |
@@ -985,11 +985,11 @@ discard block |
||
| 985 | 985 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 986 | 986 | } |
| 987 | 987 | |
| 988 | - /** |
|
| 989 | - * Add auto paragraphs to text areas |
|
| 988 | + /** |
|
| 989 | + * Add auto paragraphs to text areas |
|
| 990 | 990 | * |
| 991 | - * @since 2.0 |
|
| 992 | - */ |
|
| 991 | + * @since 2.0 |
|
| 992 | + */ |
|
| 993 | 993 | public static function use_wpautop( $content ) { |
| 994 | 994 | if ( apply_filters( 'frm_use_wpautop', true ) ) { |
| 995 | 995 | $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
@@ -998,26 +998,26 @@ discard block |
||
| 998 | 998 | } |
| 999 | 999 | |
| 1000 | 1000 | public static function replace_quotes( $val ) { |
| 1001 | - //Replace double quotes |
|
| 1001 | + //Replace double quotes |
|
| 1002 | 1002 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 1003 | - //Replace single quotes |
|
| 1004 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 1005 | - return $val; |
|
| 1006 | - } |
|
| 1007 | - |
|
| 1008 | - /** |
|
| 1009 | - * @since 2.0 |
|
| 1010 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 1011 | - */ |
|
| 1012 | - public static function jquery_ui_base_url() { |
|
| 1003 | + //Replace single quotes |
|
| 1004 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 1005 | + return $val; |
|
| 1006 | + } |
|
| 1007 | + |
|
| 1008 | + /** |
|
| 1009 | + * @since 2.0 |
|
| 1010 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 1011 | + */ |
|
| 1012 | + public static function jquery_ui_base_url() { |
|
| 1013 | 1013 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 1014 | 1014 | $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
| 1015 | - return $url; |
|
| 1016 | - } |
|
| 1015 | + return $url; |
|
| 1016 | + } |
|
| 1017 | 1017 | |
| 1018 | - /** |
|
| 1019 | - * @param string $handle |
|
| 1020 | - */ |
|
| 1018 | + /** |
|
| 1019 | + * @param string $handle |
|
| 1020 | + */ |
|
| 1021 | 1021 | public static function script_version( $handle, $default = 0 ) { |
| 1022 | 1022 | global $wp_scripts; |
| 1023 | 1023 | if ( ! $wp_scripts ) { |
@@ -1039,12 +1039,12 @@ discard block |
||
| 1039 | 1039 | |
| 1040 | 1040 | public static function js_redirect( $url ) { |
| 1041 | 1041 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 1042 | - } |
|
| 1042 | + } |
|
| 1043 | 1043 | |
| 1044 | 1044 | public static function get_user_id_param( $user_id ) { |
| 1045 | 1045 | if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
| 1046 | - return $user_id; |
|
| 1047 | - } |
|
| 1046 | + return $user_id; |
|
| 1047 | + } |
|
| 1048 | 1048 | |
| 1049 | 1049 | $user_id = sanitize_text_field( $user_id ); |
| 1050 | 1050 | if ( $user_id == 'current' ) { |
@@ -1056,14 +1056,14 @@ discard block |
||
| 1056 | 1056 | $user = get_user_by( 'login', $user_id ); |
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | - if ( $user ) { |
|
| 1060 | - $user_id = $user->ID; |
|
| 1061 | - } |
|
| 1059 | + if ( $user ) { |
|
| 1060 | + $user_id = $user->ID; |
|
| 1061 | + } |
|
| 1062 | 1062 | unset( $user ); |
| 1063 | - } |
|
| 1063 | + } |
|
| 1064 | 1064 | |
| 1065 | - return $user_id; |
|
| 1066 | - } |
|
| 1065 | + return $user_id; |
|
| 1066 | + } |
|
| 1067 | 1067 | |
| 1068 | 1068 | public static function get_file_contents( $filename, $atts = array() ) { |
| 1069 | 1069 | if ( ! is_file( $filename ) ) { |
@@ -1078,28 +1078,28 @@ discard block |
||
| 1078 | 1078 | return $contents; |
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | - /** |
|
| 1082 | - * @param string $table_name |
|
| 1083 | - * @param string $column |
|
| 1081 | + /** |
|
| 1082 | + * @param string $table_name |
|
| 1083 | + * @param string $column |
|
| 1084 | 1084 | * @param int $id |
| 1085 | 1085 | * @param int $num_chars |
| 1086 | - */ |
|
| 1087 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 1088 | - $key = ''; |
|
| 1086 | + */ |
|
| 1087 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 1088 | + $key = ''; |
|
| 1089 | 1089 | |
| 1090 | - if ( ! empty( $name ) ) { |
|
| 1090 | + if ( ! empty( $name ) ) { |
|
| 1091 | 1091 | $key = sanitize_key( $name ); |
| 1092 | - } |
|
| 1092 | + } |
|
| 1093 | 1093 | |
| 1094 | 1094 | if ( empty( $key ) ) { |
| 1095 | 1095 | $max_slug_value = pow( 36, $num_chars ); |
| 1096 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 1096 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 1097 | 1097 | $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
| 1098 | - } |
|
| 1098 | + } |
|
| 1099 | 1099 | |
| 1100 | 1100 | if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 1101 | 1101 | $key = $key . 'a'; |
| 1102 | - } |
|
| 1102 | + } |
|
| 1103 | 1103 | |
| 1104 | 1104 | $key_check = FrmDb::get_var( |
| 1105 | 1105 | $table_name, |
@@ -1111,7 +1111,7 @@ discard block |
||
| 1111 | 1111 | ); |
| 1112 | 1112 | |
| 1113 | 1113 | if ( $key_check || is_numeric( $key_check ) ) { |
| 1114 | - $suffix = 2; |
|
| 1114 | + $suffix = 2; |
|
| 1115 | 1115 | do { |
| 1116 | 1116 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 1117 | 1117 | $key_check = FrmDb::get_var( |
@@ -1125,20 +1125,20 @@ discard block |
||
| 1125 | 1125 | $suffix++; |
| 1126 | 1126 | } while ( $key_check || is_numeric( $key_check ) ); |
| 1127 | 1127 | $key = $alt_post_name; |
| 1128 | - } |
|
| 1129 | - return $key; |
|
| 1130 | - } |
|
| 1128 | + } |
|
| 1129 | + return $key; |
|
| 1130 | + } |
|
| 1131 | 1131 | |
| 1132 | - /** |
|
| 1133 | - * Editing a Form or Entry |
|
| 1132 | + /** |
|
| 1133 | + * Editing a Form or Entry |
|
| 1134 | 1134 | * |
| 1135 | - * @param string $table |
|
| 1136 | - * @return bool|array |
|
| 1137 | - */ |
|
| 1138 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1139 | - if ( ! $record ) { |
|
| 1140 | - return false; |
|
| 1141 | - } |
|
| 1135 | + * @param string $table |
|
| 1136 | + * @return bool|array |
|
| 1137 | + */ |
|
| 1138 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1139 | + if ( ! $record ) { |
|
| 1140 | + return false; |
|
| 1141 | + } |
|
| 1142 | 1142 | |
| 1143 | 1143 | if ( empty( $post_values ) ) { |
| 1144 | 1144 | $post_values = stripslashes_deep( $_POST ); |
@@ -1161,14 +1161,14 @@ discard block |
||
| 1161 | 1161 | |
| 1162 | 1162 | self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) ); |
| 1163 | 1163 | |
| 1164 | - if ( $table == 'entries' ) { |
|
| 1165 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1166 | - } else if ( $table == 'forms' ) { |
|
| 1167 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1168 | - } |
|
| 1164 | + if ( $table == 'entries' ) { |
|
| 1165 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1166 | + } else if ( $table == 'forms' ) { |
|
| 1167 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1168 | + } |
|
| 1169 | 1169 | |
| 1170 | - return $values; |
|
| 1171 | - } |
|
| 1170 | + return $values; |
|
| 1171 | + } |
|
| 1172 | 1172 | |
| 1173 | 1173 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 1174 | 1174 | if ( ! empty( $fields ) ) { |
@@ -1181,15 +1181,15 @@ discard block |
||
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | 1183 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1184 | - $post_values = $args['post_values']; |
|
| 1184 | + $post_values = $args['post_values']; |
|
| 1185 | 1185 | |
| 1186 | - if ( $args['default'] ) { |
|
| 1187 | - $meta_value = $field->default_value; |
|
| 1188 | - } else { |
|
| 1186 | + if ( $args['default'] ) { |
|
| 1187 | + $meta_value = $field->default_value; |
|
| 1188 | + } else { |
|
| 1189 | 1189 | if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
| 1190 | 1190 | if ( ! isset( $field->field_options['custom_field'] ) ) { |
| 1191 | - $field->field_options['custom_field'] = ''; |
|
| 1192 | - } |
|
| 1191 | + $field->field_options['custom_field'] = ''; |
|
| 1192 | + } |
|
| 1193 | 1193 | $meta_value = FrmProEntryMetaHelper::get_post_value( |
| 1194 | 1194 | $record->post_id, |
| 1195 | 1195 | $field->field_options['post_field'], |
@@ -1201,31 +1201,31 @@ discard block |
||
| 1201 | 1201 | 'field' => $field, |
| 1202 | 1202 | ) |
| 1203 | 1203 | ); |
| 1204 | - } else { |
|
| 1204 | + } else { |
|
| 1205 | 1205 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1206 | - } |
|
| 1207 | - } |
|
| 1206 | + } |
|
| 1207 | + } |
|
| 1208 | 1208 | |
| 1209 | 1209 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1210 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1210 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1211 | 1211 | |
| 1212 | 1212 | $field_array = self::start_field_array( $field ); |
| 1213 | 1213 | $field_array['value'] = $new_value; |
| 1214 | 1214 | $field_array['type'] = apply_filters( 'frm_field_type', $field_type, $field, $new_value ); |
| 1215 | 1215 | $field_array['parent_form_id'] = $args['parent_form_id']; |
| 1216 | 1216 | |
| 1217 | - $args['field_type'] = $field_type; |
|
| 1217 | + $args['field_type'] = $field_type; |
|
| 1218 | 1218 | |
| 1219 | 1219 | FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args ); |
| 1220 | 1220 | |
| 1221 | 1221 | if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
| 1222 | - $field_array['unique_msg'] = ''; |
|
| 1223 | - } |
|
| 1222 | + $field_array['unique_msg'] = ''; |
|
| 1223 | + } |
|
| 1224 | 1224 | |
| 1225 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1225 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1226 | 1226 | |
| 1227 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1228 | - } |
|
| 1227 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1228 | + } |
|
| 1229 | 1229 | |
| 1230 | 1230 | /** |
| 1231 | 1231 | * @since 3.0 |
@@ -1246,20 +1246,20 @@ discard block |
||
| 1246 | 1246 | ); |
| 1247 | 1247 | } |
| 1248 | 1248 | |
| 1249 | - /** |
|
| 1250 | - * @param string $table |
|
| 1251 | - */ |
|
| 1249 | + /** |
|
| 1250 | + * @param string $table |
|
| 1251 | + */ |
|
| 1252 | 1252 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1253 | - if ( $table == 'entries' ) { |
|
| 1254 | - $form = $record->form_id; |
|
| 1253 | + if ( $table == 'entries' ) { |
|
| 1254 | + $form = $record->form_id; |
|
| 1255 | 1255 | FrmForm::maybe_get_form( $form ); |
| 1256 | - } else { |
|
| 1257 | - $form = $record; |
|
| 1258 | - } |
|
| 1256 | + } else { |
|
| 1257 | + $form = $record; |
|
| 1258 | + } |
|
| 1259 | 1259 | |
| 1260 | - if ( ! $form ) { |
|
| 1261 | - return; |
|
| 1262 | - } |
|
| 1260 | + if ( ! $form ) { |
|
| 1261 | + return; |
|
| 1262 | + } |
|
| 1263 | 1263 | |
| 1264 | 1264 | $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
| 1265 | 1265 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
@@ -1268,26 +1268,26 @@ discard block |
||
| 1268 | 1268 | return; |
| 1269 | 1269 | } |
| 1270 | 1270 | |
| 1271 | - foreach ( $form->options as $opt => $value ) { |
|
| 1272 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1273 | - } |
|
| 1271 | + foreach ( $form->options as $opt => $value ) { |
|
| 1272 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1273 | + } |
|
| 1274 | 1274 | |
| 1275 | 1275 | self::fill_form_defaults( $post_values, $values ); |
| 1276 | - } |
|
| 1276 | + } |
|
| 1277 | 1277 | |
| 1278 | - /** |
|
| 1279 | - * Set to POST value or default |
|
| 1280 | - */ |
|
| 1278 | + /** |
|
| 1279 | + * Set to POST value or default |
|
| 1280 | + */ |
|
| 1281 | 1281 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1282 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1282 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1283 | 1283 | |
| 1284 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1285 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1284 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1285 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1286 | 1286 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1287 | - } |
|
| 1287 | + } |
|
| 1288 | 1288 | |
| 1289 | 1289 | unset( $opt, $default ); |
| 1290 | - } |
|
| 1290 | + } |
|
| 1291 | 1291 | |
| 1292 | 1292 | if ( ! isset( $values['custom_style'] ) ) { |
| 1293 | 1293 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1296,10 +1296,10 @@ discard block |
||
| 1296 | 1296 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1297 | 1297 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1298 | 1298 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1299 | - } |
|
| 1299 | + } |
|
| 1300 | 1300 | unset( $h ); |
| 1301 | - } |
|
| 1302 | - } |
|
| 1301 | + } |
|
| 1302 | + } |
|
| 1303 | 1303 | |
| 1304 | 1304 | /** |
| 1305 | 1305 | * @since 2.2.10 |
@@ -1322,33 +1322,33 @@ discard block |
||
| 1322 | 1322 | if ( $possible_email_field ) { |
| 1323 | 1323 | $class .= 'show_frm_not_email_to'; |
| 1324 | 1324 | } |
| 1325 | - ?> |
|
| 1325 | + ?> |
|
| 1326 | 1326 | <li> |
| 1327 | 1327 | <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> |
| 1328 | 1328 | <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> |
| 1329 | 1329 | <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> |
| 1330 | 1330 | </li> |
| 1331 | 1331 | <?php |
| 1332 | - } |
|
| 1332 | + } |
|
| 1333 | 1333 | |
| 1334 | 1334 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1335 | - if ( is_array( $str ) ) { |
|
| 1336 | - return ''; |
|
| 1335 | + if ( is_array( $str ) ) { |
|
| 1336 | + return ''; |
|
| 1337 | 1337 | } |
| 1338 | 1338 | |
| 1339 | - $length = (int) $length; |
|
| 1339 | + $length = (int) $length; |
|
| 1340 | 1340 | $str = wp_strip_all_tags( $str ); |
| 1341 | 1341 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1342 | 1342 | |
| 1343 | 1343 | if ( $length == 0 ) { |
| 1344 | - return ''; |
|
| 1345 | - } else if ( $length <= 10 ) { |
|
| 1344 | + return ''; |
|
| 1345 | + } else if ( $length <= 10 ) { |
|
| 1346 | 1346 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1347 | 1347 | return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
| 1348 | - } |
|
| 1348 | + } |
|
| 1349 | 1349 | |
| 1350 | - $sub = ''; |
|
| 1351 | - $len = 0; |
|
| 1350 | + $sub = ''; |
|
| 1351 | + $len = 0; |
|
| 1352 | 1352 | |
| 1353 | 1353 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1354 | 1354 | |
@@ -1356,21 +1356,21 @@ discard block |
||
| 1356 | 1356 | $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
| 1357 | 1357 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1358 | 1358 | if ( $total_len > $length && substr_count( $sub, ' ' ) ) { |
| 1359 | - break; |
|
| 1360 | - } |
|
| 1359 | + break; |
|
| 1360 | + } |
|
| 1361 | 1361 | |
| 1362 | - $sub .= $part; |
|
| 1362 | + $sub .= $part; |
|
| 1363 | 1363 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1364 | 1364 | |
| 1365 | 1365 | if ( substr_count( $sub, ' ' ) > $minword && $total_len >= $length ) { |
| 1366 | - break; |
|
| 1367 | - } |
|
| 1366 | + break; |
|
| 1367 | + } |
|
| 1368 | 1368 | |
| 1369 | 1369 | unset( $total_len, $word ); |
| 1370 | - } |
|
| 1370 | + } |
|
| 1371 | 1371 | |
| 1372 | 1372 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
| 1373 | - } |
|
| 1373 | + } |
|
| 1374 | 1374 | |
| 1375 | 1375 | public static function mb_function( $function_names, $args ) { |
| 1376 | 1376 | $mb_function_name = $function_names[0]; |
@@ -1383,17 +1383,17 @@ discard block |
||
| 1383 | 1383 | |
| 1384 | 1384 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1385 | 1385 | if ( empty( $date ) ) { |
| 1386 | - return $date; |
|
| 1387 | - } |
|
| 1386 | + return $date; |
|
| 1387 | + } |
|
| 1388 | 1388 | |
| 1389 | 1389 | if ( empty( $date_format ) ) { |
| 1390 | 1390 | $date_format = get_option( 'date_format' ); |
| 1391 | 1391 | } |
| 1392 | 1392 | |
| 1393 | 1393 | if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
| 1394 | - $frmpro_settings = new FrmProSettings(); |
|
| 1394 | + $frmpro_settings = new FrmProSettings(); |
|
| 1395 | 1395 | $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
| 1396 | - } |
|
| 1396 | + } |
|
| 1397 | 1397 | |
| 1398 | 1398 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1399 | 1399 | |
@@ -1402,8 +1402,8 @@ discard block |
||
| 1402 | 1402 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | - return $formatted; |
|
| 1406 | - } |
|
| 1405 | + return $formatted; |
|
| 1406 | + } |
|
| 1407 | 1407 | |
| 1408 | 1408 | private static function add_time_to_date( $time_format, $date ) { |
| 1409 | 1409 | if ( empty( $time_format ) ) { |
@@ -1485,32 +1485,32 @@ discard block |
||
| 1485 | 1485 | ); |
| 1486 | 1486 | } |
| 1487 | 1487 | |
| 1488 | - // Pagination Methods |
|
| 1488 | + // Pagination Methods |
|
| 1489 | 1489 | |
| 1490 | - /** |
|
| 1491 | - * @param integer $current_p |
|
| 1492 | - */ |
|
| 1490 | + /** |
|
| 1491 | + * @param integer $current_p |
|
| 1492 | + */ |
|
| 1493 | 1493 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1494 | 1494 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | - /** |
|
| 1498 | - * @param integer $current_p |
|
| 1499 | - */ |
|
| 1500 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1501 | - if ( $current_p == 1 ) { |
|
| 1502 | - return 1; |
|
| 1503 | - } else { |
|
| 1504 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1505 | - } |
|
| 1506 | - } |
|
| 1497 | + /** |
|
| 1498 | + * @param integer $current_p |
|
| 1499 | + */ |
|
| 1500 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1501 | + if ( $current_p == 1 ) { |
|
| 1502 | + return 1; |
|
| 1503 | + } else { |
|
| 1504 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1505 | + } |
|
| 1506 | + } |
|
| 1507 | 1507 | |
| 1508 | 1508 | /** |
| 1509 | 1509 | * @return array |
| 1510 | 1510 | */ |
| 1511 | 1511 | public static function json_to_array( $json_vars ) { |
| 1512 | - $vars = array(); |
|
| 1513 | - foreach ( $json_vars as $jv ) { |
|
| 1512 | + $vars = array(); |
|
| 1513 | + foreach ( $json_vars as $jv ) { |
|
| 1514 | 1514 | $jv_name = explode( '[', $jv['name'] ); |
| 1515 | 1515 | $last = count( $jv_name ) - 1; |
| 1516 | 1516 | foreach ( $jv_name as $p => $n ) { |
@@ -1527,77 +1527,77 @@ discard block |
||
| 1527 | 1527 | $l3 = $name; |
| 1528 | 1528 | } |
| 1529 | 1529 | |
| 1530 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1530 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1531 | 1531 | |
| 1532 | - switch ( $p ) { |
|
| 1533 | - case 0: |
|
| 1534 | - $l1 = $name; |
|
| 1535 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1532 | + switch ( $p ) { |
|
| 1533 | + case 0: |
|
| 1534 | + $l1 = $name; |
|
| 1535 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1536 | 1536 | break; |
| 1537 | 1537 | |
| 1538 | - case 1: |
|
| 1539 | - $l2 = $name; |
|
| 1540 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1538 | + case 1: |
|
| 1539 | + $l2 = $name; |
|
| 1540 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1541 | 1541 | break; |
| 1542 | 1542 | |
| 1543 | - case 2: |
|
| 1544 | - $l3 = $name; |
|
| 1545 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1543 | + case 2: |
|
| 1544 | + $l3 = $name; |
|
| 1545 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1546 | 1546 | break; |
| 1547 | 1547 | |
| 1548 | - case 3: |
|
| 1549 | - $l4 = $name; |
|
| 1550 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1551 | - } |
|
| 1548 | + case 3: |
|
| 1549 | + $l4 = $name; |
|
| 1550 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1551 | + } |
|
| 1552 | 1552 | |
| 1553 | 1553 | unset( $this_val, $n ); |
| 1554 | - } |
|
| 1554 | + } |
|
| 1555 | 1555 | |
| 1556 | 1556 | unset( $last, $jv ); |
| 1557 | - } |
|
| 1558 | - |
|
| 1559 | - return $vars; |
|
| 1560 | - } |
|
| 1561 | - |
|
| 1562 | - /** |
|
| 1563 | - * @param string $name |
|
| 1564 | - * @param string $l1 |
|
| 1565 | - */ |
|
| 1566 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1567 | - if ( $name == '' ) { |
|
| 1568 | - $vars[] = $val; |
|
| 1569 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1570 | - $vars[ $l1 ] = $val; |
|
| 1571 | - } |
|
| 1572 | - } |
|
| 1557 | + } |
|
| 1558 | + |
|
| 1559 | + return $vars; |
|
| 1560 | + } |
|
| 1561 | + |
|
| 1562 | + /** |
|
| 1563 | + * @param string $name |
|
| 1564 | + * @param string $l1 |
|
| 1565 | + */ |
|
| 1566 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1567 | + if ( $name == '' ) { |
|
| 1568 | + $vars[] = $val; |
|
| 1569 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1570 | + $vars[ $l1 ] = $val; |
|
| 1571 | + } |
|
| 1572 | + } |
|
| 1573 | 1573 | |
| 1574 | 1574 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1575 | - $tooltips = array( |
|
| 1576 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1577 | - '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' ), |
|
| 1578 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1579 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1580 | - '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' ), |
|
| 1581 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1582 | - '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() ) ), |
|
| 1583 | - ); |
|
| 1584 | - |
|
| 1585 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1586 | - return; |
|
| 1587 | - } |
|
| 1588 | - |
|
| 1589 | - if ( 'open' == $class ) { |
|
| 1590 | - echo ' frm_help"'; |
|
| 1591 | - } else { |
|
| 1592 | - echo ' class="frm_help"'; |
|
| 1593 | - } |
|
| 1575 | + $tooltips = array( |
|
| 1576 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1577 | + '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' ), |
|
| 1578 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1579 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1580 | + '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' ), |
|
| 1581 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1582 | + '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() ) ), |
|
| 1583 | + ); |
|
| 1584 | + |
|
| 1585 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1586 | + return; |
|
| 1587 | + } |
|
| 1588 | + |
|
| 1589 | + if ( 'open' == $class ) { |
|
| 1590 | + echo ' frm_help"'; |
|
| 1591 | + } else { |
|
| 1592 | + echo ' class="frm_help"'; |
|
| 1593 | + } |
|
| 1594 | 1594 | |
| 1595 | 1595 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1596 | 1596 | |
| 1597 | - if ( 'open' != $class ) { |
|
| 1598 | - echo '"'; |
|
| 1599 | - } |
|
| 1600 | - } |
|
| 1597 | + if ( 'open' != $class ) { |
|
| 1598 | + echo '"'; |
|
| 1599 | + } |
|
| 1600 | + } |
|
| 1601 | 1601 | |
| 1602 | 1602 | /** |
| 1603 | 1603 | * Add the current_page class to that page in the form nav |
@@ -1613,35 +1613,35 @@ discard block |
||
| 1613 | 1613 | } |
| 1614 | 1614 | } |
| 1615 | 1615 | |
| 1616 | - /** |
|
| 1617 | - * Prepare and json_encode post content |
|
| 1618 | - * |
|
| 1619 | - * @since 2.0 |
|
| 1620 | - * |
|
| 1621 | - * @param array $post_content |
|
| 1622 | - * @return string $post_content ( json encoded array ) |
|
| 1623 | - */ |
|
| 1624 | - public static function prepare_and_encode( $post_content ) { |
|
| 1625 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1616 | + /** |
|
| 1617 | + * Prepare and json_encode post content |
|
| 1618 | + * |
|
| 1619 | + * @since 2.0 |
|
| 1620 | + * |
|
| 1621 | + * @param array $post_content |
|
| 1622 | + * @return string $post_content ( json encoded array ) |
|
| 1623 | + */ |
|
| 1624 | + public static function prepare_and_encode( $post_content ) { |
|
| 1625 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1626 | 1626 | foreach ( $post_content as $key => $val ) { |
| 1627 | 1627 | // Replace problematic characters (like ") |
| 1628 | 1628 | $val = str_replace( '"', '"', $val ); |
| 1629 | 1629 | |
| 1630 | 1630 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1631 | - unset( $key, $val ); |
|
| 1632 | - } |
|
| 1631 | + unset( $key, $val ); |
|
| 1632 | + } |
|
| 1633 | 1633 | |
| 1634 | - // json_encode the array |
|
| 1635 | - $post_content = json_encode( $post_content ); |
|
| 1634 | + // json_encode the array |
|
| 1635 | + $post_content = json_encode( $post_content ); |
|
| 1636 | 1636 | |
| 1637 | - // add extra slashes for \r\n since WP strips them |
|
| 1637 | + // add extra slashes for \r\n since WP strips them |
|
| 1638 | 1638 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1639 | 1639 | |
| 1640 | - // allow for " |
|
| 1641 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1640 | + // allow for " |
|
| 1641 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1642 | 1642 | |
| 1643 | - return $post_content; |
|
| 1644 | - } |
|
| 1643 | + return $post_content; |
|
| 1644 | + } |
|
| 1645 | 1645 | |
| 1646 | 1646 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1647 | 1647 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1664,55 +1664,55 @@ discard block |
||
| 1664 | 1664 | |
| 1665 | 1665 | public static function maybe_json_decode( $string ) { |
| 1666 | 1666 | if ( is_array( $string ) ) { |
| 1667 | - return $string; |
|
| 1668 | - } |
|
| 1667 | + return $string; |
|
| 1668 | + } |
|
| 1669 | 1669 | |
| 1670 | 1670 | $new_string = json_decode( $string, true ); |
| 1671 | 1671 | if ( function_exists( 'json_last_error' ) ) { |
| 1672 | 1672 | // php 5.3+ |
| 1673 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1674 | - $string = $new_string; |
|
| 1675 | - } |
|
| 1673 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1674 | + $string = $new_string; |
|
| 1675 | + } |
|
| 1676 | 1676 | } elseif ( isset( $new_string ) ) { |
| 1677 | 1677 | // php < 5.3 fallback |
| 1678 | - $string = $new_string; |
|
| 1679 | - } |
|
| 1680 | - return $string; |
|
| 1681 | - } |
|
| 1682 | - |
|
| 1683 | - /** |
|
| 1684 | - * @since 1.07.10 |
|
| 1685 | - * |
|
| 1686 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1687 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1688 | - */ |
|
| 1678 | + $string = $new_string; |
|
| 1679 | + } |
|
| 1680 | + return $string; |
|
| 1681 | + } |
|
| 1682 | + |
|
| 1683 | + /** |
|
| 1684 | + * @since 1.07.10 |
|
| 1685 | + * |
|
| 1686 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1687 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1688 | + */ |
|
| 1689 | 1689 | public static function maybe_highlight_menu( $post_type ) { |
| 1690 | - global $post; |
|
| 1690 | + global $post; |
|
| 1691 | 1691 | |
| 1692 | 1692 | if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
| 1693 | - return; |
|
| 1694 | - } |
|
| 1693 | + return; |
|
| 1694 | + } |
|
| 1695 | 1695 | |
| 1696 | 1696 | if ( is_object( $post ) && $post->post_type != $post_type ) { |
| 1697 | - return; |
|
| 1698 | - } |
|
| 1697 | + return; |
|
| 1698 | + } |
|
| 1699 | 1699 | |
| 1700 | - self::load_admin_wide_js(); |
|
| 1701 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1702 | - } |
|
| 1700 | + self::load_admin_wide_js(); |
|
| 1701 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1702 | + } |
|
| 1703 | 1703 | |
| 1704 | - /** |
|
| 1705 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1704 | + /** |
|
| 1705 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1706 | 1706 | * |
| 1707 | - * @since 2.0 |
|
| 1708 | - */ |
|
| 1707 | + * @since 2.0 |
|
| 1708 | + */ |
|
| 1709 | 1709 | public static function load_admin_wide_js( $load = true ) { |
| 1710 | 1710 | $version = self::plugin_version(); |
| 1711 | 1711 | wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1712 | 1712 | |
| 1713 | 1713 | $global_strings = array( |
| 1714 | 1714 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1715 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1715 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1716 | 1716 | 'url' => self::plugin_url(), |
| 1717 | 1717 | 'loading' => __( 'Loading…', 'formidable' ), |
| 1718 | 1718 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
@@ -1722,7 +1722,7 @@ discard block |
||
| 1722 | 1722 | if ( $load ) { |
| 1723 | 1723 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1724 | 1724 | } |
| 1725 | - } |
|
| 1725 | + } |
|
| 1726 | 1726 | |
| 1727 | 1727 | /** |
| 1728 | 1728 | * @since 2.0.9 |
@@ -1731,9 +1731,9 @@ discard block |
||
| 1731 | 1731 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1732 | 1732 | } |
| 1733 | 1733 | |
| 1734 | - /** |
|
| 1735 | - * @param string $location |
|
| 1736 | - */ |
|
| 1734 | + /** |
|
| 1735 | + * @param string $location |
|
| 1736 | + */ |
|
| 1737 | 1737 | public static function localize_script( $location ) { |
| 1738 | 1738 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1739 | 1739 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1798,28 +1798,28 @@ discard block |
||
| 1798 | 1798 | } |
| 1799 | 1799 | } |
| 1800 | 1800 | |
| 1801 | - /** |
|
| 1801 | + /** |
|
| 1802 | 1802 | * Echo the message on the plugins listing page |
| 1803 | 1803 | * |
| 1804 | - * @since 1.07.10 |
|
| 1805 | - * |
|
| 1806 | - * @param float $min_version The version the add-on requires |
|
| 1807 | - */ |
|
| 1804 | + * @since 1.07.10 |
|
| 1805 | + * |
|
| 1806 | + * @param float $min_version The version the add-on requires |
|
| 1807 | + */ |
|
| 1808 | 1808 | public static function min_version_notice( $min_version ) { |
| 1809 | - $frm_version = self::plugin_version(); |
|
| 1809 | + $frm_version = self::plugin_version(); |
|
| 1810 | 1810 | |
| 1811 | - // check if Formidable meets minimum requirements |
|
| 1811 | + // check if Formidable meets minimum requirements |
|
| 1812 | 1812 | if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
| 1813 | - return; |
|
| 1814 | - } |
|
| 1813 | + return; |
|
| 1814 | + } |
|
| 1815 | 1815 | |
| 1816 | 1816 | $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
| 1817 | 1817 | 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">' . |
| 1818 | - esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1819 | - '</div></td></tr>'; |
|
| 1820 | - } |
|
| 1818 | + esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1819 | + '</div></td></tr>'; |
|
| 1820 | + } |
|
| 1821 | 1821 | |
| 1822 | - public static function locales( $type = 'date' ) { |
|
| 1822 | + public static function locales( $type = 'date' ) { |
|
| 1823 | 1823 | $locales = array( |
| 1824 | 1824 | 'en' => __( 'English', 'formidable' ), |
| 1825 | 1825 | 'af' => __( 'Afrikaans', 'formidable' ), |
@@ -1897,8 +1897,8 @@ discard block |
||
| 1897 | 1897 | $locales = array_diff_key( $locales, array_flip( $unset ) ); |
| 1898 | 1898 | $locales = apply_filters( 'frm_locales', $locales ); |
| 1899 | 1899 | |
| 1900 | - return $locales; |
|
| 1901 | - } |
|
| 1900 | + return $locales; |
|
| 1901 | + } |
|
| 1902 | 1902 | |
| 1903 | 1903 | /** |
| 1904 | 1904 | * Used to filter shortcode in text widgets |