コード例 #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;
}
コード例 #2
0
ファイル: wvr-fileio.php プロジェクト: uwmadisoncals/weaver
function weaver_f_check_WP_Filesystem()
{
    if (!weaver_f_file_access_available()) {
        return false;
    }
    $save_dir = weaver_f_uploads_base_dir() . 'weaver-subthemes';
    if (!weaver_f_mkdir($save_dir)) {
        return false;
    }
    return true;
}
コード例 #3
0
function weaver_admin_page_process_options()
{
    /* Process all options - called upon entry to options forms */
    // echo("WEAVER-SETTINGS:"); var_dump($weaver_main_settings);
    // echo "POST-weaver-settings:" ; var_dump($_POST['weaver_main_settings']);
    // echo "POST-FULL:" ; var_dump($_POST);
    settings_errors();
    // display results from SAPI save settings
    /* ================ Weaver Upgrade 2020 Weaver buttons ================== */
    if (weaver_submitted('hide_import_old_weaver')) {
        weaver_setopt('wvr_hide_if_are_oldWeaver_opts', true);
        weaver_save_msg(__('Hide 2010 Weaver Notice', WEAVER_TRANSADMIN));
    }
    if (weaver_submitted('import_old_weaver')) {
        weaver_import_2010_weaver();
        weaver_save_msg(__("Previously existing settngs imported.", WEAVER_TRANSADMIN));
    }
    /* ================ Weaver Themes Tab ================== */
    if (weaver_submitted('setsubtheme') || weaver_submitted('setsubtheme2')) {
        /* seems like Mozilla doesn't like 2 sets of select inputs on same page, so we make up 2 ids/names to use */
        if (isset($_POST['setsubtheme'])) {
            $pID = 'ttw_subtheme';
        } else {
            $pID = 'ttw_subtheme2';
        }
        $cur_subtheme = weaver_filter_textarea($_POST[$pID]);
        /* must have been set to get here */
        if ($cur_subtheme == '') {
            $cur_subtheme = 'Wheat';
        }
        /* but just in case */
        /* now, I set all values for theme */
        weaver_activate_subtheme($cur_subtheme);
        $t = weaver_getopt('ttw_subtheme');
        if ($t == '') {
            $t = 'Wheat';
        }
        /* did we save a theme? */
        weaver_save_msg(__("Weaver current sub-theme set to: ", WEAVER_TRANSADMIN) . $t);
    }
    /* ================ Weaver FTP File Access ================== */
    if (weaver_submitted('ftp_save_form')) {
        if (isset($_POST['ftp_hostnamex'])) {
            weaver_setopt('ftp_hostname', trim(weaver_filter_textarea($_POST['ftp_hostnamex'])));
        }
        if (isset($_POST['ftp_usernamex'])) {
            weaver_setopt('ftp_username', trim(weaver_filter_textarea($_POST['ftp_usernamex'])));
        }
        if (isset($_POST['ftp_passwordx'])) {
            weaver_setopt('ftp_password', weaver_encrypt(trim($_POST['ftp_passwordx'])));
        }
        if (isset($_POST['ftp_hide_check_messagex'])) {
            weaver_setopt('ftp_hide_check_message', true);
        } else {
            weaver_setopt('ftp_hide_check_message', false);
        }
        weaver_save_msg(__('FTP File Access Form Settings Saved.', WEAVER_TRANSADMIN));
    }
    /* ================ Weaver Main Options Tab ================== */
    /* Weaver Main and Advanced Options processed in validation callbacks */
    /* ================ Weaver Advanced Options Tab ================== */
    /* SAPI settings are handled in the Main Options Tab section above */
    if (weaver_submitted('reset_weaver')) {
        // delete everything!
        weaver_save_msg(__('All Weaver settings have been reset to the defaults.', WEAVER_TRANS));
        delete_option('weaver_main_settings');
        delete_option('weaver_advanced_settings');
        weaver_load_cache();
        // be sure cache has something valid in it
        weaver_init_opts('reset_weaver');
    }
    /* ================ Weaver Save/Restore Themes Tab ================== */
    /* this tab has the most individual forms and submit commands */
    if (weaver_submitted('changethemename')) {
        if (isset($_POST['newthemename'])) {
            $new_name = sanitize_user($_POST['newthemename']);
            weaver_setopt('ttw_themename', $new_name);
            echo '<div id="message" class="updated fade"><p><strong>Theme name changed to ' . $new_name . '</strong></p></div>';
        }
        global $weaver_dev;
        if ($weaver_dev) {
            // used to save a theme for distribution/inclusion in dynamic theme db
            if (isset($_POST['newthemeimage'])) {
                weaver_setopt('ttw_theme_image', $_POST['newthemeimage']);
            }
            if (isset($_POST['newthemedesc'])) {
                weaver_setopt('ttw_theme_description', $_POST['newthemedesc']);
            }
        }
    }
    if (weaver_submitted('savemytheme')) {
        if (weaver_savemytheme()) {
            weaver_save_msg(__('All current main and advanced options backed up in <em>My Saved Theme</em>.', WEAVER_TRANSADMIN));
        } else {
            weaver_save_msg(__('ERROR: Saving <em>My Saved Theme</em> failed.', WEAVER_TRANSADMIN));
        }
    }
    if (weaver_submitted('backup_settings')) {
        $name = weaver_savebackup();
        if ($name !== false) {
            weaver_save_msg(__('All current main and advanced options backed up in:', WEAVER_TRANSADMIN) . ' "' . $name . '.wvb"');
        } else {
            weaver_save_msg(__('ERROR: Saving backup failed.', WEAVER_TRANSADMIN));
        }
    }
    if (weaver_submitted('filesavetheme')) {
        $base = strtolower(sanitize_file_name($_POST['savethemename']));
        $temp_url = weaver_write_current_theme($base);
        if ($temp_url == '') {
            weaver_save_msg(__('Invalid name supplied to save theme to file.', WEAVER_TRANSADMIN));
        } else {
            weaver_save_msg(__("All current main and advanced options saved in ", WEAVER_TRANSADMIN) . $temp_url);
        }
    }
    if (weaver_submitted('uploadtheme') && isset($_POST['uploadit']) && $_POST['uploadit'] == 'yes') {
        weaver_uploadit();
    }
    if (weaver_submitted('restoretheme')) {
        $base = $_POST['ttw_restorename'];
        $valid = validate_file($base);
        // make sure an ok file name
        $fn = weaver_f_uploads_base_dir() . 'weaver-subthemes/' . $base;
        if ($valid < 1 && weaver_upload_theme($fn)) {
            $t = weaver_getopt('ttw_subtheme');
            if ($t == '') {
                $t = 'Wheat';
            }
            /* did we save a theme? */
            weaver_save_msg(__("Weaver theme restored from file, saved as: ", WEAVER_TRANSADMIN) . $t);
        } else {
            weaver_save_msg('<em style="color:red;">' . __('INVALID FILE NAME PROVIDED - Try Again', WEAVER_TRANSADMIN) . "({$fn})" . '</em>');
        }
    }
    if (weaver_submitted('deletetheme')) {
        $myFile = $_POST['selectName'];
        $valid = validate_file($myFile);
        if ($valid < 1 && $myFile != "None") {
            weaver_f_delete(weaver_f_uploads_base_dir() . 'weaver-subthemes/' . $myFile);
            echo '<div style="background-color: rgb(255, 251, 204);" id="message" class="updated fade"><p>File: <strong>' . $myFile . '</strong> has been deleted.</p></div>';
        } else {
            echo '<div style="background-color: rgb(255, 251, 204);" id="message" class="updated fade"><p>File: <strong>' . $myFile . '</strong> invalid file name, not deleted.</p></div>';
        }
    }
    /* ====================================================== */
    if (weaver_submitted('wvrx_save_extension')) {
        /* for theme extensions */
        do_action('wvrx_save_extension');
    }
    if (weaver_submitted('wvrx_plus_save_plus')) {
        do_action('wvrx_plus_save_plus');
    }
    // All plus submit buttons...
    weaver_save_opts('Weaver Admin');
    /* FINALLY - SAVE ALL OPTIONS AND UPDATE CURRENT CSS FILE */
}
コード例 #4
0
ファイル: functions.php プロジェクト: uwmadisoncals/weaver
function weaver_get_css_filename()
{
    return weaver_f_uploads_base_dir() . 'weaver-subthemes/style-weaver.css';
}
コード例 #5
0
    function weaver_saverestore_admin()
    {
        /* admin tab for saving and restoring theme */
        if (!weaver_f_file_access_available()) {
            echo '<h2>Save/Restore Themes and Backups - DISABLED';
            weaver_help_link('help.html#SaveRestore', 'Help on Save/Restore Themes');
            echo '</h2>';
            echo '<p>Weaver will continue to function with reduced functionality. You will be able to change sub-themes,
	set your own options, and your theme will be displayed with in-line CSS. You won\'t be able to save backups
	of your work, or have page/post styling.</p>' . "\n";
            echo '<div style="display:none">';
            $upload_link = '';
        } else {
            $upload_link = weaver_write_current_theme('current_ttw_subtheme');
            // make a temp copy
        }
        $ttw_theme_dir = weaver_f_uploads_base_dir() . 'weaver-subthemes/';
        ?>

    <h2>Save/Restore Themes and Backups<?php 
        weaver_help_link('help.html#SaveRestore', 'Help on Save/Restore Themes');
        ?>
    </h2>
    <h4>You can save either all your settings in a backup file, or just theme related settings in a theme file:</h4>
    <ol style="font-size: 85%">
     <li>Save <em>all</em> your current settings in a backup file on your site's file system (in <?php 
        echo $ttw_theme_dir;
        ?>
). Automatically names the backup file to include current date and time.
     Survives Weaver Theme updates. -or-</li>
    <li>"Save in My Saved Theme" - Saves <em>all</em> settings in a special "My Saved Theme" backup file. Survives Weaver Theme updates. -or-</li>

    <li>Download current theme related settings to a file on your own computer. -or-</li>
   <li>Save theme related settings to a file on your Site's file system (in <?php 
        echo $ttw_theme_dir;
        ?>
