request; $has_page = array_filter( $menus['main'], function ( $item ) use ( $slug ) { return trim( $item['url'], '/' ) === $slug; } ); if ( ! empty( $has_page ) ) { $classes[] = 'is-page-in-menu'; } return $classes; } /** * Filter the featured image to show an avatar on the `my-pledges` page. * * @param string $html The post thumbnail HTML. * @param int $post_id The post ID. * @param int $post_thumbnail_id The post thumbnail ID, or 0 if there isn't one. * @param string|int[] $size Requested image size. Can be any registered image size name, or * an array of width and height values in pixels (in that order). * @param string|array $attr Query string or array of attributes. * * @return string Updated HTML. */ function swap_avatar_for_featured_image( $html, $post_id, $post_thumbnail_id, $size, $attr ) { if ( is_page( 'my-pledges' ) && empty( $html ) ) { $attr_str = ''; foreach ( $attr as $name => $value ) { $attr_str .= " $name=" . '"' . $value . '"'; } $html = get_avatar( wp_get_current_user(), 110, 'mystery', '', array( 'extra_attr' => $attr_str ) ); } return $html; } add_filter( 'post_thumbnail_html', __NAMESPACE__ . '\swap_avatar_for_featured_image', 10, 5 ); /** * Filter the sizes attributes for specific images. * * @param array $sources One or more arrays of source data to include in the 'srcset'. * @param array $size_array An array of requested width and height values. * @param string $image_src The 'src' of the image. * * @return array */ function modify_image_srcset( $sources, $size_array, $image_src ) { // The main header image is set with a fixed height, and when the smaller // screen sizes are used, it scales up to that height causing pixelation. if ( str_contains( $image_src, '5ftf-wordcamp.jpg' ) ) { // These sizes are smaller than 260px tall. unset( $sources[1024], $sources[768], $sources[300] ); } return $sources; }