Example #1
0
function weaver_save_current_css()
{
    // write the current generated CSS to a file - called only from Weaver Admin
    if (!weaver_f_file_access_available()) {
        weaver_f_file_access_fail('Limited file access. Probably running with reduced functionality.');
        return '';
    }
    $save_dir = weaver_f_uploads_base_dir() . 'weaver-subthemes';
    $save_url = weaver_f_uploads_base_url() . 'weaver-subthemes';
    $usename = 'style-weaver.css';
    $ttw_theme_dir_exists = weaver_f_mkdir($save_dir);
    if (!$ttw_theme_dir_exists) {
        weaver_f_file_access_fail('Unable to create directory. Probably a file system permission problem. Directory' . $save_dir);
    }
    $ttw_theme_dir_writable = $ttw_theme_dir_exists;
    if (!weaver_f_is_writable($save_dir)) {
        weaver_f_file_access_fail('Directory not writable. Probably a file system permission problem. Directory: ' . $save_dir);
        $ttw_theme_dir_writable = false;
    }
    $filename = $save_dir . '/' . $usename;
    // we will add txt
    if (!$ttw_theme_dir_writable || !$ttw_theme_dir_exists || !($handle = weaver_f_open($filename, 'w'))) {
        weaver_f_file_access_fail('Unable to create file. Probably a file system permission problem. File: ' . $filename);
        return '';
    }
    weaver_f_write($handle, sprintf("/* WARNING: Do not edit this file. It is dynamically generated. Any edits you make will be overwritten. */\n/* This file generated using %s %s subtheme: %s */\n", WEAVER_THEMENAME, WEAVER_VERSION, weaver_getopt('ttw_subtheme')));
    weaver_output_style($handle);
    if (!weaver_f_close($handle)) {
        weaver_f_file_access_fail('Unable to create file. Probably a file system permission problem. File: ' . $filename);
        return '';
    }
    require_once 'wvr-editorcss.php';
    weaver_save_editor_css($save_dir);
    return $save_url . '/' . $usename;
}
Example #2
0
function weaver_save_editor_css($mce_css_dir)
{
    // create a new editor-style.css file (sorry, no rtl) in the upload directory so will be multi-site compatible
    $base_style = get_template_directory() . '/editor-style.css';
    /* the default editor css file */
    if (!weaver_f_file_access_available() || !weaver_f_is_writable($mce_css_dir)) {
        return false;
        // just bail and let the default editor-style.css be used
    }
    /* delete current weaver-editor-style.css
          Copy default editor style to editor-style.css
          Add Weaver overrides to that file
          Close
       */
    if (!weaver_f_exists($base_style)) {
        return false;
    }
    $contents = weaver_f_get_contents($base_style);
    // get the core part
    $filename = trailingslashit($mce_css_dir) . 'weaver-editor-style.css';
    if (!($handle = weaver_f_open($filename, 'w'))) {
        // can't write - blow it off
        return false;
    }
    weaver_f_write($handle, $contents);
    // save new editor style css file
    weaver_f_write($handle, sprintf("\n/* Subtheme %s specific editor styling */\n", weaver_getopt('ttw_subtheme')));
    weaver_output_editor_style($handle);
    weaver_f_write($handle, sprintf("/* WEAVER WARNING: Do not edit this file. It is dynamically generated. Any edits you make will be overwritten. */\n/* This file generated using %s %s subtheme: %s */\n", WEAVER_THEMENAME, WEAVER_VERSION, weaver_getopt('ttw_subtheme')));
    weaver_f_close($handle);
    return;
}
Example #3
0
 function weaver_generate_wphead()
 {
     /* this guy does ALL the work for generating theme look - it writes out the over-rides to the standard style.css */
     global $weaver_main_options, $weaver_cur_page_ID;
     // if ( have_posts() )
     //   the_post();
     $weaver_cur_page_ID = get_the_ID();
     // we're on a page now, so set the post id for the rest of the session
     // rewind_posts();
     printf("\n<!-- This site is using %s %s subtheme: %s -->\n", WEAVER_THEMENAME, WEAVER_VERSION, weaver_getopt('ttw_subtheme'));
     if (!weaver_getopt('ttw_hide_metainfo')) {
         echo weaver_getopt('ttw_metainfo') . "\n";
     }
     // handle 3 stylesheet situations
     //	default: used weaver-style.css
     //	no weaver-style.css: when first installed, there will not be a weaver-style.css, so use inline instead
     //	force inline: user wants inline css
     if (weaver_use_inline_css(weaver_get_css_filename())) {
         // generate inline CSS
         if (!weaver_getopt('ttw_subtheme')) {
             // It would be nice to use wp_enqueue_style, but it is too late at this point, so we
             // will generate the code manually - this is a one-shot special case that happens ONLY
             // when the theme preview option is being used from the themes admin page
             echo '<link rel="stylesheet" type="text/css" media="all" href="' . get_stylesheet_directory_uri() . '/subthemes/style-weaver-preview.css" />' . "\n";
         } else {
             require_once 'wvr-generatecss.php';
             // include only now at runtime.
             echo '<style type="text/css">' . "\n";
             $output = weaver_f_open('php://output', 'w+');
             weaver_output_style($output);
             echo "</style> <!-- end of main options style section -->\n";
         }
     } else {
         // file should have been added from header.php
     }
     /* now head options */
     echo weaver_getopt('ttw_theme_head_opts');
     echo weaver_getopt('ttw_head_opts');
     /* let the user have the last word! */
     $per_page_code = weaver_get_per_page_value('page-head-code');
     if (!empty($per_page_code)) {
         echo $per_page_code;
     }
     weaver_fix_IE();
     do_action('wvrx_extended_wp_head');
     /* call extended wp_head stuff */
     do_action('wvrx_plus_wp_head');
     // future header plugin
     echo "\n<!-- End of Weaver options -->\n";
 }
