function weaveriip_social_generate_code($height = 24, $number = 1000, $is_widget = true, $tag = 'span') { global $weaveriip_social_services; if (!weaverii_pro_isset('social')) { weaveriip_init_social(); } $soc = weaverii_pro_getopt('social'); $out = ''; // need to sort the buttons according to the order field. This code may not be the best way to do this, // but it was easier that figuring sorting the array of services. $sorted = array(); $active_services = array(); foreach ($weaveriip_social_services as $service) { // find all active buttons $id = $service['icon']; if (!isset($soc[$id . '_use']) || !$soc[$id . '_use']) { // not set to use continue; } $order = $soc[$id . '_order']; if ($order == '') { $order = 100000; } $sorted[$id] = $order; array_push($active_services, $service); // order doesn't matter here, so just push } asort($sorted); // sort the list of service names $sorted_ids = array_keys($sorted); // get the keys into an array - will be a sorted list of services $displayed = 0; $rm = $is_widget ? '6' : '0'; $out .= '<' . $tag . ' class="weaver-social" >'; foreach ($sorted_ids as $use_id) { foreach ($active_services as $service) { // find the active service that matches the next sorted id $id = $service['icon']; if ($id != $use_id) { continue; } $title = $soc[$id . '_hover']; // $service['blurb']; $url = $soc[$id . '_url']; $custom = isset($soc[$id . '_custom']) ? $soc[$id . '_custom'] : ''; if ($custom != '') { $imgsrc = $custom; } else { $imgsrc = apply_filters('weaverii-social-dir', weaverii_relative_url('includes/pro/social/1/')) . $id . '.png'; } $target = '_blank'; if (isset($soc[$id . '_stay']) && $soc[$id . '_stay']) { $target = '_self'; } $out .= '<a class="wvr-social-a" href="' . $url . '" target="' . $target . '" title="' . $title . '">' . '<img class="wvr-social-img" style="margin-right:' . $rm . 'px; width:' . $height . 'px !important;" src="' . $imgsrc . '" height="' . $height . '" width="' . $height . '" title="' . $title . '" alt="' . $title . '" /></a>' . "\n"; if (++$displayed >= $number) { $out .= '</' . $tag . '>' . "\n"; return $out; // bail when display number reached } break; } } // end foreach $out .= '</' . $tag . '>' . "\n"; if ($is_widget) { $out .= '<div style="clear:both;"></div>' . "\n"; } return $out; }
function weaveriip_social_show_list() { global $weaveriip_social_services; if (!weaverii_pro_isset('social')) { weaveriip_init_social(); // make sane } $soc = weaverii_pro_getopt('social'); // fetch the sub list $baseurl = trailingslashit(get_template_directory_uri()); /* from codex example */ ?> <div> <table class='even-odd'> <tr> <td><strong><small>Use</small></strong></td> <td style="text-align:center;font-weight:bold;"><small>Display<br />Order</small></td> <td></td> <td style="font-weight:bold;"><small>Social Site Description</small></td> <td style="font-weight:bold;"><small>Full URL link to your account</</td> <td style="font-weight:bold;"><small>Stay<br />on page</</td> </tr> <?php $i = 1; foreach ($weaveriip_social_services as $service) { if ($i++ & 1) { $rowbg = '#eee'; } else { $rowbg = 'transparent'; } echo "<tr style=\"background:{$rowbg};\">\n"; $id = $service['icon']; if (!isset($soc[$id . '_use'])) { $soc[$id . '_use'] = ''; } if (!isset($soc[$id . '_url'])) { $soc[$id . '_url'] = ''; } if (!isset($soc[$id . '_order'])) { $soc[$id . '_order'] = ''; } if (!isset($soc[$id . '_hover'])) { $soc[$id . '_hover'] = ''; } if (!isset($soc[$id . '_stay'])) { $soc[$id . '_stay'] = ''; } if (!isset($soc[$id . '_custom'])) { $soc[$id . '_custom'] = ''; } ?> <td style="padding:5px;"> <input type="checkbox" name="<?php echo $id; ?> _use" id="<?php echo $id; ?> _use" <?php echo $soc[$id . '_use'] ? "checked" : ""; ?> /> </td> <td style="padding:5px;"> <input type="text" name="<?php echo $id; ?> _order" id="<?php echo $id; ?> _order" style="width:50px;height:20px;" class="regular-text" value="<?php weaverii_esc_textarea($soc[$id . '_order']); ?> " /> </td> <?php if ($service['icon'][0] == '_') { if ($soc[$id . '_custom'] == '') { $img = '<img src="' . apply_filters('weaverii-social-dir', $baseurl . 'includes/pro/social/1/') . 'button-white.png" height="28" width="28" alt="white button" />'; } else { $img = '<img src="' . $soc[$id . '_custom'] . '" height="28" width="28" alt="custom button" />'; } } else { $img = '<img src="' . apply_filters('weaverii-social-dir', $baseurl . 'includes/pro/social/1/') . $service['icon'] . '.png" height="28" width="28" alt="social button" />'; } if ($service['site'][0] == '#') { // special case - no link echo '<td style="padding:5px;">' . $img . '</td>' . "\n"; echo '<td style="width:340px;padding-left:10px; padding-right:10px;">'; ?> <input type="text" name="<?php echo $id; ?> _hover" id="<?php echo $id; ?> _hover" style="width:340px;height:20px;" class="regular-text" value="<?php weaverii_esc_textarea($soc[$id . '_hover']); ?> " /></td> <?php } else { echo '<td style="padding:5px;"><a href="http://' . $service['site'] . '" target="_blank">' . $img . '</td>' . "\n"; ?> <td style="width:340px;padding-left:10px; padding-right:10px;"><input type="text" name="<?php echo $id; ?> _hover" id="<?php echo $id; ?> _hover" style="width:340px;height:20px;" class="regular-text" value="<?php weaverii_esc_textarea($soc[$id . '_hover']); ?> " /></td> <?php // echo '<td style="width:340px;padding-left:10px; padding-right:10px;">' . $service['blurb'] . "</td>\n"; } ?> <td style="padding:5px;"> <?php if ($service['site'][0] == '#') { // special case - no link echo substr($service['site'], 1) . '<br />'; } ?> <input type="text" name="<?php echo $id; ?> _url" id="<?php echo $id; ?> _url" style="width:280px;height:20px;" class="regular-text" value="<?php weaverii_esc_textarea($soc[$id . '_url']); ?> " /> </td> <td style="padding:5px;"> <input type="checkbox" name="<?php echo $id; ?> _stay" id="<?php echo $id; ?> _stay" <?php echo $soc[$id . '_stay'] ? "checked" : ""; ?> /> </td> <?php if ($service['icon'][0] == '_') { echo "<tr style=\"background:{$rowbg};\">\n"; ?> <td colspan> </td><td colspan="2"><small>Custom Icon URL:</td><td style="width:340px;padding-left:10px; padding-right:10px;"> <input type="text" name="<?php echo $id; ?> _custom" id="<?php echo $id; ?> _custom" style="width:300px;" class="regular-text" value="<?php weaverii_esc_textarea($soc[$id . '_custom']); ?> " /><?php weaverii_media_lib_button($id . '_custom'); ?> </td><td> <small>Suggested size: 32x32 px</td></tr> <?php } echo "</tr>\n"; } // end foreach ?> </table> </div> <?php }