Automattic / Automattic/VIP-Coding-Standards

Catch incorrect bloginfo() usage

Open
#396 1 comment 0 reactions 0 assignees View on GitHub
Type: Enhancement
Dominant language
PHP
Stars
261
Forks
44
Avg merge
19m
Merged PRs (30d)
1

Description

## What problem would the enhancement address for VIP?
When using `bloginfo()`, the caller should not echo the output, as `bloginfo()` does this internally (see [here](https://developer.wordpress.org/reference/functions/bloginfo/#source)). Callers should simply call `bloginfo()` without any `echo`, but if the callers want to control when the output is echoed, they should use `get_bloginfo()` ([#](https://developer.wordpress.org/reference/functions/get_bloginfo/)). Our standards should catch these kinds of issues in code.

## Describe the solution you'd like
The usage of `echo bloginfo()` should be caught and advice given on using `get_bloginfo()` instead or to skip the echo.

## What code should be reported as a violation?
echo bloginfo( 'name' );

## What code should *not* be reported as a violation?
echo get_bloginfo( 'name' );

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.