function weaveriip_buttons_show_list() { global $weaveriip_buttons_services; if (!weaverii_pro_isset('buttons')) { weaveriip_init_buttons(); // just in case! } $buttons = weaverii_pro_getopt('buttons'); $baseurl = get_template_directory_uri(); /* from codex example */ ?> <div> <table class='even-odd'> <tr> <td style="font-weight:bold;padding:5px;"></td> <td style="font-weight:bold;padding:5px;"><small>Image</small></td> <td style="font-weight:bold;padding:5px;"><small>Button Image - Full URL <span style="font-weight:normal">(required)</span></small></td> <td style="font-weight:bold;padding:5px;"><small>Hover Text Description</small></td> <td style="font-weight:bold;padding:5px;"><small>Link - Full URL</</td> <td style="font-weight:bold;padding:5px;"><small>New<br />Page</small></td> </tr> <?php for ($i = 0; $i < $buttons['maxbuttons']; $i++) { if ($i & 1) { echo "<tr>\n"; } else { echo "<tr style=\"background:#eee;\">\n"; } $id = 'b' . $i; ?> <td> <?php echo $i + 1; ?> </td> <?php if ($buttons[$id . '_img_url'] == '') { // special case - no link echo ' <td style="padding:5px;"><img src="' . trailingslashit($baseurl) . 'includes/pro/images/default-button.png" alt="no link" /></td>' . "\n"; } else { echo ' <td style="padding:5px;"><img src="' . $buttons[$id . '_img_url'] . '" alt="button" /></td>' . "\n"; } ?> <td> <input type="text" name="<?php echo $id; ?> _img_url" id="<?php echo $id; ?> _img_url" style="width:240px;height:20px;" class="regular-text" value="<?php echo esc_textarea($buttons[$id . '_img_url']); ?> " /><?php weaverii_media_lib_button($id . '_img_url'); ?> </td> <td style="width:200px;padding-left:10px; padding-right:10px;"> <input type="text" name="<?php echo $id; ?> _hover" id="<?php echo $id; ?> _hover" style="width:200px;height:20px;" class="regular-text" value="<?php echo esc_textarea($buttons[$id . '_hover']); ?> " /> </td> <td style="padding:5px;"> <input type="text" name="<?php echo $id; ?> _link_url" id="<?php echo $id; ?> _link_url" style="width:240px;height:20px;" class="regular-text" value="<?php echo esc_textarea($buttons[$id . '_link_url']); ?> " /> </td> <td style="padding:5px;"> <input type="checkbox" name="<?php echo $id; ?> _blank" id="<?php echo $id; ?> _blank" <?php echo $buttons[$id . '_blank'] ? "checked" : ""; ?> /> </td> <?php } // end for ?> </table> </div> <?php }
function weaveriip_save_buttons() { if (!weaverii_pro_isset('buttons')) { weaveriip_init_buttons(); } $buttons = weaverii_pro_getopt('buttons'); if (isset($_POST['maxbuttons']) && $_POST['maxbuttons'] != $buttons['maxbuttons']) { $buttons['maxbuttons'] = weaveriip_default_int($_POST['maxbuttons'], 1, 64, 8); weaverii_pro_setopt('buttons', $buttons); weaverii_pro_update_options('link buttons'); // kind of convoluted when changing value... weaveriip_init_buttons(); $buttons = weaverii_pro_getopt('buttons'); } $maxbuttons = $buttons['maxbuttons']; for ($i = 0; $i < $maxbuttons; $i++) { $id = 'b' . $i; if (isset($_POST[$id . '_img_url'])) { $buttons[$id . '_img_url'] = weaverii_filter_textarea($_POST[$id . '_img_url']); } if (isset($_POST[$id . '_hover'])) { $buttons[$id . '_hover'] = weaverii_filter_textarea($_POST[$id . '_hover']); } if (isset($_POST[$id . '_link_url'])) { $buttons[$id . '_link_url'] = weaverii_filter_textarea($_POST[$id . '_link_url']); } if (isset($_POST[$id . '_blank'])) { $buttons[$id . '_blank'] = 'checked'; } else { $buttons[$id . '_blank'] = false; } } weaverii_pro_setopt('buttons', $buttons); weaverii_pro_update_options('link buttons2'); }