WC_Dynamic_Gallery_Fonts_Face

The WooCommerce Dynamic Gallery LITE WC Dynamic Gallery Fonts Face class.

Defined (1)

The class is defined in the following location(s).

/admin/includes/fonts_face.php  
  1. class WC_Dynamic_Gallery_Fonts_Face extends WC_Dynamic_Gallery_Admin_UI 
  2.  
  3. /** 
  4. * Window Default Fonts 
  5. */ 
  6. public $default_fonts = array( 
  7. 'Arial, sans-serif' => 'Arial',  
  8. 'Verdana, Geneva, sans-serif' => 'Verdana',  
  9. 'Trebuchet MS, Tahoma, sans-serif' => 'Trebuchet',  
  10. 'Georgia, serif' => 'Georgia',  
  11. 'Times New Roman, serif' => 'Times New Roman',  
  12. 'Tahoma, Geneva, Verdana, sans-serif' => 'Tahoma',  
  13. 'Palatino, Palatino Linotype, serif' => 'Palatino',  
  14. 'Helvetica Neue, Helvetica, sans-serif' => 'Helvetica*',  
  15. 'Calibri, Candara, Segoe, Optima, sans-serif' => 'Calibri*',  
  16. 'Myriad Pro, Myriad, sans-serif' => 'Myriad Pro*',  
  17. 'Lucida Grande, Lucida Sans Unicode, Lucida Sans, sans-serif' => 'Lucida',  
  18. 'Arial Black, sans-serif' => 'Arial Black',  
  19. 'Gill Sans, Gill Sans MT, Calibri, sans-serif' => 'Gill Sans*',  
  20. 'Geneva, Tahoma, Verdana, sans-serif' => 'Geneva*',  
  21. 'Impact, Charcoal, sans-serif' => 'Impact',  
  22. 'Courier, Courier New, monospace' => 'Courier',  
  23. 'Century Gothic, sans-serif' => 'Century Gothic',  
  24. ); 
  25.  
  26. /** 
  27. * Google API Key use to get dynamic list of fonts from google, you can create new API KEY to use from https://developers.google.com/fonts/docs/developer_api 
  28. */ 
  29. public $google_api_key = ''; 
  30.  
  31. /**-----------------------------------------------------------------------------------*/ 
  32. /** Google Webfonts Array */ 
  33. /** Documentation: 
  34. /** 
  35. /** name: The name of the Google Font. 
  36. /** variant: The Google Font API variants available for the font. 
  37. /**-----------------------------------------------------------------------------------*/ 
  38.  
  39. // Available Google webfont names 
  40. public $google_fonts = array( array( 'name' => "Cantarell", 'variant' => ':r, b, i, bi'),  
  41. array( 'name' => "Cardo", 'variant' => ''),  
  42. array( 'name' => "Crimson Text", 'variant' => ''),  
  43. array( 'name' => "Droid Sans", 'variant' => ':r, b'),  
  44. array( 'name' => "Droid Sans Mono", 'variant' => ''),  
  45. array( 'name' => "Droid Serif", 'variant' => ':r, b, i, bi'),  
  46. array( 'name' => "IM Fell DW Pica", 'variant' => ':r, i'),  
  47. array( 'name' => "Inconsolata", 'variant' => ''),  
  48. array( 'name' => "Josefin Sans", 'variant' => ':400, 400italic, 700, 700italic'),  
  49. array( 'name' => "Josefin Slab", 'variant' => ':r, b, i, bi'),  
  50. array( 'name' => "Lobster", 'variant' => ''),  
  51. array( 'name' => "Molengo", 'variant' => ''),  
  52. array( 'name' => "Nobile", 'variant' => ':r, b, i, bi'),  
  53. array( 'name' => "OFL Sorts Mill Goudy TT", 'variant' => ':r, i'),  
  54. array( 'name' => "Old Standard TT", 'variant' => ':r, b, i'),  
  55. array( 'name' => "Reenie Beanie", 'variant' => ''),  
  56. array( 'name' => "Tangerine", 'variant' => ':r, b'),  
  57. array( 'name' => "Vollkorn", 'variant' => ':r, b'),  
  58. array( 'name' => "Yanone Kaffeesatz", 'variant' => ':r, b'),  
  59. array( 'name' => "Cuprum", 'variant' => ''),  
  60. array( 'name' => "Neucha", 'variant' => ''),  
  61. array( 'name' => "Neuton", 'variant' => ''),  
  62. array( 'name' => "PT Sans", 'variant' => ':r, b, i, bi'),  
  63. array( 'name' => "PT Sans Caption", 'variant' => ':r, b'),  
  64. array( 'name' => "PT Sans Narrow", 'variant' => ':r, b'),  
  65. array( 'name' => "Philosopher", 'variant' => ''),  
  66. array( 'name' => "Allerta", 'variant' => ''),  
  67. array( 'name' => "Allerta Stencil", 'variant' => ''),  
  68. array( 'name' => "Arimo", 'variant' => ':r, b, i, bi'),  
  69. array( 'name' => "Arvo", 'variant' => ':r, b, i, bi'),  
  70. array( 'name' => "Bentham", 'variant' => ''),  
  71. array( 'name' => "Coda", 'variant' => ':800'),  
  72. array( 'name' => "Cousine", 'variant' => ''),  
  73. array( 'name' => "Covered By Your Grace", 'variant' => ''),  
  74. array( 'name' => "Geo", 'variant' => ''),  
  75. array( 'name' => "Just Me Again Down Here", 'variant' => ''),  
  76. array( 'name' => "Puritan", 'variant' => ':r, b, i, bi'),  
  77. array( 'name' => "Raleway", 'variant' => ':100'),  
  78. array( 'name' => "Tinos", 'variant' => ':r, b, i, bi'),  
  79. array( 'name' => "UnifrakturCook", 'variant' => ':bold'),  
  80. array( 'name' => "UnifrakturMaguntia", 'variant' => ''),  
  81. array( 'name' => "Mountains of Christmas", 'variant' => ''),  
  82. array( 'name' => "Lato", 'variant' => ':400, 700, 400italic'),  
  83. array( 'name' => "Orbitron", 'variant' => ':r, b, i, bi'),  
  84. array( 'name' => "Allan", 'variant' => ':bold'),  
  85. array( 'name' => "Anonymous Pro", 'variant' => ':r, b, i, bi'),  
  86. array( 'name' => "Copse", 'variant' => ''),  
  87. array( 'name' => "Kenia", 'variant' => ''),  
  88. array( 'name' => "Ubuntu", 'variant' => ':r, b, i, bi'),  
  89. array( 'name' => "Vibur", 'variant' => ''),  
  90. array( 'name' => "Sniglet", 'variant' => ':800'),  
  91. array( 'name' => "Syncopate", 'variant' => ''),  
  92. array( 'name' => "Cabin", 'variant' => ':400, 400italic, 700, 700italic, '),  
  93. array( 'name' => "Merriweather", 'variant' => ''),  
  94. array( 'name' => "Maiden Orange", 'variant' => ''),  
  95. array( 'name' => "Just Another Hand", 'variant' => ''),  
  96. array( 'name' => "Kristi", 'variant' => ''),  
  97. array( 'name' => "Corben", 'variant' => ':b'),  
  98. array( 'name' => "Gruppo", 'variant' => ''),  
  99. array( 'name' => "Buda", 'variant' => ':light'),  
  100. array( 'name' => "Lekton", 'variant' => ''),  
  101. array( 'name' => "Luckiest Guy", 'variant' => ''),  
  102. array( 'name' => "Crushed", 'variant' => ''),  
  103. array( 'name' => "Chewy", 'variant' => ''),  
  104. array( 'name' => "Coming Soon", 'variant' => ''),  
  105. array( 'name' => "Crafty Girls", 'variant' => ''),  
  106. array( 'name' => "Fontdiner Swanky", 'variant' => ''),  
  107. array( 'name' => "Permanent Marker", 'variant' => ''),  
  108. array( 'name' => "Rock Salt", 'variant' => ''),  
  109. array( 'name' => "Sunshiney", 'variant' => ''),  
  110. array( 'name' => "Unkempt", 'variant' => ''),  
  111. array( 'name' => "Calligraffitti", 'variant' => ''),  
  112. array( 'name' => "Cherry Cream Soda", 'variant' => ''),  
  113. array( 'name' => "Homemade Apple", 'variant' => ''),  
  114. array( 'name' => "Irish Growler", 'variant' => ''),  
  115. array( 'name' => "Kranky", 'variant' => ''),  
  116. array( 'name' => "Schoolbell", 'variant' => ''),  
  117. array( 'name' => "Slackey", 'variant' => ''),  
  118. array( 'name' => "Walter Turncoat", 'variant' => ''),  
  119. array( 'name' => "Radley", 'variant' => ''),  
  120. array( 'name' => "Meddon", 'variant' => ''),  
  121. array( 'name' => "Kreon", 'variant' => ':r, b'),  
  122. array( 'name' => "Dancing Script", 'variant' => ''),  
  123. array( 'name' => "Goudy Bookletter 1911", 'variant' => ''),  
  124. array( 'name' => "PT Serif Caption", 'variant' => ':r, i'),  
  125. array( 'name' => "PT Serif", 'variant' => ':r, b, i, bi'),  
  126. array( 'name' => "Astloch", 'variant' => ':b'),  
  127. array( 'name' => "Bevan", 'variant' => ''),  
  128. array( 'name' => "Anton", 'variant' => ''),  
  129. array( 'name' => "Expletus Sans", 'variant' => ':b'),  
  130. array( 'name' => "VT323", 'variant' => ''),  
  131. array( 'name' => "Pacifico", 'variant' => ''),  
  132. array( 'name' => "Candal", 'variant' => ''),  
  133. array( 'name' => "Architects Daughter", 'variant' => ''),  
  134. array( 'name' => "Indie Flower", 'variant' => ''),  
  135. array( 'name' => "League Script", 'variant' => ''),  
  136. array( 'name' => "Quattrocento", 'variant' => ''),  
  137. array( 'name' => "Amaranth", 'variant' => ''),  
  138. array( 'name' => "Irish Grover", 'variant' => ''),  
  139. array( 'name' => "Oswald", 'variant' => ':400, 300, 700'),  
  140. array( 'name' => "EB Garamond", 'variant' => ''),  
  141. array( 'name' => "Nova Round", 'variant' => ''),  
  142. array( 'name' => "Nova Slim", 'variant' => ''),  
  143. array( 'name' => "Nova Script", 'variant' => ''),  
  144. array( 'name' => "Nova Cut", 'variant' => ''),  
  145. array( 'name' => "Nova Mono", 'variant' => ''),  
  146. array( 'name' => "Nova Oval", 'variant' => ''),  
  147. array( 'name' => "Nova Flat", 'variant' => ''),  
  148. array( 'name' => "Terminal Dosis Light", 'variant' => ''),  
  149. array( 'name' => "Michroma", 'variant' => ''),  
  150. array( 'name' => "Miltonian", 'variant' => ''),  
  151. array( 'name' => "Miltonian Tattoo", 'variant' => ''),  
  152. array( 'name' => "Annie Use Your Telescope", 'variant' => ''),  
  153. array( 'name' => "Dawning of a New Day", 'variant' => ''),  
  154. array( 'name' => "Sue Ellen Francisco", 'variant' => ''),  
  155. array( 'name' => "Waiting for the Sunrise", 'variant' => ''),  
  156. array( 'name' => "Special Elite", 'variant' => ''),  
  157. array( 'name' => "Quattrocento Sans", 'variant' => ''),  
  158. array( 'name' => "Smythe", 'variant' => ''),  
  159. array( 'name' => "The Girl Next Door", 'variant' => ''),  
  160. array( 'name' => "Aclonica", 'variant' => ''),  
  161. array( 'name' => "News Cycle", 'variant' => ''),  
  162. array( 'name' => "Damion", 'variant' => ''),  
  163. array( 'name' => "Wallpoet", 'variant' => ''),  
  164. array( 'name' => "Over the Rainbow", 'variant' => ''),  
  165. array( 'name' => "MedievalSharp", 'variant' => ''),  
  166. array( 'name' => "Six Caps", 'variant' => ''),  
  167. array( 'name' => "Swanky and Moo Moo", 'variant' => ''),  
  168. array( 'name' => "Bigshot One", 'variant' => ''),  
  169. array( 'name' => "Francois One", 'variant' => ''),  
  170. array( 'name' => "Sigmar One", 'variant' => ''),  
  171. array( 'name' => "Carter One", 'variant' => ''),  
  172. array( 'name' => "Holta3revd One SC", 'variant' => ''),  
  173. array( 'name' => "Paytone One", 'variant' => ''),  
  174. array( 'name' => "Monofett", 'variant' => ''),  
  175. array( 'name' => "Rokkitt", 'variant' => ':400, 700'),  
  176. array( 'name' => "Megrim", 'variant' => ''),  
  177. array( 'name' => "Judson", 'variant' => ':r, ri, b'),  
  178. array( 'name' => "Didact Gothic", 'variant' => ''),  
  179. array( 'name' => "Play", 'variant' => ':r, b'),  
  180. array( 'name' => "Ultra", 'variant' => ''),  
  181. array( 'name' => "Metrophobic", 'variant' => ''),  
  182. array( 'name' => "Mako", 'variant' => ''),  
  183. array( 'name' => "Shanti", 'variant' => ''),  
  184. array( 'name' => "Caudex", 'variant' => ':r, b, i, bi'),  
  185. array( 'name' => "Jura", 'variant' => ''),  
  186. array( 'name' => "Ruslan Display", 'variant' => ''),  
  187. array( 'name' => "Brawler", 'variant' => ''),  
  188. array( 'name' => "Nunito", 'variant' => ''),  
  189. array( 'name' => "Wire One", 'variant' => ''),  
  190. array( 'name' => "Podkova", 'variant' => ''),  
  191. array( 'name' => "Muli", 'variant' => ''),  
  192. array( 'name' => "Maven Pro", 'variant' => ':400, 500, 700'),  
  193. array( 'name' => "Tenor Sans", 'variant' => ''),  
  194. array( 'name' => "Limelight", 'variant' => ''),  
  195. array( 'name' => "Playfair Display", 'variant' => ''),  
  196. array( 'name' => "Artifika", 'variant' => ''),  
  197. array( 'name' => "Lora", 'variant' => ''),  
  198. array( 'name' => "Kameron", 'variant' => ':r, b'),  
  199. array( 'name' => "Cedarville Cursive", 'variant' => ''),  
  200. array( 'name' => "Zeyada", 'variant' => ''),  
  201. array( 'name' => "La Belle Aurore", 'variant' => ''),  
  202. array( 'name' => "Shadows Into Light", 'variant' => ''),  
  203. array( 'name' => "Lobster Two", 'variant' => ':r, b, i, bi'),  
  204. array( 'name' => "Nixie One", 'variant' => ''),  
  205. array( 'name' => "Redressed", 'variant' => ''),  
  206. array( 'name' => "Bangers", 'variant' => ''),  
  207. array( 'name' => "Open Sans Condensed", 'variant' => ':300italic, 400italic, 700italic, 400, 300, 700'),  
  208. array( 'name' => "Open Sans", 'variant' => ':r, i, b, bi'),  
  209. array( 'name' => "Varela", 'variant' => ''),  
  210. array( 'name' => "Goblin One", 'variant' => ''),  
  211. array( 'name' => "Asset", 'variant' => ''),  
  212. array( 'name' => "Gravitas One", 'variant' => ''),  
  213. array( 'name' => "Hammersmith One", 'variant' => ''),  
  214. array( 'name' => "Stardos Stencil", 'variant' => ''),  
  215. array( 'name' => "Love Ya Like A Sister", 'variant' => ''),  
  216. array( 'name' => "Loved by the King", 'variant' => ''),  
  217. array( 'name' => "Bowlby One SC", 'variant' => ''),  
  218. array( 'name' => "Forum", 'variant' => ''),  
  219. array( 'name' => "Patrick Hand", 'variant' => ''),  
  220. array( 'name' => "Varela Round", 'variant' => ''),  
  221. array( 'name' => "Yeseva One", 'variant' => ''),  
  222. array( 'name' => "Give You Glory", 'variant' => ''),  
  223. array( 'name' => "Modern Antiqua", 'variant' => ''),  
  224. array( 'name' => "Bowlby One", 'variant' => ''),  
  225. array( 'name' => "Tienne", 'variant' => ''),  
  226. array( 'name' => "Istok Web", 'variant' => ':r, b, i, bi'),  
  227. array( 'name' => "Yellowtail", 'variant' => ''),  
  228. array( 'name' => "Pompiere", 'variant' => ''),  
  229. array( 'name' => "Unna", 'variant' => ''),  
  230. array( 'name' => "Rosario", 'variant' => ''),  
  231. array( 'name' => "Leckerli One", 'variant' => ''),  
  232. array( 'name' => "Snippet", 'variant' => ''),  
  233. array( 'name' => "Ovo", 'variant' => ''),  
  234. array( 'name' => "IM Fell English", 'variant' => ':r, i'),  
  235. array( 'name' => "IM Fell English SC", 'variant' => ''),  
  236. array( 'name' => "Gloria Hallelujah", 'variant' => ''),  
  237. array( 'name' => "Kelly Slab", 'variant' => ''),  
  238. array( 'name' => "Black Ops One", 'variant' => ''),  
  239. array( 'name' => "Carme", 'variant' => ''),  
  240. array( 'name' => "Aubrey", 'variant' => ''),  
  241. array( 'name' => "Federo", 'variant' => ''),  
  242. array( 'name' => "Delius", 'variant' => ''),  
  243. array( 'name' => "Rochester", 'variant' => ''),  
  244. array( 'name' => "Rationale", 'variant' => ''),  
  245. array( 'name' => "Abel", 'variant' => ''),  
  246. array( 'name' => "Marvel", 'variant' => ':r, b, i, bi'),  
  247. array( 'name' => "Actor", 'variant' => ''),  
  248. array( 'name' => "Delius Swash Caps", 'variant' => ''),  
  249. array( 'name' => "Smokum", 'variant' => ''),  
  250. array( 'name' => "Tulpen One", 'variant' => ''),  
  251. array( 'name' => "Coustard", 'variant' => ':r, b'),  
  252. array( 'name' => "Andika", 'variant' => ''),  
  253. array( 'name' => "Alice", 'variant' => ''),  
  254. array( 'name' => "Questrial", 'variant' => ''),  
  255. array( 'name' => "Comfortaa", 'variant' => ':r, b'),  
  256. array( 'name' => "Geostar", 'variant' => ''),  
  257. array( 'name' => "Geostar Fill", 'variant' => ''),  
  258. array( 'name' => "Volkhov", 'variant' => ''),  
  259. array( 'name' => "Voltaire", 'variant' => ''),  
  260. array( 'name' => "Montez", 'variant' => ''),  
  261. array( 'name' => "Short Stack", 'variant' => ''),  
  262. array( 'name' => "Vidaloka", 'variant' => ''),  
  263. array( 'name' => "Aldrich", 'variant' => ''),  
  264. array( 'name' => "Numans", 'variant' => ''),  
  265. array( 'name' => "Days One", 'variant' => ''),  
  266. array( 'name' => "Gentium Book Basic", 'variant' => ''),  
  267. array( 'name' => "Monoton", 'variant' => ''),  
  268. array( 'name' => "Alike", 'variant' => ''),  
  269. array( 'name' => "Delius Unicase", 'variant' => ''),  
  270. array( 'name' => "Abril Fatface", 'variant' => ''),  
  271. array( 'name' => "Dorsa", 'variant' => ''),  
  272. array( 'name' => "Antic", 'variant' => ''),  
  273. array( 'name' => "Passero One", 'variant' => ''),  
  274. array( 'name' => "Fana3revd Text", 'variant' => ''),  
  275. array( 'name' => "Prociono", 'variant' => ''),  
  276. array( 'name' => "Merienda One", 'variant' => ''),  
  277. array( 'name' => "Changa One", 'variant' => ''),  
  278. array( 'name' => "Julee", 'variant' => ''),  
  279. array( 'name' => "Prata", 'variant' => ''),  
  280. array( 'name' => "Adamina", 'variant' => ''),  
  281. array( 'name' => "Sorts Mill Goudy", 'variant' => ''),  
  282. array( 'name' => "Terminal Dosis", 'variant' => ''),  
  283. array( 'name' => "Sansita One", 'variant' => ''),  
  284. array( 'name' => "Chivo", 'variant' => ''),  
  285. array( 'name' => "Spinnaker", 'variant' => ''),  
  286. array( 'name' => "Poller One", 'variant' => ''),  
  287. array( 'name' => "Alike Angular", 'variant' => ''),  
  288. array( 'name' => "Gochi Hand", 'variant' => ''),  
  289. array( 'name' => "Poly", 'variant' => ''),  
  290. array( 'name' => "Andada", 'variant' => ''),  
  291. array( 'name' => "Federant", 'variant' => ''),  
  292. array( 'name' => "Ubuntu Condensed", 'variant' => ''),  
  293. array( 'name' => "Ubuntu Mono", 'variant' => ''),  
  294. array( 'name' => "Sancreek", 'variant' => ''),  
  295. array( 'name' => "Coda", 'variant' => ''),  
  296. array( 'name' => "Rancho", 'variant' => ''),  
  297. array( 'name' => "Satisfy", 'variant' => ''),  
  298. array( 'name' => "Pinyon Script", 'variant' => ''),  
  299. array( 'name' => "Vast Shadow", 'variant' => ''),  
  300. array( 'name' => "Marck Script", 'variant' => ''),  
  301. array( 'name' => "Salsa", 'variant' => ''),  
  302. array( 'name' => "Amatic SC", 'variant' => ''),  
  303. array( 'name' => "Quicksand", 'variant' => ''),  
  304. array( 'name' => "Linden Hill", 'variant' => ''),  
  305. array( 'name' => "Corben", 'variant' => ''),  
  306. array( 'name' => "Creepster Caps", 'variant' => ''),  
  307. array( 'name' => "Butcherman Caps", 'variant' => ''),  
  308. array( 'name' => "Eater Caps", 'variant' => ''),  
  309. array( 'name' => "Nosifer Caps", 'variant' => ''),  
  310. array( 'name' => "Atomic Age", 'variant' => ''),  
  311. array( 'name' => "Contrail One", 'variant' => ''),  
  312. array( 'name' => "Jockey One", 'variant' => ''),  
  313. array( 'name' => "Cabin Sketch", 'variant' => ':r, b'),  
  314. array( 'name' => "Cabin Condensed", 'variant' => ':r, b'),  
  315. array( 'name' => "Fjord One", 'variant' => ''),  
  316. array( 'name' => "Rametto One", 'variant' => ''),  
  317. array( 'name' => "Mate", 'variant' => ':r, i'),  
  318. array( 'name' => "Mate SC", 'variant' => ''),  
  319. array( 'name' => "Arapey", 'variant' => ':r, i'),  
  320. array( 'name' => "Supermercado One", 'variant' => ''),  
  321. array( 'name' => "Petrona", 'variant' => ''),  
  322. array( 'name' => "Lancelot", 'variant' => ''),  
  323. array( 'name' => "Convergence", 'variant' => ''),  
  324. array( 'name' => "Cutive", 'variant' => ''),  
  325. array( 'name' => "Karla", 'variant' => ':400, 400italic, 700, 700italic'),  
  326. array( 'name' => "Bitter", 'variant' => ':r, i, b'),  
  327. array( 'name' => "Asap", 'variant' => ':400, 700, 400italic, 700italic'),  
  328. array( 'name' => "Bree Serif", 'variant' => '') 
  329.  
  330. ); 
  331.  
  332. /**-----------------------------------------------------------------------------------*/ 
  333. /** Fonts Face Constructor */ 
  334. /**-----------------------------------------------------------------------------------*/ 
  335. public function __construct() { 
  336.  
  337. // Enable Google Font API Key 
  338. if ( isset( $_POST[ $this->google_api_key_option . '_enable' ] ) ) { 
  339. $old_google_api_key_enable = get_option( $this->google_api_key_option . '_enable', 0 ); 
  340.  
  341. update_option( $this->google_api_key_option . '_enable', 1 ); 
  342.  
  343. $option_value = trim( $_POST[ $this->google_api_key_option ] ); 
  344.  
  345. $old_google_api_key_option = get_option( $this->google_api_key_option ); 
  346.  
  347. if ( 1 != $old_google_api_key_enable || $option_value != $old_google_api_key_option ) { 
  348.  
  349. update_option( $this->google_api_key_option, $option_value ); 
  350.  
  351. // Clear cached of google api key status 
  352. delete_transient( $this->google_api_key_option . '_status' ); 
  353.  
  354. // Disable Google Font API Key 
  355. } elseif ( isset( $_POST[ $this->google_api_key_option ] ) ) { 
  356. $old_google_api_key_enable = get_option( $this->google_api_key_option . '_enable', 0 ); 
  357.  
  358. update_option( $this->google_api_key_option . '_enable', 0 ); 
  359.  
  360. $option_value = trim( $_POST[ $this->google_api_key_option ] ); 
  361. update_option( $this->google_api_key_option, $option_value ); 
  362.  
  363. if ( 0 != $old_google_api_key_enable ) { 
  364. // Clear cached of google api key status 
  365. delete_transient( $this->google_api_key_option . '_status' ); 
  366.  
  367. $this->is_valid_google_api_key(); 
  368.  
  369. $google_fonts = get_option( $this->plugin_name . '_google_font_list', array() ); 
  370.  
  371. if ( ! is_array( $google_fonts ) || count( $google_fonts ) < 1 ) { 
  372. $google_fonts = apply_filters( $this->plugin_name . '_google_fonts', $this->google_fonts ); 
  373.  
  374. sort( $google_fonts ); 
  375.  
  376. $new_google_fonts = array(); 
  377. foreach ( $google_fonts as $row ) { 
  378. $new_google_fonts[$row['name']] = $row; 
  379.  
  380. $this->google_fonts = $new_google_fonts; 
  381.  
  382.  
  383. public function is_valid_google_api_key( $cache=true ) { 
  384. $is_valid = false; 
  385.  
  386. $this->google_api_key = get_option( $this->google_api_key_option, '' ); 
  387. $google_api_key_enable = get_option( $this->google_api_key_option . '_enable', 0 ); 
  388.  
  389. if ( '' != trim( $this->google_api_key ) && 1 == $google_api_key_enable ) { 
  390.  
  391. $google_api_key_status = get_transient( $this->google_api_key_option . '_status' ); 
  392.  
  393. if ( ! $cache ) { 
  394. $google_api_key_status = null; 
  395.  
  396. if ( ! $google_api_key_status ) { 
  397. $respone_api = wp_remote_get( "https://www.googleapis.com/webfonts/v1/webfonts?sort=alpha&key=" . trim( $this->google_api_key ),  
  398. array( 
  399. 'sslverify' => false,  
  400. 'timeout' => 45 
  401. ); 
  402.  
  403. $font_list = array(); 
  404. $response_fonts = array(); 
  405.  
  406. // Check it is a valid request 
  407. if ( ! is_wp_error( $respone_api ) ) { 
  408.  
  409. $json_string = get_magic_quotes_gpc() ? stripslashes( $respone_api['body'] ) : $respone_api['body']; 
  410. $response_fonts = json_decode( $json_string, true ); 
  411.  
  412. // Make sure that the valid response from google is not an error message 
  413. if ( ! isset( $response_fonts['error'] ) ) { 
  414. $google_api_key_status = 'valid'; 
  415. } else { 
  416. $google_api_key_status = 'invalid'; 
  417.  
  418. } else { 
  419. $google_api_key_status = 'invalid'; 
  420.  
  421. // Get font list from default webfonts.json file of plugin 
  422. if ( 'invalid' == $google_api_key_status && file_exists( $this->admin_plugin_dir() . '/assets/webfonts/webfonts.json' ) ) { 
  423. $webfonts = wp_remote_fopen( $this->admin_plugin_url() . '/assets/webfonts/webfonts.json' ); 
  424. if ( false != $webfonts ) { 
  425. $json_string = get_magic_quotes_gpc() ? stripslashes( $webfonts ) : $webfonts; 
  426. $response_fonts = json_decode( $json_string, true ); 
  427.  
  428. // Saving the font list to database for get later 
  429. if ( is_array( $response_fonts ) 
  430. && isset( $response_fonts['items'] ) 
  431. && is_array( $response_fonts['items'] ) 
  432. && count( $response_fonts['items'] ) > 0 ) { 
  433.  
  434. foreach ( $response_fonts['items'] as $font_item ) { 
  435. $variants = ''; 
  436. $comma = ''; 
  437. foreach ( $font_item['variants'] as $variant ) { 
  438. $variants .= $comma . trim( $variant ); 
  439. $comma = ', '; 
  440. if ( '' != trim( $variants ) ) { 
  441. $variants = ':' . $variants; 
  442.  
  443. $font_list[] = array( 'name' => trim( $font_item['family'] ), 'variant' => $variants ); 
  444.  
  445. update_option( $this->plugin_name . '_google_font_list', $font_list ); 
  446.  
  447. //caching google api status for 24 hours 
  448. set_transient( $this->google_api_key_option . '_status', $google_api_key_status, 86400 ); 
  449.  
  450. if ( 'valid' == $google_api_key_status ) { 
  451. $is_valid = true; 
  452.  
  453. } else { 
  454.  
  455. $google_api_key_status = get_transient( $this->google_api_key_option . '_status' ); 
  456.  
  457. if ( ! $cache ) { 
  458. $google_api_key_status = null; 
  459.  
  460. if ( ! $google_api_key_status ) { 
  461.  
  462. $font_list = array(); 
  463. $response_fonts = array(); 
  464.  
  465. // Get font list from default webfonts.json file of plugin 
  466. if ( file_exists( $this->admin_plugin_dir() . '/assets/webfonts/webfonts.json' ) ) { 
  467. $webfonts = wp_remote_fopen( $this->admin_plugin_url() . '/assets/webfonts/webfonts.json' ); 
  468. if ( false != $webfonts ) { 
  469. $json_string = get_magic_quotes_gpc() ? stripslashes( $webfonts ) : $webfonts; 
  470. $response_fonts = json_decode( $json_string, true ); 
  471.  
  472. // Saving the font list to database for get later 
  473. if ( is_array( $response_fonts ) 
  474. && isset( $response_fonts['items'] ) 
  475. && is_array( $response_fonts['items'] ) 
  476. && count( $response_fonts['items'] ) > 0 ) { 
  477.  
  478. foreach ( $response_fonts['items'] as $font_item ) { 
  479. $variants = ''; 
  480. $comma = ''; 
  481. foreach ( $font_item['variants'] as $variant ) { 
  482. $variants .= $comma . trim( $variant ); 
  483. $comma = ', '; 
  484. if ( '' != trim( $variants ) ) { 
  485. $variants = ':' . $variants; 
  486.  
  487. $font_list[] = array( 'name' => trim( $font_item['family'] ), 'variant' => $variants ); 
  488.  
  489. update_option( $this->plugin_name . '_google_font_list', $font_list ); 
  490.  
  491. //caching google api status for 24 hours 
  492. set_transient( $this->google_api_key_option . '_status', 'invalid', 86400 ); 
  493.  
  494.  
  495. return $is_valid; 
  496.  
  497. /**-----------------------------------------------------------------------------------*/ 
  498. /** Get Window Default Fonts */ 
  499. /**-----------------------------------------------------------------------------------*/ 
  500. public function get_default_fonts() { 
  501. $default_fonts = apply_filters( $this->plugin_name . '_default_fonts', $this->default_fonts ); 
  502.  
  503. asort( $default_fonts ); 
  504.  
  505. return $default_fonts; 
  506.  
  507. /**-----------------------------------------------------------------------------------*/ 
  508. /** Get Google Fonts */ 
  509. /**-----------------------------------------------------------------------------------*/ 
  510. public function get_google_fonts() { 
  511.  
  512. return $this->google_fonts; 
  513.  
  514. /**-----------------------------------------------------------------------------------*/ 
  515. /** generate_font_css() */ 
  516. /** Generate font CSS for frontend */ 
  517. /**-----------------------------------------------------------------------------------*/ 
  518. public function generate_font_css( $option, $em = '1.2' ) { 
  519. $google_fonts = $this->get_google_fonts(); 
  520.  
  521. if ( array_key_exists( $option['face'], $google_fonts ) ) { 
  522. $option['face'] = "'" . $option['face'] . "', arial, sans-serif"; 
  523.  
  524. $line_height = '1.4em'; 
  525. if( isset( $option['line_height'] ) ) { 
  526. $line_height = $option['line_height']; 
  527.  
  528. if ( !@$option['style'] && !@$option['size'] && !@$option['color'] ) 
  529. return 'font-family: '.stripslashes($option["face"]).' !important;'; 
  530. else 
  531. return 'font:'.$option['style'].' '.$option['size'].'/' . $line_height . ' ' .stripslashes($option['face']).' !important; color:'.$option['color'].' !important;'; 
  532.  
  533.  
  534. /**-----------------------------------------------------------------------------------*/ 
  535. /** Google Webfonts Stylesheet Generator */ 
  536. /**-----------------------------------------------------------------------------------*/ 
  537. /** 
  538. INSTRUCTIONS: Needs to be loaded for the Google Fonts options to work for font options. 
  539.   
  540. add_action( 'wp_head', array( $this, 'generate_google_webfonts' ) ); 
  541. */ 
  542. public function generate_google_webfonts( $my_google_fonts = array(), $echo = true ) { 
  543. $google_fonts = $this->get_google_fonts(); 
  544.  
  545. $fonts = ''; 
  546. $output = ''; 
  547.  
  548. // Go through the options 
  549. if ( is_array( $my_google_fonts ) ) { 
  550. foreach ( $my_google_fonts as $font_face ) { 
  551. // Check if the google font name exists in the current "face" option 
  552. if ( array_key_exists( $font_face, $google_fonts ) && !strstr( $fonts, $font_face ) ) { 
  553. $fonts .= $google_fonts[$font_face]['name'].$google_fonts[$font_face]['variant']."|"; 
  554. } // End Foreach Loop 
  555.  
  556. // Output google font css in header 
  557. if ( trim( $fonts ) != '' ) { 
  558. $fonts = str_replace( " ", "+", $fonts); 
  559. $output .= "\n<!-- Google Webfonts -->\n"; 
  560. $output .= '<link href="http'. ( is_ssl() ? 's' : '' ) .'://fonts.googleapis.com/css?family=' . $fonts .'" rel="stylesheet" type="text/css" />'."\n"; 
  561. $output = str_replace( '|"', '"', $output); 
  562.  
  563. if ( $echo ) 
  564. echo $output; 
  565. else 
  566. return $output; 
  567.  
  568. } // End generate_google_webfonts() 
  569.