我使用此代码以便用户可以输入[photo no="1"], [photo no="2"], [photo no="3"]
等在他们的岗位上。但是我听说extract
是一个不安全的函数。如何修改此代码以删除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\'] \' ;
}
}