function weaver_write_backup($savefile, $is_theme = true)
{
    /*	write the current settings to a file, return true or false
    	$savefile is a base-name - no directory, no extension
        */
    global $weaver_opts_cache, $weaver_main_opts_list, $weaver_advanced_opts_list;
    $nosave = array('ftp_hostname' => true, 'ftp_username' => true, 'ftp_password' => true);
    // don't write these
    if (!weaver_f_file_access_available()) {
        weaver_f_file_access_fail('Limited file access. Probably running with reduced functionality.');
        return '';
    }
    weaver_save_opts('weaver_write_backup', true);
    // let's save it in case the user forgot (saves everything)
    $wpdir = wp_upload_dir();
    // get the upload directory
    $save_dir = weaver_f_uploads_base_dir() . 'weaver-subthemes';
    $save_url = weaver_f_uploads_base_url() . 'weaver-subthemes';
    if ($is_theme) {
        $ext = '.wvr';
    } else {
        $ext = '.wvb';
    }
    $usename = strtolower(sanitize_file_name($savefile));
    $usename = str_replace($ext, '', $usename);
    if (strlen($usename) < 1) {
        return '';
    }
    $usename = $usename . $ext;
    $ttw_theme_dir_exists = weaver_f_mkdir($save_dir);
    $ttw_theme_dir_writable = $ttw_theme_dir_exists;
    if (!weaver_f_is_writable($save_dir)) {
        $ttw_theme_dir_writable = false;
    }
    $filename = trailingslashit($save_dir) . $usename;
    if (!$ttw_theme_dir_writable || !$ttw_theme_dir_exists || !($handle = weaver_f_open($filename, 'w'))) {
        weaver_f_file_access_fail('Unable to create file. Probably a file system permission problem. File: ' . $filename);
        return '';
    }
    /* file open, ready to write - so let's write something - either a backup or a theme */
    if (!$is_theme) {
        weaver_f_write($handle, "WVB-V02.00");
        /* Save theme settings: 10 byte header */
        $theme_opts = array();
        foreach ($weaver_opts_cache as $key => $value) {
            if ($value != '' && !isset($nosave[$key])) {
                $theme_opts[$key] = $value;
            }
        }
        $tosave = serialize($theme_opts);
        /* serialize full set of options right now */
    } else {
        /* save only theme settings */
        weaver_f_write($handle, "TTW-V01.10");
        /* Save theme settings: 10 byte header */
        global $weaver_dev;
        if ($weaver_dev) {
            $theme_name = weaver_getopt('ttw_themename');
            weaver_setopt('ttw_subtheme', $theme_name);
        }
        $theme_opts = array();
        /* now can set the new values from $restore */
        foreach ($weaver_opts_cache as $key => $value) {
            if ($value != '' && !isset($nosave[$key])) {
                if (isset($weaver_main_opts_list[$key]) && !$weaver_main_opts_list[$key]) {
                    $theme_opts[$key] = $value;
                } else {
                    if (isset($weaver_advanced_opts_list[$key]) && !$weaver_advanced_opts_list[$key]) {
                        $theme_opts[$key] = $value;
                    }
                }
            }
        }
        $tosave = serialize($theme_opts);
    }
    weaver_f_write($handle, $tosave);
    // write all Weaver settings to user save file
    weaver_f_close($handle);
    return trailingslashit($save_url) . $usename;
}
Example #5
0
    if (!weaver_use_inline_css(weaver_get_css_filename())) {
        // use file
        $vers = weaver_getopt('ttw_style_version');
        if (!$vers) {
            $vers = '0';
        } else {
            $vers = sprintf("%d", $vers);
        }
        wp_register_style('weaver-style-sheet', weaver_get_css_url(), array(), $vres);
        wp_enqueue_style('weaver-style-sheet');
    } else {
        // generate inline CSS
        require_once 'wvr-includes/wvr-generatecss.php';
        // include only now at runtime.
        echo '<style type="text/css">' . "\n";
        $output = weaver_f_open('php://output', 'w+');
        weaver_output_style($output);
        echo "</style> <!-- end of main options style section -->\n";
    }
} else {
    ?>
<style type="text/css">
body, p, #wrapper, #main {
	background: transparent;
	border: 0;
	margin: 0;
	padding: 0;
	vertical-align: baseline;
}
</style>
<?php