Skip to content

Commit

Permalink
Merge pull request #38 from wpstarter/dev
Browse files Browse the repository at this point in the history
Fix warning on handleMatchedRoute when getShortcodeAtts not return array
  • Loading branch information
as247 committed May 5, 2023
2 parents e0dc260 + c047836 commit 404dc66
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/WpStarter/Wordpress/Routing/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ protected function handleMatchedRoute(Request $request, $route)

protected function getShortcodeAtts($content,$shortcode){
preg_match_all( '/' . get_shortcode_regex($shortcode) . '/', $content, $matches, PREG_SET_ORDER );
if ( empty( $matches ) ) {
return false;
$atts=[];
if ( ! empty( $matches ) ) {
$atts = shortcode_parse_atts($matches[0][3]??'');
}
if(!is_array($atts)){
$atts=[];
}
return shortcode_parse_atts($matches[0][3]??'');
return $atts;
}
}
}

0 comments on commit 404dc66

Please sign in to comment.