{"id":670,"date":"2011-07-22T10:59:39","date_gmt":"2011-07-22T10:59:39","guid":{"rendered":"https://www.divydovy.com/?p=670"},"modified":"2020-01-23T10:30:12","modified_gmt":"2020-01-23T10:30:12","slug":"cufon-for-thematic-with-no-plugins-improved","status":"publish","type":"post","link":"https://www.divydovy.com/2011/07/cufon-for-thematic-with-no-plugins-improved/","title":{"rendered":"Cufón for Thematic with no plugins &#8211; improved"},"content":{"rendered":"<p>Since I wrote the original &#8216;<a title=\"Cufon for Thematic with no plugins\" href=\"https://www.divydovy.com/2010/06/cufon-for-thematic-with-no-plugins/\">Cufon for Thematic with no plugins</a>&#8216; post, I&#8217;ve learnt how to use script queueing, rather than hard-coded links. Here&#8217;s the official WP page about script queueing: <a title=\"Script Enqueueing\" href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_script\" target=\"_blank\" rel=\"noopener noreferrer\">http://codex.wordpress.org/Function_Reference/wp_enqueue_script</a> if you want to find out more.</p>\n<p>Here&#8217;s the improved version of that post, also featuring a little function to convert the doctype into XHTML Strict, which Cufon needs in order to observe CSS line-height declarations:</p>\n<p><code>// Enqueue Cufon and Font JS files<br />\nif ( !is_admin() ) { // instruction to only load if it is not the admin area<br />\n\t// register scripts<br />\n\twp_register_script('cufon-yui',<br />\n\t\tget_bloginfo('stylesheet_directory') . '/js/cufon-yui.js',<br />\n\t\tarray('jquery'),<br />\n\t\tfalse,<br />\n\t\tfalse<br />\n\t);<br />\n\twp_register_script('font-yourfont',<br />\n\t\tget_bloginfo('stylesheet_directory') . '/js/YourFont.font.js',<br />\n\t\tarray('jquery', 'cufon-yui'),<br />\n\t\tfalse,<br />\n\t\tfalse<br />\n\t);<br />\n\t// enqueue scripts<br />\n\twp_enqueue_script('cufon-yui');<br />\n\twp_enqueue_script('font-yourfont');<br />\n}</p>\n<p>// Cufon needs strict doctype for line-height<br />\nfunction childtheme_create_doctype($content) {<br />\n\t$content = '&lt;!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"&gt;';<br />\n\t$content .= \"\\n\";<br />\n\t$content .= '&lt;html xmlns=\"http://www.w3.org/1999/xhtml\"';<br />\n\treturn $content;<br />\n}<br />\nadd_filter('thematic_create_doctype', 'childtheme_create_doctype');</p>\n<p>// Add extra scripts to head<br />\nfunction childtheme_head() { ?&gt;<br />\n\t&lt;!-- Cufon --&gt;<br />\n\t&lt;script type=\"text/javascript\"&gt;<br />\n\t\tCufon.replace('h1, h2', { fontFamily: 'YourFont' });<br />\n\t&lt;/script&gt;<br />\n&lt;?php }<br />\nadd_action('wp_head', 'childtheme_head');</p>\n<p>// Load Child Theme js file, Google Analytics<br />\nfunction load_childtheme_js() {?&gt;<br />\n    &lt;script type=\"text/javascript\"&gt; Cufon.now(); &lt;/script&gt;<br />\n&lt;?php }<br />\nadd_action('thematic_after','load_childtheme_js');</code><br />\nAny comments or corrections, please shout in the comments!</p>\n","protected":false},"excerpt":{"rendered":"<p>Since I wrote the original &#8216;Cufon for Thematic with no plugins&#8216; post, I&#8217;ve learnt how to use script queueing, rather than hard-coded links. Here&#8217;s the official WP page about script queueing: http://codex.wordpress.org/Function_Reference/wp_enqueue_script if you want to find out more. Here&#8217;s the improved version of that post, also featuring a little function to convert the doctype into XHTML Strict, which Cufon needs in order to observe CSS line-height declarations: // Enqueue Cufon and Font JS files if ( !is_admin() ) { // instruction to only load if it is not the admin area // register scripts wp_register_script(&#8216;cufon-yui&#8217;, get_bloginfo(&#8216;stylesheet_directory&#8217;) . &#8216;/js/cufon-yui.js&#8217;, array(&#8216;jquery&#8217;), [&hellip;]</p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","clkt_auto_upload":"0","_clkt_publish_and_upload":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wordproof_timestamp":false},"categories":[7],"tags":[142,225,166,165,140,125],"my_content_publications":[],"class_list":["post-670","type-post","status-publish","format-standard","hentry","category-web","tag-cufon","tag-font-replacement","tag-fonts","tag-functions","tag-thematic","tag-wordpress"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"clkt_attachments":{"featured_image":null,"inline_attachments":[],"upload_candidates":[],"max_free_size":102400,"max_allowed_size":104857600},"_clkt_upload_mode":"new_only","clkt_content_hash":"8627f956de7c7e5ae6965d86b03e7e748b6d5780d832fa496abf904aa639421e","customFields":{"clkt_auto_upload":"0","activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"processed_attachments":{"total_attachments":0,"uploaded_to_arweave":0,"kept_original_urls":0,"upload_summary":{"total":0,"uploaded":0,"failed":0,"too_large":0,"reused":0}}},"paymentAddress":"8_-tV4d15kVVq9Gd-Al2MAIC3LqNtJ_KgFol71TzxPw"}