Skip to content

Commit

Permalink
PHPCS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
polevaultweb committed Mar 16, 2024
1 parent 9cc61eb commit cea36b2
Show file tree
Hide file tree
Showing 160 changed files with 4,309 additions and 3,000 deletions.
93 changes: 48 additions & 45 deletions includes/abstracts/class-wpcm-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function get_cached_widget( $args ) {
}

if ( isset( $cache[ $args['widget_id'] ] ) ) {
echo $cache[ $args['widget_id'] ];
echo $cache[ $args['widget_id'] ]; // phpcs:ignore

return true;
}
Expand All @@ -97,7 +97,9 @@ public function cache_widget( $args, $content ) {
* Flush the cache
*/
public function flush_widget_cache() {
wp_cache_delete( apply_filters( 'wpclubmanager_cached_widget_id', $this->widget_id ), 'widget' );
if ( $this->widget_id ) {
wp_cache_delete( apply_filters( 'wpclubmanager_cached_widget_id', $this->widget_id ), 'widget' );
}
}

/**
Expand All @@ -107,12 +109,12 @@ public function flush_widget_cache() {
* @param array $instance
*/
public function widget_start( $args, $instance ) {
echo $args['before_widget'];
echo $args['before_widget']; // phpcs:ignore

$title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base );

if ( $title ) {
echo $args['before_title'] . $title . $args['after_title'];
echo $args['before_title'] . esc_html( $title ) . $args['after_title']; // phpcs:ignore
}
}

