Esempio n. 1
0
    static function link_tag()
    {
        global $blog_id, $current_blog;
        if (apply_filters('safecss_style_error', false)) {
            return;
        }
        if (!is_super_admin() && isset($current_blog) && (1 == $current_blog->spam || 1 == $current_blog->deleted)) {
            return;
        }
        if (Jetpack_Custom_CSS::is_customizer_preview()) {
            return;
        }
        $css = '';
        $option = Jetpack_Custom_CSS::is_preview() ? 'safecss_preview' : 'safecss';
        if ('safecss' == $option) {
            if (get_option('safecss_revision_migrated')) {
                $safecss_post = Jetpack_Custom_CSS::get_post();
                if (!empty($safecss_post['post_content'])) {
                    $css = $safecss_post['post_content'];
                }
            } else {
                $current_revision = Jetpack_Custom_CSS::get_current_revision();
                if (!empty($current_revision['post_content'])) {
                    $css = $current_revision['post_content'];
                }
            }
            // Fix for un-migrated Custom CSS
            if (empty($safecss_post)) {
                $_css = get_option('safecss');
                if (!empty($_css)) {
                    $css = $_css;
                }
            }
        }
        if ('safecss_preview' == $option) {
            $safecss_post = Jetpack_Custom_CSS::get_current_revision();
            if (!empty($safecss_post['post_content'])) {
                $css = $safecss_post['post_content'];
            }
        }
        $css = str_replace(array('\\\\00BB \\\\0020', '\\0BB \\020', '0BB 020'), '\\00BB \\0020', $css);
        if ($css == '') {
            return;
        }
        if (apply_filters('safecss_embed_style', false, $css)) {
            echo "\r\n" . '<style id="custom-css-css">' . Jetpack_Custom_CSS::get_css(true) . "</style>\r\n";
        } else {
            $href = home_url('/');
            $href = add_query_arg('custom-css', 1, $href);
            $href = add_query_arg('csblog', $blog_id, $href);
            $href = add_query_arg('cscache', 6, $href);
            $href = add_query_arg('csrev', (int) get_option($option . '_rev'), $href);
            /**
             * Filter the Custom CSS link enqueued in the head.
             *
             * @module custom-css
             *
             * @since 1.7.0
             *
             * @param string $href Custom CSS link enqueued in the head.
             * @param string $blog_id Blog ID.
             */
            $href = apply_filters('safecss_href', $href, $blog_id);
            if (Jetpack_Custom_CSS::is_preview()) {
                $href = add_query_arg('csspreview', 'true', $href);
            }
            ?>
			<link rel="stylesheet" id="custom-css-css" type="text/css" href="<?php 
            echo esc_url($href);
            ?>
" />
			<?php 
        }
        /**
         * Fires after creating the <link> in the <head> element for the custom css stylesheet.
         *
         * @module custom-css
         *
         * @since 2.2.2
         */
        do_action('safecss_link_tag_post');
    }
Esempio n. 2
0
    static function link_tag()
    {
        global $blog_id, $current_blog;
        if (apply_filters('safecss_style_error', false)) {
            return;
        }
        if (!is_super_admin() && isset($current_blog) && (1 == $current_blog->spam || 1 == $current_blog->deleted)) {
            return;
        }
        if (Jetpack_Custom_CSS::is_customizer_preview()) {
            return;
        }
        $css = '';
        $option = Jetpack_Custom_CSS::is_preview() ? 'safecss_preview' : 'safecss';
        if ('safecss' == $option) {
            if (get_option('safecss_revision_migrated')) {
                $safecss_post = Jetpack_Custom_CSS::get_post();
                if (!empty($safecss_post['post_content'])) {
                    $css = $safecss_post['post_content'];
                }
            } else {
                $current_revision = Jetpack_Custom_CSS::get_current_revision();
                if (!empty($current_revision['post_content'])) {
                    $css = $current_revision['post_content'];
                }
            }
            // Fix for un-migrated Custom CSS
            if (empty($safecss_post)) {
                $_css = get_option('safecss');
                if (!empty($_css)) {
                    $css = $_css;
                }
            }
        }
        if ('safecss_preview' == $option) {
            $safecss_post = Jetpack_Custom_CSS::get_current_revision();
            if (!empty($safecss_post['post_content'])) {
                $css = $safecss_post['post_content'];
            }
        }
        $css = str_replace(array('\\\\00BB \\\\0020', '\\0BB \\020', '0BB 020'), '\\00BB \\0020', $css);
        if ($css == '') {
            return;
        }
        $href = trailingslashit(site_url());
        $href = add_query_arg('custom-css', 1, $href);
        $href = add_query_arg('csblog', $blog_id, $href);
        $href = add_query_arg('cscache', 6, $href);
        $href = add_query_arg('csrev', (int) get_option($option . '_rev'), $href);
        $href = apply_filters('safecss_href', $href, $blog_id);
        if (Jetpack_Custom_CSS::is_preview()) {
            $href = add_query_arg('csspreview', 'true', $href);
        }
        ?>
		<link rel="stylesheet" id="custom-css-css" type="text/css" href="<?php 
        echo esc_url($href);
        ?>
" />
		<?php 
        do_action('safecss_link_tag_post');
    }