Linux 软件免费装

Delay Print CSS

开发者 peterwilsoncc
更新时间 2010年8月26日 22:05
PHP版本: 2.8 及以上
WordPress版本: 3.0.1

标签

css style themes stylesheets

下载

0.1

详情介绍:

Many browsers will not render your webpage until the print.css is loaded. Delay Print CSS prevents this from happening. Once your page has fully rendered (including JavaScript, images, etc) your print stylesheets will be loaded. Using the methods described in a recent blog post this plugin uses JavaScript, with a non JavaScript fallback, to load your stylesheets last. If your WordPress site uses jQuery then it is used to load the stylesheets, otherwise the plugin outputs its own JavaScript.

安装:

Upload delay-print-css to the /wp-content/plugins/ directory of your install. Activate the plugin through the 'Plugins' menu in WordPress In your theme or plugin, use wp_register_style and/or wp_enqueue_style to load your CSS. This requires you to remove any html tags you have in your theme and add the following code to your functions.php file: function mytheme_enqueue_css(){ if (!is_admin()){ wp_enqueue_style ( 'mytheme-print', /* handle */ '/path-to/print.css', /* source */ null, /* no requirements */ '1.0', /* version */ 'print' /* media type */ ); } } add_action('wp_print_styles', 'mytheme_enqueue_css'); To wrap your stylesheet in conditional tags, add the following below the wp_enqueue_style call in your new function global $wp_styles; $wp_styles->registered['mytheme-print']->extra['conditional'] = 'IE 6'

常见问题:

I use jQuery but the plugin outputting its own JavaScript

You may not be loading your JavaScript the WordPress way. If wp_enqueue_script means nothing to you, then have a read of a tutorial I wrote on the subject

My stylesheets aren't been loaded any differently

Make sure you are using wp_enqueue_style to load your CSS, an explanation is in the Installation section of this readme file.

Can I use IE conditional comments

Yes. If you set your stylesheet to be for a particular version of IE, this plugin will respect that.

Is this plugin safe to use on a production site?

This plugin was written as a proof of concept, has a sub 1.0 version number and has been tested for a few common situations only. I don't use it on a production website but let me know of your experiences if you choose to.