@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public static $plug_version = '3.05'; |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @since 1.07.02 |
|
| 18 | - * |
|
| 19 | - * @param none |
|
| 20 | - * @return string The version of this plugin |
|
| 21 | - */ |
|
| 22 | - public static function plugin_version() { |
|
| 23 | - return self::$plug_version; |
|
| 24 | - } |
|
| 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 | } |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | return add_query_arg( $query_args, $page ); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * Get the Formidable settings |
|
| 93 | - * |
|
| 94 | - * @since 2.0 |
|
| 95 | - * |
|
| 96 | - * @param None |
|
| 97 | - * @return FrmSettings $frm_setings |
|
| 98 | - */ |
|
| 91 | + /** |
|
| 92 | + * Get the Formidable settings |
|
| 93 | + * |
|
| 94 | + * @since 2.0 |
|
| 95 | + * |
|
| 96 | + * @param None |
|
| 97 | + * @return FrmSettings $frm_setings |
|
| 98 | + */ |
|
| 99 | 99 | public static function get_settings() { |
| 100 | 100 | global $frm_settings; |
| 101 | 101 | if ( empty( $frm_settings ) ) { |
@@ -156,50 +156,50 @@ discard block |
||
| 156 | 156 | return $is_formidable; |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - /** |
|
| 160 | - * Check for certain page in Formidable settings |
|
| 161 | - * |
|
| 162 | - * @since 2.0 |
|
| 163 | - * |
|
| 164 | - * @param string $page The name of the page to check |
|
| 165 | - * @return boolean |
|
| 166 | - */ |
|
| 159 | + /** |
|
| 160 | + * Check for certain page in Formidable settings |
|
| 161 | + * |
|
| 162 | + * @since 2.0 |
|
| 163 | + * |
|
| 164 | + * @param string $page The name of the page to check |
|
| 165 | + * @return boolean |
|
| 166 | + */ |
|
| 167 | 167 | public static function is_admin_page( $page = 'formidable' ) { |
| 168 | - global $pagenow; |
|
| 168 | + global $pagenow; |
|
| 169 | 169 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 170 | - if ( $pagenow ) { |
|
| 170 | + if ( $pagenow ) { |
|
| 171 | 171 | // allow this to be true during ajax load i.e. ajax form builder loading |
| 172 | 172 | return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page; |
| 173 | - } |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | 175 | return is_admin() && $get_page == $page; |
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Check for the form preview page |
|
| 180 | - * |
|
| 181 | - * @since 2.0 |
|
| 182 | - * |
|
| 183 | - * @param None |
|
| 184 | - * @return boolean |
|
| 185 | - */ |
|
| 186 | - public static function is_preview_page() { |
|
| 187 | - global $pagenow; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Check for the form preview page |
|
| 180 | + * |
|
| 181 | + * @since 2.0 |
|
| 182 | + * |
|
| 183 | + * @param None |
|
| 184 | + * @return boolean |
|
| 185 | + */ |
|
| 186 | + public static function is_preview_page() { |
|
| 187 | + global $pagenow; |
|
| 188 | 188 | $action = self::simple_get( 'action', 'sanitize_title' ); |
| 189 | 189 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * Check for ajax except the form preview page |
|
| 194 | - * |
|
| 195 | - * @since 2.0 |
|
| 196 | - * |
|
| 197 | - * @param None |
|
| 198 | - * @return boolean |
|
| 199 | - */ |
|
| 200 | - public static function doing_ajax() { |
|
| 201 | - return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 202 | - } |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * Check for ajax except the form preview page |
|
| 194 | + * |
|
| 195 | + * @since 2.0 |
|
| 196 | + * |
|
| 197 | + * @param None |
|
| 198 | + * @return boolean |
|
| 199 | + */ |
|
| 200 | + public static function doing_ajax() { |
|
| 201 | + return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | public static function js_suffix() { |
| 205 | 205 | return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
@@ -227,81 +227,81 @@ discard block |
||
| 227 | 227 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - /** |
|
| 231 | - * Check if on an admin page |
|
| 232 | - * |
|
| 233 | - * @since 2.0 |
|
| 234 | - * |
|
| 235 | - * @param None |
|
| 236 | - * @return boolean |
|
| 237 | - */ |
|
| 238 | - public static function is_admin() { |
|
| 239 | - return is_admin() && ! self::wp_doing_ajax(); |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * Check if value contains blank value or empty array |
|
| 244 | - * |
|
| 245 | - * @since 2.0 |
|
| 246 | - * @param mixed $value - value to check |
|
| 230 | + /** |
|
| 231 | + * Check if on an admin page |
|
| 232 | + * |
|
| 233 | + * @since 2.0 |
|
| 234 | + * |
|
| 235 | + * @param None |
|
| 236 | + * @return boolean |
|
| 237 | + */ |
|
| 238 | + public static function is_admin() { |
|
| 239 | + return is_admin() && ! self::wp_doing_ajax(); |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * Check if value contains blank value or empty array |
|
| 244 | + * |
|
| 245 | + * @since 2.0 |
|
| 246 | + * @param mixed $value - value to check |
|
| 247 | 247 | * @param string |
| 248 | - * @return boolean |
|
| 249 | - */ |
|
| 250 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 251 | - return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 255 | - return ! self::is_empty_value( $value, $empty ); |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * Get any value from the $_SERVER |
|
| 260 | - * |
|
| 261 | - * @since 2.0 |
|
| 262 | - * @param string $value |
|
| 263 | - * @return string |
|
| 264 | - */ |
|
| 248 | + * @return boolean |
|
| 249 | + */ |
|
| 250 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 251 | + return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 255 | + return ! self::is_empty_value( $value, $empty ); |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * Get any value from the $_SERVER |
|
| 260 | + * |
|
| 261 | + * @since 2.0 |
|
| 262 | + * @param string $value |
|
| 263 | + * @return string |
|
| 264 | + */ |
|
| 265 | 265 | public static function get_server_value( $value ) { |
| 266 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * Check for the IP address in several places |
|
| 271 | - * Used by [ip] shortcode |
|
| 272 | - * |
|
| 273 | - * @return string The IP address of the current user |
|
| 274 | - */ |
|
| 275 | - public static function get_ip_address() { |
|
| 266 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * Check for the IP address in several places |
|
| 271 | + * Used by [ip] shortcode |
|
| 272 | + * |
|
| 273 | + * @return string The IP address of the current user |
|
| 274 | + */ |
|
| 275 | + public static function get_ip_address() { |
|
| 276 | 276 | $ip = ''; |
| 277 | 277 | 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 ) { |
| 278 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 279 | - continue; |
|
| 280 | - } |
|
| 278 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 279 | + continue; |
|
| 280 | + } |
|
| 281 | 281 | |
| 282 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 282 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 283 | 283 | $ip = trim( $ip ); // just to be safe |
| 284 | 284 | |
| 285 | 285 | if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
| 286 | - return sanitize_text_field( $ip ); |
|
| 287 | - } |
|
| 288 | - } |
|
| 289 | - } |
|
| 286 | + return sanitize_text_field( $ip ); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | + } |
|
| 290 | 290 | |
| 291 | 291 | return sanitize_text_field( $ip ); |
| 292 | - } |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 294 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 295 | 295 | if ( strpos( $param, '[' ) ) { |
| 296 | 296 | $params = explode( '[', $param ); |
| 297 | - $param = $params[0]; |
|
| 298 | - } |
|
| 297 | + $param = $params[0]; |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | 300 | if ( $src == 'get' ) { |
| 301 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 302 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 303 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 304 | - } |
|
| 301 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 302 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 303 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 304 | + } |
|
| 305 | 305 | self::sanitize_value( $sanitize, $value ); |
| 306 | 306 | } else { |
| 307 | 307 | $value = self::get_simple_request( |
@@ -325,8 +325,8 @@ discard block |
||
| 325 | 325 | } |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - return $value; |
|
| 329 | - } |
|
| 328 | + return $value; |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | 331 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
| 332 | 332 | return self::get_simple_request( |
@@ -394,12 +394,12 @@ discard block |
||
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | /** |
| 397 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 398 | - * |
|
| 399 | - * @since 2.0.8 |
|
| 400 | - * @param string $value |
|
| 401 | - * @return string $value |
|
| 402 | - */ |
|
| 397 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 398 | + * |
|
| 399 | + * @since 2.0.8 |
|
| 400 | + * @param string $value |
|
| 401 | + * @return string $value |
|
| 402 | + */ |
|
| 403 | 403 | public static function preserve_backslashes( $value ) { |
| 404 | 404 | // If backslashes have already been added, don't add them again |
| 405 | 405 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -421,14 +421,14 @@ discard block |
||
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 425 | - $temp_values = $values; |
|
| 426 | - foreach ( $temp_values as $k => $val ) { |
|
| 427 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 424 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 425 | + $temp_values = $values; |
|
| 426 | + foreach ( $temp_values as $k => $val ) { |
|
| 427 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 428 | 428 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 429 | - } |
|
| 430 | - } |
|
| 431 | - } |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | 432 | |
| 433 | 433 | /** |
| 434 | 434 | * Sanitize the value, and allow some HTML |
@@ -565,40 +565,40 @@ discard block |
||
| 565 | 565 | ); |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | - /** |
|
| 569 | - * Used when switching the action for a bulk action |
|
| 568 | + /** |
|
| 569 | + * Used when switching the action for a bulk action |
|
| 570 | 570 | * |
| 571 | - * @since 2.0 |
|
| 572 | - */ |
|
| 571 | + * @since 2.0 |
|
| 572 | + */ |
|
| 573 | 573 | public static function remove_get_action() { |
| 574 | 574 | if ( ! isset( $_GET ) ) { |
| 575 | 575 | return; |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 579 | - if ( ! empty( $new_action ) ) { |
|
| 578 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 579 | + if ( ! empty( $new_action ) ) { |
|
| 580 | 580 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', self::get_server_value( 'REQUEST_URI' ) ); |
| 581 | - } |
|
| 582 | - } |
|
| 581 | + } |
|
| 582 | + } |
|
| 583 | 583 | |
| 584 | - /** |
|
| 585 | - * Check the WP query for a parameter |
|
| 586 | - * |
|
| 587 | - * @since 2.0 |
|
| 588 | - * @return string|array |
|
| 589 | - */ |
|
| 590 | - public static function get_query_var( $value, $param ) { |
|
| 591 | - if ( $value != '' ) { |
|
| 592 | - return $value; |
|
| 593 | - } |
|
| 584 | + /** |
|
| 585 | + * Check the WP query for a parameter |
|
| 586 | + * |
|
| 587 | + * @since 2.0 |
|
| 588 | + * @return string|array |
|
| 589 | + */ |
|
| 590 | + public static function get_query_var( $value, $param ) { |
|
| 591 | + if ( $value != '' ) { |
|
| 592 | + return $value; |
|
| 593 | + } |
|
| 594 | 594 | |
| 595 | - global $wp_query; |
|
| 596 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 597 | - $value = $wp_query->query_vars[ $param ]; |
|
| 598 | - } |
|
| 595 | + global $wp_query; |
|
| 596 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 597 | + $value = $wp_query->query_vars[ $param ]; |
|
| 598 | + } |
|
| 599 | 599 | |
| 600 | - return $value; |
|
| 601 | - } |
|
| 600 | + return $value; |
|
| 601 | + } |
|
| 602 | 602 | |
| 603 | 603 | /** |
| 604 | 604 | * @since 3.0 |
@@ -620,16 +620,16 @@ discard block |
||
| 620 | 620 | } |
| 621 | 621 | } |
| 622 | 622 | |
| 623 | - /** |
|
| 624 | - * @param string $type |
|
| 625 | - */ |
|
| 626 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 627 | - // only load the form hooks once |
|
| 623 | + /** |
|
| 624 | + * @param string $type |
|
| 625 | + */ |
|
| 626 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 627 | + // only load the form hooks once |
|
| 628 | 628 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 629 | - if ( ! $hooks_loaded ) { |
|
| 629 | + if ( ! $hooks_loaded ) { |
|
| 630 | 630 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 631 | - } |
|
| 632 | - } |
|
| 631 | + } |
|
| 632 | + } |
|
| 633 | 633 | |
| 634 | 634 | /** |
| 635 | 635 | * Save all front-end js scripts into a single file |
@@ -654,18 +654,18 @@ discard block |
||
| 654 | 654 | $new_file->combine_files( $files ); |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | - /** |
|
| 658 | - * Check a value from a shortcode to see if true or false. |
|
| 659 | - * True when value is 1, true, 'true', 'yes' |
|
| 660 | - * |
|
| 661 | - * @since 1.07.10 |
|
| 662 | - * |
|
| 663 | - * @param string $value The value to compare |
|
| 664 | - * @return boolean True or False |
|
| 665 | - */ |
|
| 657 | + /** |
|
| 658 | + * Check a value from a shortcode to see if true or false. |
|
| 659 | + * True when value is 1, true, 'true', 'yes' |
|
| 660 | + * |
|
| 661 | + * @since 1.07.10 |
|
| 662 | + * |
|
| 663 | + * @param string $value The value to compare |
|
| 664 | + * @return boolean True or False |
|
| 665 | + */ |
|
| 666 | 666 | public static function is_true( $value ) { |
| 667 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 668 | - } |
|
| 667 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 668 | + } |
|
| 669 | 669 | |
| 670 | 670 | public static function get_pages() { |
| 671 | 671 | $query = array( |
@@ -678,10 +678,10 @@ discard block |
||
| 678 | 678 | return get_posts( $query ); |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 682 | - $pages = self::get_pages(); |
|
| 681 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 682 | + $pages = self::get_pages(); |
|
| 683 | 683 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 684 | - ?> |
|
| 684 | + ?> |
|
| 685 | 685 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
| 686 | 686 | <option value=""> </option> |
| 687 | 687 | <?php foreach ( $pages as $page ) { ?> |
@@ -691,16 +691,16 @@ discard block |
||
| 691 | 691 | <?php } ?> |
| 692 | 692 | </select> |
| 693 | 693 | <?php |
| 694 | - } |
|
| 694 | + } |
|
| 695 | 695 | |
| 696 | 696 | public static function post_edit_link( $post_id ) { |
| 697 | 697 | $post = get_post( $post_id ); |
| 698 | - if ( $post ) { |
|
| 698 | + if ( $post ) { |
|
| 699 | 699 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 700 | 700 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 701 | - } |
|
| 702 | - return ''; |
|
| 703 | - } |
|
| 701 | + } |
|
| 702 | + return ''; |
|
| 703 | + } |
|
| 704 | 704 | |
| 705 | 705 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 706 | 706 | ?> |
@@ -711,73 +711,73 @@ discard block |
||
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | public static function roles_options( $capability ) { |
| 714 | - global $frm_vars; |
|
| 714 | + global $frm_vars; |
|
| 715 | 715 | if ( isset( $frm_vars['editable_roles'] ) ) { |
| 716 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 717 | - } else { |
|
| 718 | - $editable_roles = get_editable_roles(); |
|
| 719 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 720 | - } |
|
| 716 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 717 | + } else { |
|
| 718 | + $editable_roles = get_editable_roles(); |
|
| 719 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 720 | + } |
|
| 721 | 721 | |
| 722 | - foreach ( $editable_roles as $role => $details ) { |
|
| 722 | + foreach ( $editable_roles as $role => $details ) { |
|
| 723 | 723 | $name = translate_user_role( $details['name'] ); |
| 724 | 724 | ?> |
| 725 | 725 | <option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option> |
| 726 | 726 | <?php |
| 727 | 727 | unset( $role, $details ); |
| 728 | - } |
|
| 729 | - } |
|
| 728 | + } |
|
| 729 | + } |
|
| 730 | 730 | |
| 731 | 731 | public static function frm_capabilities( $type = 'auto' ) { |
| 732 | - $cap = array( |
|
| 733 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 734 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 735 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 736 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 737 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 738 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 739 | - ); |
|
| 732 | + $cap = array( |
|
| 733 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 734 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 735 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 736 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 737 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 738 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 739 | + ); |
|
| 740 | 740 | |
| 741 | 741 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 742 | - return $cap; |
|
| 743 | - } |
|
| 742 | + return $cap; |
|
| 743 | + } |
|
| 744 | 744 | |
| 745 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 746 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 747 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 748 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 745 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 746 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 747 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 748 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 749 | 749 | |
| 750 | - return $cap; |
|
| 751 | - } |
|
| 750 | + return $cap; |
|
| 751 | + } |
|
| 752 | 752 | |
| 753 | 753 | public static function user_has_permission( $needed_role ) { |
| 754 | - if ( $needed_role == '-1' ) { |
|
| 755 | - return false; |
|
| 754 | + if ( $needed_role == '-1' ) { |
|
| 755 | + return false; |
|
| 756 | 756 | } |
| 757 | 757 | |
| 758 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 759 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 760 | - return true; |
|
| 761 | - } |
|
| 758 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 759 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 760 | + return true; |
|
| 761 | + } |
|
| 762 | 762 | |
| 763 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 764 | - foreach ( $roles as $role ) { |
|
| 763 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 764 | + foreach ( $roles as $role ) { |
|
| 765 | 765 | if ( current_user_can( $role ) ) { |
| 766 | - return true; |
|
| 766 | + return true; |
|
| 767 | 767 | } |
| 768 | - if ( $role == $needed_role ) { |
|
| 769 | - break; |
|
| 768 | + if ( $role == $needed_role ) { |
|
| 769 | + break; |
|
| 770 | 770 | } |
| 771 | - } |
|
| 772 | - return false; |
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - /** |
|
| 776 | - * Make sure administrators can see Formidable menu |
|
| 777 | - * |
|
| 778 | - * @since 2.0 |
|
| 779 | - */ |
|
| 780 | - public static function maybe_add_permissions() { |
|
| 771 | + } |
|
| 772 | + return false; |
|
| 773 | + } |
|
| 774 | + |
|
| 775 | + /** |
|
| 776 | + * Make sure administrators can see Formidable menu |
|
| 777 | + * |
|
| 778 | + * @since 2.0 |
|
| 779 | + */ |
|
| 780 | + public static function maybe_add_permissions() { |
|
| 781 | 781 | self::force_capability( 'frm_view_entries' ); |
| 782 | 782 | |
| 783 | 783 | if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
@@ -786,12 +786,12 @@ discard block |
||
| 786 | 786 | |
| 787 | 787 | $user_id = get_current_user_id(); |
| 788 | 788 | $user = new WP_User( $user_id ); |
| 789 | - $frm_roles = self::frm_capabilities(); |
|
| 790 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 789 | + $frm_roles = self::frm_capabilities(); |
|
| 790 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 791 | 791 | $user->add_cap( $frm_role ); |
| 792 | 792 | unset( $frm_role, $frm_role_description ); |
| 793 | - } |
|
| 794 | - } |
|
| 793 | + } |
|
| 794 | + } |
|
| 795 | 795 | |
| 796 | 796 | /** |
| 797 | 797 | * Make sure admins have permission to see the menu items |
@@ -808,30 +808,30 @@ discard block |
||
| 808 | 808 | } |
| 809 | 809 | } |
| 810 | 810 | |
| 811 | - /** |
|
| 812 | - * Check if the user has permision for action. |
|
| 813 | - * Return permission message and stop the action if no permission |
|
| 811 | + /** |
|
| 812 | + * Check if the user has permision for action. |
|
| 813 | + * Return permission message and stop the action if no permission |
|
| 814 | 814 | * |
| 815 | - * @since 2.0 |
|
| 816 | - * @param string $permission |
|
| 817 | - */ |
|
| 815 | + * @since 2.0 |
|
| 816 | + * @param string $permission |
|
| 817 | + */ |
|
| 818 | 818 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 819 | 819 | $permission_error = self::permission_nonce_error( $permission ); |
| 820 | - if ( $permission_error !== false ) { |
|
| 821 | - if ( 'hide' == $show_message ) { |
|
| 822 | - $permission_error = ''; |
|
| 823 | - } |
|
| 820 | + if ( $permission_error !== false ) { |
|
| 821 | + if ( 'hide' == $show_message ) { |
|
| 822 | + $permission_error = ''; |
|
| 823 | + } |
|
| 824 | 824 | wp_die( esc_html( $permission_error ) ); |
| 825 | - } |
|
| 826 | - } |
|
| 825 | + } |
|
| 826 | + } |
|
| 827 | 827 | |
| 828 | - /** |
|
| 829 | - * Check user permission and nonce |
|
| 828 | + /** |
|
| 829 | + * Check user permission and nonce |
|
| 830 | 830 | * |
| 831 | - * @since 2.0 |
|
| 832 | - * @param string $permission |
|
| 833 | - * @return false|string The permission message or false if allowed |
|
| 834 | - */ |
|
| 831 | + * @since 2.0 |
|
| 832 | + * @param string $permission |
|
| 833 | + * @return false|string The permission message or false if allowed |
|
| 834 | + */ |
|
| 835 | 835 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 836 | 836 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 837 | 837 | $frm_settings = self::get_settings(); |
@@ -840,22 +840,22 @@ discard block |
||
| 840 | 840 | |
| 841 | 841 | $error = false; |
| 842 | 842 | if ( empty( $nonce_name ) ) { |
| 843 | - return $error; |
|
| 844 | - } |
|
| 843 | + return $error; |
|
| 844 | + } |
|
| 845 | 845 | |
| 846 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 847 | - $frm_settings = self::get_settings(); |
|
| 848 | - $error = $frm_settings->admin_permission; |
|
| 849 | - } |
|
| 846 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 847 | + $frm_settings = self::get_settings(); |
|
| 848 | + $error = $frm_settings->admin_permission; |
|
| 849 | + } |
|
| 850 | 850 | |
| 851 | - return $error; |
|
| 852 | - } |
|
| 851 | + return $error; |
|
| 852 | + } |
|
| 853 | 853 | |
| 854 | - public static function checked( $values, $current ) { |
|
| 854 | + public static function checked( $values, $current ) { |
|
| 855 | 855 | if ( self::check_selected( $values, $current ) ) { |
| 856 | - echo ' checked="checked"'; |
|
| 856 | + echo ' checked="checked"'; |
|
| 857 | 857 | } |
| 858 | - } |
|
| 858 | + } |
|
| 859 | 859 | |
| 860 | 860 | public static function check_selected( $values, $current ) { |
| 861 | 861 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -893,24 +893,24 @@ discard block |
||
| 893 | 893 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 894 | 894 | } |
| 895 | 895 | |
| 896 | - /** |
|
| 897 | - * Flatten a multi-dimensional array |
|
| 898 | - */ |
|
| 896 | + /** |
|
| 897 | + * Flatten a multi-dimensional array |
|
| 898 | + */ |
|
| 899 | 899 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 900 | - $return = array(); |
|
| 901 | - foreach ( $array as $key => $value ) { |
|
| 900 | + $return = array(); |
|
| 901 | + foreach ( $array as $key => $value ) { |
|
| 902 | 902 | if ( is_array( $value ) ) { |
| 903 | 903 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 904 | - } else { |
|
| 904 | + } else { |
|
| 905 | 905 | if ( $keys == 'keep' ) { |
| 906 | 906 | $return[ $key ] = $value; |
| 907 | 907 | } else { |
| 908 | 908 | $return[] = $value; |
| 909 | 909 | } |
| 910 | - } |
|
| 911 | - } |
|
| 912 | - return $return; |
|
| 913 | - } |
|
| 910 | + } |
|
| 911 | + } |
|
| 912 | + return $return; |
|
| 913 | + } |
|
| 914 | 914 | |
| 915 | 915 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 916 | 916 | $safe_text = str_replace( '"', '"', $text ); |
@@ -921,11 +921,11 @@ discard block |
||
| 921 | 921 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | - /** |
|
| 925 | - * Add auto paragraphs to text areas |
|
| 924 | + /** |
|
| 925 | + * Add auto paragraphs to text areas |
|
| 926 | 926 | * |
| 927 | - * @since 2.0 |
|
| 928 | - */ |
|
| 927 | + * @since 2.0 |
|
| 928 | + */ |
|
| 929 | 929 | public static function use_wpautop( $content ) { |
| 930 | 930 | if ( apply_filters( 'frm_use_wpautop', true ) ) { |
| 931 | 931 | $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
@@ -934,26 +934,26 @@ discard block |
||
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | public static function replace_quotes( $val ) { |
| 937 | - //Replace double quotes |
|
| 937 | + //Replace double quotes |
|
| 938 | 938 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 939 | - //Replace single quotes |
|
| 940 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 941 | - return $val; |
|
| 942 | - } |
|
| 943 | - |
|
| 944 | - /** |
|
| 945 | - * @since 2.0 |
|
| 946 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 947 | - */ |
|
| 948 | - public static function jquery_ui_base_url() { |
|
| 939 | + //Replace single quotes |
|
| 940 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 941 | + return $val; |
|
| 942 | + } |
|
| 943 | + |
|
| 944 | + /** |
|
| 945 | + * @since 2.0 |
|
| 946 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 947 | + */ |
|
| 948 | + public static function jquery_ui_base_url() { |
|
| 949 | 949 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 950 | 950 | $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
| 951 | - return $url; |
|
| 952 | - } |
|
| 951 | + return $url; |
|
| 952 | + } |
|
| 953 | 953 | |
| 954 | - /** |
|
| 955 | - * @param string $handle |
|
| 956 | - */ |
|
| 954 | + /** |
|
| 955 | + * @param string $handle |
|
| 956 | + */ |
|
| 957 | 957 | public static function script_version( $handle, $default = 0 ) { |
| 958 | 958 | global $wp_scripts; |
| 959 | 959 | if ( ! $wp_scripts ) { |
@@ -975,12 +975,12 @@ discard block |
||
| 975 | 975 | |
| 976 | 976 | public static function js_redirect( $url ) { |
| 977 | 977 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 978 | - } |
|
| 978 | + } |
|
| 979 | 979 | |
| 980 | 980 | public static function get_user_id_param( $user_id ) { |
| 981 | 981 | if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
| 982 | - return $user_id; |
|
| 983 | - } |
|
| 982 | + return $user_id; |
|
| 983 | + } |
|
| 984 | 984 | |
| 985 | 985 | $user_id = sanitize_text_field( $user_id ); |
| 986 | 986 | if ( $user_id == 'current' ) { |
@@ -992,14 +992,14 @@ discard block |
||
| 992 | 992 | $user = get_user_by( 'login', $user_id ); |
| 993 | 993 | } |
| 994 | 994 | |
| 995 | - if ( $user ) { |
|
| 996 | - $user_id = $user->ID; |
|
| 997 | - } |
|
| 995 | + if ( $user ) { |
|
| 996 | + $user_id = $user->ID; |
|
| 997 | + } |
|
| 998 | 998 | unset( $user ); |
| 999 | - } |
|
| 999 | + } |
|
| 1000 | 1000 | |
| 1001 | - return $user_id; |
|
| 1002 | - } |
|
| 1001 | + return $user_id; |
|
| 1002 | + } |
|
| 1003 | 1003 | |
| 1004 | 1004 | public static function get_file_contents( $filename, $atts = array() ) { |
| 1005 | 1005 | if ( ! is_file( $filename ) ) { |
@@ -1014,28 +1014,28 @@ discard block |
||
| 1014 | 1014 | return $contents; |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | - /** |
|
| 1018 | - * @param string $table_name |
|
| 1019 | - * @param string $column |
|
| 1017 | + /** |
|
| 1018 | + * @param string $table_name |
|
| 1019 | + * @param string $column |
|
| 1020 | 1020 | * @param int $id |
| 1021 | 1021 | * @param int $num_chars |
| 1022 | - */ |
|
| 1023 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 1024 | - $key = ''; |
|
| 1022 | + */ |
|
| 1023 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 1024 | + $key = ''; |
|
| 1025 | 1025 | |
| 1026 | - if ( ! empty( $name ) ) { |
|
| 1026 | + if ( ! empty( $name ) ) { |
|
| 1027 | 1027 | $key = sanitize_key( $name ); |
| 1028 | - } |
|
| 1028 | + } |
|
| 1029 | 1029 | |
| 1030 | 1030 | if ( empty( $key ) ) { |
| 1031 | 1031 | $max_slug_value = pow( 36, $num_chars ); |
| 1032 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 1032 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 1033 | 1033 | $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
| 1034 | - } |
|
| 1034 | + } |
|
| 1035 | 1035 | |
| 1036 | 1036 | if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 1037 | 1037 | $key = $key . 'a'; |
| 1038 | - } |
|
| 1038 | + } |
|
| 1039 | 1039 | |
| 1040 | 1040 | $key_check = FrmDb::get_var( |
| 1041 | 1041 | $table_name, |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | ); |
| 1048 | 1048 | |
| 1049 | 1049 | if ( $key_check || is_numeric( $key_check ) ) { |
| 1050 | - $suffix = 2; |
|
| 1050 | + $suffix = 2; |
|
| 1051 | 1051 | do { |
| 1052 | 1052 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 1053 | 1053 | $key_check = FrmDb::get_var( |
@@ -1061,20 +1061,20 @@ discard block |
||
| 1061 | 1061 | $suffix++; |
| 1062 | 1062 | } while ( $key_check || is_numeric( $key_check ) ); |
| 1063 | 1063 | $key = $alt_post_name; |
| 1064 | - } |
|
| 1065 | - return $key; |
|
| 1066 | - } |
|
| 1064 | + } |
|
| 1065 | + return $key; |
|
| 1066 | + } |
|
| 1067 | 1067 | |
| 1068 | - /** |
|
| 1069 | - * Editing a Form or Entry |
|
| 1068 | + /** |
|
| 1069 | + * Editing a Form or Entry |
|
| 1070 | 1070 | * |
| 1071 | - * @param string $table |
|
| 1072 | - * @return bool|array |
|
| 1073 | - */ |
|
| 1074 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1075 | - if ( ! $record ) { |
|
| 1076 | - return false; |
|
| 1077 | - } |
|
| 1071 | + * @param string $table |
|
| 1072 | + * @return bool|array |
|
| 1073 | + */ |
|
| 1074 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1075 | + if ( ! $record ) { |
|
| 1076 | + return false; |
|
| 1077 | + } |
|
| 1078 | 1078 | |
| 1079 | 1079 | if ( empty( $post_values ) ) { |
| 1080 | 1080 | $post_values = stripslashes_deep( $_POST ); |
@@ -1097,14 +1097,14 @@ discard block |
||
| 1097 | 1097 | |
| 1098 | 1098 | self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) ); |
| 1099 | 1099 | |
| 1100 | - if ( $table == 'entries' ) { |
|
| 1101 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1102 | - } else if ( $table == 'forms' ) { |
|
| 1103 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1104 | - } |
|
| 1100 | + if ( $table == 'entries' ) { |
|
| 1101 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1102 | + } else if ( $table == 'forms' ) { |
|
| 1103 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1104 | + } |
|
| 1105 | 1105 | |
| 1106 | - return $values; |
|
| 1107 | - } |
|
| 1106 | + return $values; |
|
| 1107 | + } |
|
| 1108 | 1108 | |
| 1109 | 1109 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 1110 | 1110 | if ( ! empty( $fields ) ) { |
@@ -1117,15 +1117,15 @@ discard block |
||
| 1117 | 1117 | } |
| 1118 | 1118 | |
| 1119 | 1119 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1120 | - $post_values = $args['post_values']; |
|
| 1120 | + $post_values = $args['post_values']; |
|
| 1121 | 1121 | |
| 1122 | - if ( $args['default'] ) { |
|
| 1123 | - $meta_value = $field->default_value; |
|
| 1124 | - } else { |
|
| 1122 | + if ( $args['default'] ) { |
|
| 1123 | + $meta_value = $field->default_value; |
|
| 1124 | + } else { |
|
| 1125 | 1125 | if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
| 1126 | 1126 | if ( ! isset( $field->field_options['custom_field'] ) ) { |
| 1127 | - $field->field_options['custom_field'] = ''; |
|
| 1128 | - } |
|
| 1127 | + $field->field_options['custom_field'] = ''; |
|
| 1128 | + } |
|
| 1129 | 1129 | $meta_value = FrmProEntryMetaHelper::get_post_value( |
| 1130 | 1130 | $record->post_id, |
| 1131 | 1131 | $field->field_options['post_field'], |
@@ -1137,31 +1137,31 @@ discard block |
||
| 1137 | 1137 | 'field' => $field, |
| 1138 | 1138 | ) |
| 1139 | 1139 | ); |
| 1140 | - } else { |
|
| 1140 | + } else { |
|
| 1141 | 1141 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1142 | - } |
|
| 1143 | - } |
|
| 1142 | + } |
|
| 1143 | + } |
|
| 1144 | 1144 | |
| 1145 | 1145 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1146 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1146 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1147 | 1147 | |
| 1148 | 1148 | $field_array = self::start_field_array( $field ); |
| 1149 | 1149 | $field_array['value'] = $new_value; |
| 1150 | 1150 | $field_array['type'] = apply_filters( 'frm_field_type', $field_type, $field, $new_value ); |
| 1151 | 1151 | $field_array['parent_form_id'] = $args['parent_form_id']; |
| 1152 | 1152 | |
| 1153 | - $args['field_type'] = $field_type; |
|
| 1153 | + $args['field_type'] = $field_type; |
|
| 1154 | 1154 | |
| 1155 | 1155 | FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args ); |
| 1156 | 1156 | |
| 1157 | 1157 | if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
| 1158 | - $field_array['unique_msg'] = ''; |
|
| 1159 | - } |
|
| 1158 | + $field_array['unique_msg'] = ''; |
|
| 1159 | + } |
|
| 1160 | 1160 | |
| 1161 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1161 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1162 | 1162 | |
| 1163 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1164 | - } |
|
| 1163 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1164 | + } |
|
| 1165 | 1165 | |
| 1166 | 1166 | /** |
| 1167 | 1167 | * @since 3.0 |
@@ -1182,20 +1182,20 @@ discard block |
||
| 1182 | 1182 | ); |
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | - /** |
|
| 1186 | - * @param string $table |
|
| 1187 | - */ |
|
| 1185 | + /** |
|
| 1186 | + * @param string $table |
|
| 1187 | + */ |
|
| 1188 | 1188 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1189 | - if ( $table == 'entries' ) { |
|
| 1190 | - $form = $record->form_id; |
|
| 1189 | + if ( $table == 'entries' ) { |
|
| 1190 | + $form = $record->form_id; |
|
| 1191 | 1191 | FrmForm::maybe_get_form( $form ); |
| 1192 | - } else { |
|
| 1193 | - $form = $record; |
|
| 1194 | - } |
|
| 1192 | + } else { |
|
| 1193 | + $form = $record; |
|
| 1194 | + } |
|
| 1195 | 1195 | |
| 1196 | - if ( ! $form ) { |
|
| 1197 | - return; |
|
| 1198 | - } |
|
| 1196 | + if ( ! $form ) { |
|
| 1197 | + return; |
|
| 1198 | + } |
|
| 1199 | 1199 | |
| 1200 | 1200 | $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
| 1201 | 1201 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
@@ -1204,26 +1204,26 @@ discard block |
||
| 1204 | 1204 | return; |
| 1205 | 1205 | } |
| 1206 | 1206 | |
| 1207 | - foreach ( $form->options as $opt => $value ) { |
|
| 1208 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1209 | - } |
|
| 1207 | + foreach ( $form->options as $opt => $value ) { |
|
| 1208 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1209 | + } |
|
| 1210 | 1210 | |
| 1211 | 1211 | self::fill_form_defaults( $post_values, $values ); |
| 1212 | - } |
|
| 1212 | + } |
|
| 1213 | 1213 | |
| 1214 | - /** |
|
| 1215 | - * Set to POST value or default |
|
| 1216 | - */ |
|
| 1214 | + /** |
|
| 1215 | + * Set to POST value or default |
|
| 1216 | + */ |
|
| 1217 | 1217 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1218 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1218 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1219 | 1219 | |
| 1220 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1221 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1220 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1221 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1222 | 1222 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1223 | - } |
|
| 1223 | + } |
|
| 1224 | 1224 | |
| 1225 | 1225 | unset( $opt, $default ); |
| 1226 | - } |
|
| 1226 | + } |
|
| 1227 | 1227 | |
| 1228 | 1228 | if ( ! isset( $values['custom_style'] ) ) { |
| 1229 | 1229 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1232,10 +1232,10 @@ discard block |
||
| 1232 | 1232 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1233 | 1233 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1234 | 1234 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1235 | - } |
|
| 1235 | + } |
|
| 1236 | 1236 | unset( $h ); |
| 1237 | - } |
|
| 1238 | - } |
|
| 1237 | + } |
|
| 1238 | + } |
|
| 1239 | 1239 | |
| 1240 | 1240 | /** |
| 1241 | 1241 | * @since 2.2.10 |
@@ -1258,33 +1258,33 @@ discard block |
||
| 1258 | 1258 | if ( $possible_email_field ) { |
| 1259 | 1259 | $class .= 'show_frm_not_email_to'; |
| 1260 | 1260 | } |
| 1261 | - ?> |
|
| 1261 | + ?> |
|
| 1262 | 1262 | <li> |
| 1263 | 1263 | <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> |
| 1264 | 1264 | <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> |
| 1265 | 1265 | <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> |
| 1266 | 1266 | </li> |
| 1267 | 1267 | <?php |
| 1268 | - } |
|
| 1268 | + } |
|
| 1269 | 1269 | |
| 1270 | 1270 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1271 | - if ( is_array( $str ) ) { |
|
| 1272 | - return ''; |
|
| 1271 | + if ( is_array( $str ) ) { |
|
| 1272 | + return ''; |
|
| 1273 | 1273 | } |
| 1274 | 1274 | |
| 1275 | - $length = (int) $length; |
|
| 1275 | + $length = (int) $length; |
|
| 1276 | 1276 | $str = wp_strip_all_tags( $str ); |
| 1277 | 1277 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1278 | 1278 | |
| 1279 | 1279 | if ( $length == 0 ) { |
| 1280 | - return ''; |
|
| 1281 | - } else if ( $length <= 10 ) { |
|
| 1280 | + return ''; |
|
| 1281 | + } else if ( $length <= 10 ) { |
|
| 1282 | 1282 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1283 | 1283 | return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
| 1284 | - } |
|
| 1284 | + } |
|
| 1285 | 1285 | |
| 1286 | - $sub = ''; |
|
| 1287 | - $len = 0; |
|
| 1286 | + $sub = ''; |
|
| 1287 | + $len = 0; |
|
| 1288 | 1288 | |
| 1289 | 1289 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1290 | 1290 | |
@@ -1292,21 +1292,21 @@ discard block |
||
| 1292 | 1292 | $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
| 1293 | 1293 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1294 | 1294 | if ( $total_len > $length && substr_count( $sub, ' ' ) ) { |
| 1295 | - break; |
|
| 1296 | - } |
|
| 1295 | + break; |
|
| 1296 | + } |
|
| 1297 | 1297 | |
| 1298 | - $sub .= $part; |
|
| 1298 | + $sub .= $part; |
|
| 1299 | 1299 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1300 | 1300 | |
| 1301 | 1301 | if ( substr_count( $sub, ' ' ) > $minword && $total_len >= $length ) { |
| 1302 | - break; |
|
| 1303 | - } |
|
| 1302 | + break; |
|
| 1303 | + } |
|
| 1304 | 1304 | |
| 1305 | 1305 | unset( $total_len, $word ); |
| 1306 | - } |
|
| 1306 | + } |
|
| 1307 | 1307 | |
| 1308 | 1308 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
| 1309 | - } |
|
| 1309 | + } |
|
| 1310 | 1310 | |
| 1311 | 1311 | public static function mb_function( $function_names, $args ) { |
| 1312 | 1312 | $mb_function_name = $function_names[0]; |
@@ -1319,17 +1319,17 @@ discard block |
||
| 1319 | 1319 | |
| 1320 | 1320 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1321 | 1321 | if ( empty( $date ) ) { |
| 1322 | - return $date; |
|
| 1323 | - } |
|
| 1322 | + return $date; |
|
| 1323 | + } |
|
| 1324 | 1324 | |
| 1325 | 1325 | if ( empty( $date_format ) ) { |
| 1326 | 1326 | $date_format = get_option( 'date_format' ); |
| 1327 | 1327 | } |
| 1328 | 1328 | |
| 1329 | 1329 | if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
| 1330 | - $frmpro_settings = new FrmProSettings(); |
|
| 1330 | + $frmpro_settings = new FrmProSettings(); |
|
| 1331 | 1331 | $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
| 1332 | - } |
|
| 1332 | + } |
|
| 1333 | 1333 | |
| 1334 | 1334 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1335 | 1335 | |
@@ -1338,8 +1338,8 @@ discard block |
||
| 1338 | 1338 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | - return $formatted; |
|
| 1342 | - } |
|
| 1341 | + return $formatted; |
|
| 1342 | + } |
|
| 1343 | 1343 | |
| 1344 | 1344 | private static function add_time_to_date( $time_format, $date ) { |
| 1345 | 1345 | if ( empty( $time_format ) ) { |
@@ -1421,32 +1421,32 @@ discard block |
||
| 1421 | 1421 | ); |
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | - // Pagination Methods |
|
| 1424 | + // Pagination Methods |
|
| 1425 | 1425 | |
| 1426 | - /** |
|
| 1427 | - * @param integer $current_p |
|
| 1428 | - */ |
|
| 1426 | + /** |
|
| 1427 | + * @param integer $current_p |
|
| 1428 | + */ |
|
| 1429 | 1429 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1430 | 1430 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | - /** |
|
| 1434 | - * @param integer $current_p |
|
| 1435 | - */ |
|
| 1436 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1437 | - if ( $current_p == 1 ) { |
|
| 1438 | - return 1; |
|
| 1439 | - } else { |
|
| 1440 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1441 | - } |
|
| 1442 | - } |
|
| 1433 | + /** |
|
| 1434 | + * @param integer $current_p |
|
| 1435 | + */ |
|
| 1436 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1437 | + if ( $current_p == 1 ) { |
|
| 1438 | + return 1; |
|
| 1439 | + } else { |
|
| 1440 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1441 | + } |
|
| 1442 | + } |
|
| 1443 | 1443 | |
| 1444 | 1444 | /** |
| 1445 | 1445 | * @return array |
| 1446 | 1446 | */ |
| 1447 | 1447 | public static function json_to_array( $json_vars ) { |
| 1448 | - $vars = array(); |
|
| 1449 | - foreach ( $json_vars as $jv ) { |
|
| 1448 | + $vars = array(); |
|
| 1449 | + foreach ( $json_vars as $jv ) { |
|
| 1450 | 1450 | $jv_name = explode( '[', $jv['name'] ); |
| 1451 | 1451 | $last = count( $jv_name ) - 1; |
| 1452 | 1452 | foreach ( $jv_name as $p => $n ) { |
@@ -1463,77 +1463,77 @@ discard block |
||
| 1463 | 1463 | $l3 = $name; |
| 1464 | 1464 | } |
| 1465 | 1465 | |
| 1466 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1466 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1467 | 1467 | |
| 1468 | - switch ( $p ) { |
|
| 1469 | - case 0: |
|
| 1470 | - $l1 = $name; |
|
| 1471 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1468 | + switch ( $p ) { |
|
| 1469 | + case 0: |
|
| 1470 | + $l1 = $name; |
|
| 1471 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1472 | 1472 | break; |
| 1473 | 1473 | |
| 1474 | - case 1: |
|
| 1475 | - $l2 = $name; |
|
| 1476 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1474 | + case 1: |
|
| 1475 | + $l2 = $name; |
|
| 1476 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1477 | 1477 | break; |
| 1478 | 1478 | |
| 1479 | - case 2: |
|
| 1480 | - $l3 = $name; |
|
| 1481 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1479 | + case 2: |
|
| 1480 | + $l3 = $name; |
|
| 1481 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1482 | 1482 | break; |
| 1483 | 1483 | |
| 1484 | - case 3: |
|
| 1485 | - $l4 = $name; |
|
| 1486 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1487 | - } |
|
| 1484 | + case 3: |
|
| 1485 | + $l4 = $name; |
|
| 1486 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1487 | + } |
|
| 1488 | 1488 | |
| 1489 | 1489 | unset( $this_val, $n ); |
| 1490 | - } |
|
| 1490 | + } |
|
| 1491 | 1491 | |
| 1492 | 1492 | unset( $last, $jv ); |
| 1493 | - } |
|
| 1494 | - |
|
| 1495 | - return $vars; |
|
| 1496 | - } |
|
| 1497 | - |
|
| 1498 | - /** |
|
| 1499 | - * @param string $name |
|
| 1500 | - * @param string $l1 |
|
| 1501 | - */ |
|
| 1502 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1503 | - if ( $name == '' ) { |
|
| 1504 | - $vars[] = $val; |
|
| 1505 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1506 | - $vars[ $l1 ] = $val; |
|
| 1507 | - } |
|
| 1508 | - } |
|
| 1493 | + } |
|
| 1494 | + |
|
| 1495 | + return $vars; |
|
| 1496 | + } |
|
| 1497 | + |
|
| 1498 | + /** |
|
| 1499 | + * @param string $name |
|
| 1500 | + * @param string $l1 |
|
| 1501 | + */ |
|
| 1502 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1503 | + if ( $name == '' ) { |
|
| 1504 | + $vars[] = $val; |
|
| 1505 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1506 | + $vars[ $l1 ] = $val; |
|
| 1507 | + } |
|
| 1508 | + } |
|
| 1509 | 1509 | |
| 1510 | 1510 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1511 | - $tooltips = array( |
|
| 1512 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1513 | - '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' ), |
|
| 1514 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1515 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1516 | - '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' ), |
|
| 1517 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1518 | - '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() ) ), |
|
| 1519 | - ); |
|
| 1520 | - |
|
| 1521 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1522 | - return; |
|
| 1523 | - } |
|
| 1524 | - |
|
| 1525 | - if ( 'open' == $class ) { |
|
| 1526 | - echo ' frm_help"'; |
|
| 1527 | - } else { |
|
| 1528 | - echo ' class="frm_help"'; |
|
| 1529 | - } |
|
| 1511 | + $tooltips = array( |
|
| 1512 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1513 | + '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' ), |
|
| 1514 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1515 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1516 | + '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' ), |
|
| 1517 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1518 | + '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() ) ), |
|
| 1519 | + ); |
|
| 1520 | + |
|
| 1521 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1522 | + return; |
|
| 1523 | + } |
|
| 1524 | + |
|
| 1525 | + if ( 'open' == $class ) { |
|
| 1526 | + echo ' frm_help"'; |
|
| 1527 | + } else { |
|
| 1528 | + echo ' class="frm_help"'; |
|
| 1529 | + } |
|
| 1530 | 1530 | |
| 1531 | 1531 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1532 | 1532 | |
| 1533 | - if ( 'open' != $class ) { |
|
| 1534 | - echo '"'; |
|
| 1535 | - } |
|
| 1536 | - } |
|
| 1533 | + if ( 'open' != $class ) { |
|
| 1534 | + echo '"'; |
|
| 1535 | + } |
|
| 1536 | + } |
|
| 1537 | 1537 | |
| 1538 | 1538 | /** |
| 1539 | 1539 | * Add the current_page class to that page in the form nav |
@@ -1549,35 +1549,35 @@ discard block |
||
| 1549 | 1549 | } |
| 1550 | 1550 | } |
| 1551 | 1551 | |
| 1552 | - /** |
|
| 1553 | - * Prepare and json_encode post content |
|
| 1554 | - * |
|
| 1555 | - * @since 2.0 |
|
| 1556 | - * |
|
| 1557 | - * @param array $post_content |
|
| 1558 | - * @return string $post_content ( json encoded array ) |
|
| 1559 | - */ |
|
| 1560 | - public static function prepare_and_encode( $post_content ) { |
|
| 1561 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1552 | + /** |
|
| 1553 | + * Prepare and json_encode post content |
|
| 1554 | + * |
|
| 1555 | + * @since 2.0 |
|
| 1556 | + * |
|
| 1557 | + * @param array $post_content |
|
| 1558 | + * @return string $post_content ( json encoded array ) |
|
| 1559 | + */ |
|
| 1560 | + public static function prepare_and_encode( $post_content ) { |
|
| 1561 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1562 | 1562 | foreach ( $post_content as $key => $val ) { |
| 1563 | 1563 | // Replace problematic characters (like ") |
| 1564 | 1564 | $val = str_replace( '"', '"', $val ); |
| 1565 | 1565 | |
| 1566 | 1566 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1567 | - unset( $key, $val ); |
|
| 1568 | - } |
|
| 1567 | + unset( $key, $val ); |
|
| 1568 | + } |
|
| 1569 | 1569 | |
| 1570 | - // json_encode the array |
|
| 1571 | - $post_content = json_encode( $post_content ); |
|
| 1570 | + // json_encode the array |
|
| 1571 | + $post_content = json_encode( $post_content ); |
|
| 1572 | 1572 | |
| 1573 | - // add extra slashes for \r\n since WP strips them |
|
| 1573 | + // add extra slashes for \r\n since WP strips them |
|
| 1574 | 1574 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1575 | 1575 | |
| 1576 | - // allow for " |
|
| 1577 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1576 | + // allow for " |
|
| 1577 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1578 | 1578 | |
| 1579 | - return $post_content; |
|
| 1580 | - } |
|
| 1579 | + return $post_content; |
|
| 1580 | + } |
|
| 1581 | 1581 | |
| 1582 | 1582 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1583 | 1583 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1600,55 +1600,55 @@ discard block |
||
| 1600 | 1600 | |
| 1601 | 1601 | public static function maybe_json_decode( $string ) { |
| 1602 | 1602 | if ( is_array( $string ) ) { |
| 1603 | - return $string; |
|
| 1604 | - } |
|
| 1603 | + return $string; |
|
| 1604 | + } |
|
| 1605 | 1605 | |
| 1606 | 1606 | $new_string = json_decode( $string, true ); |
| 1607 | 1607 | if ( function_exists( 'json_last_error' ) ) { |
| 1608 | 1608 | // php 5.3+ |
| 1609 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1610 | - $string = $new_string; |
|
| 1611 | - } |
|
| 1609 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1610 | + $string = $new_string; |
|
| 1611 | + } |
|
| 1612 | 1612 | } elseif ( isset( $new_string ) ) { |
| 1613 | 1613 | // php < 5.3 fallback |
| 1614 | - $string = $new_string; |
|
| 1615 | - } |
|
| 1616 | - return $string; |
|
| 1617 | - } |
|
| 1618 | - |
|
| 1619 | - /** |
|
| 1620 | - * @since 1.07.10 |
|
| 1621 | - * |
|
| 1622 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1623 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1624 | - */ |
|
| 1614 | + $string = $new_string; |
|
| 1615 | + } |
|
| 1616 | + return $string; |
|
| 1617 | + } |
|
| 1618 | + |
|
| 1619 | + /** |
|
| 1620 | + * @since 1.07.10 |
|
| 1621 | + * |
|
| 1622 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1623 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1624 | + */ |
|
| 1625 | 1625 | public static function maybe_highlight_menu( $post_type ) { |
| 1626 | - global $post; |
|
| 1626 | + global $post; |
|
| 1627 | 1627 | |
| 1628 | 1628 | if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
| 1629 | - return; |
|
| 1630 | - } |
|
| 1629 | + return; |
|
| 1630 | + } |
|
| 1631 | 1631 | |
| 1632 | 1632 | if ( is_object( $post ) && $post->post_type != $post_type ) { |
| 1633 | - return; |
|
| 1634 | - } |
|
| 1633 | + return; |
|
| 1634 | + } |
|
| 1635 | 1635 | |
| 1636 | - self::load_admin_wide_js(); |
|
| 1637 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1638 | - } |
|
| 1636 | + self::load_admin_wide_js(); |
|
| 1637 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1638 | + } |
|
| 1639 | 1639 | |
| 1640 | - /** |
|
| 1641 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1640 | + /** |
|
| 1641 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1642 | 1642 | * |
| 1643 | - * @since 2.0 |
|
| 1644 | - */ |
|
| 1643 | + * @since 2.0 |
|
| 1644 | + */ |
|
| 1645 | 1645 | public static function load_admin_wide_js( $load = true ) { |
| 1646 | 1646 | $version = self::plugin_version(); |
| 1647 | 1647 | wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1648 | 1648 | |
| 1649 | 1649 | $global_strings = array( |
| 1650 | 1650 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1651 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1651 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1652 | 1652 | 'url' => self::plugin_url(), |
| 1653 | 1653 | 'loading' => __( 'Loading…' ), |
| 1654 | 1654 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
@@ -1658,7 +1658,7 @@ discard block |
||
| 1658 | 1658 | if ( $load ) { |
| 1659 | 1659 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1660 | 1660 | } |
| 1661 | - } |
|
| 1661 | + } |
|
| 1662 | 1662 | |
| 1663 | 1663 | /** |
| 1664 | 1664 | * @since 2.0.9 |
@@ -1667,9 +1667,9 @@ discard block |
||
| 1667 | 1667 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1668 | 1668 | } |
| 1669 | 1669 | |
| 1670 | - /** |
|
| 1671 | - * @param string $location |
|
| 1672 | - */ |
|
| 1670 | + /** |
|
| 1671 | + * @param string $location |
|
| 1672 | + */ |
|
| 1673 | 1673 | public static function localize_script( $location ) { |
| 1674 | 1674 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1675 | 1675 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1735,28 +1735,28 @@ discard block |
||
| 1735 | 1735 | } |
| 1736 | 1736 | } |
| 1737 | 1737 | |
| 1738 | - /** |
|
| 1738 | + /** |
|
| 1739 | 1739 | * Echo the message on the plugins listing page |
| 1740 | 1740 | * |
| 1741 | - * @since 1.07.10 |
|
| 1742 | - * |
|
| 1743 | - * @param float $min_version The version the add-on requires |
|
| 1744 | - */ |
|
| 1741 | + * @since 1.07.10 |
|
| 1742 | + * |
|
| 1743 | + * @param float $min_version The version the add-on requires |
|
| 1744 | + */ |
|
| 1745 | 1745 | public static function min_version_notice( $min_version ) { |
| 1746 | - $frm_version = self::plugin_version(); |
|
| 1746 | + $frm_version = self::plugin_version(); |
|
| 1747 | 1747 | |
| 1748 | - // check if Formidable meets minimum requirements |
|
| 1748 | + // check if Formidable meets minimum requirements |
|
| 1749 | 1749 | if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
| 1750 | - return; |
|
| 1751 | - } |
|
| 1750 | + return; |
|
| 1751 | + } |
|
| 1752 | 1752 | |
| 1753 | 1753 | $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
| 1754 | 1754 | 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">' . |
| 1755 | - esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1756 | - '</div></td></tr>'; |
|
| 1757 | - } |
|
| 1755 | + esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1756 | + '</div></td></tr>'; |
|
| 1757 | + } |
|
| 1758 | 1758 | |
| 1759 | - public static function locales( $type = 'date' ) { |
|
| 1759 | + public static function locales( $type = 'date' ) { |
|
| 1760 | 1760 | $locales = array( |
| 1761 | 1761 | 'en' => __( 'English', 'formidable' ), |
| 1762 | 1762 | '' => __( 'English/Western', 'formidable' ), |
@@ -1835,8 +1835,8 @@ discard block |
||
| 1835 | 1835 | $locales = array_diff_key( $locales, array_flip( $unset ) ); |
| 1836 | 1836 | $locales = apply_filters( 'frm_locales', $locales ); |
| 1837 | 1837 | |
| 1838 | - return $locales; |
|
| 1839 | - } |
|
| 1838 | + return $locales; |
|
| 1839 | + } |
|
| 1840 | 1840 | |
| 1841 | 1841 | /** |
| 1842 | 1842 | * Used to filter shortcode in text widgets |