PluginProbe
Social Share Buttons / trunk
Social Share Buttons vtrunk
trunk 0.9 1.0 1.1 1.1.1 1.1.2 1.10 1.11 1.12 1.15 1.16 1.17 1.18 1.19 1.2 1.20 1.3 1.30 1.4 1.5 1.6 1.7 1.8 1.9
share-button / classes / class-patches.php

class-patches.php in Social Share Buttons trunk, at classes/class-patches.php

84 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace MBSocial;
3 defined('ABSPATH') or die('No direct access permitted');
4
5 // Class for temporary ugly code to keep everything together
6
7 class patches
8 {
9
10 protected static $webfonts;
11 //'mbsocial/parsecss/', --filter
12
13 // From maxbuttons font block -
14 public static function checkWebFonts($args)
15 {
16 $defaults = array(
17 'font' => '',
18 'weight' => '400',
19
20 );
21
22 if (! Install::isPro())
23 return;
24
25
26 $args = wp_parse_args($args, $defaults);
27
28 $system_fonts = array('', 'Arial', 'Courier New', 'Georgia', 'Tahoma', 'Times New Roman', 'Trebuchet MS',
29 'Verdana');
30
31 $webfontspath = MB()->get_plugin_path(true) . '/assets/fonts/webfonts.json';
32 $webfontspath = apply_filters('maxbuttons/webfonts', $webfontspath);
33
34 //$is_bold = (isset($options['bold']) && $options['bold'] == 'bold' ) ? true: false;
35 //$is_italic = (isset($options['style']) && $options['style'] == 'italic' ) ? true: false;
36
37 $font = $args['font'];
38 $weight = $args['weight'];
39
40 $full_font = $font;
41
42 // system fonts not process by webfonts
43 if(in_array($font, $system_fonts))
44 return;
45
46 if ( is_null(static::$webfonts))
47 static::$webfonts = json_decode(file_get_contents($webfontspath), true);
48
49 $webfonts = static::$webfonts;
50
51 foreach($webfonts['items'] as $index => $item)
52 {
53 if ($item['family'] == $font)
54 {
55 $weight = false;
56 $variants = $item['variants'];
57
58 if (in_array('regular', $variants))
59 {
60 $weight = 400;
61 }
62 elseif (in_array('300', $variants))
63 {
64 $weight = 300;
65 }
66 elseif(in_array('500', $variants))
67 {
68 $weight = 500;
69 }
70 break;
71 }
72 }
73 $webfonts = null;
74
75 $font = preg_replace('/\s/', '+', $font);
76 $url = '//fonts.googleapis.com/css?family=' . $font . ':' . $weight;
77
78 //$this->webfonts[$full_font] = $url;
79
80 return $url;
81 }
82
83 }
84