Aspen Extras
Extra Options for the Aspen Theme
- Upload and Manage Add-on Subthemes - Adds options to the Aspen
"Aspen Subthemes" tab that allow you to easily upload and manage new free and premium add-on subthemes and child
themes you can download from AspenTheme.com.
- Update Aspen Theme Versions - Adds options to the Aspen
"Save/Restore" tab that allows you to update Aspen with the latest versions from AspenTheme.com.
- Per Page Theme Switcher - You can save subthemes and use them on a Per Page basis. The
admin options for this feature are included below.
- Clear Aspen Setttings - Clear Aspen's settings from the database
Theme Switcher Administration
The Aspen Extras Theme Switcher is an advanced option that will be really useful to some
Aspen Theme users. It allows you to save a copy of your current settings in the WordPress Database
using a name of your choosing. That name can then be used set an alternative Per Page subtheme for individual
static pages, or dynamically by adding ?atw_theme=subtheme-name to the link to any page on the site.
If you use the link parameter method to switch themes (e.g., http://example.com/altpage/?atw_theme=subtheme-name),
then a cookie will be set, and all pages on the site will be displayed with the alternate subtheme for 20 minutes.
using ?atw_theme=default will delete the cookie and change back to the default theme.
Create your alternative subtheme using the following instructions, and save it.
Then, you can define a Per Page Custom Field for any
static page. Set the Name of the Custom Field to aspen_switch_theme. Set the Value>
to the name you specify in the "Save Current Theme is Subtheme DB List" below (exactly as it appears in the "Select Theme to Delete"
list box). You can set as many pages as you want
to use the same subtheme, or you can even use several different saved subthemes.
This feature only works for regular static pages or page with posts - no archive-like pages. It also works
if you are logged in as an admin, although the alternate theme will not be used for the Page Editor.
The link parameter ?atw_theme=name version will work on any page.
Instructions - Saving Alternative Subthemes
- Create a subtheme with ALL options set as desired.
- Enter a name for your theme - You can be descriptive, but should be short. Name will be normalized
to all lower case with blanks converted to dashes (-).
- Click the "Save Current Theme as Named" button.
- Repeat for each theme you want to define.
- To use a saved subtheme on a per page basis, add a Custom Field called aspen_switch_theme
to the specific static page from the Pages editor. You can also specify
?atw_theme=name
at the end of a link to a page: http://example.com/?atw_theme=blue
Important - Use Save/Restore to save your alternate subthemes
There is no way to retrieve alternative subthemes settings saved from this plugin. You should be sure to use
the Save/Restore tab to save a copy of the subthemes used for this plugin in an alternative location such
as downloading it to your own computer.
Save Current Theme in Subtheme DB List
Currently saved subthemes:
$val) {
echo '
' . $theme . ' ';
}
?>
Delete Saved Theme
24) {
$name = aspen_get_per_page_value('aspen_switch_theme');
$set_cookie = false; // don't set cookie on a per page theme
}
if ($name == ''
&& isset($_COOKIE['atw_switch_theme'])
) { // okay, could be a cookie set
$name = $_COOKIE['atw_switch_theme'];
$set_cookie = false;
}
if ($name == 'default') {
$url = parse_url(home_url( '/' ));
$domain = $url['host'];
$path = '/';
setcookie('atw_switch_theme',$name,time()-3600,$path,$domain); // 20 minutes (60*20)
} else if ($name != '') { // see if there is an alternate per page theme
// echo '' . "\n";
// okay - have an alternate theme now - reset basic and pro options
$themes = get_option('aspen_switch_themes',array());
if (isset($themes[$name]['aspen_base'])) {
// successful switch...
$opts = $themes[$name]['aspen_base'];
aspen_opt_cache($opts);
if ($set_cookie) { // don't reset cookie
$url = parse_url(home_url( '/' ));
$domain = $url['host'];
$path = '/';
setcookie('atw_switch_theme',$name,time()+1200,$path,$domain); // 20 minutes (60*20)
}
}
}
}
function aspen_x_t_($m) {
return $m;
}
function aspen_x_plugins_url($file,$ext) {
return plugins_url($file,__FILE__) . $ext;
}
//========================================================================
// Clean Settings
function aspen_extras_clean() {
?>
Clean Aspen Theme Settings
If you will not be using the Aspen Theme any longer, this Aspen Extras features allows you
to remove Aspen settings from the WordPress database. The options will be removed, and can't
be recovered once deleted.
IMPORTANT WARNING! - clearing settings will remove your current settings.
You should use the Aspen Save/Restore to save you settings to your computer first!
Select an Add-on Subtheme You Have Uploaded';
$addon_dir = aspen_f_uploads_base_dir() . 'aspen-subthemes/addon-subthemes/';
$addon_url = aspen_f_uploads_base_url() . 'aspen-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 == '.ath' ) {
$addon_list[] = $base;
}
}
}
if (!empty($addon_list)) {
natcasesort($addon_list);
$cur_addon = aspen_getopt('aspopt_addon_name');
if ($cur_addon)
echo '
Currently selected Add-on Subtheme: ' . ucwords(str_replace('-',' ',$cur_addon)) . '
';
?>
No Add-on Subthemes available.
Upload an Add-on Subtheme From Your Computer';
?>
Sorry,
there was a problem uploading your add on theme. The name you picked did not have a valid
Aspen theme file in the /wevaerii-subthemes/addon-subthemes directory.
';
} else {
aspen_save_msg('Aspen theme options reset to ' .
ucwords(str_replace('-',' ',$name )) . ' add-on subtheme.');
aspen_setopt('aspopt_addon_name',$name);
}
}
}
else if (aspen_submitted('delete_added_subtheme') ) { // Delete selected addon theme
if (isset($_POST['aspopt_addon_name']))
{
$name = $_POST['aspopt_addon_name'];
@unlink(aspen_f_uploads_base_dir() . 'aspen-subthemes/addon-subthemes/' . $name . '.ath');
@unlink(aspen_f_uploads_base_dir() . 'aspen-subthemes/addon-subthemes/' . $name . '.jpg');
aspen_save_msg('Deleted ' .
ucwords(str_replace('-',' ',$name )) . ' add-on subtheme.');
}
}
else if (aspen_submitted('upload_addon')
&& isset($_POST['uploadaddon'])
&& $_POST['uploadaddon'] == 'yes') {
// upload theme from users computer
// they've supplied and uploaded a file
$ok = aspen_unpackzip('uploaded_addon', aspen_f_uploads_base_dir() . 'aspen-subthemes/addon-subthemes/');
}
else if (aspen_submitted('upload_theme')) {
// upload theme from users computer
// they've supplied and uploaded a file
if (isset($_FILES['uploaded_theme']['name'])) // uploaded_theme
$filename = $_FILES['uploaded_theme']['name'];
else
$filename = "";
$to = aspen_f_themes_dir();
if (strpos($filename,'aspen-') === false && strpos($filename, 'aspen-') === false)
{
?>
You can upload extra add-on subthemes you\'ve downloaded using the
Aspen Subthemes tab. Note: the Save and Restore options on this page are for the custom settings you
have created. These save/restore options are not related to Add-on Subthemes, although you can
modify an Add-on Subtheme, and save your changes here.
';
}
add_action('aspen_child_update','aspen_child_update_action');
function aspen_child_update_action() {
echo '';
if ((!is_multisite() && current_user_can('install_themes')) || (is_multisite() && current_user_can('manage_network_themes')))
{
?>
Note - using this Aspen theme update tool will directly update your /wp-content/themes/aspen/
directory with the new version. Any files you may have added to one of that
directory, such as a new language translation file, will not be removed. Thus, this provides an easy way to
update Aspen while retaining any new files you may have added.
You must be an Admin or Super-Admin to update Aspen.';
}
}
?>