I am using this code so that users can input [photo no="1"], [photo no="2"], [photo no="3"]
etc.. in their posts. However I heard that extract
is an unsafe function to use. How could I modify this code to remove extract
?
function photo_shortcode($atts){
extract(shortcode_atts(array(
'no' => 1,
), $atts));
$no = is_numeric($no) ? (int) $no : 1;
$images = get_field('fl_gallery');
if ( !empty( $images ) ) {
$image = $images[$no];
return ' $image['url'] ' ;
}
}