Skip to content

Commit

Permalink
Fix: plugin Check
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatrangnet authored and rilwis committed Oct 14, 2024
1 parent 8a21f91 commit 8ee9153
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 23 deletions.
19 changes: 11 additions & 8 deletions src/GroupField.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private function find_element_dynamic_tag( $settings, &$results = [] ) {
$name = 'setting' !== $elements['settings']['object-type'] ? 'meta-box-settings-text' : 'meta-box-text';

$results = array_merge_recursive( $results, [
'editor' => '[elementor-tag id="' . dechex( rand( 1, 99999999 ) ) . '" name="' . $name . '" settings="' . urlencode( json_encode( [
'editor' => '[elementor-tag id="' . dechex( wp_rand( 1, 99999999 ) ) . '" name="' . $name . '" settings="' . urlencode( wp_json_encode( [
'key' => str_replace( '.', ':', $field_group[1] ),
'mb_skin_template' => $elements['settings']['mb_skin_template'],
] ) ) . '"]',
Expand Down Expand Up @@ -294,7 +294,7 @@ public function get_value_dynamic_tag( $post_type, $field_id, $template_id = nul
$value_field = $value_field[ $field_id ];
}

echo $value_field;
echo $value_field; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
return true;
}

Expand All @@ -307,15 +307,16 @@ public function extract_value_dynamic_tag( $field = [], $field_setting = [], $te
echo '<div class="mbei-group mbei-group-nested">';
foreach ( $field as $key => $value ) {
if ( isset( $field_setting[ $key ] ) && isset( $field_setting[ $key ]['mime_type'] ) && 'image' === $field_setting[ $key ]['mime_type'] && ! empty( $value ) ) {
echo '<div class="mbei-subfield mbei-subfield--' . $key . '">' . wp_get_attachment_image( $value, 'full' ) . '</div>';
echo '<div class="mbei-subfield mbei-subfield--' . $key . '">' . wp_get_attachment_image( $value, 'full' ) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
continue;
}
echo '<div class="mbei-subfield mbei-subfield--' . $key . '"> ' . $value . '</div>';
echo '<div class="mbei-subfield mbei-subfield--' . $key . '"> ' . $value . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
echo '</div>';
return;
}

// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $this->get_placeholder_template( $template_id, [
'loop_header' => '<div class="mbei-sub-group">',
'loop_footer' => '</div>',
Expand Down Expand Up @@ -537,6 +538,7 @@ public function render_nested_group( $data_groups, $data_column ) {
continue;
}

// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<div class="mbei-subfield mbei-subfield--' . ( $clone === false ? $key : $data_column['id'] ) . '">';
if ( is_array( $value ) && ! empty( $value ) ) {
$data_column[ $key ]['fields'] = array_combine( array_column( $data_column[ $key ]['fields'], 'id' ), $data_column[ $key ]['fields'] );
Expand All @@ -557,7 +559,7 @@ public function display_data_template( $template_id, $data_groups, $data_column,
$content_template = $this->get_template( $template_id );
$cols = array_keys( $content_template['data'] );

if ( stripos( json_encode( $cols ), '.' ) !== false ) {
if ( stripos( wp_json_encode( $cols ), '.' ) !== false ) {
$tmp_cols = $this->split_field_nested( $cols );
}

Expand Down Expand Up @@ -701,7 +703,7 @@ public function display_data_template( $template_id, $data_groups, $data_column,
$content = str_replace( $content_template['data'][ $col ]['content'], $value, $content );

}
echo $content;
echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}

Expand All @@ -718,7 +720,7 @@ public function display_data_widget( $data_groups, $data_column, $options = [
continue;
}

echo $options['loop_header'];
echo $options['loop_header']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
foreach ( $data_group as $key => $value ) {
$data_sub_column = [];
if ( is_array( $value ) && ! empty( $value ) ) {
Expand All @@ -734,9 +736,10 @@ public function display_data_widget( $data_groups, $data_column, $options = [
continue;
}

// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo sprintf( '<div class="mbei-subfield mbei-subfield--%s">%s</div>', $key, $content );
}
echo $options['loop_footer'];
echo $options['loop_footer']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Templates/display_field-icon.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
echo $this->display_icon( $data, $field );
echo $this->display_icon( $data, $field ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2 changes: 1 addition & 1 deletion src/Templates/display_field-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use MBEI\GroupField;

if ( true === $return ) {
echo GroupField::change_url_ssl( wp_get_attachment_image_src( $data, 'full' )[0] );
echo GroupField::change_url_ssl( wp_get_attachment_image_src( $data, 'full' )[0] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
} else {
echo wp_get_attachment_image( $data, 'full' );
}
Expand Down
2 changes: 1 addition & 1 deletion src/Templates/display_field-post.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
$post = get_post( $data );
echo $post->post_title;
echo $post->post_title; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2 changes: 1 addition & 1 deletion src/Templates/display_field-text.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php echo $data;
<?php echo $data; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2 changes: 1 addition & 1 deletion src/Templates/display_field-url.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
echo sprintf( '<a href="%s">%s</a>', $data, $data );
echo sprintf( '<a href="%s">%s</a>', $data, $data ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

2 changes: 1 addition & 1 deletion src/Templates/display_field-user.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php
$user = get_user_by( 'id', $data );
echo $user->data->display_name;
echo $user->data->display_name; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2 changes: 1 addition & 1 deletion src/Traits/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private function the_value() {

$field = rwmb_get_field_settings( $field_id, [], null );
if ( ! empty( $field ) && ( 'color' === $field['type'] ) ) {
echo rwmb_get_value( $field_id );
echo rwmb_get_value( $field_id ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private function the_value() {

$field = rwmb_get_field_settings( $field_id, [ 'object_type' => 'setting' ], $option_name );
if ( ! empty( $field ) && ( 'color' === $field['type'] ) ) {
echo rwmb_get_value( trim( $field_id ), [ 'object_type' => 'setting' ], $option_name );
echo rwmb_get_value( trim( $field_id ), [ 'object_type' => 'setting' ], $option_name ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
return;
}

Expand Down
10 changes: 6 additions & 4 deletions src/Widgets/GroupSkin.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GroupSkin extends Skin_Base {

public function __construct( Widget_Base $parent ) {
parent::__construct( $parent );
$this->skin_id = dechex( rand( 1, 99999999 ) );
$this->skin_id = dechex( wp_rand( 1, 99999999 ) );
}

public function get_title() {
Expand Down Expand Up @@ -50,7 +50,9 @@ protected function render_loop_footer() {

private function style_inline( $size, $spacing ) {
echo '<style type="text/css">';
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '.mbei-sub-groups[data-id="' . $this->get_skin_id() . '"]{display: grid; grid-template-columns: repeat(' . $size . ', 1fr);}';
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '.mbei-sub-groups[data-id="' . $this->get_skin_id() . '"] .mbei-sub-group{gap: ' . $spacing . 'px;}';
echo '</style>';
}
Expand Down Expand Up @@ -106,8 +108,8 @@ public function render() {
$mb_column = ! empty( $this->parent->get_settings_for_display( 'mb_column' ) ) ? $this->parent->get_settings_for_display( 'mb_column' ) : 3;
$mb_spacing = ! empty( $this->parent->get_settings_for_display( 'mb_spacing' ) ) ? $this->parent->get_settings_for_display( 'mb_spacing' ) : 20;

echo $this->style_inline( $mb_column, $mb_spacing );
echo $this->render_header();
echo $this->style_inline( $mb_column, $mb_spacing ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $this->render_header(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( $this->parent->get_settings_for_display( 'mb_skin_template' ) ) {
$group_fields->display_data_template( $this->parent->get_settings_for_display( 'mb_skin_template' ), $data_groups, $data_column, [
'loop_header' => $this->render_loop_header(),
Expand All @@ -119,7 +121,7 @@ public function render() {
'loop_footer' => $this->render_loop_footer(),
]);
}
echo $this->render_footer();
echo $this->render_footer(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

}
6 changes: 3 additions & 3 deletions src/Widgets/MBGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function render_nested_group( $data_groups, $data_column, $group_fields )
continue;
}

echo '<div class="mbei-subfield mbei-subfield--' . $key . '">';
echo '<div class="mbei-subfield mbei-subfield--' . $key . '">'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( is_array( $value ) && ! empty( $value ) ) {
$data_column[ $key ]['fields'] = array_combine( array_column( $data_column[ $key ]['fields'], 'id' ), $data_column[ $key ]['fields'] );
$this->render_nested_group( $value, $data_column[ $key ]['fields'], $group_fields );
Expand Down Expand Up @@ -261,7 +261,7 @@ protected function render() {
$fields = $group_fields->get_field_group( 'post' === $settings['object-type'] ? $settings['field-group'] : $settings['field-group-setting'], $settings['object-type'] );
$data_column = array_combine( array_column( $fields['fields'], 'id' ), $fields['fields'] );

echo $this->render_header();
echo $this->render_header(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( $this->get_settings_for_display( 'mb_skin_template' ) ) {
$group_fields->display_data_template( $this->get_settings_for_display( 'mb_skin_template' ), $data_groups, $data_column, [
'loop_header' => $this->render_loop_header(),
Expand All @@ -273,7 +273,7 @@ protected function render() {
'loop_footer' => $this->render_loop_footer(),
]);
}
echo $this->render_footer();
echo $this->render_footer(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

protected function content_template() {
Expand Down

0 comments on commit 8ee9153

Please sign in to comment.