Skip to content

Commit

Permalink
More phpcs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dshanske committed Oct 1, 2023
1 parent b9f2d2a commit 1c80bad
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 40 deletions.
2 changes: 1 addition & 1 deletion includes/class-kind-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public static function options_callback() {
*/
public static function checkbox_callback( array $args ) {
$option = get_option( $args['name'] );
$checked = intval($option ?? 0);
$checked = intval( $option ?? 0 );
printf( '<input name="%1$s" type="hidden" value="0" />', esc_attr( $args['name'] ) ); // phpcs:ignore
printf( '<input name="%1$s" type="checkbox" value="1" %2$s />', esc_attr( $args['name'] ), checked( 1, $checked, false) ); // phpcs:ignore
}
Expand Down
2 changes: 1 addition & 1 deletion includes/class-kind-media-metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public static function wp_sanitize_media_metadata( $metadata ) {
$value = wp_sanitize_media_metadata( $value );
} elseif ( is_string( $value ) && preg_match( '~[^\x20-\x7E\t\r\n]~', $value ) > 0 ) {
$encoding = mb_detect_encoding( $value, 'ISO-8859-1, UCS-2' );
$value = $encoding ? mb_convert_encoding( $value, 'UTF-8', $encoding ) : utf8_encode( $value );
$value = $encoding ? mb_convert_encoding( $value, 'UTF-8', $encoding ) $value;
}
$metadata[ $name ] = $value;
}
Expand Down
8 changes: 4 additions & 4 deletions includes/class-kind-metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ public static function kind_the_time( $prefix, $label, $datetime, $class ) {
$offset = $time['offset'];
}
$string = '<label class="half ' . $class . '" for="' . $prefix . '">' . $label . '<br/>';
$string .= '<input class="date" type="date" name="' . $prefix . '_date" id="' . $prefix . '_date" value="' . ($time['date'] ?? '') . '"/>';
$string .= '<input class="time" type="time" name="' . $prefix . '_time" id="' . $prefix . '_time" step="1" value="' . ($time['time'] ?? '') . '"/>';
$string .= '<input class="date" type="date" name="' . $prefix . '_date" id="' . $prefix . '_date" value="' . ( $time['date'] ?? '' ) . '"/>';
$string .= '<input class="time" type="time" name="' . $prefix . '_time" id="' . $prefix . '_time" step="1" value="' . ( $time['time'] ?? '' ) . '"/>';
$string .= self::select_offset( $prefix, $offset );
$string .= '</label>';
return $string;
Expand Down Expand Up @@ -397,9 +397,9 @@ public static function save_post( $post_id, $post ) {
}

$durations = array(
'Y' => intval( $_POST['duration_years'] ?? '' ),
'Y' => intval( $_POST['duration_years'] ?? '' ),
'M' => intval( $_POST['duration_months'] ?? '' ),
'D' => intval( $_POST['duration_days'] ?? '' ),
'D' => intval( $_POST['duration_days'] ?? '' ),
'H' => intval( $_POST['duration_hours'] ?? '' ),
'I' => intval( $_POST['duration_minutes'] ?? '' ),
'S' => intval( $_POST['duration_seconds'] ?? '' ),
Expand Down
2 changes: 1 addition & 1 deletion includes/class-kind-post-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function widget( $args, $instance ) {
'terms' => $kind,
),
),
'numberposts' => $instance['number'] ?? 5 ,
'numberposts' => $instance['number'] ?? 5,
);
$posts = get_posts( $query );
}
Expand Down
3 changes: 0 additions & 3 deletions includes/class-kind-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public function __construct( $post ) {
}

$post = get_post( $post );
if ( ! $post ) {
return false;
}
}

