Exemplo n.º 1
0
function weaverii_save_current_css()
{
    // write the current generated CSS to a file - called only from Weaver II Admin
    if (!weaverii_f_file_access_available() || !current_user_can('edit_theme_options')) {
        return '';
    }
    $save_dir = weaverii_f_uploads_base_dir() . 'weaverii-subthemes';
    $save_url = weaverii_f_uploads_base_url() . 'weaverii-subthemes';
    $usename = 'style-weaverii.css';
    $wii_theme_dir_exists = weaverii_f_mkdir($save_dir);
    if (!$wii_theme_dir_exists) {
        weaverii_f_file_access_fail('Unable to create directory. Probably a file system permission problem. Directory' . $save_dir);
    }
    $wii_theme_dir_writable = $wii_theme_dir_exists;
    if (!weaverii_f_is_writable($save_dir)) {
        weaverii_f_file_access_fail('Directory not writable. Probably a file system permission problem. Directory: ' . $save_dir);
        $wii_theme_dir_writable = false;
    }
    $filename = $save_dir . '/' . $usename;
    // we will add txt
    if (!$wii_theme_dir_writable || !$wii_theme_dir_exists || !($handle = weaverii_f_open($filename, 'w'))) {
        weaverii_f_file_access_fail('Unable to create file. Probably a file system permission problem. File: ' . $filename);
        return '';
    }
    weaverii_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", WEAVERII_THEMENAME, WEAVERII_VERSION, weaverii_getopt('wii_subtheme')));
    weaverii_output_style($handle);
    if (!weaverii_f_close($handle)) {
        weaverii_f_file_access_fail('Unable to create file. Probably a file system permission problem. File: ' . $filename);
        return '';
    }
    return $save_url . '/' . $usename;
}
function weaverii_child_show_extrathemes_action()
{
    echo '<h3 class="wvr-option-subheader">Select an Add-on Subtheme You Have Uploaded</h3>';
    $addon_dir = weaverii_f_uploads_base_dir() . 'weaverii-subthemes/addon-subthemes/';
    $addon_url = weaverii_f_uploads_base_url() . 'weaverii-subthemes/addon-subthemes/';
    $addon_list = array();
    if ($media_dir = @opendir($addon_dir)) {
        // build the list of themes from directory
        while ($m_file = readdir($media_dir)) {
            $len = strlen($m_file);
            $base = substr($m_file, 0, $len - 4);
            $ext = $len > 4 ? substr($m_file, $len - 4, 4) : '';
            if ($ext == '.w2t') {
                $addon_list[] = $base;
            }
        }
    }
    if (!empty($addon_list)) {
        natcasesort($addon_list);
        $cur_addon = weaverii_getopt('wii_addon_name');
        if ($cur_addon) {
            echo '<h3>Currently selected Add-on Subtheme: ' . ucwords(str_replace('-', ' ', $cur_addon)) . '</h3>';
        }
        ?>
    <form enctype="multipart/form-data" name='pick_added_theme' method='post'>

     <h4>Select an add-on subtheme: </h4>

<?php 
        foreach ($addon_list as $addon) {
            $name = ucwords(str_replace('-', ' ', $addon));
            ?>
        <div style="float:left; width:200px;">
            <label><input type="radio" name="wii_addon_name"
<?php 
            echo 'value="' . $addon . '"' . (weaverii_getopt('wii_addon_name') == $addon ? 'checked' : '') . '/> <strong>' . $name . '</strong><br />
            <img style="border: 1px solid gray; margin: 5px 0px 10px 0px;" src="' . $addon_url . $addon . '.jpg" width="150px" height="113px" /><label></div>' . "\n";
        }
        ?>
        <div style="clear:both;"></div>
        <br /><span class='submit'><input name="set_added_subtheme" type="submit" value="Set to Selected Add-on Subtheme" /></span>&nbsp;
        <span style="color:#b00;"><strong>Note:</strong> Selecting a new subtheme will change only theme related settings. Most Advanced Options will be retained.
        You can use the Save/Restore tab to save a copy of all your current settings first.</span>

<?php 
        weaverii_nonce_field('set_added_subtheme');
        ?>

        <br /><br /><span class='wvr-small-submit' style="margin-left:100px;"><input name="delete_added_subtheme" type="submit" value="Delete Selected Add-on Subtheme" /></span> &nbsp;<small>This will delete the selected Add-on Subtheme from the Add-on directory</small>
<?php 
        weaverii_nonce_field('delete_added_subtheme');
        ?>
        </form>
<?php 
    } else {
        ?>
	<p>You have not uploaded any Add-on Subthemes yet.</p>
<?php 
    }
    echo '<h3 class="wvr-option-subheader">Upload an Add-on Subtheme From Your Computer</h3>';
    ?>
<form name='form_added_theme' enctype="multipart/form-data" action="<?php 
    echo $_SERVER["REQUEST_URI"];
    ?>
" method="POST">
    <table>
	<tr valign="top">
	    <td><strong>Select Add-on Subtheme .zip file to upload:</strong>
		<input name="uploaded_addon" type="file" />
		<input type="hidden" name="uploadaddon" value="yes" />
            </td>
	</tr>
        <tr><td>
	    <span style="margin-left:50px;" class='submit'>
		<input name="upload_addon" type="submit" value="Upload Add-on Subtheme" />
	    </span>&nbsp;<small><strong>Upload and Save</strong> an Add-on Subtheme or Subtheme collection from .zip file on your computer. Will be saved on your site's filesystem.</small>
	</td></tr>
    </table>
    <?php 
    weaverii_nonce_field('upload_addon');
    ?>
</form>

<?php 
}
Exemplo n.º 3
0
function weaverii_filter_css($css)
{
    // filter user added CSS for root relative file paths
    if (strpos($css, '%template_directory%') !== false) {
        $css = str_replace('%template_directory%', parse_url(trailingslashit(get_template_directory_uri()), PHP_URL_PATH), $css);
    }
    if (strpos($css, '%stylesheet_directory%') !== false) {
        $css = str_replace('%stylesheet_directory%', parse_url(trailingslashit(get_stylesheet_directory_uri()), PHP_URL_PATH), $css);
    }
    if (strpos($css, '%addon_directory%') !== false) {
        $css = str_replace('%addon_directory%', parse_url(trailingslashit(weaverii_f_uploads_base_url()) . 'weaverii-subthemes/addon-subthemes/', PHP_URL_PATH), $css);
    }
    return $css;
}
Exemplo n.º 4
0
function weaverii_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 $weaverii_pro_opts;
    global $weaverii_opts_cache;
    $save_dir = weaverii_f_uploads_base_dir() . 'weaverii-subthemes';
    $save_url = weaverii_f_uploads_base_url() . 'weaverii-subthemes';
    if ($is_theme) {
        $ext = '.w2t';
    } else {
        $ext = '.w2b';
    }
    $usename = strtolower(sanitize_file_name($savefile));
    $usename = str_replace($ext, '', $usename);
    if (strlen($usename) < 1) {
        return '';
    }
    $usename = $usename . $ext;
    $wii_theme_dir_exists = weaverii_f_mkdir($save_dir);
    $wii_theme_dir_writable = $wii_theme_dir_exists;
    if (!weaverii_f_is_writable($save_dir)) {
        $wii_theme_dir_writable = false;
    }
    $filename = trailingslashit($save_dir) . $usename;
    if (!$wii_theme_dir_writable || !$wii_theme_dir_exists || !($handle = weaverii_f_open($filename, 'w'))) {
        weaverii_f_file_access_fail('Unable to create file. Probably a file system permission problem. File: ' . $filename);
        return '';
    }
    $tosave = weaverii_get_save_settings($is_theme);
    /* file open, ready to write - so let's write something - either a backup or a theme */
    weaverii_f_write($handle, $tosave);
    // write all Weaver II settings to user save file
    weaverii_f_close($handle);
    return trailingslashit($save_url) . $usename;
}