From 51a307bd2c3b3e8b342eef7925d91835d9d254b1 Mon Sep 17 00:00:00 2001 From: Glynn Quelch Date: Mon, 2 Dec 2024 11:01:18 +0000 Subject: [PATCH] Fix simple liniting issues --- themes/osi/inc/template-functions.php | 70 +++++++++++++++------------ 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/themes/osi/inc/template-functions.php b/themes/osi/inc/template-functions.php index 4133874..a23cefa 100755 --- a/themes/osi/inc/template-functions.php +++ b/themes/osi/inc/template-functions.php @@ -12,7 +12,7 @@ * * @return array */ -function osi_body_classes( $classes ) { +function osi_body_classes( array $classes ) { // Adds a class of hfeed to non-singular pages. if ( ! is_singular() ) { $classes[] = 'hfeed'; @@ -55,7 +55,16 @@ function is_blog() { return ( ( 'post' === $posttype ) && ( is_home() || is_single() || is_archive() || is_category() || is_tag() || is_author() ) ) ? true : false; } -function fix_blog_link_on_cpt( $classes, $item, $args ) { +/** + * Fixes blog link for cpt. + * + * @param array $classes The classes. + * @param object $item The link item. + * @param array $args Additional args. + * + * @return array + */ +function fix_blog_link_on_cpt( $classes, $item, $args ) { //phpcs:ignore if ( ! is_blog() ) { $blog_page_id = intval( get_option( 'page_for_posts' ) ); @@ -76,13 +85,13 @@ function fix_blog_link_on_cpt( $classes, $item, $args ) { * * @link http://justintadlock.com/archives/2011/07/01/captions-in-wordpress * - * @param string $output The caption output. Default empty. - * @param array $attr Attributes of the caption shortcode. + * @param string $output The caption output. Default empty. + * @param array $attr Attributes of the caption shortcode. * @param string $content The image element output. * * @return string */ -function osi_caption( $output, $attr, $content ) { +function osi_caption( $output, $attr, $content ) { //phpcs:ignore if ( is_feed() ) { return $output; } @@ -116,13 +125,13 @@ function osi_caption( $output, $attr, $content ) { /** - * remove width attribute of thumbnails + * Remove width attribute of thumbnails. * * @param string $html The HTML content. * * @return string */ -function osi_remove_width_attribute( $html ) { +function osi_remove_width_attribute( string $html ): string { $html = preg_replace( '/(width|height)="\d*"\s/', '', $html ); return $html; } @@ -133,11 +142,11 @@ function osi_remove_width_attribute( $html ) { * From http://wordpress.stackexchange.com/questions/115368/overide-gallery-default-link-to-settings * Default image links in gallery (not the same as image_default_link_type) * - * @param array $settings + * @param array $settings The settings array. * * @return array */ -function osi_gallery_default_type_set_link( $settings ) { +function osi_gallery_default_type_set_link( array $settings ): array { $settings['galleryDefaults']['link'] = 'file'; return $settings; } @@ -161,12 +170,12 @@ function osi_inline_media_styles() { return $styles; } -/** - * Check if we're on the license search page - * - * @return boolean - */ if ( ! function_exists( 'is_license_search' ) ) { + /** + * Check if we're on the license search page + * + * @return boolean + */ function is_license_search() { if ( ! isset( $_REQUEST['ls'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return false; @@ -176,12 +185,13 @@ function is_license_search() { } } -/** - * Get the license search query - * - * @return string - */ + if ( ! function_exists( 'get_license_search_query' ) ) { + /** + * Get the license search query + * + * @return string + */ function get_license_search_query() { $query = isset( $_REQUEST['ls'] ) ? $_REQUEST['ls'] : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended @@ -194,15 +204,15 @@ function get_license_search_query() { /** * Meta Block Field Filter Date - * - * @param string $content The content of the block. - * @param array $attributes The attributes of the block. - * @param array $block The block. - * @param int $post_id The post ID. - * + * + * @param string $content The content of the block. + * @param array $attributes The attributes of the block. + * @param array $block The block. + * @param integer $post_id The post ID. + * * @return string */ -function osi_filter_meta_block_date_output( $content, $attributes, $block, $post_id ) { +function osi_filter_meta_block_date_output( string $content, array $attributes, $block, $post_id ) { //phpcs:ignore if ( is_numeric( $content ) && 8 === strlen( $content ) ) { $content = DateTime::createFromFormat( 'Ymd', $content )->format( 'M Y' ); } @@ -212,12 +222,12 @@ function osi_filter_meta_block_date_output( $content, $attributes, $block, $post /** * Order Press Mentions by Publication Date - * + * * @param WP_Query $query The WP_Query instance (passed by reference). - * + * * @return WP_Query */ -function osi_press_mentions_by_publication_date( $query ) { +function osi_press_mentions_by_publication_date( WP_Query $query ) { if ( ! is_admin() && $query->is_main_query() ) { if ( is_post_type_archive( 'press-mentions' ) ) { $query->set( 'meta_key', 'date_of_publication' ); @@ -307,7 +317,7 @@ function osi_supporters_shortcode_renderer( array $args = array() ): string { $per_page = isset( $args['limit'] ) ? $args['limit'] : -1; // Override the main query for this specific case - query_posts( + query_posts( // phpcs:ignore array( 'post_type' => 'supporter', 'posts_per_page' => $per_page,