@@ -13,15 +13,15 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public static $plug_version = '3.04.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 | } |
@@ -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 ) ) { |
@@ -136,50 +136,50 @@ discard block |
||
| 136 | 136 | return $is_formidable; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * Check for certain page in Formidable settings |
|
| 141 | - * |
|
| 142 | - * @since 2.0 |
|
| 143 | - * |
|
| 144 | - * @param string $page The name of the page to check |
|
| 145 | - * @return boolean |
|
| 146 | - */ |
|
| 139 | + /** |
|
| 140 | + * Check for certain page in Formidable settings |
|
| 141 | + * |
|
| 142 | + * @since 2.0 |
|
| 143 | + * |
|
| 144 | + * @param string $page The name of the page to check |
|
| 145 | + * @return boolean |
|
| 146 | + */ |
|
| 147 | 147 | public static function is_admin_page( $page = 'formidable' ) { |
| 148 | - global $pagenow; |
|
| 148 | + global $pagenow; |
|
| 149 | 149 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 150 | - if ( $pagenow ) { |
|
| 150 | + if ( $pagenow ) { |
|
| 151 | 151 | // allow this to be true during ajax load i.e. ajax form builder loading |
| 152 | 152 | return ( $pagenow == 'admin.php' || $pagenow == 'admin-ajax.php' ) && $get_page == $page; |
| 153 | - } |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | 155 | return is_admin() && $get_page == $page; |
| 156 | - } |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * Check for the form preview page |
|
| 160 | - * |
|
| 161 | - * @since 2.0 |
|
| 162 | - * |
|
| 163 | - * @param None |
|
| 164 | - * @return boolean |
|
| 165 | - */ |
|
| 166 | - public static function is_preview_page() { |
|
| 167 | - global $pagenow; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * Check for the form preview page |
|
| 160 | + * |
|
| 161 | + * @since 2.0 |
|
| 162 | + * |
|
| 163 | + * @param None |
|
| 164 | + * @return boolean |
|
| 165 | + */ |
|
| 166 | + public static function is_preview_page() { |
|
| 167 | + global $pagenow; |
|
| 168 | 168 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
| 169 | 169 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 170 | - } |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * Check for ajax except the form preview page |
|
| 174 | - * |
|
| 175 | - * @since 2.0 |
|
| 176 | - * |
|
| 177 | - * @param None |
|
| 178 | - * @return boolean |
|
| 179 | - */ |
|
| 180 | - public static function doing_ajax() { |
|
| 181 | - return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 182 | - } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * Check for ajax except the form preview page |
|
| 174 | + * |
|
| 175 | + * @since 2.0 |
|
| 176 | + * |
|
| 177 | + * @param None |
|
| 178 | + * @return boolean |
|
| 179 | + */ |
|
| 180 | + public static function doing_ajax() { |
|
| 181 | + return self::wp_doing_ajax() && ! self::is_preview_page(); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | 184 | public static function js_suffix() { |
| 185 | 185 | return defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
@@ -206,81 +206,81 @@ discard block |
||
| 206 | 206 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - /** |
|
| 210 | - * Check if on an admin page |
|
| 211 | - * |
|
| 212 | - * @since 2.0 |
|
| 213 | - * |
|
| 214 | - * @param None |
|
| 215 | - * @return boolean |
|
| 216 | - */ |
|
| 217 | - public static function is_admin() { |
|
| 218 | - return is_admin() && ! self::wp_doing_ajax(); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * Check if value contains blank value or empty array |
|
| 223 | - * |
|
| 224 | - * @since 2.0 |
|
| 225 | - * @param mixed $value - value to check |
|
| 209 | + /** |
|
| 210 | + * Check if on an admin page |
|
| 211 | + * |
|
| 212 | + * @since 2.0 |
|
| 213 | + * |
|
| 214 | + * @param None |
|
| 215 | + * @return boolean |
|
| 216 | + */ |
|
| 217 | + public static function is_admin() { |
|
| 218 | + return is_admin() && ! self::wp_doing_ajax(); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * Check if value contains blank value or empty array |
|
| 223 | + * |
|
| 224 | + * @since 2.0 |
|
| 225 | + * @param mixed $value - value to check |
|
| 226 | 226 | * @param string |
| 227 | - * @return boolean |
|
| 228 | - */ |
|
| 229 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 230 | - return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 234 | - return ! self::is_empty_value( $value, $empty ); |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * Get any value from the $_SERVER |
|
| 239 | - * |
|
| 240 | - * @since 2.0 |
|
| 241 | - * @param string $value |
|
| 242 | - * @return string |
|
| 243 | - */ |
|
| 227 | + * @return boolean |
|
| 228 | + */ |
|
| 229 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 230 | + return ( is_array( $value ) && empty( $value ) ) || $value === $empty; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 234 | + return ! self::is_empty_value( $value, $empty ); |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * Get any value from the $_SERVER |
|
| 239 | + * |
|
| 240 | + * @since 2.0 |
|
| 241 | + * @param string $value |
|
| 242 | + * @return string |
|
| 243 | + */ |
|
| 244 | 244 | public static function get_server_value( $value ) { |
| 245 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * Check for the IP address in several places |
|
| 250 | - * Used by [ip] shortcode |
|
| 251 | - * |
|
| 252 | - * @return string The IP address of the current user |
|
| 253 | - */ |
|
| 254 | - public static function get_ip_address() { |
|
| 245 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * Check for the IP address in several places |
|
| 250 | + * Used by [ip] shortcode |
|
| 251 | + * |
|
| 252 | + * @return string The IP address of the current user |
|
| 253 | + */ |
|
| 254 | + public static function get_ip_address() { |
|
| 255 | 255 | $ip = ''; |
| 256 | 256 | 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 ) { |
| 257 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 258 | - continue; |
|
| 259 | - } |
|
| 257 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 258 | + continue; |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 261 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 262 | 262 | $ip = trim( $ip ); // just to be safe |
| 263 | 263 | |
| 264 | 264 | if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
| 265 | - return sanitize_text_field( $ip ); |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - } |
|
| 265 | + return sanitize_text_field( $ip ); |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | 270 | return sanitize_text_field( $ip ); |
| 271 | - } |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 273 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 274 | 274 | if ( strpos( $param, '[' ) ) { |
| 275 | 275 | $params = explode( '[', $param ); |
| 276 | - $param = $params[0]; |
|
| 277 | - } |
|
| 276 | + $param = $params[0]; |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | 279 | if ( $src == 'get' ) { |
| 280 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 281 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 282 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 283 | - } |
|
| 280 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 281 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 282 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 283 | + } |
|
| 284 | 284 | self::sanitize_value( $sanitize, $value ); |
| 285 | 285 | } else { |
| 286 | 286 | $value = self::get_simple_request( |
@@ -304,8 +304,8 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - return $value; |
|
| 308 | - } |
|
| 307 | + return $value; |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | 310 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
| 311 | 311 | return self::get_simple_request( |
@@ -373,12 +373,12 @@ discard block |
||
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
| 376 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 377 | - * |
|
| 378 | - * @since 2.0.8 |
|
| 379 | - * @param string $value |
|
| 380 | - * @return string $value |
|
| 381 | - */ |
|
| 376 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 377 | + * |
|
| 378 | + * @since 2.0.8 |
|
| 379 | + * @param string $value |
|
| 380 | + * @return string $value |
|
| 381 | + */ |
|
| 382 | 382 | public static function preserve_backslashes( $value ) { |
| 383 | 383 | // If backslashes have already been added, don't add them again |
| 384 | 384 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -400,14 +400,14 @@ discard block |
||
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 404 | - $temp_values = $values; |
|
| 405 | - foreach ( $temp_values as $k => $val ) { |
|
| 406 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 403 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 404 | + $temp_values = $values; |
|
| 405 | + foreach ( $temp_values as $k => $val ) { |
|
| 406 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 407 | 407 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 408 | - } |
|
| 409 | - } |
|
| 410 | - } |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + } |
|
| 411 | 411 | |
| 412 | 412 | /** |
| 413 | 413 | * Sanitize the value, and allow some HTML |
@@ -524,39 +524,39 @@ discard block |
||
| 524 | 524 | ); |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | - /** |
|
| 528 | - * Used when switching the action for a bulk action |
|
| 529 | - * @since 2.0 |
|
| 530 | - */ |
|
| 527 | + /** |
|
| 528 | + * Used when switching the action for a bulk action |
|
| 529 | + * @since 2.0 |
|
| 530 | + */ |
|
| 531 | 531 | public static function remove_get_action() { |
| 532 | 532 | if ( ! isset( $_GET ) ) { |
| 533 | 533 | return; |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 537 | - if ( ! empty( $new_action ) ) { |
|
| 536 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 537 | + if ( ! empty( $new_action ) ) { |
|
| 538 | 538 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 539 | - } |
|
| 540 | - } |
|
| 539 | + } |
|
| 540 | + } |
|
| 541 | 541 | |
| 542 | - /** |
|
| 543 | - * Check the WP query for a parameter |
|
| 544 | - * |
|
| 545 | - * @since 2.0 |
|
| 546 | - * @return string|array |
|
| 547 | - */ |
|
| 548 | - public static function get_query_var( $value, $param ) { |
|
| 549 | - if ( $value != '' ) { |
|
| 550 | - return $value; |
|
| 551 | - } |
|
| 542 | + /** |
|
| 543 | + * Check the WP query for a parameter |
|
| 544 | + * |
|
| 545 | + * @since 2.0 |
|
| 546 | + * @return string|array |
|
| 547 | + */ |
|
| 548 | + public static function get_query_var( $value, $param ) { |
|
| 549 | + if ( $value != '' ) { |
|
| 550 | + return $value; |
|
| 551 | + } |
|
| 552 | 552 | |
| 553 | - global $wp_query; |
|
| 554 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 555 | - $value = $wp_query->query_vars[ $param ]; |
|
| 556 | - } |
|
| 553 | + global $wp_query; |
|
| 554 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 555 | + $value = $wp_query->query_vars[ $param ]; |
|
| 556 | + } |
|
| 557 | 557 | |
| 558 | - return $value; |
|
| 559 | - } |
|
| 558 | + return $value; |
|
| 559 | + } |
|
| 560 | 560 | |
| 561 | 561 | /** |
| 562 | 562 | * @since 3.0 |
@@ -578,16 +578,16 @@ discard block |
||
| 578 | 578 | } |
| 579 | 579 | } |
| 580 | 580 | |
| 581 | - /** |
|
| 582 | - * @param string $type |
|
| 583 | - */ |
|
| 584 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 585 | - // only load the form hooks once |
|
| 581 | + /** |
|
| 582 | + * @param string $type |
|
| 583 | + */ |
|
| 584 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 585 | + // only load the form hooks once |
|
| 586 | 586 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 587 | - if ( ! $hooks_loaded ) { |
|
| 587 | + if ( ! $hooks_loaded ) { |
|
| 588 | 588 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 589 | - } |
|
| 590 | - } |
|
| 589 | + } |
|
| 590 | + } |
|
| 591 | 591 | |
| 592 | 592 | /** |
| 593 | 593 | * Save all front-end js scripts into a single file |
@@ -612,18 +612,18 @@ discard block |
||
| 612 | 612 | $new_file->combine_files( $files ); |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - /** |
|
| 616 | - * Check a value from a shortcode to see if true or false. |
|
| 617 | - * True when value is 1, true, 'true', 'yes' |
|
| 618 | - * |
|
| 619 | - * @since 1.07.10 |
|
| 620 | - * |
|
| 621 | - * @param string $value The value to compare |
|
| 622 | - * @return boolean True or False |
|
| 623 | - */ |
|
| 615 | + /** |
|
| 616 | + * Check a value from a shortcode to see if true or false. |
|
| 617 | + * True when value is 1, true, 'true', 'yes' |
|
| 618 | + * |
|
| 619 | + * @since 1.07.10 |
|
| 620 | + * |
|
| 621 | + * @param string $value The value to compare |
|
| 622 | + * @return boolean True or False |
|
| 623 | + */ |
|
| 624 | 624 | public static function is_true( $value ) { |
| 625 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 626 | - } |
|
| 625 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 626 | + } |
|
| 627 | 627 | |
| 628 | 628 | public static function get_pages() { |
| 629 | 629 | $query = array( |
@@ -636,10 +636,10 @@ discard block |
||
| 636 | 636 | return get_posts( $query ); |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 640 | - $pages = self::get_pages(); |
|
| 639 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 640 | + $pages = self::get_pages(); |
|
| 641 | 641 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 642 | - ?> |
|
| 642 | + ?> |
|
| 643 | 643 | <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
| 644 | 644 | <option value=""> </option> |
| 645 | 645 | <?php foreach ( $pages as $page ) { ?> |
@@ -649,16 +649,16 @@ discard block |
||
| 649 | 649 | <?php } ?> |
| 650 | 650 | </select> |
| 651 | 651 | <?php |
| 652 | - } |
|
| 652 | + } |
|
| 653 | 653 | |
| 654 | 654 | public static function post_edit_link( $post_id ) { |
| 655 | 655 | $post = get_post( $post_id ); |
| 656 | - if ( $post ) { |
|
| 656 | + if ( $post ) { |
|
| 657 | 657 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 658 | 658 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 659 | - } |
|
| 660 | - return ''; |
|
| 661 | - } |
|
| 659 | + } |
|
| 660 | + return ''; |
|
| 661 | + } |
|
| 662 | 662 | |
| 663 | 663 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 664 | 664 | ?> |
@@ -669,73 +669,73 @@ discard block |
||
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | public static function roles_options( $capability ) { |
| 672 | - global $frm_vars; |
|
| 672 | + global $frm_vars; |
|
| 673 | 673 | if ( isset( $frm_vars['editable_roles'] ) ) { |
| 674 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 675 | - } else { |
|
| 676 | - $editable_roles = get_editable_roles(); |
|
| 677 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 678 | - } |
|
| 674 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 675 | + } else { |
|
| 676 | + $editable_roles = get_editable_roles(); |
|
| 677 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 678 | + } |
|
| 679 | 679 | |
| 680 | - foreach ( $editable_roles as $role => $details ) { |
|
| 680 | + foreach ( $editable_roles as $role => $details ) { |
|
| 681 | 681 | $name = translate_user_role( $details['name'] ); |
| 682 | 682 | ?> |
| 683 | 683 | <option value="<?php echo esc_attr( $role ); ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ); ?> </option> |
| 684 | 684 | <?php |
| 685 | 685 | unset( $role, $details ); |
| 686 | - } |
|
| 687 | - } |
|
| 686 | + } |
|
| 687 | + } |
|
| 688 | 688 | |
| 689 | 689 | public static function frm_capabilities( $type = 'auto' ) { |
| 690 | - $cap = array( |
|
| 691 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 692 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 693 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 694 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 695 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 696 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 697 | - ); |
|
| 690 | + $cap = array( |
|
| 691 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 692 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 693 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 694 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 695 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 696 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 697 | + ); |
|
| 698 | 698 | |
| 699 | 699 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 700 | - return $cap; |
|
| 701 | - } |
|
| 700 | + return $cap; |
|
| 701 | + } |
|
| 702 | 702 | |
| 703 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 704 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 705 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 706 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 703 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 704 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 705 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 706 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 707 | 707 | |
| 708 | - return $cap; |
|
| 709 | - } |
|
| 708 | + return $cap; |
|
| 709 | + } |
|
| 710 | 710 | |
| 711 | 711 | public static function user_has_permission( $needed_role ) { |
| 712 | - if ( $needed_role == '-1' ) { |
|
| 713 | - return false; |
|
| 712 | + if ( $needed_role == '-1' ) { |
|
| 713 | + return false; |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 717 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 718 | - return true; |
|
| 719 | - } |
|
| 716 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 717 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 718 | + return true; |
|
| 719 | + } |
|
| 720 | 720 | |
| 721 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 722 | - foreach ( $roles as $role ) { |
|
| 721 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 722 | + foreach ( $roles as $role ) { |
|
| 723 | 723 | if ( current_user_can( $role ) ) { |
| 724 | - return true; |
|
| 724 | + return true; |
|
| 725 | 725 | } |
| 726 | - if ( $role == $needed_role ) { |
|
| 727 | - break; |
|
| 726 | + if ( $role == $needed_role ) { |
|
| 727 | + break; |
|
| 728 | 728 | } |
| 729 | - } |
|
| 730 | - return false; |
|
| 731 | - } |
|
| 732 | - |
|
| 733 | - /** |
|
| 734 | - * Make sure administrators can see Formidable menu |
|
| 735 | - * |
|
| 736 | - * @since 2.0 |
|
| 737 | - */ |
|
| 738 | - public static function maybe_add_permissions() { |
|
| 729 | + } |
|
| 730 | + return false; |
|
| 731 | + } |
|
| 732 | + |
|
| 733 | + /** |
|
| 734 | + * Make sure administrators can see Formidable menu |
|
| 735 | + * |
|
| 736 | + * @since 2.0 |
|
| 737 | + */ |
|
| 738 | + public static function maybe_add_permissions() { |
|
| 739 | 739 | self::force_capability( 'frm_view_entries' ); |
| 740 | 740 | |
| 741 | 741 | if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
@@ -744,12 +744,12 @@ discard block |
||
| 744 | 744 | |
| 745 | 745 | $user_id = get_current_user_id(); |
| 746 | 746 | $user = new WP_User( $user_id ); |
| 747 | - $frm_roles = self::frm_capabilities(); |
|
| 748 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 747 | + $frm_roles = self::frm_capabilities(); |
|
| 748 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 749 | 749 | $user->add_cap( $frm_role ); |
| 750 | 750 | unset( $frm_role, $frm_role_description ); |
| 751 | - } |
|
| 752 | - } |
|
| 751 | + } |
|
| 752 | + } |
|
| 753 | 753 | |
| 754 | 754 | /** |
| 755 | 755 | * Make sure admins have permission to see the menu items |
@@ -765,28 +765,28 @@ discard block |
||
| 765 | 765 | } |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | - /** |
|
| 769 | - * Check if the user has permision for action. |
|
| 770 | - * Return permission message and stop the action if no permission |
|
| 771 | - * @since 2.0 |
|
| 772 | - * @param string $permission |
|
| 773 | - */ |
|
| 768 | + /** |
|
| 769 | + * Check if the user has permision for action. |
|
| 770 | + * Return permission message and stop the action if no permission |
|
| 771 | + * @since 2.0 |
|
| 772 | + * @param string $permission |
|
| 773 | + */ |
|
| 774 | 774 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 775 | 775 | $permission_error = self::permission_nonce_error( $permission ); |
| 776 | - if ( $permission_error !== false ) { |
|
| 777 | - if ( 'hide' == $show_message ) { |
|
| 778 | - $permission_error = ''; |
|
| 779 | - } |
|
| 776 | + if ( $permission_error !== false ) { |
|
| 777 | + if ( 'hide' == $show_message ) { |
|
| 778 | + $permission_error = ''; |
|
| 779 | + } |
|
| 780 | 780 | wp_die( esc_html( $permission_error ) ); |
| 781 | - } |
|
| 782 | - } |
|
| 783 | - |
|
| 784 | - /** |
|
| 785 | - * Check user permission and nonce |
|
| 786 | - * @since 2.0 |
|
| 787 | - * @param string $permission |
|
| 788 | - * @return false|string The permission message or false if allowed |
|
| 789 | - */ |
|
| 781 | + } |
|
| 782 | + } |
|
| 783 | + |
|
| 784 | + /** |
|
| 785 | + * Check user permission and nonce |
|
| 786 | + * @since 2.0 |
|
| 787 | + * @param string $permission |
|
| 788 | + * @return false|string The permission message or false if allowed |
|
| 789 | + */ |
|
| 790 | 790 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 791 | 791 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 792 | 792 | $frm_settings = self::get_settings(); |
@@ -795,22 +795,22 @@ discard block |
||
| 795 | 795 | |
| 796 | 796 | $error = false; |
| 797 | 797 | if ( empty( $nonce_name ) ) { |
| 798 | - return $error; |
|
| 799 | - } |
|
| 798 | + return $error; |
|
| 799 | + } |
|
| 800 | 800 | |
| 801 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 802 | - $frm_settings = self::get_settings(); |
|
| 803 | - $error = $frm_settings->admin_permission; |
|
| 804 | - } |
|
| 801 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 802 | + $frm_settings = self::get_settings(); |
|
| 803 | + $error = $frm_settings->admin_permission; |
|
| 804 | + } |
|
| 805 | 805 | |
| 806 | - return $error; |
|
| 807 | - } |
|
| 806 | + return $error; |
|
| 807 | + } |
|
| 808 | 808 | |
| 809 | - public static function checked( $values, $current ) { |
|
| 809 | + public static function checked( $values, $current ) { |
|
| 810 | 810 | if ( self::check_selected( $values, $current ) ) { |
| 811 | - echo ' checked="checked"'; |
|
| 811 | + echo ' checked="checked"'; |
|
| 812 | 812 | } |
| 813 | - } |
|
| 813 | + } |
|
| 814 | 814 | |
| 815 | 815 | public static function check_selected( $values, $current ) { |
| 816 | 816 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -848,24 +848,24 @@ discard block |
||
| 848 | 848 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 849 | 849 | } |
| 850 | 850 | |
| 851 | - /** |
|
| 852 | - * Flatten a multi-dimensional array |
|
| 853 | - */ |
|
| 851 | + /** |
|
| 852 | + * Flatten a multi-dimensional array |
|
| 853 | + */ |
|
| 854 | 854 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 855 | - $return = array(); |
|
| 856 | - foreach ( $array as $key => $value ) { |
|
| 855 | + $return = array(); |
|
| 856 | + foreach ( $array as $key => $value ) { |
|
| 857 | 857 | if ( is_array( $value ) ) { |
| 858 | 858 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 859 | - } else { |
|
| 859 | + } else { |
|
| 860 | 860 | if ( $keys == 'keep' ) { |
| 861 | 861 | $return[ $key ] = $value; |
| 862 | 862 | } else { |
| 863 | 863 | $return[] = $value; |
| 864 | 864 | } |
| 865 | - } |
|
| 866 | - } |
|
| 867 | - return $return; |
|
| 868 | - } |
|
| 865 | + } |
|
| 866 | + } |
|
| 867 | + return $return; |
|
| 868 | + } |
|
| 869 | 869 | |
| 870 | 870 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 871 | 871 | $safe_text = str_replace( '"', '"', $text ); |
@@ -876,10 +876,10 @@ discard block |
||
| 876 | 876 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | - /** |
|
| 880 | - * Add auto paragraphs to text areas |
|
| 881 | - * @since 2.0 |
|
| 882 | - */ |
|
| 879 | + /** |
|
| 880 | + * Add auto paragraphs to text areas |
|
| 881 | + * @since 2.0 |
|
| 882 | + */ |
|
| 883 | 883 | public static function use_wpautop( $content ) { |
| 884 | 884 | if ( apply_filters( 'frm_use_wpautop', true ) ) { |
| 885 | 885 | $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
@@ -888,26 +888,26 @@ discard block |
||
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | public static function replace_quotes( $val ) { |
| 891 | - //Replace double quotes |
|
| 891 | + //Replace double quotes |
|
| 892 | 892 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 893 | - //Replace single quotes |
|
| 894 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 895 | - return $val; |
|
| 896 | - } |
|
| 897 | - |
|
| 898 | - /** |
|
| 899 | - * @since 2.0 |
|
| 900 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 901 | - */ |
|
| 902 | - public static function jquery_ui_base_url() { |
|
| 893 | + //Replace single quotes |
|
| 894 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 895 | + return $val; |
|
| 896 | + } |
|
| 897 | + |
|
| 898 | + /** |
|
| 899 | + * @since 2.0 |
|
| 900 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 901 | + */ |
|
| 902 | + public static function jquery_ui_base_url() { |
|
| 903 | 903 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 904 | 904 | $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
| 905 | - return $url; |
|
| 906 | - } |
|
| 905 | + return $url; |
|
| 906 | + } |
|
| 907 | 907 | |
| 908 | - /** |
|
| 909 | - * @param string $handle |
|
| 910 | - */ |
|
| 908 | + /** |
|
| 909 | + * @param string $handle |
|
| 910 | + */ |
|
| 911 | 911 | public static function script_version( $handle, $default = 0 ) { |
| 912 | 912 | global $wp_scripts; |
| 913 | 913 | if ( ! $wp_scripts ) { |
@@ -929,12 +929,12 @@ discard block |
||
| 929 | 929 | |
| 930 | 930 | public static function js_redirect( $url ) { |
| 931 | 931 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 932 | - } |
|
| 932 | + } |
|
| 933 | 933 | |
| 934 | 934 | public static function get_user_id_param( $user_id ) { |
| 935 | 935 | if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
| 936 | - return $user_id; |
|
| 937 | - } |
|
| 936 | + return $user_id; |
|
| 937 | + } |
|
| 938 | 938 | |
| 939 | 939 | $user_id = sanitize_text_field( $user_id ); |
| 940 | 940 | if ( $user_id == 'current' ) { |
@@ -946,14 +946,14 @@ discard block |
||
| 946 | 946 | $user = get_user_by( 'login', $user_id ); |
| 947 | 947 | } |
| 948 | 948 | |
| 949 | - if ( $user ) { |
|
| 950 | - $user_id = $user->ID; |
|
| 951 | - } |
|
| 949 | + if ( $user ) { |
|
| 950 | + $user_id = $user->ID; |
|
| 951 | + } |
|
| 952 | 952 | unset( $user ); |
| 953 | - } |
|
| 953 | + } |
|
| 954 | 954 | |
| 955 | - return $user_id; |
|
| 956 | - } |
|
| 955 | + return $user_id; |
|
| 956 | + } |
|
| 957 | 957 | |
| 958 | 958 | public static function get_file_contents( $filename, $atts = array() ) { |
| 959 | 959 | if ( ! is_file( $filename ) ) { |
@@ -968,28 +968,28 @@ discard block |
||
| 968 | 968 | return $contents; |
| 969 | 969 | } |
| 970 | 970 | |
| 971 | - /** |
|
| 972 | - * @param string $table_name |
|
| 973 | - * @param string $column |
|
| 971 | + /** |
|
| 972 | + * @param string $table_name |
|
| 973 | + * @param string $column |
|
| 974 | 974 | * @param int $id |
| 975 | 975 | * @param int $num_chars |
| 976 | - */ |
|
| 977 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 978 | - $key = ''; |
|
| 976 | + */ |
|
| 977 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 978 | + $key = ''; |
|
| 979 | 979 | |
| 980 | - if ( ! empty( $name ) ) { |
|
| 980 | + if ( ! empty( $name ) ) { |
|
| 981 | 981 | $key = sanitize_key( $name ); |
| 982 | - } |
|
| 982 | + } |
|
| 983 | 983 | |
| 984 | 984 | if ( empty( $key ) ) { |
| 985 | 985 | $max_slug_value = pow( 36, $num_chars ); |
| 986 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 986 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 987 | 987 | $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
| 988 | - } |
|
| 988 | + } |
|
| 989 | 989 | |
| 990 | 990 | if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 991 | 991 | $key = $key . 'a'; |
| 992 | - } |
|
| 992 | + } |
|
| 993 | 993 | |
| 994 | 994 | $key_check = FrmDb::get_var( |
| 995 | 995 | $table_name, |
@@ -1001,7 +1001,7 @@ discard block |
||
| 1001 | 1001 | ); |
| 1002 | 1002 | |
| 1003 | 1003 | if ( $key_check || is_numeric( $key_check ) ) { |
| 1004 | - $suffix = 2; |
|
| 1004 | + $suffix = 2; |
|
| 1005 | 1005 | do { |
| 1006 | 1006 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 1007 | 1007 | $key_check = FrmDb::get_var( |
@@ -1015,19 +1015,19 @@ discard block |
||
| 1015 | 1015 | $suffix++; |
| 1016 | 1016 | } while ( $key_check || is_numeric( $key_check ) ); |
| 1017 | 1017 | $key = $alt_post_name; |
| 1018 | - } |
|
| 1019 | - return $key; |
|
| 1020 | - } |
|
| 1021 | - |
|
| 1022 | - /** |
|
| 1023 | - * Editing a Form or Entry |
|
| 1024 | - * @param string $table |
|
| 1025 | - * @return bool|array |
|
| 1026 | - */ |
|
| 1027 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1028 | - if ( ! $record ) { |
|
| 1029 | - return false; |
|
| 1030 | - } |
|
| 1018 | + } |
|
| 1019 | + return $key; |
|
| 1020 | + } |
|
| 1021 | + |
|
| 1022 | + /** |
|
| 1023 | + * Editing a Form or Entry |
|
| 1024 | + * @param string $table |
|
| 1025 | + * @return bool|array |
|
| 1026 | + */ |
|
| 1027 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 1028 | + if ( ! $record ) { |
|
| 1029 | + return false; |
|
| 1030 | + } |
|
| 1031 | 1031 | |
| 1032 | 1032 | if ( empty( $post_values ) ) { |
| 1033 | 1033 | $post_values = stripslashes_deep( $_POST ); |
@@ -1050,14 +1050,14 @@ discard block |
||
| 1050 | 1050 | |
| 1051 | 1051 | self::prepare_field_arrays( $fields, $record, $values, array_merge( $args, compact( 'default', 'post_values' ) ) ); |
| 1052 | 1052 | |
| 1053 | - if ( $table == 'entries' ) { |
|
| 1054 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1055 | - } else if ( $table == 'forms' ) { |
|
| 1056 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1057 | - } |
|
| 1053 | + if ( $table == 'entries' ) { |
|
| 1054 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1055 | + } else if ( $table == 'forms' ) { |
|
| 1056 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1057 | + } |
|
| 1058 | 1058 | |
| 1059 | - return $values; |
|
| 1060 | - } |
|
| 1059 | + return $values; |
|
| 1060 | + } |
|
| 1061 | 1061 | |
| 1062 | 1062 | private static function prepare_field_arrays( $fields, $record, array &$values, $args ) { |
| 1063 | 1063 | if ( ! empty( $fields ) ) { |
@@ -1070,15 +1070,15 @@ discard block |
||
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1073 | - $post_values = $args['post_values']; |
|
| 1073 | + $post_values = $args['post_values']; |
|
| 1074 | 1074 | |
| 1075 | - if ( $args['default'] ) { |
|
| 1076 | - $meta_value = $field->default_value; |
|
| 1077 | - } else { |
|
| 1075 | + if ( $args['default'] ) { |
|
| 1076 | + $meta_value = $field->default_value; |
|
| 1077 | + } else { |
|
| 1078 | 1078 | if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
| 1079 | 1079 | if ( ! isset( $field->field_options['custom_field'] ) ) { |
| 1080 | - $field->field_options['custom_field'] = ''; |
|
| 1081 | - } |
|
| 1080 | + $field->field_options['custom_field'] = ''; |
|
| 1081 | + } |
|
| 1082 | 1082 | $meta_value = FrmProEntryMetaHelper::get_post_value( |
| 1083 | 1083 | $record->post_id, |
| 1084 | 1084 | $field->field_options['post_field'], |
@@ -1090,31 +1090,31 @@ discard block |
||
| 1090 | 1090 | 'field' => $field, |
| 1091 | 1091 | ) |
| 1092 | 1092 | ); |
| 1093 | - } else { |
|
| 1093 | + } else { |
|
| 1094 | 1094 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1095 | - } |
|
| 1096 | - } |
|
| 1095 | + } |
|
| 1096 | + } |
|
| 1097 | 1097 | |
| 1098 | 1098 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1099 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1099 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1100 | 1100 | |
| 1101 | 1101 | $field_array = self::start_field_array( $field ); |
| 1102 | 1102 | $field_array['value'] = $new_value; |
| 1103 | 1103 | $field_array['type'] = apply_filters( 'frm_field_type', $field_type, $field, $new_value ); |
| 1104 | 1104 | $field_array['parent_form_id'] = $args['parent_form_id']; |
| 1105 | 1105 | |
| 1106 | - $args['field_type'] = $field_type; |
|
| 1106 | + $args['field_type'] = $field_type; |
|
| 1107 | 1107 | |
| 1108 | 1108 | FrmFieldsHelper::prepare_edit_front_field( $field_array, $field, $values['id'], $args ); |
| 1109 | 1109 | |
| 1110 | 1110 | if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
| 1111 | - $field_array['unique_msg'] = ''; |
|
| 1112 | - } |
|
| 1111 | + $field_array['unique_msg'] = ''; |
|
| 1112 | + } |
|
| 1113 | 1113 | |
| 1114 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1114 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1115 | 1115 | |
| 1116 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1117 | - } |
|
| 1116 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1117 | + } |
|
| 1118 | 1118 | |
| 1119 | 1119 | /** |
| 1120 | 1120 | * @since 3.0 |
@@ -1135,20 +1135,20 @@ discard block |
||
| 1135 | 1135 | ); |
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | - /** |
|
| 1139 | - * @param string $table |
|
| 1140 | - */ |
|
| 1138 | + /** |
|
| 1139 | + * @param string $table |
|
| 1140 | + */ |
|
| 1141 | 1141 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1142 | - if ( $table == 'entries' ) { |
|
| 1143 | - $form = $record->form_id; |
|
| 1142 | + if ( $table == 'entries' ) { |
|
| 1143 | + $form = $record->form_id; |
|
| 1144 | 1144 | FrmForm::maybe_get_form( $form ); |
| 1145 | - } else { |
|
| 1146 | - $form = $record; |
|
| 1147 | - } |
|
| 1145 | + } else { |
|
| 1146 | + $form = $record; |
|
| 1147 | + } |
|
| 1148 | 1148 | |
| 1149 | - if ( ! $form ) { |
|
| 1150 | - return; |
|
| 1151 | - } |
|
| 1149 | + if ( ! $form ) { |
|
| 1150 | + return; |
|
| 1151 | + } |
|
| 1152 | 1152 | |
| 1153 | 1153 | $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
| 1154 | 1154 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
@@ -1157,26 +1157,26 @@ discard block |
||
| 1157 | 1157 | return; |
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | - foreach ( $form->options as $opt => $value ) { |
|
| 1161 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1162 | - } |
|
| 1160 | + foreach ( $form->options as $opt => $value ) { |
|
| 1161 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1162 | + } |
|
| 1163 | 1163 | |
| 1164 | 1164 | self::fill_form_defaults( $post_values, $values ); |
| 1165 | - } |
|
| 1165 | + } |
|
| 1166 | 1166 | |
| 1167 | - /** |
|
| 1168 | - * Set to POST value or default |
|
| 1169 | - */ |
|
| 1167 | + /** |
|
| 1168 | + * Set to POST value or default |
|
| 1169 | + */ |
|
| 1170 | 1170 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1171 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1171 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1172 | 1172 | |
| 1173 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1174 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1173 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1174 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1175 | 1175 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1176 | - } |
|
| 1176 | + } |
|
| 1177 | 1177 | |
| 1178 | 1178 | unset( $opt, $default ); |
| 1179 | - } |
|
| 1179 | + } |
|
| 1180 | 1180 | |
| 1181 | 1181 | if ( ! isset( $values['custom_style'] ) ) { |
| 1182 | 1182 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1185,10 +1185,10 @@ discard block |
||
| 1185 | 1185 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1186 | 1186 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1187 | 1187 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1188 | - } |
|
| 1188 | + } |
|
| 1189 | 1189 | unset( $h ); |
| 1190 | - } |
|
| 1191 | - } |
|
| 1190 | + } |
|
| 1191 | + } |
|
| 1192 | 1192 | |
| 1193 | 1193 | /** |
| 1194 | 1194 | * @since 2.2.10 |
@@ -1211,33 +1211,33 @@ discard block |
||
| 1211 | 1211 | if ( $possible_email_field ) { |
| 1212 | 1212 | $class .= 'show_frm_not_email_to'; |
| 1213 | 1213 | } |
| 1214 | - ?> |
|
| 1214 | + ?> |
|
| 1215 | 1215 | <li> |
| 1216 | 1216 | <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> |
| 1217 | 1217 | <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> |
| 1218 | 1218 | <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> |
| 1219 | 1219 | </li> |
| 1220 | 1220 | <?php |
| 1221 | - } |
|
| 1221 | + } |
|
| 1222 | 1222 | |
| 1223 | 1223 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1224 | - if ( is_array( $str ) ) { |
|
| 1225 | - return ''; |
|
| 1224 | + if ( is_array( $str ) ) { |
|
| 1225 | + return ''; |
|
| 1226 | 1226 | } |
| 1227 | 1227 | |
| 1228 | - $length = (int) $length; |
|
| 1228 | + $length = (int) $length; |
|
| 1229 | 1229 | $str = wp_strip_all_tags( $str ); |
| 1230 | 1230 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1231 | 1231 | |
| 1232 | 1232 | if ( $length == 0 ) { |
| 1233 | - return ''; |
|
| 1234 | - } else if ( $length <= 10 ) { |
|
| 1233 | + return ''; |
|
| 1234 | + } else if ( $length <= 10 ) { |
|
| 1235 | 1235 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1236 | 1236 | return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
| 1237 | - } |
|
| 1237 | + } |
|
| 1238 | 1238 | |
| 1239 | - $sub = ''; |
|
| 1240 | - $len = 0; |
|
| 1239 | + $sub = ''; |
|
| 1240 | + $len = 0; |
|
| 1241 | 1241 | |
| 1242 | 1242 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1243 | 1243 | |
@@ -1245,21 +1245,21 @@ discard block |
||
| 1245 | 1245 | $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
| 1246 | 1246 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1247 | 1247 | if ( $total_len > $length && str_word_count( $sub ) ) { |
| 1248 | - break; |
|
| 1249 | - } |
|
| 1248 | + break; |
|
| 1249 | + } |
|
| 1250 | 1250 | |
| 1251 | - $sub .= $part; |
|
| 1251 | + $sub .= $part; |
|
| 1252 | 1252 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1253 | 1253 | |
| 1254 | 1254 | if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
| 1255 | - break; |
|
| 1256 | - } |
|
| 1255 | + break; |
|
| 1256 | + } |
|
| 1257 | 1257 | |
| 1258 | 1258 | unset( $total_len, $word ); |
| 1259 | - } |
|
| 1259 | + } |
|
| 1260 | 1260 | |
| 1261 | 1261 | return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
| 1262 | - } |
|
| 1262 | + } |
|
| 1263 | 1263 | |
| 1264 | 1264 | public static function mb_function( $function_names, $args ) { |
| 1265 | 1265 | $mb_function_name = $function_names[0]; |
@@ -1272,17 +1272,17 @@ discard block |
||
| 1272 | 1272 | |
| 1273 | 1273 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1274 | 1274 | if ( empty( $date ) ) { |
| 1275 | - return $date; |
|
| 1276 | - } |
|
| 1275 | + return $date; |
|
| 1276 | + } |
|
| 1277 | 1277 | |
| 1278 | 1278 | if ( empty( $date_format ) ) { |
| 1279 | 1279 | $date_format = get_option( 'date_format' ); |
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | 1282 | if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
| 1283 | - $frmpro_settings = new FrmProSettings(); |
|
| 1283 | + $frmpro_settings = new FrmProSettings(); |
|
| 1284 | 1284 | $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
| 1285 | - } |
|
| 1285 | + } |
|
| 1286 | 1286 | |
| 1287 | 1287 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1288 | 1288 | |
@@ -1291,8 +1291,8 @@ discard block |
||
| 1291 | 1291 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1292 | 1292 | } |
| 1293 | 1293 | |
| 1294 | - return $formatted; |
|
| 1295 | - } |
|
| 1294 | + return $formatted; |
|
| 1295 | + } |
|
| 1296 | 1296 | |
| 1297 | 1297 | private static function add_time_to_date( $time_format, $date ) { |
| 1298 | 1298 | if ( empty( $time_format ) ) { |
@@ -1374,32 +1374,32 @@ discard block |
||
| 1374 | 1374 | ); |
| 1375 | 1375 | } |
| 1376 | 1376 | |
| 1377 | - // Pagination Methods |
|
| 1377 | + // Pagination Methods |
|
| 1378 | 1378 | |
| 1379 | - /** |
|
| 1380 | - * @param integer $current_p |
|
| 1381 | - */ |
|
| 1379 | + /** |
|
| 1380 | + * @param integer $current_p |
|
| 1381 | + */ |
|
| 1382 | 1382 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1383 | 1383 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 1386 | - /** |
|
| 1387 | - * @param integer $current_p |
|
| 1388 | - */ |
|
| 1389 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1390 | - if ( $current_p == 1 ) { |
|
| 1391 | - return 1; |
|
| 1392 | - } else { |
|
| 1393 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1394 | - } |
|
| 1395 | - } |
|
| 1386 | + /** |
|
| 1387 | + * @param integer $current_p |
|
| 1388 | + */ |
|
| 1389 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1390 | + if ( $current_p == 1 ) { |
|
| 1391 | + return 1; |
|
| 1392 | + } else { |
|
| 1393 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1394 | + } |
|
| 1395 | + } |
|
| 1396 | 1396 | |
| 1397 | 1397 | /** |
| 1398 | 1398 | * @return array |
| 1399 | 1399 | */ |
| 1400 | 1400 | public static function json_to_array( $json_vars ) { |
| 1401 | - $vars = array(); |
|
| 1402 | - foreach ( $json_vars as $jv ) { |
|
| 1401 | + $vars = array(); |
|
| 1402 | + foreach ( $json_vars as $jv ) { |
|
| 1403 | 1403 | $jv_name = explode( '[', $jv['name'] ); |
| 1404 | 1404 | $last = count( $jv_name ) - 1; |
| 1405 | 1405 | foreach ( $jv_name as $p => $n ) { |
@@ -1416,77 +1416,77 @@ discard block |
||
| 1416 | 1416 | $l3 = $name; |
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1419 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1420 | 1420 | |
| 1421 | - switch ( $p ) { |
|
| 1422 | - case 0: |
|
| 1423 | - $l1 = $name; |
|
| 1424 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1421 | + switch ( $p ) { |
|
| 1422 | + case 0: |
|
| 1423 | + $l1 = $name; |
|
| 1424 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1425 | 1425 | break; |
| 1426 | 1426 | |
| 1427 | - case 1: |
|
| 1428 | - $l2 = $name; |
|
| 1429 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1427 | + case 1: |
|
| 1428 | + $l2 = $name; |
|
| 1429 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1430 | 1430 | break; |
| 1431 | 1431 | |
| 1432 | - case 2: |
|
| 1433 | - $l3 = $name; |
|
| 1434 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1432 | + case 2: |
|
| 1433 | + $l3 = $name; |
|
| 1434 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1435 | 1435 | break; |
| 1436 | 1436 | |
| 1437 | - case 3: |
|
| 1438 | - $l4 = $name; |
|
| 1439 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1440 | - } |
|
| 1437 | + case 3: |
|
| 1438 | + $l4 = $name; |
|
| 1439 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1440 | + } |
|
| 1441 | 1441 | |
| 1442 | 1442 | unset( $this_val, $n ); |
| 1443 | - } |
|
| 1443 | + } |
|
| 1444 | 1444 | |
| 1445 | 1445 | unset( $last, $jv ); |
| 1446 | - } |
|
| 1447 | - |
|
| 1448 | - return $vars; |
|
| 1449 | - } |
|
| 1450 | - |
|
| 1451 | - /** |
|
| 1452 | - * @param string $name |
|
| 1453 | - * @param string $l1 |
|
| 1454 | - */ |
|
| 1455 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1456 | - if ( $name == '' ) { |
|
| 1457 | - $vars[] = $val; |
|
| 1458 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1459 | - $vars[ $l1 ] = $val; |
|
| 1460 | - } |
|
| 1461 | - } |
|
| 1446 | + } |
|
| 1447 | + |
|
| 1448 | + return $vars; |
|
| 1449 | + } |
|
| 1450 | + |
|
| 1451 | + /** |
|
| 1452 | + * @param string $name |
|
| 1453 | + * @param string $l1 |
|
| 1454 | + */ |
|
| 1455 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1456 | + if ( $name == '' ) { |
|
| 1457 | + $vars[] = $val; |
|
| 1458 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1459 | + $vars[ $l1 ] = $val; |
|
| 1460 | + } |
|
| 1461 | + } |
|
| 1462 | 1462 | |
| 1463 | 1463 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1464 | - $tooltips = array( |
|
| 1465 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1466 | - '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' ), |
|
| 1467 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1468 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1469 | - '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' ), |
|
| 1470 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1471 | - '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() ) ), |
|
| 1472 | - ); |
|
| 1473 | - |
|
| 1474 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1475 | - return; |
|
| 1476 | - } |
|
| 1477 | - |
|
| 1478 | - if ( 'open' == $class ) { |
|
| 1479 | - echo ' frm_help"'; |
|
| 1480 | - } else { |
|
| 1481 | - echo ' class="frm_help"'; |
|
| 1482 | - } |
|
| 1464 | + $tooltips = array( |
|
| 1465 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1466 | + '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' ), |
|
| 1467 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1468 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1469 | + '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' ), |
|
| 1470 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1471 | + '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() ) ), |
|
| 1472 | + ); |
|
| 1473 | + |
|
| 1474 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1475 | + return; |
|
| 1476 | + } |
|
| 1477 | + |
|
| 1478 | + if ( 'open' == $class ) { |
|
| 1479 | + echo ' frm_help"'; |
|
| 1480 | + } else { |
|
| 1481 | + echo ' class="frm_help"'; |
|
| 1482 | + } |
|
| 1483 | 1483 | |
| 1484 | 1484 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1485 | 1485 | |
| 1486 | - if ( 'open' != $class ) { |
|
| 1487 | - echo '"'; |
|
| 1488 | - } |
|
| 1489 | - } |
|
| 1486 | + if ( 'open' != $class ) { |
|
| 1487 | + echo '"'; |
|
| 1488 | + } |
|
| 1489 | + } |
|
| 1490 | 1490 | |
| 1491 | 1491 | /** |
| 1492 | 1492 | * Add the current_page class to that page in the form nav |
@@ -1502,35 +1502,35 @@ discard block |
||
| 1502 | 1502 | } |
| 1503 | 1503 | } |
| 1504 | 1504 | |
| 1505 | - /** |
|
| 1506 | - * Prepare and json_encode post content |
|
| 1507 | - * |
|
| 1508 | - * @since 2.0 |
|
| 1509 | - * |
|
| 1510 | - * @param array $post_content |
|
| 1511 | - * @return string $post_content ( json encoded array ) |
|
| 1512 | - */ |
|
| 1513 | - public static function prepare_and_encode( $post_content ) { |
|
| 1514 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1505 | + /** |
|
| 1506 | + * Prepare and json_encode post content |
|
| 1507 | + * |
|
| 1508 | + * @since 2.0 |
|
| 1509 | + * |
|
| 1510 | + * @param array $post_content |
|
| 1511 | + * @return string $post_content ( json encoded array ) |
|
| 1512 | + */ |
|
| 1513 | + public static function prepare_and_encode( $post_content ) { |
|
| 1514 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1515 | 1515 | foreach ( $post_content as $key => $val ) { |
| 1516 | 1516 | // Replace problematic characters (like ") |
| 1517 | 1517 | $val = str_replace( '"', '"', $val ); |
| 1518 | 1518 | |
| 1519 | 1519 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1520 | - unset( $key, $val ); |
|
| 1521 | - } |
|
| 1520 | + unset( $key, $val ); |
|
| 1521 | + } |
|
| 1522 | 1522 | |
| 1523 | - // json_encode the array |
|
| 1524 | - $post_content = json_encode( $post_content ); |
|
| 1523 | + // json_encode the array |
|
| 1524 | + $post_content = json_encode( $post_content ); |
|
| 1525 | 1525 | |
| 1526 | - // add extra slashes for \r\n since WP strips them |
|
| 1526 | + // add extra slashes for \r\n since WP strips them |
|
| 1527 | 1527 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1528 | 1528 | |
| 1529 | - // allow for " |
|
| 1530 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1529 | + // allow for " |
|
| 1530 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1531 | 1531 | |
| 1532 | - return $post_content; |
|
| 1533 | - } |
|
| 1532 | + return $post_content; |
|
| 1533 | + } |
|
| 1534 | 1534 | |
| 1535 | 1535 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1536 | 1536 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1553,54 +1553,54 @@ discard block |
||
| 1553 | 1553 | |
| 1554 | 1554 | public static function maybe_json_decode( $string ) { |
| 1555 | 1555 | if ( is_array( $string ) ) { |
| 1556 | - return $string; |
|
| 1557 | - } |
|
| 1556 | + return $string; |
|
| 1557 | + } |
|
| 1558 | 1558 | |
| 1559 | 1559 | $new_string = json_decode( $string, true ); |
| 1560 | 1560 | if ( function_exists( 'json_last_error' ) ) { |
| 1561 | 1561 | // php 5.3+ |
| 1562 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1563 | - $string = $new_string; |
|
| 1564 | - } |
|
| 1562 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1563 | + $string = $new_string; |
|
| 1564 | + } |
|
| 1565 | 1565 | } elseif ( isset( $new_string ) ) { |
| 1566 | 1566 | // php < 5.3 fallback |
| 1567 | - $string = $new_string; |
|
| 1568 | - } |
|
| 1569 | - return $string; |
|
| 1570 | - } |
|
| 1571 | - |
|
| 1572 | - /** |
|
| 1573 | - * @since 1.07.10 |
|
| 1574 | - * |
|
| 1575 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1576 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1577 | - */ |
|
| 1567 | + $string = $new_string; |
|
| 1568 | + } |
|
| 1569 | + return $string; |
|
| 1570 | + } |
|
| 1571 | + |
|
| 1572 | + /** |
|
| 1573 | + * @since 1.07.10 |
|
| 1574 | + * |
|
| 1575 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1576 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1577 | + */ |
|
| 1578 | 1578 | public static function maybe_highlight_menu( $post_type ) { |
| 1579 | - global $post; |
|
| 1579 | + global $post; |
|
| 1580 | 1580 | |
| 1581 | 1581 | if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
| 1582 | - return; |
|
| 1583 | - } |
|
| 1582 | + return; |
|
| 1583 | + } |
|
| 1584 | 1584 | |
| 1585 | 1585 | if ( is_object( $post ) && $post->post_type != $post_type ) { |
| 1586 | - return; |
|
| 1587 | - } |
|
| 1586 | + return; |
|
| 1587 | + } |
|
| 1588 | 1588 | |
| 1589 | - self::load_admin_wide_js(); |
|
| 1590 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1591 | - } |
|
| 1589 | + self::load_admin_wide_js(); |
|
| 1590 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1591 | + } |
|
| 1592 | 1592 | |
| 1593 | - /** |
|
| 1594 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1595 | - * @since 2.0 |
|
| 1596 | - */ |
|
| 1593 | + /** |
|
| 1594 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1595 | + * @since 2.0 |
|
| 1596 | + */ |
|
| 1597 | 1597 | public static function load_admin_wide_js( $load = true ) { |
| 1598 | - $version = FrmAppHelper::plugin_version(); |
|
| 1598 | + $version = FrmAppHelper::plugin_version(); |
|
| 1599 | 1599 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1600 | 1600 | |
| 1601 | 1601 | $global_strings = array( |
| 1602 | 1602 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1603 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1603 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1604 | 1604 | 'url' => FrmAppHelper::plugin_url(), |
| 1605 | 1605 | 'loading' => __( 'Loading…' ), |
| 1606 | 1606 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
@@ -1610,7 +1610,7 @@ discard block |
||
| 1610 | 1610 | if ( $load ) { |
| 1611 | 1611 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1612 | 1612 | } |
| 1613 | - } |
|
| 1613 | + } |
|
| 1614 | 1614 | |
| 1615 | 1615 | /** |
| 1616 | 1616 | * @since 2.0.9 |
@@ -1619,9 +1619,9 @@ discard block |
||
| 1619 | 1619 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1620 | 1620 | } |
| 1621 | 1621 | |
| 1622 | - /** |
|
| 1623 | - * @param string $location |
|
| 1624 | - */ |
|
| 1622 | + /** |
|
| 1623 | + * @param string $location |
|
| 1624 | + */ |
|
| 1625 | 1625 | public static function localize_script( $location ) { |
| 1626 | 1626 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1627 | 1627 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1687,27 +1687,27 @@ discard block |
||
| 1687 | 1687 | } |
| 1688 | 1688 | } |
| 1689 | 1689 | |
| 1690 | - /** |
|
| 1690 | + /** |
|
| 1691 | 1691 | * echo the message on the plugins listing page |
| 1692 | - * @since 1.07.10 |
|
| 1693 | - * |
|
| 1694 | - * @param float $min_version The version the add-on requires |
|
| 1695 | - */ |
|
| 1692 | + * @since 1.07.10 |
|
| 1693 | + * |
|
| 1694 | + * @param float $min_version The version the add-on requires |
|
| 1695 | + */ |
|
| 1696 | 1696 | public static function min_version_notice( $min_version ) { |
| 1697 | - $frm_version = self::plugin_version(); |
|
| 1697 | + $frm_version = self::plugin_version(); |
|
| 1698 | 1698 | |
| 1699 | - // check if Formidable meets minimum requirements |
|
| 1699 | + // check if Formidable meets minimum requirements |
|
| 1700 | 1700 | if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
| 1701 | - return; |
|
| 1702 | - } |
|
| 1701 | + return; |
|
| 1702 | + } |
|
| 1703 | 1703 | |
| 1704 | 1704 | $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
| 1705 | 1705 | 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">' . |
| 1706 | - esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1707 | - '</div></td></tr>'; |
|
| 1708 | - } |
|
| 1706 | + esc_html__( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1707 | + '</div></td></tr>'; |
|
| 1708 | + } |
|
| 1709 | 1709 | |
| 1710 | - public static function locales( $type = 'date' ) { |
|
| 1710 | + public static function locales( $type = 'date' ) { |
|
| 1711 | 1711 | $locales = array( |
| 1712 | 1712 | 'en' => __( 'English', 'formidable' ), |
| 1713 | 1713 | '' => __( 'English/Western', 'formidable' ), |
@@ -1786,8 +1786,8 @@ discard block |
||
| 1786 | 1786 | $locales = array_diff_key( $locales, array_flip( $unset ) ); |
| 1787 | 1787 | $locales = apply_filters( 'frm_locales', $locales ); |
| 1788 | 1788 | |
| 1789 | - return $locales; |
|
| 1790 | - } |
|
| 1789 | + return $locales; |
|
| 1790 | + } |
|
| 1791 | 1791 | |
| 1792 | 1792 | /** |
| 1793 | 1793 | * Used to filter shortcode in text widgets |