src/php/frontend.php
Showing 97 of 97 total issues
Method inject_author_meta
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function inject_author_meta() { global $post; if ( ! $post || ! is_singular() ) { return; }
Function inject_author_meta
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
function inject_author_meta() { global $post; if ( ! $post || ! is_singular() ) { return; }
- Read upRead up
A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 21 and the first side effect is on line 12. Open
Open
<?php
- Exclude checks
Expected 1 space after FUNCTION keyword; 0 found Open
Open
function( $coauthor ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
foreach ( $authors as $author ) {
- Exclude checks
Expected 0 spaces between opening bracket and argument "$coauthor"; 1 found Open
Open
function( $coauthor ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if ( function_exists( 'get_coauthors' ) ) {
- Exclude checks
Expected 0 spaces between argument "$coauthor" and closing bracket; 1 found Open
Open
function( $coauthor ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if ( is_singular() && has_block( 'abt/bibliography', $post ) ) {
- Exclude checks
Space found after opening bracket of FOREACH loop Open
Open
foreach ( $authors as $author ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if ( ! $post || ! is_singular() ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if ( is_int( $bib_index ) ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if ( is_singular() ) {
- Exclude checks
Space found before closing bracket of FOREACH loop Open
Open
foreach ( $authors as $author ) {
- Exclude checks
Expected 0 spaces between opening bracket and type hint "WP_Post"; 1 found Open
Open
function collect_bibliography( WP_Post $post ) {
- Exclude checks
Expected 0 spaces between argument "$post" and closing bracket; 1 found Open
Open
function collect_bibliography( WP_Post $post ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if ( $author->first_name && $author->last_name ) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ( is_singular() ) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
get_coauthors( $post->ID )
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$author_ids = array_merge( $author_ids, $coauthor_ids );
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
'include' => $author_ids,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
<?php
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
<meta property="abt:author" content="<?php echo esc_attr( $parsed ); ?>" />
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
wp_enqueue_style( 'abt-frontend' );
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
foreach ( $authors as $author ) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ( $author->first_name && $author->last_name ) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ( is_singular() && has_block( 'abt/bibliography', $post ) ) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ( is_int( $bib_index ) ) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
add_json_script( 'abt-bibliography-json', $blocks[ $bib_index ]['innerHTML'] );
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
function( $coauthor ) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
?>
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
[
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
wp_enqueue_script( 'abt-frontend' );
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ( function_exists( 'get_coauthors' ) ) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$parsed = $author->first_name . '|' . $author->last_name;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$blocks = parse_blocks( $post->post_content );
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
global $post;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$author_ids = [ $post->post_author ];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
},
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
if ( ! $post || ! is_singular() ) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$coauthor_ids = array_map(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
return $coauthor->ID;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$authors = get_users(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
$bib_index = array_search( 'abt/bibliography', array_column( $blocks, 'blockName' ), true );
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
}
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
defined( 'ABSPATH' ) || exit;
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
get_coauthors( $post->ID )
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
add_json_script( 'abt-bibliography-json', $blocks[ $bib_index ]['innerHTML'] );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
wp_enqueue_script( 'abt-frontend' );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
get_coauthors( $post->ID )
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
<meta property="abt:author" content="<?php echo esc_attr( $parsed ); ?>" />
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
add_action( 'wp_head', __NAMESPACE__ . '\inject_author_meta' );
- Exclude checks
Opening brace should be on a new line Open
Open
function collect_bibliography( WP_Post $post ) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
if ( is_singular() && has_block( 'abt/bibliography', $post ) ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if ( is_singular() && has_block( 'abt/bibliography', $post ) ) {
- Exclude checks
Expected 0 spaces after opening bracket; 1 found Open
Open
if ( is_int( $bib_index ) ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
add_action( 'the_post', __NAMESPACE__ . '\collect_bibliography' );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
$blocks = parse_blocks( $post->post_content );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if ( is_int( $bib_index ) ) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
add_action( 'the_post', __NAMESPACE__ . '\collect_bibliography' );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_scripts' );
- Exclude checks
Expected 0 spaces after opening bracket; 1 found Open
Open
foreach ( $authors as $author ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
$blocks = parse_blocks( $post->post_content );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
$bib_index = array_search( 'abt/bibliography', array_column( $blocks, 'blockName' ), true );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
$bib_index = array_search( 'abt/bibliography', array_column( $blocks, 'blockName' ), true );
- Exclude checks
Opening brace should be on a new line Open
Open
function enqueue_scripts() {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
wp_enqueue_style( 'abt-frontend' );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\enqueue_scripts' );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
if ( function_exists( 'get_coauthors' ) ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
add_action( 'wp_head', __NAMESPACE__ . '\inject_author_meta' );
- Exclude checks
Expected 0 spaces after opening bracket; 1 found Open
Open
if ( is_singular() && has_block( 'abt/bibliography', $post ) ) {
- Exclude checks
Expected 0 spaces after opening bracket; 1 found Open
Open
if ( is_singular() ) {
- Exclude checks
Expected 0 spaces after opening bracket; 1 found Open
Open
if ( function_exists( 'get_coauthors' ) ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
$author_ids = array_merge( $author_ids, $coauthor_ids );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
$bib_index = array_search( 'abt/bibliography', array_column( $blocks, 'blockName' ), true );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
wp_enqueue_style( 'abt-frontend' );
- Exclude checks
Expected 0 spaces after opening bracket; 1 found Open
Open
if ( $author->first_name && $author->last_name ) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
$bib_index = array_search( 'abt/bibliography', array_column( $blocks, 'blockName' ), true );
- Exclude checks
Opening brace should be on a new line Open
Open
function inject_author_meta() {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
defined( 'ABSPATH' ) || exit;
- Exclude checks
Expected 0 spaces after opening bracket; 1 found Open
Open
if ( ! $post || ! is_singular() ) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
if ( function_exists( 'get_coauthors' ) ) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
$author_ids = array_merge( $author_ids, $coauthor_ids );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
<meta property="abt:author" content="<?php echo esc_attr( $parsed ); ?>" />
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
if ( is_int( $bib_index ) ) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
Open
add_json_script( 'abt-bibliography-json', $blocks[ $bib_index ]['innerHTML'] );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
Open
wp_enqueue_script( 'abt-frontend' );
- Exclude checks