.</li></ol>
<?php 
        if (weaver_allow_multisite()) {
            ?>
    <h4>You can restore a saved theme or backup file by:</h4>
    <ol style="font-size: 85%">
   <li>Picking "My Saved Theme" backup from the standard themes list. -or-</li>
   <li>Restoring a theme/backup that you saved in a file on your site (to current settings). -or-</li>
   <li>Uploading a theme/backup from a file saved on your own computer (to current settings).</li>
    </ol>
<?php 
        }
        if (!weaver_allow_multisite()) {
            ?>
    <h4>You will be unable to restore your saved file directly</h4>
    <p>Since this is a WordPress Multi-site installation, you are restricted from uploading
    a Weaver theme/backup from a saved file. However, the save file capability gives you the ability
    to save your work so you can transfer it to a WordPress site where you have full admin
    capabilities (non-Multi-site installation, for example), or to share with others. Please
    note that you <em>can</em> save your settings in "My Saved Theme" which will allow you
    to explore other predefined themes without losing your work.
    </p>
<?php 
        }
        ?>

    <hr />
    <h3><span style="color:blue;">Use "My Saved Theme"</span></h3>
    <?php 
        weaver_st_show_subtheme_form();
        /* add the picker for subthemes */
        ?>

        <hr />
    <h3><span style="color:blue;">Save Current Settings in Backup File</span></h3>
     <small><strong>Save</strong> <u>all</u> current options (both Main and Advanced) in a <strong>file</strong> on your
     WordPress Site's <em><?php 
        echo $ttw_theme_dir;
        ?>
