@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public static $plug_version = '3.02.03'; |
| 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 |
@@ -508,39 +508,39 @@ discard block |
||
| 508 | 508 | ); |
| 509 | 509 | } |
| 510 | 510 | |
| 511 | - /** |
|
| 512 | - * Used when switching the action for a bulk action |
|
| 513 | - * @since 2.0 |
|
| 514 | - */ |
|
| 511 | + /** |
|
| 512 | + * Used when switching the action for a bulk action |
|
| 513 | + * @since 2.0 |
|
| 514 | + */ |
|
| 515 | 515 | public static function remove_get_action() { |
| 516 | 516 | if ( ! isset( $_GET ) ) { |
| 517 | 517 | return; |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 521 | - if ( ! empty( $new_action ) ) { |
|
| 520 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 521 | + if ( ! empty( $new_action ) ) { |
|
| 522 | 522 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 523 | - } |
|
| 524 | - } |
|
| 523 | + } |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - /** |
|
| 527 | - * Check the WP query for a parameter |
|
| 528 | - * |
|
| 529 | - * @since 2.0 |
|
| 530 | - * @return string|array |
|
| 531 | - */ |
|
| 532 | - public static function get_query_var( $value, $param ) { |
|
| 533 | - if ( $value != '' ) { |
|
| 534 | - return $value; |
|
| 535 | - } |
|
| 526 | + /** |
|
| 527 | + * Check the WP query for a parameter |
|
| 528 | + * |
|
| 529 | + * @since 2.0 |
|
| 530 | + * @return string|array |
|
| 531 | + */ |
|
| 532 | + public static function get_query_var( $value, $param ) { |
|
| 533 | + if ( $value != '' ) { |
|
| 534 | + return $value; |
|
| 535 | + } |
|
| 536 | 536 | |
| 537 | - global $wp_query; |
|
| 538 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 539 | - $value = $wp_query->query_vars[ $param ]; |
|
| 540 | - } |
|
| 537 | + global $wp_query; |
|
| 538 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 539 | + $value = $wp_query->query_vars[ $param ]; |
|
| 540 | + } |
|
| 541 | 541 | |
| 542 | - return $value; |
|
| 543 | - } |
|
| 542 | + return $value; |
|
| 543 | + } |
|
| 544 | 544 | |
| 545 | 545 | /** |
| 546 | 546 | * @since 3.0 |
@@ -562,16 +562,16 @@ discard block |
||
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - /** |
|
| 566 | - * @param string $type |
|
| 567 | - */ |
|
| 568 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 569 | - // only load the form hooks once |
|
| 565 | + /** |
|
| 566 | + * @param string $type |
|
| 567 | + */ |
|
| 568 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 569 | + // only load the form hooks once |
|
| 570 | 570 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 571 | - if ( ! $hooks_loaded ) { |
|
| 571 | + if ( ! $hooks_loaded ) { |
|
| 572 | 572 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 573 | - } |
|
| 574 | - } |
|
| 573 | + } |
|
| 574 | + } |
|
| 575 | 575 | |
| 576 | 576 | /** |
| 577 | 577 | * Save all front-end js scripts into a single file |
@@ -593,29 +593,29 @@ discard block |
||
| 593 | 593 | $new_file->combine_files( $files ); |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - /** |
|
| 597 | - * Check a value from a shortcode to see if true or false. |
|
| 598 | - * True when value is 1, true, 'true', 'yes' |
|
| 599 | - * |
|
| 600 | - * @since 1.07.10 |
|
| 601 | - * |
|
| 602 | - * @param string $value The value to compare |
|
| 603 | - * @return boolean True or False |
|
| 604 | - */ |
|
| 596 | + /** |
|
| 597 | + * Check a value from a shortcode to see if true or false. |
|
| 598 | + * True when value is 1, true, 'true', 'yes' |
|
| 599 | + * |
|
| 600 | + * @since 1.07.10 |
|
| 601 | + * |
|
| 602 | + * @param string $value The value to compare |
|
| 603 | + * @return boolean True or False |
|
| 604 | + */ |
|
| 605 | 605 | public static function is_true( $value ) { |
| 606 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 607 | - } |
|
| 606 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 607 | + } |
|
| 608 | 608 | |
| 609 | - /** |
|
| 610 | - * Used to filter shortcode in text widgets |
|
| 609 | + /** |
|
| 610 | + * Used to filter shortcode in text widgets |
|
| 611 | 611 | * |
| 612 | 612 | * @deprecated 2.5.4 |
| 613 | 613 | * @codeCoverageIgnore |
| 614 | - */ |
|
| 615 | - public static function widget_text_filter_callback( $matches ) { |
|
| 614 | + */ |
|
| 615 | + public static function widget_text_filter_callback( $matches ) { |
|
| 616 | 616 | _deprecated_function( __METHOD__, '2.5.4' ); |
| 617 | - return do_shortcode( $matches[0] ); |
|
| 618 | - } |
|
| 617 | + return do_shortcode( $matches[0] ); |
|
| 618 | + } |
|
| 619 | 619 | |
| 620 | 620 | public static function get_pages() { |
| 621 | 621 | return get_posts( array( |
@@ -627,10 +627,10 @@ discard block |
||
| 627 | 627 | ) ); |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 631 | - $pages = self::get_pages(); |
|
| 630 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 631 | + $pages = self::get_pages(); |
|
| 632 | 632 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 633 | - ?> |
|
| 633 | + ?> |
|
| 634 | 634 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
| 635 | 635 | <option value=""> </option> |
| 636 | 636 | <?php foreach ( $pages as $page ) { ?> |
@@ -640,16 +640,16 @@ discard block |
||
| 640 | 640 | <?php } ?> |
| 641 | 641 | </select> |
| 642 | 642 | <?php |
| 643 | - } |
|
| 643 | + } |
|
| 644 | 644 | |
| 645 | 645 | public static function post_edit_link( $post_id ) { |
| 646 | 646 | $post = get_post( $post_id ); |
| 647 | - if ( $post ) { |
|
| 647 | + if ( $post ) { |
|
| 648 | 648 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 649 | 649 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 650 | - } |
|
| 651 | - return ''; |
|
| 652 | - } |
|
| 650 | + } |
|
| 651 | + return ''; |
|
| 652 | + } |
|
| 653 | 653 | |
| 654 | 654 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 655 | 655 | ?> |
@@ -660,73 +660,73 @@ discard block |
||
| 660 | 660 | } |
| 661 | 661 | |
| 662 | 662 | public static function roles_options( $capability ) { |
| 663 | - global $frm_vars; |
|
| 663 | + global $frm_vars; |
|
| 664 | 664 | if ( isset( $frm_vars['editable_roles'] ) ) { |
| 665 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 666 | - } else { |
|
| 667 | - $editable_roles = get_editable_roles(); |
|
| 668 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 669 | - } |
|
| 665 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 666 | + } else { |
|
| 667 | + $editable_roles = get_editable_roles(); |
|
| 668 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 669 | + } |
|
| 670 | 670 | |
| 671 | - foreach ( $editable_roles as $role => $details ) { |
|
| 671 | + foreach ( $editable_roles as $role => $details ) { |
|
| 672 | 672 | $name = translate_user_role( $details['name'] ); |
| 673 | 673 | ?> |
| 674 | 674 | <option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option> |
| 675 | 675 | <?php |
| 676 | 676 | unset( $role, $details ); |
| 677 | - } |
|
| 678 | - } |
|
| 677 | + } |
|
| 678 | + } |
|
| 679 | 679 | |
| 680 | 680 | public static function frm_capabilities( $type = 'auto' ) { |
| 681 | - $cap = array( |
|
| 682 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 683 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 684 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 685 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 686 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 687 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 688 | - ); |
|
| 681 | + $cap = array( |
|
| 682 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 683 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 684 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 685 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 686 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 687 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 688 | + ); |
|
| 689 | 689 | |
| 690 | 690 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 691 | - return $cap; |
|
| 692 | - } |
|
| 691 | + return $cap; |
|
| 692 | + } |
|
| 693 | 693 | |
| 694 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 695 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 696 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 697 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 694 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 695 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 696 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 697 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 698 | 698 | |
| 699 | - return $cap; |
|
| 700 | - } |
|
| 699 | + return $cap; |
|
| 700 | + } |
|
| 701 | 701 | |
| 702 | 702 | public static function user_has_permission( $needed_role ) { |
| 703 | - if ( $needed_role == '-1' ) { |
|
| 704 | - return false; |
|
| 703 | + if ( $needed_role == '-1' ) { |
|
| 704 | + return false; |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 708 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 709 | - return true; |
|
| 710 | - } |
|
| 707 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 708 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 709 | + return true; |
|
| 710 | + } |
|
| 711 | 711 | |
| 712 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 713 | - foreach ( $roles as $role ) { |
|
| 712 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 713 | + foreach ( $roles as $role ) { |
|
| 714 | 714 | if ( current_user_can( $role ) ) { |
| 715 | - return true; |
|
| 715 | + return true; |
|
| 716 | 716 | } |
| 717 | - if ( $role == $needed_role ) { |
|
| 718 | - break; |
|
| 717 | + if ( $role == $needed_role ) { |
|
| 718 | + break; |
|
| 719 | 719 | } |
| 720 | - } |
|
| 721 | - return false; |
|
| 722 | - } |
|
| 723 | - |
|
| 724 | - /** |
|
| 725 | - * Make sure administrators can see Formidable menu |
|
| 726 | - * |
|
| 727 | - * @since 2.0 |
|
| 728 | - */ |
|
| 729 | - public static function maybe_add_permissions() { |
|
| 720 | + } |
|
| 721 | + return false; |
|
| 722 | + } |
|
| 723 | + |
|
| 724 | + /** |
|
| 725 | + * Make sure administrators can see Formidable menu |
|
| 726 | + * |
|
| 727 | + * @since 2.0 |
|
| 728 | + */ |
|
| 729 | + public static function maybe_add_permissions() { |
|
| 730 | 730 | self::force_capability( 'frm_view_entries' ); |
| 731 | 731 | |
| 732 | 732 | if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
@@ -735,12 +735,12 @@ discard block |
||
| 735 | 735 | |
| 736 | 736 | $user_id = get_current_user_id(); |
| 737 | 737 | $user = new WP_User( $user_id ); |
| 738 | - $frm_roles = self::frm_capabilities(); |
|
| 739 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 738 | + $frm_roles = self::frm_capabilities(); |
|
| 739 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 740 | 740 | $user->add_cap( $frm_role ); |
| 741 | 741 | unset( $frm_role, $frm_role_description ); |
| 742 | - } |
|
| 743 | - } |
|
| 742 | + } |
|
| 743 | + } |
|
| 744 | 744 | |
| 745 | 745 | /** |
| 746 | 746 | * Make sure admins have permission to see the menu items |
@@ -756,28 +756,28 @@ discard block |
||
| 756 | 756 | } |
| 757 | 757 | } |
| 758 | 758 | |
| 759 | - /** |
|
| 760 | - * Check if the user has permision for action. |
|
| 761 | - * Return permission message and stop the action if no permission |
|
| 762 | - * @since 2.0 |
|
| 763 | - * @param string $permission |
|
| 764 | - */ |
|
| 759 | + /** |
|
| 760 | + * Check if the user has permision for action. |
|
| 761 | + * Return permission message and stop the action if no permission |
|
| 762 | + * @since 2.0 |
|
| 763 | + * @param string $permission |
|
| 764 | + */ |
|
| 765 | 765 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 766 | 766 | $permission_error = self::permission_nonce_error( $permission ); |
| 767 | - if ( $permission_error !== false ) { |
|
| 768 | - if ( 'hide' == $show_message ) { |
|
| 769 | - $permission_error = ''; |
|
| 770 | - } |
|
| 767 | + if ( $permission_error !== false ) { |
|
| 768 | + if ( 'hide' == $show_message ) { |
|
| 769 | + $permission_error = ''; |
|
| 770 | + } |
|
| 771 | 771 | wp_die( esc_html( $permission_error ) ); |
| 772 | - } |
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - /** |
|
| 776 | - * Check user permission and nonce |
|
| 777 | - * @since 2.0 |
|
| 778 | - * @param string $permission |
|
| 779 | - * @return false|string The permission message or false if allowed |
|
| 780 | - */ |
|
| 772 | + } |
|
| 773 | + } |
|
| 774 | + |
|
| 775 | + /** |
|
| 776 | + * Check user permission and nonce |
|
| 777 | + * @since 2.0 |
|
| 778 | + * @param string $permission |
|
| 779 | + * @return false|string The permission message or false if allowed |
|
| 780 | + */ |
|
| 781 | 781 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 782 | 782 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 783 | 783 | $frm_settings = self::get_settings(); |
@@ -786,22 +786,22 @@ discard block |
||
| 786 | 786 | |
| 787 | 787 | $error = false; |
| 788 | 788 | if ( empty( $nonce_name ) ) { |
| 789 | - return $error; |
|
| 790 | - } |
|
| 789 | + return $error; |
|
| 790 | + } |
|
| 791 | 791 | |
| 792 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 793 | - $frm_settings = self::get_settings(); |
|
| 794 | - $error = $frm_settings->admin_permission; |
|
| 795 | - } |
|
| 792 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 793 | + $frm_settings = self::get_settings(); |
|
| 794 | + $error = $frm_settings->admin_permission; |
|
| 795 | + } |
|
| 796 | 796 | |
| 797 | - return $error; |
|
| 798 | - } |
|
| 797 | + return $error; |
|
| 798 | + } |
|
| 799 | 799 | |
| 800 | - public static function checked( $values, $current ) { |
|
| 800 | + public static function checked( $values, $current ) { |
|
| 801 | 801 | if ( self::check_selected( $values, $current ) ) { |
| 802 | - echo ' checked="checked"'; |
|
| 802 | + echo ' checked="checked"'; |
|
| 803 | 803 | } |
| 804 | - } |
|
| 804 | + } |
|
| 805 | 805 | |
| 806 | 806 | public static function check_selected( $values, $current ) { |
| 807 | 807 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -839,24 +839,24 @@ discard block |
||
| 839 | 839 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | - /** |
|
| 843 | - * Flatten a multi-dimensional array |
|
| 844 | - */ |
|
| 842 | + /** |
|
| 843 | + * Flatten a multi-dimensional array |
|
| 844 | + */ |
|
| 845 | 845 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 846 | - $return = array(); |
|
| 847 | - foreach ( $array as $key => $value ) { |
|
| 846 | + $return = array(); |
|
| 847 | + foreach ( $array as $key => $value ) { |
|
| 848 | 848 | if ( is_array( $value ) ) { |
| 849 | 849 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 850 | - } else { |
|
| 850 | + } else { |
|
| 851 | 851 | if ( $keys == 'keep' ) { |
| 852 | 852 | $return[ $key ] = $value; |
| 853 | 853 | } else { |
| 854 | 854 | $return[] = $value; |
| 855 | 855 | } |
| 856 | - } |
|
| 857 | - } |
|
| 858 | - return $return; |
|
| 859 | - } |
|
| 856 | + } |
|
| 857 | + } |
|
| 858 | + return $return; |
|
| 859 | + } |
|
| 860 | 860 | |
| 861 | 861 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 862 | 862 | $safe_text = str_replace( '"', '"', $text ); |
@@ -867,10 +867,10 @@ discard block |
||
| 867 | 867 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 868 | 868 | } |
| 869 | 869 | |
| 870 | - /** |
|
| 871 | - * Add auto paragraphs to text areas |
|
| 872 | - * @since 2.0 |
|
| 873 | - */ |
|
| 870 | + /** |
|
| 871 | + * Add auto paragraphs to text areas |
|
| 872 | + * @since 2.0 |
|
| 873 | + */ |
|
| 874 | 874 | public static function use_wpautop( $content ) { |
| 875 | 875 | if ( apply_filters( 'frm_use_wpautop', true ) ) { |
| 876 | 876 | $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
@@ -879,26 +879,26 @@ discard block |
||
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | public static function replace_quotes( $val ) { |
| 882 | - //Replace double quotes |
|
| 882 | + //Replace double quotes |
|
| 883 | 883 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 884 | - //Replace single quotes |
|
| 885 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 886 | - return $val; |
|
| 887 | - } |
|
| 888 | - |
|
| 889 | - /** |
|
| 890 | - * @since 2.0 |
|
| 891 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 892 | - */ |
|
| 893 | - public static function jquery_ui_base_url() { |
|
| 884 | + //Replace single quotes |
|
| 885 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 886 | + return $val; |
|
| 887 | + } |
|
| 888 | + |
|
| 889 | + /** |
|
| 890 | + * @since 2.0 |
|
| 891 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 892 | + */ |
|
| 893 | + public static function jquery_ui_base_url() { |
|
| 894 | 894 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 895 | 895 | $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
| 896 | - return $url; |
|
| 897 | - } |
|
| 896 | + return $url; |
|
| 897 | + } |
|
| 898 | 898 | |
| 899 | - /** |
|
| 900 | - * @param string $handle |
|
| 901 | - */ |
|
| 899 | + /** |
|
| 900 | + * @param string $handle |
|
| 901 | + */ |
|
| 902 | 902 | public static function script_version( $handle, $default = 0 ) { |
| 903 | 903 | global $wp_scripts; |
| 904 | 904 | if ( ! $wp_scripts ) { |
@@ -920,12 +920,12 @@ discard block |
||
| 920 | 920 | |
| 921 | 921 | public static function js_redirect( $url ) { |
| 922 | 922 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 923 | - } |
|
| 923 | + } |
|
| 924 | 924 | |
| 925 | 925 | public static function get_user_id_param( $user_id ) { |
| 926 | 926 | if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
| 927 | - return $user_id; |
|
| 928 | - } |
|
| 927 | + return $user_id; |
|
| 928 | + } |
|
| 929 | 929 | |
| 930 | 930 | $user_id = sanitize_text_field( $user_id ); |
| 931 | 931 | if ( $user_id == 'current' ) { |
@@ -937,14 +937,14 @@ discard block |
||
| 937 | 937 | $user = get_user_by( 'login', $user_id ); |
| 938 | 938 | } |
| 939 | 939 | |
| 940 | - if ( $user ) { |
|
| 941 | - $user_id = $user->ID; |
|
| 942 | - } |
|
| 940 | + if ( $user ) { |
|
| 941 | + $user_id = $user->ID; |
|
| 942 | + } |
|
| 943 | 943 | unset( $user ); |
| 944 | - } |
|
| 944 | + } |
|
| 945 | 945 | |
| 946 | - return $user_id; |
|
| 947 | - } |
|
| 946 | + return $user_id; |
|
| 947 | + } |
|
| 948 | 948 | |
| 949 | 949 | public static function get_file_contents( $filename, $atts = array() ) { |
| 950 | 950 | if ( ! is_file( $filename ) ) { |
@@ -959,28 +959,28 @@ discard block |
||
| 959 | 959 | return $contents; |
| 960 | 960 | } |
| 961 | 961 | |
| 962 | - /** |
|
| 963 | - * @param string $table_name |
|
| 964 | - * @param string $column |
|
| 962 | + /** |
|
| 963 | + * @param string $table_name |
|
| 964 | + * @param string $column |
|
| 965 | 965 | * @param int $id |
| 966 | 966 | * @param int $num_chars |
| 967 | - */ |
|
| 968 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 969 | - $key = ''; |
|
| 967 | + */ |
|
| 968 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 969 | + $key = ''; |
|
| 970 | 970 | |
| 971 | - if ( ! empty( $name ) ) { |
|
| 971 | + if ( ! empty( $name ) ) { |
|
| 972 | 972 | $key = sanitize_key( $name ); |
| 973 | - } |
|
| 973 | + } |
|
| 974 | 974 | |
| 975 | 975 | if ( empty( $key ) ) { |
| 976 | 976 | $max_slug_value = pow( 36, $num_chars ); |
| 977 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 977 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 978 | 978 | $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
| 979 | - } |
|
| 979 | + } |
|
| 980 | 980 | |
| 981 | 981 | if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 982 | 982 | $key = $key . 'a'; |
| 983 | - } |
|
| 983 | + } |
|
| 984 | 984 | |
| 985 | 985 | $key_check = FrmDb::get_var( $table_name, array( |
| 986 | 986 | $column => $key, |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | ), $column ); |
| 989 | 989 | |
| 990 | 990 | if ( $key_check || is_numeric( $key_check ) ) { |
| 991 | - $suffix = 2; |
|
| 991 | + $suffix = 2; |
|
| 992 | 992 | do { |
| 993 | 993 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 994 | 994 | $key_check = FrmDb::get_var( $table_name, array( |
@@ -998,19 +998,19 @@ discard block |
||
| 998 | 998 | $suffix++; |
| 999 | 999 | } while ( $key_check || is_numeric( $key_check ) ); |
| 1000 | 1000 | $key = $alt_post_name; |
| 1001 | - } |
|
| 1002 | - return $key; |
|
| 1003 | - } |
|
| 1004 | - |
|
| 1005 | - /** |
|
| 1006 | - * Editing a Form or Entry |
|
| 1007 | - * @param string $table |
|
| 1008 | - * @return bool|array |
|
| 1009 | - */ |
|
| 1010 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1011 | - if ( ! $record ) { |
|
| 1012 | - return false; |
|
| 1013 | - } |
|
| 1001 | + } |
|
| 1002 | + return $key; |
|
| 1003 | + } |
|
| 1004 | + |
|
| 1005 | + /** |
|
| 1006 | + * Editing a Form or Entry |
|
| 1007 | + * @param string $table |
|
| 1008 | + * @return bool|array |
|
| 1009 | + */ |
|
| 1010 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1011 | + if ( ! $record ) { |
|
| 1012 | + return false; |
|
| 1013 | + } |
|
| 1014 | 1014 | |
| 1015 | 1015 | if ( empty( $post_values ) ) { |
| 1016 | 1016 | $post_values = stripslashes_deep( $_POST ); |
@@ -1033,14 +1033,14 @@ discard block |
||
| 1033 | 1033 | |
| 1034 | 1034 | self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) ); |
| 1035 | 1035 | |
| 1036 | - if ( $table == 'entries' ) { |
|
| 1037 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1038 | - } else if ( $table == 'forms' ) { |
|
| 1039 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1040 | - } |
|
| 1036 | + if ( $table == 'entries' ) { |
|
| 1037 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1038 | + } else if ( $table == 'forms' ) { |
|
| 1039 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1040 | + } |
|
| 1041 | 1041 | |
| 1042 | - return $values; |
|
| 1043 | - } |
|
| 1042 | + return $values; |
|
| 1043 | + } |
|
| 1044 | 1044 | |
| 1045 | 1045 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 1046 | 1046 | if ( ! empty( $fields ) ) { |
@@ -1053,46 +1053,46 @@ discard block |
||
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | 1055 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1056 | - $post_values = $args['post_values']; |
|
| 1056 | + $post_values = $args['post_values']; |
|
| 1057 | 1057 | |
| 1058 | - if ( $args['default'] ) { |
|
| 1059 | - $meta_value = $field->default_value; |
|
| 1060 | - } else { |
|
| 1058 | + if ( $args['default'] ) { |
|
| 1059 | + $meta_value = $field->default_value; |
|
| 1060 | + } else { |
|
| 1061 | 1061 | if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
| 1062 | 1062 | if ( ! isset( $field->field_options['custom_field'] ) ) { |
| 1063 | - $field->field_options['custom_field'] = ''; |
|
| 1064 | - } |
|
| 1063 | + $field->field_options['custom_field'] = ''; |
|
| 1064 | + } |
|
| 1065 | 1065 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( |
| 1066 | 1066 | 'truncate' => false, |
| 1067 | 1067 | 'type' => $field->type, |
| 1068 | 1068 | 'form_id' => $field->form_id, |
| 1069 | 1069 | 'field' => $field, |
| 1070 | 1070 | ) ); |
| 1071 | - } else { |
|
| 1071 | + } else { |
|
| 1072 | 1072 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1073 | - } |
|
| 1074 | - } |
|
| 1073 | + } |
|
| 1074 | + } |
|
| 1075 | 1075 | |
| 1076 | 1076 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1077 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1077 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1078 | 1078 | |
| 1079 | 1079 | $field_array = self::start_field_array( $field ); |
| 1080 | 1080 | $field_array['value'] = $new_value; |
| 1081 | 1081 | $field_array['type'] = apply_filters( 'frm_field_type', $field_type, $field, $new_value ); |
| 1082 | 1082 | $field_array['parent_form_id'] = $args['parent_form_id']; |
| 1083 | 1083 | |
| 1084 | - $args['field_type'] = $field_type; |
|
| 1084 | + $args['field_type'] = $field_type; |
|
| 1085 | 1085 | |
| 1086 | 1086 | FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args ); |
| 1087 | 1087 | |
| 1088 | 1088 | if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
| 1089 | - $field_array['unique_msg'] = ''; |
|
| 1090 | - } |
|
| 1089 | + $field_array['unique_msg'] = ''; |
|
| 1090 | + } |
|
| 1091 | 1091 | |
| 1092 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1092 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1093 | 1093 | |
| 1094 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1095 | - } |
|
| 1094 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1095 | + } |
|
| 1096 | 1096 | |
| 1097 | 1097 | /** |
| 1098 | 1098 | * @since 3.0 |
@@ -1113,20 +1113,20 @@ discard block |
||
| 1113 | 1113 | ); |
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | - /** |
|
| 1117 | - * @param string $table |
|
| 1118 | - */ |
|
| 1116 | + /** |
|
| 1117 | + * @param string $table |
|
| 1118 | + */ |
|
| 1119 | 1119 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1120 | - if ( $table == 'entries' ) { |
|
| 1121 | - $form = $record->form_id; |
|
| 1120 | + if ( $table == 'entries' ) { |
|
| 1121 | + $form = $record->form_id; |
|
| 1122 | 1122 | FrmForm::maybe_get_form( $form ); |
| 1123 | - } else { |
|
| 1124 | - $form = $record; |
|
| 1125 | - } |
|
| 1123 | + } else { |
|
| 1124 | + $form = $record; |
|
| 1125 | + } |
|
| 1126 | 1126 | |
| 1127 | - if ( ! $form ) { |
|
| 1128 | - return; |
|
| 1129 | - } |
|
| 1127 | + if ( ! $form ) { |
|
| 1128 | + return; |
|
| 1129 | + } |
|
| 1130 | 1130 | |
| 1131 | 1131 | $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
| 1132 | 1132 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
@@ -1135,26 +1135,26 @@ discard block |
||
| 1135 | 1135 | return; |
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | - foreach ( $form->options as $opt => $value ) { |
|
| 1139 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1140 | - } |
|
| 1138 | + foreach ( $form->options as $opt => $value ) { |
|
| 1139 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1140 | + } |
|
| 1141 | 1141 | |
| 1142 | 1142 | self::fill_form_defaults( $post_values, $values ); |
| 1143 | - } |
|
| 1143 | + } |
|
| 1144 | 1144 | |
| 1145 | - /** |
|
| 1146 | - * Set to POST value or default |
|
| 1147 | - */ |
|
| 1145 | + /** |
|
| 1146 | + * Set to POST value or default |
|
| 1147 | + */ |
|
| 1148 | 1148 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1149 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1149 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1150 | 1150 | |
| 1151 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1152 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1151 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1152 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1153 | 1153 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1154 | - } |
|
| 1154 | + } |
|
| 1155 | 1155 | |
| 1156 | 1156 | unset( $opt, $default ); |
| 1157 | - } |
|
| 1157 | + } |
|
| 1158 | 1158 | |
| 1159 | 1159 | if ( ! isset( $values['custom_style'] ) ) { |
| 1160 | 1160 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1163,10 +1163,10 @@ discard block |
||
| 1163 | 1163 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1164 | 1164 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1165 | 1165 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1166 | - } |
|
| 1166 | + } |
|
| 1167 | 1167 | unset( $h ); |
| 1168 | - } |
|
| 1169 | - } |
|
| 1168 | + } |
|
| 1169 | + } |
|
| 1170 | 1170 | |
| 1171 | 1171 | /** |
| 1172 | 1172 | * @since 2.2.10 |
@@ -1189,33 +1189,33 @@ discard block |
||
| 1189 | 1189 | if ( $possible_email_field ) { |
| 1190 | 1190 | $class .= 'show_frm_not_email_to'; |
| 1191 | 1191 | } |
| 1192 | - ?> |
|
| 1192 | + ?> |
|
| 1193 | 1193 | <li> |
| 1194 | 1194 | <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> |
| 1195 | 1195 | <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> |
| 1196 | 1196 | <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> |
| 1197 | 1197 | </li> |
| 1198 | 1198 | <?php |
| 1199 | - } |
|
| 1199 | + } |
|
| 1200 | 1200 | |
| 1201 | 1201 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1202 | - if ( is_array( $str ) ) { |
|
| 1203 | - return ''; |
|
| 1202 | + if ( is_array( $str ) ) { |
|
| 1203 | + return ''; |
|
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | - $length = (int) $length; |
|
| 1206 | + $length = (int) $length; |
|
| 1207 | 1207 | $str = wp_strip_all_tags( $str ); |
| 1208 | 1208 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1209 | 1209 | |
| 1210 | 1210 | if ( $length == 0 ) { |
| 1211 | - return ''; |
|
| 1212 | - } else if ( $length <= 10 ) { |
|
| 1211 | + return ''; |
|
| 1212 | + } else if ( $length <= 10 ) { |
|
| 1213 | 1213 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1214 | 1214 | return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
| 1215 | - } |
|
| 1215 | + } |
|
| 1216 | 1216 | |
| 1217 | - $sub = ''; |
|
| 1218 | - $len = 0; |
|
| 1217 | + $sub = ''; |
|
| 1218 | + $len = 0; |
|
| 1219 | 1219 | |
| 1220 | 1220 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1221 | 1221 | |
@@ -1223,21 +1223,21 @@ discard block |
||
| 1223 | 1223 | $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
| 1224 | 1224 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1225 | 1225 | if ( $total_len > $length && str_word_count( $sub ) ) { |
| 1226 | - break; |
|
| 1227 | - } |
|
| 1226 | + break; |
|
| 1227 | + } |
|
| 1228 | 1228 | |
| 1229 | - $sub .= $part; |
|
| 1229 | + $sub .= $part; |
|
| 1230 | 1230 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1231 | 1231 | |
| 1232 | 1232 | if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
| 1233 | - break; |
|
| 1234 | - } |
|
| 1233 | + break; |
|
| 1234 | + } |
|
| 1235 | 1235 | |
| 1236 | 1236 | unset( $total_len, $word ); |
| 1237 | - } |
|
| 1237 | + } |
|
| 1238 | 1238 | |
| 1239 | 1239 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
| 1240 | - } |
|
| 1240 | + } |
|
| 1241 | 1241 | |
| 1242 | 1242 | public static function mb_function( $function_names, $args ) { |
| 1243 | 1243 | $mb_function_name = $function_names[0]; |
@@ -1250,17 +1250,17 @@ discard block |
||
| 1250 | 1250 | |
| 1251 | 1251 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1252 | 1252 | if ( empty( $date ) ) { |
| 1253 | - return $date; |
|
| 1254 | - } |
|
| 1253 | + return $date; |
|
| 1254 | + } |
|
| 1255 | 1255 | |
| 1256 | 1256 | if ( empty( $date_format ) ) { |
| 1257 | 1257 | $date_format = get_option( 'date_format' ); |
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | 1260 | if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
| 1261 | - $frmpro_settings = new FrmProSettings(); |
|
| 1261 | + $frmpro_settings = new FrmProSettings(); |
|
| 1262 | 1262 | $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
| 1263 | - } |
|
| 1263 | + } |
|
| 1264 | 1264 | |
| 1265 | 1265 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1266 | 1266 | |
@@ -1269,8 +1269,8 @@ discard block |
||
| 1269 | 1269 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1270 | 1270 | } |
| 1271 | 1271 | |
| 1272 | - return $formatted; |
|
| 1273 | - } |
|
| 1272 | + return $formatted; |
|
| 1273 | + } |
|
| 1274 | 1274 | |
| 1275 | 1275 | private static function add_time_to_date( $time_format, $date ) { |
| 1276 | 1276 | if ( empty( $time_format ) ) { |
@@ -1352,32 +1352,32 @@ discard block |
||
| 1352 | 1352 | ); |
| 1353 | 1353 | } |
| 1354 | 1354 | |
| 1355 | - // Pagination Methods |
|
| 1355 | + // Pagination Methods |
|
| 1356 | 1356 | |
| 1357 | - /** |
|
| 1358 | - * @param integer $current_p |
|
| 1359 | - */ |
|
| 1357 | + /** |
|
| 1358 | + * @param integer $current_p |
|
| 1359 | + */ |
|
| 1360 | 1360 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1361 | 1361 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1362 | 1362 | } |
| 1363 | 1363 | |
| 1364 | - /** |
|
| 1365 | - * @param integer $current_p |
|
| 1366 | - */ |
|
| 1367 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1368 | - if ( $current_p == 1 ) { |
|
| 1369 | - return 1; |
|
| 1370 | - } else { |
|
| 1371 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1372 | - } |
|
| 1373 | - } |
|
| 1364 | + /** |
|
| 1365 | + * @param integer $current_p |
|
| 1366 | + */ |
|
| 1367 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1368 | + if ( $current_p == 1 ) { |
|
| 1369 | + return 1; |
|
| 1370 | + } else { |
|
| 1371 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1372 | + } |
|
| 1373 | + } |
|
| 1374 | 1374 | |
| 1375 | 1375 | /** |
| 1376 | 1376 | * @return array |
| 1377 | 1377 | */ |
| 1378 | 1378 | public static function json_to_array( $json_vars ) { |
| 1379 | - $vars = array(); |
|
| 1380 | - foreach ( $json_vars as $jv ) { |
|
| 1379 | + $vars = array(); |
|
| 1380 | + foreach ( $json_vars as $jv ) { |
|
| 1381 | 1381 | $jv_name = explode( '[', $jv['name'] ); |
| 1382 | 1382 | $last = count( $jv_name ) - 1; |
| 1383 | 1383 | foreach ( $jv_name as $p => $n ) { |
@@ -1394,77 +1394,77 @@ discard block |
||
| 1394 | 1394 | $l3 = $name; |
| 1395 | 1395 | } |
| 1396 | 1396 | |
| 1397 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1397 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1398 | 1398 | |
| 1399 | - switch ( $p ) { |
|
| 1400 | - case 0: |
|
| 1401 | - $l1 = $name; |
|
| 1402 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1399 | + switch ( $p ) { |
|
| 1400 | + case 0: |
|
| 1401 | + $l1 = $name; |
|
| 1402 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1403 | 1403 | break; |
| 1404 | 1404 | |
| 1405 | - case 1: |
|
| 1406 | - $l2 = $name; |
|
| 1407 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1405 | + case 1: |
|
| 1406 | + $l2 = $name; |
|
| 1407 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1408 | 1408 | break; |
| 1409 | 1409 | |
| 1410 | - case 2: |
|
| 1411 | - $l3 = $name; |
|
| 1412 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1410 | + case 2: |
|
| 1411 | + $l3 = $name; |
|
| 1412 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1413 | 1413 | break; |
| 1414 | 1414 | |
| 1415 | - case 3: |
|
| 1416 | - $l4 = $name; |
|
| 1417 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1418 | - } |
|
| 1415 | + case 3: |
|
| 1416 | + $l4 = $name; |
|
| 1417 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1418 | + } |
|
| 1419 | 1419 | |
| 1420 | 1420 | unset( $this_val, $n ); |
| 1421 | - } |
|
| 1421 | + } |
|
| 1422 | 1422 | |
| 1423 | 1423 | unset( $last, $jv ); |
| 1424 | - } |
|
| 1425 | - |
|
| 1426 | - return $vars; |
|
| 1427 | - } |
|
| 1428 | - |
|
| 1429 | - /** |
|
| 1430 | - * @param string $name |
|
| 1431 | - * @param string $l1 |
|
| 1432 | - */ |
|
| 1433 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1434 | - if ( $name == '' ) { |
|
| 1435 | - $vars[] = $val; |
|
| 1436 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1437 | - $vars[ $l1 ] = $val; |
|
| 1438 | - } |
|
| 1439 | - } |
|
| 1424 | + } |
|
| 1425 | + |
|
| 1426 | + return $vars; |
|
| 1427 | + } |
|
| 1428 | + |
|
| 1429 | + /** |
|
| 1430 | + * @param string $name |
|
| 1431 | + * @param string $l1 |
|
| 1432 | + */ |
|
| 1433 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1434 | + if ( $name == '' ) { |
|
| 1435 | + $vars[] = $val; |
|
| 1436 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1437 | + $vars[ $l1 ] = $val; |
|
| 1438 | + } |
|
| 1439 | + } |
|
| 1440 | 1440 | |
| 1441 | 1441 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1442 | - $tooltips = array( |
|
| 1443 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1444 | - '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' ), |
|
| 1445 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1446 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1447 | - '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' ), |
|
| 1448 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1449 | - '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() ) ), |
|
| 1450 | - ); |
|
| 1451 | - |
|
| 1452 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1453 | - return; |
|
| 1454 | - } |
|
| 1455 | - |
|
| 1456 | - if ( 'open' == $class ) { |
|
| 1457 | - echo ' frm_help"'; |
|
| 1458 | - } else { |
|
| 1459 | - echo ' class="frm_help"'; |
|
| 1460 | - } |
|
| 1442 | + $tooltips = array( |
|
| 1443 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1444 | + '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' ), |
|
| 1445 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1446 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1447 | + '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' ), |
|
| 1448 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1449 | + '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() ) ), |
|
| 1450 | + ); |
|
| 1451 | + |
|
| 1452 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1453 | + return; |
|
| 1454 | + } |
|
| 1455 | + |
|
| 1456 | + if ( 'open' == $class ) { |
|
| 1457 | + echo ' frm_help"'; |
|
| 1458 | + } else { |
|
| 1459 | + echo ' class="frm_help"'; |
|
| 1460 | + } |
|
| 1461 | 1461 | |
| 1462 | 1462 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1463 | 1463 | |
| 1464 | - if ( 'open' != $class ) { |
|
| 1465 | - echo '"'; |
|
| 1466 | - } |
|
| 1467 | - } |
|
| 1464 | + if ( 'open' != $class ) { |
|
| 1465 | + echo '"'; |
|
| 1466 | + } |
|
| 1467 | + } |
|
| 1468 | 1468 | |
| 1469 | 1469 | /** |
| 1470 | 1470 | * Add the current_page class to that page in the form nav |
@@ -1480,35 +1480,35 @@ discard block |
||
| 1480 | 1480 | } |
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | - /** |
|
| 1484 | - * Prepare and json_encode post content |
|
| 1485 | - * |
|
| 1486 | - * @since 2.0 |
|
| 1487 | - * |
|
| 1488 | - * @param array $post_content |
|
| 1489 | - * @return string $post_content ( json encoded array ) |
|
| 1490 | - */ |
|
| 1491 | - public static function prepare_and_encode( $post_content ) { |
|
| 1492 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1483 | + /** |
|
| 1484 | + * Prepare and json_encode post content |
|
| 1485 | + * |
|
| 1486 | + * @since 2.0 |
|
| 1487 | + * |
|
| 1488 | + * @param array $post_content |
|
| 1489 | + * @return string $post_content ( json encoded array ) |
|
| 1490 | + */ |
|
| 1491 | + public static function prepare_and_encode( $post_content ) { |
|
| 1492 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1493 | 1493 | foreach ( $post_content as $key => $val ) { |
| 1494 | 1494 | // Replace problematic characters (like ") |
| 1495 | 1495 | $val = str_replace( '"', '"', $val ); |
| 1496 | 1496 | |
| 1497 | 1497 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1498 | - unset( $key, $val ); |
|
| 1499 | - } |
|
| 1498 | + unset( $key, $val ); |
|
| 1499 | + } |
|
| 1500 | 1500 | |
| 1501 | - // json_encode the array |
|
| 1502 | - $post_content = json_encode( $post_content ); |
|
| 1501 | + // json_encode the array |
|
| 1502 | + $post_content = json_encode( $post_content ); |
|
| 1503 | 1503 | |
| 1504 | - // add extra slashes for \r\n since WP strips them |
|
| 1504 | + // add extra slashes for \r\n since WP strips them |
|
| 1505 | 1505 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1506 | 1506 | |
| 1507 | - // allow for " |
|
| 1508 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1507 | + // allow for " |
|
| 1508 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1509 | 1509 | |
| 1510 | - return $post_content; |
|
| 1511 | - } |
|
| 1510 | + return $post_content; |
|
| 1511 | + } |
|
| 1512 | 1512 | |
| 1513 | 1513 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1514 | 1514 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1531,63 +1531,63 @@ discard block |
||
| 1531 | 1531 | |
| 1532 | 1532 | public static function maybe_json_decode( $string ) { |
| 1533 | 1533 | if ( is_array( $string ) ) { |
| 1534 | - return $string; |
|
| 1535 | - } |
|
| 1534 | + return $string; |
|
| 1535 | + } |
|
| 1536 | 1536 | |
| 1537 | 1537 | $new_string = json_decode( $string, true ); |
| 1538 | 1538 | if ( function_exists( 'json_last_error' ) ) { |
| 1539 | 1539 | // php 5.3+ |
| 1540 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1541 | - $string = $new_string; |
|
| 1542 | - } |
|
| 1540 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1541 | + $string = $new_string; |
|
| 1542 | + } |
|
| 1543 | 1543 | } elseif ( isset( $new_string ) ) { |
| 1544 | 1544 | // php < 5.3 fallback |
| 1545 | - $string = $new_string; |
|
| 1546 | - } |
|
| 1547 | - return $string; |
|
| 1548 | - } |
|
| 1549 | - |
|
| 1550 | - /** |
|
| 1551 | - * @since 1.07.10 |
|
| 1552 | - * |
|
| 1553 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1554 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1555 | - */ |
|
| 1545 | + $string = $new_string; |
|
| 1546 | + } |
|
| 1547 | + return $string; |
|
| 1548 | + } |
|
| 1549 | + |
|
| 1550 | + /** |
|
| 1551 | + * @since 1.07.10 |
|
| 1552 | + * |
|
| 1553 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1554 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1555 | + */ |
|
| 1556 | 1556 | public static function maybe_highlight_menu( $post_type ) { |
| 1557 | - global $post; |
|
| 1557 | + global $post; |
|
| 1558 | 1558 | |
| 1559 | 1559 | if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
| 1560 | - return; |
|
| 1561 | - } |
|
| 1560 | + return; |
|
| 1561 | + } |
|
| 1562 | 1562 | |
| 1563 | 1563 | if ( is_object( $post ) && $post->post_type != $post_type ) { |
| 1564 | - return; |
|
| 1565 | - } |
|
| 1564 | + return; |
|
| 1565 | + } |
|
| 1566 | 1566 | |
| 1567 | - self::load_admin_wide_js(); |
|
| 1568 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1569 | - } |
|
| 1567 | + self::load_admin_wide_js(); |
|
| 1568 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1569 | + } |
|
| 1570 | 1570 | |
| 1571 | - /** |
|
| 1572 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1573 | - * @since 2.0 |
|
| 1574 | - */ |
|
| 1571 | + /** |
|
| 1572 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1573 | + * @since 2.0 |
|
| 1574 | + */ |
|
| 1575 | 1575 | public static function load_admin_wide_js( $load = true ) { |
| 1576 | - $version = FrmAppHelper::plugin_version(); |
|
| 1576 | + $version = FrmAppHelper::plugin_version(); |
|
| 1577 | 1577 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1578 | 1578 | |
| 1579 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1579 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1580 | 1580 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1581 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1581 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1582 | 1582 | 'url' => FrmAppHelper::plugin_url(), |
| 1583 | 1583 | 'loading' => __( 'Loading…' ), |
| 1584 | 1584 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
| 1585 | - ) ); |
|
| 1585 | + ) ); |
|
| 1586 | 1586 | |
| 1587 | 1587 | if ( $load ) { |
| 1588 | 1588 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1589 | 1589 | } |
| 1590 | - } |
|
| 1590 | + } |
|
| 1591 | 1591 | |
| 1592 | 1592 | /** |
| 1593 | 1593 | * @since 2.0.9 |
@@ -1596,9 +1596,9 @@ discard block |
||
| 1596 | 1596 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1597 | 1597 | } |
| 1598 | 1598 | |
| 1599 | - /** |
|
| 1600 | - * @param string $location |
|
| 1601 | - */ |
|
| 1599 | + /** |
|
| 1600 | + * @param string $location |
|
| 1601 | + */ |
|
| 1602 | 1602 | public static function localize_script( $location ) { |
| 1603 | 1603 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1604 | 1604 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1658,27 +1658,27 @@ discard block |
||
| 1658 | 1658 | } |
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | - /** |
|
| 1661 | + /** |
|
| 1662 | 1662 | * echo the message on the plugins listing page |
| 1663 | - * @since 1.07.10 |
|
| 1664 | - * |
|
| 1665 | - * @param float $min_version The version the add-on requires |
|
| 1666 | - */ |
|
| 1663 | + * @since 1.07.10 |
|
| 1664 | + * |
|
| 1665 | + * @param float $min_version The version the add-on requires |
|
| 1666 | + */ |
|
| 1667 | 1667 | public static function min_version_notice( $min_version ) { |
| 1668 | - $frm_version = self::plugin_version(); |
|
| 1668 | + $frm_version = self::plugin_version(); |
|
| 1669 | 1669 | |
| 1670 | - // check if Formidable meets minimum requirements |
|
| 1670 | + // check if Formidable meets minimum requirements |
|
| 1671 | 1671 | if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
| 1672 | - return; |
|
| 1673 | - } |
|
| 1672 | + return; |
|
| 1673 | + } |
|
| 1674 | 1674 | |
| 1675 | 1675 | $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
| 1676 | 1676 | 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">' . |
| 1677 | - esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1678 | - '</div></td></tr>'; |
|
| 1679 | - } |
|
| 1677 | + esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1678 | + '</div></td></tr>'; |
|
| 1679 | + } |
|
| 1680 | 1680 | |
| 1681 | - public static function locales( $type = 'date' ) { |
|
| 1681 | + public static function locales( $type = 'date' ) { |
|
| 1682 | 1682 | $locales = array( |
| 1683 | 1683 | 'en' => __( 'English', 'formidable' ), |
| 1684 | 1684 | '' => __( 'English/Western', 'formidable' ), |
@@ -1757,8 +1757,8 @@ discard block |
||
| 1757 | 1757 | $locales = array_diff_key( $locales, array_flip( $unset ) ); |
| 1758 | 1758 | $locales = apply_filters( 'frm_locales', $locales ); |
| 1759 | 1759 | |
| 1760 | - return $locales; |
|
| 1761 | - } |
|
| 1760 | + return $locales; |
|
| 1761 | + } |
|
| 1762 | 1762 | |
| 1763 | 1763 | /** |
| 1764 | 1764 | * Prepare and save settings in styles and actions |