@@ -51,16 +51,16 @@ discard block |
||
| 51 | 51 | $tokens = $phpcsFile->getTokens(); |
| 52 | 52 | |
| 53 | 53 | // Make sure this if/else has a scope (curly braces). |
| 54 | - if ( ! isset( $tokens[ $stackPtr ]['scope_opener'] ) || ! isset( $tokens[ $stackPtr ]['scope_closer'] ) ) { |
|
| 54 | + if ( ! isset( $tokens[$stackPtr]['scope_opener'] ) || ! isset( $tokens[$stackPtr]['scope_closer'] ) ) { |
|
| 55 | 55 | return; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - $scopeOpener = $tokens[ $stackPtr ]['scope_opener']; |
|
| 59 | - $scopeCloser = $tokens[ $stackPtr ]['scope_closer']; |
|
| 58 | + $scopeOpener = $tokens[$stackPtr]['scope_opener']; |
|
| 59 | + $scopeCloser = $tokens[$stackPtr]['scope_closer']; |
|
| 60 | 60 | |
| 61 | 61 | // Calculate the number of lines in the block body. |
| 62 | - $openerLine = $tokens[ $scopeOpener ]['line']; |
|
| 63 | - $closerLine = $tokens[ $scopeCloser ]['line']; |
|
| 62 | + $openerLine = $tokens[$scopeOpener]['line']; |
|
| 63 | + $closerLine = $tokens[$scopeCloser]['line']; |
|
| 64 | 64 | |
| 65 | 65 | // Body lines = closerLine - openerLine - 1. |
| 66 | 66 | // We want to trigger when there are exactly 3 body lines (2 code + 1 blank). |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | // A blank line is a whitespace token that contains 2+ consecutive newlines. |
| 77 | 77 | $blankLineToken = null; |
| 78 | 78 | |
| 79 | - for ( $i = $scopeOpener + 1; $i < $scopeCloser; $i++ ) { |
|
| 80 | - if ( $tokens[ $i ]['code'] === T_WHITESPACE ) { |
|
| 81 | - $content = $tokens[ $i ]['content']; |
|
| 79 | + for ( $i = $scopeOpener + 1; $i < $scopeCloser; $i ++ ) { |
|
| 80 | + if ( $tokens[$i]['code'] === T_WHITESPACE ) { |
|
| 81 | + $content = $tokens[$i]['content']; |
|
| 82 | 82 | $newlineCount = substr_count( $content, "\n" ); |
| 83 | 83 | |
| 84 | 84 | // If this whitespace has 2+ newlines, it contains a blank line. |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | // Also check for consecutive newline tokens (PHPCS sometimes splits them). |
| 94 | 94 | $lastWasNewline = false; |
| 95 | 95 | |
| 96 | - for ( $i = $scopeOpener + 1; $i < $scopeCloser; $i++ ) { |
|
| 97 | - if ( $tokens[ $i ]['code'] === T_WHITESPACE && $tokens[ $i ]['content'] === "\n" ) { |
|
| 96 | + for ( $i = $scopeOpener + 1; $i < $scopeCloser; $i ++ ) { |
|
| 97 | + if ( $tokens[$i]['code'] === T_WHITESPACE && $tokens[$i]['content'] === "\n" ) { |
|
| 98 | 98 | if ( $lastWasNewline ) { |
| 99 | 99 | $blankLineToken = $i; |
| 100 | 100 | break; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | if ( true === $fix ) { |
| 120 | 120 | $phpcsFile->fixer->beginChangeset(); |
| 121 | 121 | |
| 122 | - $content = $tokens[ $blankLineToken ]['content']; |
|
| 122 | + $content = $tokens[$blankLineToken]['content']; |
|
| 123 | 123 | |
| 124 | 124 | // Remove one newline from the whitespace. |
| 125 | 125 | if ( substr_count( $content, "\n" ) >= 2 ) { |
@@ -135,22 +135,22 @@ discard block |
||
| 135 | 135 | $default_settings = $this->get_defaults(); |
| 136 | 136 | |
| 137 | 137 | foreach ( $default_settings as $setting => $default ) { |
| 138 | - if ( ! isset( $new_instance['post_content'][ $setting ] ) ) { |
|
| 139 | - $new_instance['post_content'][ $setting ] = $default; |
|
| 138 | + if ( ! isset( $new_instance['post_content'][$setting] ) ) { |
|
| 139 | + $new_instance['post_content'][$setting] = $default; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | if ( $this->is_color( $setting ) ) { |
| 143 | - $color_val = $new_instance['post_content'][ $setting ]; |
|
| 143 | + $color_val = $new_instance['post_content'][$setting]; |
|
| 144 | 144 | |
| 145 | 145 | if ( $color_val !== '' && str_contains( $color_val, 'rgb' ) ) { |
| 146 | 146 | // Maybe sanitize if invalid rgba value is entered. |
| 147 | 147 | $this->maybe_sanitize_rgba_value( $color_val ); |
| 148 | 148 | } |
| 149 | - $new_instance['post_content'][ $setting ] = str_replace( '#', '', $color_val ); |
|
| 150 | - } elseif ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ), true ) && ! isset( $new_instance['post_content'][ $setting ] ) ) { |
|
| 151 | - $new_instance['post_content'][ $setting ] = 0; |
|
| 149 | + $new_instance['post_content'][$setting] = str_replace( '#', '', $color_val ); |
|
| 150 | + } elseif ( in_array( $setting, array( 'submit_style', 'important_style', 'auto_width' ), true ) && ! isset( $new_instance['post_content'][$setting] ) ) { |
|
| 151 | + $new_instance['post_content'][$setting] = 0; |
|
| 152 | 152 | } elseif ( $setting === 'font' ) { |
| 153 | - $new_instance['post_content'][ $setting ] = $this->force_balanced_quotation( $new_instance['post_content'][ $setting ] ); |
|
| 153 | + $new_instance['post_content'][$setting] = $this->force_balanced_quotation( $new_instance['post_content'][$setting] ); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
@@ -264,10 +264,10 @@ discard block |
||
| 264 | 264 | $sanitized_settings = array(); |
| 265 | 265 | |
| 266 | 266 | foreach ( $valid_keys as $key ) { |
| 267 | - $sanitized_settings[ $key ] = isset( $settings[ $key ] ) ? sanitize_textarea_field( $settings[ $key ] ) : $defaults[ $key ]; |
|
| 267 | + $sanitized_settings[$key] = isset( $settings[$key] ) ? sanitize_textarea_field( $settings[$key] ) : $defaults[$key]; |
|
| 268 | 268 | |
| 269 | 269 | if ( 'custom_css' !== $key && 'single_style_custom_css' !== $key ) { |
| 270 | - $sanitized_settings[ $key ] = $this->strip_invalid_characters( $sanitized_settings[ $key ] ); |
|
| 270 | + $sanitized_settings[$key] = $this->strip_invalid_characters( $sanitized_settings[$key] ); |
|
| 271 | 271 | } |
| 272 | 272 | } |
| 273 | 273 | |
@@ -562,12 +562,12 @@ discard block |
||
| 562 | 562 | $style->post_content = $this->override_defaults( $style->post_content ); |
| 563 | 563 | $style->post_content = wp_parse_args( $style->post_content, $default_values ); |
| 564 | 564 | |
| 565 | - $styles[ $style->ID ] = $style; |
|
| 565 | + $styles[$style->ID] = $style; |
|
| 566 | 566 | }//end foreach |
| 567 | 567 | |
| 568 | 568 | if ( ! $default_style ) { |
| 569 | 569 | $default_style = reset( $styles ); |
| 570 | - $styles[ $default_style->ID ]->menu_order = 1; |
|
| 570 | + $styles[$default_style->ID]->menu_order = 1; |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | return $styles; |
@@ -824,7 +824,7 @@ discard block |
||
| 824 | 824 | continue; |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | - if ( $value && $char === $value[ strlen( $value ) - 1 ] ) { |
|
| 827 | + if ( $value && $char === $value[strlen( $value ) - 1] ) { |
|
| 828 | 828 | $value = $char . $value; |
| 829 | 829 | } else { |
| 830 | 830 | $value .= $char; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | 'class' => '', |
| 51 | 51 | 'inc_children' => 'exclude', |
| 52 | 52 | ); |
| 53 | - $args = wp_parse_args( $args, $defaults ); |
|
| 53 | + $args = wp_parse_args( $args, $defaults ); |
|
| 54 | 54 | |
| 55 | 55 | if ( ! $args['field_id'] ) { |
| 56 | 56 | $args['field_id'] = $field_name; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | */ |
| 96 | 96 | public static function add_html_attr( $class, $param, &$add_html ) { |
| 97 | 97 | if ( $class ) { |
| 98 | - $add_html[ $param ] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"'; |
|
| 98 | + $add_html[$param] = sanitize_title( $param ) . '="' . esc_attr( trim( sanitize_text_field( $class ) ) ) . '"'; |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | |
@@ -350,8 +350,8 @@ discard block |
||
| 350 | 350 | ); |
| 351 | 351 | |
| 352 | 352 | foreach ( $defaults as $var => $default ) { |
| 353 | - if ( ! isset( $values[ $var ] ) ) { |
|
| 354 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 353 | + if ( ! isset( $values[$var] ) ) { |
|
| 354 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | 357 | |
@@ -367,8 +367,8 @@ discard block |
||
| 367 | 367 | ); |
| 368 | 368 | |
| 369 | 369 | foreach ( $defaults as $var => $default ) { |
| 370 | - if ( ! isset( $values[ $var ] ) ) { |
|
| 371 | - $values[ $var ] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 370 | + if ( ! isset( $values[$var] ) ) { |
|
| 371 | + $values[$var] = FrmAppHelper::get_param( $var, $default, 'get', 'sanitize_text_field' ); |
|
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | 374 | unset( $defaults ); |
@@ -419,16 +419,16 @@ discard block |
||
| 419 | 419 | |
| 420 | 420 | foreach ( $defaults as $var => $default ) { |
| 421 | 421 | if ( is_array( $default ) ) { |
| 422 | - if ( ! isset( $values[ $var ] ) ) { |
|
| 423 | - $values[ $var ] = $record && isset( $record->options[ $var ] ) ? $record->options[ $var ] : array(); |
|
| 422 | + if ( ! isset( $values[$var] ) ) { |
|
| 423 | + $values[$var] = $record && isset( $record->options[$var] ) ? $record->options[$var] : array(); |
|
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | foreach ( $default as $k => $v ) { |
| 427 | - $values[ $var ][ $k ] = $post_values && isset( $post_values[ $var ][ $k ] ) ? $post_values[ $var ][ $k ] : ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) ? $record->options[ $var ][ $k ] : $v ); |
|
| 427 | + $values[$var][$k] = $post_values && isset( $post_values[$var][$k] ) ? $post_values[$var][$k] : ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) ? $record->options[$var][$k] : $v ); |
|
| 428 | 428 | |
| 429 | 429 | if ( is_array( $v ) ) { |
| 430 | 430 | foreach ( $v as $k1 => $v1 ) { |
| 431 | - $values[ $var ][ $k ][ $k1 ] = $post_values && isset( $post_values[ $var ][ $k ][ $k1 ] ) ? $post_values[ $var ][ $k ][ $k1 ] : ( $record && isset( $record->options[ $var ] ) && isset( $record->options[ $var ][ $k ] ) && isset( $record->options[ $var ][ $k ][ $k1 ] ) ? $record->options[ $var ][ $k ][ $k1 ] : $v1 ); |
|
| 431 | + $values[$var][$k][$k1] = $post_values && isset( $post_values[$var][$k][$k1] ) ? $post_values[$var][$k][$k1] : ( $record && isset( $record->options[$var] ) && isset( $record->options[$var][$k] ) && isset( $record->options[$var][$k][$k1] ) ? $record->options[$var][$k][$k1] : $v1 ); |
|
| 432 | 432 | unset( $k1, $v1 ); |
| 433 | 433 | } |
| 434 | 434 | } |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | unset( $k, $v ); |
| 437 | 437 | } |
| 438 | 438 | } else { |
| 439 | - $values[ $var ] = $post_values && isset( $post_values['options'][ $var ] ) ? $post_values['options'][ $var ] : ( $record && isset( $record->options[ $var ] ) ? $record->options[ $var ] : $default ); |
|
| 439 | + $values[$var] = $post_values && isset( $post_values['options'][$var] ) ? $post_values['options'][$var] : ( $record && isset( $record->options[$var] ) ? $record->options[$var] : $default ); |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | unset( $var, $default ); |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | $defaults = self::get_default_opts(); |
| 486 | 486 | |
| 487 | 487 | foreach ( $defaults as $var => $default ) { |
| 488 | - $options[ $var ] = $values['options'][ $var ] ?? $default; |
|
| 488 | + $options[$var] = $values['options'][$var] ?? $default; |
|
| 489 | 489 | unset( $var, $default ); |
| 490 | 490 | } |
| 491 | 491 | } |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | public static function insert_opt_html( $args ) { |
| 682 | 682 | $class = $args['class'] ?? ''; |
| 683 | 683 | $fields = self::get_field_type_data_for_insert_opt_html(); |
| 684 | - $field = $fields[ $args['type'] ] ?? array(); |
|
| 684 | + $field = $fields[$args['type']] ?? array(); |
|
| 685 | 685 | |
| 686 | 686 | self::prepare_field_type( $field ); |
| 687 | 687 | |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | |
| 823 | 823 | foreach ( $fields as $field ) { |
| 824 | 824 | if ( $prev_order === $field->field_order ) { |
| 825 | - ++$add_order; |
|
| 825 | + ++ $add_order; |
|
| 826 | 826 | } |
| 827 | 827 | |
| 828 | 828 | if ( $add_order ) { |
@@ -1359,9 +1359,9 @@ discard block |
||
| 1359 | 1359 | $link .= ' onclick="return confirm(\'' . esc_attr( $link_details['confirm'] ) . '\')"'; |
| 1360 | 1360 | } |
| 1361 | 1361 | |
| 1362 | - $label = $link_details[ $length ] ?? $link_details['label']; |
|
| 1362 | + $label = $link_details[$length] ?? $link_details['label']; |
|
| 1363 | 1363 | |
| 1364 | - if ( $length === 'icon' && isset( $link_details[ $length ] ) ) { |
|
| 1364 | + if ( $length === 'icon' && isset( $link_details[$length] ) ) { |
|
| 1365 | 1365 | $label = '<span class="' . $label . '" title="' . esc_attr( $link_details['label'] ) . '" aria-hidden="true"></span>'; |
| 1366 | 1366 | $link .= ' aria-label="' . esc_attr( $link_details['label'] ) . '"'; |
| 1367 | 1367 | } |
@@ -1529,7 +1529,7 @@ discard block |
||
| 1529 | 1529 | $status = 'publish'; |
| 1530 | 1530 | } |
| 1531 | 1531 | |
| 1532 | - return $nice_names[ $status ]; |
|
| 1532 | + return $nice_names[$status]; |
|
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | 1535 | /** |
@@ -1593,7 +1593,7 @@ discard block |
||
| 1593 | 1593 | |
| 1594 | 1594 | if ( count( $categories ) === 1 ) { |
| 1595 | 1595 | $category = reset( $categories ); |
| 1596 | - $icon = $icons[ $category ] ?? $icon; |
|
| 1596 | + $icon = $icons[$category] ?? $icon; |
|
| 1597 | 1597 | } elseif ( $categories ) { |
| 1598 | 1598 | $icons = array_intersect_key( $icons, array_flip( $categories ) ); |
| 1599 | 1599 | $icon = reset( $icons ); |
@@ -1725,7 +1725,7 @@ discard block |
||
| 1725 | 1725 | |
| 1726 | 1726 | foreach ( $item['categories'] as $k => $category ) { |
| 1727 | 1727 | if ( in_array( $category, $plans, true ) ) { |
| 1728 | - unset( $item['categories'][ $k ] ); |
|
| 1728 | + unset( $item['categories'][$k] ); |
|
| 1729 | 1729 | return self::convert_legacy_package_names( $category ); |
| 1730 | 1730 | } |
| 1731 | 1731 | } |
@@ -1760,7 +1760,7 @@ discard block |
||
| 1760 | 1760 | * @return array |
| 1761 | 1761 | */ |
| 1762 | 1762 | public static function get_license_types( $args = array() ) { |
| 1763 | - $defaults = array( |
|
| 1763 | + $defaults = array( |
|
| 1764 | 1764 | 'include_all' => true, |
| 1765 | 1765 | 'case_lower' => false, |
| 1766 | 1766 | ); |
@@ -1969,9 +1969,9 @@ discard block |
||
| 1969 | 1969 | } |
| 1970 | 1970 | |
| 1971 | 1971 | foreach ( $shortcodes[0] as $key => $shortcode ) { |
| 1972 | - $options = trim( $shortcodes[3][ $key ] ); |
|
| 1972 | + $options = trim( $shortcodes[3][$key] ); |
|
| 1973 | 1973 | |
| 1974 | - if ( in_array( $shortcodes[1][ $key ], array( 'if ' ), true ) ) { |
|
| 1974 | + if ( in_array( $shortcodes[1][$key], array( 'if ' ), true ) ) { |
|
| 1975 | 1975 | // Skip if shortcodes. |
| 1976 | 1976 | continue; |
| 1977 | 1977 | } |
@@ -1981,7 +1981,7 @@ discard block |
||
| 1981 | 1981 | continue; |
| 1982 | 1982 | } |
| 1983 | 1983 | |
| 1984 | - $new_shortcode = '[' . $shortcodes[2][ $key ]; |
|
| 1984 | + $new_shortcode = '[' . $shortcodes[2][$key]; |
|
| 1985 | 1985 | |
| 1986 | 1986 | if ( $options ) { |
| 1987 | 1987 | $new_shortcode .= ' ' . $options; |