Ejemplo n.º 1
0
function safecss_style()
{
    global $blog_id, $current_blog;
    if (safecss_is_freetrial() && (!safecss_is_preview() || !current_user_can('switch_themes'))) {
        return;
    }
    $option = safecss_is_preview() ? 'safecss_preview' : 'safecss';
    // Prevent debug notices
    $css = '';
    // Check if extra CSS exists
    if ('safecss' == $option) {
        if (get_option('safecss_revision_migrated')) {
            if ($safecss_post = get_safecss_post()) {
                $css = $safecss_post['post_content'];
            } else {
                if ($current_revision = get_current_revision()) {
                    $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 = get_current_revision();
        $css = $safecss_post['post_content'];
    }
    $css = str_replace(array('\\\\00BB \\\\0020', '\\0BB \\020', '0BB 020'), '\\00BB \\0020', $css);
    if ($css == '') {
        return;
    }
    $href = get_option('siteurl');
    $href = add_query_arg('custom-css', 1, $href);
    $href = add_query_arg('csblog', $blog_id, $href);
    $href = add_query_arg('cscache', 5, $href);
    $href = add_query_arg('csrev', (int) get_option($option . '_rev'), $href);
    if (safecss_is_preview()) {
        $href = add_query_arg('csspreview', 'true', $href);
    }
    ?>

	<link rel="stylesheet" type="text/css" href="<?php 
    echo esc_url($href);
    ?>
" />
<?php 
}
Ejemplo n.º 2
0
/**
 * When restoring a SafeCSS post revision, also copy over the
 * content_width and custom_css_add post metadata.
 */
function custom_css_restore_revision($_post_id, $_revision_id)
{
    $_post = get_post($_post_id);
    if ('safecss' != $_post->post_type) {
        return;
    }
    $safecss_revision = get_current_revision();
    $content_width = get_post_meta($_revision_id, 'content_width', true);
    $custom_css_add = get_post_meta($_revision_id, 'custom_css_add', true);
    update_metadata('post', $safecss_revision['ID'], 'content_width', $content_width);
    update_metadata('post', $safecss_revision['ID'], 'custom_css_add', $custom_css_add);
    update_post_meta($_post->ID, 'content_width', $content_width);
    update_post_meta($_post->ID, 'custom_css_add', $custom_css_add);
}