</em> directory named 'weaver_backup_yyyy-mm-dd-hhmm.wvb'
     where the last part is a GMT based date and time stamp.
<?php 
        if (weaver_allow_multisite()) {
            ?>
    You will be able to restore this theme later using the <strong>Restore Saved Theme/Backup</strong> section.
<?php 
        }
        ?>
    Please be sure you've saved any changes you might have made.</small><br />
     <form enctype="multipart/form-data" name='backup-settings' method='post'>
	<span class='submit'><input name='backup_settings' type='submit' value='Backup All Current Settings'/></span>
    <?php 
        weaver_nonce_field('backup_settings');
        ?>
    </form><br />

    <hr />
    <h3><span style="color:blue;">Save Current Theme to File or Download to your computer</span></h3>
     <small><strong>Save</strong> current <em>theme related</em> settings (non-site specific settings), either by downloading
    to <strong>your computer</strong> or saving a <strong>file</strong> on your WordPress Site's <em><?php 
        echo $ttw_theme_dir;
        ?>
</em> directory.
<?php 
        if (weaver_allow_multisite()) {
            ?>
    You will be able to restore this theme later using the <strong>Restore Saved Theme/Backup</strong> section.
<?php 
        }
        ?>
    Please be sure you've saved any changes you might have made.</small><br /><br />

  <strong>Save as file on this website's server</strong>
 <p>Please provide a name for your file, then click the "Save File" button. <b>Warning:</b> Duplicate names will
    automatically overwrite existing file without notification.</p>
 <form enctype="multipart/form-data" name='savetheme' method='post'><table cellspacing='10' cellpadding='5'>
    <table>
    <td>Name for saved theme: <input type="text" name="savethemename" size="30" />&nbsp;<small>(Please use a meaningful
    name - do not provide file extension. Name might be altered to standard form.)</small></td></tr>
	<tr>
	<td><span class='submit'><input name='filesavetheme' type='submit' value='Save Theme in File'/></span>&nbsp;&nbsp;
	<small><strong>Save Theme in File</strong> - Theme will be saved in <em><?php 
        echo $ttw_theme_dir;
        ?>
</em> directory on your site server.</small></td>
        </tr>
    </table>
    <?php 
        weaver_nonce_field('filesavetheme');
        ?>
 </form><br />

    <strong>Download to your computer</strong>

 <p>Please <em>right</em>-click <a href="<?php 
        echo "{$upload_link}";
        ?>
"><strong>[* here *]</strong></a> to download the saved theme to your computer. </p>

<?php 
        if (weaver_allow_multisite()) {
            ?>
<hr />

    <h3><span style="color:blue;">Restore Saved Theme/Backup from file</span></h3>
    <small>You can restore a previously saved theme (.wvr) or backup (.wvb) file directly from your WordPress
    Site's <em><?php 
            echo $ttw_theme_dir;
            ?>
</em> directory, or from a file saved on your computer.
    Note: after you restore a saved theme, it will be loaded into the current settings. A <em>theme</em> restore will
    replace only settings that are not site-specific. A <em>backup</em> file will replace all current settings.
    If you've uploaded the theme from your computer, you might then want to also save a local copy on your
    website server.</small><br /><br />

    <form enctype="multipart/form-data" name='localrestoretheme' method='post'><table cellspacing='10' cellpadding='5'>
    <table>
    <tr><td><strong>Restore from file saved on this website's server</strong></td></tr>
    <tr>
        <td>Select theme/backup file: <?php 
            weaver_subtheme_list('ttw_restorename');
            ?>
&nbsp;Note: <strong>.wvr</strong> are Theme definitions. <strong>.wvb</strong> are full backups. (Restores to current settings.)</td></tr>
	<tr>
	<td><span class='submit'><input name='restoretheme' type='submit' value='Restore Theme/Backup'/></span>&nbsp;&nbsp;
	<small><strong>Restore</strong> a theme/backup  you've previously saved on your site's <em><?php 
            echo $ttw_theme_dir;
            ?>
</em> directory. Will replace current settings.</small></td>
    </tr>
        <tr><td>&nbsp;</td></tr>
    </table>
    <?php 
            weaver_nonce_field('restoretheme');
            ?>
    </form>
    <form enctype="multipart/form-data" action="<?php 
            echo $_SERVER["REQUEST_URI"];
            ?>
" method="POST">
	<table>
            <tr><td><strong>Upload file saved on your computer</strong></td></tr>
		<tr valign="top">
			<td>Select theme/backup file to upload: <input name="uploaded" type="file" />
			<input type="hidden" name="uploadit" value="yes" />&nbsp;(Restores to current settings.)
                        </td>
		</tr>
                <tr><td><span class='submit'><input name="uploadtheme" type="submit" value="Upload theme/backup" /></span>&nbsp;<small><strong>Upload and Restore</strong> a theme/backup from file on your computer. Will become current settings.</small></td></tr>
                <tr><td>&nbsp;</td></tr>
	</table>
	<?php 
            weaver_nonce_field('uploadtheme');
            ?>
    </form>

    <hr />

    <form enctype="multipart/form-data" name='maintaintheme' method='post'>
    <h3><span style="color:green;">Sub-theme and Backup File Maintenance</span></h3>
        <?php 
            weaver_subtheme_list('selectName');
            ?>

        <span class='submit'><input name='deletetheme' type='submit' value='Delete Sub-Theme/Backup File'/></span>
          <strong>Warning!</strong>This action can't be undone, so be sure you mean to delete a file!
	  <?php 
            weaver_nonce_field('deletetheme');
            ?>
    </form>
<?php 
        }
        if (!weaver_f_file_access_available()) {
            echo '</div> <!-- end of hiding save/restore because not file access available -->';
        }
        ?>
    <hr />
	<form name="ttw_resetweaver_form" method="post" onSubmit="return confirm('Are you sure you want to reset all Weaver settings?');">
	    <h3><span style="color:green;">Clear all Weaver Settings</span></h3>
	    <strong>Click the Clear button to reset all Weaver settings to the default values.</strong><br > <em>Warning: You will lose all current settings.</em> You should use "Backup All Current Settings" to save a copy
	    of your current settings before clearing! <span class="submit"><input type="submit" name="reset_weaver" value="Clear All Weaver Settings"/></span>
	    <?php 
        weaver_nonce_field('reset_weaver');
        ?>
	</form> <!-- ttw_resetweaver_form -->
    <hr />
<?php 
    }