Esempio n. 1
0
function weaver2010_setup()
{
    /* Called after the theme stuff has been added.
       It adds additional default header images plus secondary menu and the top/bottom widget areas */
    $ttw_dir = get_template_directory_uri();
    register_default_headers(array('wheat' => array('url' => "{$ttw_dir}/images/headers/wheat.jpg", 'thumbnail_url' => "{$ttw_dir}/images/headers/wheat-thumbnail.jpg", 'description' => __('Wheat 940x198 Header', TTW_TRANS)), 'sopris' => array('url' => "{$ttw_dir}/images/headers/sopris.png", 'thumbnail_url' => "{$ttw_dir}/images/headers/sopris-thumbnail.png", 'description' => __('Sopris 940x198 Header', TTW_TRANS)), 'mum' => array('url' => "{$ttw_dir}/images/headers/mum.jpg", 'thumbnail_url' => "{$ttw_dir}/images/headers/mum-thumbnail.jpg", 'description' => __('Mum 940x198 Header', TTW_TRANS)), 'ivorydrive' => array('url' => "{$ttw_dir}/images/headers/ivorydrive.png", 'thumbnail_url' => "{$ttw_dir}/images/headers/ivorydrive-thumbnail.png", 'description' => __('Ivory Drive 940x198 Blank Header BG', TTW_TRANS)), 'indieave' => array('url' => "{$ttw_dir}/images/headers/indieave.png", 'thumbnail_url' => "{$ttw_dir}/images/headers/indieave-thumbnail.png", 'description' => __('Indie Ave 940x180 Blank Header BG', TTW_TRANS)), 'wpweaver' => array('url' => "{$ttw_dir}/images/headers/wpweaver.jpg", 'thumbnail_url' => "{$ttw_dir}/images/headers/wpweaver-thumbnail.jpg", 'description' => __('WPWeaver 940x140 Header', TTW_TRANS))));
    ## secondary menu
    register_nav_menus(array('secondary' => __('Secondary Navigation', TTW_TRANS)));
    ## top widget area
    register_sidebar(array('name' => __('Weaver Top Widget Area', TTW_TRANS), 'id' => 'top-widget-area', 'description' => __('The top widget area appears above the content area.', TTW_TRANS), 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => "</li>", 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
    ## bottom widget area
    register_sidebar(array('name' => __('Weaver Bottom Widget Area', TTW_TRANS), 'id' => 'bottom-widget-area', 'description' => __('The bottom widget area appears below the content.', TTW_TRANS), 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => "</li>", 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
    ## Special Post Pages Top Widget area
    register_sidebar(array('name' => __('Weaver Post Pages Widget Area', TTW_TRANS), 'id' => 'postpages-widget-area', 'description' => __('This widget area will appear at the top of special post pages (archives, attachment, author, category, single post) This is not used on the main blog page.', TTW_TRANS), 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => "</li>", 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
    ## alternative widget area
    register_sidebar(array('name' => __('Weaver Alternative Widget Area', TTW_TRANS), 'id' => 'alternative-widget-area', 'description' => __('An alternative widget area used only by the Alternative Left and Right page templates.', TTW_TRANS), 'before_widget' => '<li id="%1$s" class="widget-container %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widget-title">', 'after_title' => '</h3>'));
    ## bottom widget area
    register_sidebar(array('name' => __('Weaver Header Widget Area', TTW_TRANS), 'id' => 'header-widget-area', 'description' => __("The header widget area appears at the top of the page. It is intended\n\t\tfor more advanced web pages, and is designed primarily to use Text Widgets to show social feeds\n\t\tor other custom items. Styling is via '#ttw-head-widget', '#ttw-head-widget .textwidget',\n\t\tand inline span style rules. Unless you add widgets, it doesn't show.", TTW_TRANS), 'before_widget' => '', 'after_widget' => '', 'before_title' => '<em class="head-widget-title">', 'after_title' => '</em>'));
    ttw_initopts();
    /* load opts */
    do_action('ttwx_extended_setup');
    do_action('ttwx_themes_setup');
    // needs to before get subtheme because might change it
    $cur_theme = ttw_getopt('ttw_subtheme');
    if ($cur_theme == '' && TTW_START_THEME != TTW_DEFAULT_THEME) {
        require_once 'ttw-subthemes.php';
        // we only need to include this once on first install.
        st_set_subtheme(TTW_START_THEME);
    }
}
Esempio n. 2
0
function ttw_do_admin()
{
    /* theme admin page */
    /* This generates the startup script calls, etc, for the admin page */
    global $ttw_optionsList, $ttw_myoptionsList, $ttw_options, $ttw_adminOpts, $ttw_adminOptsDefault, $ttw_optionsListDefault;
    if (!current_user_can('edit_theme_options')) {
        wp_die("No permission to access that page.");
    }
    $ttw_dir = get_template_directory_uri();
    /* PROCESS $_POST VALUES FROM FORM SUBMISSION FIRST */
    /* First, process any actions from the buttons */
    if (ttw_submitted('saveoptions')) {
        // These options are defined in the Main Options form, and should all set
        // the default value when no value is set from the form.
        echo '<div id="message" class="updated fade"><p><strong>' . __("Twenty Ten Weaver main options saved.", TTW_TRANS) . '</strong></p></div>';
        foreach ($ttw_options as $value) {
            /* only reset main options so use $ttw_options */
            $id = $value['id'];
            $type = $value['type'];
            if ($type == 'ctext') {
                if (isset($_POST[$id])) {
                    // do the color part
                    $v = ttw_esc_code($_POST[$id]);
                    ttw_setopt($id, $v);
                } else {
                    ttw_defaultopt($id);
                }
                $css_id = $id . '_css';
                if (isset($_POST[$css_id])) {
                    // do the CSS part
                    $v = ttw_esc_code($_POST[$css_id]);
                    if (strpos($v, '{') === false && strlen($v) > 0) {
                        ttw_setopt($css_id, '{' . $v . '}');
                        // tricky - allows them to add multiple rules, or sub-rules
                    } else {
                        ttw_setopt($css_id, $v);
                    }
                } else {
                    ttw_setopt($css_id, '/* NO OPTION SET*/');
                }
            } else {
                if (isset($_POST[$id])) {
                    $v = ttw_esc_code($_POST[$id]);
                    ttw_setopt($id, $v);
                } else {
                    ttw_defaultopt($id);
                }
            }
        }
        ttw_saveopts();
    }
    if (ttw_submitted('saveadvanced')) {
        echo '<div id="message" class="updated fade"><p><strong>' . __("Twenty Ten Weaver advanced options saved.", TTW_TRANS) . '</strong></p></div>';
        // THEME OPTS - advanced  theme opts - unlike the options from the Main Options form,
        // these options don't have default values, and thus use the ttw_post_xxx functions.
        ttw_post_opt('ttw_head_opts');
        ttw_post_opt('ttw_theme_head_opts');
        ttw_post_opt('ttw_footer_opts');
        ttw_post_opt('ttw_header_insert');
        ttw_post_opt_html('ttw_preheader_insert');
        ttw_post_opt_html('ttw_prefooter_insert');
        ttw_post_opt_html('ttw_postfooter_insert');
        ttw_post_opt_html('ttw_postheader_insert');
        ttw_post_opt_html('ttw_presidebar_insert');
        ttw_post_opt_html('ttw_custom_header_insert');
        ttw_post_opt('ttw_header_frontpage_only');
        ttw_post_opt('ttw_hide_front_preheader');
        ttw_post_opt('ttw_hide_rest_preheader');
        ttw_post_opt('ttw_hide_front_postheader');
        ttw_post_opt('ttw_hide_rest_postheader');
        ttw_post_opt('ttw_hide_front_prefooter');
        ttw_post_opt('ttw_hide_rest_prefooter');
        ttw_post_opt('ttw_hide_front_postfooter');
        ttw_post_opt('ttw_hide_rest_postfooter');
        ttw_post_opt('ttw_hide_front_presidebar');
        ttw_post_opt('ttw_hide_rest_presidebar');
        ttw_post_opt('ttw_hide_custom_header_template_menus');
        ttw_post_opt('ttw_hide_custom_header_template_siteinfo');
        ttw_post_opt('ttw_hide_blank_header');
        ttw_post_opt('ttw_hide_blank_footer');
        // ADMIN OPTS - per site tags - not theme related
        ttw_post_adminopt('ttw_hide_preview');
        ttw_post_adminopt('ttw_hide_theme_thumbs');
        ttw_post_adminopt('ttw_hide_auto_css_rules');
        ttw_post_adminopt('ttw_hide_metainfo');
        ttw_post_adminopt('ttw_metainfo');
        ttw_post_adminopt('ttw_end_opts');
        ttw_post_adminopt('ttw_copyright');
        ttw_post_adminopt('ttw_hide_poweredby');
        ttw_post_adminopt('ttw_force_inline_css');
        ttw_post_adminopt('ttw_hide_IE_warning_css');
        // NOW, save everything
        ttw_saveopts();
    }
    if (ttw_submitted('setsubtheme') || ttw_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 = ttw_esc_code($_POST[$pID]);
        /* must have been set to get here */
        if ($cur_subtheme == '') {
            $cur_subtheme = TTW_DEFAULT_THEME;
        }
        /* but just in case */
        /* now, i set all values for theme */
        st_set_subtheme($cur_subtheme);
        $t = ttw_getopt('ttw_subtheme');
        if ($t == '') {
            $t = TTW_DEFAULT_THEME;
        }
        /* did we save a theme? */
        echo '<div id="message" class="updated fade"><p><strong>' . __("Twenty Ten Weaver options reset to sub-theme: ", TTW_TRANS) . $t . '.</strong></p></div>';
    }
    if (ttw_submitted('changethemename')) {
        if (isset($_POST['newthemename'])) {
            $new_name = sanitize_user($_POST['newthemename']);
            ttw_setopt('ttw_themename', $new_name);
            echo '<div id="message" class="updated fade"><p><strong>Theme name changed to ' . $new_name . '</strong></p></div>';
        }
    }
    if (ttw_submitted('savemytheme')) {
        ttw_savemytheme();
        echo '<div id="message" class="updated fade"><p><strong>' . __('All current main and advanced options saved in <em>My Saved Theme</em>.', TTW_TRANS) . '</strong></p></div>';
    }
    if (ttw_submitted('reset_weaver')) {
        // delete everything!
        echo '<div id="message" class="updated fade"><p><strong>All Weaver settings have been reset to the default.</strong></p></div>';
        delete_option('ttw_options');
        delete_option('ttw_myoptions');
        delete_option('ttw_adminoptions');
        $ttw_optionsList = $ttw_optionsListDefault;
        foreach ($ttw_options as $value) {
            ttw_defaultopt($value['id']);
        }
        $ttw_myoptionsList = $ttw_optionsList;
        $ttw_adminOpts = $ttw_adminOptsDefault;
        ttw_saveopts();
        st_set_subtheme(TTW_START_THEME);
    }
    if (ttw_submitted('filesavetheme')) {
        $base = strtolower(sanitize_file_name($_POST['savethemename']));
        $temp_url = ttw_write_current_theme($base);
        if ($temp_url == '') {
            echo '<div id="message" class="updated fade"><p><strong>Invalid name supplied to save theme to file.</strong></p></div>';
        } else {
            echo '<div id="message" class="updated fade"><p><strong>' . __("All current main and advanced options saved in {$temp_url}.", TTW_TRANS) . '</strong></p></div>';
        }
    }
    if (ttw_submitted('uploadtheme') && isset($_POST['uploadit']) && $_POST['uploadit'] == 'yes') {
        ttw_uploadit();
    }
    if (ttw_submitted('uploadthemeurl')) {
        // url method
        $filename = esc_url($_POST['ttw_uploadname']);
        if (ttw_upload_theme($filename)) {
            $t = ttw_getopt('ttw_subtheme');
            if ($t == '') {
                $t = TTW_DEFAULT_THEME;
            }
            /* did we save a theme? */
            echo '<div id="message" class="updated fade"><p><strong>' . __("Twenty Ten Weaver theme options reset to uploaded theme, saved as: ", TTW_TRANS) . $t . '.</strong></p></div>';
        } else {
            echo '<div id="message" class="updated fade"><p><strong><em style="color:red;">' . __('INVALID THEME URL PROVIDED - Try Again', TTW_TRANS) . '</em></strong></p></div>';
        }
    }
    if (ttw_submitted('restoretheme')) {
        $wpdir = wp_upload_dir();
        $base = $_POST['ttw_restorename'];
        $valid = validate_file($base);
        // make sure an ok file name
        $fn = $wpdir['basedir'] . '/weaver-subthemes/' . $base;
        if ($valid < 1 && ttw_upload_theme($fn)) {
            $t = ttw_getopt('ttw_subtheme');
            if ($t == '') {
                $t = TTW_DEFAULT_THEME;
            }
            /* did we save a theme? */
            echo '<div id="message" class="updated fade"><p><strong>' . __("Twenty Ten Weaver theme restored from file, saved as: ", TTW_TRANS) . $t . '.</strong></p></div>';
        } else {
            echo '<div id="message" class="updated fade"><p><strong><em style="color:red;">' . __('INVALID FILE NAME PROVIDED - Try Again', TTW_TRANS) . '</em></strong></p></div>';
        }
    }
    if (ttw_submitted('deletetheme')) {
        $myFile = $_POST['selectName'];
        $valid = validate_file($myFile);
        if ($valid < 1 && $myFile != "None") {
            $wpdir = wp_upload_dir();
            unlink($wpdir['basedir'] . '/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 (ttw_submitted('ttw_save_extension')) {
        /* for theme extensions */
        do_action('ttwx_save_extension');
    }
    ?>
<div style="float:left;"><h3><?php 
    echo TTW_THEMEVERSION;
    ?>
 Options</h3><a name="top_main" id="top_main"></a></div>
<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="JUNTAHFM7YGYQ">
<input type="image" src="https://www.paypal.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.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</div><div style="clear:both;">

<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', TTW_TRANS);
    ?>
</a></li>
	<li><a href="#tab1"><?php 
    echo __('Main Options', TTW_TRANS);
    ?>
</a></li>
<?php 
    if (ttw_allow_multisite()) {
        ?>
	<li><a href="#tab2"><?php 
        echo __('Advanced Options', TTW_TRANS);
        ?>
</a></li>
	<li><a href="#tab3"><?php 
        echo __('Save/Restore Themes', TTW_TRANS);
        ?>
</a></li>
	<li><a href="#tab4"><?php 
        echo __('Snippets', TTW_TRANS);
        ?>
</a></li>
	<?php 
    }
    ?>
	<li><a href="#tab7"><?php 
    echo __('CSS Help', TTW_TRANS);
    ?>
</a></li>
	<li><a href="#tab5"><?php 
    echo __('Help', TTW_TRANS);
    ?>
</a></li>
	<?php 
    do_action('ttwx_add_extended_tab_title', '<li><a href="#tab6">', '</a></li>');
    ?>
    </ul>

    <div id="tab0" class="tab" >
         <?php 
    ttw_themes_admin();
    ?>
    </div>
    <div id="tab1" class="tab" >
         <?php 
    ttw_options_admin();
    ?>
    </div>
<?php 
    if (ttw_allow_multisite()) {
        ?>
    <div id="tab2" class="tab">
       <?php 
        ttw_advanced_admin();
        ?>
    </div>
    <div id="tab3" class="tab">
       <?php 
        ttw_saverestore_admin();
        ?>
    </div>
    <div id="tab4" class="tab">
       <?php 
        ttw_snippets_admin();
        ?>
    </div>
<?php 
    }
    ?>
    <div id="tab7" class="tab">
       <?php 
    ttw_csshelp_admin();
    ?>
    </div>
    <div id="tab5" class="tab">
       <?php 
    ttw_help_admin();
    ?>
    </div>
    <?php 
    do_action('ttwx_add_extended_tab', '<div id="tab6" class="tab" >', '</div>');
    /* extended option admin tab */
    ?>

  </div>

<?php 
    if (!ttw_getadminopt('ttw_hide_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 "<h3>Site Preview Disabled</h3>\n";
    }
    ?>
</div>
    <script type="text/javascript">
	var tabber1 = new Yetii({
	id: 'tab-container-1',
	persist: true
	});
</script>
<?php 
}