PluginProbe
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation / trunk
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation vtrunk
1.4.48 1.4.47 1.4.46 1.4.45 1.4.44 1.4.43 1.4.42 1.4.41 1.4.40 1.4.39 1.4.38 1.4.37 1.4.36 1.1.2 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 64 releases
optin / includes / utils / class-country-decoder.php

class-country-decoder.php in WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation trunk, at includes/utils/class-country-decoder.php

59 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore
2
3 namespace OPTN\Includes\Utils;
4
5 /**
6 * Country decoder class
7 */
8 class CountryDecoder {
9
10 /**
11 * Country map
12 *
13 * @var array $country_map country map
14 */
15 private static $country_map = null;
16
17 /**
18 * Reads the country data from json and returns it
19 *
20 * @return array
21 */
22 private static function get_country_map() {
23 if ( empty( self::$country_map ) ) {
24 self::$country_map = wp_json_file_decode( plugin_dir_path( __FILE__ ) . '/country.json', array( 'associative' => true ) );
25 }
26
27 return self::$country_map;
28 }
29
30 /**
31 * Decodes country code to actual country
32 *
33 * @param string $code country code.
34 * @return string|null
35 */
36 public static function decode( $code ) {
37 $code = strtoupper( $code );
38
39 $country_map = self::get_country_map();
40
41 return isset( $country_map[ $code ] ) ? $country_map[ $code ] : null;
42 }
43
44
45 /**
46 * Get total World Domination >:()
47 *
48 * @param int $count count.
49 * @return float
50 */
51 public static function get_dom_pct( $count ) {
52 $country_map = self::get_country_map();
53
54 $country_count = count( $country_map );
55
56 return 0 === $country_count ? 0 : min( round( ( $count / $country_count ) * 100, 2 ), 100 );
57 }
58 }
59