Skip to content

Commit c550d23

Browse files
lrobi2014christophherr
authored andcommitted
Merge pull request #341 from lrobi2014/fix/wpcs-110
* Fix errors and warnings in src directory. * Fix code sniffer erros in tests * Update getRemoteContent integration test * Revert getRemoteContent file * Remove g character * Remove g character * Rename PHP silenced errors sniffer function. * Fix spelling mistake * Revert change to array_replace sniff * Style fixes. * Style fixes
1 parent 5f94284 commit c550d23

File tree

158 files changed

+3235
-2154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+3235
-2154
lines changed

lib/admin/wp-customize.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@
1616
* @return void
1717
*/
1818
function beans_do_enqueue_wp_customize_assets() {
19-
wp_enqueue_script( 'beans-wp-customize-preview', BEANS_ADMIN_JS_URL . 'wp-customize-preview.js', array(
20-
'jquery',
21-
'customize-preview',
22-
), BEANS_VERSION, true );
19+
wp_enqueue_script(
20+
'beans-wp-customize-preview',
21+
BEANS_ADMIN_JS_URL . 'wp-customize-preview.js',
22+
array(
23+
'jquery',
24+
'customize-preview',
25+
),
26+
BEANS_VERSION,
27+
true
28+
);
2329
}
2430

2531
beans_add_smart_action( 'customize_register', 'beans_do_register_wp_customize_options' );