Expand All @@ -122,7 +124,7 @@ public function widget_start( $args, $instance ) {
* @param array $args
*/
public function widget_end( $args ) {
echo $args['after_widget'];
echo $args['after_widget']; // phpcs:ignore
}

/**
Expand Down Expand Up @@ -168,6 +170,7 @@ public function update( $new_instance, $old_instance ): array {
$new_instance[ $key ] = implode( ',', $new_instance[ $key ] );
}
$instance[ $key ] = strip_tags( $new_instance[ $key ] );
break;
case 'standings_columns':
if ( is_array( $new_instance[ $key ] ) ) {
$new_instance[ $key ] = implode( ',', $new_instance[ $key ] );
Expand Down Expand Up @@ -212,27 +215,27 @@ public function form( $instance ) {
case 'text':
?>
<p class="wpcm-widget-admin">
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
<label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo esc_html( $setting['label'] ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"
name="<?php echo $this->get_field_name( $key ); ?>" type="text"
value="<?php echo esc_attr( $value ); ?>"/>
name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>" type="text"
value="<?php echo esc_attr( $value ); ?>"/>
</p>
<?php
break;
case 'number':
?>
<p class="wpcm-widget-admin">
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo $this->get_field_name( $key ); ?>" type="number" step="<?php echo esc_attr( $setting['step'] ); ?>" min="<?php echo esc_attr( $setting['min'] ); ?>" max="<?php echo esc_attr( $setting['max'] ); ?>" value="<?php echo esc_attr( $value ); ?>"/>
<label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo esc_html( $setting['label'] ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>" type="number" step="<?php echo esc_attr( $setting['step'] ); ?>" min="<?php echo esc_attr( $setting['min'] ); ?>" max="<?php echo esc_attr( $setting['max'] ); ?>" value="<?php echo esc_attr( $value ); ?>"/>
</p>
<?php
break;
case 'select':
?>
<div class="wpcm-widget-admin">
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
<label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo esc_html( $setting['label'] ); ?></label>
<select class="widefat" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"
name="<?php echo $this->get_field_name( $key ); ?>">
name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>">
<?php foreach ( $setting['options'] as $option_key => $option_value ) : ?>
<option
value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, $value ); ?>><?php echo esc_html( $option_value ); ?></option>
Expand All @@ -245,7 +248,7 @@ public function form( $instance ) {
case 'tax_select':
?>
<div class="wpcm-widget-admin"><label
for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo esc_html( $setting['label'] ); ?></label>
<?php
$args = array(
'show_option_none' => __( 'All', 'wp-club-manager' ),
Expand All @@ -267,15 +270,15 @@ public function form( $instance ) {
case 'pages_select':
?>
<div class="wpcm-widget-admin"><label
for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo esc_html( $setting['label'] ); ?></label>
<?php
$args = array(
'show_option_none' => __( 'None', 'wp-club-manager' ),
'selected' => $value,
'name' => $this->get_field_name( $key ),
'id' => $this->get_field_id( $key ),
'name' => esc_attr( $this->get_field_name( $key ) ),
'id' => esc_attr( $this->get_field_id( $key ) ),
);
wp_dropdown_pages( $args );
wp_dropdown_pages( $args ); // phpcs:ignore
?>
</div>
<?php
Expand All @@ -284,7 +287,7 @@ public function form( $instance ) {
case 'posts_select':
?>
<div class="wpcm-widget-admin"><label
for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo esc_html( $setting['label'] ); ?></label>
<?php
$args = array(
// 'show_option_none' => __( 'None', 'wp-club-manager' ),
Expand All @@ -307,9 +310,9 @@ public function form( $instance ) {
?>
<p class="wpcm-widget-admin">
<input id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"
name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>" type="checkbox"
value="1" <?php checked( $value, '1' ); ?> />
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>" type="checkbox"
value="1" <?php checked( $value, '1' ); ?> />
<label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo esc_html( $setting['label'] ); ?></label>
</p>
<?php
break;
Expand All @@ -319,17 +322,17 @@ public function form( $instance ) {
?>
<div class="wpcm-widget-admin">
<label
for="<?php echo $this->get_field_id( $key ); ?>"><?php _e( 'Order by', 'wp-club-manager' ); ?></label>
for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php esc_html_e( 'Order by', 'wp-club-manager' ); ?></label>
<select id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"
name="<?php echo $this->get_field_name( $key ); ?>">
name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>">
<?php foreach ( $setting['options'] as $option_key => $option_value ) : ?>
<option
value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, $value ); ?>><?php echo esc_html( $option_value ); ?></option>
<?php endforeach; ?>
<?php foreach ( $player_stats_labels as $option_key => $option_value ) : ?>

<option id="<?php echo $key; ?>"
value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, $value ); ?>><?php echo strip_tags( $option_value ); ?></option>
<option id="<?php echo esc_attr( $key ); ?>"
value="<?php echo esc_attr( esc_attr( $option_key ) ); ?>" <?php selected( $option_key, $value ); ?>><?php echo esc_html( strip_tags( $option_value ) ); ?></option>

<?php endforeach; ?>
</select>
Expand All @@ -339,28 +342,28 @@ public function form( $instance ) {

case 'player_stats':
$stats_labels = wpcm_get_player_all_names();
$stats = explode( ',', $value );
$stats = explode( ',', $value );
?>
<div class="wpcm-widget-admin">
<table>
<tr>
<?php
$count = 0;
foreach ( $stats_labels as $option_key => $option_value ) {
++ $count;
++$count;
if ( $count > 2 ) {
$count = 1;
echo '</tr><tr>';
}
?>
<td>
<label class="selectit"
for="<?php echo $this->get_field_id( $key ); ?>-<?php echo $option_key; ?>">
for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>-<?php echo esc_attr( $option_key ); ?>">
<input type="checkbox"
id="<?php echo $this->get_field_id( $key ); ?>-<?php echo $option_key; ?>"
name="<?php echo $this->get_field_name( $key ); ?>[]"
value="<?php echo $option_key; ?>" <?php checked( in_array( $option_key, $stats ) ); ?> />
<?php echo strip_tags( $option_value ); ?>
id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>-<?php echo esc_attr( $option_key ); ?>"
name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>[]"
value="<?php echo esc_attr( $option_key ); ?>" <?php checked( in_array( $option_key, $stats ) ); ?> />
<?php echo esc_html( strip_tags( $option_value ) ); ?>
</label>
</td>
<?php } ?>
Expand All @@ -375,13 +378,13 @@ public function form( $instance ) {
?>
<div class="wpcm-widget-admin">
<label
for="<?php echo $this->get_field_id( $key ); ?>"><?php _e( 'Order by', 'wp-club-manager' ); ?></label>
for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php esc_html_e( 'Order by', 'wp-club-manager' ); ?></label>
<select id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"
name="<?php echo $this->get_field_name( $key ); ?>">
name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>">
<?php foreach ( $standings_columns_labels as $option_key => $option_value ) : ?>

<option id="<?php echo $key; ?>"
value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, $value ); ?>><?php echo strip_tags( $option_value ); ?></option>
<option id="<?php echo esc_attr( $key ); ?>"
value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, $value ); ?>><?php echo esc_html( strip_tags( $option_value ) ); ?></option>

<?php endforeach; ?>
</select>
Expand All @@ -391,25 +394,25 @@ public function form( $instance ) {

case 'standings_columns':
$column_labels = wpcm_get_preset_labels( 'standings', 'label' );
$columns = explode( ',', $value );
$columns = explode( ',', $value );
?>
<div class="wpcm-widget-admin">
<table>
<tr>
<?php
$count = 0;
foreach ( $column_labels as $option_key => $option_value ) {
++ $count;
++$count;
if ( $count > 4 ) {
$count = 1;
echo '</tr><tr>';
}
?>
<td>
<label class="selectit"
for="<?php echo $this->get_field_id( $key ); ?>-<?php echo $option_key; ?>">
<input type="checkbox" id="<?php echo $this->get_field_id( $key ); ?>-<?php echo $option_key; ?>" name="<?php echo $this->get_field_name( $key ); ?>[]" value="<?php echo $option_key; ?>" <?php checked( in_array( $option_key, $columns ) ); ?> />
<?php echo strip_tags( $option_value ); ?>
for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>-<?php echo esc_attr( $option_key ); ?>">
<input type="checkbox" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>-<?php echo esc_attr( $option_key ); ?>" name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>[]" value="<?php echo esc_attr( $option_key ); ?>" <?php checked( in_array( $option_key, $columns ) ); ?> />
<?php echo esc_html( strip_tags( $option_value ) ); ?>
</label>
</td>
<?php } ?>
Expand All @@ -434,12 +437,12 @@ public function form( $instance ) {
}
?>
<div class="wpcm-widget-admin">
<label for="<?php echo $this->get_field_id( $key ); ?>"><?php echo $setting['label']; ?></label>
<label for="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"><?php echo esc_html( $setting['label'] ); ?></label>
<select class="widefat" id="<?php echo esc_attr( $this->get_field_id( $key ) ); ?>"
name="<?php echo $this->get_field_name( $key ); ?>">
name="<?php echo esc_attr( $this->get_field_name( $key ) ); ?>">
<?php foreach ( $focus_options as $option_key => $option_value ) : ?>
<option
value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, $value ); ?>><?php echo strip_tags( $option_value ); ?></option>
value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $option_key, $value ); ?>><?php echo esc_html( strip_tags( $option_value ) ); ?></option>
<?php endforeach; ?>
</select>
</div>
Expand All @@ -448,7 +451,7 @@ public function form( $instance ) {

case 'section_heading':
?>
<h4><?php echo $setting['label']; ?></h4>
<h4><?php echo esc_html( $setting['label'] ); ?></h4>
<?php
break;

Expand Down
Loading

0 comments on commit cea36b2

Please sign in to comment.