-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtiny-pixel-typekit.php
49 lines (44 loc) · 1.57 KB
/
tiny-pixel-typekit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/*
Plugin Name: ✨Typekit WP✨
Description: Simple typekit integration for WordPress
Plugin URI: https://github.com/pixelcollective/tiny-typekit
Author: Tiny Pixel Collective, Kelly Mears <[email protected]>
Version: 1.0.0
Author URI: https://tinypixel.io
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
require_once plugin_dir_path( __FILE__ ). 'CMB2/init.php';
add_action( 'cmb2_admin_init', function () {
$tinypixel_options = new_cmb2_box( array(
'id' => 'tiny_pixel_options',
'title' => esc_html__( 'Tiny Pixel', 'tiny_pixel' ),
'object_types' => array( 'options-page' ),
'option_key' => 'tiny_pixel',
'icon_url' => 'dashicons-palmtree',
) );
$typekit_options = new_cmb2_box( array (
'id' => 'tiny_pixel_typekit',
'title' => esc_html__( 'Typekit', 'cmb2' ),
'object_types' => array( 'options-page' ),
'option_key' => 'tiny_pixel_typekit',
'parent_slug' => 'tiny_pixel',
) );
$typekit_options->add_field( array (
'name' => esc_html__( 'Typekit', 'tiny_pixel' ),
'desc' => esc_html__( 'Provided by Adobe Typekit', 'tiny_pixel' ),
'default' => 'xBoX720.js',
'id' => 'embed',
'type' => 'text',
) );
});
add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_script( 'pixel_typekit', '//use.typekit.net/'. cmb2_get_option( 'tiny_pixel_typekit', 'embed', false ), array(), null );
});
add_action('wp_head', function() {
if (wp_script_is( 'pixel_typekit', 'enqueued' )) :
echo '<script type="text/javascript">try{Typekit.load();}catch(e){}</script>';
endif;
});