Skip to content

Commit

Permalink
Fix simple liniting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
gin0115 committed Dec 2, 2024
1 parent 35a93e3 commit 51a307b
Showing 1 changed file with 40 additions and 30 deletions.
70 changes: 40 additions & 30 deletions themes/osi/inc/template-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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' ) );

Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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

Expand All @@ -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' );
}
Expand All @@ -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' );
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 51a307b

Please sign in to comment.