PluginProbe
Powerkit – Supercharge your WordPress Site / 2.3.9
Powerkit – Supercharge your WordPress Site v2.3.9
3.1.1 3.1.0 3.0.9 3.0.8 trunk 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 All 87 releases
powerkit / modules / typekit-fonts / helpers / helper-typekit-fonts.php

helper-typekit-fonts.php in Powerkit – Supercharge your WordPress Site 2.3.9, at modules/typekit-fonts/helpers/helper-typekit-fonts.php

127 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Helpers Typekit Fonts
4 *
5 * @package Powerkit
6 * @subpackage Modules/Helper
7 */
8
9 /**
10 * Convert variant slug to font data.
11 *
12 * @param string $variant The variant slug.
13 * @param bool $compact The style data return.
14 */
15 function powerkit_typekit_font_convert_format( $variant, $compact = false ) {
16
17 $format = array(
18 'n1' => array(
19 'weight' => '100',
20 'style' => 'normal',
21 ),
22 'i1' => array(
23 'weight' => '100',
24 'style' => 'italic',
25 ),
26 'n2' => array(
27 'weight' => '200',
28 'style' => 'normal',
29 ),
30 'i2' => array(
31 'weight' => '200',
32 'style' => 'italic',
33 ),
34 'n3' => array(
35 'weight' => '300',
36 'style' => 'normal',
37 ),
38 'i3' => array(
39 'weight' => '300',
40 'style' => 'italic',
41 ),
42 'n4' => array(
43 'weight' => 'normal',
44 'style' => 'normal',
45 ),
46 'i4' => array(
47 'weight' => 'normal',
48 'style' => 'italic',
49 ),
50 'n5' => array(
51 'weight' => '500',
52 'style' => 'normal',
53 ),
54 'i5' => array(
55 'weight' => '500',
56 'style' => 'italic',
57 ),
58 'n6' => array(
59 'weight' => '600',
60 'style' => 'normal',
61 ),
62 'i6' => array(
63 'weight' => '600',
64 'style' => 'italic',
65 ),
66 'n7' => array(
67 'weight' => '700',
68 'style' => 'normal',
69 ),
70 'i7' => array(
71 'weight' => '700',
72 'style' => 'italic',
73 ),
74 'n8' => array(
75 'weight' => '800',
76 'style' => 'normal',
77 ),
78 'i8' => array(
79 'weight' => '800',
80 'style' => 'italic',
81 ),
82 'n9' => array(
83 'weight' => '900',
84 'style' => 'normal',
85 ),
86 'i9' => array(
87 'weight' => '900',
88 'style' => 'italic',
89 ),
90 );
91
92 if ( isset( $format[ $variant ] ) ) {
93
94 if ( $compact ) {
95 return $format[ $variant ]['weight'] . $format[ $variant ]['style'];
96 } else {
97 return $format[ $variant ];
98 }
99 }
100
101 return $variant;
102 }
103
104 /**
105 * Registers font variations format.
106 *
107 * @param array $variations If you want to return a specific option.
108 * @return array
109 */
110 function powerkit_typekit_font_variations_format( $variations = array() ) {
111
112 if ( $variations && isset( $variations ) ) {
113 foreach ( $variations as $key => $item ) {
114 $format_compact = powerkit_typekit_font_convert_format( $item, true );
115
116 $format_compact = preg_replace( '/normalnormal/', 'regular', $format_compact );
117 $format_compact = preg_replace( '/normalitalic/', 'italic', $format_compact );
118 $format_compact = preg_replace( '/(\d*)normal/', '$1', $format_compact );
119
120 $variations[ $key ] = $format_compact;
121 }
122 return $variations;
123 }
124
125 return $format;
126 }
127