Custom Adobe Fonts (Typekit) - Version 1.0.0

Version Description

Download this release

Release Info

Developer Nikschavan
Plugin Icon 128x128 Custom Adobe Fonts (Typekit)
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

assets/css/custom-typekit-fonts.css ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .typekit-custom-fonts-table.form-table {
2
+ margin: 0;
3
+ }
4
+
5
+ .typekit-custom-fonts-table.form-table input {
6
+ padding: 5px;
7
+ margin-right: 5px;
8
+ }
9
+
10
+ .typekit-custom-fonts-table.form-table .button {
11
+ margin-right: 5px;
12
+ }
13
+
14
+ .typekit-custom-fonts-table th {
15
+ padding-left: 10px;
16
+ border-right: 1px solid #E1E1E1;
17
+ border-bottom: 1px solid #E1E1E1;
18
+ }
19
+
20
+ .typekit-custom-fonts-table td {
21
+ border-bottom: 1px solid #E1E1E1;
22
+ }
23
+
24
+ .typekit-font-list th {
25
+ background-color: #fafafa;
26
+ border: 0;
27
+ padding: 10px;
28
+ }
29
+
30
+ .typekit-font-list {
31
+ border: 1px solid #E1E1E1;
32
+ }
33
+
34
+ .typekit-font-list td {
35
+ border: 0;
36
+ padding: 10px;
37
+ }
38
+
39
+ /* Tooltips */
40
+ .custom-typekit-fonts-help {
41
+ cursor: help;
42
+ float: right;
43
+ color: #a6a6a6;
44
+ }
45
+
46
+ .ui-widget-content.custom-typekit-fonts-help-ui-tooltip {
47
+ background: #333;
48
+ border-width: 1px;
49
+ border-color: #333;
50
+ -webkit-border-radius: 3px;
51
+ border-radius: 3px;
52
+ -webkit-box-shadow: -1px 0px 2px 0px rgba(214, 214, 214, 0.5);
53
+ box-shadow: -1px 0px 2px 0px rgba(214, 214, 214, 0.5);
54
+ color: #dedede;
55
+ max-width: 250px;
56
+ text-align: center;
57
+ padding: 7px;
58
+ text-rendering: optimizeLegibility;
59
+ text-shadow: none;
60
+ z-index: 9999;
61
+ }
62
+
63
+ .ctf-kit-active {
64
+ color: #3cb341;
65
+ }
66
+
67
+ .ctf-kit-not-active {
68
+ color: #ae5842;
69
+ }
assets/js/custom-typekit-fonts.js ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($) {
2
+
3
+ /**
4
+ * Bsf Custom Fonts
5
+ *
6
+ * @class TypekitCustomFonts
7
+ * @since 1.0.0
8
+ */
9
+
10
+ TypekitCustomFonts = {
11
+
12
+ /**
13
+ * Initializes a Bsf Custom Fonts.
14
+ *
15
+ * @since 1.0
16
+ * @method init
17
+ */
18
+ init: function () {
19
+ // Init.
20
+ if ($('.add-new-typekit').length) {
21
+ $('#custom-typekit-font-id').hide();
22
+ } else {
23
+ $('#custom-typekit-font-id').show();
24
+ }
25
+
26
+ // Call Tooltip
27
+ $('.custom-typekit-fonts-help').tooltip({
28
+ content: function () {
29
+ return $(this).prop('title');
30
+ },
31
+ tooltipClass: 'custom-typekit-fonts-help-ui-tooltip',
32
+ position: {
33
+ my: 'center top',
34
+ at: 'center bottom+10',
35
+ },
36
+ hide: {
37
+ duration: 200,
38
+ },
39
+ show: {
40
+ duration: 200,
41
+ },
42
+ });
43
+ $(document).delegate(".add-new-typekit", "click", TypekitCustomFonts._add_new_typekit_id);
44
+ },
45
+
46
+ /**
47
+ * Get hide kit id and show edit kit id button.
48
+ */
49
+ _add_new_typekit_id: function () {
50
+ $('#custom-typekit-font-id').val('');
51
+ $('#custom-typekit-font-id').show();
52
+ $(this).hide();
53
+
54
+ },
55
+ }
56
+
57
+ /* Initializes the Bsf Custom Fonts. */
58
+ $(function () {
59
+ TypekitCustomFonts.init();
60
+ });
61
+
62
+ })(jQuery);
classes/class-custom-typekit-fonts-admin.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Bsf Custom Fonts Admin Ui
4
+ *
5
+ * @since 1.0.0
6
+ * @package Bsf_Custom_Fonts
7
+ */
8
+
9
+ defined( 'ABSPATH' ) or exit;
10
+
11
+ if ( ! class_exists( 'Custom_Typekit_Fonts_Admin' ) ) :
12
+
13
+ /**
14
+ * Custom_Typekit_Fonts_Admin
15
+ */
16
+ class Custom_Typekit_Fonts_Admin {
17
+
18
+ /**
19
+ * Instance of Custom_Typekit_Fonts_Admin
20
+ *
21
+ * @since 1.0.0
22
+ * @var (Object) Custom_Typekit_Fonts_Admin
23
+ */
24
+ private static $_instance = null;
25
+
26
+ /**
27
+ * Parent Menu Slug
28
+ *
29
+ * @since 1.0.0
30
+ * @var (string) $parent_menu_slug
31
+ */
32
+ protected $parent_menu_slug = 'themes.php';
33
+
34
+ /**
35
+ * Instance of Custom_Typekit_Fonts_Admin.
36
+ *
37
+ * @since 1.0.0
38
+ *
39
+ * @return object Class object.
40
+ */
41
+ public static function get_instance() {
42
+ if ( ! isset( self::$_instance ) ) {
43
+ self::$_instance = new self;
44
+ }
45
+
46
+ return self::$_instance;
47
+ }
48
+
49
+ /**
50
+ * Constructor.
51
+ *
52
+ * @since 1.0.0
53
+ */
54
+ public function __construct() {
55
+ add_action( 'admin_menu', array( $this, 'register_custom_fonts_menu' ) );
56
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
57
+ add_action( 'admin_notices', array( $this, 'set_custom_typekit_fonts_notice' ) );
58
+
59
+ }
60
+
61
+ /**
62
+ * Set admin notice
63
+ *
64
+ * @since 1.0.0
65
+ */
66
+ public function set_custom_typekit_fonts_notice() {
67
+ // Notice for astra theme version.
68
+ if ( defined( 'ASTRA_THEME_VERSION' ) ) {
69
+ if ( version_compare( ASTRA_THEME_VERSION, '1.0.18', '<' ) ) {
70
+ ?>
71
+ <div class="notice notice-error is-dismissible">
72
+ <p>
73
+ <?php echo esc_html__( 'Custom Typekit Fonts Plugin requires minimum 1.0.18 version of the Astra Theme.', 'custom-typekit-fonts' ); ?>
74
+ </p>
75
+ </div>
76
+ <?php
77
+ }
78
+ }
79
+
80
+ // Notice for Custom Typekit Fonts action.
81
+ if ( isset( $_POST['custom-typekit-fonts-nonce'] ) && wp_verify_nonce( $_POST['custom-typekit-fonts-nonce'], 'custom-typekit-fonts' ) ) {
82
+
83
+ if ( isset( $_POST['custom-typekit-fonts-submitted'] ) ) {
84
+ if ( sanitize_text_field( $_POST['custom-typekit-fonts-submitted'] ) == 'submitted' && current_user_can( 'manage_options' ) ) {
85
+ ?>
86
+
87
+ <?php
88
+ // if Kit ID not validated show notice.
89
+ if ( isset( $_POST['custom-typekit-font-notice'] ) && $_POST['custom-typekit-font-notice'] ) {
90
+ ?>
91
+ <div class="notice notice-error is-dismissible">
92
+ <p><?php _e( 'Please Enter the Valid Kit ID to get the kit details.', 'custom-typekit-fonts' ); ?></p>
93
+ </div>
94
+ <?php } else { ?>
95
+ <div class="notice notice-success is-dismissible">
96
+ <p><?php _e( 'Custom Typekit Fonts settings have been successfully saved.', 'custom-typekit-fonts' ); ?></p>
97
+ </div>
98
+ <?php
99
+ }
100
+ }
101
+ }
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Register custom font menu
107
+ *
108
+ * @since 1.0.0
109
+ */
110
+ public function register_custom_fonts_menu() {
111
+ add_options_page(
112
+ __( 'Custom Typekit Fonts', 'custom-typekit-fonts' ),
113
+ __( 'Custom Typekit Fonts', 'custom-typekit-fonts' ),
114
+ 'edit_theme_options',
115
+ 'custom-typekit-fonts',
116
+ array( $this, 'typekit_options_page' )
117
+ );
118
+
119
+ add_submenu_page(
120
+ 'themes.php',
121
+ __( 'Custom Typekit Fonts', 'custom-typekit-fonts' ),
122
+ __( 'Custom Typekit Fonts', 'custom-typekit-fonts' ),
123
+ 'edit_theme_options',
124
+ 'custom-typekit-fonts',
125
+ array( $this, 'typekit_options_page' )
126
+ );
127
+ }
128
+
129
+ /**
130
+ * Typekit Custom Fonts Setting page
131
+ *
132
+ * @since 1.0.0
133
+ */
134
+ public function typekit_options_page() {
135
+
136
+ require_once CUSTOM_TYPEKIT_FONTS_DIR . 'templates/custom-typekit-fonts-options.php';
137
+ }
138
+
139
+ /**
140
+ * Enqueue Admin Scripts
141
+ *
142
+ * @since 1.0.0
143
+ */
144
+ public function enqueue_scripts() {
145
+
146
+ wp_enqueue_style( 'custom-typekit-fonts-css', CUSTOM_TYPEKIT_FONTS_URI . 'assets/css/custom-typekit-fonts.css', array(), CUSTOM_TYPEKIT_FONTS_VER );
147
+
148
+ wp_enqueue_script( 'custom-typekit-fonts-js', CUSTOM_TYPEKIT_FONTS_URI . 'assets/js/custom-typekit-fonts.js', array( 'jquery-ui-tooltip' ), CUSTOM_TYPEKIT_FONTS_VER );
149
+
150
+ }
151
+
152
+ }
153
+
154
+
155
+ /**
156
+ * Kicking this off by calling 'get_instance()' method
157
+ */
158
+ Custom_Typekit_Fonts_Admin::get_instance();
159
+
160
+ endif;
classes/class-custom-typekit-fonts-render.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Bsf Custom Fonts Admin Ui
4
+ *
5
+ * @since 1.0.0
6
+ * @package Bsf_Custom_Fonts
7
+ */
8
+
9
+ defined( 'ABSPATH' ) or exit;
10
+
11
+ if ( ! class_exists( 'Custom_Typekit_Fonts_Render' ) ) :
12
+
13
+ /**
14
+ * Custom_Typekit_Fonts_Render
15
+ */
16
+ class Custom_Typekit_Fonts_Render {
17
+
18
+ /**
19
+ * Instance of Custom_Typekit_Fonts_Render
20
+ *
21
+ * @since 1.0.0
22
+ * @var (Object) Custom_Typekit_Fonts_Render
23
+ */
24
+ private static $_instance = null;
25
+
26
+ /**
27
+ * Member Varible
28
+ *
29
+ * @var string $font_css
30
+ */
31
+ protected $font_css;
32
+
33
+ /**
34
+ * Instance of Bsf_Custom_Fonts_Admin.
35
+ *
36
+ * @since 1.0.0
37
+ *
38
+ * @return object Class object.
39
+ */
40
+ public static function get_instance() {
41
+ if ( ! isset( self::$_instance ) ) {
42
+ self::$_instance = new self;
43
+ }
44
+
45
+ return self::$_instance;
46
+ }
47
+
48
+ /**
49
+ * Constructor.
50
+ *
51
+ * @since 1.0.0
52
+ */
53
+ public function __construct() {
54
+
55
+ add_action( 'wp_head', array( $this, 'typekit_embed_head' ) );
56
+ // add Custom Font list into Astra customizer.
57
+ add_action( 'astra_customizer_font_list', array( $this, 'add_customizer_font_list' ) );
58
+ add_action( 'astra_render_fonts', array( $this, 'render_fonts' ) );
59
+ add_filter( 'astra_custom_fonts', array( $this, 'add_typekit_fonts' ) );
60
+ add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
61
+ }
62
+
63
+ /**
64
+ * Add Script into wp head
65
+ *
66
+ * @since 1.0.0
67
+ */
68
+ function typekit_embed_head() {
69
+ $kit_info = get_option( 'custom-typekit-fonts' );
70
+ if ( empty( $kit_info['custom-typekit-font-details'] ) ) {
71
+ return;
72
+ }
73
+ ?>
74
+ <script>
75
+ (function(d) {
76
+ var config = {
77
+ kitId : '<?php echo esc_js( $kit_info['custom-typekit-font-id'] ); ?>',
78
+ scriptTimeout : 3000,
79
+ async : true
80
+ },
81
+ h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)
82
+ })(document);
83
+ </script>
84
+
85
+ <?php
86
+ }
87
+
88
+ /**
89
+ * Add Custom Fonts list into
90
+ *
91
+ * @since 1.0.0
92
+ *
93
+ * @param array $custom_fonts custom fonts.
94
+ */
95
+ function add_typekit_fonts( $custom_fonts ) {
96
+
97
+ $kit_info = get_option( 'custom-typekit-fonts' );
98
+ if ( empty( $kit_info['custom-typekit-font-details'] ) ) {
99
+ return $custom_fonts;
100
+ }
101
+ $new_custom_fonts = wp_parse_args( $kit_info['custom-typekit-font-details'], $custom_fonts );
102
+
103
+ return $new_custom_fonts;
104
+
105
+ }
106
+
107
+ /**
108
+ * Dequeue Render custom fonts
109
+ *
110
+ * @since 1.0.0
111
+ *
112
+ * @param array $load_fonts astra fonts.
113
+ */
114
+ public function render_fonts( $load_fonts ) {
115
+
116
+ $kit_list = get_option( 'custom-typekit-fonts' );
117
+ if ( ! empty( $kit_list['custom-typekit-font-details'] ) ) {
118
+ foreach ( $load_fonts as $load_font_name => $load_font ) {
119
+ $font_arr = explode( ',', $load_font_name );
120
+ $font_name = $font_arr[0];
121
+ // unset theme fonts to prevent the script call.
122
+ if ( isset( $kit_list['custom-typekit-font-details'][ $font_name ] ) ) {
123
+ unset( $load_fonts[ $load_font_name ] );
124
+ }
125
+ }
126
+ }
127
+
128
+ return $load_fonts;
129
+ }
130
+
131
+ /**
132
+ * Add Custom Font list into Astra customizer.
133
+ *
134
+ * @since 1.0.0
135
+ *
136
+ * @param string $value selected font family.
137
+ */
138
+ public function add_customizer_font_list( $value ) {
139
+
140
+ $kit_list = get_option( 'custom-typekit-fonts' );
141
+ if ( ! empty( $kit_list['custom-typekit-font-details'] ) ) {
142
+ echo '<optgroup label="Typekit">';
143
+ foreach ( $kit_list['custom-typekit-font-details'] as $font => $properties ) {
144
+ echo '<option value="' . esc_attr( $font ) . ',' . $properties['fallback'] . '" ' . selected( $font, $value, false ) . '>' . esc_attr( $font ) . '</option>';
145
+ }
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Loads textdomain for the plugin.
151
+ *
152
+ * @since 1.0.0
153
+ */
154
+ function load_textdomain() {
155
+ load_plugin_textdomain( 'custom-typekit-fonts' );
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Kicking this off by calling 'get_instance()' method
161
+ */
162
+ Custom_Typekit_Fonts_Render::get_instance();
163
+
164
+ endif;
165
+
166
+
167
+
168
+
169
+
classes/class-custom-typekit-fonts.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Typekit Custom fonts - Init
4
+ *
5
+ * @package Custom_Typekit_Fonts
6
+ */
7
+
8
+ if ( ! class_exists( 'Custom_Typekit_Fonts' ) ) {
9
+
10
+ /**
11
+ * Typekit Custom fonts
12
+ *
13
+ * @since 1.0.0
14
+ */
15
+ class Custom_Typekit_Fonts {
16
+
17
+ /**
18
+ * Member Varible
19
+ *
20
+ * @var object instance
21
+ */
22
+ private static $instance;
23
+
24
+ /**
25
+ * Initiator
26
+ */
27
+ public static function get_instance() {
28
+ if ( ! isset( self::$instance ) ) {
29
+ self::$instance = new self;
30
+ }
31
+
32
+ return self::$instance;
33
+ }
34
+
35
+ /**
36
+ * Constructor function that initializes required actions and hooks
37
+ */
38
+ public function __construct() {
39
+ require_once CUSTOM_TYPEKIT_FONTS_DIR . 'classes/class-custom-typekit-fonts-admin.php';
40
+ require_once CUSTOM_TYPEKIT_FONTS_DIR . 'classes/class-custom-typekit-fonts-render.php';
41
+
42
+ add_action( 'init', array( $this, 'options_setting' ) );
43
+ }
44
+
45
+ /**
46
+ * Update the custom-typekit-font option
47
+ *
48
+ * @since 1.0.0
49
+ */
50
+ public function options_setting() {
51
+
52
+ if ( isset( $_POST['custom-typekit-fonts-nonce'] ) && wp_verify_nonce( $_POST['custom-typekit-fonts-nonce'], 'custom-typekit-fonts' ) ) {
53
+
54
+ if ( isset( $_POST['custom-typekit-fonts-submitted'] ) ) {
55
+ if ( sanitize_text_field( $_POST['custom-typekit-fonts-submitted'] ) == 'submitted' ) {
56
+
57
+ $option = array();
58
+ $option['custom-typekit-font-id'] = sanitize_text_field( $_POST['custom-typekit-font-id'] );
59
+ $option['custom-typekit-font-details'] = $this->get_custom_typekit_details( $option['custom-typekit-font-id'] );
60
+
61
+ if ( empty( $option['custom-typekit-font-details'] ) ) {
62
+ $_POST['custom-typekit-font-notice'] = true;
63
+
64
+ // Get all stored typekit fonts.
65
+ // Search it in 'get_option( ASTRA_THEME_SETTINGS )'.
66
+ // If found set 'inherit'.
67
+ // Update 'ASTRA_THEME_SETTINGS'.
68
+ if ( defined( 'ASTRA_THEME_SETTINGS' ) ) {
69
+ // get astra options.
70
+ $options = get_option( ASTRA_THEME_SETTINGS );
71
+ $custom_typekit = get_option( 'custom-typekit-fonts' );
72
+ foreach ( $options as $key => $value ) {
73
+ $font_arr = explode( ',', $value );
74
+ $font_name = $font_arr[0];
75
+ if ( isset( $custom_typekit['custom-typekit-font-details'][ $font_name ] ) ) {
76
+ // set default inherit if custom font is deleted.
77
+ $options[ $key ] = 'inherit';
78
+ }
79
+ }
80
+ // update astra options.
81
+ update_option( ASTRA_THEME_SETTINGS, $options );
82
+ }
83
+ }
84
+
85
+ update_option( 'custom-typekit-fonts', $option );
86
+
87
+ }
88
+ }
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Get the Kit details usign wp_remote_get.
94
+ *
95
+ * @since 1.0.0
96
+ *
97
+ * @param string $kit_id Typekit ID.
98
+ */
99
+ function get_custom_typekit_details( $kit_id ) {
100
+
101
+ $typekit_info = array();
102
+ $typekit_uri = 'https://typekit.com/api/v1/json/kits/' . $kit_id . '/published';
103
+ $response = wp_remote_get(
104
+ $typekit_uri,
105
+ array(
106
+ 'timeout' => '30',
107
+ )
108
+ );
109
+
110
+ if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 ) {
111
+ return $typekit_info;
112
+ }
113
+
114
+ $data = json_decode( wp_remote_retrieve_body( $response ), true );
115
+ $families = $data['kit']['families'];
116
+
117
+ foreach ( $families as $family ) :
118
+
119
+ $typekit_info[ $family['name'] ] = array(
120
+ 'family' => $family['name'],
121
+ 'fallback' => str_replace( '"', '', $family['css_stack'] ),
122
+ 'weights' => array(),
123
+ );
124
+
125
+ foreach ( $family['variations'] as $variation ) :
126
+
127
+ $variations = str_split( $variation );
128
+
129
+ switch ( $variations[0] ) {
130
+ case 'n':
131
+ $style = 'normal';
132
+ break;
133
+ default:
134
+ $style = 'normal';
135
+ break;
136
+ }
137
+
138
+ $weight = $variations[1] . '00';
139
+
140
+ if ( ! in_array( $weight, $typekit_info[ $family['name'] ]['weights'] ) ) {
141
+ $typekit_info[ $family['name'] ]['weights'][] = $weight;
142
+ }
143
+
144
+ endforeach;
145
+
146
+ endforeach;
147
+
148
+ return $typekit_info;
149
+ }
150
+
151
+ }
152
+
153
+ /**
154
+ * Kicking this off by calling 'get_instance()' method
155
+ */
156
+ Custom_Typekit_Fonts::get_instance();
157
+ }// End if().
custom-typekit-fonts.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Custom Typekit Fonts
4
+ * Plugin URI: http://www.wpastra.com/
5
+ * Description: Custom Typekit Fonts allows you to extends the fonts supports from the Typekit.
6
+ * Author: Brainstorm Force
7
+ * Author URI: http://www.brainstormforce.com
8
+ * Text Domain: custom-typekit-fonts
9
+ * Version: 1.0.0
10
+ *
11
+ * @package Typekit_Custom_Fonts
12
+ */
13
+
14
+ /**
15
+ * Exit if accessed directly.
16
+ */
17
+ if ( ! defined( 'ABSPATH' ) ) {
18
+ exit();
19
+ }
20
+
21
+ /**
22
+ * Set constants.
23
+ */
24
+ define( 'CUSTOM_TYPEKIT_FONTS_FILE', __FILE__ );
25
+ define( 'CUSTOM_TYPEKIT_FONTS_BASE', plugin_basename( CUSTOM_TYPEKIT_FONTS_FILE ) );
26
+ define( 'CUSTOM_TYPEKIT_FONTS_DIR', plugin_dir_path( CUSTOM_TYPEKIT_FONTS_FILE ) );
27
+ define( 'CUSTOM_TYPEKIT_FONTS_URI', plugins_url( '/', CUSTOM_TYPEKIT_FONTS_FILE ) );
28
+ define( 'CUSTOM_TYPEKIT_FONTS_VER', '1.0.0' );
29
+ /**
30
+ * BSF Custom Fonts
31
+ */
32
+ require_once CUSTOM_TYPEKIT_FONTS_DIR . 'classes/class-custom-typekit-fonts.php';
languages/custom-typekit-fonts.pot ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2017 Brainstorm Force
2
+ # This file is distributed under the same license as the Custom Typekit Fonts package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Custom Typekit Fonts 1.0.0\n"
6
+ "Report-Msgid-Bugs-To: "
7
+ "https://wordpress.org/support/plugin/custom-typekit-fonts\n"
8
+ "POT-Creation-Date: 2017-08-18 14:27:59+00:00\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=utf-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "X-Generator: grunt-wp-i18n 0.5.4\n"
16
+ "X-Poedit-KeywordsList: "
17
+ "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
18
+ "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n"
19
+ "Language: en\n"
20
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
21
+ "X-Poedit-Country: United States\n"
22
+ "X-Poedit-SourceCharset: UTF-8\n"
23
+ "X-Poedit-Basepath: ../\n"
24
+ "X-Poedit-SearchPath-0: .\n"
25
+ "X-Poedit-Bookmarks: \n"
26
+ "X-Textdomain-Support: yes\n"
27
+
28
+ #: classes/class-custom-typekit-fonts-admin.php:73
29
+ msgid ""
30
+ "Custom Typekit Fonts Plugin requires minimum 1.0.18 version of the Astra "
31
+ "Theme."
32
+ msgstr ""
33
+
34
+ #: classes/class-custom-typekit-fonts-admin.php:92
35
+ #: templates/custom-typekit-fonts-options.php:27
36
+ msgid "Please Enter the Valid Kit ID to get the kit details."
37
+ msgstr ""
38
+
39
+ #: classes/class-custom-typekit-fonts-admin.php:96
40
+ msgid "Custom Typekit Fonts settings have been successfully saved."
41
+ msgstr ""
42
+
43
+ #. Plugin Name of the plugin/theme
44
+ msgid "Custom Typekit Fonts"
45
+ msgstr ""
46
+
47
+ #: templates/custom-typekit-fonts-options.php:11
48
+ msgid "Typekit"
49
+ msgstr ""
50
+
51
+ #: templates/custom-typekit-fonts-options.php:17
52
+ msgid "Settings"
53
+ msgstr ""
54
+
55
+ #: templates/custom-typekit-fonts-options.php:24
56
+ msgid "Kit ID:"
57
+ msgstr ""
58
+
59
+ #: templates/custom-typekit-fonts-options.php:35
60
+ msgid "Edit Kit ID"
61
+ msgstr ""
62
+
63
+ #: templates/custom-typekit-fonts-options.php:39
64
+ msgid "Refresh"
65
+ msgstr ""
66
+
67
+ #: templates/custom-typekit-fonts-options.php:41
68
+ msgid "Save"
69
+ msgstr ""
70
+
71
+ #: templates/custom-typekit-fonts-options.php:53
72
+ msgid "Kit Details:"
73
+ msgstr ""
74
+
75
+ #: templates/custom-typekit-fonts-options.php:55
76
+ msgid ""
77
+ "Make sure you have published the kit from Typekit. Only published "
78
+ "information is displayed here."
79
+ msgstr ""
80
+
81
+ #: templates/custom-typekit-fonts-options.php:61
82
+ msgid "Fonts"
83
+ msgstr ""
84
+
85
+ #: templates/custom-typekit-fonts-options.php:64
86
+ msgid "Weights"
87
+ msgstr ""
88
+
89
+ #: templates/custom-typekit-fonts-options.php:102
90
+ msgid "Help"
91
+ msgstr ""
92
+
93
+ #: templates/custom-typekit-fonts-options.php:108
94
+ #. translators: %1$s: typekit site url.
95
+ msgid ""
96
+ "You can get the Kit ID <a href=%1$s target=\"_blank\" >here</a> from your "
97
+ "Typekit Account. <b>Kit ID</b> can be found next to the kit names."
98
+ msgstr ""
99
+
100
+ #: templates/custom-typekit-fonts-options.php:119
101
+ msgid "How it works?"
102
+ msgstr ""
103
+
104
+ #: templates/custom-typekit-fonts-options.php:123
105
+ msgid ""
106
+ "Once you get the Kit Details, all the fonts will be listed in the "
107
+ "customizer under typography"
108
+ msgstr ""
109
+
110
+ #: templates/custom-typekit-fonts-options.php:127
111
+ msgid "Go To Customizer"
112
+ msgstr ""
113
+
114
+ #. Plugin URI of the plugin/theme
115
+ msgid "http://www.wpastra.com/"
116
+ msgstr ""
117
+
118
+ #. Description of the plugin/theme
119
+ msgid ""
120
+ "Custom Fonts allows you to add more fonts that extend formatting options in "
121
+ "your site."
122
+ msgstr ""
123
+
124
+ #. Author of the plugin/theme
125
+ msgid "Brainstorm Force"
126
+ msgstr ""
127
+
128
+ #. Author URI of the plugin/theme
129
+ msgid "http://www.brainstormforce.com"
130
+ msgstr ""
readme.txt ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Custom Typekit Fonts ===
2
+ Contributors: brainstormforce
3
+ Donate link: https://wpastra.com/
4
+ Tags: custom typekit fonts, theme custom fonts, unlimited typekit custom fonts
5
+ Requires at least: 4.4
6
+ Tested up to: 4.8.1
7
+ Stable tag: 1.0.0
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Custom Typekit Fonts allows you to extends the fonts supports from the Typekit.
12
+
13
+ == Description ==
14
+
15
+ Custom Typekit Fonts allows you to extends the fonts supports from the Typekit.
16
+
17
+ You don't need to include any code to get the Typekit Fonts. You can directly add Typekit ID and start using the fonts of your choice. Select any published kit font into the customizer.
18
+
19
+ Get more details from [Typekit](https://typekit.com/).
20
+
21
+ == Installation ==
22
+
23
+ 1. Upload the plugin files to the `/wp-content/plugins/custom-typekit-fonts` directory, or install the plugin through the WordPress plugins screen directly.
24
+ 2. Activate the plugin through the 'Plugins' screen in WordPress.
25
+ 3. Use the Appearance->Custom Typekit Fonts -> Add Kit ID and start using fonts from customizer.
26
+
27
+ == Screenshots ==
28
+
29
+ 1. Enter your Typekit ID
30
+ 2. Get all published kit details from your Typekit ID
31
+ 3. Select any Typekit font into the Customizer
32
+ 4. Get your Typekit ID
33
+
34
+ == Changelog ==
35
+
36
+ v1.0.0
37
+ * Initial release
templates/custom-typekit-fonts-options.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Custom Typekit fonts Template
4
+ *
5
+ * @package Custom_Typekit_Fonts
6
+ */
7
+
8
+ $kit_info = get_option( 'custom-typekit-fonts' );
9
+ ?>
10
+ <div class="wrap">
11
+ <h2><?php esc_html_e( 'Typekit', 'custom-typekit-fonts' ); ?></h2>
12
+ <div id="poststuff">
13
+ <div id="post-body" class="metabox-holder columns-2 typekit-custom-fonts-wrap">
14
+ <div id="post-body-content">
15
+ <div class="meta-box-sortables ui-sortable">
16
+ <div class="postbox">
17
+ <h3 class="hndle"><span><?php esc_html_e( 'Settings', 'custom-typekit-fonts' ); ?></span></h3>
18
+ <form name="custom-typekit-fonts-form" method="post" action="">
19
+ <table class="form-table typekit-custom-fonts-table">
20
+ <tbody>
21
+ <tr valign="top">
22
+ <th scope="row">
23
+ <label
24
+ for="typekit_id"> <?php esc_html_e( 'Kit ID:', 'custom-typekit-fonts' ); ?>
25
+ </label>
26
+ <i class="custom-typekit-fonts-help dashicons dashicons-editor-help"
27
+ title="<?php echo esc_attr__( 'Please Enter the Valid Kit ID to get the kit details.', 'custom-typekit-fonts' ); ?>"></i>
28
+ </th>
29
+ <td><input
30
+ style="display:<?php echo esc_attr( empty( $kit_info['custom-typekit-font-details'] ) ? 'inline-block' : 'none' ); ?>"
31
+ type="text" name="custom-typekit-font-id" id="custom-typekit-font-id"
32
+ value="<?php echo ( isset( $kit_info['custom-typekit-font-id'] ) ) ? esc_attr( $kit_info['custom-typekit-font-id'] ) : ''; ?>">
33
+ <?php if ( ! empty( $kit_info['custom-typekit-font-details'] ) ) : ?>
34
+ <a class="add-new-typekit button button-large"
35
+ href="#"><?php echo esc_html__( 'Edit Kit ID', 'custom-typekit-fonts' ); ?></a>
36
+ <?php endif; ?>
37
+
38
+ <?php
39
+ $btn = __( 'Refresh', 'custom-typekit-fonts' );
40
+ if ( empty( $kit_info['custom-typekit-font-id'] ) || empty( $kit_info['custom-typekit-font-details'] ) ) {
41
+ $btn = __( 'Save', 'custom-typekit-fonts' );
42
+ }
43
+ ?>
44
+ <input id="submit" class="button button-large" type="submit"
45
+ value=" <?php echo esc_attr( $btn ); ?> ">
46
+ </td>
47
+ </tr>
48
+
49
+ <?php if ( ! empty( $kit_info['custom-typekit-font-details'] ) ) : ?>
50
+ <tr>
51
+ <th>
52
+ <label
53
+ for="font-list"> <?php esc_html_e( 'Kit Details:', 'custom-typekit-fonts' ); ?> </label>
54
+ <i class="custom-typekit-fonts-help dashicons dashicons-editor-help"
55
+ title="<?php echo esc_attr__( 'Make sure you have published the kit from Typekit. Only published information is displayed here.', 'custom-typekit-fonts' ); ?>"></i>
56
+ </th>
57
+ <td>
58
+ <table class="typekit-font-list">
59
+ <tr>
60
+ <th>
61
+ <?php esc_html_e( 'Fonts', 'custom-typekit-fonts' ); ?>
62
+ </th>
63
+ <th>
64
+ <?php esc_html_e( 'Weights', 'custom-typekit-fonts' ); ?>
65
+ </th>
66
+ </tr>
67
+ <?php
68
+
69
+ foreach ( $kit_info['custom-typekit-font-details'] as $font ) :
70
+
71
+ echo '<tr>';
72
+ echo '<td>' . $font['family'] . '</td>';
73
+ echo '<td>';
74
+ $comma_sep_arr = array();
75
+ foreach ( $font['weights'] as $weight ) :
76
+ $comma_sep_arr[] = $weight;
77
+ endforeach;
78
+ echo join( ', ', $comma_sep_arr );
79
+ echo '</td>';
80
+ echo '</tr>';
81
+
82
+ endforeach;
83
+
84
+ ?>
85
+ </table>
86
+ </td>
87
+ </tr>
88
+ <?php endif; ?>
89
+ </tbody>
90
+ </table>
91
+
92
+ <?php wp_nonce_field( 'custom-typekit-fonts', 'custom-typekit-fonts-nonce' ); ?>
93
+ <input name="custom-typekit-fonts-submitted" type="hidden" value="submitted">
94
+
95
+ </form>
96
+ </div>
97
+ </div>
98
+ </div>
99
+ <div id="postbox-container-1" class="postbox-container">
100
+ <div class="meta-box-sortables">
101
+ <div class="postbox">
102
+ <h3 class="hndle"><span><?php esc_html_e( 'Help', 'custom-typekit-fonts' ); ?></span></h3>
103
+ <div class="inside">
104
+ <div class="panel-inner">
105
+ <p>
106
+ <?php
107
+ /* translators: %1$s: typekit site url. */
108
+ printf( __( 'You can get the Kit ID <a href=%1$s target="_blank" >here</a> from your Typekit Account. <b>Kit ID</b> can be found next to the kit names.', 'custom-typekit-fonts' ), 'https://typekit.com/account/kits' );
109
+ ?>
110
+ </p>
111
+
112
+ </div>
113
+ </div>
114
+ </div>
115
+ </div>
116
+
117
+ <div class="meta-box-sortables">
118
+ <div class="postbox">
119
+ <h3 class="hndle"><span><?php esc_html_e( 'How it works?', 'custom-typekit-fonts' ); ?></span>
120
+ </h3>
121
+ <div class="inside">
122
+ <div class="panel-inner">
123
+ <p> <?php esc_html_e( 'Once you get the Kit Details, all the fonts will be listed in the customizer under typography', 'custom-typekit-fonts' ); ?>
124
+
125
+ </p>
126
+ <a class="submit button button-hero"
127
+ href="<?php echo esc_url( admin_url( 'customize.php' ) ); ?>"><?php esc_html_e( 'Go To Customizer', 'custom-typekit-fonts' ); ?></a>
128
+
129
+ </div>
130
+ </div>
131
+ </div>
132
+ </div>
133
+ </div>
134
+ </div>
135
+ </div>
136
+ </div>