@@ -57,6 +57,9 @@ discard block |
||
| 57 | 57 | return get_option('blogname'); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | + /** |
|
| 61 | + * @param string $url |
|
| 62 | + */ |
|
| 60 | 63 | public static function make_affiliate_url( $url ) { |
| 61 | 64 | $affiliate_id = self::get_affiliate(); |
| 62 | 65 | if ( ! empty( $affiliate_id ) ) { |
@@ -356,7 +359,7 @@ discard block |
||
| 356 | 359 | * Sanitize the value, and allow some HTML |
| 357 | 360 | * @since 2.0 |
| 358 | 361 | * @param string $value |
| 359 | - * @param array $allowed |
|
| 362 | + * @param string[] $allowed |
|
| 360 | 363 | * @return string |
| 361 | 364 | */ |
| 362 | 365 | public static function kses( $value, $allowed = array() ) { |
@@ -464,6 +467,7 @@ discard block |
||
| 464 | 467 | /** |
| 465 | 468 | * Keep track of the keys cached in each group so they can be deleted |
| 466 | 469 | * in Redis and Memcache |
| 470 | + * @param string $group |
|
| 467 | 471 | */ |
| 468 | 472 | public static function add_key_to_group_cache( $key, $group ) { |
| 469 | 473 | $cached = self::get_group_cached_keys( $group ); |
@@ -784,6 +788,9 @@ discard block |
||
| 784 | 788 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
| 785 | 789 | } |
| 786 | 790 | |
| 791 | + /** |
|
| 792 | + * @param string $function |
|
| 793 | + */ |
|
| 787 | 794 | public static function recursive_function_map( $value, $function ) { |
| 788 | 795 | if ( is_array( $value ) ) { |
| 789 | 796 | $original_function = $function; |
@@ -1217,6 +1224,9 @@ discard block |
||
| 1217 | 1224 | return $sub . (($len < $original_len) ? $continue : ''); |
| 1218 | 1225 | } |
| 1219 | 1226 | |
| 1227 | + /** |
|
| 1228 | + * @param string[] $function_names |
|
| 1229 | + */ |
|
| 1220 | 1230 | public static function mb_function( $function_names, $args ) { |
| 1221 | 1231 | $mb_function_name = $function_names[0]; |
| 1222 | 1232 | $function_name = $function_names[1]; |
@@ -1250,6 +1260,9 @@ discard block |
||
| 1250 | 1260 | return $formatted; |
| 1251 | 1261 | } |
| 1252 | 1262 | |
| 1263 | + /** |
|
| 1264 | + * @param string $time_format |
|
| 1265 | + */ |
|
| 1253 | 1266 | private static function add_time_to_date( $time_format, $date ) { |
| 1254 | 1267 | if ( empty( $time_format ) ) { |
| 1255 | 1268 | $time_format = get_option('time_format'); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined('ABSPATH') ) { |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public static function plugin_folder() { |
| 26 | - return basename(self::plugin_path()); |
|
| 26 | + return basename( self::plugin_path() ); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public static function plugin_path() { |
| 30 | - return dirname(dirname(dirname(__FILE__))); |
|
| 30 | + return dirname( dirname( dirname( __FILE__ ) ) ); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public static function plugin_url() { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * @return string |
| 55 | 55 | */ |
| 56 | 56 | public static function site_name() { |
| 57 | - return get_option('blogname'); |
|
| 57 | + return get_option( 'blogname' ); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | public static function make_affiliate_url( $url ) { |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public static function get_settings() { |
| 81 | 81 | global $frm_settings; |
| 82 | - if ( empty($frm_settings) ) { |
|
| 82 | + if ( empty( $frm_settings ) ) { |
|
| 83 | 83 | $frm_settings = new FrmSettings(); |
| 84 | 84 | } |
| 85 | 85 | return $frm_settings; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | public static function pro_is_installed() { |
| 103 | - return apply_filters('frm_pro_installed', false); |
|
| 103 | + return apply_filters( 'frm_pro_installed', false ); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @return boolean |
| 145 | 145 | */ |
| 146 | 146 | public static function doing_ajax() { |
| 147 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 147 | + return defined( 'DOING_AJAX' ) && DOING_AJAX && ! self::is_preview_page(); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * @return boolean |
| 165 | 165 | */ |
| 166 | 166 | public static function is_admin() { |
| 167 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 167 | + return is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * @return string |
| 192 | 192 | */ |
| 193 | 193 | public static function get_server_value( $value ) { |
| 194 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 194 | + return isset( $_SERVER[$value] ) ? wp_strip_all_tags( $_SERVER[$value] ) : ''; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -206,14 +206,14 @@ discard block |
||
| 206 | 206 | 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
| 207 | 207 | 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
| 208 | 208 | ) as $key ) { |
| 209 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 209 | + if ( ! isset( $_SERVER[$key] ) ) { |
|
| 210 | 210 | continue; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 214 | - $ip = trim($ip); // just to be safe |
|
| 213 | + foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { |
|
| 214 | + $ip = trim( $ip ); // just to be safe |
|
| 215 | 215 | |
| 216 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 216 | + if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { |
|
| 217 | 217 | return $ip; |
| 218 | 218 | } |
| 219 | 219 | } |
@@ -223,15 +223,15 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
| 226 | - if ( strpos($param, '[') ) { |
|
| 227 | - $params = explode('[', $param); |
|
| 226 | + if ( strpos( $param, '[' ) ) { |
|
| 227 | + $params = explode( '[', $param ); |
|
| 228 | 228 | $param = $params[0]; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | if ( $src == 'get' ) { |
| 232 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 233 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 234 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 232 | + $value = isset( $_POST[$param] ) ? stripslashes_deep( $_POST[$param] ) : ( isset( $_GET[$param] ) ? stripslashes_deep( $_GET[$param] ) : $default ); |
|
| 233 | + if ( ! isset( $_POST[$param] ) && isset( $_GET[$param] ) && ! is_array( $value ) ) { |
|
| 234 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[$param] ) ); |
|
| 235 | 235 | } |
| 236 | 236 | self::sanitize_value( $sanitize, $value ); |
| 237 | 237 | } else { |
@@ -240,12 +240,12 @@ discard block |
||
| 240 | 240 | |
| 241 | 241 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 242 | 242 | foreach ( $params as $k => $p ) { |
| 243 | - if ( ! $k || ! is_array($value) ) { |
|
| 243 | + if ( ! $k || ! is_array( $value ) ) { |
|
| 244 | 244 | continue; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - $p = trim($p, ']'); |
|
| 248 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 247 | + $p = trim( $p, ']' ); |
|
| 248 | + $value = isset( $value[$p] ) ? $value[$p] : $default; |
|
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | 251 | |
@@ -284,16 +284,16 @@ discard block |
||
| 284 | 284 | |
| 285 | 285 | $value = $args['default']; |
| 286 | 286 | if ( $args['type'] == 'get' ) { |
| 287 | - if ( $_GET && isset( $_GET[ $args['param'] ] ) ) { |
|
| 288 | - $value = $_GET[ $args['param'] ]; |
|
| 287 | + if ( $_GET && isset( $_GET[$args['param']] ) ) { |
|
| 288 | + $value = $_GET[$args['param']]; |
|
| 289 | 289 | } |
| 290 | 290 | } else if ( $args['type'] == 'post' ) { |
| 291 | - if ( isset( $_POST[ $args['param'] ] ) ) { |
|
| 292 | - $value = stripslashes_deep( maybe_unserialize( $_POST[ $args['param'] ] ) ); |
|
| 291 | + if ( isset( $_POST[$args['param']] ) ) { |
|
| 292 | + $value = stripslashes_deep( maybe_unserialize( $_POST[$args['param']] ) ); |
|
| 293 | 293 | } |
| 294 | 294 | } else { |
| 295 | - if ( isset( $_REQUEST[ $args['param'] ] ) ) { |
|
| 296 | - $value = $_REQUEST[ $args['param'] ]; |
|
| 295 | + if ( isset( $_REQUEST[$args['param']] ) ) { |
|
| 296 | + $value = $_REQUEST[$args['param']]; |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | if ( is_array( $value ) ) { |
| 322 | 322 | $temp_values = $value; |
| 323 | 323 | foreach ( $temp_values as $k => $v ) { |
| 324 | - FrmAppHelper::sanitize_value( $sanitize, $value[ $k ] ); |
|
| 324 | + FrmAppHelper::sanitize_value( $sanitize, $value[$k] ); |
|
| 325 | 325 | } |
| 326 | 326 | } else { |
| 327 | 327 | $value = call_user_func( $sanitize, $value ); |
@@ -332,8 +332,8 @@ discard block |
||
| 332 | 332 | public static function sanitize_request( $sanitize_method, &$values ) { |
| 333 | 333 | $temp_values = $values; |
| 334 | 334 | foreach ( $temp_values as $k => $val ) { |
| 335 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 336 | - $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
|
| 335 | + if ( isset( $sanitize_method[$k] ) ) { |
|
| 336 | + $values[$k] = call_user_func( $sanitize_method[$k], $val ); |
|
| 337 | 337 | } |
| 338 | 338 | } |
| 339 | 339 | } |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | public static function sanitize_array( &$values ) { |
| 342 | 342 | $temp_values = $values; |
| 343 | 343 | foreach ( $temp_values as $k => $val ) { |
| 344 | - $values[ $k ] = wp_kses_post( $val ); |
|
| 344 | + $values[$k] = wp_kses_post( $val ); |
|
| 345 | 345 | } |
| 346 | 346 | } |
| 347 | 347 | |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | |
| 365 | 365 | $allowed_html = array(); |
| 366 | 366 | foreach ( $allowed as $a ) { |
| 367 | - $allowed_html[ $a ] = isset( $html[ $a ] ) ? $html[ $a ] : array(); |
|
| 367 | + $allowed_html[$a] = isset( $html[$a] ) ? $html[$a] : array(); |
|
| 368 | 368 | } |
| 369 | 369 | |
| 370 | 370 | return wp_kses( $value, $allowed_html ); |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | * @since 2.0 |
| 376 | 376 | */ |
| 377 | 377 | public static function remove_get_action() { |
| 378 | - if ( ! isset($_GET) ) { |
|
| 378 | + if ( ! isset( $_GET ) ) { |
|
| 379 | 379 | return; |
| 380 | 380 | } |
| 381 | 381 | |
@@ -397,8 +397,8 @@ discard block |
||
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | global $wp_query; |
| 400 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 401 | - $value = $wp_query->query_vars[ $param ]; |
|
| 400 | + if ( isset( $wp_query->query_vars[$param] ) ) { |
|
| 401 | + $value = $wp_query->query_vars[$param]; |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | return $value; |
@@ -427,19 +427,19 @@ discard block |
||
| 427 | 427 | * @return mixed $results The cache or query results |
| 428 | 428 | */ |
| 429 | 429 | public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
| 430 | - $results = wp_cache_get($cache_key, $group); |
|
| 431 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 430 | + $results = wp_cache_get( $cache_key, $group ); |
|
| 431 | + if ( ! self::is_empty_value( $results, false ) || empty( $query ) ) { |
|
| 432 | 432 | return $results; |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | if ( 'get_posts' == $type ) { |
| 436 | - $results = get_posts($query); |
|
| 436 | + $results = get_posts( $query ); |
|
| 437 | 437 | } else if ( 'get_associative_results' == $type ) { |
| 438 | 438 | global $wpdb; |
| 439 | 439 | $results = $wpdb->get_results( $query, OBJECT_K ); |
| 440 | 440 | } else { |
| 441 | 441 | global $wpdb; |
| 442 | - $results = $wpdb->{$type}($query); |
|
| 442 | + $results = $wpdb->{$type}( $query ); |
|
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | self::set_cache( $cache_key, $results, $group, $time ); |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | */ |
| 461 | 461 | public static function add_key_to_group_cache( $key, $group ) { |
| 462 | 462 | $cached = self::get_group_cached_keys( $group ); |
| 463 | - $cached[ $key ] = $key; |
|
| 463 | + $cached[$key] = $key; |
|
| 464 | 464 | wp_cache_set( 'cached_keys', $cached, $group, 300 ); |
| 465 | 465 | } |
| 466 | 466 | |
@@ -487,9 +487,9 @@ discard block |
||
| 487 | 487 | } |
| 488 | 488 | |
| 489 | 489 | // then check the transient |
| 490 | - $results = get_transient($cache_key); |
|
| 490 | + $results = get_transient( $cache_key ); |
|
| 491 | 491 | if ( $results ) { |
| 492 | - wp_cache_set($cache_key, $results); |
|
| 492 | + wp_cache_set( $cache_key, $results ); |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | return $results; |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | * @param string $cache_key |
| 501 | 501 | */ |
| 502 | 502 | public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
| 503 | - delete_transient($cache_key); |
|
| 503 | + delete_transient( $cache_key ); |
|
| 504 | 504 | wp_cache_delete( $cache_key, $group ); |
| 505 | 505 | } |
| 506 | 506 | |
@@ -544,17 +544,17 @@ discard block |
||
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | public static function get_pages() { |
| 547 | - return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
| 547 | + return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => - 1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
| 551 | 551 | $pages = self::get_pages(); |
| 552 | 552 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 553 | 553 | ?> |
| 554 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
|
| 554 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" class="frm-pages-dropdown"> |
|
| 555 | 555 | <option value=""> </option> |
| 556 | 556 | <?php foreach ( $pages as $page ) { ?> |
| 557 | - <option value="<?php echo esc_attr($page->ID); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
| 557 | + <option value="<?php echo esc_attr( $page->ID ); ?>" <?php selected( $selected, $page->ID ) ?>> |
|
| 558 | 558 | <?php echo esc_html( $truncate ? self::truncate( $page->post_title, $truncate ) : $page->post_title ); ?> |
| 559 | 559 | </option> |
| 560 | 560 | <?php } ?> |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | public static function post_edit_link( $post_id ) { |
| 566 | - $post = get_post($post_id); |
|
| 566 | + $post = get_post( $post_id ); |
|
| 567 | 567 | if ( $post ) { |
| 568 | 568 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 569 | 569 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
@@ -573,17 +573,17 @@ discard block |
||
| 573 | 573 | |
| 574 | 574 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 575 | 575 | ?> |
| 576 | - <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
|
| 576 | + <select name="<?php echo esc_attr( $field_name ); ?>" id="<?php echo esc_attr( $field_name ); ?>" <?php |
|
| 577 | 577 | echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
| 578 | 578 | ?> class="frm_multiselect"> |
| 579 | - <?php self::roles_options($capability); ?> |
|
| 579 | + <?php self::roles_options( $capability ); ?> |
|
| 580 | 580 | </select> |
| 581 | 581 | <?php |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | public static function roles_options( $capability ) { |
| 585 | 585 | global $frm_vars; |
| 586 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 586 | + if ( isset( $frm_vars['editable_roles'] ) ) { |
|
| 587 | 587 | $editable_roles = $frm_vars['editable_roles']; |
| 588 | 588 | } else { |
| 589 | 589 | $editable_roles = get_editable_roles(); |
@@ -591,10 +591,10 @@ discard block |
||
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | foreach ( $editable_roles as $role => $details ) { |
| 594 | - $name = translate_user_role($details['name'] ); ?> |
|
| 595 | - <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
|
| 594 | + $name = translate_user_role( $details['name'] ); ?> |
|
| 595 | + <option value="<?php echo esc_attr( $role ) ?>" <?php echo in_array( $role, (array) $capability ) ? ' selected="selected"' : ''; ?>><?php echo esc_attr( $name ) ?> </option> |
|
| 596 | 596 | <?php |
| 597 | - unset($role, $details); |
|
| 597 | + unset( $role, $details ); |
|
| 598 | 598 | } |
| 599 | 599 | } |
| 600 | 600 | |
@@ -650,7 +650,7 @@ discard block |
||
| 650 | 650 | public static function maybe_add_permissions() { |
| 651 | 651 | self::force_capability( 'frm_view_entries' ); |
| 652 | 652 | |
| 653 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 653 | + if ( ! current_user_can( 'administrator' ) || current_user_can( 'frm_view_forms' ) ) { |
|
| 654 | 654 | return; |
| 655 | 655 | } |
| 656 | 656 | |
@@ -659,7 +659,7 @@ discard block |
||
| 659 | 659 | $frm_roles = self::frm_capabilities(); |
| 660 | 660 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 661 | 661 | $user->add_cap( $frm_role ); |
| 662 | - unset($frm_role, $frm_role_description); |
|
| 662 | + unset( $frm_role, $frm_role_description ); |
|
| 663 | 663 | } |
| 664 | 664 | } |
| 665 | 665 | |
@@ -684,12 +684,12 @@ discard block |
||
| 684 | 684 | * @param string $permission |
| 685 | 685 | */ |
| 686 | 686 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 687 | - $permission_error = self::permission_nonce_error($permission); |
|
| 687 | + $permission_error = self::permission_nonce_error( $permission ); |
|
| 688 | 688 | if ( $permission_error !== false ) { |
| 689 | 689 | if ( 'hide' == $show_message ) { |
| 690 | 690 | $permission_error = ''; |
| 691 | 691 | } |
| 692 | - wp_die($permission_error); |
|
| 692 | + wp_die( $permission_error ); |
|
| 693 | 693 | } |
| 694 | 694 | } |
| 695 | 695 | |
@@ -706,11 +706,11 @@ discard block |
||
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | $error = false; |
| 709 | - if ( empty($nonce_name) ) { |
|
| 709 | + if ( empty( $nonce_name ) ) { |
|
| 710 | 710 | return $error; |
| 711 | 711 | } |
| 712 | 712 | |
| 713 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 713 | + if ( $_REQUEST && ( ! isset( $_REQUEST[$nonce_name] ) || ! wp_verify_nonce( $_REQUEST[$nonce_name], $nonce ) ) ) { |
|
| 714 | 714 | $frm_settings = self::get_settings(); |
| 715 | 715 | $error = $frm_settings->admin_permission; |
| 716 | 716 | } |
@@ -790,7 +790,7 @@ discard block |
||
| 790 | 790 | } else { |
| 791 | 791 | foreach ( $value as $k => $v ) { |
| 792 | 792 | if ( ! is_array( $v ) ) { |
| 793 | - $value[ $k ] = call_user_func( $original_function, $v ); |
|
| 793 | + $value[$k] = call_user_func( $original_function, $v ); |
|
| 794 | 794 | } |
| 795 | 795 | } |
| 796 | 796 | } |
@@ -811,11 +811,11 @@ discard block |
||
| 811 | 811 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 812 | 812 | $return = array(); |
| 813 | 813 | foreach ( $array as $key => $value ) { |
| 814 | - if ( is_array($value) ) { |
|
| 814 | + if ( is_array( $value ) ) { |
|
| 815 | 815 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 816 | 816 | } else { |
| 817 | 817 | if ( $keys == 'keep' ) { |
| 818 | - $return[ $key ] = $value; |
|
| 818 | + $return[$key] = $value; |
|
| 819 | 819 | } else { |
| 820 | 820 | $return[] = $value; |
| 821 | 821 | } |
@@ -838,8 +838,8 @@ discard block |
||
| 838 | 838 | * @since 2.0 |
| 839 | 839 | */ |
| 840 | 840 | public static function use_wpautop( $content ) { |
| 841 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 842 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 841 | + if ( apply_filters( 'frm_use_wpautop', true ) ) { |
|
| 842 | + $content = wpautop( str_replace( '<br>', '<br />', $content ) ); |
|
| 843 | 843 | } |
| 844 | 844 | return $content; |
| 845 | 845 | } |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | */ |
| 859 | 859 | public static function jquery_ui_base_url() { |
| 860 | 860 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 861 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 861 | + $url = apply_filters( 'frm_jquery_ui_base_url', $url ); |
|
| 862 | 862 | return $url; |
| 863 | 863 | } |
| 864 | 864 | |
@@ -872,11 +872,11 @@ discard block |
||
| 872 | 872 | } |
| 873 | 873 | |
| 874 | 874 | $ver = $default; |
| 875 | - if ( ! isset( $wp_scripts->registered[ $handle ] ) ) { |
|
| 875 | + if ( ! isset( $wp_scripts->registered[$handle] ) ) { |
|
| 876 | 876 | return $ver; |
| 877 | 877 | } |
| 878 | 878 | |
| 879 | - $query = $wp_scripts->registered[ $handle ]; |
|
| 879 | + $query = $wp_scripts->registered[$handle]; |
|
| 880 | 880 | if ( is_object( $query ) && ! empty( $query->ver ) ) { |
| 881 | 881 | $ver = $query->ver; |
| 882 | 882 | } |
@@ -889,36 +889,36 @@ discard block |
||
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | public static function get_user_id_param( $user_id ) { |
| 892 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 892 | + if ( ! $user_id || empty( $user_id ) || is_numeric( $user_id ) ) { |
|
| 893 | 893 | return $user_id; |
| 894 | 894 | } |
| 895 | 895 | |
| 896 | 896 | if ( $user_id == 'current' ) { |
| 897 | 897 | $user_id = get_current_user_id(); |
| 898 | 898 | } else { |
| 899 | - if ( is_email($user_id) ) { |
|
| 900 | - $user = get_user_by('email', $user_id); |
|
| 899 | + if ( is_email( $user_id ) ) { |
|
| 900 | + $user = get_user_by( 'email', $user_id ); |
|
| 901 | 901 | } else { |
| 902 | - $user = get_user_by('login', $user_id); |
|
| 902 | + $user = get_user_by( 'login', $user_id ); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | if ( $user ) { |
| 906 | 906 | $user_id = $user->ID; |
| 907 | 907 | } |
| 908 | - unset($user); |
|
| 908 | + unset( $user ); |
|
| 909 | 909 | } |
| 910 | 910 | |
| 911 | 911 | return $user_id; |
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | public static function get_file_contents( $filename, $atts = array() ) { |
| 915 | - if ( ! is_file($filename) ) { |
|
| 915 | + if ( ! is_file( $filename ) ) { |
|
| 916 | 916 | return false; |
| 917 | 917 | } |
| 918 | 918 | |
| 919 | - extract($atts); |
|
| 919 | + extract( $atts ); |
|
| 920 | 920 | ob_start(); |
| 921 | - include($filename); |
|
| 921 | + include( $filename ); |
|
| 922 | 922 | $contents = ob_get_contents(); |
| 923 | 923 | ob_end_clean(); |
| 924 | 924 | return $contents; |
@@ -934,27 +934,27 @@ discard block |
||
| 934 | 934 | $key = ''; |
| 935 | 935 | |
| 936 | 936 | if ( ! empty( $name ) ) { |
| 937 | - $key = sanitize_key($name); |
|
| 937 | + $key = sanitize_key( $name ); |
|
| 938 | 938 | } |
| 939 | 939 | |
| 940 | 940 | if ( empty( $key ) ) { |
| 941 | - $max_slug_value = pow(36, $num_chars); |
|
| 941 | + $max_slug_value = pow( 36, $num_chars ); |
|
| 942 | 942 | $min_slug_value = 37; // we want to have at least 2 characters in the slug |
| 943 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 943 | + $key = base_convert( rand( $min_slug_value, $max_slug_value ), 10, 36 ); |
|
| 944 | 944 | } |
| 945 | 945 | |
| 946 | - if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
| 946 | + if ( is_numeric( $key ) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
|
| 947 | 947 | $key = $key . 'a'; |
| 948 | 948 | } |
| 949 | 949 | |
| 950 | 950 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
| 951 | 951 | |
| 952 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 952 | + if ( $key_check || is_numeric( $key_check ) ) { |
|
| 953 | 953 | $suffix = 2; |
| 954 | 954 | do { |
| 955 | 955 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 956 | 956 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
| 957 | - $suffix++; |
|
| 957 | + $suffix ++; |
|
| 958 | 958 | } while ( $key_check || is_numeric( $key_check ) ); |
| 959 | 959 | $key = $alt_post_name; |
| 960 | 960 | } |
@@ -971,32 +971,32 @@ discard block |
||
| 971 | 971 | return false; |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | - if ( empty($post_values) ) { |
|
| 975 | - $post_values = stripslashes_deep($_POST); |
|
| 974 | + if ( empty( $post_values ) ) { |
|
| 975 | + $post_values = stripslashes_deep( $_POST ); |
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | $values = array( 'id' => $record->id, 'fields' => array() ); |
| 979 | 979 | |
| 980 | 980 | foreach ( array( 'name', 'description' ) as $var ) { |
| 981 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 982 | - $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
| 983 | - unset($var, $default_val); |
|
| 981 | + $default_val = isset( $record->{$var}) ? $record->{$var} : ''; |
|
| 982 | + $values[$var] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
|
| 983 | + unset( $var, $default_val ); |
|
| 984 | 984 | } |
| 985 | 985 | |
| 986 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 986 | + $values['description'] = self::use_wpautop( $values['description'] ); |
|
| 987 | 987 | $frm_settings = self::get_settings(); |
| 988 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
| 988 | + $is_form_builder = self::is_admin_page( 'formidable' ); |
|
| 989 | 989 | |
| 990 | 990 | foreach ( (array) $fields as $field ) { |
| 991 | 991 | // Make sure to filter default values (for placeholder text), but not on the form builder page |
| 992 | 992 | if ( ! $is_form_builder ) { |
| 993 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 993 | + $field->default_value = apply_filters( 'frm_get_default_value', $field->default_value, $field, true ); |
|
| 994 | 994 | } |
| 995 | 995 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
| 996 | - self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
| 996 | + self::fill_field_defaults( $field, $record, $values, compact( 'default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
|
| 997 | 997 | } |
| 998 | 998 | |
| 999 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 999 | + self::fill_form_opts( $record, $table, $post_values, $values ); |
|
| 1000 | 1000 | |
| 1001 | 1001 | if ( $table == 'entries' ) { |
| 1002 | 1002 | $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
@@ -1013,8 +1013,8 @@ discard block |
||
| 1013 | 1013 | if ( $args['default'] ) { |
| 1014 | 1014 | $meta_value = $field->default_value; |
| 1015 | 1015 | } else { |
| 1016 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1017 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1016 | + if ( $record->post_id && self::pro_is_installed() && isset( $field->field_options['post_field'] ) && $field->field_options['post_field'] ) { |
|
| 1017 | + if ( ! isset( $field->field_options['custom_field'] ) ) { |
|
| 1018 | 1018 | $field->field_options['custom_field'] = ''; |
| 1019 | 1019 | } |
| 1020 | 1020 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
@@ -1023,8 +1023,8 @@ discard block |
||
| 1023 | 1023 | } |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | - $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
|
| 1027 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1026 | + $field_type = isset( $post_values['field_options']['type_' . $field->id] ) ? $post_values['field_options']['type_' . $field->id] : $field->type; |
|
| 1027 | + $new_value = isset( $post_values['item_meta'][$field->id] ) ? maybe_unserialize( $post_values['item_meta'][$field->id] ) : $meta_value; |
|
| 1028 | 1028 | |
| 1029 | 1029 | $field_array = array( |
| 1030 | 1030 | 'id' => $field->id, |
@@ -1032,7 +1032,7 @@ discard block |
||
| 1032 | 1032 | 'default_value' => $field->default_value, |
| 1033 | 1033 | 'name' => $field->name, |
| 1034 | 1034 | 'description' => $field->description, |
| 1035 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1035 | + 'type' => apply_filters( 'frm_field_type', $field_type, $field, $new_value ), |
|
| 1036 | 1036 | 'options' => $field->options, |
| 1037 | 1037 | 'required' => $field->required, |
| 1038 | 1038 | 'field_key' => $field->field_key, |
@@ -1042,40 +1042,40 @@ discard block |
||
| 1042 | 1042 | ); |
| 1043 | 1043 | |
| 1044 | 1044 | $args['field_type'] = $field_type; |
| 1045 | - self::fill_field_opts($field, $field_array, $args); |
|
| 1045 | + self::fill_field_opts( $field, $field_array, $args ); |
|
| 1046 | 1046 | // Track the original field's type |
| 1047 | 1047 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
| 1048 | 1048 | |
| 1049 | 1049 | $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
| 1050 | 1050 | |
| 1051 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1051 | + if ( ! isset( $field_array['unique'] ) || ! $field_array['unique'] ) { |
|
| 1052 | 1052 | $field_array['unique_msg'] = ''; |
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | 1055 | $field_array = array_merge( $field->field_options, $field_array ); |
| 1056 | 1056 | |
| 1057 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1057 | + $values['fields'][$field->id] = $field_array; |
|
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
| 1061 | 1061 | $post_values = $args['post_values']; |
| 1062 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1062 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts( $field_array['type'], $field, true ); |
|
| 1063 | 1063 | |
| 1064 | 1064 | foreach ( $opt_defaults as $opt => $default_opt ) { |
| 1065 | - $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
|
| 1066 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1067 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1068 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1065 | + $field_array[$opt] = ( $post_values && isset( $post_values['field_options'][$opt . '_' . $field->id] ) ) ? maybe_unserialize( $post_values['field_options'][$opt . '_' . $field->id] ) : ( isset( $field->field_options[$opt] ) ? $field->field_options[$opt] : $default_opt ); |
|
| 1066 | + if ( $opt == 'blank' && $field_array[$opt] == '' ) { |
|
| 1067 | + $field_array[$opt] = $args['frm_settings']->blank_msg; |
|
| 1068 | + } else if ( $opt == 'invalid' && $field_array[$opt] == '' ) { |
|
| 1069 | 1069 | if ( $args['field_type'] == 'captcha' ) { |
| 1070 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1070 | + $field_array[$opt] = $args['frm_settings']->re_msg; |
|
| 1071 | 1071 | } else { |
| 1072 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1072 | + $field_array[$opt] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1073 | 1073 | } |
| 1074 | 1074 | } |
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | 1077 | if ( $field_array['custom_html'] == '' ) { |
| 1078 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1078 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html( $args['field_type'] ); |
|
| 1079 | 1079 | } |
| 1080 | 1080 | } |
| 1081 | 1081 | |
@@ -1094,18 +1094,18 @@ discard block |
||
| 1094 | 1094 | return; |
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1097 | + $values['form_name'] = isset( $record->form_id ) ? $form->name : ''; |
|
| 1098 | 1098 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1099 | 1099 | |
| 1100 | - if ( ! is_array($form->options) ) { |
|
| 1100 | + if ( ! is_array( $form->options ) ) { |
|
| 1101 | 1101 | return; |
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | 1104 | foreach ( $form->options as $opt => $value ) { |
| 1105 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1105 | + $values[$opt] = isset( $post_values[$opt] ) ? maybe_unserialize( $post_values[$opt] ) : $value; |
|
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | - self::fill_form_defaults($post_values, $values); |
|
| 1108 | + self::fill_form_defaults( $post_values, $values ); |
|
| 1109 | 1109 | } |
| 1110 | 1110 | |
| 1111 | 1111 | /** |
@@ -1115,11 +1115,11 @@ discard block |
||
| 1115 | 1115 | $form_defaults = FrmFormsHelper::get_default_opts(); |
| 1116 | 1116 | |
| 1117 | 1117 | foreach ( $form_defaults as $opt => $default ) { |
| 1118 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1119 | - $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
|
| 1118 | + if ( ! isset( $values[$opt] ) || $values[$opt] == '' ) { |
|
| 1119 | + $values[$opt] = ( $post_values && isset( $post_values['options'][$opt] ) ) ? $post_values['options'][$opt] : $default; |
|
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | - unset($opt, $defaut); |
|
| 1122 | + unset( $opt, $defaut ); |
|
| 1123 | 1123 | } |
| 1124 | 1124 | |
| 1125 | 1125 | if ( ! isset( $values['custom_style'] ) ) { |
@@ -1127,10 +1127,10 @@ discard block |
||
| 1127 | 1127 | } |
| 1128 | 1128 | |
| 1129 | 1129 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1130 | - if ( ! isset( $values[ $h . '_html' ] ) ) { |
|
| 1131 | - $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1130 | + if ( ! isset( $values[$h . '_html'] ) ) { |
|
| 1131 | + $values[$h . '_html'] = ( isset( $post_values['options'][$h . '_html'] ) ? $post_values['options'][$h . '_html'] : FrmFormsHelper::get_default_html( $h ) ); |
|
| 1132 | 1132 | } |
| 1133 | - unset($h); |
|
| 1133 | + unset( $h ); |
|
| 1134 | 1134 | } |
| 1135 | 1135 | } |
| 1136 | 1136 | |
@@ -1161,9 +1161,9 @@ discard block |
||
| 1161 | 1161 | } |
| 1162 | 1162 | ?> |
| 1163 | 1163 | <li> |
| 1164 | - <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> |
|
| 1165 | - <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> |
|
| 1166 | - <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> |
|
| 1164 | + <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> |
|
| 1165 | + <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> |
|
| 1166 | + <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> |
|
| 1167 | 1167 | </li> |
| 1168 | 1168 | <?php |
| 1169 | 1169 | } |
@@ -1181,7 +1181,7 @@ discard block |
||
| 1181 | 1181 | return ''; |
| 1182 | 1182 | } else if ( $length <= 10 ) { |
| 1183 | 1183 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1184 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1184 | + return $sub . ( ( $length < $original_len ) ? $continue : '' ); |
|
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | 1187 | $sub = ''; |
@@ -1190,23 +1190,23 @@ discard block |
||
| 1190 | 1190 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1191 | 1191 | |
| 1192 | 1192 | foreach ( $words as $word ) { |
| 1193 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1193 | + $part = ( ( $sub != '' ) ? ' ' : '' ) . $word; |
|
| 1194 | 1194 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1195 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1195 | + if ( $total_len > $length && str_word_count( $sub ) ) { |
|
| 1196 | 1196 | break; |
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | 1199 | $sub .= $part; |
| 1200 | 1200 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1201 | 1201 | |
| 1202 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1202 | + if ( str_word_count( $sub ) > $minword && $total_len >= $length ) { |
|
| 1203 | 1203 | break; |
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | - unset($total_len, $word); |
|
| 1206 | + unset( $total_len, $word ); |
|
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1209 | + return $sub . ( ( $len < $original_len ) ? $continue : '' ); |
|
| 1210 | 1210 | } |
| 1211 | 1211 | |
| 1212 | 1212 | public static function mb_function( $function_names, $args ) { |
@@ -1219,17 +1219,17 @@ discard block |
||
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | 1221 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1222 | - if ( empty($date) ) { |
|
| 1222 | + if ( empty( $date ) ) { |
|
| 1223 | 1223 | return $date; |
| 1224 | 1224 | } |
| 1225 | 1225 | |
| 1226 | - if ( empty($date_format) ) { |
|
| 1227 | - $date_format = get_option('date_format'); |
|
| 1226 | + if ( empty( $date_format ) ) { |
|
| 1227 | + $date_format = get_option( 'date_format' ); |
|
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1230 | + if ( preg_match( '/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date ) && self::pro_is_installed() ) { |
|
| 1231 | 1231 | $frmpro_settings = new FrmProSettings(); |
| 1232 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1232 | + $date = FrmProAppHelper::convert_date( $date, $frmpro_settings->date_format, 'Y-m-d' ); |
|
| 1233 | 1233 | } |
| 1234 | 1234 | |
| 1235 | 1235 | $formatted = self::get_localized_date( $date_format, $date ); |
@@ -1244,7 +1244,7 @@ discard block |
||
| 1244 | 1244 | |
| 1245 | 1245 | private static function add_time_to_date( $time_format, $date ) { |
| 1246 | 1246 | if ( empty( $time_format ) ) { |
| 1247 | - $time_format = get_option('time_format'); |
|
| 1247 | + $time_format = get_option( 'time_format' ); |
|
| 1248 | 1248 | } |
| 1249 | 1249 | |
| 1250 | 1250 | $trimmed_format = trim( $time_format ); |
@@ -1290,10 +1290,10 @@ discard block |
||
| 1290 | 1290 | $time_strings = self::get_time_strings(); |
| 1291 | 1291 | |
| 1292 | 1292 | foreach ( $time_strings as $k => $v ) { |
| 1293 | - if ( $diff[ $k ] ) { |
|
| 1294 | - $time_strings[ $k ] = $diff[ $k ] . ' ' . ( $diff[ $k ] > 1 ? $v[1] : $v[0] ); |
|
| 1293 | + if ( $diff[$k] ) { |
|
| 1294 | + $time_strings[$k] = $diff[$k] . ' ' . ( $diff[$k] > 1 ? $v[1] : $v[0] ); |
|
| 1295 | 1295 | } else { |
| 1296 | - unset( $time_strings[ $k ] ); |
|
| 1296 | + unset( $time_strings[$k] ); |
|
| 1297 | 1297 | } |
| 1298 | 1298 | } |
| 1299 | 1299 | |
@@ -1332,7 +1332,7 @@ discard block |
||
| 1332 | 1332 | */ |
| 1333 | 1333 | public static function esc_like( $term ) { |
| 1334 | 1334 | global $wpdb; |
| 1335 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1335 | + if ( method_exists( $wpdb, 'esc_like' ) ) { |
|
| 1336 | 1336 | // WP 4.0 |
| 1337 | 1337 | $term = $wpdb->esc_like( $term ); |
| 1338 | 1338 | } else { |
@@ -1346,17 +1346,17 @@ discard block |
||
| 1346 | 1346 | * @param string $order_query |
| 1347 | 1347 | */ |
| 1348 | 1348 | public static function esc_order( $order_query ) { |
| 1349 | - if ( empty($order_query) ) { |
|
| 1349 | + if ( empty( $order_query ) ) { |
|
| 1350 | 1350 | return ''; |
| 1351 | 1351 | } |
| 1352 | 1352 | |
| 1353 | 1353 | // remove ORDER BY before santizing |
| 1354 | - $order_query = strtolower($order_query); |
|
| 1355 | - if ( strpos($order_query, 'order by') !== false ) { |
|
| 1356 | - $order_query = str_replace('order by', '', $order_query); |
|
| 1354 | + $order_query = strtolower( $order_query ); |
|
| 1355 | + if ( strpos( $order_query, 'order by' ) !== false ) { |
|
| 1356 | + $order_query = str_replace( 'order by', '', $order_query ); |
|
| 1357 | 1357 | } |
| 1358 | 1358 | |
| 1359 | - $order_query = explode(' ', trim($order_query)); |
|
| 1359 | + $order_query = explode( ' ', trim( $order_query ) ); |
|
| 1360 | 1360 | |
| 1361 | 1361 | $order_fields = array( |
| 1362 | 1362 | 'id', 'form_key', 'name', 'description', |
@@ -1364,13 +1364,13 @@ discard block |
||
| 1364 | 1364 | 'default_template', 'status', 'created_at', |
| 1365 | 1365 | ); |
| 1366 | 1366 | |
| 1367 | - $order = trim(trim(reset($order_query), ',')); |
|
| 1368 | - if ( ! in_array($order, $order_fields) ) { |
|
| 1367 | + $order = trim( trim( reset( $order_query ), ',' ) ); |
|
| 1368 | + if ( ! in_array( $order, $order_fields ) ) { |
|
| 1369 | 1369 | return ''; |
| 1370 | 1370 | } |
| 1371 | 1371 | |
| 1372 | 1372 | $order_by = ''; |
| 1373 | - if ( count($order_query) > 1 ) { |
|
| 1373 | + if ( count( $order_query ) > 1 ) { |
|
| 1374 | 1374 | $order_by = end( $order_query ); |
| 1375 | 1375 | self::esc_order_by( $order_by ); |
| 1376 | 1376 | } |
@@ -1392,23 +1392,23 @@ discard block |
||
| 1392 | 1392 | * @param string $limit |
| 1393 | 1393 | */ |
| 1394 | 1394 | public static function esc_limit( $limit ) { |
| 1395 | - if ( empty($limit) ) { |
|
| 1395 | + if ( empty( $limit ) ) { |
|
| 1396 | 1396 | return ''; |
| 1397 | 1397 | } |
| 1398 | 1398 | |
| 1399 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1400 | - if ( is_numeric($limit) ) { |
|
| 1399 | + $limit = trim( str_replace( ' limit', '', strtolower( $limit ) ) ); |
|
| 1400 | + if ( is_numeric( $limit ) ) { |
|
| 1401 | 1401 | return ' LIMIT ' . $limit; |
| 1402 | 1402 | } |
| 1403 | 1403 | |
| 1404 | - $limit = explode(',', trim($limit)); |
|
| 1404 | + $limit = explode( ',', trim( $limit ) ); |
|
| 1405 | 1405 | foreach ( $limit as $k => $l ) { |
| 1406 | 1406 | if ( is_numeric( $l ) ) { |
| 1407 | - $limit[ $k ] = $l; |
|
| 1407 | + $limit[$k] = $l; |
|
| 1408 | 1408 | } |
| 1409 | 1409 | } |
| 1410 | 1410 | |
| 1411 | - $limit = implode(',', $limit); |
|
| 1411 | + $limit = implode( ',', $limit ); |
|
| 1412 | 1412 | return ' LIMIT ' . $limit; |
| 1413 | 1413 | } |
| 1414 | 1414 | |
@@ -1417,12 +1417,12 @@ discard block |
||
| 1417 | 1417 | * @since 2.0 |
| 1418 | 1418 | */ |
| 1419 | 1419 | public static function prepare_array_values( $array, $type = '%s' ) { |
| 1420 | - $placeholders = array_fill(0, count($array), $type); |
|
| 1421 | - return implode(', ', $placeholders); |
|
| 1420 | + $placeholders = array_fill( 0, count( $array ), $type ); |
|
| 1421 | + return implode( ', ', $placeholders ); |
|
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | 1424 | public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
| 1425 | - if ( empty($where) ) { |
|
| 1425 | + if ( empty( $where ) ) { |
|
| 1426 | 1426 | return ''; |
| 1427 | 1427 | } |
| 1428 | 1428 | |
@@ -1463,19 +1463,19 @@ discard block |
||
| 1463 | 1463 | public static function json_to_array( $json_vars ) { |
| 1464 | 1464 | $vars = array(); |
| 1465 | 1465 | foreach ( $json_vars as $jv ) { |
| 1466 | - $jv_name = explode('[', $jv['name']); |
|
| 1467 | - $last = count($jv_name) - 1; |
|
| 1466 | + $jv_name = explode( '[', $jv['name'] ); |
|
| 1467 | + $last = count( $jv_name ) - 1; |
|
| 1468 | 1468 | foreach ( $jv_name as $p => $n ) { |
| 1469 | - $name = trim($n, ']'); |
|
| 1470 | - if ( ! isset($l1) ) { |
|
| 1469 | + $name = trim( $n, ']' ); |
|
| 1470 | + if ( ! isset( $l1 ) ) { |
|
| 1471 | 1471 | $l1 = $name; |
| 1472 | 1472 | } |
| 1473 | 1473 | |
| 1474 | - if ( ! isset($l2) ) { |
|
| 1474 | + if ( ! isset( $l2 ) ) { |
|
| 1475 | 1475 | $l2 = $name; |
| 1476 | 1476 | } |
| 1477 | 1477 | |
| 1478 | - if ( ! isset($l3) ) { |
|
| 1478 | + if ( ! isset( $l3 ) ) { |
|
| 1479 | 1479 | $l3 = $name; |
| 1480 | 1480 | } |
| 1481 | 1481 | |
@@ -1489,24 +1489,24 @@ discard block |
||
| 1489 | 1489 | |
| 1490 | 1490 | case 1: |
| 1491 | 1491 | $l2 = $name; |
| 1492 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1492 | + self::add_value_to_array( $name, $l2, $this_val, $vars[$l1] ); |
|
| 1493 | 1493 | break; |
| 1494 | 1494 | |
| 1495 | 1495 | case 2: |
| 1496 | 1496 | $l3 = $name; |
| 1497 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1497 | + self::add_value_to_array( $name, $l3, $this_val, $vars[$l1][$l2] ); |
|
| 1498 | 1498 | break; |
| 1499 | 1499 | |
| 1500 | 1500 | case 3: |
| 1501 | 1501 | $l4 = $name; |
| 1502 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1502 | + self::add_value_to_array( $name, $l4, $this_val, $vars[$l1][$l2][$l3] ); |
|
| 1503 | 1503 | break; |
| 1504 | 1504 | } |
| 1505 | 1505 | |
| 1506 | - unset($this_val, $n); |
|
| 1506 | + unset( $this_val, $n ); |
|
| 1507 | 1507 | } |
| 1508 | 1508 | |
| 1509 | - unset($last, $jv); |
|
| 1509 | + unset( $last, $jv ); |
|
| 1510 | 1510 | } |
| 1511 | 1511 | |
| 1512 | 1512 | return $vars; |
@@ -1519,8 +1519,8 @@ discard block |
||
| 1519 | 1519 | public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
| 1520 | 1520 | if ( $name == '' ) { |
| 1521 | 1521 | $vars[] = $val; |
| 1522 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1523 | - $vars[ $l1 ] = $val; |
|
| 1522 | + } else if ( ! isset( $vars[$l1] ) ) { |
|
| 1523 | + $vars[$l1] = $val; |
|
| 1524 | 1524 | } |
| 1525 | 1525 | } |
| 1526 | 1526 | |
@@ -1535,7 +1535,7 @@ discard block |
||
| 1535 | 1535 | '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() ) ), |
| 1536 | 1536 | ); |
| 1537 | 1537 | |
| 1538 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1538 | + if ( ! isset( $tooltips[$name] ) ) { |
|
| 1539 | 1539 | return; |
| 1540 | 1540 | } |
| 1541 | 1541 | |
@@ -1545,7 +1545,7 @@ discard block |
||
| 1545 | 1545 | echo ' class="frm_help"'; |
| 1546 | 1546 | } |
| 1547 | 1547 | |
| 1548 | - echo ' title="' . esc_attr( $tooltips[ $name ] ); |
|
| 1548 | + echo ' title="' . esc_attr( $tooltips[$name] ); |
|
| 1549 | 1549 | |
| 1550 | 1550 | if ( 'open' != $class ) { |
| 1551 | 1551 | echo '"'; |
@@ -1597,13 +1597,13 @@ discard block |
||
| 1597 | 1597 | } |
| 1598 | 1598 | |
| 1599 | 1599 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1600 | - if ( ! isset( $post_content[ $key ] ) ) { |
|
| 1600 | + if ( ! isset( $post_content[$key] ) ) { |
|
| 1601 | 1601 | return; |
| 1602 | 1602 | } |
| 1603 | 1603 | |
| 1604 | 1604 | if ( is_array( $val ) ) { |
| 1605 | 1605 | foreach ( $val as $k1 => $v1 ) { |
| 1606 | - self::prepare_action_slashes( $v1, $k1, $post_content[ $key ] ); |
|
| 1606 | + self::prepare_action_slashes( $v1, $k1, $post_content[$key] ); |
|
| 1607 | 1607 | unset( $k1, $v1 ); |
| 1608 | 1608 | } |
| 1609 | 1609 | } else { |
@@ -1611,7 +1611,7 @@ discard block |
||
| 1611 | 1611 | $val = stripslashes( $val ); |
| 1612 | 1612 | |
| 1613 | 1613 | // Add backslashes before double quotes and forward slashes only |
| 1614 | - $post_content[ $key ] = addcslashes( $val, '"\\/' ); |
|
| 1614 | + $post_content[$key] = addcslashes( $val, '"\\/' ); |
|
| 1615 | 1615 | } |
| 1616 | 1616 | } |
| 1617 | 1617 | |
@@ -1628,7 +1628,7 @@ discard block |
||
| 1628 | 1628 | $settings['post_content'] = FrmAppHelper::prepare_and_encode( $settings['post_content'] ); |
| 1629 | 1629 | |
| 1630 | 1630 | if ( empty( $settings['ID'] ) ) { |
| 1631 | - unset( $settings['ID']); |
|
| 1631 | + unset( $settings['ID'] ); |
|
| 1632 | 1632 | } |
| 1633 | 1633 | |
| 1634 | 1634 | // delete all caches for this group |
@@ -1662,17 +1662,17 @@ discard block |
||
| 1662 | 1662 | } |
| 1663 | 1663 | |
| 1664 | 1664 | public static function maybe_json_decode( $string ) { |
| 1665 | - if ( is_array($string) ) { |
|
| 1665 | + if ( is_array( $string ) ) { |
|
| 1666 | 1666 | return $string; |
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | - $new_string = json_decode($string, true); |
|
| 1670 | - if ( function_exists('json_last_error') ) { |
|
| 1669 | + $new_string = json_decode( $string, true ); |
|
| 1670 | + if ( function_exists( 'json_last_error' ) ) { |
|
| 1671 | 1671 | // php 5.3+ |
| 1672 | 1672 | if ( json_last_error() == JSON_ERROR_NONE ) { |
| 1673 | 1673 | $string = $new_string; |
| 1674 | 1674 | } |
| 1675 | - } else if ( isset($new_string) ) { |
|
| 1675 | + } else if ( isset( $new_string ) ) { |
|
| 1676 | 1676 | // php < 5.3 fallback |
| 1677 | 1677 | $string = $new_string; |
| 1678 | 1678 | } |
@@ -1688,11 +1688,11 @@ discard block |
||
| 1688 | 1688 | public static function maybe_highlight_menu( $post_type ) { |
| 1689 | 1689 | global $post; |
| 1690 | 1690 | |
| 1691 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1691 | + if ( isset( $_REQUEST['post_type'] ) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1692 | 1692 | return; |
| 1693 | 1693 | } |
| 1694 | 1694 | |
| 1695 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1695 | + if ( is_object( $post ) && $post->post_type != $post_type ) { |
|
| 1696 | 1696 | return; |
| 1697 | 1697 | } |
| 1698 | 1698 | |
@@ -1793,11 +1793,11 @@ discard block |
||
| 1793 | 1793 | $frm_version = self::plugin_version(); |
| 1794 | 1794 | |
| 1795 | 1795 | // check if Formidable meets minimum requirements |
| 1796 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1796 | + if ( version_compare( $frm_version, $min_version, '>=' ) ) { |
|
| 1797 | 1797 | return; |
| 1798 | 1798 | } |
| 1799 | 1799 | |
| 1800 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1800 | + $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' ); |
|
| 1801 | 1801 | 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">' . |
| 1802 | 1802 | __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
| 1803 | 1803 | '</div></td></tr>'; |
@@ -1805,38 +1805,38 @@ discard block |
||
| 1805 | 1805 | |
| 1806 | 1806 | public static function locales( $type = 'date' ) { |
| 1807 | 1807 | $locales = array( |
| 1808 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1809 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1810 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1808 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1809 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1810 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1811 | 1811 | 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
| 1812 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1813 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1812 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1813 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1814 | 1814 | 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
| 1815 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1816 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1815 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1816 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1817 | 1817 | 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
| 1818 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1818 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1819 | 1819 | 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
| 1820 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1820 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1821 | 1821 | 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
| 1822 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1822 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1823 | 1823 | 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
| 1824 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1825 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1826 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1827 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1828 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1824 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1825 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1826 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1827 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1828 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1829 | 1829 | 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
| 1830 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1830 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1831 | 1831 | 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
| 1832 | 1832 | 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
| 1833 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1833 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1834 | 1834 | 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
| 1835 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1835 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1836 | 1836 | 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
| 1837 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1838 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1839 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1837 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1838 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1839 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1840 | 1840 | ); |
| 1841 | 1841 | |
| 1842 | 1842 | if ( $type == 'captcha' ) { |
@@ -1855,8 +1855,8 @@ discard block |
||
| 1855 | 1855 | ); |
| 1856 | 1856 | } |
| 1857 | 1857 | |
| 1858 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1859 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1858 | + $locales = array_diff_key( $locales, array_flip( $unset ) ); |
|
| 1859 | + $locales = apply_filters( 'frm_locales', $locales ); |
|
| 1860 | 1860 | |
| 1861 | 1861 | return $locales; |
| 1862 | 1862 | } |
@@ -12,50 +12,50 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | public static $plug_version = '2.03.10b1'; |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * @since 1.07.02 |
|
| 17 | - * |
|
| 18 | - * @param none |
|
| 19 | - * @return string The version of this plugin |
|
| 20 | - */ |
|
| 21 | - public static function plugin_version() { |
|
| 22 | - return self::$plug_version; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - public static function plugin_folder() { |
|
| 26 | - return basename(self::plugin_path()); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public static function plugin_path() { |
|
| 30 | - return dirname(dirname(dirname(__FILE__))); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public static function plugin_url() { |
|
| 34 | - //prevously FRM_URL constant |
|
| 15 | + /** |
|
| 16 | + * @since 1.07.02 |
|
| 17 | + * |
|
| 18 | + * @param none |
|
| 19 | + * @return string The version of this plugin |
|
| 20 | + */ |
|
| 21 | + public static function plugin_version() { |
|
| 22 | + return self::$plug_version; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + public static function plugin_folder() { |
|
| 26 | + return basename(self::plugin_path()); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public static function plugin_path() { |
|
| 30 | + return dirname(dirname(dirname(__FILE__))); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public static function plugin_url() { |
|
| 34 | + //prevously FRM_URL constant |
|
| 35 | 35 | return plugins_url( '', self::plugin_path() . '/formidable.php' ); |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | public static function relative_plugin_url() { |
| 39 | 39 | return str_replace( array( 'https:', 'http:' ), '', self::plugin_url() ); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @return string Site URL |
|
| 44 | - */ |
|
| 45 | - public static function site_url() { |
|
| 46 | - return site_url(); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * Get the name of this site |
|
| 51 | - * Used for [sitename] shortcode |
|
| 52 | - * |
|
| 53 | - * @since 2.0 |
|
| 54 | - * @return string |
|
| 55 | - */ |
|
| 56 | - public static function site_name() { |
|
| 57 | - return get_option('blogname'); |
|
| 58 | - } |
|
| 42 | + /** |
|
| 43 | + * @return string Site URL |
|
| 44 | + */ |
|
| 45 | + public static function site_url() { |
|
| 46 | + return site_url(); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * Get the name of this site |
|
| 51 | + * Used for [sitename] shortcode |
|
| 52 | + * |
|
| 53 | + * @since 2.0 |
|
| 54 | + * @return string |
|
| 55 | + */ |
|
| 56 | + public static function site_name() { |
|
| 57 | + return get_option('blogname'); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | public static function make_affiliate_url( $url ) { |
| 61 | 61 | $affiliate_id = self::get_affiliate(); |
@@ -69,83 +69,83 @@ discard block |
||
| 69 | 69 | return ''; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * Get the Formidable settings |
|
| 74 | - * |
|
| 75 | - * @since 2.0 |
|
| 76 | - * |
|
| 77 | - * @param None |
|
| 78 | - * @return FrmSettings $frm_setings |
|
| 79 | - */ |
|
| 80 | - public static function get_settings() { |
|
| 81 | - global $frm_settings; |
|
| 82 | - if ( empty($frm_settings) ) { |
|
| 83 | - $frm_settings = new FrmSettings(); |
|
| 84 | - } |
|
| 85 | - return $frm_settings; |
|
| 86 | - } |
|
| 72 | + /** |
|
| 73 | + * Get the Formidable settings |
|
| 74 | + * |
|
| 75 | + * @since 2.0 |
|
| 76 | + * |
|
| 77 | + * @param None |
|
| 78 | + * @return FrmSettings $frm_setings |
|
| 79 | + */ |
|
| 80 | + public static function get_settings() { |
|
| 81 | + global $frm_settings; |
|
| 82 | + if ( empty($frm_settings) ) { |
|
| 83 | + $frm_settings = new FrmSettings(); |
|
| 84 | + } |
|
| 85 | + return $frm_settings; |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | public static function get_menu_name() { |
| 89 | 89 | $frm_settings = FrmAppHelper::get_settings(); |
| 90 | 90 | return $frm_settings->menu; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * Show a message in place of pro features |
|
| 95 | - * |
|
| 96 | - * @since 2.0 |
|
| 97 | - */ |
|
| 93 | + /** |
|
| 94 | + * Show a message in place of pro features |
|
| 95 | + * |
|
| 96 | + * @since 2.0 |
|
| 97 | + */ |
|
| 98 | 98 | public static function update_message() { |
| 99 | 99 | _deprecated_function( __FUNCTION__, '2.0.19' ); |
| 100 | - } |
|
| 101 | - |
|
| 102 | - public static function pro_is_installed() { |
|
| 103 | - return apply_filters('frm_pro_installed', false); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * Check for certain page in Formidable settings |
|
| 108 | - * |
|
| 109 | - * @since 2.0 |
|
| 110 | - * |
|
| 111 | - * @param string $page The name of the page to check |
|
| 112 | - * @return boolean |
|
| 113 | - */ |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + public static function pro_is_installed() { |
|
| 103 | + return apply_filters('frm_pro_installed', false); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * Check for certain page in Formidable settings |
|
| 108 | + * |
|
| 109 | + * @since 2.0 |
|
| 110 | + * |
|
| 111 | + * @param string $page The name of the page to check |
|
| 112 | + * @return boolean |
|
| 113 | + */ |
|
| 114 | 114 | public static function is_admin_page( $page = 'formidable' ) { |
| 115 | - global $pagenow; |
|
| 115 | + global $pagenow; |
|
| 116 | 116 | $get_page = self::simple_get( 'page', 'sanitize_title' ); |
| 117 | - if ( $pagenow ) { |
|
| 117 | + if ( $pagenow ) { |
|
| 118 | 118 | return $pagenow == 'admin.php' && $get_page == $page; |
| 119 | - } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | 121 | return is_admin() && $get_page == $page; |
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * Check for the form preview page |
|
| 126 | - * |
|
| 127 | - * @since 2.0 |
|
| 128 | - * |
|
| 129 | - * @param None |
|
| 130 | - * @return boolean |
|
| 131 | - */ |
|
| 132 | - public static function is_preview_page() { |
|
| 133 | - global $pagenow; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * Check for the form preview page |
|
| 126 | + * |
|
| 127 | + * @since 2.0 |
|
| 128 | + * |
|
| 129 | + * @param None |
|
| 130 | + * @return boolean |
|
| 131 | + */ |
|
| 132 | + public static function is_preview_page() { |
|
| 133 | + global $pagenow; |
|
| 134 | 134 | $action = FrmAppHelper::simple_get( 'action', 'sanitize_title' ); |
| 135 | 135 | return $pagenow && $pagenow == 'admin-ajax.php' && $action == 'frm_forms_preview'; |
| 136 | - } |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | - /** |
|
| 139 | - * Check for ajax except the form preview page |
|
| 140 | - * |
|
| 141 | - * @since 2.0 |
|
| 142 | - * |
|
| 143 | - * @param None |
|
| 144 | - * @return boolean |
|
| 145 | - */ |
|
| 146 | - public static function doing_ajax() { |
|
| 147 | - return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 148 | - } |
|
| 138 | + /** |
|
| 139 | + * Check for ajax except the form preview page |
|
| 140 | + * |
|
| 141 | + * @since 2.0 |
|
| 142 | + * |
|
| 143 | + * @param None |
|
| 144 | + * @return boolean |
|
| 145 | + */ |
|
| 146 | + public static function doing_ajax() { |
|
| 147 | + return defined('DOING_AJAX') && DOING_AJAX && ! self::is_preview_page(); |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | 150 | /** |
| 151 | 151 | * @since 2.0.8 |
@@ -155,102 +155,102 @@ discard block |
||
| 155 | 155 | return isset( $frm_vars['prevent_caching'] ) && $frm_vars['prevent_caching']; |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - /** |
|
| 159 | - * Check if on an admin page |
|
| 160 | - * |
|
| 161 | - * @since 2.0 |
|
| 162 | - * |
|
| 163 | - * @param None |
|
| 164 | - * @return boolean |
|
| 165 | - */ |
|
| 166 | - public static function is_admin() { |
|
| 167 | - return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * Check if value contains blank value or empty array |
|
| 172 | - * |
|
| 173 | - * @since 2.0 |
|
| 174 | - * @param mixed $value - value to check |
|
| 158 | + /** |
|
| 159 | + * Check if on an admin page |
|
| 160 | + * |
|
| 161 | + * @since 2.0 |
|
| 162 | + * |
|
| 163 | + * @param None |
|
| 164 | + * @return boolean |
|
| 165 | + */ |
|
| 166 | + public static function is_admin() { |
|
| 167 | + return is_admin() && ( ! defined('DOING_AJAX') || ! DOING_AJAX ); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * Check if value contains blank value or empty array |
|
| 172 | + * |
|
| 173 | + * @since 2.0 |
|
| 174 | + * @param mixed $value - value to check |
|
| 175 | 175 | * @param string |
| 176 | - * @return boolean |
|
| 177 | - */ |
|
| 178 | - public static function is_empty_value( $value, $empty = '' ) { |
|
| 179 | - return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 183 | - return ! self::is_empty_value( $value, $empty ); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * Get any value from the $_SERVER |
|
| 188 | - * |
|
| 189 | - * @since 2.0 |
|
| 190 | - * @param string $value |
|
| 191 | - * @return string |
|
| 192 | - */ |
|
| 176 | + * @return boolean |
|
| 177 | + */ |
|
| 178 | + public static function is_empty_value( $value, $empty = '' ) { |
|
| 179 | + return ( is_array( $value ) && empty( $value ) ) || $value == $empty; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + public static function is_not_empty_value( $value, $empty = '' ) { |
|
| 183 | + return ! self::is_empty_value( $value, $empty ); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * Get any value from the $_SERVER |
|
| 188 | + * |
|
| 189 | + * @since 2.0 |
|
| 190 | + * @param string $value |
|
| 191 | + * @return string |
|
| 192 | + */ |
|
| 193 | 193 | public static function get_server_value( $value ) { |
| 194 | - return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * Check for the IP address in several places |
|
| 199 | - * Used by [ip] shortcode |
|
| 200 | - * |
|
| 201 | - * @return string The IP address of the current user |
|
| 202 | - */ |
|
| 203 | - public static function get_ip_address() { |
|
| 194 | + return isset( $_SERVER[ $value ] ) ? wp_strip_all_tags( $_SERVER[ $value ] ) : ''; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * Check for the IP address in several places |
|
| 199 | + * Used by [ip] shortcode |
|
| 200 | + * |
|
| 201 | + * @return string The IP address of the current user |
|
| 202 | + */ |
|
| 203 | + public static function get_ip_address() { |
|
| 204 | 204 | $ip = ''; |
| 205 | - foreach ( array( |
|
| 206 | - 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 207 | - 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
| 208 | - ) as $key ) { |
|
| 209 | - if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 210 | - continue; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 214 | - $ip = trim($ip); // just to be safe |
|
| 215 | - |
|
| 216 | - if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 217 | - return $ip; |
|
| 218 | - } |
|
| 219 | - } |
|
| 220 | - } |
|
| 205 | + foreach ( array( |
|
| 206 | + 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 207 | + 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', |
|
| 208 | + ) as $key ) { |
|
| 209 | + if ( ! isset( $_SERVER[ $key ] ) ) { |
|
| 210 | + continue; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + foreach ( explode( ',', $_SERVER[ $key ] ) as $ip ) { |
|
| 214 | + $ip = trim($ip); // just to be safe |
|
| 215 | + |
|
| 216 | + if ( filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false ) { |
|
| 217 | + return $ip; |
|
| 218 | + } |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | 222 | return sanitize_text_field( $ip ); |
| 223 | - } |
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 226 | - if ( strpos($param, '[') ) { |
|
| 227 | - $params = explode('[', $param); |
|
| 228 | - $param = $params[0]; |
|
| 229 | - } |
|
| 225 | + public static function get_param( $param, $default = '', $src = 'get', $sanitize = '' ) { |
|
| 226 | + if ( strpos($param, '[') ) { |
|
| 227 | + $params = explode('[', $param); |
|
| 228 | + $param = $params[0]; |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | 231 | if ( $src == 'get' ) { |
| 232 | - $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 233 | - if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 234 | - $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 235 | - } |
|
| 232 | + $value = isset( $_POST[ $param ] ) ? stripslashes_deep( $_POST[ $param ] ) : ( isset( $_GET[ $param ] ) ? stripslashes_deep( $_GET[ $param ] ) : $default ); |
|
| 233 | + if ( ! isset( $_POST[ $param ] ) && isset( $_GET[ $param ] ) && ! is_array( $value ) ) { |
|
| 234 | + $value = stripslashes_deep( htmlspecialchars_decode( $_GET[ $param ] ) ); |
|
| 235 | + } |
|
| 236 | 236 | self::sanitize_value( $sanitize, $value ); |
| 237 | 237 | } else { |
| 238 | - $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
| 239 | - } |
|
| 238 | + $value = self::get_simple_request( array( 'type' => $src, 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | 241 | if ( isset( $params ) && is_array( $value ) && ! empty( $value ) ) { |
| 242 | - foreach ( $params as $k => $p ) { |
|
| 243 | - if ( ! $k || ! is_array($value) ) { |
|
| 244 | - continue; |
|
| 245 | - } |
|
| 242 | + foreach ( $params as $k => $p ) { |
|
| 243 | + if ( ! $k || ! is_array($value) ) { |
|
| 244 | + continue; |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - $p = trim($p, ']'); |
|
| 248 | - $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 249 | - } |
|
| 250 | - } |
|
| 247 | + $p = trim($p, ']'); |
|
| 248 | + $value = isset( $value[ $p ] ) ? $value[ $p ] : $default; |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - return $value; |
|
| 253 | - } |
|
| 252 | + return $value; |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | 255 | public static function get_post_param( $param, $default = '', $sanitize = '' ) { |
| 256 | 256 | return self::get_simple_request( array( 'type' => 'post', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | public static function simple_get( $param, $sanitize = 'sanitize_text_field', $default = '' ) { |
| 268 | 268 | return self::get_simple_request( array( 'type' => 'get', 'param' => $param, 'default' => $default, 'sanitize' => $sanitize ) ); |
| 269 | - } |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | 271 | /** |
| 272 | 272 | * Get a GET/POST/REQUEST value and sanitize it |
@@ -302,12 +302,12 @@ discard block |
||
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | - * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 306 | - * |
|
| 307 | - * @since 2.0.8 |
|
| 308 | - * @param string $value |
|
| 309 | - * @return string $value |
|
| 310 | - */ |
|
| 305 | + * Preserve backslashes in a value, but make sure value doesn't get compounding slashes |
|
| 306 | + * |
|
| 307 | + * @since 2.0.8 |
|
| 308 | + * @param string $value |
|
| 309 | + * @return string $value |
|
| 310 | + */ |
|
| 311 | 311 | public static function preserve_backslashes( $value ) { |
| 312 | 312 | // If backslashes have already been added, don't add them again |
| 313 | 313 | if ( strpos( $value, '\\\\' ) === false ) { |
@@ -329,14 +329,14 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | - public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 333 | - $temp_values = $values; |
|
| 334 | - foreach ( $temp_values as $k => $val ) { |
|
| 335 | - if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 332 | + public static function sanitize_request( $sanitize_method, &$values ) { |
|
| 333 | + $temp_values = $values; |
|
| 334 | + foreach ( $temp_values as $k => $val ) { |
|
| 335 | + if ( isset( $sanitize_method[ $k ] ) ) { |
|
| 336 | 336 | $values[ $k ] = call_user_func( $sanitize_method[ $k ], $val ); |
| 337 | - } |
|
| 338 | - } |
|
| 339 | - } |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | 341 | public static function sanitize_array( &$values ) { |
| 342 | 342 | $temp_values = $values; |
@@ -354,12 +354,12 @@ discard block |
||
| 354 | 354 | */ |
| 355 | 355 | public static function kses( $value, $allowed = array() ) { |
| 356 | 356 | $html = array( |
| 357 | - 'a' => array( |
|
| 357 | + 'a' => array( |
|
| 358 | 358 | 'href' => array(), |
| 359 | 359 | 'title' => array(), |
| 360 | 360 | 'id' => array(), |
| 361 | 361 | 'class' => array(), |
| 362 | - ), |
|
| 362 | + ), |
|
| 363 | 363 | ); |
| 364 | 364 | |
| 365 | 365 | $allowed_html = array(); |
@@ -370,77 +370,77 @@ discard block |
||
| 370 | 370 | return wp_kses( $value, $allowed_html ); |
| 371 | 371 | } |
| 372 | 372 | |
| 373 | - /** |
|
| 374 | - * Used when switching the action for a bulk action |
|
| 375 | - * @since 2.0 |
|
| 376 | - */ |
|
| 377 | - public static function remove_get_action() { |
|
| 378 | - if ( ! isset($_GET) ) { |
|
| 379 | - return; |
|
| 380 | - } |
|
| 373 | + /** |
|
| 374 | + * Used when switching the action for a bulk action |
|
| 375 | + * @since 2.0 |
|
| 376 | + */ |
|
| 377 | + public static function remove_get_action() { |
|
| 378 | + if ( ! isset($_GET) ) { |
|
| 379 | + return; |
|
| 380 | + } |
|
| 381 | 381 | |
| 382 | - $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 383 | - if ( ! empty( $new_action ) ) { |
|
| 382 | + $new_action = isset( $_GET['action'] ) ? sanitize_text_field( $_GET['action'] ) : ( isset( $_GET['action2'] ) ? sanitize_text_field( $_GET['action2'] ) : '' ); |
|
| 383 | + if ( ! empty( $new_action ) ) { |
|
| 384 | 384 | $_SERVER['REQUEST_URI'] = str_replace( '&action=' . $new_action, '', FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 385 | - } |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - /** |
|
| 389 | - * Check the WP query for a parameter |
|
| 390 | - * |
|
| 391 | - * @since 2.0 |
|
| 392 | - * @return string|array |
|
| 393 | - */ |
|
| 394 | - public static function get_query_var( $value, $param ) { |
|
| 395 | - if ( $value != '' ) { |
|
| 396 | - return $value; |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - global $wp_query; |
|
| 400 | - if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 401 | - $value = $wp_query->query_vars[ $param ]; |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - return $value; |
|
| 405 | - } |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * @param string $type |
|
| 409 | - */ |
|
| 410 | - public static function trigger_hook_load( $type, $object = null ) { |
|
| 411 | - // only load the form hooks once |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + /** |
|
| 389 | + * Check the WP query for a parameter |
|
| 390 | + * |
|
| 391 | + * @since 2.0 |
|
| 392 | + * @return string|array |
|
| 393 | + */ |
|
| 394 | + public static function get_query_var( $value, $param ) { |
|
| 395 | + if ( $value != '' ) { |
|
| 396 | + return $value; |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + global $wp_query; |
|
| 400 | + if ( isset( $wp_query->query_vars[ $param ] ) ) { |
|
| 401 | + $value = $wp_query->query_vars[ $param ]; |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + return $value; |
|
| 405 | + } |
|
| 406 | + |
|
| 407 | + /** |
|
| 408 | + * @param string $type |
|
| 409 | + */ |
|
| 410 | + public static function trigger_hook_load( $type, $object = null ) { |
|
| 411 | + // only load the form hooks once |
|
| 412 | 412 | $hooks_loaded = apply_filters( 'frm_' . $type . '_hooks_loaded', false, $object ); |
| 413 | - if ( ! $hooks_loaded ) { |
|
| 413 | + if ( ! $hooks_loaded ) { |
|
| 414 | 414 | do_action( 'frm_load_' . $type . '_hooks' ); |
| 415 | - } |
|
| 416 | - } |
|
| 417 | - |
|
| 418 | - /** |
|
| 419 | - * Check cache before fetching values and saving to cache |
|
| 420 | - * |
|
| 421 | - * @since 2.0 |
|
| 422 | - * |
|
| 423 | - * @param string $cache_key The unique name for this cache |
|
| 424 | - * @param string $group The name of the cache group |
|
| 425 | - * @param string $query If blank, don't run a db call |
|
| 426 | - * @param string $type The wpdb function to use with this query |
|
| 427 | - * @return mixed $results The cache or query results |
|
| 428 | - */ |
|
| 429 | - public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
| 430 | - $results = wp_cache_get($cache_key, $group); |
|
| 431 | - if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 432 | - return $results; |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - if ( 'get_posts' == $type ) { |
|
| 436 | - $results = get_posts($query); |
|
| 415 | + } |
|
| 416 | + } |
|
| 417 | + |
|
| 418 | + /** |
|
| 419 | + * Check cache before fetching values and saving to cache |
|
| 420 | + * |
|
| 421 | + * @since 2.0 |
|
| 422 | + * |
|
| 423 | + * @param string $cache_key The unique name for this cache |
|
| 424 | + * @param string $group The name of the cache group |
|
| 425 | + * @param string $query If blank, don't run a db call |
|
| 426 | + * @param string $type The wpdb function to use with this query |
|
| 427 | + * @return mixed $results The cache or query results |
|
| 428 | + */ |
|
| 429 | + public static function check_cache( $cache_key, $group = '', $query = '', $type = 'get_var', $time = 300 ) { |
|
| 430 | + $results = wp_cache_get($cache_key, $group); |
|
| 431 | + if ( ! self::is_empty_value( $results, false ) || empty($query) ) { |
|
| 432 | + return $results; |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + if ( 'get_posts' == $type ) { |
|
| 436 | + $results = get_posts($query); |
|
| 437 | 437 | } else if ( 'get_associative_results' == $type ) { |
| 438 | 438 | global $wpdb; |
| 439 | 439 | $results = $wpdb->get_results( $query, OBJECT_K ); |
| 440 | - } else { |
|
| 441 | - global $wpdb; |
|
| 442 | - $results = $wpdb->{$type}($query); |
|
| 443 | - } |
|
| 440 | + } else { |
|
| 441 | + global $wpdb; |
|
| 442 | + $results = $wpdb->{$type}($query); |
|
| 443 | + } |
|
| 444 | 444 | |
| 445 | 445 | self::set_cache( $cache_key, $results, $group, $time ); |
| 446 | 446 | |
@@ -473,44 +473,44 @@ discard block |
||
| 473 | 473 | return $cached; |
| 474 | 474 | } |
| 475 | 475 | |
| 476 | - /** |
|
| 477 | - * Data that should be stored for a long time can be stored in a transient. |
|
| 478 | - * First check the cache, then check the transient |
|
| 479 | - * @since 2.0 |
|
| 480 | - * @return mixed The cached value or false |
|
| 481 | - */ |
|
| 476 | + /** |
|
| 477 | + * Data that should be stored for a long time can be stored in a transient. |
|
| 478 | + * First check the cache, then check the transient |
|
| 479 | + * @since 2.0 |
|
| 480 | + * @return mixed The cached value or false |
|
| 481 | + */ |
|
| 482 | 482 | public static function check_cache_and_transient( $cache_key ) { |
| 483 | - // check caching layer first |
|
| 484 | - $results = self::check_cache( $cache_key ); |
|
| 485 | - if ( $results ) { |
|
| 486 | - return $results; |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - // then check the transient |
|
| 490 | - $results = get_transient($cache_key); |
|
| 491 | - if ( $results ) { |
|
| 492 | - wp_cache_set($cache_key, $results); |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - return $results; |
|
| 496 | - } |
|
| 497 | - |
|
| 498 | - /** |
|
| 499 | - * @since 2.0 |
|
| 500 | - * @param string $cache_key |
|
| 501 | - */ |
|
| 483 | + // check caching layer first |
|
| 484 | + $results = self::check_cache( $cache_key ); |
|
| 485 | + if ( $results ) { |
|
| 486 | + return $results; |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + // then check the transient |
|
| 490 | + $results = get_transient($cache_key); |
|
| 491 | + if ( $results ) { |
|
| 492 | + wp_cache_set($cache_key, $results); |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + return $results; |
|
| 496 | + } |
|
| 497 | + |
|
| 498 | + /** |
|
| 499 | + * @since 2.0 |
|
| 500 | + * @param string $cache_key |
|
| 501 | + */ |
|
| 502 | 502 | public static function delete_cache_and_transient( $cache_key, $group = 'default' ) { |
| 503 | 503 | delete_transient($cache_key); |
| 504 | 504 | wp_cache_delete( $cache_key, $group ); |
| 505 | 505 | } |
| 506 | 506 | |
| 507 | - /** |
|
| 508 | - * Delete all caching in a single group |
|
| 509 | - * |
|
| 510 | - * @since 2.0 |
|
| 511 | - * |
|
| 512 | - * @param string $group The name of the cache group |
|
| 513 | - */ |
|
| 507 | + /** |
|
| 508 | + * Delete all caching in a single group |
|
| 509 | + * |
|
| 510 | + * @since 2.0 |
|
| 511 | + * |
|
| 512 | + * @param string $group The name of the cache group |
|
| 513 | + */ |
|
| 514 | 514 | public static function cache_delete_group( $group ) { |
| 515 | 515 | $cached_keys = self::get_group_cached_keys( $group ); |
| 516 | 516 | |
@@ -523,34 +523,34 @@ discard block |
||
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - /** |
|
| 527 | - * Check a value from a shortcode to see if true or false. |
|
| 528 | - * True when value is 1, true, 'true', 'yes' |
|
| 529 | - * |
|
| 530 | - * @since 1.07.10 |
|
| 531 | - * |
|
| 532 | - * @param string $value The value to compare |
|
| 533 | - * @return boolean True or False |
|
| 534 | - */ |
|
| 526 | + /** |
|
| 527 | + * Check a value from a shortcode to see if true or false. |
|
| 528 | + * True when value is 1, true, 'true', 'yes' |
|
| 529 | + * |
|
| 530 | + * @since 1.07.10 |
|
| 531 | + * |
|
| 532 | + * @param string $value The value to compare |
|
| 533 | + * @return boolean True or False |
|
| 534 | + */ |
|
| 535 | 535 | public static function is_true( $value ) { |
| 536 | - return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 537 | - } |
|
| 536 | + return ( true === $value || 1 == $value || 'true' == $value || 'yes' == $value ); |
|
| 537 | + } |
|
| 538 | 538 | |
| 539 | - /** |
|
| 540 | - * Used to filter shortcode in text widgets |
|
| 541 | - */ |
|
| 542 | - public static function widget_text_filter_callback( $matches ) { |
|
| 543 | - return do_shortcode( $matches[0] ); |
|
| 544 | - } |
|
| 539 | + /** |
|
| 540 | + * Used to filter shortcode in text widgets |
|
| 541 | + */ |
|
| 542 | + public static function widget_text_filter_callback( $matches ) { |
|
| 543 | + return do_shortcode( $matches[0] ); |
|
| 544 | + } |
|
| 545 | 545 | |
| 546 | - public static function get_pages() { |
|
| 546 | + public static function get_pages() { |
|
| 547 | 547 | return get_posts( array( 'post_type' => 'page', 'post_status' => array( 'publish', 'private' ), 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' ) ); |
| 548 | - } |
|
| 548 | + } |
|
| 549 | 549 | |
| 550 | - public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 551 | - $pages = self::get_pages(); |
|
| 550 | + public static function wp_pages_dropdown( $field_name, $page_id, $truncate = false ) { |
|
| 551 | + $pages = self::get_pages(); |
|
| 552 | 552 | $selected = self::get_post_param( $field_name, $page_id, 'absint' ); |
| 553 | - ?> |
|
| 553 | + ?> |
|
| 554 | 554 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" class="frm-pages-dropdown"> |
| 555 | 555 | <option value=""> </option> |
| 556 | 556 | <?php foreach ( $pages as $page ) { ?> |
@@ -560,108 +560,108 @@ discard block |
||
| 560 | 560 | <?php } ?> |
| 561 | 561 | </select> |
| 562 | 562 | <?php |
| 563 | - } |
|
| 563 | + } |
|
| 564 | 564 | |
| 565 | 565 | public static function post_edit_link( $post_id ) { |
| 566 | - $post = get_post($post_id); |
|
| 567 | - if ( $post ) { |
|
| 566 | + $post = get_post($post_id); |
|
| 567 | + if ( $post ) { |
|
| 568 | 568 | $post_url = admin_url( 'post.php?post=' . $post_id . '&action=edit' ); |
| 569 | 569 | return '<a href="' . esc_url( $post_url ) . '">' . self::truncate( $post->post_title, 50 ) . '</a>'; |
| 570 | - } |
|
| 571 | - return ''; |
|
| 572 | - } |
|
| 570 | + } |
|
| 571 | + return ''; |
|
| 572 | + } |
|
| 573 | 573 | |
| 574 | 574 | public static function wp_roles_dropdown( $field_name, $capability, $multiple = 'single' ) { |
| 575 | - ?> |
|
| 575 | + ?> |
|
| 576 | 576 | <select name="<?php echo esc_attr($field_name); ?>" id="<?php echo esc_attr($field_name); ?>" <?php |
| 577 | - echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
| 578 | - ?> class="frm_multiselect"> |
|
| 577 | + echo ( 'multiple' == $multiple ) ? 'multiple="multiple"' : ''; |
|
| 578 | + ?> class="frm_multiselect"> |
|
| 579 | 579 | <?php self::roles_options($capability); ?> |
| 580 | 580 | </select> |
| 581 | 581 | <?php |
| 582 | - } |
|
| 582 | + } |
|
| 583 | 583 | |
| 584 | 584 | public static function roles_options( $capability ) { |
| 585 | - global $frm_vars; |
|
| 586 | - if ( isset($frm_vars['editable_roles']) ) { |
|
| 587 | - $editable_roles = $frm_vars['editable_roles']; |
|
| 588 | - } else { |
|
| 589 | - $editable_roles = get_editable_roles(); |
|
| 590 | - $frm_vars['editable_roles'] = $editable_roles; |
|
| 591 | - } |
|
| 592 | - |
|
| 593 | - foreach ( $editable_roles as $role => $details ) { |
|
| 594 | - $name = translate_user_role($details['name'] ); ?> |
|
| 585 | + global $frm_vars; |
|
| 586 | + if ( isset($frm_vars['editable_roles']) ) { |
|
| 587 | + $editable_roles = $frm_vars['editable_roles']; |
|
| 588 | + } else { |
|
| 589 | + $editable_roles = get_editable_roles(); |
|
| 590 | + $frm_vars['editable_roles'] = $editable_roles; |
|
| 591 | + } |
|
| 592 | + |
|
| 593 | + foreach ( $editable_roles as $role => $details ) { |
|
| 594 | + $name = translate_user_role($details['name'] ); ?> |
|
| 595 | 595 | <option value="<?php echo esc_attr($role) ?>" <?php echo in_array($role, (array) $capability) ? ' selected="selected"' : ''; ?>><?php echo esc_attr($name) ?> </option> |
| 596 | 596 | <?php |
| 597 | - unset($role, $details); |
|
| 598 | - } |
|
| 599 | - } |
|
| 597 | + unset($role, $details); |
|
| 598 | + } |
|
| 599 | + } |
|
| 600 | 600 | |
| 601 | 601 | public static function frm_capabilities( $type = 'auto' ) { |
| 602 | - $cap = array( |
|
| 603 | - 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 604 | - 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 605 | - 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 606 | - 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 607 | - 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 608 | - 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 609 | - ); |
|
| 602 | + $cap = array( |
|
| 603 | + 'frm_view_forms' => __( 'View Forms and Templates', 'formidable' ), |
|
| 604 | + 'frm_edit_forms' => __( 'Add/Edit Forms and Templates', 'formidable' ), |
|
| 605 | + 'frm_delete_forms' => __( 'Delete Forms and Templates', 'formidable' ), |
|
| 606 | + 'frm_change_settings' => __( 'Access this Settings Page', 'formidable' ), |
|
| 607 | + 'frm_view_entries' => __( 'View Entries from Admin Area', 'formidable' ), |
|
| 608 | + 'frm_delete_entries' => __( 'Delete Entries from Admin Area', 'formidable' ), |
|
| 609 | + ); |
|
| 610 | 610 | |
| 611 | 611 | if ( ! self::pro_is_installed() && 'pro' != $type ) { |
| 612 | - return $cap; |
|
| 613 | - } |
|
| 612 | + return $cap; |
|
| 613 | + } |
|
| 614 | 614 | |
| 615 | - $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 616 | - $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 617 | - $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 618 | - $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 615 | + $cap['frm_create_entries'] = __( 'Add Entries from Admin Area', 'formidable' ); |
|
| 616 | + $cap['frm_edit_entries'] = __( 'Edit Entries from Admin Area', 'formidable' ); |
|
| 617 | + $cap['frm_view_reports'] = __( 'View Reports', 'formidable' ); |
|
| 618 | + $cap['frm_edit_displays'] = __( 'Add/Edit Views', 'formidable' ); |
|
| 619 | 619 | |
| 620 | - return $cap; |
|
| 621 | - } |
|
| 620 | + return $cap; |
|
| 621 | + } |
|
| 622 | 622 | |
| 623 | 623 | public static function user_has_permission( $needed_role ) { |
| 624 | - if ( $needed_role == '-1' ) { |
|
| 625 | - return false; |
|
| 624 | + if ( $needed_role == '-1' ) { |
|
| 625 | + return false; |
|
| 626 | 626 | } |
| 627 | 627 | |
| 628 | - // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 629 | - if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 630 | - return true; |
|
| 631 | - } |
|
| 628 | + // $needed_role will be equal to blank if "Logged-in users" is selected |
|
| 629 | + if ( ( $needed_role == '' && is_user_logged_in() ) || current_user_can( $needed_role ) ) { |
|
| 630 | + return true; |
|
| 631 | + } |
|
| 632 | 632 | |
| 633 | - $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 634 | - foreach ( $roles as $role ) { |
|
| 633 | + $roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' ); |
|
| 634 | + foreach ( $roles as $role ) { |
|
| 635 | 635 | if ( current_user_can( $role ) ) { |
| 636 | - return true; |
|
| 636 | + return true; |
|
| 637 | 637 | } |
| 638 | - if ( $role == $needed_role ) { |
|
| 639 | - break; |
|
| 638 | + if ( $role == $needed_role ) { |
|
| 639 | + break; |
|
| 640 | 640 | } |
| 641 | - } |
|
| 642 | - return false; |
|
| 643 | - } |
|
| 644 | - |
|
| 645 | - /** |
|
| 646 | - * Make sure administrators can see Formidable menu |
|
| 647 | - * |
|
| 648 | - * @since 2.0 |
|
| 649 | - */ |
|
| 650 | - public static function maybe_add_permissions() { |
|
| 641 | + } |
|
| 642 | + return false; |
|
| 643 | + } |
|
| 644 | + |
|
| 645 | + /** |
|
| 646 | + * Make sure administrators can see Formidable menu |
|
| 647 | + * |
|
| 648 | + * @since 2.0 |
|
| 649 | + */ |
|
| 650 | + public static function maybe_add_permissions() { |
|
| 651 | 651 | self::force_capability( 'frm_view_entries' ); |
| 652 | 652 | |
| 653 | - if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 654 | - return; |
|
| 655 | - } |
|
| 653 | + if ( ! current_user_can('administrator') || current_user_can('frm_view_forms') ) { |
|
| 654 | + return; |
|
| 655 | + } |
|
| 656 | 656 | |
| 657 | 657 | $user_id = get_current_user_id(); |
| 658 | 658 | $user = new WP_User( $user_id ); |
| 659 | - $frm_roles = self::frm_capabilities(); |
|
| 660 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 659 | + $frm_roles = self::frm_capabilities(); |
|
| 660 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 661 | 661 | $user->add_cap( $frm_role ); |
| 662 | - unset($frm_role, $frm_role_description); |
|
| 663 | - } |
|
| 664 | - } |
|
| 662 | + unset($frm_role, $frm_role_description); |
|
| 663 | + } |
|
| 664 | + } |
|
| 665 | 665 | |
| 666 | 666 | /** |
| 667 | 667 | * Make sure admins have permission to see the menu items |
@@ -677,28 +677,28 @@ discard block |
||
| 677 | 677 | } |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | - /** |
|
| 681 | - * Check if the user has permision for action. |
|
| 682 | - * Return permission message and stop the action if no permission |
|
| 683 | - * @since 2.0 |
|
| 684 | - * @param string $permission |
|
| 685 | - */ |
|
| 680 | + /** |
|
| 681 | + * Check if the user has permision for action. |
|
| 682 | + * Return permission message and stop the action if no permission |
|
| 683 | + * @since 2.0 |
|
| 684 | + * @param string $permission |
|
| 685 | + */ |
|
| 686 | 686 | public static function permission_check( $permission, $show_message = 'show' ) { |
| 687 | - $permission_error = self::permission_nonce_error($permission); |
|
| 688 | - if ( $permission_error !== false ) { |
|
| 689 | - if ( 'hide' == $show_message ) { |
|
| 690 | - $permission_error = ''; |
|
| 691 | - } |
|
| 692 | - wp_die($permission_error); |
|
| 693 | - } |
|
| 694 | - } |
|
| 695 | - |
|
| 696 | - /** |
|
| 697 | - * Check user permission and nonce |
|
| 698 | - * @since 2.0 |
|
| 699 | - * @param string $permission |
|
| 700 | - * @return false|string The permission message or false if allowed |
|
| 701 | - */ |
|
| 687 | + $permission_error = self::permission_nonce_error($permission); |
|
| 688 | + if ( $permission_error !== false ) { |
|
| 689 | + if ( 'hide' == $show_message ) { |
|
| 690 | + $permission_error = ''; |
|
| 691 | + } |
|
| 692 | + wp_die($permission_error); |
|
| 693 | + } |
|
| 694 | + } |
|
| 695 | + |
|
| 696 | + /** |
|
| 697 | + * Check user permission and nonce |
|
| 698 | + * @since 2.0 |
|
| 699 | + * @param string $permission |
|
| 700 | + * @return false|string The permission message or false if allowed |
|
| 701 | + */ |
|
| 702 | 702 | public static function permission_nonce_error( $permission, $nonce_name = '', $nonce = '' ) { |
| 703 | 703 | if ( ! empty( $permission ) && ! current_user_can( $permission ) && ! current_user_can( 'administrator' ) ) { |
| 704 | 704 | $frm_settings = self::get_settings(); |
@@ -706,23 +706,23 @@ discard block |
||
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | $error = false; |
| 709 | - if ( empty($nonce_name) ) { |
|
| 710 | - return $error; |
|
| 711 | - } |
|
| 709 | + if ( empty($nonce_name) ) { |
|
| 710 | + return $error; |
|
| 711 | + } |
|
| 712 | 712 | |
| 713 | - if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 714 | - $frm_settings = self::get_settings(); |
|
| 715 | - $error = $frm_settings->admin_permission; |
|
| 716 | - } |
|
| 713 | + if ( $_REQUEST && ( ! isset( $_REQUEST[ $nonce_name ] ) || ! wp_verify_nonce( $_REQUEST[ $nonce_name ], $nonce ) ) ) { |
|
| 714 | + $frm_settings = self::get_settings(); |
|
| 715 | + $error = $frm_settings->admin_permission; |
|
| 716 | + } |
|
| 717 | 717 | |
| 718 | - return $error; |
|
| 719 | - } |
|
| 718 | + return $error; |
|
| 719 | + } |
|
| 720 | 720 | |
| 721 | - public static function checked( $values, $current ) { |
|
| 721 | + public static function checked( $values, $current ) { |
|
| 722 | 722 | if ( self::check_selected( $values, $current ) ) { |
| 723 | - echo ' checked="checked"'; |
|
| 723 | + echo ' checked="checked"'; |
|
| 724 | 724 | } |
| 725 | - } |
|
| 725 | + } |
|
| 726 | 726 | |
| 727 | 727 | public static function check_selected( $values, $current ) { |
| 728 | 728 | $values = self::recursive_function_map( $values, 'trim' ); |
@@ -732,50 +732,50 @@ discard block |
||
| 732 | 732 | return ( is_array( $values ) && in_array( $current, $values ) ) || ( ! is_array( $values ) && $values == $current ); |
| 733 | 733 | } |
| 734 | 734 | |
| 735 | - /** |
|
| 736 | - * Check if current field option is an "other" option |
|
| 737 | - * |
|
| 738 | - * @since 2.0 |
|
| 739 | - * |
|
| 740 | - * @param string $opt_key |
|
| 741 | - * @return boolean Returns true if current field option is an "Other" option |
|
| 742 | - */ |
|
| 743 | - public static function is_other_opt( $opt_key ) { |
|
| 744 | - _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
| 745 | - return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
| 746 | - } |
|
| 747 | - |
|
| 748 | - /** |
|
| 749 | - * Get value that belongs in "Other" text box |
|
| 750 | - * |
|
| 751 | - * @since 2.0 |
|
| 752 | - * |
|
| 753 | - * @param string $opt_key |
|
| 754 | - * @param array $field |
|
| 755 | - * @return string $other_val |
|
| 756 | - */ |
|
| 757 | - public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
| 735 | + /** |
|
| 736 | + * Check if current field option is an "other" option |
|
| 737 | + * |
|
| 738 | + * @since 2.0 |
|
| 739 | + * |
|
| 740 | + * @param string $opt_key |
|
| 741 | + * @return boolean Returns true if current field option is an "Other" option |
|
| 742 | + */ |
|
| 743 | + public static function is_other_opt( $opt_key ) { |
|
| 744 | + _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::is_other_opt' ); |
|
| 745 | + return FrmFieldsHelper::is_other_opt( $opt_key ); |
|
| 746 | + } |
|
| 747 | + |
|
| 748 | + /** |
|
| 749 | + * Get value that belongs in "Other" text box |
|
| 750 | + * |
|
| 751 | + * @since 2.0 |
|
| 752 | + * |
|
| 753 | + * @param string $opt_key |
|
| 754 | + * @param array $field |
|
| 755 | + * @return string $other_val |
|
| 756 | + */ |
|
| 757 | + public static function get_other_val( $opt_key, $field, $parent = false, $pointer = false ) { |
|
| 758 | 758 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::get_other_val' ); |
| 759 | 759 | return FrmFieldsHelper::get_other_val( compact( 'opt_key', 'field', 'parent', 'pointer' ) ); |
| 760 | - } |
|
| 761 | - |
|
| 762 | - /** |
|
| 763 | - * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 764 | - * Intended for front-end use |
|
| 765 | - * |
|
| 766 | - * @since 2.0 |
|
| 767 | - * |
|
| 768 | - * @param array $field |
|
| 769 | - * @param boolean $other_opt |
|
| 770 | - * @param string $checked |
|
| 771 | - * @param array $args should include opt_key and field name |
|
| 772 | - * @return string $other_val |
|
| 773 | - */ |
|
| 774 | - public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
| 760 | + } |
|
| 761 | + |
|
| 762 | + /** |
|
| 763 | + * Check if there is a saved value for the "Other" text field. If so, set it as the $other_val. |
|
| 764 | + * Intended for front-end use |
|
| 765 | + * |
|
| 766 | + * @since 2.0 |
|
| 767 | + * |
|
| 768 | + * @param array $field |
|
| 769 | + * @param boolean $other_opt |
|
| 770 | + * @param string $checked |
|
| 771 | + * @param array $args should include opt_key and field name |
|
| 772 | + * @return string $other_val |
|
| 773 | + */ |
|
| 774 | + public static function prepare_other_input( $field, &$other_opt, &$checked, $args = array() ) { |
|
| 775 | 775 | _deprecated_function( __FUNCTION__, '2.0.6', 'FrmFieldsHelper::prepare_other_input' ); |
| 776 | 776 | $args['field'] = $field; |
| 777 | 777 | return FrmFieldsHelper::prepare_other_input( $args, $other_opt, $checked ); |
| 778 | - } |
|
| 778 | + } |
|
| 779 | 779 | |
| 780 | 780 | public static function recursive_function_map( $value, $function ) { |
| 781 | 781 | if ( is_array( $value ) ) { |
@@ -805,24 +805,24 @@ discard block |
||
| 805 | 805 | return (bool) count( array_filter( array_keys( $array ), 'is_string' ) ); |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | - /** |
|
| 809 | - * Flatten a multi-dimensional array |
|
| 810 | - */ |
|
| 808 | + /** |
|
| 809 | + * Flatten a multi-dimensional array |
|
| 810 | + */ |
|
| 811 | 811 | public static function array_flatten( $array, $keys = 'keep' ) { |
| 812 | - $return = array(); |
|
| 813 | - foreach ( $array as $key => $value ) { |
|
| 814 | - if ( is_array($value) ) { |
|
| 812 | + $return = array(); |
|
| 813 | + foreach ( $array as $key => $value ) { |
|
| 814 | + if ( is_array($value) ) { |
|
| 815 | 815 | $return = array_merge( $return, self::array_flatten( $value, $keys ) ); |
| 816 | - } else { |
|
| 816 | + } else { |
|
| 817 | 817 | if ( $keys == 'keep' ) { |
| 818 | 818 | $return[ $key ] = $value; |
| 819 | 819 | } else { |
| 820 | 820 | $return[] = $value; |
| 821 | 821 | } |
| 822 | - } |
|
| 823 | - } |
|
| 824 | - return $return; |
|
| 825 | - } |
|
| 822 | + } |
|
| 823 | + } |
|
| 824 | + return $return; |
|
| 825 | + } |
|
| 826 | 826 | |
| 827 | 827 | public static function esc_textarea( $text, $is_rich_text = false ) { |
| 828 | 828 | $safe_text = str_replace( '"', '"', $text ); |
@@ -833,38 +833,38 @@ discard block |
||
| 833 | 833 | return apply_filters( 'esc_textarea', $safe_text, $text ); |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | - /** |
|
| 837 | - * Add auto paragraphs to text areas |
|
| 838 | - * @since 2.0 |
|
| 839 | - */ |
|
| 836 | + /** |
|
| 837 | + * Add auto paragraphs to text areas |
|
| 838 | + * @since 2.0 |
|
| 839 | + */ |
|
| 840 | 840 | public static function use_wpautop( $content ) { |
| 841 | - if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 842 | - $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 843 | - } |
|
| 844 | - return $content; |
|
| 845 | - } |
|
| 841 | + if ( apply_filters('frm_use_wpautop', true) ) { |
|
| 842 | + $content = wpautop(str_replace( '<br>', '<br />', $content)); |
|
| 843 | + } |
|
| 844 | + return $content; |
|
| 845 | + } |
|
| 846 | 846 | |
| 847 | 847 | public static function replace_quotes( $val ) { |
| 848 | - //Replace double quotes |
|
| 848 | + //Replace double quotes |
|
| 849 | 849 | $val = str_replace( array( '“', '”', '″' ), '"', $val ); |
| 850 | - //Replace single quotes |
|
| 851 | - $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 852 | - return $val; |
|
| 853 | - } |
|
| 854 | - |
|
| 855 | - /** |
|
| 856 | - * @since 2.0 |
|
| 857 | - * @return string The base Google APIS url for the current version of jQuery UI |
|
| 858 | - */ |
|
| 859 | - public static function jquery_ui_base_url() { |
|
| 850 | + //Replace single quotes |
|
| 851 | + $val = str_replace( array( '‘', '’', '′', '′', '’', '‘' ), "'", $val ); |
|
| 852 | + return $val; |
|
| 853 | + } |
|
| 854 | + |
|
| 855 | + /** |
|
| 856 | + * @since 2.0 |
|
| 857 | + * @return string The base Google APIS url for the current version of jQuery UI |
|
| 858 | + */ |
|
| 859 | + public static function jquery_ui_base_url() { |
|
| 860 | 860 | $url = 'http' . ( is_ssl() ? 's' : '' ) . '://ajax.googleapis.com/ajax/libs/jqueryui/' . self::script_version( 'jquery-ui-core', '1.11.4' ); |
| 861 | - $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 862 | - return $url; |
|
| 863 | - } |
|
| 861 | + $url = apply_filters('frm_jquery_ui_base_url', $url); |
|
| 862 | + return $url; |
|
| 863 | + } |
|
| 864 | 864 | |
| 865 | - /** |
|
| 866 | - * @param string $handle |
|
| 867 | - */ |
|
| 865 | + /** |
|
| 866 | + * @param string $handle |
|
| 867 | + */ |
|
| 868 | 868 | public static function script_version( $handle, $default = 0 ) { |
| 869 | 869 | global $wp_scripts; |
| 870 | 870 | if ( ! $wp_scripts ) { |
@@ -886,241 +886,241 @@ discard block |
||
| 886 | 886 | |
| 887 | 887 | public static function js_redirect( $url ) { |
| 888 | 888 | return '<script type="text/javascript">window.location="' . esc_url_raw( $url ) . '"</script>'; |
| 889 | - } |
|
| 889 | + } |
|
| 890 | 890 | |
| 891 | 891 | public static function get_user_id_param( $user_id ) { |
| 892 | - if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 893 | - return $user_id; |
|
| 894 | - } |
|
| 892 | + if ( ! $user_id || empty($user_id) || is_numeric($user_id) ) { |
|
| 893 | + return $user_id; |
|
| 894 | + } |
|
| 895 | 895 | |
| 896 | 896 | if ( $user_id == 'current' ) { |
| 897 | 897 | $user_id = get_current_user_id(); |
| 898 | 898 | } else { |
| 899 | - if ( is_email($user_id) ) { |
|
| 900 | - $user = get_user_by('email', $user_id); |
|
| 901 | - } else { |
|
| 902 | - $user = get_user_by('login', $user_id); |
|
| 903 | - } |
|
| 899 | + if ( is_email($user_id) ) { |
|
| 900 | + $user = get_user_by('email', $user_id); |
|
| 901 | + } else { |
|
| 902 | + $user = get_user_by('login', $user_id); |
|
| 903 | + } |
|
| 904 | 904 | |
| 905 | - if ( $user ) { |
|
| 906 | - $user_id = $user->ID; |
|
| 907 | - } |
|
| 908 | - unset($user); |
|
| 909 | - } |
|
| 905 | + if ( $user ) { |
|
| 906 | + $user_id = $user->ID; |
|
| 907 | + } |
|
| 908 | + unset($user); |
|
| 909 | + } |
|
| 910 | 910 | |
| 911 | - return $user_id; |
|
| 912 | - } |
|
| 911 | + return $user_id; |
|
| 912 | + } |
|
| 913 | 913 | |
| 914 | 914 | public static function get_file_contents( $filename, $atts = array() ) { |
| 915 | - if ( ! is_file($filename) ) { |
|
| 916 | - return false; |
|
| 917 | - } |
|
| 918 | - |
|
| 919 | - extract($atts); |
|
| 920 | - ob_start(); |
|
| 921 | - include($filename); |
|
| 922 | - $contents = ob_get_contents(); |
|
| 923 | - ob_end_clean(); |
|
| 924 | - return $contents; |
|
| 925 | - } |
|
| 926 | - |
|
| 927 | - /** |
|
| 928 | - * @param string $table_name |
|
| 929 | - * @param string $column |
|
| 915 | + if ( ! is_file($filename) ) { |
|
| 916 | + return false; |
|
| 917 | + } |
|
| 918 | + |
|
| 919 | + extract($atts); |
|
| 920 | + ob_start(); |
|
| 921 | + include($filename); |
|
| 922 | + $contents = ob_get_contents(); |
|
| 923 | + ob_end_clean(); |
|
| 924 | + return $contents; |
|
| 925 | + } |
|
| 926 | + |
|
| 927 | + /** |
|
| 928 | + * @param string $table_name |
|
| 929 | + * @param string $column |
|
| 930 | 930 | * @param int $id |
| 931 | 931 | * @param int $num_chars |
| 932 | - */ |
|
| 933 | - public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 934 | - $key = ''; |
|
| 932 | + */ |
|
| 933 | + public static function get_unique_key( $name = '', $table_name, $column, $id = 0, $num_chars = 5 ) { |
|
| 934 | + $key = ''; |
|
| 935 | 935 | |
| 936 | - if ( ! empty( $name ) ) { |
|
| 937 | - $key = sanitize_key($name); |
|
| 938 | - } |
|
| 936 | + if ( ! empty( $name ) ) { |
|
| 937 | + $key = sanitize_key($name); |
|
| 938 | + } |
|
| 939 | 939 | |
| 940 | 940 | if ( empty( $key ) ) { |
| 941 | - $max_slug_value = pow(36, $num_chars); |
|
| 942 | - $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 943 | - $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 944 | - } |
|
| 941 | + $max_slug_value = pow(36, $num_chars); |
|
| 942 | + $min_slug_value = 37; // we want to have at least 2 characters in the slug |
|
| 943 | + $key = base_convert( rand($min_slug_value, $max_slug_value), 10, 36 ); |
|
| 944 | + } |
|
| 945 | 945 | |
| 946 | 946 | if ( is_numeric($key) || in_array( $key, array( 'id', 'key', 'created-at', 'detaillink', 'editlink', 'siteurl', 'evenodd' ) ) ) { |
| 947 | 947 | $key = $key . 'a'; |
| 948 | - } |
|
| 948 | + } |
|
| 949 | 949 | |
| 950 | 950 | $key_check = FrmDb::get_var( $table_name, array( $column => $key, 'ID !' => $id ), $column ); |
| 951 | 951 | |
| 952 | - if ( $key_check || is_numeric($key_check) ) { |
|
| 953 | - $suffix = 2; |
|
| 952 | + if ( $key_check || is_numeric($key_check) ) { |
|
| 953 | + $suffix = 2; |
|
| 954 | 954 | do { |
| 955 | 955 | $alt_post_name = substr( $key, 0, 200 - ( strlen( $suffix ) + 1 ) ) . $suffix; |
| 956 | 956 | $key_check = FrmDb::get_var( $table_name, array( $column => $alt_post_name, 'ID !' => $id ), $column ); |
| 957 | 957 | $suffix++; |
| 958 | 958 | } while ( $key_check || is_numeric( $key_check ) ); |
| 959 | 959 | $key = $alt_post_name; |
| 960 | - } |
|
| 961 | - return $key; |
|
| 962 | - } |
|
| 963 | - |
|
| 964 | - /** |
|
| 965 | - * Editing a Form or Entry |
|
| 966 | - * @param string $table |
|
| 967 | - * @return bool|array |
|
| 968 | - */ |
|
| 969 | - public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 970 | - if ( ! $record ) { |
|
| 971 | - return false; |
|
| 972 | - } |
|
| 973 | - |
|
| 974 | - if ( empty($post_values) ) { |
|
| 975 | - $post_values = stripslashes_deep($_POST); |
|
| 976 | - } |
|
| 960 | + } |
|
| 961 | + return $key; |
|
| 962 | + } |
|
| 963 | + |
|
| 964 | + /** |
|
| 965 | + * Editing a Form or Entry |
|
| 966 | + * @param string $table |
|
| 967 | + * @return bool|array |
|
| 968 | + */ |
|
| 969 | + public static function setup_edit_vars( $record, $table, $fields = '', $default = false, $post_values = array(), $args = array() ) { |
|
| 970 | + if ( ! $record ) { |
|
| 971 | + return false; |
|
| 972 | + } |
|
| 973 | + |
|
| 974 | + if ( empty($post_values) ) { |
|
| 975 | + $post_values = stripslashes_deep($_POST); |
|
| 976 | + } |
|
| 977 | 977 | |
| 978 | 978 | $values = array( 'id' => $record->id, 'fields' => array() ); |
| 979 | 979 | |
| 980 | 980 | foreach ( array( 'name', 'description' ) as $var ) { |
| 981 | - $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 981 | + $default_val = isset($record->{$var}) ? $record->{$var} : ''; |
|
| 982 | 982 | $values[ $var ] = self::get_param( $var, $default_val, 'get', 'wp_kses_post' ); |
| 983 | - unset($var, $default_val); |
|
| 984 | - } |
|
| 985 | - |
|
| 986 | - $values['description'] = self::use_wpautop($values['description']); |
|
| 987 | - $frm_settings = self::get_settings(); |
|
| 988 | - $is_form_builder = self::is_admin_page('formidable' ); |
|
| 989 | - |
|
| 990 | - foreach ( (array) $fields as $field ) { |
|
| 991 | - // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
| 992 | - if ( ! $is_form_builder ) { |
|
| 993 | - $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 994 | - } |
|
| 983 | + unset($var, $default_val); |
|
| 984 | + } |
|
| 985 | + |
|
| 986 | + $values['description'] = self::use_wpautop($values['description']); |
|
| 987 | + $frm_settings = self::get_settings(); |
|
| 988 | + $is_form_builder = self::is_admin_page('formidable' ); |
|
| 989 | + |
|
| 990 | + foreach ( (array) $fields as $field ) { |
|
| 991 | + // Make sure to filter default values (for placeholder text), but not on the form builder page |
|
| 992 | + if ( ! $is_form_builder ) { |
|
| 993 | + $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true ); |
|
| 994 | + } |
|
| 995 | 995 | $parent_form_id = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id; |
| 996 | 996 | self::fill_field_defaults($field, $record, $values, compact('default', 'post_values', 'frm_settings', 'parent_form_id' ) ); |
| 997 | - } |
|
| 997 | + } |
|
| 998 | 998 | |
| 999 | - self::fill_form_opts($record, $table, $post_values, $values); |
|
| 999 | + self::fill_form_opts($record, $table, $post_values, $values); |
|
| 1000 | 1000 | |
| 1001 | - if ( $table == 'entries' ) { |
|
| 1002 | - $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1003 | - } else if ( $table == 'forms' ) { |
|
| 1004 | - $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1005 | - } |
|
| 1001 | + if ( $table == 'entries' ) { |
|
| 1002 | + $values = FrmEntriesHelper::setup_edit_vars( $values, $record ); |
|
| 1003 | + } else if ( $table == 'forms' ) { |
|
| 1004 | + $values = FrmFormsHelper::setup_edit_vars( $values, $record, $post_values ); |
|
| 1005 | + } |
|
| 1006 | 1006 | |
| 1007 | - return $values; |
|
| 1008 | - } |
|
| 1007 | + return $values; |
|
| 1008 | + } |
|
| 1009 | 1009 | |
| 1010 | 1010 | private static function fill_field_defaults( $field, $record, array &$values, $args ) { |
| 1011 | - $post_values = $args['post_values']; |
|
| 1012 | - |
|
| 1013 | - if ( $args['default'] ) { |
|
| 1014 | - $meta_value = $field->default_value; |
|
| 1015 | - } else { |
|
| 1016 | - if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1017 | - if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1018 | - $field->field_options['custom_field'] = ''; |
|
| 1019 | - } |
|
| 1011 | + $post_values = $args['post_values']; |
|
| 1012 | + |
|
| 1013 | + if ( $args['default'] ) { |
|
| 1014 | + $meta_value = $field->default_value; |
|
| 1015 | + } else { |
|
| 1016 | + if ( $record->post_id && self::pro_is_installed() && isset($field->field_options['post_field']) && $field->field_options['post_field'] ) { |
|
| 1017 | + if ( ! isset($field->field_options['custom_field']) ) { |
|
| 1018 | + $field->field_options['custom_field'] = ''; |
|
| 1019 | + } |
|
| 1020 | 1020 | $meta_value = FrmProEntryMetaHelper::get_post_value( $record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array( 'truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field ) ); |
| 1021 | - } else { |
|
| 1021 | + } else { |
|
| 1022 | 1022 | $meta_value = FrmEntryMeta::get_meta_value( $record, $field->id ); |
| 1023 | - } |
|
| 1024 | - } |
|
| 1023 | + } |
|
| 1024 | + } |
|
| 1025 | 1025 | |
| 1026 | 1026 | $field_type = isset( $post_values['field_options'][ 'type_' . $field->id ] ) ? $post_values['field_options'][ 'type_' . $field->id ] : $field->type; |
| 1027 | - $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1028 | - |
|
| 1029 | - $field_array = array( |
|
| 1030 | - 'id' => $field->id, |
|
| 1031 | - 'value' => $new_value, |
|
| 1032 | - 'default_value' => $field->default_value, |
|
| 1033 | - 'name' => $field->name, |
|
| 1034 | - 'description' => $field->description, |
|
| 1035 | - 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1036 | - 'options' => $field->options, |
|
| 1037 | - 'required' => $field->required, |
|
| 1038 | - 'field_key' => $field->field_key, |
|
| 1039 | - 'field_order' => $field->field_order, |
|
| 1040 | - 'form_id' => $field->form_id, |
|
| 1027 | + $new_value = isset( $post_values['item_meta'][ $field->id ] ) ? maybe_unserialize( $post_values['item_meta'][ $field->id ] ) : $meta_value; |
|
| 1028 | + |
|
| 1029 | + $field_array = array( |
|
| 1030 | + 'id' => $field->id, |
|
| 1031 | + 'value' => $new_value, |
|
| 1032 | + 'default_value' => $field->default_value, |
|
| 1033 | + 'name' => $field->name, |
|
| 1034 | + 'description' => $field->description, |
|
| 1035 | + 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), |
|
| 1036 | + 'options' => $field->options, |
|
| 1037 | + 'required' => $field->required, |
|
| 1038 | + 'field_key' => $field->field_key, |
|
| 1039 | + 'field_order' => $field->field_order, |
|
| 1040 | + 'form_id' => $field->form_id, |
|
| 1041 | 1041 | 'parent_form_id' => $args['parent_form_id'], |
| 1042 | - ); |
|
| 1042 | + ); |
|
| 1043 | 1043 | |
| 1044 | - $args['field_type'] = $field_type; |
|
| 1045 | - self::fill_field_opts($field, $field_array, $args); |
|
| 1044 | + $args['field_type'] = $field_type; |
|
| 1045 | + self::fill_field_opts($field, $field_array, $args); |
|
| 1046 | 1046 | // Track the original field's type |
| 1047 | 1047 | $field_array['original_type'] = isset( $field->field_options['original_type'] ) ? $field->field_options['original_type'] : $field->type; |
| 1048 | 1048 | |
| 1049 | - $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
| 1049 | + $field_array = apply_filters( 'frm_setup_edit_fields_vars', $field_array, $field, $values['id'], array() ); |
|
| 1050 | 1050 | |
| 1051 | - if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1052 | - $field_array['unique_msg'] = ''; |
|
| 1053 | - } |
|
| 1051 | + if ( ! isset($field_array['unique']) || ! $field_array['unique'] ) { |
|
| 1052 | + $field_array['unique_msg'] = ''; |
|
| 1053 | + } |
|
| 1054 | 1054 | |
| 1055 | - $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1055 | + $field_array = array_merge( $field->field_options, $field_array ); |
|
| 1056 | 1056 | |
| 1057 | - $values['fields'][ $field->id ] = $field_array; |
|
| 1058 | - } |
|
| 1057 | + $values['fields'][ $field->id ] = $field_array; |
|
| 1058 | + } |
|
| 1059 | 1059 | |
| 1060 | 1060 | private static function fill_field_opts( $field, array &$field_array, $args ) { |
| 1061 | - $post_values = $args['post_values']; |
|
| 1062 | - $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1061 | + $post_values = $args['post_values']; |
|
| 1062 | + $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true); |
|
| 1063 | 1063 | |
| 1064 | - foreach ( $opt_defaults as $opt => $default_opt ) { |
|
| 1064 | + foreach ( $opt_defaults as $opt => $default_opt ) { |
|
| 1065 | 1065 | $field_array[ $opt ] = ( $post_values && isset( $post_values['field_options'][ $opt . '_' . $field->id ] ) ) ? maybe_unserialize( $post_values['field_options'][ $opt . '_' . $field->id ] ) : ( isset( $field->field_options[ $opt ] ) ? $field->field_options[ $opt ] : $default_opt ); |
| 1066 | - if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1067 | - $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1068 | - } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1069 | - if ( $args['field_type'] == 'captcha' ) { |
|
| 1070 | - $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1071 | - } else { |
|
| 1072 | - $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1073 | - } |
|
| 1074 | - } |
|
| 1075 | - } |
|
| 1076 | - |
|
| 1077 | - if ( $field_array['custom_html'] == '' ) { |
|
| 1078 | - $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1079 | - } |
|
| 1080 | - } |
|
| 1081 | - |
|
| 1082 | - /** |
|
| 1083 | - * @param string $table |
|
| 1084 | - */ |
|
| 1066 | + if ( $opt == 'blank' && $field_array[ $opt ] == '' ) { |
|
| 1067 | + $field_array[ $opt ] = $args['frm_settings']->blank_msg; |
|
| 1068 | + } else if ( $opt == 'invalid' && $field_array[ $opt ] == '' ) { |
|
| 1069 | + if ( $args['field_type'] == 'captcha' ) { |
|
| 1070 | + $field_array[ $opt ] = $args['frm_settings']->re_msg; |
|
| 1071 | + } else { |
|
| 1072 | + $field_array[ $opt ] = sprintf( __( '%s is invalid', 'formidable' ), $field_array['name'] ); |
|
| 1073 | + } |
|
| 1074 | + } |
|
| 1075 | + } |
|
| 1076 | + |
|
| 1077 | + if ( $field_array['custom_html'] == '' ) { |
|
| 1078 | + $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']); |
|
| 1079 | + } |
|
| 1080 | + } |
|
| 1081 | + |
|
| 1082 | + /** |
|
| 1083 | + * @param string $table |
|
| 1084 | + */ |
|
| 1085 | 1085 | private static function fill_form_opts( $record, $table, $post_values, array &$values ) { |
| 1086 | - if ( $table == 'entries' ) { |
|
| 1087 | - $form = $record->form_id; |
|
| 1086 | + if ( $table == 'entries' ) { |
|
| 1087 | + $form = $record->form_id; |
|
| 1088 | 1088 | FrmForm::maybe_get_form( $form ); |
| 1089 | - } else { |
|
| 1090 | - $form = $record; |
|
| 1091 | - } |
|
| 1089 | + } else { |
|
| 1090 | + $form = $record; |
|
| 1091 | + } |
|
| 1092 | 1092 | |
| 1093 | - if ( ! $form ) { |
|
| 1094 | - return; |
|
| 1095 | - } |
|
| 1093 | + if ( ! $form ) { |
|
| 1094 | + return; |
|
| 1095 | + } |
|
| 1096 | 1096 | |
| 1097 | - $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1097 | + $values['form_name'] = isset($record->form_id) ? $form->name : ''; |
|
| 1098 | 1098 | $values['parent_form_id'] = isset( $record->form_id ) ? $form->parent_form_id : 0; |
| 1099 | 1099 | |
| 1100 | - if ( ! is_array($form->options) ) { |
|
| 1101 | - return; |
|
| 1102 | - } |
|
| 1100 | + if ( ! is_array($form->options) ) { |
|
| 1101 | + return; |
|
| 1102 | + } |
|
| 1103 | 1103 | |
| 1104 | - foreach ( $form->options as $opt => $value ) { |
|
| 1105 | - $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1106 | - } |
|
| 1104 | + foreach ( $form->options as $opt => $value ) { |
|
| 1105 | + $values[ $opt ] = isset( $post_values[ $opt ] ) ? maybe_unserialize( $post_values[ $opt ] ) : $value; |
|
| 1106 | + } |
|
| 1107 | 1107 | |
| 1108 | - self::fill_form_defaults($post_values, $values); |
|
| 1109 | - } |
|
| 1108 | + self::fill_form_defaults($post_values, $values); |
|
| 1109 | + } |
|
| 1110 | 1110 | |
| 1111 | - /** |
|
| 1112 | - * Set to POST value or default |
|
| 1113 | - */ |
|
| 1111 | + /** |
|
| 1112 | + * Set to POST value or default |
|
| 1113 | + */ |
|
| 1114 | 1114 | private static function fill_form_defaults( $post_values, array &$values ) { |
| 1115 | - $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1115 | + $form_defaults = FrmFormsHelper::get_default_opts(); |
|
| 1116 | 1116 | |
| 1117 | - foreach ( $form_defaults as $opt => $default ) { |
|
| 1118 | - if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1117 | + foreach ( $form_defaults as $opt => $default ) { |
|
| 1118 | + if ( ! isset( $values[ $opt ] ) || $values[ $opt ] == '' ) { |
|
| 1119 | 1119 | $values[ $opt ] = ( $post_values && isset( $post_values['options'][ $opt ] ) ) ? $post_values['options'][ $opt ] : $default; |
| 1120 | - } |
|
| 1120 | + } |
|
| 1121 | 1121 | |
| 1122 | - unset($opt, $defaut); |
|
| 1123 | - } |
|
| 1122 | + unset($opt, $defaut); |
|
| 1123 | + } |
|
| 1124 | 1124 | |
| 1125 | 1125 | if ( ! isset( $values['custom_style'] ) ) { |
| 1126 | 1126 | $values['custom_style'] = self::custom_style_value( $post_values ); |
@@ -1129,10 +1129,10 @@ discard block |
||
| 1129 | 1129 | foreach ( array( 'before', 'after', 'submit' ) as $h ) { |
| 1130 | 1130 | if ( ! isset( $values[ $h . '_html' ] ) ) { |
| 1131 | 1131 | $values[ $h . '_html' ] = ( isset( $post_values['options'][ $h . '_html' ] ) ? $post_values['options'][ $h . '_html' ] : FrmFormsHelper::get_default_html( $h ) ); |
| 1132 | - } |
|
| 1133 | - unset($h); |
|
| 1134 | - } |
|
| 1135 | - } |
|
| 1132 | + } |
|
| 1133 | + unset($h); |
|
| 1134 | + } |
|
| 1135 | + } |
|
| 1136 | 1136 | |
| 1137 | 1137 | /** |
| 1138 | 1138 | * @since 2.2.10 |
@@ -1155,59 +1155,59 @@ discard block |
||
| 1155 | 1155 | } |
| 1156 | 1156 | |
| 1157 | 1157 | public static function insert_opt_html( $args ) { |
| 1158 | - $class = ''; |
|
| 1159 | - if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
| 1160 | - $class .= 'show_frm_not_email_to'; |
|
| 1161 | - } |
|
| 1162 | - ?> |
|
| 1158 | + $class = ''; |
|
| 1159 | + if ( in_array( $args['type'], array( 'email', 'user_id', 'hidden', 'select', 'radio', 'checkbox', 'phone', 'text' ) ) ) { |
|
| 1160 | + $class .= 'show_frm_not_email_to'; |
|
| 1161 | + } |
|
| 1162 | + ?> |
|
| 1163 | 1163 | <li> |
| 1164 | 1164 | <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> |
| 1165 | 1165 | <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> |
| 1166 | 1166 | <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> |
| 1167 | 1167 | </li> |
| 1168 | 1168 | <?php |
| 1169 | - } |
|
| 1169 | + } |
|
| 1170 | 1170 | |
| 1171 | 1171 | public static function truncate( $str, $length, $minword = 3, $continue = '...' ) { |
| 1172 | - if ( is_array( $str ) ) { |
|
| 1173 | - return ''; |
|
| 1172 | + if ( is_array( $str ) ) { |
|
| 1173 | + return ''; |
|
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | - $length = (int) $length; |
|
| 1176 | + $length = (int) $length; |
|
| 1177 | 1177 | $str = wp_strip_all_tags( $str ); |
| 1178 | 1178 | $original_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $str ) ); |
| 1179 | 1179 | |
| 1180 | 1180 | if ( $length == 0 ) { |
| 1181 | - return ''; |
|
| 1182 | - } else if ( $length <= 10 ) { |
|
| 1181 | + return ''; |
|
| 1182 | + } else if ( $length <= 10 ) { |
|
| 1183 | 1183 | $sub = self::mb_function( array( 'mb_substr', 'substr' ), array( $str, 0, $length ) ); |
| 1184 | - return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1185 | - } |
|
| 1184 | + return $sub . (($length < $original_len) ? $continue : ''); |
|
| 1185 | + } |
|
| 1186 | 1186 | |
| 1187 | - $sub = ''; |
|
| 1188 | - $len = 0; |
|
| 1187 | + $sub = ''; |
|
| 1188 | + $len = 0; |
|
| 1189 | 1189 | |
| 1190 | 1190 | $words = self::mb_function( array( 'mb_split', 'explode' ), array( ' ', $str ) ); |
| 1191 | 1191 | |
| 1192 | 1192 | foreach ( $words as $word ) { |
| 1193 | - $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1193 | + $part = (($sub != '') ? ' ' : '') . $word; |
|
| 1194 | 1194 | $total_len = self::mb_function( array( 'mb_strlen', 'strlen' ), array( $sub . $part ) ); |
| 1195 | - if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1196 | - break; |
|
| 1197 | - } |
|
| 1195 | + if ( $total_len > $length && str_word_count($sub) ) { |
|
| 1196 | + break; |
|
| 1197 | + } |
|
| 1198 | 1198 | |
| 1199 | - $sub .= $part; |
|
| 1199 | + $sub .= $part; |
|
| 1200 | 1200 | $len += self::mb_function( array( 'mb_strlen', 'strlen' ), array( $part ) ); |
| 1201 | 1201 | |
| 1202 | - if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1203 | - break; |
|
| 1204 | - } |
|
| 1202 | + if ( str_word_count($sub) > $minword && $total_len >= $length ) { |
|
| 1203 | + break; |
|
| 1204 | + } |
|
| 1205 | 1205 | |
| 1206 | - unset($total_len, $word); |
|
| 1207 | - } |
|
| 1206 | + unset($total_len, $word); |
|
| 1207 | + } |
|
| 1208 | 1208 | |
| 1209 | - return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1210 | - } |
|
| 1209 | + return $sub . (($len < $original_len) ? $continue : ''); |
|
| 1210 | + } |
|
| 1211 | 1211 | |
| 1212 | 1212 | public static function mb_function( $function_names, $args ) { |
| 1213 | 1213 | $mb_function_name = $function_names[0]; |
@@ -1219,18 +1219,18 @@ discard block |
||
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | 1221 | public static function get_formatted_time( $date, $date_format = '', $time_format = '' ) { |
| 1222 | - if ( empty($date) ) { |
|
| 1223 | - return $date; |
|
| 1224 | - } |
|
| 1222 | + if ( empty($date) ) { |
|
| 1223 | + return $date; |
|
| 1224 | + } |
|
| 1225 | 1225 | |
| 1226 | - if ( empty($date_format) ) { |
|
| 1227 | - $date_format = get_option('date_format'); |
|
| 1228 | - } |
|
| 1226 | + if ( empty($date_format) ) { |
|
| 1227 | + $date_format = get_option('date_format'); |
|
| 1228 | + } |
|
| 1229 | 1229 | |
| 1230 | - if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1231 | - $frmpro_settings = new FrmProSettings(); |
|
| 1232 | - $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1233 | - } |
|
| 1230 | + if ( preg_match('/^\d{1-2}\/\d{1-2}\/\d{4}$/', $date) && self::pro_is_installed() ) { |
|
| 1231 | + $frmpro_settings = new FrmProSettings(); |
|
| 1232 | + $date = FrmProAppHelper::convert_date($date, $frmpro_settings->date_format, 'Y-m-d'); |
|
| 1233 | + } |
|
| 1234 | 1234 | |
| 1235 | 1235 | $formatted = self::get_localized_date( $date_format, $date ); |
| 1236 | 1236 | |
@@ -1239,8 +1239,8 @@ discard block |
||
| 1239 | 1239 | $formatted .= self::add_time_to_date( $time_format, $date ); |
| 1240 | 1240 | } |
| 1241 | 1241 | |
| 1242 | - return $formatted; |
|
| 1243 | - } |
|
| 1242 | + return $formatted; |
|
| 1243 | + } |
|
| 1244 | 1244 | |
| 1245 | 1245 | private static function add_time_to_date( $time_format, $date ) { |
| 1246 | 1246 | if ( empty( $time_format ) ) { |
@@ -1322,61 +1322,61 @@ discard block |
||
| 1322 | 1322 | ); |
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | - /** |
|
| 1326 | - * Added for < WP 4.0 compatability |
|
| 1327 | - * |
|
| 1328 | - * @since 1.07.10 |
|
| 1329 | - * |
|
| 1330 | - * @param string $term The value to escape |
|
| 1331 | - * @return string The escaped value |
|
| 1332 | - */ |
|
| 1325 | + /** |
|
| 1326 | + * Added for < WP 4.0 compatability |
|
| 1327 | + * |
|
| 1328 | + * @since 1.07.10 |
|
| 1329 | + * |
|
| 1330 | + * @param string $term The value to escape |
|
| 1331 | + * @return string The escaped value |
|
| 1332 | + */ |
|
| 1333 | 1333 | public static function esc_like( $term ) { |
| 1334 | - global $wpdb; |
|
| 1335 | - if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1334 | + global $wpdb; |
|
| 1335 | + if ( method_exists($wpdb, 'esc_like') ) { |
|
| 1336 | 1336 | // WP 4.0 |
| 1337 | - $term = $wpdb->esc_like( $term ); |
|
| 1338 | - } else { |
|
| 1339 | - $term = like_escape( $term ); |
|
| 1340 | - } |
|
| 1337 | + $term = $wpdb->esc_like( $term ); |
|
| 1338 | + } else { |
|
| 1339 | + $term = like_escape( $term ); |
|
| 1340 | + } |
|
| 1341 | 1341 | |
| 1342 | - return $term; |
|
| 1343 | - } |
|
| 1342 | + return $term; |
|
| 1343 | + } |
|
| 1344 | 1344 | |
| 1345 | - /** |
|
| 1346 | - * @param string $order_query |
|
| 1347 | - */ |
|
| 1345 | + /** |
|
| 1346 | + * @param string $order_query |
|
| 1347 | + */ |
|
| 1348 | 1348 | public static function esc_order( $order_query ) { |
| 1349 | - if ( empty($order_query) ) { |
|
| 1350 | - return ''; |
|
| 1351 | - } |
|
| 1352 | - |
|
| 1353 | - // remove ORDER BY before santizing |
|
| 1354 | - $order_query = strtolower($order_query); |
|
| 1355 | - if ( strpos($order_query, 'order by') !== false ) { |
|
| 1356 | - $order_query = str_replace('order by', '', $order_query); |
|
| 1357 | - } |
|
| 1358 | - |
|
| 1359 | - $order_query = explode(' ', trim($order_query)); |
|
| 1360 | - |
|
| 1361 | - $order_fields = array( |
|
| 1362 | - 'id', 'form_key', 'name', 'description', |
|
| 1363 | - 'parent_form_id', 'logged_in', 'is_template', |
|
| 1364 | - 'default_template', 'status', 'created_at', |
|
| 1365 | - ); |
|
| 1366 | - |
|
| 1367 | - $order = trim(trim(reset($order_query), ',')); |
|
| 1368 | - if ( ! in_array($order, $order_fields) ) { |
|
| 1369 | - return ''; |
|
| 1370 | - } |
|
| 1371 | - |
|
| 1372 | - $order_by = ''; |
|
| 1373 | - if ( count($order_query) > 1 ) { |
|
| 1349 | + if ( empty($order_query) ) { |
|
| 1350 | + return ''; |
|
| 1351 | + } |
|
| 1352 | + |
|
| 1353 | + // remove ORDER BY before santizing |
|
| 1354 | + $order_query = strtolower($order_query); |
|
| 1355 | + if ( strpos($order_query, 'order by') !== false ) { |
|
| 1356 | + $order_query = str_replace('order by', '', $order_query); |
|
| 1357 | + } |
|
| 1358 | + |
|
| 1359 | + $order_query = explode(' ', trim($order_query)); |
|
| 1360 | + |
|
| 1361 | + $order_fields = array( |
|
| 1362 | + 'id', 'form_key', 'name', 'description', |
|
| 1363 | + 'parent_form_id', 'logged_in', 'is_template', |
|
| 1364 | + 'default_template', 'status', 'created_at', |
|
| 1365 | + ); |
|
| 1366 | + |
|
| 1367 | + $order = trim(trim(reset($order_query), ',')); |
|
| 1368 | + if ( ! in_array($order, $order_fields) ) { |
|
| 1369 | + return ''; |
|
| 1370 | + } |
|
| 1371 | + |
|
| 1372 | + $order_by = ''; |
|
| 1373 | + if ( count($order_query) > 1 ) { |
|
| 1374 | 1374 | $order_by = end( $order_query ); |
| 1375 | 1375 | self::esc_order_by( $order_by ); |
| 1376 | - } |
|
| 1376 | + } |
|
| 1377 | 1377 | |
| 1378 | 1378 | return ' ORDER BY ' . $order . ' ' . $order_by; |
| 1379 | - } |
|
| 1379 | + } |
|
| 1380 | 1380 | |
| 1381 | 1381 | /** |
| 1382 | 1382 | * Make sure this is ordering by either ASC or DESC |
@@ -1388,169 +1388,169 @@ discard block |
||
| 1388 | 1388 | } |
| 1389 | 1389 | } |
| 1390 | 1390 | |
| 1391 | - /** |
|
| 1392 | - * @param string $limit |
|
| 1393 | - */ |
|
| 1391 | + /** |
|
| 1392 | + * @param string $limit |
|
| 1393 | + */ |
|
| 1394 | 1394 | public static function esc_limit( $limit ) { |
| 1395 | - if ( empty($limit) ) { |
|
| 1396 | - return ''; |
|
| 1397 | - } |
|
| 1395 | + if ( empty($limit) ) { |
|
| 1396 | + return ''; |
|
| 1397 | + } |
|
| 1398 | 1398 | |
| 1399 | - $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1400 | - if ( is_numeric($limit) ) { |
|
| 1399 | + $limit = trim(str_replace(' limit', '', strtolower($limit))); |
|
| 1400 | + if ( is_numeric($limit) ) { |
|
| 1401 | 1401 | return ' LIMIT ' . $limit; |
| 1402 | - } |
|
| 1402 | + } |
|
| 1403 | 1403 | |
| 1404 | - $limit = explode(',', trim($limit)); |
|
| 1405 | - foreach ( $limit as $k => $l ) { |
|
| 1406 | - if ( is_numeric( $l ) ) { |
|
| 1407 | - $limit[ $k ] = $l; |
|
| 1408 | - } |
|
| 1409 | - } |
|
| 1404 | + $limit = explode(',', trim($limit)); |
|
| 1405 | + foreach ( $limit as $k => $l ) { |
|
| 1406 | + if ( is_numeric( $l ) ) { |
|
| 1407 | + $limit[ $k ] = $l; |
|
| 1408 | + } |
|
| 1409 | + } |
|
| 1410 | 1410 | |
| 1411 | - $limit = implode(',', $limit); |
|
| 1411 | + $limit = implode(',', $limit); |
|
| 1412 | 1412 | return ' LIMIT ' . $limit; |
| 1413 | - } |
|
| 1414 | - |
|
| 1415 | - /** |
|
| 1416 | - * Get an array of values ready to go through $wpdb->prepare |
|
| 1417 | - * @since 2.0 |
|
| 1418 | - */ |
|
| 1419 | - public static function prepare_array_values( $array, $type = '%s' ) { |
|
| 1420 | - $placeholders = array_fill(0, count($array), $type); |
|
| 1421 | - return implode(', ', $placeholders); |
|
| 1422 | - } |
|
| 1423 | - |
|
| 1424 | - public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
| 1425 | - if ( empty($where) ) { |
|
| 1426 | - return ''; |
|
| 1427 | - } |
|
| 1413 | + } |
|
| 1414 | + |
|
| 1415 | + /** |
|
| 1416 | + * Get an array of values ready to go through $wpdb->prepare |
|
| 1417 | + * @since 2.0 |
|
| 1418 | + */ |
|
| 1419 | + public static function prepare_array_values( $array, $type = '%s' ) { |
|
| 1420 | + $placeholders = array_fill(0, count($array), $type); |
|
| 1421 | + return implode(', ', $placeholders); |
|
| 1422 | + } |
|
| 1423 | + |
|
| 1424 | + public static function prepend_and_or_where( $starts_with = ' WHERE ', $where = '' ) { |
|
| 1425 | + if ( empty($where) ) { |
|
| 1426 | + return ''; |
|
| 1427 | + } |
|
| 1428 | 1428 | |
| 1429 | 1429 | if ( is_array( $where ) ) { |
| 1430 | - global $wpdb; |
|
| 1431 | - FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
| 1430 | + global $wpdb; |
|
| 1431 | + FrmDb::get_where_clause_and_values( $where, $starts_with ); |
|
| 1432 | 1432 | $where = $wpdb->prepare( $where['where'], $where['values'] ); |
| 1433 | 1433 | } else { |
| 1434 | - $where = $starts_with . $where; |
|
| 1435 | - } |
|
| 1434 | + $where = $starts_with . $where; |
|
| 1435 | + } |
|
| 1436 | 1436 | |
| 1437 | - return $where; |
|
| 1438 | - } |
|
| 1437 | + return $where; |
|
| 1438 | + } |
|
| 1439 | 1439 | |
| 1440 | - // Pagination Methods |
|
| 1440 | + // Pagination Methods |
|
| 1441 | 1441 | |
| 1442 | - /** |
|
| 1443 | - * @param integer $current_p |
|
| 1444 | - */ |
|
| 1442 | + /** |
|
| 1443 | + * @param integer $current_p |
|
| 1444 | + */ |
|
| 1445 | 1445 | public static function get_last_record_num( $r_count, $current_p, $p_size ) { |
| 1446 | 1446 | return ( ( $r_count < ( $current_p * $p_size ) ) ? $r_count : ( $current_p * $p_size ) ); |
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | - /** |
|
| 1450 | - * @param integer $current_p |
|
| 1451 | - */ |
|
| 1452 | - public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1453 | - if ( $current_p == 1 ) { |
|
| 1454 | - return 1; |
|
| 1455 | - } else { |
|
| 1456 | - return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1457 | - } |
|
| 1458 | - } |
|
| 1449 | + /** |
|
| 1450 | + * @param integer $current_p |
|
| 1451 | + */ |
|
| 1452 | + public static function get_first_record_num( $r_count, $current_p, $p_size ) { |
|
| 1453 | + if ( $current_p == 1 ) { |
|
| 1454 | + return 1; |
|
| 1455 | + } else { |
|
| 1456 | + return ( self::get_last_record_num( $r_count, ( $current_p - 1 ), $p_size ) + 1 ); |
|
| 1457 | + } |
|
| 1458 | + } |
|
| 1459 | 1459 | |
| 1460 | 1460 | /** |
| 1461 | 1461 | * @return array |
| 1462 | 1462 | */ |
| 1463 | 1463 | public static function json_to_array( $json_vars ) { |
| 1464 | - $vars = array(); |
|
| 1465 | - foreach ( $json_vars as $jv ) { |
|
| 1466 | - $jv_name = explode('[', $jv['name']); |
|
| 1467 | - $last = count($jv_name) - 1; |
|
| 1468 | - foreach ( $jv_name as $p => $n ) { |
|
| 1469 | - $name = trim($n, ']'); |
|
| 1470 | - if ( ! isset($l1) ) { |
|
| 1471 | - $l1 = $name; |
|
| 1472 | - } |
|
| 1473 | - |
|
| 1474 | - if ( ! isset($l2) ) { |
|
| 1475 | - $l2 = $name; |
|
| 1476 | - } |
|
| 1477 | - |
|
| 1478 | - if ( ! isset($l3) ) { |
|
| 1479 | - $l3 = $name; |
|
| 1480 | - } |
|
| 1481 | - |
|
| 1482 | - $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1483 | - |
|
| 1484 | - switch ( $p ) { |
|
| 1485 | - case 0: |
|
| 1486 | - $l1 = $name; |
|
| 1487 | - self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1488 | - break; |
|
| 1489 | - |
|
| 1490 | - case 1: |
|
| 1491 | - $l2 = $name; |
|
| 1492 | - self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1493 | - break; |
|
| 1494 | - |
|
| 1495 | - case 2: |
|
| 1496 | - $l3 = $name; |
|
| 1497 | - self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1498 | - break; |
|
| 1499 | - |
|
| 1500 | - case 3: |
|
| 1501 | - $l4 = $name; |
|
| 1502 | - self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1503 | - break; |
|
| 1504 | - } |
|
| 1505 | - |
|
| 1506 | - unset($this_val, $n); |
|
| 1507 | - } |
|
| 1508 | - |
|
| 1509 | - unset($last, $jv); |
|
| 1510 | - } |
|
| 1511 | - |
|
| 1512 | - return $vars; |
|
| 1513 | - } |
|
| 1514 | - |
|
| 1515 | - /** |
|
| 1516 | - * @param string $name |
|
| 1517 | - * @param string $l1 |
|
| 1518 | - */ |
|
| 1519 | - public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1520 | - if ( $name == '' ) { |
|
| 1521 | - $vars[] = $val; |
|
| 1522 | - } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1523 | - $vars[ $l1 ] = $val; |
|
| 1524 | - } |
|
| 1525 | - } |
|
| 1464 | + $vars = array(); |
|
| 1465 | + foreach ( $json_vars as $jv ) { |
|
| 1466 | + $jv_name = explode('[', $jv['name']); |
|
| 1467 | + $last = count($jv_name) - 1; |
|
| 1468 | + foreach ( $jv_name as $p => $n ) { |
|
| 1469 | + $name = trim($n, ']'); |
|
| 1470 | + if ( ! isset($l1) ) { |
|
| 1471 | + $l1 = $name; |
|
| 1472 | + } |
|
| 1473 | + |
|
| 1474 | + if ( ! isset($l2) ) { |
|
| 1475 | + $l2 = $name; |
|
| 1476 | + } |
|
| 1477 | + |
|
| 1478 | + if ( ! isset($l3) ) { |
|
| 1479 | + $l3 = $name; |
|
| 1480 | + } |
|
| 1481 | + |
|
| 1482 | + $this_val = ( $p == $last ) ? $jv['value'] : array(); |
|
| 1483 | + |
|
| 1484 | + switch ( $p ) { |
|
| 1485 | + case 0: |
|
| 1486 | + $l1 = $name; |
|
| 1487 | + self::add_value_to_array( $name, $l1, $this_val, $vars ); |
|
| 1488 | + break; |
|
| 1489 | + |
|
| 1490 | + case 1: |
|
| 1491 | + $l2 = $name; |
|
| 1492 | + self::add_value_to_array( $name, $l2, $this_val, $vars[ $l1 ] ); |
|
| 1493 | + break; |
|
| 1494 | + |
|
| 1495 | + case 2: |
|
| 1496 | + $l3 = $name; |
|
| 1497 | + self::add_value_to_array( $name, $l3, $this_val, $vars[ $l1 ][ $l2 ] ); |
|
| 1498 | + break; |
|
| 1499 | + |
|
| 1500 | + case 3: |
|
| 1501 | + $l4 = $name; |
|
| 1502 | + self::add_value_to_array( $name, $l4, $this_val, $vars[ $l1 ][ $l2 ][ $l3 ] ); |
|
| 1503 | + break; |
|
| 1504 | + } |
|
| 1505 | + |
|
| 1506 | + unset($this_val, $n); |
|
| 1507 | + } |
|
| 1508 | + |
|
| 1509 | + unset($last, $jv); |
|
| 1510 | + } |
|
| 1511 | + |
|
| 1512 | + return $vars; |
|
| 1513 | + } |
|
| 1514 | + |
|
| 1515 | + /** |
|
| 1516 | + * @param string $name |
|
| 1517 | + * @param string $l1 |
|
| 1518 | + */ |
|
| 1519 | + public static function add_value_to_array( $name, $l1, $val, &$vars ) { |
|
| 1520 | + if ( $name == '' ) { |
|
| 1521 | + $vars[] = $val; |
|
| 1522 | + } else if ( ! isset( $vars[ $l1 ] ) ) { |
|
| 1523 | + $vars[ $l1 ] = $val; |
|
| 1524 | + } |
|
| 1525 | + } |
|
| 1526 | 1526 | |
| 1527 | 1527 | public static function maybe_add_tooltip( $name, $class = 'closed', $form_name = '' ) { |
| 1528 | - $tooltips = array( |
|
| 1529 | - 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1530 | - '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' ), |
|
| 1531 | - 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1532 | - 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1533 | - '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' ), |
|
| 1534 | - 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1535 | - '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() ) ), |
|
| 1536 | - ); |
|
| 1537 | - |
|
| 1538 | - if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1539 | - return; |
|
| 1540 | - } |
|
| 1541 | - |
|
| 1542 | - if ( 'open' == $class ) { |
|
| 1543 | - echo ' frm_help"'; |
|
| 1544 | - } else { |
|
| 1545 | - echo ' class="frm_help"'; |
|
| 1546 | - } |
|
| 1528 | + $tooltips = array( |
|
| 1529 | + 'action_title' => __( 'Give this action a label for easy reference.', 'formidable' ), |
|
| 1530 | + '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' ), |
|
| 1531 | + 'cc' => __( 'Add CC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1532 | + 'bcc' => __( 'Add BCC addresses separated by a ",". FORMAT: Name <[email protected]> or [email protected].', 'formidable' ), |
|
| 1533 | + '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' ), |
|
| 1534 | + 'from' => __( 'Enter the name and/or email address of the sender. FORMAT: John Bates <[email protected]> or [email protected].', 'formidable' ), |
|
| 1535 | + '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() ) ), |
|
| 1536 | + ); |
|
| 1537 | + |
|
| 1538 | + if ( ! isset( $tooltips[ $name ] ) ) { |
|
| 1539 | + return; |
|
| 1540 | + } |
|
| 1541 | + |
|
| 1542 | + if ( 'open' == $class ) { |
|
| 1543 | + echo ' frm_help"'; |
|
| 1544 | + } else { |
|
| 1545 | + echo ' class="frm_help"'; |
|
| 1546 | + } |
|
| 1547 | 1547 | |
| 1548 | 1548 | echo ' title="' . esc_attr( $tooltips[ $name ] ); |
| 1549 | 1549 | |
| 1550 | - if ( 'open' != $class ) { |
|
| 1551 | - echo '"'; |
|
| 1552 | - } |
|
| 1553 | - } |
|
| 1550 | + if ( 'open' != $class ) { |
|
| 1551 | + echo '"'; |
|
| 1552 | + } |
|
| 1553 | + } |
|
| 1554 | 1554 | |
| 1555 | 1555 | /** |
| 1556 | 1556 | * Add the current_page class to that page in the form nav |
@@ -1566,35 +1566,35 @@ discard block |
||
| 1566 | 1566 | } |
| 1567 | 1567 | } |
| 1568 | 1568 | |
| 1569 | - /** |
|
| 1570 | - * Prepare and json_encode post content |
|
| 1571 | - * |
|
| 1572 | - * @since 2.0 |
|
| 1573 | - * |
|
| 1574 | - * @param array $post_content |
|
| 1575 | - * @return string $post_content ( json encoded array ) |
|
| 1576 | - */ |
|
| 1577 | - public static function prepare_and_encode( $post_content ) { |
|
| 1578 | - //Loop through array to strip slashes and add only the needed ones |
|
| 1569 | + /** |
|
| 1570 | + * Prepare and json_encode post content |
|
| 1571 | + * |
|
| 1572 | + * @since 2.0 |
|
| 1573 | + * |
|
| 1574 | + * @param array $post_content |
|
| 1575 | + * @return string $post_content ( json encoded array ) |
|
| 1576 | + */ |
|
| 1577 | + public static function prepare_and_encode( $post_content ) { |
|
| 1578 | + //Loop through array to strip slashes and add only the needed ones |
|
| 1579 | 1579 | foreach ( $post_content as $key => $val ) { |
| 1580 | 1580 | // Replace problematic characters (like ") |
| 1581 | 1581 | $val = str_replace( '"', '"', $val ); |
| 1582 | 1582 | |
| 1583 | 1583 | self::prepare_action_slashes( $val, $key, $post_content ); |
| 1584 | - unset( $key, $val ); |
|
| 1585 | - } |
|
| 1584 | + unset( $key, $val ); |
|
| 1585 | + } |
|
| 1586 | 1586 | |
| 1587 | - // json_encode the array |
|
| 1588 | - $post_content = json_encode( $post_content ); |
|
| 1587 | + // json_encode the array |
|
| 1588 | + $post_content = json_encode( $post_content ); |
|
| 1589 | 1589 | |
| 1590 | - // add extra slashes for \r\n since WP strips them |
|
| 1590 | + // add extra slashes for \r\n since WP strips them |
|
| 1591 | 1591 | $post_content = str_replace( array( '\\r', '\\n', '\\u', '\\t' ), array( '\\\\r', '\\\\n', '\\\\u', '\\\\t' ), $post_content ); |
| 1592 | 1592 | |
| 1593 | - // allow for " |
|
| 1594 | - $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1593 | + // allow for " |
|
| 1594 | + $post_content = str_replace( '"', '\\"', $post_content ); |
|
| 1595 | 1595 | |
| 1596 | - return $post_content; |
|
| 1597 | - } |
|
| 1596 | + return $post_content; |
|
| 1597 | + } |
|
| 1598 | 1598 | |
| 1599 | 1599 | private static function prepare_action_slashes( $val, $key, &$post_content ) { |
| 1600 | 1600 | if ( ! isset( $post_content[ $key ] ) ) { |
@@ -1662,64 +1662,64 @@ discard block |
||
| 1662 | 1662 | } |
| 1663 | 1663 | |
| 1664 | 1664 | public static function maybe_json_decode( $string ) { |
| 1665 | - if ( is_array($string) ) { |
|
| 1666 | - return $string; |
|
| 1667 | - } |
|
| 1665 | + if ( is_array($string) ) { |
|
| 1666 | + return $string; |
|
| 1667 | + } |
|
| 1668 | 1668 | |
| 1669 | - $new_string = json_decode($string, true); |
|
| 1670 | - if ( function_exists('json_last_error') ) { |
|
| 1669 | + $new_string = json_decode($string, true); |
|
| 1670 | + if ( function_exists('json_last_error') ) { |
|
| 1671 | 1671 | // php 5.3+ |
| 1672 | - if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1673 | - $string = $new_string; |
|
| 1674 | - } |
|
| 1675 | - } else if ( isset($new_string) ) { |
|
| 1672 | + if ( json_last_error() == JSON_ERROR_NONE ) { |
|
| 1673 | + $string = $new_string; |
|
| 1674 | + } |
|
| 1675 | + } else if ( isset($new_string) ) { |
|
| 1676 | 1676 | // php < 5.3 fallback |
| 1677 | - $string = $new_string; |
|
| 1678 | - } |
|
| 1679 | - return $string; |
|
| 1680 | - } |
|
| 1681 | - |
|
| 1682 | - /** |
|
| 1683 | - * @since 1.07.10 |
|
| 1684 | - * |
|
| 1685 | - * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1686 | - * echo The javascript to open and highlight the Formidable menu |
|
| 1687 | - */ |
|
| 1677 | + $string = $new_string; |
|
| 1678 | + } |
|
| 1679 | + return $string; |
|
| 1680 | + } |
|
| 1681 | + |
|
| 1682 | + /** |
|
| 1683 | + * @since 1.07.10 |
|
| 1684 | + * |
|
| 1685 | + * @param string $post_type The name of the post type that may need to be highlighted |
|
| 1686 | + * echo The javascript to open and highlight the Formidable menu |
|
| 1687 | + */ |
|
| 1688 | 1688 | public static function maybe_highlight_menu( $post_type ) { |
| 1689 | - global $post; |
|
| 1689 | + global $post; |
|
| 1690 | 1690 | |
| 1691 | - if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1692 | - return; |
|
| 1693 | - } |
|
| 1691 | + if ( isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != $post_type ) { |
|
| 1692 | + return; |
|
| 1693 | + } |
|
| 1694 | 1694 | |
| 1695 | - if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1696 | - return; |
|
| 1697 | - } |
|
| 1695 | + if ( is_object($post) && $post->post_type != $post_type ) { |
|
| 1696 | + return; |
|
| 1697 | + } |
|
| 1698 | 1698 | |
| 1699 | - self::load_admin_wide_js(); |
|
| 1700 | - echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1701 | - } |
|
| 1699 | + self::load_admin_wide_js(); |
|
| 1700 | + echo '<script type="text/javascript">jQuery(document).ready(function(){frmSelectSubnav();});</script>'; |
|
| 1701 | + } |
|
| 1702 | 1702 | |
| 1703 | - /** |
|
| 1704 | - * Load the JS file on non-Formidable pages in the admin area |
|
| 1705 | - * @since 2.0 |
|
| 1706 | - */ |
|
| 1703 | + /** |
|
| 1704 | + * Load the JS file on non-Formidable pages in the admin area |
|
| 1705 | + * @since 2.0 |
|
| 1706 | + */ |
|
| 1707 | 1707 | public static function load_admin_wide_js( $load = true ) { |
| 1708 | - $version = FrmAppHelper::plugin_version(); |
|
| 1708 | + $version = FrmAppHelper::plugin_version(); |
|
| 1709 | 1709 | wp_register_script( 'formidable_admin_global', FrmAppHelper::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version ); |
| 1710 | 1710 | |
| 1711 | - wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1711 | + wp_localize_script( 'formidable_admin_global', 'frmGlobal', array( |
|
| 1712 | 1712 | 'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ), |
| 1713 | - 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1713 | + 'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ), |
|
| 1714 | 1714 | 'url' => FrmAppHelper::plugin_url(), |
| 1715 | 1715 | 'loading' => __( 'Loading…' ), |
| 1716 | 1716 | 'nonce' => wp_create_nonce( 'frm_ajax' ), |
| 1717 | - ) ); |
|
| 1717 | + ) ); |
|
| 1718 | 1718 | |
| 1719 | 1719 | if ( $load ) { |
| 1720 | 1720 | wp_enqueue_script( 'formidable_admin_global' ); |
| 1721 | 1721 | } |
| 1722 | - } |
|
| 1722 | + } |
|
| 1723 | 1723 | |
| 1724 | 1724 | /** |
| 1725 | 1725 | * @since 2.0.9 |
@@ -1728,9 +1728,9 @@ discard block |
||
| 1728 | 1728 | wp_enqueue_style( 'frm_fonts', self::plugin_url() . '/css/frm_fonts.css', array(), self::plugin_version() ); |
| 1729 | 1729 | } |
| 1730 | 1730 | |
| 1731 | - /** |
|
| 1732 | - * @param string $location |
|
| 1733 | - */ |
|
| 1731 | + /** |
|
| 1732 | + * @param string $location |
|
| 1733 | + */ |
|
| 1734 | 1734 | public static function localize_script( $location ) { |
| 1735 | 1735 | $ajax_url = admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); |
| 1736 | 1736 | $ajax_url = apply_filters( 'frm_ajax_url', $ajax_url ); |
@@ -1785,81 +1785,81 @@ discard block |
||
| 1785 | 1785 | } |
| 1786 | 1786 | } |
| 1787 | 1787 | |
| 1788 | - /** |
|
| 1788 | + /** |
|
| 1789 | 1789 | * echo the message on the plugins listing page |
| 1790 | - * @since 1.07.10 |
|
| 1791 | - * |
|
| 1792 | - * @param float $min_version The version the add-on requires |
|
| 1793 | - */ |
|
| 1790 | + * @since 1.07.10 |
|
| 1791 | + * |
|
| 1792 | + * @param float $min_version The version the add-on requires |
|
| 1793 | + */ |
|
| 1794 | 1794 | public static function min_version_notice( $min_version ) { |
| 1795 | - $frm_version = self::plugin_version(); |
|
| 1795 | + $frm_version = self::plugin_version(); |
|
| 1796 | 1796 | |
| 1797 | - // check if Formidable meets minimum requirements |
|
| 1798 | - if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1799 | - return; |
|
| 1800 | - } |
|
| 1797 | + // check if Formidable meets minimum requirements |
|
| 1798 | + if ( version_compare($frm_version, $min_version, '>=') ) { |
|
| 1799 | + return; |
|
| 1800 | + } |
|
| 1801 | 1801 | |
| 1802 | - $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1802 | + $wp_list_table = _get_list_table('WP_Plugins_List_Table'); |
|
| 1803 | 1803 | 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">' . |
| 1804 | - __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1805 | - '</div></td></tr>'; |
|
| 1806 | - } |
|
| 1807 | - |
|
| 1808 | - public static function locales( $type = 'date' ) { |
|
| 1809 | - $locales = array( |
|
| 1810 | - 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1811 | - 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1812 | - 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1813 | - 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
| 1814 | - 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1815 | - 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1816 | - 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
| 1817 | - 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1818 | - 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1819 | - 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
| 1820 | - 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1821 | - 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
| 1822 | - 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1823 | - 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
| 1824 | - 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1825 | - 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
| 1826 | - 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1827 | - 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1828 | - 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1829 | - 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1830 | - 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1831 | - 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
| 1832 | - 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1833 | - 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
| 1834 | - 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
| 1835 | - 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1836 | - 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
| 1837 | - 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1838 | - 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
| 1839 | - 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1840 | - 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1841 | - 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1842 | - ); |
|
| 1843 | - |
|
| 1844 | - if ( $type == 'captcha' ) { |
|
| 1845 | - // remove the languages unavailable for the captcha |
|
| 1846 | - $unset = array( |
|
| 1847 | - '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
| 1848 | - 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
| 1849 | - 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
| 1850 | - ); |
|
| 1851 | - } else { |
|
| 1852 | - // remove the languages unavailable for the datepicker |
|
| 1853 | - $unset = array( |
|
| 1854 | - 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
| 1855 | - 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
| 1856 | - 'es-419', 'tr', |
|
| 1857 | - ); |
|
| 1858 | - } |
|
| 1859 | - |
|
| 1860 | - $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1861 | - $locales = apply_filters('frm_locales', $locales); |
|
| 1862 | - |
|
| 1863 | - return $locales; |
|
| 1864 | - } |
|
| 1804 | + __( 'You are running an outdated version of Formidable. This plugin may not work correctly if you do not update Formidable.', 'formidable' ) . |
|
| 1805 | + '</div></td></tr>'; |
|
| 1806 | + } |
|
| 1807 | + |
|
| 1808 | + public static function locales( $type = 'date' ) { |
|
| 1809 | + $locales = array( |
|
| 1810 | + 'en' => __( 'English', 'formidable' ), '' => __( 'English/Western', 'formidable' ), |
|
| 1811 | + 'af' => __( 'Afrikaans', 'formidable' ), 'sq' => __( 'Albanian', 'formidable' ), |
|
| 1812 | + 'ar' => __( 'Arabic', 'formidable' ), 'hy' => __( 'Armenian', 'formidable' ), |
|
| 1813 | + 'az' => __( 'Azerbaijani', 'formidable' ), 'eu' => __( 'Basque', 'formidable' ), |
|
| 1814 | + 'bs' => __( 'Bosnian', 'formidable' ), 'bg' => __( 'Bulgarian', 'formidable' ), |
|
| 1815 | + 'ca' => __( 'Catalan', 'formidable' ), 'zh-HK' => __( 'Chinese Hong Kong', 'formidable' ), |
|
| 1816 | + 'zh-CN' => __( 'Chinese Simplified', 'formidable' ), 'zh-TW' => __( 'Chinese Traditional', 'formidable' ), |
|
| 1817 | + 'hr' => __( 'Croatian', 'formidable' ), 'cs' => __( 'Czech', 'formidable' ), |
|
| 1818 | + 'da' => __( 'Danish', 'formidable' ), 'nl' => __( 'Dutch', 'formidable' ), |
|
| 1819 | + 'en-GB' => __( 'English/UK', 'formidable' ), 'eo' => __( 'Esperanto', 'formidable' ), |
|
| 1820 | + 'et' => __( 'Estonian', 'formidable' ), 'fo' => __( 'Faroese', 'formidable' ), |
|
| 1821 | + 'fa' => __( 'Farsi/Persian', 'formidable' ), 'fil' => __( 'Filipino', 'formidable' ), |
|
| 1822 | + 'fi' => __( 'Finnish', 'formidable' ), 'fr' => __( 'French', 'formidable' ), |
|
| 1823 | + 'fr-CA' => __( 'French/Canadian', 'formidable' ), 'fr-CH' => __( 'French/Swiss', 'formidable' ), |
|
| 1824 | + 'de' => __( 'German', 'formidable' ), 'de-AT' => __( 'German/Austria', 'formidable' ), |
|
| 1825 | + 'de-CH' => __( 'German/Switzerland', 'formidable' ), 'el' => __( 'Greek', 'formidable' ), |
|
| 1826 | + 'he' => __( 'Hebrew', 'formidable' ), 'iw' => __( 'Hebrew', 'formidable' ), |
|
| 1827 | + 'hi' => __( 'Hindi', 'formidable' ), 'hu' => __( 'Hungarian', 'formidable' ), |
|
| 1828 | + 'is' => __( 'Icelandic', 'formidable' ), 'id' => __( 'Indonesian', 'formidable' ), |
|
| 1829 | + 'it' => __( 'Italian', 'formidable' ), 'ja' => __( 'Japanese', 'formidable' ), |
|
| 1830 | + 'ko' => __( 'Korean', 'formidable' ), 'lv' => __( 'Latvian', 'formidable' ), |
|
| 1831 | + 'lt' => __( 'Lithuanian', 'formidable' ), 'ms' => __( 'Malaysian', 'formidable' ), |
|
| 1832 | + 'no' => __( 'Norwegian', 'formidable' ), 'pl' => __( 'Polish', 'formidable' ), |
|
| 1833 | + 'pt' => __( 'Portuguese', 'formidable' ), 'pt-BR' => __( 'Portuguese/Brazilian', 'formidable' ), |
|
| 1834 | + 'pt-PT' => __( 'Portuguese/Portugal', 'formidable' ), 'ro' => __( 'Romanian', 'formidable' ), |
|
| 1835 | + 'ru' => __( 'Russian', 'formidable' ), 'sr' => __( 'Serbian', 'formidable' ), |
|
| 1836 | + 'sr-SR' => __( 'Serbian', 'formidable' ), 'sk' => __( 'Slovak', 'formidable' ), |
|
| 1837 | + 'sl' => __( 'Slovenian', 'formidable' ), 'es' => __( 'Spanish', 'formidable' ), |
|
| 1838 | + 'es-419' => __( 'Spanish/Latin America', 'formidable' ), 'sv' => __( 'Swedish', 'formidable' ), |
|
| 1839 | + 'ta' => __( 'Tamil', 'formidable' ), 'th' => __( 'Thai', 'formidable' ), |
|
| 1840 | + 'tu' => __( 'Turkish', 'formidable' ), 'tr' => __( 'Turkish', 'formidable' ), |
|
| 1841 | + 'uk' => __( 'Ukranian', 'formidable' ), 'vi' => __( 'Vietnamese', 'formidable' ), |
|
| 1842 | + ); |
|
| 1843 | + |
|
| 1844 | + if ( $type == 'captcha' ) { |
|
| 1845 | + // remove the languages unavailable for the captcha |
|
| 1846 | + $unset = array( |
|
| 1847 | + '', 'af', 'sq', 'hy', 'az', 'eu', 'bs', |
|
| 1848 | + 'zh-HK', 'eo', 'et', 'fo', 'fr-CH', |
|
| 1849 | + 'he', 'is', 'ms', 'sr-SR', 'ta', 'tu', |
|
| 1850 | + ); |
|
| 1851 | + } else { |
|
| 1852 | + // remove the languages unavailable for the datepicker |
|
| 1853 | + $unset = array( |
|
| 1854 | + 'en', 'fil', 'fr-CA', 'de-AT', 'de-AT', |
|
| 1855 | + 'de-CH', 'iw', 'hi', 'pt', 'pt-PT', |
|
| 1856 | + 'es-419', 'tr', |
|
| 1857 | + ); |
|
| 1858 | + } |
|
| 1859 | + |
|
| 1860 | + $locales = array_diff_key($locales, array_flip($unset)); |
|
| 1861 | + $locales = apply_filters('frm_locales', $locales); |
|
| 1862 | + |
|
| 1863 | + return $locales; |
|
| 1864 | + } |
|
| 1865 | 1865 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | <div class="update-nag frm-update-to-pro"> |
| 139 | 139 | <?php echo FrmAppHelper::kses( $tip['tip'] ) ?> |
| 140 | 140 | <span><?php echo FrmAppHelper::kses( $tip['call'] ) ?></span> |
| 141 | - <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a> |
|
| 141 | + <a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com?banner=1&tip=' . absint( $tip['num'] ) ) ) ?>" class="button">Upgrade to Pro</a> |
|
| 142 | 142 | </div> |
| 143 | 143 | <?php |
| 144 | 144 | } |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | public static function uninstall() { |
| 373 | - FrmAppHelper::permission_check('administrator'); |
|
| 373 | + FrmAppHelper::permission_check( 'administrator' ); |
|
| 374 | 374 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 375 | 375 | |
| 376 | 376 | $frmdb = new FrmDb(); |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | public static function deauthorize() { |
| 408 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
| 408 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
| 409 | 409 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 410 | 410 | |
| 411 | 411 | delete_option( 'frmpro-credentials' ); |
@@ -3,14 +3,14 @@ discard block |
||
| 3 | 3 | class FrmAppController { |
| 4 | 4 | |
| 5 | 5 | public static function menu() { |
| 6 | - FrmAppHelper::maybe_add_permissions(); |
|
| 7 | - if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
| 8 | - return; |
|
| 9 | - } |
|
| 6 | + FrmAppHelper::maybe_add_permissions(); |
|
| 7 | + if ( ! current_user_can( 'frm_view_forms' ) ) { |
|
| 8 | + return; |
|
| 9 | + } |
|
| 10 | 10 | |
| 11 | 11 | $menu_name = FrmAppHelper::get_menu_name(); |
| 12 | 12 | add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', '', self::get_menu_position() ); |
| 13 | - } |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | 15 | private static function get_menu_position() { |
| 16 | 16 | $count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) ); |
@@ -19,15 +19,15 @@ discard block |
||
| 19 | 19 | return $pos; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public static function load_wp_admin_style() { |
|
| 23 | - FrmAppHelper::load_font_style(); |
|
| 24 | - } |
|
| 22 | + public static function load_wp_admin_style() { |
|
| 23 | + FrmAppHelper::load_font_style(); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | 26 | public static function get_form_nav( $form, $show_nav = false, $title = 'show' ) { |
| 27 | 27 | $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav, 'get', 'absint' ); |
| 28 | - if ( empty( $show_nav ) || ! $form ) { |
|
| 29 | - return; |
|
| 30 | - } |
|
| 28 | + if ( empty( $show_nav ) || ! $form ) { |
|
| 29 | + return; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | FrmForm::maybe_get_form( $form ); |
| 33 | 33 | if ( ! is_object( $form ) ) { |
@@ -85,28 +85,28 @@ discard block |
||
| 85 | 85 | return $nav_items; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - // Adds a settings link to the plugins page |
|
| 89 | - public static function settings_link( $links ) { |
|
| 88 | + // Adds a settings link to the plugins page |
|
| 89 | + public static function settings_link( $links ) { |
|
| 90 | 90 | $settings = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings' ) ) . '">' . __( 'Settings', 'formidable' ) . '</a>'; |
| 91 | - array_unshift( $links, $settings ); |
|
| 91 | + array_unshift( $links, $settings ); |
|
| 92 | 92 | |
| 93 | - return $links; |
|
| 94 | - } |
|
| 93 | + return $links; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - public static function pro_get_started_headline() { |
|
| 96 | + public static function pro_get_started_headline() { |
|
| 97 | 97 | self::maybe_show_upgrade_bar(); |
| 98 | 98 | |
| 99 | - // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 100 | - if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 101 | - return; |
|
| 102 | - } |
|
| 99 | + // Don't display this error as we're upgrading the thing, or if the user shouldn't see the message |
|
| 100 | + if ( 'upgrade-plugin' == FrmAppHelper::simple_get( 'action', 'sanitize_title' ) || ! current_user_can( 'update_plugins' ) ) { |
|
| 101 | + return; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | if ( get_site_option( 'frmpro-authorized' ) && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) { |
| 105 | - FrmAppHelper::load_admin_wide_js(); |
|
| 105 | + FrmAppHelper::load_admin_wide_js(); |
|
| 106 | 106 | |
| 107 | - // user is authorized, but running free version |
|
| 108 | - $inst_install_url = 'https://formidableforms.com/knowledgebase/install-formidable-forms/'; |
|
| 109 | - ?> |
|
| 107 | + // user is authorized, but running free version |
|
| 108 | + $inst_install_url = 'https://formidableforms.com/knowledgebase/install-formidable-forms/'; |
|
| 109 | + ?> |
|
| 110 | 110 | <div class="error" class="frm_previous_install"> |
| 111 | 111 | <?php |
| 112 | 112 | echo wp_kses_post( apply_filters( 'frm_pro_update_msg', |
@@ -118,8 +118,8 @@ discard block |
||
| 118 | 118 | ) ); ?> |
| 119 | 119 | </div> |
| 120 | 120 | <?php |
| 121 | - } |
|
| 122 | - } |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | 123 | |
| 124 | 124 | private static function maybe_show_upgrade_bar() { |
| 125 | 125 | $page = FrmAppHelper::simple_get( 'page', 'sanitize_title' ); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - public static function admin_js() { |
|
| 227 | + public static function admin_js() { |
|
| 228 | 228 | $version = FrmAppHelper::plugin_version(); |
| 229 | 229 | FrmAppHelper::load_admin_wide_js( false ); |
| 230 | 230 | |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | 'bootstrap_tooltip', 'bootstrap-multiselect', |
| 236 | 236 | ), $version, true ); |
| 237 | 237 | wp_register_style( 'formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version ); |
| 238 | - wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 238 | + wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array( 'jquery' ), '3.3.4' ); |
|
| 239 | 239 | wp_register_style( 'formidable-grids', FrmAppHelper::plugin_url() . '/css/frm_grids.css', array(), $version ); |
| 240 | 240 | |
| 241 | 241 | // load multselect js |
@@ -247,54 +247,54 @@ discard block |
||
| 247 | 247 | global $pagenow; |
| 248 | 248 | if ( strpos( $page, 'formidable' ) === 0 || ( $pagenow == 'edit.php' && $post_type == 'frm_display' ) ) { |
| 249 | 249 | |
| 250 | - wp_enqueue_script( 'admin-widgets' ); |
|
| 251 | - wp_enqueue_style( 'widgets' ); |
|
| 252 | - wp_enqueue_script( 'formidable' ); |
|
| 253 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 250 | + wp_enqueue_script( 'admin-widgets' ); |
|
| 251 | + wp_enqueue_style( 'widgets' ); |
|
| 252 | + wp_enqueue_script( 'formidable' ); |
|
| 253 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 254 | 254 | FrmAppHelper::localize_script( 'admin' ); |
| 255 | 255 | |
| 256 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 256 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 257 | 257 | wp_enqueue_style( 'formidable-grids' ); |
| 258 | 258 | wp_enqueue_style( 'formidable-dropzone' ); |
| 259 | - add_thickbox(); |
|
| 259 | + add_thickbox(); |
|
| 260 | 260 | |
| 261 | - wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 261 | + wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array( 'jquery' ), '2.3.0' ); |
|
| 262 | 262 | |
| 263 | - } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 264 | - if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 265 | - $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 263 | + } else if ( $pagenow == 'post.php' || ( $pagenow == 'post-new.php' && $post_type == 'frm_display' ) ) { |
|
| 264 | + if ( isset( $_REQUEST['post_type'] ) ) { |
|
| 265 | + $post_type = sanitize_title( $_REQUEST['post_type'] ); |
|
| 266 | 266 | } else if ( isset( $_REQUEST['post'] ) && absint( $_REQUEST['post'] ) ) { |
| 267 | 267 | $post = get_post( absint( $_REQUEST['post'] ) ); |
| 268 | - if ( ! $post ) { |
|
| 269 | - return; |
|
| 270 | - } |
|
| 271 | - $post_type = $post->post_type; |
|
| 272 | - } else { |
|
| 273 | - return; |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - if ( $post_type == 'frm_display' ) { |
|
| 277 | - wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 278 | - wp_enqueue_script( 'formidable_admin' ); |
|
| 279 | - wp_enqueue_style( 'formidable-admin' ); |
|
| 268 | + if ( ! $post ) { |
|
| 269 | + return; |
|
| 270 | + } |
|
| 271 | + $post_type = $post->post_type; |
|
| 272 | + } else { |
|
| 273 | + return; |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + if ( $post_type == 'frm_display' ) { |
|
| 277 | + wp_enqueue_script( 'jquery-ui-draggable' ); |
|
| 278 | + wp_enqueue_script( 'formidable_admin' ); |
|
| 279 | + wp_enqueue_style( 'formidable-admin' ); |
|
| 280 | 280 | FrmAppHelper::localize_script( 'admin' ); |
| 281 | - } |
|
| 282 | - } else if ( $pagenow == 'widgets.php' ) { |
|
| 283 | - FrmAppHelper::load_admin_wide_js(); |
|
| 284 | - } |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - public static function load_lang() { |
|
| 288 | - load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - /** |
|
| 292 | - * Filter shortcodes in text widgets |
|
| 293 | - */ |
|
| 294 | - public static function widget_text_filter( $content ) { |
|
| 295 | - $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
| 296 | - return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
| 297 | - } |
|
| 281 | + } |
|
| 282 | + } else if ( $pagenow == 'widgets.php' ) { |
|
| 283 | + FrmAppHelper::load_admin_wide_js(); |
|
| 284 | + } |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + public static function load_lang() { |
|
| 288 | + load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() . '/languages/' ); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + /** |
|
| 292 | + * Filter shortcodes in text widgets |
|
| 293 | + */ |
|
| 294 | + public static function widget_text_filter( $content ) { |
|
| 295 | + $regex = '/\[\s*(formidable|display-frm-data|frm-stats|frm-graph|frm-entry-links|formresults|frm-search)\s+.*\]/'; |
|
| 296 | + return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content ); |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | 299 | /** |
| 300 | 300 | * Deprecated in favor of wpmu_upgrade_site |
@@ -359,20 +359,20 @@ discard block |
||
| 359 | 359 | wp_die(); |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - public static function activation_install() { |
|
| 363 | - FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 364 | - FrmFormActionsController::actions_init(); |
|
| 365 | - self::install(); |
|
| 366 | - } |
|
| 362 | + public static function activation_install() { |
|
| 363 | + FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' ); |
|
| 364 | + FrmFormActionsController::actions_init(); |
|
| 365 | + self::install(); |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - public static function install( $old_db_version = false ) { |
|
| 369 | - $frmdb = new FrmDb(); |
|
| 370 | - $frmdb->upgrade( $old_db_version ); |
|
| 371 | - } |
|
| 368 | + public static function install( $old_db_version = false ) { |
|
| 369 | + $frmdb = new FrmDb(); |
|
| 370 | + $frmdb->upgrade( $old_db_version ); |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | - public static function uninstall() { |
|
| 373 | + public static function uninstall() { |
|
| 374 | 374 | FrmAppHelper::permission_check('administrator'); |
| 375 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 375 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 376 | 376 | |
| 377 | 377 | $frmdb = new FrmDb(); |
| 378 | 378 | $frmdb->uninstall(); |
@@ -381,43 +381,43 @@ discard block |
||
| 381 | 381 | deactivate_plugins( FrmAppHelper::plugin_folder() . '/formidable.php', false, false ); |
| 382 | 382 | echo esc_url_raw( admin_url( 'plugins.php?deactivate=true' ) ); |
| 383 | 383 | |
| 384 | - wp_die(); |
|
| 385 | - } |
|
| 384 | + wp_die(); |
|
| 385 | + } |
|
| 386 | 386 | |
| 387 | - public static function drop_tables( $tables ) { |
|
| 388 | - global $wpdb; |
|
| 389 | - $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 390 | - $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 391 | - $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 392 | - $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 393 | - return $tables; |
|
| 394 | - } |
|
| 387 | + public static function drop_tables( $tables ) { |
|
| 388 | + global $wpdb; |
|
| 389 | + $tables[] = $wpdb->prefix . 'frm_fields'; |
|
| 390 | + $tables[] = $wpdb->prefix . 'frm_forms'; |
|
| 391 | + $tables[] = $wpdb->prefix . 'frm_items'; |
|
| 392 | + $tables[] = $wpdb->prefix . 'frm_item_metas'; |
|
| 393 | + return $tables; |
|
| 394 | + } |
|
| 395 | 395 | |
| 396 | - // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 397 | - public static function page_route( $content ) { |
|
| 398 | - global $post; |
|
| 396 | + // Routes for wordpress pages -- we're just replacing content here folks. |
|
| 397 | + public static function page_route( $content ) { |
|
| 398 | + global $post; |
|
| 399 | 399 | |
| 400 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 401 | - if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 402 | - $content = FrmFormsController::page_preview(); |
|
| 403 | - } |
|
| 400 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 401 | + if ( $post && $post->ID == $frm_settings->preview_page_id && isset( $_GET['form'] ) ) { |
|
| 402 | + $content = FrmFormsController::page_preview(); |
|
| 403 | + } |
|
| 404 | 404 | |
| 405 | - return $content; |
|
| 406 | - } |
|
| 405 | + return $content; |
|
| 406 | + } |
|
| 407 | 407 | |
| 408 | - public static function deauthorize() { |
|
| 408 | + public static function deauthorize() { |
|
| 409 | 409 | FrmAppHelper::permission_check('frm_change_settings'); |
| 410 | - check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 411 | - |
|
| 412 | - delete_option( 'frmpro-credentials' ); |
|
| 413 | - delete_option( 'frmpro-authorized' ); |
|
| 414 | - delete_site_option( 'frmpro-credentials' ); |
|
| 415 | - delete_site_option( 'frmpro-authorized' ); |
|
| 416 | - wp_die(); |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - public static function get_form_shortcode( $atts ) { |
|
| 420 | - _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 421 | - return FrmFormsController::get_form_shortcode( $atts ); |
|
| 422 | - } |
|
| 410 | + check_ajax_referer( 'frm_ajax', 'nonce' ); |
|
| 411 | + |
|
| 412 | + delete_option( 'frmpro-credentials' ); |
|
| 413 | + delete_option( 'frmpro-authorized' ); |
|
| 414 | + delete_site_option( 'frmpro-credentials' ); |
|
| 415 | + delete_site_option( 'frmpro-authorized' ); |
|
| 416 | + wp_die(); |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + public static function get_form_shortcode( $atts ) { |
|
| 420 | + _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' ); |
|
| 421 | + return FrmFormsController::get_form_shortcode( $atts ); |
|
| 422 | + } |
|
| 423 | 423 | } |
@@ -58,9 +58,9 @@ |
||
| 58 | 58 | <tr> |
| 59 | 59 | <th>Included AddOns</th> |
| 60 | 60 | <td>None</td> |
| 61 | - <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com/pricing/#addon-lists') ) ?>" target="_blank">Premium Addons</a></td> |
|
| 62 | - <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com/pricing/#addon-lists') ) ?>" target="_blank">Advanced Addons</a></td> |
|
| 63 | - <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url('https://formidableforms.com/pricing/#addon-lists') ) ?>" target="_blank">Enterprise Addons</a></td> |
|
| 61 | + <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/pricing/#addon-lists' ) ) ?>" target="_blank">Premium Addons</a></td> |
|
| 62 | + <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/pricing/#addon-lists' ) ) ?>" target="_blank">Advanced Addons</a></td> |
|
| 63 | + <td><a href="<?php echo esc_url( FrmAppHelper::make_affiliate_url( 'https://formidableforms.com/pricing/#addon-lists' ) ) ?>" target="_blank">Enterprise Addons</a></td> |
|
| 64 | 64 | </tr> |
| 65 | 65 | </tbody> |
| 66 | 66 | </table> |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <div class="frmcenter frm_no_entries_form"> |
| 2 | 2 | <?php |
| 3 | -if ( $form && isset($form->options['no_save']) && $form->options['no_save'] ) { ?> |
|
| 3 | +if ( $form && isset( $form->options['no_save'] ) && $form->options['no_save'] ) { ?> |
|
| 4 | 4 | <h3><?php _e( 'This form is not set to save any entries.', 'formidable' ) ?></h3> |
| 5 | 5 | <p>If you would like entries in this form to be saved, go to the <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable' ) . '&frm_action=settings&id=' . $form->id ) ?>">form Settings</a> page and uncheck the "Do not store any entries submitted from this form" box.</p> |
| 6 | 6 | <?php |
| 7 | 7 | } else if ( $form ) { |
| 8 | 8 | ?> |
| 9 | -<div class="frm_no_entries_header"><?php printf(__( 'No Entries for form: %s', 'formidable' ), $form->name); ?></div> |
|
| 10 | -<p class="frm_no_entries_text"><?php printf( __( 'For instructions on publishing your form see %1$sthe docs%2$s or click "%3$sAdd New%4$s" above to add an entry from here (Requires License)', 'formidable' ), '<a href="https://formidableforms.com/knowledgebase/publish-your-forms/" target="_blank">', '</a> <br/>', '<a href="' . esc_url( admin_url('admin.php?page=formidable-entries&frm_action=new&form=' . $form->id ) ) . '">', '</a>' ); ?></p> |
|
| 9 | +<div class="frm_no_entries_header"><?php printf( __( 'No Entries for form: %s', 'formidable' ), $form->name ); ?></div> |
|
| 10 | +<p class="frm_no_entries_text"><?php printf( __( 'For instructions on publishing your form see %1$sthe docs%2$s or click "%3$sAdd New%4$s" above to add an entry from here (Requires License)', 'formidable' ), '<a href="https://formidableforms.com/knowledgebase/publish-your-forms/" target="_blank">', '</a> <br/>', '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&frm_action=new&form=' . $form->id ) ) . '">', '</a>' ); ?></p> |
|
| 11 | 11 | <?php |
| 12 | 12 | } else { |
| 13 | 13 | ?> |
@@ -14,44 +14,44 @@ |
||
| 14 | 14 | <div class="inside"> |
| 15 | 15 | <table class="form-table"><tbody> |
| 16 | 16 | <?php |
| 17 | - $first_h3 = 'frm_first_h3'; |
|
| 18 | - foreach ( $fields as $field ) { |
|
| 17 | + $first_h3 = 'frm_first_h3'; |
|
| 18 | + foreach ( $fields as $field ) { |
|
| 19 | 19 | if ( in_array( $field->type, array( 'captcha', 'html', 'end_divider', 'form' ) ) ) { |
| 20 | - continue; |
|
| 21 | - } |
|
| 20 | + continue; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - if ( in_array($field->type, array( 'break', 'divider' ) ) ) { |
|
| 24 | - ?> |
|
| 23 | + if ( in_array($field->type, array( 'break', 'divider' ) ) ) { |
|
| 24 | + ?> |
|
| 25 | 25 | </tbody></table> |
| 26 | 26 | <br/><h3 class="<?php echo esc_attr( $first_h3 ) ?>"><?php echo esc_html( $field->name ) ?></h3> |
| 27 | 27 | <table class="form-table"><tbody> |
| 28 | 28 | <?php |
| 29 | - $first_h3 = ''; |
|
| 30 | - } else { |
|
| 31 | - ?> |
|
| 29 | + $first_h3 = ''; |
|
| 30 | + } else { |
|
| 31 | + ?> |
|
| 32 | 32 | <tr> |
| 33 | 33 | <th scope="row"><?php echo esc_html( $field->name ) ?>:</th> |
| 34 | 34 | <td> |
| 35 | 35 | <?php |
| 36 | 36 | $embedded_field_id = ( $entry->form_id != $field->form_id ) ? 'form' . $field->form_id : 0; |
| 37 | - $atts = array( |
|
| 38 | - 'type' => $field->type, 'post_id' => $entry->post_id, |
|
| 39 | - 'show_filename' => true, 'show_icon' => true, 'entry_id' => $entry->id, |
|
| 40 | - 'embedded_field_id' => $embedded_field_id, |
|
| 41 | - ); |
|
| 37 | + $atts = array( |
|
| 38 | + 'type' => $field->type, 'post_id' => $entry->post_id, |
|
| 39 | + 'show_filename' => true, 'show_icon' => true, 'entry_id' => $entry->id, |
|
| 40 | + 'embedded_field_id' => $embedded_field_id, |
|
| 41 | + ); |
|
| 42 | 42 | $display_value = FrmEntriesHelper::prepare_display_value( $entry, $field, $atts ); |
| 43 | 43 | echo $display_value; |
| 44 | 44 | |
| 45 | - if ( is_email($display_value) && ! in_array($display_value, $to_emails) ) { |
|
| 46 | - $to_emails[] = $display_value; |
|
| 47 | - } |
|
| 48 | - ?> |
|
| 45 | + if ( is_email($display_value) && ! in_array($display_value, $to_emails) ) { |
|
| 46 | + $to_emails[] = $display_value; |
|
| 47 | + } |
|
| 48 | + ?> |
|
| 49 | 49 | </td> |
| 50 | 50 | </tr> |
| 51 | 51 | <?php } |
| 52 | - } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - ?> |
|
| 54 | + ?> |
|
| 55 | 55 | |
| 56 | 56 | <?php if ( $entry->parent_item_id ) { ?> |
| 57 | 57 | <tr><th><?php _e( 'Parent Entry ID', 'formidable' ) ?>:</th> |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <div id="form_show_entry_page" class="wrap"> |
| 2 | 2 | <h2 class="frm_no_print"><?php _e( 'View Entry', 'formidable' ) ?> |
| 3 | - <?php do_action('frm_entry_inside_h2', $entry->form_id); ?> |
|
| 3 | + <?php do_action( 'frm_entry_inside_h2', $entry->form_id ); ?> |
|
| 4 | 4 | </h2> |
| 5 | 5 | |
| 6 | 6 | <div class="frm_forms"> |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | <div id="poststuff"> |
| 9 | 9 | <div id="post-body" class="metabox-holder columns-2"> |
| 10 | 10 | <div id="post-body-content"> |
| 11 | - <?php FrmAppController::get_form_nav($entry->form_id, true); ?> |
|
| 11 | + <?php FrmAppController::get_form_nav( $entry->form_id, true ); ?> |
|
| 12 | 12 | <div class="postbox"> |
| 13 | 13 | <h3 class="hndle"><span><?php _e( 'Entry', 'formidable' ) ?></span></h3> |
| 14 | 14 | <div class="inside"> |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | continue; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - if ( in_array($field->type, array( 'break', 'divider' ) ) ) { |
|
| 23 | + if ( in_array( $field->type, array( 'break', 'divider' ) ) ) { |
|
| 24 | 24 | ?> |
| 25 | 25 | </tbody></table> |
| 26 | 26 | <br/><h3 class="<?php echo esc_attr( $first_h3 ) ?>"><?php echo esc_html( $field->name ) ?></h3> |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | $display_value = FrmEntriesHelper::prepare_display_value( $entry, $field, $atts ); |
| 43 | 43 | echo $display_value; |
| 44 | 44 | |
| 45 | - if ( is_email($display_value) && ! in_array($display_value, $to_emails) ) { |
|
| 45 | + if ( is_email( $display_value ) && ! in_array( $display_value, $to_emails ) ) { |
|
| 46 | 46 | $to_emails[] = $display_value; |
| 47 | 47 | } |
| 48 | 48 | ?> |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | </td></tr> |
| 60 | 60 | <?php } ?> |
| 61 | 61 | </tbody></table> |
| 62 | - <?php do_action('frm_show_entry', $entry); ?> |
|
| 62 | + <?php do_action( 'frm_show_entry', $entry ); ?> |
|
| 63 | 63 | </div> |
| 64 | 64 | </div> |
| 65 | 65 | |
| 66 | - <?php do_action('frm_after_show_entry', $entry); ?> |
|
| 66 | + <?php do_action( 'frm_after_show_entry', $entry ); ?> |
|
| 67 | 67 | |
| 68 | 68 | </div> |
| 69 | 69 | <?php require( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-show.php' ); ?> |
@@ -2,26 +2,26 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmSettingsController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | // Make sure admins can see the menu items |
| 7 | 7 | FrmAppHelper::force_capability( 'frm_change_settings' ); |
| 8 | 8 | |
| 9 | - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
|
| 10 | - } |
|
| 9 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Global Settings', 'formidable' ), __( 'Global Settings', 'formidable' ), 'frm_change_settings', 'formidable-settings', 'FrmSettingsController::route' ); |
|
| 10 | + } |
|
| 11 | 11 | |
| 12 | - public static function license_box() { |
|
| 12 | + public static function license_box() { |
|
| 13 | 13 | $a = FrmAppHelper::simple_get( 't', 'sanitize_title', 'general_settings' ); |
| 14 | - include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); |
|
| 15 | - } |
|
| 14 | + include( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php' ); |
|
| 15 | + } |
|
| 16 | 16 | |
| 17 | - public static function display_form( $errors = array(), $message = '' ) { |
|
| 18 | - global $frm_vars; |
|
| 17 | + public static function display_form( $errors = array(), $message = '' ) { |
|
| 18 | + global $frm_vars; |
|
| 19 | 19 | |
| 20 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 21 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 20 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 21 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 22 | 22 | |
| 23 | - $uploads = wp_upload_dir(); |
|
| 24 | - $target_path = $uploads['basedir'] . '/formidable/css'; |
|
| 23 | + $uploads = wp_upload_dir(); |
|
| 24 | + $target_path = $uploads['basedir'] . '/formidable/css'; |
|
| 25 | 25 | |
| 26 | 26 | $sections = array(); |
| 27 | 27 | if ( apply_filters( 'frm_include_addon_page', false ) ) { |
@@ -30,54 +30,54 @@ discard block |
||
| 30 | 30 | 'name' => __( 'Plugin Licenses', 'formidable' ), |
| 31 | 31 | ); |
| 32 | 32 | } |
| 33 | - $sections = apply_filters( 'frm_add_settings_section', $sections ); |
|
| 33 | + $sections = apply_filters( 'frm_add_settings_section', $sections ); |
|
| 34 | 34 | |
| 35 | - $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
|
| 35 | + $captcha_lang = FrmAppHelper::locales( 'captcha' ); |
|
| 36 | 36 | |
| 37 | - require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); |
|
| 38 | - } |
|
| 37 | + require( FrmAppHelper::plugin_path() . '/classes/views/frm-settings/form.php' ); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public static function process_form( $stop_load = false ) { |
|
| 41 | - global $frm_vars; |
|
| 40 | + public static function process_form( $stop_load = false ) { |
|
| 41 | + global $frm_vars; |
|
| 42 | 42 | |
| 43 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 43 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 44 | 44 | |
| 45 | 45 | $process_form = FrmAppHelper::get_post_param( 'process_form', '', 'sanitize_text_field' ); |
| 46 | 46 | if ( ! wp_verify_nonce( $process_form, 'process_form_nonce' ) ) { |
| 47 | - wp_die( $frm_settings->admin_permission ); |
|
| 48 | - } |
|
| 47 | + wp_die( $frm_settings->admin_permission ); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - $errors = array(); |
|
| 51 | - $message = ''; |
|
| 50 | + $errors = array(); |
|
| 51 | + $message = ''; |
|
| 52 | 52 | |
| 53 | - if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { |
|
| 54 | - $errors = $frm_settings->validate( $_POST, array() ); |
|
| 53 | + if ( ! isset( $frm_vars['settings_routed'] ) || ! $frm_vars['settings_routed'] ) { |
|
| 54 | + $errors = $frm_settings->validate( $_POST, array() ); |
|
| 55 | 55 | |
| 56 | - $frm_settings->update( stripslashes_deep( $_POST ) ); |
|
| 56 | + $frm_settings->update( stripslashes_deep( $_POST ) ); |
|
| 57 | 57 | |
| 58 | - if ( empty( $errors ) ) { |
|
| 59 | - $frm_settings->store(); |
|
| 60 | - $message = __( 'Settings Saved', 'formidable' ); |
|
| 61 | - } |
|
| 62 | - } else { |
|
| 63 | - $message = __( 'Settings Saved', 'formidable' ); |
|
| 64 | - } |
|
| 58 | + if ( empty( $errors ) ) { |
|
| 59 | + $frm_settings->store(); |
|
| 60 | + $message = __( 'Settings Saved', 'formidable' ); |
|
| 61 | + } |
|
| 62 | + } else { |
|
| 63 | + $message = __( 'Settings Saved', 'formidable' ); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | if ( $stop_load == 'stop_load' ) { |
| 67 | - $frm_vars['settings_routed'] = true; |
|
| 68 | - return; |
|
| 69 | - } |
|
| 67 | + $frm_vars['settings_routed'] = true; |
|
| 68 | + return; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - self::display_form( $errors, $message ); |
|
| 72 | - } |
|
| 71 | + self::display_form( $errors, $message ); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - public static function route( $stop_load = false ) { |
|
| 75 | - $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 74 | + public static function route( $stop_load = false ) { |
|
| 75 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 76 | 76 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 77 | - if ( $action == 'process-form' ) { |
|
| 77 | + if ( $action == 'process-form' ) { |
|
| 78 | 78 | self::process_form( $stop_load ); |
| 79 | - } else if ( $stop_load != 'stop_load' ) { |
|
| 79 | + } else if ( $stop_load != 'stop_load' ) { |
|
| 80 | 80 | self::display_form(); |
| 81 | - } |
|
| 82 | - } |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -1,16 +1,16 @@ discard block |
||
| 1 | -<input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('post_excerpt', '') ) ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" /> |
|
| 2 | -<input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('ID', '') ) ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" /> |
|
| 1 | +<input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'post_excerpt', '' ) ) ?>" class="frm_action_name" value="<?php echo esc_attr( $form_action->post_excerpt ); ?>" /> |
|
| 2 | +<input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'ID', '' ) ) ?>" value="<?php echo esc_attr( $form_action->ID ); ?>" /> |
|
| 3 | 3 | |
| 4 | 4 | <table class="form-table"> |
| 5 | 5 | <tr> |
| 6 | 6 | <th> |
| 7 | - <label <?php FrmAppHelper::maybe_add_tooltip('action_title') ?>><?php _e( 'Label', 'formidable' ) ?></label> |
|
| 7 | + <label <?php FrmAppHelper::maybe_add_tooltip( 'action_title' ) ?>><?php _e( 'Label', 'formidable' ) ?></label> |
|
| 8 | 8 | </th> |
| 9 | - <td><input type="text" name="<?php echo esc_attr( $action_control->get_field_name('post_title', '') ) ?>" value="<?php echo esc_attr($form_action->post_title); ?>" class="large-text <?php FrmAppHelper::maybe_add_tooltip('action_title', 'open') ?>" id="<?php echo esc_attr( $action_control->get_field_id('action_post_title') ) ?>" /> |
|
| 9 | + <td><input type="text" name="<?php echo esc_attr( $action_control->get_field_name( 'post_title', '' ) ) ?>" value="<?php echo esc_attr( $form_action->post_title ); ?>" class="large-text <?php FrmAppHelper::maybe_add_tooltip( 'action_title', 'open' ) ?>" id="<?php echo esc_attr( $action_control->get_field_id( 'action_post_title' ) ) ?>" /> |
|
| 10 | 10 | </td> |
| 11 | 11 | </tr> |
| 12 | 12 | </table> |
| 13 | -<?php $action_control->form($form_action, compact('form', 'action_key', 'values')); |
|
| 13 | +<?php $action_control->form( $form_action, compact( 'form', 'action_key', 'values' ) ); |
|
| 14 | 14 | |
| 15 | 15 | if ( ! isset( $action_control->action_options['event'] ) ) { |
| 16 | 16 | $events = 'create'; |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | if ( count( $action_control->action_options['event'] ) == 1 || $action_control->action_options['force_event'] ) { |
| 24 | 24 | foreach ( $action_control->action_options['event'] as $e ) { ?> |
| 25 | - <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name('event') ) ?>[]" value="<?php echo esc_attr( $e ) ?>" /> |
|
| 25 | + <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'event' ) ) ?>[]" value="<?php echo esc_attr( $e ) ?>" /> |
|
| 26 | 26 | <?php |
| 27 | 27 | } |
| 28 | 28 | } else { |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | <h3><?php _e( 'Action Triggers', 'formidable' ); ?></h3> |
| 31 | 31 | <p> |
| 32 | 32 | <label class="frm_left_label"><?php _e( 'Trigger this action after', 'formidable' ) ?></label> |
| 33 | - <select name="<?php echo esc_attr( $action_control->get_field_name('event') ) ?>[]" multiple="multiple" class="frm_multiselect" id="<?php echo esc_attr( $action_control->get_field_id('event') ) ?>"> |
|
| 33 | + <select name="<?php echo esc_attr( $action_control->get_field_name( 'event' ) ) ?>[]" multiple="multiple" class="frm_multiselect" id="<?php echo esc_attr( $action_control->get_field_id( 'event' ) ) ?>"> |
|
| 34 | 34 | <?php |
| 35 | 35 | |
| 36 | 36 | $event_labels = FrmFormAction::trigger_labels(); |
| 37 | 37 | foreach ( $action_control->action_options['event'] as $event ) { ?> |
| 38 | - <option value="<?php echo esc_attr( $event ) ?>" <?php echo in_array( $event, (array) $form_action->post_content['event'] ) ? ' selected="selected"' : ''; ?> ><?php echo isset( $event_labels[ $event ] ) ? $event_labels[ $event ] : $event; ?></option> |
|
| 38 | + <option value="<?php echo esc_attr( $event ) ?>" <?php echo in_array( $event, (array) $form_action->post_content['event'] ) ? ' selected="selected"' : ''; ?> ><?php echo isset( $event_labels[$event] ) ? $event_labels[$event] : $event; ?></option> |
|
| 39 | 39 | <?php |
| 40 | 40 | }?> |
| 41 | 41 | </select> |
@@ -47,5 +47,5 @@ discard block |
||
| 47 | 47 | do_action( 'frm_additional_action_settings', $form_action, $pass_args ); |
| 48 | 48 | |
| 49 | 49 | ?> |
| 50 | -<span class="alignright frm_action_id <?php echo empty( $form_action->ID ) ? 'frm_hidden' : ''; ?>"><?php printf( __( 'Action ID: %1$s', 'formidable' ), $form_action->ID); ?></span> |
|
| 50 | +<span class="alignright frm_action_id <?php echo empty( $form_action->ID ) ? 'frm_hidden' : ''; ?>"><?php printf( __( 'Action ID: %1$s', 'formidable' ), $form_action->ID ); ?></span> |
|
| 51 | 51 | <div style="clear:both;"></div> |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | 'swanky-purse' => 'Swanky Purse', |
| 30 | 30 | ); |
| 31 | 31 | |
| 32 | - $themes = apply_filters('frm_jquery_themes', $themes); |
|
| 32 | + $themes = apply_filters( 'frm_jquery_themes', $themes ); |
|
| 33 | 33 | return $themes; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -40,12 +40,12 @@ discard block |
||
| 40 | 40 | |
| 41 | 41 | if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
| 42 | 42 | $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
| 43 | - } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
| 43 | + } else if ( preg_match( '/^http.?:\/\/.*\..*$/', $theme_css ) ) { |
|
| 44 | 44 | $css_file = $theme_css; |
| 45 | 45 | } else { |
| 46 | 46 | $uploads = self::get_upload_base(); |
| 47 | 47 | $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css'; |
| 48 | - if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
| 48 | + if ( file_exists( $uploads['basedir'] . $file_path ) ) { |
|
| 49 | 49 | $css_file = $uploads['baseurl'] . $file_path; |
| 50 | 50 | } else { |
| 51 | 51 | $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css'; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $form = self::get_form_for_page(); |
| 60 | 60 | $theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
| 61 | 61 | if ( $theme_css != -1 ) { |
| 62 | - wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
| 62 | + wp_enqueue_style( 'jquery-theme', self::jquery_css_url( $theme_css ), array(), FrmAppHelper::plugin_version() ); |
|
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | public static function get_upload_base() { |
| 81 | 81 | $uploads = wp_upload_dir(); |
| 82 | - if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
| 83 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 82 | + if ( is_ssl() && ! preg_match( '/^https:\/\/.*\..*$/', $uploads['baseurl'] ) ) { |
|
| 83 | + $uploads['baseurl'] = str_replace( 'http://', 'https://', $uploads['baseurl'] ); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | return $uploads; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | <h2 class="nav-tab-wrapper"> |
| 92 | 92 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles' ) ) ?>" class="nav-tab <?php echo ( '' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Edit Styles', 'formidable' ) ?></a> |
| 93 | 93 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=manage' ) ) ?>" class="nav-tab <?php echo ( 'manage' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Manage Form Styles', 'formidable' ) ?></a> |
| 94 | - <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
|
| 94 | + <a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
|
| 95 | 95 | </h2> |
| 96 | 96 | <?php |
| 97 | 97 | } |
@@ -130,15 +130,15 @@ discard block |
||
| 130 | 130 | * @return The class for this icon |
| 131 | 131 | */ |
| 132 | 132 | public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) { |
| 133 | - if ( 'arrow' == $type && is_numeric($key) ) { |
|
| 133 | + if ( 'arrow' == $type && is_numeric( $key ) ) { |
|
| 134 | 134 | //frm_arrowup6_icon |
| 135 | 135 | $arrow = array( '-' => 'down', '+' => 'up' ); |
| 136 | - $class = 'frm_arrow' . $arrow[ $icon ]; |
|
| 136 | + $class = 'frm_arrow' . $arrow[$icon]; |
|
| 137 | 137 | } else { |
| 138 | 138 | //frm_minus1_icon |
| 139 | - $key = str_replace('p', '', $key); |
|
| 139 | + $key = str_replace( 'p', '', $key ); |
|
| 140 | 140 | $plus = array( '-' => 'minus', '+' => 'plus' ); |
| 141 | - $class = 'frm_' . $plus[ $icon ]; |
|
| 141 | + $class = 'frm_' . $plus[$icon]; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | if ( $key ) { |
@@ -156,9 +156,9 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
| 158 | 158 | ?> |
| 159 | - <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
|
| 159 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( $name ) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
|
| 160 | 160 | <?php foreach ( $icons as $key => $icon ) { ?> |
| 161 | - <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[ $name ], $key ) ?>> |
|
| 161 | + <option value="<?php echo esc_attr( $key ) ?>" <?php selected( $style->post_content[$name], $key ) ?>> |
|
| 162 | 162 | <?php echo '' . $icon['+'] . '; ' . $icon['-'] . ';'; ?> |
| 163 | 163 | </option> |
| 164 | 164 | <?php } ?> |
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | <div class="btn-group hide-if-no-js" id="frm_<?php echo esc_attr( $name ) ?>_select"> |
| 168 | 168 | <button class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" type="button"> |
| 169 | - <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '+', $type ) ) ?>"></i> |
|
| 170 | - <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[ $name ], '-', $type ) ) ?>"></i> |
|
| 169 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '+', $type ) ) ?>"></i> |
|
| 170 | + <i class="frm_icon_font <?php echo esc_attr( self::icon_key_to_class( $style->post_content[$name], '-', $type ) ) ?>"></i> |
|
| 171 | 171 | <b class="caret"></b> |
| 172 | 172 | </button> |
| 173 | 173 | <ul class="multiselect-container frm-dropdown-menu"> |
@@ -190,9 +190,9 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | public static function hex2rgb( $hex ) { |
| 193 | - $hex = str_replace('#', '', $hex); |
|
| 193 | + $hex = str_replace( '#', '', $hex ); |
|
| 194 | 194 | |
| 195 | - if ( strlen($hex) == 3 ) { |
|
| 195 | + if ( strlen( $hex ) == 3 ) { |
|
| 196 | 196 | $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) ); |
| 197 | 197 | $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) ); |
| 198 | 198 | $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) ); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | $b = hexdec( substr( $hex, 4, 2 ) ); |
| 203 | 203 | } |
| 204 | 204 | $rgb = array( $r, $g, $b ); |
| 205 | - return implode(',', $rgb); // returns the rgb values separated by commas |
|
| 205 | + return implode( ',', $rgb ); // returns the rgb values separated by commas |
|
| 206 | 206 | //return $rgb; // returns an array with the rgb values |
| 207 | 207 | } |
| 208 | 208 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * @since 2.3 |
| 213 | 213 | */ |
| 214 | 214 | public static function adjust_brightness( $hex, $steps ) { |
| 215 | - $steps = max( -255, min( 255, $steps ) ); |
|
| 215 | + $steps = max( - 255, min( 255, $steps ) ); |
|
| 216 | 216 | |
| 217 | 217 | // Normalize into a six character long hex string |
| 218 | 218 | $hex = str_replace( '#', '', $hex ); |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | foreach ( $color_parts as $color ) { |
| 230 | 230 | $color = hexdec( $color ); // Convert to decimal |
| 231 | - $color = max( 0,min( 255,$color + $steps ) ); // Adjust color |
|
| 231 | + $color = max( 0, min( 255, $color + $steps ) ); // Adjust color |
|
| 232 | 232 | $return .= str_pad( dechex( $color ), 2, '0', STR_PAD_LEFT ); // Make two char hex code |
| 233 | 233 | } |
| 234 | 234 | |
@@ -263,8 +263,8 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | $checkbox_opts = array( 'important_style', 'auto_width', 'submit_style', 'collapse_icon', 'center_form' ); |
| 265 | 265 | foreach ( $checkbox_opts as $opt ) { |
| 266 | - if ( ! isset( $settings[ $opt ] ) ) { |
|
| 267 | - $settings[ $opt ] = 0; |
|
| 266 | + if ( ! isset( $settings[$opt] ) ) { |
|
| 267 | + $settings[$opt] = 0; |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | $colors = self::allow_color_override(); |
| 281 | 281 | foreach ( $colors as $css => $opts ) { |
| 282 | 282 | foreach ( $opts as $opt ) { |
| 283 | - self::get_color_output( $css, $settings[ $opt ] ); |
|
| 283 | + self::get_color_output( $css, $settings[$opt] ); |
|
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | } |
@@ -1,67 +1,67 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | class FrmStylesHelper { |
| 3 | 3 | |
| 4 | - public static function jquery_themes() { |
|
| 5 | - $themes = array( |
|
| 6 | - 'ui-lightness' => 'UI Lightness', |
|
| 7 | - 'ui-darkness' => 'UI Darkness', |
|
| 8 | - 'smoothness' => 'Smoothness', |
|
| 9 | - 'start' => 'Start', |
|
| 10 | - 'redmond' => 'Redmond', |
|
| 11 | - 'sunny' => 'Sunny', |
|
| 12 | - 'overcast' => 'Overcast', |
|
| 13 | - 'le-frog' => 'Le Frog', |
|
| 14 | - 'flick' => 'Flick', |
|
| 4 | + public static function jquery_themes() { |
|
| 5 | + $themes = array( |
|
| 6 | + 'ui-lightness' => 'UI Lightness', |
|
| 7 | + 'ui-darkness' => 'UI Darkness', |
|
| 8 | + 'smoothness' => 'Smoothness', |
|
| 9 | + 'start' => 'Start', |
|
| 10 | + 'redmond' => 'Redmond', |
|
| 11 | + 'sunny' => 'Sunny', |
|
| 12 | + 'overcast' => 'Overcast', |
|
| 13 | + 'le-frog' => 'Le Frog', |
|
| 14 | + 'flick' => 'Flick', |
|
| 15 | 15 | 'pepper-grinder' => 'Pepper Grinder', |
| 16 | - 'eggplant' => 'Eggplant', |
|
| 17 | - 'dark-hive' => 'Dark Hive', |
|
| 18 | - 'cupertino' => 'Cupertino', |
|
| 19 | - 'south-street' => 'South Street', |
|
| 20 | - 'blitzer' => 'Blitzer', |
|
| 21 | - 'humanity' => 'Humanity', |
|
| 22 | - 'hot-sneaks' => 'Hot Sneaks', |
|
| 23 | - 'excite-bike' => 'Excite Bike', |
|
| 24 | - 'vader' => 'Vader', |
|
| 25 | - 'dot-luv' => 'Dot Luv', |
|
| 26 | - 'mint-choc' => 'Mint Choc', |
|
| 27 | - 'black-tie' => 'Black Tie', |
|
| 28 | - 'trontastic' => 'Trontastic', |
|
| 29 | - 'swanky-purse' => 'Swanky Purse', |
|
| 30 | - ); |
|
| 31 | - |
|
| 32 | - $themes = apply_filters('frm_jquery_themes', $themes); |
|
| 33 | - return $themes; |
|
| 34 | - } |
|
| 16 | + 'eggplant' => 'Eggplant', |
|
| 17 | + 'dark-hive' => 'Dark Hive', |
|
| 18 | + 'cupertino' => 'Cupertino', |
|
| 19 | + 'south-street' => 'South Street', |
|
| 20 | + 'blitzer' => 'Blitzer', |
|
| 21 | + 'humanity' => 'Humanity', |
|
| 22 | + 'hot-sneaks' => 'Hot Sneaks', |
|
| 23 | + 'excite-bike' => 'Excite Bike', |
|
| 24 | + 'vader' => 'Vader', |
|
| 25 | + 'dot-luv' => 'Dot Luv', |
|
| 26 | + 'mint-choc' => 'Mint Choc', |
|
| 27 | + 'black-tie' => 'Black Tie', |
|
| 28 | + 'trontastic' => 'Trontastic', |
|
| 29 | + 'swanky-purse' => 'Swanky Purse', |
|
| 30 | + ); |
|
| 31 | + |
|
| 32 | + $themes = apply_filters('frm_jquery_themes', $themes); |
|
| 33 | + return $themes; |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | public static function jquery_css_url( $theme_css ) { |
| 37 | - if ( $theme_css == -1 ) { |
|
| 38 | - return; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
| 42 | - $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
| 43 | - } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
| 44 | - $css_file = $theme_css; |
|
| 45 | - } else { |
|
| 46 | - $uploads = self::get_upload_base(); |
|
| 37 | + if ( $theme_css == -1 ) { |
|
| 38 | + return; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + if ( ! $theme_css || $theme_css == '' || $theme_css == 'ui-lightness' ) { |
|
| 42 | + $css_file = FrmAppHelper::plugin_url() . '/css/ui-lightness/jquery-ui.css'; |
|
| 43 | + } else if ( preg_match('/^http.?:\/\/.*\..*$/', $theme_css) ) { |
|
| 44 | + $css_file = $theme_css; |
|
| 45 | + } else { |
|
| 46 | + $uploads = self::get_upload_base(); |
|
| 47 | 47 | $file_path = '/formidable/css/' . $theme_css . '/jquery-ui.css'; |
| 48 | - if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
| 49 | - $css_file = $uploads['baseurl'] . $file_path; |
|
| 50 | - } else { |
|
| 48 | + if ( file_exists($uploads['basedir'] . $file_path) ) { |
|
| 49 | + $css_file = $uploads['baseurl'] . $file_path; |
|
| 50 | + } else { |
|
| 51 | 51 | $css_file = FrmAppHelper::jquery_ui_base_url() . '/themes/' . $theme_css . '/jquery-ui.min.css'; |
| 52 | - } |
|
| 53 | - } |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - return $css_file; |
|
| 56 | - } |
|
| 55 | + return $css_file; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public static function enqueue_jquery_css() { |
|
| 58 | + public static function enqueue_jquery_css() { |
|
| 59 | 59 | $form = self::get_form_for_page(); |
| 60 | 60 | $theme_css = FrmStylesController::get_style_val( 'theme_css', $form ); |
| 61 | - if ( $theme_css != -1 ) { |
|
| 62 | - wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
| 63 | - } |
|
| 64 | - } |
|
| 61 | + if ( $theme_css != -1 ) { |
|
| 62 | + wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | public static function get_form_for_page() { |
| 67 | 67 | global $frm_vars; |
@@ -77,14 +77,14 @@ discard block |
||
| 77 | 77 | return $form_id; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public static function get_upload_base() { |
|
| 81 | - $uploads = wp_upload_dir(); |
|
| 82 | - if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
| 83 | - $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 84 | - } |
|
| 80 | + public static function get_upload_base() { |
|
| 81 | + $uploads = wp_upload_dir(); |
|
| 82 | + if ( is_ssl() && ! preg_match('/^https:\/\/.*\..*$/', $uploads['baseurl']) ) { |
|
| 83 | + $uploads['baseurl'] = str_replace('http://', 'https://', $uploads['baseurl']); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - return $uploads; |
|
| 87 | - } |
|
| 86 | + return $uploads; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | 89 | public static function style_menu( $active = '' ) { |
| 90 | 90 | ?> |
@@ -94,22 +94,22 @@ discard block |
||
| 94 | 94 | <a href="<?php echo esc_url( admin_url('admin.php?page=formidable-styles&frm_action=custom_css' ) ) ?>" class="nav-tab <?php echo ( 'custom_css' == $active ) ? 'nav-tab-active' : '' ?>"><?php _e( 'Custom CSS', 'formidable' ) ?></a> |
| 95 | 95 | </h2> |
| 96 | 96 | <?php |
| 97 | - } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - public static function minus_icons() { |
|
| 100 | - return array( |
|
| 99 | + public static function minus_icons() { |
|
| 100 | + return array( |
|
| 101 | 101 | 0 => array( '-' => '62e', '+' => '62f' ), |
| 102 | 102 | 1 => array( '-' => '600', '+' => '602' ), |
| 103 | 103 | 2 => array( '-' => '604', '+' => '603' ), |
| 104 | 104 | 3 => array( '-' => '633', '+' => '632' ), |
| 105 | 105 | 4 => array( '-' => '613', '+' => '60f' ), |
| 106 | - ); |
|
| 107 | - } |
|
| 106 | + ); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - public static function arrow_icons() { |
|
| 110 | - $minus_icons = self::minus_icons(); |
|
| 109 | + public static function arrow_icons() { |
|
| 110 | + $minus_icons = self::minus_icons(); |
|
| 111 | 111 | |
| 112 | - return array( |
|
| 112 | + return array( |
|
| 113 | 113 | 6 => array( '-' => '62d', '+' => '62a' ), |
| 114 | 114 | 0 => array( '-' => '60d', '+' => '609' ), |
| 115 | 115 | 1 => array( '-' => '60e', '+' => '60c' ), |
@@ -117,44 +117,44 @@ discard block |
||
| 117 | 117 | 3 => array( '-' => '62b', '+' => '628' ), |
| 118 | 118 | 4 => array( '-' => '62c', '+' => '629' ), |
| 119 | 119 | 5 => array( '-' => '635', '+' => '634' ), |
| 120 | - 'p0' => $minus_icons[0], |
|
| 121 | - 'p1' => $minus_icons[1], |
|
| 122 | - 'p2' => $minus_icons[2], |
|
| 123 | - 'p3' => $minus_icons[3], |
|
| 124 | - 'p4' => $minus_icons[4], |
|
| 125 | - ); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @since 2.0 |
|
| 130 | - * @return The class for this icon |
|
| 131 | - */ |
|
| 120 | + 'p0' => $minus_icons[0], |
|
| 121 | + 'p1' => $minus_icons[1], |
|
| 122 | + 'p2' => $minus_icons[2], |
|
| 123 | + 'p3' => $minus_icons[3], |
|
| 124 | + 'p4' => $minus_icons[4], |
|
| 125 | + ); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * @since 2.0 |
|
| 130 | + * @return The class for this icon |
|
| 131 | + */ |
|
| 132 | 132 | public static function icon_key_to_class( $key, $icon = '+', $type = 'arrow' ) { |
| 133 | - if ( 'arrow' == $type && is_numeric($key) ) { |
|
| 134 | - //frm_arrowup6_icon |
|
| 133 | + if ( 'arrow' == $type && is_numeric($key) ) { |
|
| 134 | + //frm_arrowup6_icon |
|
| 135 | 135 | $arrow = array( '-' => 'down', '+' => 'up' ); |
| 136 | 136 | $class = 'frm_arrow' . $arrow[ $icon ]; |
| 137 | - } else { |
|
| 138 | - //frm_minus1_icon |
|
| 139 | - $key = str_replace('p', '', $key); |
|
| 137 | + } else { |
|
| 138 | + //frm_minus1_icon |
|
| 139 | + $key = str_replace('p', '', $key); |
|
| 140 | 140 | $plus = array( '-' => 'minus', '+' => 'plus' ); |
| 141 | 141 | $class = 'frm_' . $plus[ $icon ]; |
| 142 | - } |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - if ( $key ) { |
|
| 145 | - $class .= $key; |
|
| 146 | - } |
|
| 147 | - $class .= '_icon'; |
|
| 144 | + if ( $key ) { |
|
| 145 | + $class .= $key; |
|
| 146 | + } |
|
| 147 | + $class .= '_icon'; |
|
| 148 | 148 | |
| 149 | - return $class; |
|
| 150 | - } |
|
| 149 | + return $class; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | 152 | public static function bs_icon_select( $style, $frm_style, $type = 'arrow' ) { |
| 153 | 153 | $function_name = $type . '_icons'; |
| 154 | 154 | $icons = self::$function_name(); |
| 155 | 155 | unset( $function_name ); |
| 156 | 156 | |
| 157 | - $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
|
| 157 | + $name = ( 'arrow' == $type ) ? 'collapse_icon' : 'repeat_icon'; |
|
| 158 | 158 | ?> |
| 159 | 159 | <select name="<?php echo esc_attr( $frm_style->get_field_name($name) ) ?>" id="frm_<?php echo esc_attr( $name ) ?>" class="frm_icon_font frm_multiselect hide-if-js"> |
| 160 | 160 | <?php foreach ( $icons as $key => $icon ) { ?> |
@@ -187,24 +187,24 @@ discard block |
||
| 187 | 187 | </ul> |
| 188 | 188 | </div> |
| 189 | 189 | <?php |
| 190 | - } |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | 192 | public static function hex2rgb( $hex ) { |
| 193 | - $hex = str_replace('#', '', $hex); |
|
| 193 | + $hex = str_replace('#', '', $hex); |
|
| 194 | 194 | |
| 195 | - if ( strlen($hex) == 3 ) { |
|
| 195 | + if ( strlen($hex) == 3 ) { |
|
| 196 | 196 | $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) ); |
| 197 | 197 | $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) ); |
| 198 | 198 | $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) ); |
| 199 | - } else { |
|
| 199 | + } else { |
|
| 200 | 200 | $r = hexdec( substr( $hex, 0, 2 ) ); |
| 201 | 201 | $g = hexdec( substr( $hex, 2, 2 ) ); |
| 202 | 202 | $b = hexdec( substr( $hex, 4, 2 ) ); |
| 203 | - } |
|
| 203 | + } |
|
| 204 | 204 | $rgb = array( $r, $g, $b ); |
| 205 | - return implode(',', $rgb); // returns the rgb values separated by commas |
|
| 206 | - //return $rgb; // returns an array with the rgb values |
|
| 207 | - } |
|
| 205 | + return implode(',', $rgb); // returns the rgb values separated by commas |
|
| 206 | + //return $rgb; // returns an array with the rgb values |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | 209 | /** |
| 210 | 210 | * @param $hex string - The original color in hex format #ffffff |
@@ -175,15 +175,15 @@ |
||
| 175 | 175 | } |
| 176 | 176 | $addon['link'] = FrmAppHelper::make_affiliate_url( $addon['link'] ); |
| 177 | 177 | |
| 178 | - $addons[ $slug ] = $addon; |
|
| 178 | + $addons[$slug] = $addon; |
|
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | public static function get_licenses() { |
| 183 | - FrmAppHelper::permission_check('frm_change_settings'); |
|
| 183 | + FrmAppHelper::permission_check( 'frm_change_settings' ); |
|
| 184 | 184 | check_ajax_referer( 'frm_ajax', 'nonce' ); |
| 185 | 185 | |
| 186 | - $license = get_option('frmpro-credentials'); |
|
| 186 | + $license = get_option( 'frmpro-credentials' ); |
|
| 187 | 187 | if ( $license && is_array( $license ) && isset( $license['license'] ) ) { |
| 188 | 188 | $url = 'https://formidableforms.com/frm-edd-api/licenses?l=' . urlencode( base64_encode( $license['license'] ) ); |
| 189 | 189 | $licenses = self::send_api_request( $url, array( 'name' => 'frm_api_licence', 'expires' => 60 * 60 * 5 ) ); |