'name', 'fallback' => ''), $atts, 'wplocation_country'); $iso = wplocation_get_country_iso(wplocation_get_ipaddress()); $format = strtolower((string) $atts['format']); $country = $iso ? ($format === 'code' ? $iso : wplocation_iso_to_country($iso)) : false; if ($country && $format === 'flag' && preg_match('/^[A-Z]{2}$/', $iso)) { $flag = html_entity_decode('&#' . (127397 + ord($iso[0])) . ';&#' . (127397 + ord($iso[1])) . ';', ENT_QUOTES, 'UTF-8'); return '' . esc_html($flag) . ''; } return esc_html($country ? $country : (string) $atts['fallback']); } function wplocation_filter_location($atts, $content = null) { $atts = shortcode_atts(array('country' => '', 'exclude_country' => ''), $atts, 'wplocation_target'); $iso = wplocation_get_country_iso(wplocation_get_ipaddress()); if (!$iso) { return ''; // Unknown location has historically hidden shortcode content. } $name = wplocation_iso_to_country($iso); $matches = array_map('strtolower', array_filter(array($iso, $name))); $include = array_map('strtolower', wplocation_to_Array($atts['country'])); $exclude = array_map('strtolower', wplocation_to_Array($atts['exclude_country'])); if (array_intersect($exclude, $matches)) { return ''; } if ($include && !array_intersect($include, $matches)) { return ''; } if (!$include && !$exclude) { return ''; } return wplocation_sanitize_visible_content(do_shortcode((string) $content)); }