Skip to content

Commit

Permalink
Fix shortcode issue when no attribute is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
AnuragVasanwala committed May 8, 2023
1 parent 6d96d32 commit 1162187
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions includes/Shortcode/Stories_Shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public function register(): void {
*
* @since 1.5.0
*
* @param array<string,string|int> $attrs Shortcode attributes.
* @param array<string,string|int>|string $attrs Shortcode attributes.
* @return string Story markup.
*/
public function render_stories( array $attrs ): string {
public function render_stories( $attrs ): string {
$default_pairs = [
'view' => 'circles',
'number_of_columns' => 1,
Expand All @@ -89,6 +89,11 @@ public function render_stories( array $attrs ): string {
$default_pairs[ $taxonomy ] = '';
}

// Initialize '$attrs' when not an array OR is an empty string.
if ( empty( $attrs ) || ! is_array( $attrs) ) {

Check failure on line 93 in includes/Shortcode/Stories_Shortcode.php

View workflow job for this annotation

GitHub Actions / Lint

Function is_array() should be referenced via a fully qualified name.

Check failure on line 93 in includes/Shortcode/Stories_Shortcode.php

View workflow job for this annotation

GitHub Actions / Lint

Expected 1 spaces before closing parenthesis; 0 found
$attrs = [];

Check warning on line 94 in includes/Shortcode/Stories_Shortcode.php

View check run for this annotation

Codecov / codecov/patch

includes/Shortcode/Stories_Shortcode.php#L94

Added line #L94 was not covered by tests
}

$attributes = shortcode_atts(
$default_pairs,
$attrs,
Expand Down

0 comments on commit 1162187

Please sign in to comment.