lib/api/compiler/class-beans-compiler.php

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private function is_wp_filesystem_direct() {
164164
*/
165165
private function maybe_make_dir() {
166166

167-
if ( ! @is_dir( $this->dir ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- This is a valid use case.
167+
if ( ! @is_dir( $this->dir ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- This is a valid use case.
168168
wp_mkdir_p( $this->dir );
169169
}
170170

@@ -224,7 +224,7 @@ public function set_filename() {
224224
* @return string
225225
*/
226226
public function hash( array $given_array ) {
227-
return substr( md5( @serialize( $given_array ) ), 0, 7 ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Valid use case.
227+
return substr( md5( @serialize( $given_array ) ), 0, 7 ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged, WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize -- Valid use case.
228228
}
229229

230230
/**
@@ -432,7 +432,7 @@ public function get_internal_content() {
432432
$fragment = beans_url_to_path( $fragment );
433433

434434
// Stop here if it isn't a valid file.
435-
if ( ! file_exists( $fragment ) || 0 === @filesize( $fragment ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case.
435+
if ( ! file_exists( $fragment ) || 0 === @filesize( $fragment ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case.
436436
return false;
437437
}
438438
}
@@ -686,7 +686,7 @@ private function get_fragments_filemtime() {
686686
}
687687

688688
if ( file_exists( $fragment ) ) {
689-
$fragments_filemtime[ $index ] = @filemtime( $fragment ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case.
689+
$fragments_filemtime[ $index ] = @filemtime( $fragment ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case.
690690
}
691691
}
692692

@@ -742,7 +742,7 @@ private function remove_modified_files( $hash, $filemtime_hash ) {
742742
foreach ( $items as $item ) {
743743

744744
// Skip this one if it's a directory.
745-
if ( @is_dir( $item ) ) { // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case.
745+
if ( @is_dir( $item ) ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case.
746746
continue;
747747
}
748748

@@ -769,7 +769,7 @@ private function remove_modified_files( $hash, $filemtime_hash ) {
769769
}
770770

771771
// Clean up other modified files.
772-
@unlink( $this->dir . '/' . $item ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case.
772+
@unlink( $this->dir . '/' . $item ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case.
773773
}
774774
}
775775

@@ -844,26 +844,38 @@ private function kill() {
844844
$this->report();
845845
}
846846

847-
$html = beans_output( 'beans_compiler_error_title_text', sprintf(
848-
'<h2>%s</h2>',
849-
__( 'Not cool, Beans cannot work its magic :(', 'tm-beans' )
850-
) );
847+
$html = beans_output(
848+
'beans_compiler_error_title_text',
849+
sprintf(
850+
'<h2>%s</h2>',
851+
__( 'Not cool, Beans cannot work its magic :(', 'tm-beans' )
852+
)
853+
);
851854

852-
$html .= beans_output( 'beans_compiler_error_message_text', sprintf(
853-
'<p>%s</p>',
854-
__( 'Your current install or file permission prevents Beans from working its magic. Please get in touch with Beans support. We will gladly get you started within 24 - 48 hours (working days).', 'tm-beans' )
855-
) );
855+
$html .= beans_output(
856+
'beans_compiler_error_message_text',
857+
sprintf(
858+
'<p>%s</p>',
859+
__( 'Your current install or file permission prevents Beans from working its magic. Please get in touch with Beans support. We will gladly get you started within 24 - 48 hours (working days).', 'tm-beans' )
860+
)
861+
);
856862

857-
$html .= beans_output( 'beans_compiler_error_contact_text', sprintf(
858-
'<a class="button" href="https://www.getbeans.io/contact/?compiler_report=1" target="_blanc">%s</a>',
859-
__( 'Contact Beans Support', 'tm-beans' )
860-
) );
863+
$html .= beans_output(
864+
'beans_compiler_error_contact_text',
865+
sprintf(
866+
'<a class="button" href="https://www.getbeans.io/contact/?compiler_report=1" target="_blanc">%s</a>',
867+
__( 'Contact Beans Support', 'tm-beans' )
868+
)
869+
);
861870

862-
$html .= beans_output( 'beans_compiler_error_report_text', sprintf(
863-
'<p style="margin-top: 12px; font-size: 12px;"><a href="' . add_query_arg( 'beans_send_compiler_report', true ) . '">%1$s</a>. %2$s</p>',
864-
__( 'Send us an automatic report', 'tm-beans' ),
865-
__( 'We respect your time and understand you might not be able to contact us.', 'tm-beans' )
866-
) );
871+
$html .= beans_output(
872+
'beans_compiler_error_report_text',
873+
sprintf(
874+
'<p style="margin-top: 12px; font-size: 12px;"><a href="' . add_query_arg( 'beans_send_compiler_report', true ) . '">%1$s</a>. %2$s</p>',
875+
__( 'Send us an automatic report', 'tm-beans' ),
876+
__( 'We respect your time and understand you might not be able to contact us.', 'tm-beans' )
877+
)
878+
);
867879

868880
wp_die( wp_kses_post( $html ) );
869881
}

lib/api/compiler/class-beans-page-compiler.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,14 @@ public function compile_page_scripts() {
108108
$this->dequeued_scripts = $scripts;
109109
add_action( 'wp_print_scripts', array( $this, 'dequeue_scripts' ), 9999 );
110110

111-
beans_compile_js_fragments( 'beans', $scripts, array(
112-
'in_footer' => 'aggressive' === get_option( 'beans_compile_all_scripts_mode', 'aggressive' ),
113-
'version' => null,
114-
) );
111+
beans_compile_js_fragments(
112+
'beans',
113+
$scripts,
114+
array(
115+
'in_footer' => 'aggressive' === get_option( 'beans_compile_all_scripts_mode', 'aggressive' ),
116+
'version' => null,
117+
)
118+
);
115119
}
116120

117121
/**

lib/api/compiler/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ function beans_flush_compiler( $id, $file_format = false, $admin = false ) {
217217
foreach ( beans_scandir( $dir ) as $item ) {
218218

219219
if ( beans_str_ends_with( $item, ".{$file_format}" ) ) {
220-
@unlink( trailingslashit( $dir ) . $item ); // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged -- Valid use case.
220+
@unlink( trailingslashit( $dir ) . $item ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- Valid use case.
221221
}
222222
}
223223
}

lib/api/fields/class-beans-fields.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,17 @@ private function add() {
129129
* @return array
130130
*/
131131
private function standardize_field( array $field ) {
132-
$field = array_merge( array(
133-
'label' => false,
134-
'description' => false,
135-
'default' => false,
136-
'context' => $this->context,
137-
'attributes' => array(),
138-
'db_group' => false,
139-
), $field );
132+
$field = array_merge(
133+
array(
134+
'label' => false,
135+
'description' => false,
136+
'default' => false,
137+
'context' => $this->context,
138+
'attributes' => array(),
139+
'db_group' => false,
140+
),
141+
$field
142+
);
140143

141144
// Set the field's name.
142145
$field['name'] = 'wp_customize' === $this->context ? $field['id'] : 'beans_fields[' . $field['id'] . ']';

lib/api/fields/functions.php

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,14 @@ function beans_field( array $field ) {
9898

9999
$group_field_type = 'group' === $field['type'];
100100

101-
beans_open_markup_e( 'beans_field_wrap', 'div', array(
102-
'class' => 'bs-field-wrap bs-' . $field['type'] . ' ' . $field['context'],
103-
), $field );
101+
beans_open_markup_e(
102+
'beans_field_wrap',
103+
'div',
104+
array(
105+
'class' => 'bs-field-wrap bs-' . $field['type'] . ' ' . $field['context'],
106+
),
107+
$field
108+
);
104109

105110
// Set fields loop to cater for groups.
106111
if ( $group_field_type ) {
@@ -109,26 +114,46 @@ function beans_field( array $field ) {
109114
$fields = array( $field );
110115
}
111116

112-
beans_open_markup_e( 'beans_field_inside', 'div', array(
113-
'class' => 'bs-field-inside',
114-
), $fields );
117+
beans_open_markup_e(
118+
'beans_field_inside',
119+
'div',
120+
array(
121+
'class' => 'bs-field-inside',
122+
),
123+
$fields
124+
);
115125

116126
if ( $group_field_type ) {
117-
beans_open_markup_e( 'beans_field_group_fieldset', 'fieldset', array(
118-
'class' => 'bs-field-fieldset',
119-
), $field );
120-
beans_open_markup_e( 'beans_field_group_legend', 'legend', array(
121-
'class' => 'bs-field-legend',
122-
), $field );
127+
beans_open_markup_e(
128+
'beans_field_group_fieldset',
129+
'fieldset',
130+
array(
131+
'class' => 'bs-field-fieldset',
132+
),
133+
$field
134+
);
135+
beans_open_markup_e(
136+
'beans_field_group_legend',
137+
'legend',
138+
array(
139+
'class' => 'bs-field-legend',
140+
),
141+
$field
142+
);
123143
echo esc_html( $field['label'] );
124144
beans_close_markup_e( 'beans_field_group_legend', 'legend', $field );
125145
}
126146

127147
// Loop through fields.
128148
foreach ( $fields as $single_field ) {
129-
beans_open_markup_e( 'beans_field[_' . $single_field['id'] . ']', 'div', array(
130-
'class' => 'bs-field bs-' . $single_field['type'],
131-
), $single_field );
149+
beans_open_markup_e(
150+
'beans_field[_' . $single_field['id'] . ']',
151+
'div',
152+
array(
153+
'class' => 'bs-field bs-' . $single_field['type'],
154+
),
155+
$single_field
156+
);
132157

133158
if ( $group_field_type ) {
134159
/**

lib/api/fields/types/image.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,15 @@ function beans_field_image( array $field ) {
6363
* @return array
6464
*/
6565
function _beans_get_image_id_attributes( $id, array $field, $is_multiple ) {
66-
$attributes = array_merge( array(
67-
'class' => 'image-id',
68-
'type' => 'hidden',
69-
'name' => $is_multiple ? $field['name'] . '[]' : $field['name'], // Return single value if not multiple.
70-
'value' => $id,
71-
), $field['attributes'] );
66+
$attributes = array_merge(
67+
array(
68+
'class' => 'image-id',
69+
'type' => 'hidden',
70+
'name' => $is_multiple ? $field['name'] . '[]' : $field['name'], // Return single value if not multiple.
71+
'value' => $id,
72+
),
73+
$field['attributes']
74+
);
7275

7376
if ( 'placeholder' === $id ) {
7477
$attributes = array_merge(

lib/api/fields/types/radio.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,14 @@ function _beans_standardize_radio_image( $value, $radio ) {
8484
);
8585
}
8686

87-
$radio = array_merge( array(
88-
'src' => '',
89-
'alt' => '',
90-
'screen_reader_text' => '',
91-
), $radio );
87+
$radio = array_merge(
88+
array(
89+
'src' => '',
90+
'alt' => '',
91+
'screen_reader_text' => '',
92+
),
93+
$radio
94+
);
9295

9396
if ( $radio['screen_reader_text'] && $radio['alt'] ) {
9497
return $radio;

lib/api/fields/types/text.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
* }
2323
*/
2424
function beans_field_text( array $field ) {
25-
printf( '<input id="%s" type="text" name="%s" value="%s" %s>',
25+
printf(
26+
'<input id="%s" type="text" name="%s" value="%s" %s>',
2627
esc_attr( $field['id'] ),
2728
esc_attr( $field['name'] ),
2829
esc_attr( $field['value'] ),

lib/api/fields/types/textarea.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
* }
2323
*/
2424
function beans_field_textarea( array $field ) {
25-
printf( '<textarea id="%s" name="%s" %s>%s</textarea>',
25+
printf(
26+
'<textarea id="%s" name="%s" %s>%s</textarea>',
2627
esc_attr( $field['id'] ),
2728
esc_attr( $field['name'] ),
28-
beans_esc_attributes( $field['attributes'] ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaping is handled in the function.
29+
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaping is handled in the function.
30+
beans_esc_attributes( $field['attributes'] ),
2931
esc_textarea( $field['value'] )
3032
);
3133
}

0 commit comments

Comments
 (0)