/*
Expand Down
13 changes: 6 additions & 7 deletions includes/class-kind-taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -959,17 +959,16 @@ public static function select_metabox( $post ) {
}
if ( isset( $_GET['kind'] ) ) {
$default = get_term_by( 'slug', $_GET['kind'], 'kind' );
} else {
} elseif ( 'publish' === get_post_status( $post ) ) {
// On existing published posts without a kind fall back on article which most closely mimics the behavior of an unclassified post
if ( 'publish' === get_post_status( $post ) ) {
$default = get_term_by( 'slug', 'article', 'kind' );
} else {
$default = get_term_by( 'slug', get_option( 'kind_default' ), 'kind' );
}
$default = get_term_by( 'slug', 'article', 'kind' );
} else {
$default = get_term_by( 'slug', get_option( 'kind_default' ), 'kind' );
}

$terms = get_terms(
'kind',
array(
'taxonomy' => 'kind',
'hide_empty' => 0,
)
);
Expand Down
9 changes: 1 addition & 8 deletions includes/class-mf2-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct( $post ) {
}
$post = get_post( $post );
if ( ! $post ) {
return false;
return;
}
$this->mf2 = $this->get_mf2meta();
$this->post_author = $post->post_author;
Expand Down Expand Up @@ -759,10 +759,3 @@ public function get_attachments_from_urls( $urls ) {
return array_filter( array_unique( $att_ids ) );
}
}

function get_mf2_post( $post_id ) {
if ( $post_id instanceof MF2_Post ) {
return $post_id;
}
return new MF2_Post( $post_id );
}
2 changes: 1 addition & 1 deletion includes/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ function ( $time ) use ( $format ) {
// Backcompat for wp_filter_content_tags introduced in 5.5.
if ( ! function_exists( 'wp_filter_content_tags' ) ) {
function wp_filter_content_tags( $content ) {
return wp_make_content_images_responsive( $content );
return wp_make_content_images_responsive( $content ); // phpcs:ignore
}
}
26 changes: 13 additions & 13 deletions includes/kind-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@ function kind_display( $post_id = null ) {
echo Kind_View::get_display( $post_id ); // phpcs:ignore
}

function kind_flatten_array( $array ) {
if ( ! is_array( $array ) ) {
return $array;
function kind_flatten_array( $a ) {
if ( ! is_array( $a ) ) {
return $a;
}
if ( wp_is_numeric_array( $array ) ) {
$array = array_map( 'kind_flatten_array', $array );
if ( wp_is_numeric_array( $a ) ) {
$array = array_map( 'kind_flatten_array', $a );
}
$array = array_filter( $array );
if ( 1 === count( $array ) ) {
return $array[0];
$array = array_filter( $a );
if ( 1 === count( $a ) ) {
return $a[0];
}
}

Expand All @@ -139,18 +139,18 @@ function kind_src_url_in_content( $content ) {
* @return string Marked up link to a post.
**/

function kind_get_the_link( $post = null, $class = null ) {
function kind_get_the_link( $post = null, $cls = null ) {
$post = get_post( $post );
$kind = get_post_kind_slug( $post );

if ( is_array( $class ) ) {
$class = implode( ' ', $class );
if ( is_array( $cls ) ) {
$cls = implode( ' ', $cls );
}
$class = 'class=' . $class;
$cls = 'class=' . $class;
$time_string = '<time %1$s datetime="%2$s">%3$s</time>';
$time_string = sprintf(
$time_string,
esc_attr( $class ),
esc_attr( $cls ),
esc_attr( get_the_date( DATE_W3C, $post ) ),
get_the_date( '', $post )
);
Expand Down
1 change: 0 additions & 1 deletion includes/register-kinds.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
'name' => __( 'Likes', 'indieweb-post-kinds' ), // General name for the kind plural
'verb' => __( 'Liked', 'indieweb-post-kinds' ), // The string for the verb or action (liked this)
'property' => 'like-of', // microformats 2 property
'properties' => array(),
'properties' => array(
'like-of' => array(
'type' => 'cite',
Expand Down

0 comments on commit 1c80bad

Please sign in to comment.