function weaveriip_shortcoder_admin()
{
    if (!weaverii_pro_isset('wvpsc_num_opts')) {
        weaveriip_shortcoder_init();
    }
    $num_imgs = weaverii_pro_getopt('wvpsc_num_opts');
    if ($num_imgs < 1) {
        weaverii_pro_setopt('wvpsc_num_opts', 2);
        $num_imgs = 2;
    }
    ?>

	<div>
	<p class='wvr-option-section'>Weaver Shortcoder [weaver_sc] - <small>Define your own shortcodes.</small> <?php 
    weaveriip_help_link('pro-help.html#shortcoder', 'Shortcoder help');
    ?>
</p>
<p><code>[weaver_sc id="myname" v1="optional-replacement" ... v9="replacement"]</code></p>


	<p>This [weaver_sc] shortcode allows you to define your own named shortcodes. These really serve as "macros" - an easy way
	to define constant text or other fixed content you would like to add to your pages, posts, or widget areas.
	The content you define can include other <em>shortcodes</em> and <em>basic HTML</em>, as well as <em>Raw HTML</em>
	or <em>Scripts</em> if you have the role permissions to do that.</p>

	<p>[weaver_sc] supports nine (9) optional parameters, v1 to v9, that allow you to pass values to your shortcode
	definition text. The value of any parameter will replace the equivalent parameter specified as %v1% in your text.
	For example, if you had a shorcode "name" and definition text contained "My name is %v1%.", and you use the shortcode
	[weaver_sc id="name" v1="Bruce"], the output included in your content would be "My name is Bruce." This allows
	you to use the same short code in different pages or posts and supply variable content.</p>

	<form name="weaveriip_options_form" method="post">
	<input class="button-primary" type="submit" name="weaverii_pro_save_pro" value="Save Plus Shortcoder Options"/>
	<br />
		<fieldset class="options">
		<br /><strong style="color:blue;">Define Custom Shortcodes</strong>
		<p>You can add an arbitrary number of your own [weaver_sc] definitions by id.</p>
		<?php 
    for ($i = 1; $i <= $num_imgs; ++$i) {
        weaveriip_sc_add($i);
    }
    ?>
	<br /><strong>Custom shortcodes definitions allowed:</strong><input name="wvpsc_num_opts" id="wvpsc_num_opts" type="text" style="width:40px;height:20px;" class="regular-text" value="<?php 
    weaverii_esc_textarea(weaverii_pro_getopt('wvpsc_num_opts'));
    ?>
" />
	&nbsp;<small>Enter number of Weaver Shortcoder definitions you need (25 max).</small>
	</fieldset>
	<br />
	<input class="button-primary" type="submit" name="weaverii_pro_save_pro" value="Save Plus Shortcoder Options"/>
	<input type="hidden" name="weaveriip_save_shortcoder" value="Weaver II Pro Shortcoder Options Saved" />
	<?php 
    weaverii_nonce_field('weaverii_pro_save_pro');
    ?>
	</form>
	<hr />
	</div>
<?php 
}
function weaveriip_save_disclaimer()
{
    if (isset($_POST['wvr_disclaimer'])) {
        $val = $_POST['wvr_disclaimer'];
        if ($val == '') {
            weaverii_pro_setopt('wvr_disclaimer', '');
        } else {
            weaverii_pro_setopt('wvr_disclaimer', weaverii_filter_textarea($_POST['wvr_disclaimer']));
        }
    }
    weaverii_pro_update_options('save_disclaimer');
    /* and let the user know something happened */
    echo '<div id="message" class="updated fade"><p><strong>Weaver II Pro Comment Disclaimer Text Saved</strong></p></div>';
}
function weaveriip_save_shortcoder()
{
    /* Save options from plus header: wvrx_plus_save_header */
    if (!weaverii_pro_isset('wvpsc_num_opts')) {
        weaveriip_header_init();
    }
    if (isset($_POST['wvpsc_num_opts'])) {
        weaverii_pro_setopt('wvpsc_num_opts', weaveriip_default_int($_POST['wvpsc_num_opts'], 1, 25, 2));
    }
    for ($i = 1; $i <= weaverii_pro_getopt('wvpsc_num_opts'); $i++) {
        $base = 'wvpsc_' . $i . '_';
        if (isset($_POST[$base . 'id'])) {
            $val = filter_var(strtolower(trim(weaverii_filter_textarea($_POST[$base . 'id']))), FILTER_SANITIZE_EMAIL);
            // close enough
            weaverii_pro_setopt($base . 'id', $val);
        }
        if (isset($_POST[$base . 'text'])) {
            weaverii_pro_setopt($base . 'text', weaverii_filter_textarea($_POST[$base . 'text']));
        }
    }
    weaverii_pro_update_options('shortcoder');
    /* and let the user know something happened */
    echo '<div id="message" class="updated fade"><p><strong>Weaver II Pro Shortcoder Options Saved</strong></p></div>';
}
function weaveriip_save_slider()
{
    /* save options */
    global $weaveriip_slider_opts;
    if (!weaverii_pro_isset('slider_number_sliders')) {
        weaveriip_slider_init();
    }
    if (isset($_POST['slider_enable'])) {
        weaverii_pro_setopt('slider_enable', 'checked');
    } else {
        weaverii_pro_setopt('slider_enable', false);
    }
    if (isset($_POST['slider_number_sliders'])) {
        weaverii_pro_setopt('slider_number_sliders', weaveriip_default_int($_POST['slider_number_sliders'], 1, 10, 1));
    } else {
        weaverii_pro_setopt('slider_number_sliders', 1);
    }
    weaverii_pro_update_options('slider save slider2');
    // need the slider_number_sliders
    weaveriip_slider_init();
    // need to do this every time because might be increasing # of sliders
    $limit = weaverii_pro_getopt('slider_number_sliders');
    for ($i = 1; $i <= $limit; $i++) {
        // save opts for each slider
        $sname = 'slider' . $i;
        foreach ($weaveriip_slider_opts as $curopt) {
            if (isset($_POST[$sname . $curopt])) {
                // set to default values
                switch ($curopt) {
                    case '_number_images':
                        weaverii_pro_setopt($sname . $curopt, weaveriip_default_int($_POST[$sname . $curopt], 2, 8, 7));
                        break;
                    case '_noeffects':
                        weaverii_pro_setopt($sname . $curopt, 'checked');
                        break;
                    case '_vertical':
                        weaverii_pro_setopt($sname . $curopt, 'checked');
                        break;
                    case '_hidetext':
                        weaverii_pro_setopt($sname . $curopt, 'checked');
                        break;
                    case '_hidemobile':
                        weaverii_pro_setopt($sname . $curopt, 'checked');
                        break;
                    case '_hidemenu':
                        weaverii_pro_setopt($sname . $curopt, 'checked');
                        break;
                    case '_menu':
                        weaverii_pro_setopt($sname . $curopt, $_POST[$sname . $curopt]);
                        break;
                    case '_vert_compress':
                        weaverii_pro_setopt($sname . $curopt, weaveriip_default_int($_POST[$sname . $curopt], 10, 500, 50));
                        break;
                    case '_img_height':
                        weaverii_pro_setopt($sname . $curopt, weaveriip_default_int($_POST[$sname . $curopt], 32, 1024, 200));
                        break;
                    case '_img_width':
                        weaverii_pro_setopt($sname . $curopt, weaveriip_default_int($_POST[$sname . $curopt], 32, 1024, 320));
                        break;
                    case '_menu_width':
                        weaverii_pro_setopt($sname . $curopt, weaveriip_default_int($_POST[$sname . $curopt], 20, 2048, 940));
                        break;
                    case '_note':
                        weaverii_pro_setopt($sname . $curopt, weaverii_filter_textarea($_POST[$sname . $curopt]));
                        break;
                    case '_text_font':
                        weaverii_pro_setopt($sname . $curopt, weaverii_filter_textarea($_POST[$sname . $curopt]));
                        if (weaverii_pro_getopt($sname . $curopt) == '') {
                            weaverii_pro_setopt($sname . $curopt, WEAVERII_TEXT_FONT);
                        }
                        break;
                    case '_borders':
                        weaverii_pro_setopt($sname . $curopt, weaverii_filter_textarea($_POST[$sname . $curopt]));
                        if (weaverii_pro_getopt($sname . $curopt) == '') {
                            weaverii_pro_setopt($sname . $curopt, WEAVERII_BORDERS);
                        }
                        break;
                    default:
                        weaverii_pro_setopt($sname . $curopt, false);
                }
            } else {
                // for checkboxes
                switch ($curopt) {
                    case '_noeffects':
                        weaverii_pro_setopt($sname . $curopt, false);
                        break;
                    case '_vertical':
                        weaverii_pro_setopt($sname . $curopt, false);
                        break;
                    case '_hidetext':
                        weaverii_pro_setopt($sname . $curopt, false);
                        break;
                    case '_hidemobile':
                        weaverii_pro_setopt($sname . $curopt, false);
                        break;
                    case '_hidemenu':
                        weaverii_pro_setopt($sname . $curopt, false);
                        break;
                }
            }
        }
        for ($j = 1; $j <= 8; $j++) {
            if (isset($_POST[$sname . '_img' . $j])) {
                weaverii_pro_setopt($sname . '_img' . $j, weaverii_filter_textarea($_POST[$sname . '_img' . $j]));
            }
        }
    }
    weaverii_pro_update_options('slider 3');
    /* and let the user know something happened */
    echo '<div id="message" class="updated fade"><p><strong>Weaver Slider Options Saved</strong></p></div>';
}
function weaveriip_save_header()
{
    /* Save options from plus header: wvrx_plus_save_header */
    if (!weaverii_pro_isset('hdr_num_opts')) {
        weaveriip_header_init();
    }
    if (isset($_POST['hdr_num_opts'])) {
        weaverii_pro_setopt('hdr_num_opts', weaveriip_default_int($_POST['hdr_num_opts'], 1, 32, 2));
    }
    if (isset($_POST['hdr_use_for_header'])) {
        weaverii_pro_setopt('hdr_use_for_header', weaverii_filter_textarea($_POST['hdr_use_for_header']));
    }
    for ($i = 1; $i <= weaverii_pro_getopt('hdr_num_opts'); $i++) {
        $base = 'hdr_' . $i . '_';
        if (isset($_POST[$base . 'x'])) {
            weaverii_pro_setopt($base . 'x', weaveriip_default_dec($_POST[$base . 'x'], -2048, 33000, 0));
        }
        if (isset($_POST[$base . '_xunits'])) {
            weaverii_pro_setopt($base . '_xunits', $_POST[$base . '_xunits']);
        }
        if (isset($_POST[$base . 'y'])) {
            weaverii_pro_setopt($base . 'y', weaveriip_default_dec($_POST[$base . 'y'], -2048, 33000, 0));
        }
        if (isset($_POST[$base . '_yunits'])) {
            weaverii_pro_setopt($base . '_yunits', $_POST[$base . '_yunits']);
        }
        if (isset($_POST[$base . 'page'])) {
            weaverii_pro_setopt($base . 'page', weaverii_filter_textarea($_POST[$base . 'page']));
        }
        if (isset($_POST[$base . 'img'])) {
            weaverii_pro_setopt($base . 'img', esc_url(weaverii_filter_textarea($_POST[$base . 'img'])));
            if (weaverii_pro_getopt($base . 'img') == '' && $_POST[$base . 'img'] != '') {
                weaverii_pro_setopt($base . 'img', '#invalid_url_format_entered');
            }
        }
        if (isset($_POST[$base . 'imgalt'])) {
            weaverii_pro_setopt($base . 'imgalt', weaverii_filter_textarea($_POST[$base . 'imgalt']));
        }
        if (isset($_POST[$base . 'text'])) {
            weaverii_pro_setopt($base . 'text', weaverii_filter_textarea($_POST[$base . 'text']));
        }
        if (isset($_POST[$base . 'textstyle'])) {
            weaverii_pro_setopt($base . 'textstyle', weaverii_filter_textarea($_POST[$base . 'textstyle']));
        }
        if (isset($_POST[$base . 'link'])) {
            weaverii_pro_setopt($base . 'link', esc_url(weaverii_filter_textarea($_POST[$base . 'link'])));
            if (weaverii_pro_getopt($base . 'link') == '' && $_POST[$base . 'link'] != '') {
                weaverii_pro_setopt($base . 'link', '#invalid_url__format_entered');
            }
        }
        if (isset($_POST[$base . 'linkalt'])) {
            weaverii_pro_setopt($base . 'linkalt', weaverii_filter_textarea($_POST[$base . 'linkalt']));
        }
        if (isset($_POST[$base . 'hidemobile'])) {
            weaverii_pro_setopt($base . 'hidemobile', 'checked');
        } else {
            weaverii_pro_setopt($base . 'hidemobile', false);
        }
        if (isset($_POST[$base . 'hidetablet'])) {
            weaverii_pro_setopt($base . 'hidetablet', 'checked');
        } else {
            weaverii_pro_setopt($base . 'hidetablet', false);
        }
        if (isset($_POST[$base . 'newpage'])) {
            weaverii_pro_setopt($base . 'newpage', 'checked');
        } else {
            weaverii_pro_setopt($base . 'newpage', false);
        }
    }
    weaverii_pro_update_options('header2');
    /* and let the user know something happened */
    echo '<div id="message" class="updated fade"><p><strong>Weaver II Pro Header Options Saved</strong></p></div>';
}
function weaveriip_init_social()
{
    // social opts are kept in an array saved in weaveriip_plus:['social']
    global $weaveriip_social_services;
    if (!weaverii_pro_isset('social')) {
        $soc = array();
    } else {
        $soc = weaverii_pro_getopt('social');
    }
    foreach ($weaveriip_social_services as $service) {
        $id = $service['icon'];
        if (!isset($soc[$id . '_use'])) {
            $soc[$id . '_use'] = false;
        }
        if (!isset($soc[$id . '_order'])) {
            $soc[$id . '_order'] = '';
        }
        if (!isset($soc[$id . '_hover'])) {
            $soc[$id . '_hover'] = $service['blurb'];
        }
        if (!isset($soc[$id . '_url'])) {
            $soc[$id . '_url'] = '';
        }
        if (!isset($soc[$id . '_stay'])) {
            $soc[$id . '_stay'] = false;
        }
        if (!isset($soc[$id . '_custom'])) {
            $soc[$id . '_custom'] = '';
        }
    }
    weaverii_pro_setopt('social', $soc);
    weaverii_pro_update_options('init_social');
}
function weaverii_pro_setpost_checkbox($name)
{
    if (isset($_POST[$name])) {
        weaverii_pro_setopt($name, 'checked');
    } else {
        weaverii_pro_setopt($name, false);
    }
}
function weaveriip_save_admin_opts()
{
    global $weaverii_pro_opts;
    $weaveriip_admin_checkboxes = array('wvp_hide_slider', 'wvp_hide_extramenus', 'wvp_hide_menuoptions', 'wvp_hide_linkbuttons', 'wvp_hide_socialbuttons', 'wvp_hide_headergadgets', 'wvp_hide_popuplink', 'wvp_hide_showhide', 'wvp_hide_commentpolicy', 'wvp_hide_showfeed', 'wvp_hide_fontsopts', 'wvp_hide_widgetarea', 'wvp_hide_searchbox', 'wvp_hide_moreopts', 'wvp_show_php', 'wvp_show_totalcss', 'wvp_hide_shortcoder');
    foreach ($weaverii_pro_admin_checkboxes as $opt) {
        if (isset($_POST[$opt])) {
            weaverii_pro_setopt($opt, 'checked');
        } else {
            weaverii_pro_setopt($opt, false);
        }
    }
    weaverii_pro_update_options('save_admin_opts');
    // carry out admin opts.
    if (isset($_POST['plus_clear_settings'])) {
        // won't check, just do it.
        if (!current_user_can('edit_theme_options')) {
            return;
        }
        delete_option('weaverii_pro_plus');
        $weaverii_pro_opts = false;
    }
    echo '<div id="message" class="updated fade"><p><strong>Weaver II Pro Admin Options Saved.<br /> <span style="color:red;">NOTE: While features have been enabled
    or disabled, it will take one more save before the admin tabs display the respective features correctly.</span></strong></p></div>';
}
function weaveriip_init_buttons()
{
    // buttons opts are kept in an array saved in weaveriip_plus: ['buttons']
    if (!weaverii_pro_isset('buttons')) {
        $buttons = array();
    } else {
        $buttons = weaverii_pro_getopt('buttons');
    }
    if (!isset($buttons['maxbuttons'])) {
        $buttons['maxbuttons'] = WEAVERIIP_NUM_BUTTONS;
    }
    for ($i = 0; $i < $buttons['maxbuttons']; ++$i) {
        $id = 'b' . $i;
        if (!isset($buttons[$id . '_img_url'])) {
            $buttons[$id . '_img_url'] = '';
        }
        if (!isset($buttons[$id . '_hover'])) {
            $buttons[$id . '_hover'] = '';
        }
        if (!isset($buttons[$id . '_link_url'])) {
            $buttons[$id . '_link_url'] = '';
        }
        if (!isset($buttons[$id . '_blank'])) {
            $buttons[$id . '_blank'] = false;
        }
    }
    weaverii_pro_setopt('buttons', $buttons);
    weaverii_pro_update_options('link buttons3');
}
function weaveriip_save_totalcss()
{
    global $weaveriip_totalcss_checkbox_opts, $weaveriip_totalcss_text_opts, $weaveriip_totalcss_bg_opts;
    /* Save options from plus header: wvrx_plus_save_posts */
    if (!weaverii_pro_isset('wvp_css')) {
        weaveriip_totalcss_init();
    }
    if (isset($_POST['css_edit_lines'])) {
        $value = weaverii_filter_code($_POST['css_edit_lines']);
        if (!empty($value) && (!is_numeric($value) || !is_int((int) $value))) {
            $value = 1;
        }
        if ($value < 1 || $value > 25) {
            $value = 1;
        }
        weaverii_pro_setopt('css_edit_lines', $value);
    }
    global $weaveriip_css;
    foreach ($weaveriip_css as $option => $val) {
        if (isset($_POST[$val['id']]) && $_POST[$val['id']] != '' && $_POST[$val['id']] != '{}') {
            $css = weaverii_filter_code($_POST[$val['id']]);
            $css = weaveriip_bracket($css, '{', '}');
            weaverii_pro_setopt($val['id'], $css);
        } else {
            weaverii_pro_setopt($val['id'], false);
        }
    }
    weaverii_pro_update_options('save_totalcss');
    /* and let the user know something happened */
    echo '<div id="message" class="updated fade"><p><strong>Weaver II Pro More Options Saved</strong></p></div>';
}