Typekit Fonts for WordPress - Version 1.0.0

Version Description

Download this release

Release Info

Developer jamescollins
Plugin Icon 128x128 Typekit Fonts for WordPress
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

readme.txt ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Typekit Fonts for WordPress ===
2
+ Contributors: jamescollins, glenn-om4
3
+ Tags: typekit, fonts, font, design, wp, wpmu
4
+ Requires at least: 2.8
5
+ Tested up to: 2.8.6
6
+ Stable tag: 1.0.0
7
+
8
+ Use a range of hundreds of high quality fonts on your WordPress website by integrating the Typekit font service into your WordPress blog.
9
+
10
+ == Description ==
11
+
12
+ [Typekit](http://www.typekit.com) offer a service that allows you to select from a range of hundreds of high quality fonts for your WordPress website. The fonts are applied using the font-face standard, so they are standards compliant, fully licensed and accessible.
13
+
14
+ This plugin allows you to embed and use Typekit fonts in your WordPress blog without having to edit your theme's header or CSS files.
15
+
16
+ To use this plugin you need to sign up with Typekit, install this plugin and then configure CSS for your site. Detailed instructions are available on the plugin's settings page.
17
+
18
+ Compatible with both WordPress and WordPress MU (WPMU).
19
+
20
+ This plugin is designed to function securely with both WordPress and WordPress MU. When the JavaScript Embed Code is entered on the settings page, the user account id is extracted from the embed code and the correctly formed Typekit Embed Code is included in the site header, so it is not possible to use the Embed Code field to include arbitrary JavaScript. The Custom CSS field is also filtered, and doesn't allow any HTML code to be entered.
21
+
22
+ == Installation ==
23
+
24
+ Installation of this plugin is simple:
25
+
26
+ 1. Download the plugin files and copy to your Plugins directory.
27
+ 1. Activate the plugin through the 'Plugins' menu in WordPress.
28
+ 1. Go to the WordPress Dashboard, and use Settings, Typekit Fonts to enter the whole 2 lines of your Typekit embed code.
29
+ 1. If you want to setup some CSS selectors like the examples shown in the Advanced link, enter your CSS rules in the plugin settings as well.
30
+
31
+ == Frequently Asked Questions ==
32
+
33
+ = Where can I get help? =
34
+
35
+ There are detailed instructions on the plugin's settings page. See screenshot #2 for more information.
36
+
37
+ = Is this plugin secure? =
38
+
39
+ Yes, see the plugin's description for more information.
40
+
41
+ == Screenshots ==
42
+ 1. Settings/configuration page
43
+ 2. Detailed inline help
44
+
45
+ == Changelog ==
46
+
47
+ = v1.0.0 =
48
+
49
+ * Inital release.
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
typekit-admin.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The Administration interface
5
+ *
6
+ */
7
+ class OM4_Typekit_Admin {
8
+
9
+ var $typekitInstance;
10
+
11
+ /**
12
+ * Class Constructor
13
+ *
14
+ * @param OM4_Typekit instance
15
+ */
16
+ function OM4_Typekit_Admin(& $instance) {
17
+ global $wpdb;
18
+
19
+ $this->typekitInstance = & $instance;
20
+
21
+ add_action('admin_menu', array(& $this, 'AdminMenu'));
22
+ }
23
+
24
+ /**
25
+ * Set up the Admin Settings menu
26
+ */
27
+ function AdminMenu() {
28
+ add_options_page(__('Typekit Fonts', 'om4-typekit'), __('Typekit Fonts', 'om4-typekit'), 'manage_options', basename(__FILE__), array(& $this, 'AdminPage'));
29
+ }
30
+
31
+ /**
32
+ * Display the admin settings page
33
+ */
34
+ function AdminPage() {
35
+ ?>
36
+ <div class="wrap typekitsettings">
37
+ <style type="text/css">
38
+ .typekitsettings label { font-weight: bold; vertical-align: top; padding-right: 1em; }
39
+ .typekitsettings li p { margin: 1em 0em; }
40
+ .typekitsettings p code { margin: 0.5em; padding: 0.5em; display: block; }
41
+ .typekitsettings textarea { width: 90%; font-family: Courier, Fixed, monospace; }
42
+ .typekitsettings .indent { margin-left: 2em; }
43
+ </style>
44
+ <?php
45
+ if (isset($_POST['submit']) && check_admin_referer('om4-typekit-save-settings') && current_user_can('manage_options')) {
46
+ // settings page has been submitted
47
+
48
+ if (isset($_POST['embedcode'])) {
49
+ $this->typekitInstance->ParseEmbedCode(stripslashes($_POST['embedcode']));
50
+ $id = $this->typekitInstance->GetAccountID();
51
+ if ($id == '') {
52
+ // embed code is empty
53
+ ?>
54
+ <div id="error" class="error"><p>
55
+ <?php
56
+ $instructions = __(' Please <a href="#getembedcode">click here for instructions</a> on how to obtain your Typekit embed code.', 'om4-typekit');
57
+ if (strlen($_POST['embedcode'])) {
58
+ // an embed code has been submitted, but was rejected
59
+ printf(__('Invalid Typekit embed code. %s', 'om4-typekit'), $instructions);
60
+ } else {
61
+ // no embed code was submitted
62
+ printf(__('You must enter your Typekit embed code. %s', 'om4-typekit'), $instructions);
63
+ }
64
+ ?>
65
+ </p></div>
66
+ <?php
67
+ } else {
68
+ // ensure the Typekit account ID maps to a valid JS file on Typekit's servers (ie doesn't return a 404 error)
69
+ $url = sprintf($this->typekitInstance->embedcodeurl, $id);
70
+ $result = wp_remote_head($url);
71
+ if (is_array($result) && $result['response']['code'] == 404) {
72
+ ?>
73
+ <div id="error" class="error"><p>
74
+ <?php printf(__('Your Typekit embed code may be incorrect because <a href="%1$s" target="_blank">%1$s</a> does not exist. Please verify that your Typekit embed code is correct, or try again in a few minutes.', 'om4-typekit'), $url); ?>
75
+ </p></div>
76
+ <?php
77
+ }
78
+ }
79
+ }
80
+ if (isset($_POST['css'])) {
81
+ $this->typekitInstance->SetCSSRules(stripslashes($_POST['css']));
82
+ }
83
+ $this->typekitInstance->SaveSettings();
84
+ ?>
85
+ <div id="message" class="updated fade"><p><?php _e('Settings saved.', 'om4-typekit'); ?></p></div>
86
+ <?php
87
+ }
88
+ ?>
89
+ <form method="post">
90
+ <?php wp_nonce_field('om4-typekit-save-settings'); ?>
91
+ <h2><?php _e('Typekit Fonts for WordPress', 'om4-typekit'); ?></h2>
92
+ <p><?php _e('Typekit offer a service that allows you to select from a range of hundreds of high quality fonts for your WordPress website. The fonts are applied using the font-face standard, so they are standards compliant, fully licensed and accessible.', 'om4-typekit'); ?></p>
93
+ <p><?php _e('To use this plugin you need to sign up with Typekit, and then configure the following options.', 'om4-typekit'); ?></p>
94
+ <h3><?php _e('Register with Typekit', 'om4-typekit'); ?></h3>
95
+ <ol>
96
+ <li><?php _e('Go to <a href="http://typekit.com" target="blank">typekit.com</a> and register for an account', 'om4-typekit'); ?></li>
97
+ <li><?php _e('Choose a few fonts to add to your account and Publish them', 'om4-typekit'); ?></li>
98
+ <li id="getembedcode"><?php _e('Go to the Kit Editor and get your Embed Code (link at the top right of the screen)', 'om4-typekit'); ?></li>
99
+ </ol>
100
+ <h3><?php _e('Plugin Configuration', 'om4-typekit'); ?></h3>
101
+ <ol start="4">
102
+ <li><?php _e('Enter the whole 2 lines of your embed code into the box below:', 'om4-typekit'); ?><br />
103
+ <p class="option"><label for="embedcode"><?php _e('Typekit Embed Code:', 'om4-typekit'); ?></label> <textarea name="embedcode" rows="3" cols="80" /><?php echo $this->typekitInstance->GetEmbedCode(); ?></textarea></p>
104
+
105
+ </li>
106
+ <li><?php _e('Typekit fonts need CSS rules before they will be displayed. You can edit your own CSS style sheets if you know how. Otherwise, you can use the Custom CSS Rules field below to create CSS rules for your site (technical note: these CSS rules will be embedded in the header of each page). Look at the Advanced examples shown in the Typekit editor for ideas.', 'om4-typekit'); ?>
107
+ <p class="option"><label for="css"><?php _e('Custom CSS Rules:', 'om4-typekit'); ?></label> <textarea name="css" rows="10" cols="80" /><?php echo $this->typekitInstance->GetCSSRules(); ?></textarea><br />
108
+ <a href="#help-css"><?php _e('Click here for help on CSS', 'om4-typekit'); ?></a>
109
+ </p>
110
+ </li>
111
+ </ol>
112
+
113
+ <p class="submit"><input name="submit" type="submit" value="<?php _e('Save Settings', 'om4-typekit'); ?>" class="button-primary" /></p>
114
+ </form>
115
+ <h3 id="help"><?php _e('Help', 'om4-typekit'); ?></h3>
116
+ <h4 id="help-fontsnotshowing"><?php _e('Fonts not showing?', 'om4-typekit'); ?></h4>
117
+ <ol>
118
+ <li><?php _e('Have you created your Typekit account, added fonts to it and <strong>pressed Publish</strong>? Fonts aren\'t available until they are published.', 'om4-typekit'); ?></li>
119
+ <li><?php _e('Have you <strong>waited a few minutes</strong> to allow Typekit time to send your fonts out around the world? Grab a cup of coffee and try again soon.', 'om4-typekit'); ?></li>
120
+ <li><?php _e('Have you <strong>added CSS rules</strong> to display your fonts? If in doubt, just try the H2 rule shown in the example and see if that works for you.', 'om4-typekit'); ?></li>
121
+ </ol>
122
+ <h4 id="help-css"><?php _e('CSS', 'om4-typekit'); ?></h4>
123
+ <p><?php _e('Once Typekit is ready, you need to use CSS selectors to apply your new fonts. The Typekit settings for this plugin allows you to add new CSS selectors to your website to activate Typekit fonts.', 'om4-typekit'); ?></p>
124
+ <p><?php _e('There are many options for using CSS, but here are a few common scenarios. Note: we\'ve used proxima-nova for our examples, you\'ll need to change proxima-nova to the name of your chosen font from Typekit - your added font names will be visible in the Kit Editor.', 'om4-typekit'); ?></p>
125
+ <p>
126
+ <?php _e('Headings: if you want your Typekit fonts to be used for H2 headings, add a rule like this to your CSS Rules field:', 'om4-typekit'); ?>
127
+ <code>h2 { font-family: "proxima-nova-1","proxima-nova-2",sans-serif; }</code>
128
+ <?php _e('(and you can add similar rules if you want to target other headings such as H3)', 'om4-typekit'); ?>
129
+ <?php _e('Sidebar Headings: if you want your Typekit fonts to be used for sidebar H2 headings, add a rule like this to your CSS Rules field:', 'om4-typekit'); ?>
130
+ <code>#sidebar h2 { font-family: "proxima-nova-1","proxima-nova-2",sans-serif; }</code>
131
+ </p>
132
+ <h4 id="help-css-advanced"><?php _e('Advanced targetting of fonts with CSS selectors', 'om4-typekit'); ?></h4>
133
+ <p>
134
+ <?php _e('You can target your fonts to specific parts of your website if you know a bit more about your current WordPress theme and where the font family is specified. All WordPress themes have a style.css file, and if you know how to check that you should be able to see the selectors in use. Or you can install Chris Pederick\'s Web Developer Toolbar for Firefox and use the CSS, View CSS option to see all the CSS rules in use for your theme. When you find the selectors that are used for font-family, you can create a rule just for that selector to override that rule.', 'om4-typekit'); ?>
135
+ <?php _e('For example, if your theme has this CSS rule:', 'om4-typekit'); ?>
136
+ <code>body { font-family: Arial, Helvetica, Sans-Serif; }</code>
137
+ <?php _e('you could create this rule to apply your new font to the body of your website:', 'om4-typekit'); ?>
138
+ <code>body { font-family: "proxima-nova-1","proxima-nova-2", sans-serif; }</code>
139
+ </p>
140
+ <h4 id="help-css-external"><?php _e('Where to go to get help', 'om4-typekit'); ?></h4>
141
+ <p class="indent">
142
+ <?php _e('<a href="http://getsatisfaction.com/typekit/" target="_blank">Typekit Support</a>', 'om4-typekit'); ?>
143
+ <br /><?php _e('<a href="http://www.sitepoint.com/forums/forumdisplay.php?f=53" target="_blank">Sitepoint CSS Forums</a>', 'om4-typekit'); ?>
144
+ <br /><?php _e('<a href="http://www.w3schools.com/CSS/default.asp" target="_blank">W3Schools CSS Help</a>', 'om4-typekit'); ?>
145
+ </p>
146
+ </div>
147
+ <?php
148
+ }
149
+ }
150
+ ?>
typekit-fonts-for-wordpress.pot ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # This file is put in the public domain.
3
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
4
+ #
5
+ #, fuzzy
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: PACKAGE VERSION\n"
9
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/typekit-fonts-for-wordpress\n"
10
+ "POT-Creation-Date: 2009-11-18 02:31+0000\n"
11
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+ "Language-Team: LANGUAGE <LL@li.org>\n"
14
+ "MIME-Version: 1.0\n"
15
+ "Content-Type: text/plain; charset=CHARSET\n"
16
+ "Content-Transfer-Encoding: 8bit\n"
17
+
18
+ #: typekit-admin.php:34
19
+ msgid "Typekit Fonts"
20
+ msgstr ""
21
+
22
+ #: typekit-admin.php:62
23
+ msgid ""
24
+ " Please <a href=\"#getembedcode\">click here for instructions</a> on how to "
25
+ "obtain your Typekit embed code."
26
+ msgstr ""
27
+
28
+ #: typekit-admin.php:65
29
+ #, php-format
30
+ msgid "Invalid Typekit embed code. %s"
31
+ msgstr ""
32
+
33
+ #: typekit-admin.php:68
34
+ #, php-format
35
+ msgid "You must enter your Typekit embed code. %s"
36
+ msgstr ""
37
+
38
+ #: typekit-admin.php:80
39
+ #, php-format
40
+ msgid ""
41
+ "Your Typekit embed code may be incorrect because <a href=\"%1$s\" target="
42
+ "\"_blank\">%1$s</a> does not exist. Please verify that your Typekit embed "
43
+ "code is correct, or try again in a few minutes."
44
+ msgstr ""
45
+
46
+ #: typekit-admin.php:91
47
+ msgid "Settings saved."
48
+ msgstr ""
49
+
50
+ #: typekit-admin.php:97
51
+ msgid "Typekit Fonts for WordPress"
52
+ msgstr ""
53
+
54
+ #: typekit-admin.php:98
55
+ msgid ""
56
+ "Typekit offer a service that allows you to select from a range of hundreds "
57
+ "of high quality fonts for your WordPress website. The fonts are applied "
58
+ "using the font-face standard, so they are standards compliant, fully "
59
+ "licensed and accessible."
60
+ msgstr ""
61
+
62
+ #: typekit-admin.php:99
63
+ msgid ""
64
+ "To use this plugin you need to sign up with Typekit, and then configure the "
65
+ "following options."
66
+ msgstr ""
67
+
68
+ #: typekit-admin.php:100
69
+ msgid "Register with Typekit"
70
+ msgstr ""
71
+
72
+ #: typekit-admin.php:102
73
+ msgid ""
74
+ "Go to <a href=\"http://typekit.com\" target=\"blank\">typekit.com</a> and "
75
+ "register for an account"
76
+ msgstr ""
77
+
78
+ #: typekit-admin.php:103
79
+ msgid "Choose a few fonts to add to your account and Publish them"
80
+ msgstr ""
81
+
82
+ #: typekit-admin.php:104
83
+ msgid ""
84
+ "Go to the Kit Editor and get your Embed Code (link at the top right of the "
85
+ "screen)"
86
+ msgstr ""
87
+
88
+ #: typekit-admin.php:106
89
+ msgid "Plugin Configuration"
90
+ msgstr ""
91
+
92
+ #: typekit-admin.php:108
93
+ msgid "Enter the whole 2 lines of your embed code into the box below:"
94
+ msgstr ""
95
+
96
+ #: typekit-admin.php:109
97
+ msgid "Typekit Embed Code:"
98
+ msgstr ""
99
+
100
+ #: typekit-admin.php:112
101
+ msgid ""
102
+ "Typekit fonts need CSS rules before they will be displayed. You can edit "
103
+ "your own CSS style sheets if you know how. Otherwise, you can use the "
104
+ "Custom CSS Rules field below to create CSS rules for your site (technical "
105
+ "note: these CSS rules will be embedded in the header of each page). Look at "
106
+ "the Advanced examples shown in the Typekit editor for ideas."
107
+ msgstr ""
108
+
109
+ #: typekit-admin.php:113
110
+ msgid "Custom CSS Rules:"
111
+ msgstr ""
112
+
113
+ #: typekit-admin.php:114
114
+ msgid "Click here for help on CSS"
115
+ msgstr ""
116
+
117
+ #: typekit-admin.php:119
118
+ msgid "Save Settings"
119
+ msgstr ""
120
+
121
+ #: typekit-admin.php:121
122
+ msgid "Help"
123
+ msgstr ""
124
+
125
+ #: typekit-admin.php:122
126
+ msgid "Fonts not showing?"
127
+ msgstr ""
128
+
129
+ #: typekit-admin.php:124
130
+ msgid ""
131
+ "Have you created your Typekit account, added fonts to it and <strong>pressed "
132
+ "Publish</strong>? Fonts aren't available until they are published."
133
+ msgstr ""
134
+
135
+ #: typekit-admin.php:125
136
+ msgid ""
137
+ "Have you <strong>waited a few minutes</strong> to allow Typekit time to send "
138
+ "your fonts out around the world? Grab a cup of coffee and try again soon."
139
+ msgstr ""
140
+
141
+ #: typekit-admin.php:126
142
+ msgid ""
143
+ "Have you <strong>added CSS rules</strong> to display your fonts? If in "
144
+ "doubt, just try the H2 rule shown in the example and see if that works for "
145
+ "you."
146
+ msgstr ""
147
+
148
+ #: typekit-admin.php:128
149
+ msgid "CSS"
150
+ msgstr ""
151
+
152
+ #: typekit-admin.php:129
153
+ msgid ""
154
+ "Once Typekit is ready, you need to use CSS selectors to apply your new "
155
+ "fonts. The Typekit settings for this plugin allows you to add new CSS "
156
+ "selectors to your website to activate Typekit fonts."
157
+ msgstr ""
158
+
159
+ #: typekit-admin.php:130
160
+ msgid ""
161
+ "There are many options for using CSS, but here are a few common scenarios. "
162
+ "Note: we've used proxima-nova for our examples, you'll need to change "
163
+ "proxima-nova to the name of your chosen font from Typekit - your added font "
164
+ "names will be visible in the Kit Editor."
165
+ msgstr ""
166
+
167
+ #: typekit-admin.php:132
168
+ msgid ""
169
+ "Headings: if you want your Typekit fonts to be used for H2 headings, add a "
170
+ "rule like this to your CSS Rules field:"
171
+ msgstr ""
172
+
173
+ #: typekit-admin.php:134
174
+ msgid ""
175
+ "(and you can add similar rules if you want to target other headings such as "
176
+ "H3)"
177
+ msgstr ""
178
+
179
+ #: typekit-admin.php:135
180
+ msgid ""
181
+ "Sidebar Headings: if you want your Typekit fonts to be used for sidebar H2 "
182
+ "headings, add a rule like this to your CSS Rules field:"
183
+ msgstr ""
184
+
185
+ #: typekit-admin.php:138
186
+ msgid "Advanced targetting of fonts with CSS selectors"
187
+ msgstr ""
188
+
189
+ #: typekit-admin.php:140
190
+ msgid ""
191
+ "You can target your fonts to specific parts of your website if you know a "
192
+ "bit more about your current WordPress theme and where the font family is "
193
+ "specified. All WordPress themes have a style.css file, and if you know how "
194
+ "to check that you should be able to see the selectors in use. Or you can "
195
+ "install Chris Pederick's Web Developer Toolbar for Firefox and use the CSS, "
196
+ "View CSS option to see all the CSS rules in use for your theme. When you "
197
+ "find the selectors that are used for font-family, you can create a rule just "
198
+ "for that selector to override that rule."
199
+ msgstr ""
200
+
201
+ #: typekit-admin.php:141
202
+ msgid "For example, if your theme has this CSS rule:"
203
+ msgstr ""
204
+
205
+ #: typekit-admin.php:143
206
+ msgid ""
207
+ "you could create this rule to apply your new font to the body of your "
208
+ "website:"
209
+ msgstr ""
210
+
211
+ #: typekit-admin.php:146
212
+ msgid "Where to go to get help"
213
+ msgstr ""
214
+
215
+ #: typekit-admin.php:148
216
+ msgid ""
217
+ "<a href=\"http://getsatisfaction.com/typekit/\" target=\"_blank\">Typekit "
218
+ "Support</a>"
219
+ msgstr ""
220
+
221
+ #: typekit-admin.php:149
222
+ msgid ""
223
+ "<a href=\"http://www.sitepoint.com/forums/forumdisplay.php?f=53\" target="
224
+ "\"_blank\">Sitepoint CSS Forums</a>"
225
+ msgstr ""
226
+
227
+ #: typekit-admin.php:150
228
+ msgid ""
229
+ "<a href=\"http://www.w3schools.com/CSS/default.asp\" target=\"_blank"
230
+ "\">W3Schools CSS Help</a>"
231
+ msgstr ""
typekit.php ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Typekit Fonts for WordPress
4
+ Plugin URI: http://om4.com.au/wordpress-plugins/typekit-fonts-for-wordpress-plugin/
5
+ Description: Use a range of hundreds of high quality fonts on your WordPress website by integrating the <a href="http://typekit.com">Typekit</a> font service into your WordPress blog.
6
+ Version: 1.0.0
7
+ Author: OM4
8
+ Author URI: http://om4.com.au/
9
+ Text Domain: om4-typekit
10
+ */
11
+
12
+ /* Copyright 2009 OM4 (email : info@om4.com.au)
13
+
14
+ This program is free software; you can redistribute it and/or modify
15
+ it under the terms of the GNU General Public License as published by
16
+ the Free Software Foundation; either version 2 of the License, or
17
+ (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
+ */
28
+
29
+
30
+ class OM4_Typekit {
31
+
32
+ var $dbVersion = 1;
33
+
34
+ var $installedVersion;
35
+
36
+ var $dirname;
37
+
38
+ var $optionName = 'OM4_Typekit';
39
+
40
+ var $admin;
41
+
42
+ var $embedcode = '<script type="text/javascript" src="http://use.typekit.com/%s.js"></script>
43
+ <script type="text/javascript">try{Typekit.load();}catch(e){}</script>';
44
+
45
+ /**
46
+ * Perl-based regular expression that is used to extract the ID from the typekit embed code
47
+ *
48
+ * The ID can contain numbers and letters only
49
+ *
50
+ * @var string
51
+ */
52
+ var $embedcoderegexp = '#http://use\.typekit\.com/([a-z0-9]*)\.js#i';
53
+
54
+ /**
55
+ * The format for the Typekit JS file URL
56
+ *
57
+ * @var string
58
+ */
59
+ var $embedcodeurl = 'http://use.typekit.com/%s.js';
60
+
61
+ /*
62
+ * Default settings
63
+ */
64
+ var $settings = array(
65
+ 'id'=> '',
66
+ 'css' => ''
67
+ );
68
+
69
+ /**
70
+ * Class Constructor
71
+ *
72
+ */
73
+ function OM4_Typekit() {
74
+
75
+ // Store the name of the directory that this plugin is installed in
76
+ $this->dirname = str_replace('/typekit.php', '', plugin_basename(__FILE__));
77
+
78
+ register_activation_hook(__FILE__, array(&$this, 'Activate'));
79
+
80
+ add_action('init', array(&$this, 'Initialise'));
81
+
82
+ add_action('wp_head', array(&$this, 'HeaderCode'), 99);
83
+
84
+ $data = get_option($this->optionName);
85
+ if (is_array($data)) {
86
+ $this->installedVersion = intval($data['version']);
87
+ $this->settings = $data['settings'];
88
+ }
89
+ }
90
+
91
+ /**
92
+ * Intialise I18n
93
+ *
94
+ */
95
+ function LoadDomain() {
96
+ load_plugin_textdomain('om4-typekit', WP_PLUGIN_DIR.'/'.dirname(plugin_basename(__FILE__)));
97
+ }
98
+
99
+ /**
100
+ * Plugin Activation Tasks
101
+ *
102
+ */
103
+ function Activate() {
104
+ // There aren't really any installation tasks at the moment
105
+ if (!$this->installedVersion) {
106
+ $this->installedVersion = $this->dbVersion;
107
+ $this->SaveSettings();
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Performs any upgrade tasks if required
113
+ *
114
+ */
115
+ function CheckVersion() {
116
+ if ($this->installedVersion != $this->dbVersion) {
117
+ // Upgrade tasks
118
+ if ($this->installedVersion == 0) {
119
+ $this->installedVersion++;
120
+ }
121
+ $this->SaveSettings();
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Initialise the plugin.
127
+ * Set up the admin interface if necessary
128
+ */
129
+ function Initialise() {
130
+
131
+ $this->LoadDomain();
132
+
133
+ $this->CheckVersion();
134
+
135
+ if (is_admin()) {
136
+ // WP Dashboard
137
+ require_once('typekit-admin.php');
138
+ $this->admin = new OM4_Typekit_Admin( $this );
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Saves the plugin's settings to the database
144
+ */
145
+ function SaveSettings() {
146
+ $data = array_merge(array('version' => $this->installedVersion), array('settings' => $this->settings));
147
+ update_option($this->optionName, $data);
148
+ }
149
+
150
+ /*
151
+ * Retrieve the Typekit embed code if the unique account id has been set
152
+ * @return string The typekit embed code if the unique account ID has been set, otherwise an empty string
153
+ */
154
+ function GetEmbedCode() {
155
+ if ('' != $id = $this->GetAccountID()) return sprintf($this->embedcode, $id);
156
+ return '';
157
+ }
158
+
159
+ /**
160
+ * Get the stored Typekit Account ID
161
+ * @return string The account ID if it has been specified, otherwise an empty string
162
+ */
163
+ function GetAccountID() {
164
+ if (strlen($this->settings['id'])) return $this->settings['id'];
165
+ return '';
166
+ }
167
+
168
+ /**
169
+ * Extract the unique account id from the JavaScript embed code
170
+ * @param string JavaScript embed code
171
+ */
172
+ function ParseEmbedCode($code) {
173
+ $matches = array();
174
+
175
+ $this->settings['id'] = '';
176
+ // Attempt to extract the ID from the embed code using our regular expression
177
+ if (preg_match($this->embedcoderegexp, $code, $matches) && sizeof($matches) == 2) {
178
+ $this->settings['id'] = $matches[1];
179
+ }
180
+ }
181
+
182
+ /*
183
+ * Retrieve the custom CSS rules
184
+ * @return string The custom CSS rules
185
+ */
186
+ function GetCSSRules() {
187
+ return $this->settings['css'];
188
+ }
189
+
190
+ /**
191
+ * Parse and save the custom css rules.
192
+ * The input is santized by stripping all HTML tags
193
+ * @param string CSS code
194
+ */
195
+ function SetCSSRules($code) {
196
+ $this->settings['css'] = '';
197
+ $code = strip_tags($code);
198
+ if (strlen($code)) $this->settings['css'] = $code;
199
+ }
200
+
201
+ /**
202
+ * Display the plugin's javascript and css code in the site's header
203
+ */
204
+ function HeaderCode() {
205
+ ?>
206
+
207
+ <!-- BEGIN Typekit Fonts for WordPress -->
208
+ <?php
209
+ echo $this->GetEmbedCode();
210
+
211
+ if (strlen($this->settings['css'])) {
212
+ ?>
213
+
214
+ <style type="text/css">
215
+ <?php echo $this->settings['css']; ?>
216
+
217
+ </style>
218
+ <?php
219
+ }
220
+ ?>
221
+ <!-- END Typekit Fonts for WordPress -->
222
+
223
+ <?php
224
+ }
225
+
226
+ }
227
+
228
+ if(defined('ABSPATH') && defined('WPINC')) {
229
+ if (!isset($GLOBALS["OM4_Typekit"])) {
230
+ $GLOBALS["OM4_Typekit"] = new OM4_Typekit();
231
+ }
232
+ }
233
+
234
+ ?>