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_header_gadget_code($which = 0) { /* This is called from header.php, and will insert code into the #branding div of the header. */ global $weaverii_cur_page_ID; if (!weaverii_pro_isset('hdr_num_opts')) { weaveriip_header_init(); } // echo("<!-- Weaver II Pro Header Gadgets - Page ID: $weaverii_cur_page_ID; -->\n"); $lim = weaverii_pro_getopt('hdr_num_opts'); if ($which < 1) { // coming from header, not shortcode $max = weaverii_pro_getopt('hdr_use_for_header'); if ($max != '' && $max < $lim) { $lim = $max; } } for ($i = 1; $i <= $lim; $i++) { if ($which > 0 && $which != $i) { continue; } $x = 0; $y = 0; $img = ''; $imgalt = ''; $text = ''; $textstyle = ''; $link = ''; $linkalt = ''; $base = 'hdr_' . $i . '_'; if (weaverii_pro_getopt($base . 'hidemobile') && weaverii_use_mobile('mobile')) { continue; } if (weaverii_pro_getopt($base . 'hidetablet') && weaverii_use_mobile('tablet')) { continue; } if (weaverii_pro_isset($base . 'page')) { $page = weaverii_pro_getopt($base . 'page'); if ($page != '' && $page != $weaverii_cur_page_ID) { continue; } // show only on one page, but not this one. if (weaverii_is_checked_page_opt('wvr_plus_hidecustomheader')) { // maybe skip if (!($page != '' && $page == $weaveriip_cur_page_ID)) { continue; } } } if (weaverii_pro_isset($base . 'x')) { $x = weaverii_pro_getopt($base . 'x'); } $xunits = weaverii_pro_isset($base . '_xunits') ? weaverii_pro_getopt($base . '_xunits') : 'px'; if ($xunits == '') { $xunits = 'px'; } if (weaverii_pro_isset($base . 'y')) { $y = weaverii_pro_getopt($base . 'y'); } $yunits = weaverii_pro_isset($base . '_yunits') ? weaverii_pro_getopt($base . '_yunits') : 'px'; if ($yunits == '') { $yunits = 'px'; } if (weaverii_pro_isset($base . 'img')) { $img = weaverii_pro_getopt($base . 'img'); } if (weaverii_pro_isset($base . 'imgalt')) { $imgalt = weaverii_pro_getopt($base . 'imgalt'); } if (weaverii_pro_isset($base . 'text')) { $text = do_shortcode(weaverii_pro_getopt($base . 'text')); } if (weaverii_pro_isset($base . 'textstyle')) { $textstyle = weaverii_pro_getopt($base . 'textstyle'); } if (weaverii_pro_isset($base . 'link')) { $link = weaverii_pro_getopt($base . 'link'); } if (weaverii_pro_isset($base . 'linkalt')) { $linkalt = weaverii_pro_getopt($base . 'linkalt'); } if (weaverii_pro_isset($base . 'newpage')) { $newpage = weaverii_pro_getopt($base . 'newpage'); } if ($img == '' && $text == '' && $textstyle == '') { continue; } echo '<span id="wvr_gadget_' . $i . '" class="wvr_gadget" style="position:absolute;z-index:4;left:' . $x . $xunits . ';top:' . $y . $yunits . ';' . $textstyle . '">'; if ($link != '') { $target = $newpage ? ' target="_blank"' : ''; echo '<a href="' . $link . '" title="' . $linkalt . '"' . $target . ' style="color:inherit;">'; } if ($img != '') { echo '<img class="wvr_gadget_img" src="' . $img . '" title="' . $imgalt . '" alt="' . $imgalt . '" />'; } if ($text != '') { echo $text; } if ($link != '') { echo "</a>"; } echo "</span>\n"; } ?> <?php }
function weaveriip_headergadget_admin() { if (!weaverii_pro_isset('hdr_num_opts')) { weaveriip_header_init(); } $num_imgs = weaverii_pro_getopt('hdr_num_opts'); ?> <div> <p class='wvr-option-section'>Header Gadgets - <small>Links, Images & Text over the Header + [weaver_gadget] shortcode</small> <?php weaveriip_help_link('pro-help.html#header_gadgets', 'Header Gadgets help'); ?> </p> <p>This tab allows you to add 'gadgets' (mini-widgets) anywhere over the site header. You can use images or text, and add links. You can place these anywhere over the header area of your site.</p> <h4>[weaver_gadget] shortcode</h4> <p>The gadgets defined here can also be used with a shortcode: <code>[weaver_gadget gadget=4]</code> where the 'gadget' parameter specifies the id number of which gadget to use. The shortcode version allows arbitrary placement of gadgets on the content area. You can split the usage of gadgets (some for the header, some for the shortcode) by specifying the "Max items" option at the bottom. </p> <form name="weaveriip_options_form" method="post"> <input class="button-primary" type="submit" name="weaverii_pro_save_pro" value="Save Plus Header Gadget Options"/> <br /> <fieldset class="options"> <br /><strong style="color:blue;">Add Gadgets (Images or Text) over Header Area</strong> <p>You can add an arbitrary number of gadgets (images or text strings) over your header. You can specify how far down from the top (y) and the left (x) each one is displayed, in px or % (negative and decimal values OK). Gadgets will be displayed <em>behind</em> menu bars. You can also add a link to the gadget. Images will work best if you use an image from your Media Library (click the little image button to open Media Library). </p> <p><em><strong>Please note!</strong> Gadgets can cause unexpected results with the mobile view.</em> Gadgets placed beyond 320px to the right will cause an incorrect view on Mobile devices. You can check where they display using the Mobile:Simulate Mobile. Use % for X and Y position to give better responsive layout for gadgets on mobile devices. Specify a CSS styling rule "max-width=10%" (or other appropriate %) to make gadget images responsive/flexible sized. You can also check the hide box for gadgets if they display outside the main 320px wide content.</p> <?php for ($i = 1; $i <= $num_imgs; ++$i) { weaveriip_header_add($i); } ?> <br /><strong>Gadget items allowed:</strong><input name="hdr_num_opts" id="hdr_num_opts" type="text" style="width:40px;height:20px;" class="regular-text" value="<?php echo esc_textarea(weaverii_pro_getopt('hdr_num_opts')); ?> " /> <small>Enter number of gadget items you need to define (32 Max).</small> <br /><strong>Max items displayed over Header:</strong><input name="hdr_use_for_header" id="hdr_use_for_header" type="text" style="width:40px;height:20px;" class="regular-text" value="<?php echo esc_textarea(weaverii_pro_getopt('hdr_use_for_header')); ?> " /> <small>Only the first "n" gadgets will be displayed over the header. The rest can be uses with the [weaver_gadget] shortcode. (Default: use all defined. Use 0 to disable all over the header.)</small> </fieldset> <br /> <input class="button-primary" type="submit" name="weaverii_pro_save_pro" value="Save Plus Header Gadget Options"/> <input type="hidden" name="weaveriip_save_header" value="Weaver Plus Header Options Saved" /> <?php weaverii_nonce_field('weaverii_pro_save_pro'); ?> </form> <hr /> </div> <?php }