Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( ! empty( $_GET['fancybox-ie-css'] ) ) {
- include dirname( __FILE__ ) . '/ie.php';
- exit;
- }
- /**
- * Auto-init fancybox for image links.
- */
- function wpx_fancybox()
- {
- $config = empty( $GLOBALS['wpx_fancybox'] ) ? array() : wp_parse_args( $GLOBALS['wpx_fancybox'] );
- $config = apply_filters( 'wpx_fancybox', $config );
- $config = empty( $config ) ? '' : json_encode( $config );
- echo <<<HTML
- <script type="text/javascript">jQuery.wpxFancybox($config);</script>
- HTML;
- }
- /**
- * Enqueue Fancybox. Call anywhere before {@see wp_print_styles()}.
- */
- function wpx_fancybox_enqueue()
- {
- add_action( 'wp_footer', 'wpx_fancybox' );
- $url = plugins_url( '', __FILE__ );
- $dev = WP_DEBUG ? '.dev' : '';
- wp_enqueue_script( 'wpx-fancybox', "$url/js/jquery.fancybox$dev.js", array( 'jquery' ), '1.3.4.1' );
- wp_enqueue_style( 'wpx-fancybox', "$url/css/fancybox$dev.css", array(), '1.3.4', 'screen' );
- wp_enqueue_style( 'wpx-fancybox-ie', home_url( '?fancybox-ie-css=1.3.4.css' ), array(), null, 'screen' );
- if ( ! empty( $GLOBALS['wp_styles'] ) )
- $GLOBALS['wp_styles']->add_data( 'wpx-fancybox-ie', 'conditional', 'IE' );
- }
- add_action( 'wp_head', 'wpx_fancybox_enqueue', 1 );
- add_action( 'wpx_fancybox_enqueue', 'wpx_fancybox_enqueue' );
- /**
- * Dequeue Fancybox. Call anywhere before {@see wp_print_styles()}.
- */
- function wpx_fancybox_dequeue()
- {
- remove_action( 'wp_head', 'wpx_fancybox_enqueue', 1 );
- remove_action( 'wp_footer', 'wpx_fancybox' );
- if ( did_action( 'wp_enqueue_scripts' ) ) {
- wp_dequeue_script( 'wpx-fancybox' );
- wp_dequeue_style( 'wpx-fancybox' );
- wp_dequeue_style( 'wpx-fancybox-ie' );
- }
- }
- add_action( 'wpx_fancybox_dequeue', 'wpx_fancybox_dequeue' );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement