Esempio n. 1
0
function weaver_admin_init_cb()
{
    /* this will initialize the SAPI stuff */
    weaver_sapi_options_init();
    // This must come first as it hooks update_option used elsewhere
    // Now, init the Weaver database
    weaver_init_opts('weaver_admin_init_cb');
    /* load opts */
    do_action('wvrx_extended_setup');
    // load weaver extension options
    do_action('wvrx_plus_setup');
    // set up Plus options
    do_action('wvrx_plus_admin_init');
    // weaver_sapi_options_init();
    return;
}
Esempio n. 2
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 */
}
Esempio n. 3
0
function weaver_do_admin()
{
    /* theme admin page */
    /* This generates the startup script calls, etc, for the admin page */
    global $weaver_opts_cache, $weaver_main_options, $weaver_main_opts_list;
    if (!current_user_can('edit_theme_options')) {
        wp_die("No permission to access that page.");
    }
    weaver_admin_page_process_options();
    /* handle incoming options settings for all pages*/
    echo '<div class="wrap">';
    screen_icon("themes");
    /* add a nice icon to the admin page */
    ?>
<div style="float:left;"><h2><?php 
    echo WEAVER_THEMEVERSION;
    ?>
 Options</h2><a name="top_main" id="top_main"></a>
</div>


<?php 
    if (!weaver_getopt('ttw_subtheme')) {
        weaver_init_opts('admin', true);
    }
    if (!weaver_f_check_WP_Filesystem() && !weaver_getopt('ftp_hide_check_message')) {
        // let's get a working FS first
        weaver_ftp_form();
    } else {
        if (false && !function_exists('weaver_plus_plugin')) {
            ?>
<div style="float:right;padding-right:30px;"><small><strong>Like Weaver? Please</strong></small>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="6Y68LG9G9M82W">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</div>
<?php 
        }
        ?>
<div style="clear:both;">
<?php 
        weaver_check_for_2010_weaver();
        /* notify if 2010 Weaver settings found */
        weaver_check_version();
        // check version RSS
        ?>

<div id="tabwrap">
  <div id="tab-container-1" class='yetii'>
    <ul id="tab-container-1-nav" class='yetii'>
	<li><a href="#tab0"><?php 
        echo __('Weaver Themes', WEAVER_TRANSADMIN);
        ?>
</a></li>
	<li><a href="#tab1"><?php 
        echo __('Main Options', WEAVER_TRANSADMIN);
        ?>
</a></li>
	<li><a href="#tab2"><?php 
        echo __('Advanced Options', WEAVER_TRANSADMIN);
        ?>
</a></li>
	<li><a href="#tab3"><?php 
        echo __('Save/Restore', WEAVER_TRANSADMIN);
        ?>
</a></li>
	<?php 
        do_action('wvrx_add_plus_tab_title', '<li><a href="#tab9">', '</a></li>');
        ?>
	<li><a href="#tab4"><?php 
        echo __('Snippets', WEAVER_TRANSADMIN);
        ?>
</a></li>
	<li><a href="#tab7"><?php 
        echo __('CSS Help', WEAVER_TRANSADMIN);
        ?>
</a></li>
	<li><a href="#tab5"><?php 
        echo __('Help', WEAVER_TRANSADMIN);
        ?>
</a></li>
	<?php 
        do_action('wvrx_add_extended_tab_title', '<li><a href="#tab6">', '</a></li>');
        ?>
    </ul>

    <div id="tab0" class="tab" >
         <?php 
        weaver_themes_admin();
        ?>
    </div>
    <div id="tab1" class="tab" >
         <?php 
        weaver_options_admin();
        ?>
    </div>
    <div id="tab2" class="tab">
       <?php 
        weaver_advanced_admin();
        ?>
    </div>
    <div id="tab3" class="tab">
       <?php 
        weaver_saverestore_admin();
        ?>
    </div>
    <?php 
        do_action('wvrx_add_plus_tab', '<div id="tab9" class="tab" >', '</div>');
        /* plus option admin tab */
        ?>

    <div id="tab4" class="tab">
       <?php 
        weaver_snippets_admin();
        ?>
    </div>
    <div id="tab7" class="tab">
       <?php 
        weaver_csshelp_admin();
        ?>
    </div>
    <div id="tab5" class="tab">
       <?php 
        weaver_help_admin();
        ?>
    </div>
    <?php 
        do_action('wvrx_add_extended_tab', '<div id="tab6" class="tab" >', '</div>');
        /* extended option admin tab */
        ?>

  </div>

<?php 
        if (weaver_getopt('ttw_show_preview')) {
            ?>

<h3>Preview of site. Displays current look <em>after</em> you save options or select sub-theme.</h3>
<iframe id="preview" name="preview" src="<?php 
            echo get_option('siteurl');
            ?>
?temppreview=true" style="width:100%;height:400px;border:1px solid #ccc"></iframe>
<?php 
        } else {
            echo "<h4>If you'd like a preview box of your site here, check the 'Show Site Preview' box near the bottom of the Advanced Options tab.</h4>\n";
        }
        ?>
</div>
    <script type="text/javascript">
	var tabber1 = new Yetii({
	id: 'tab-container-1',
	persist: true
	});
</script>
    <script type="text/javascript">
	var tabberMain = new Yetii({
	id: 'tab-container-main',
	tabclass: 'tab_mainopt',
	persist: true
	});
</script>
</div>
<?php 
    }
    // end of else weaver_check_write_files
}