/** * Build the actual widget in the Dashboard * @since 0.1 */ public function form($instance) { $options = lsi_icons(); $defaults = lsi_option_defaults(); $title = isset($instance['title']) && '' !== $instance['title'] ? $instance['title'] : ''; $border_radius = isset($instance['border_radius']) && '' !== $instance['border_radius'] ? $instance['border_radius'] : $defaults['border_radius']; $font_size = isset($instance['font_size']) && '' !== $instance['font_size'] ? $instance['font_size'] : $defaults['font_size']; $background = isset($instance['background']) && '' !== $instance['background'] ? $instance['background'] : $defaults['background']; $color = isset($instance['color']) && '' !== $instance['color'] ? $instance['color'] : $defaults['color']; $background_hover = isset($instance['background_hover']) && '' !== $instance['background_hover'] ? $instance['background_hover'] : $defaults['background_hover']; $color_hover = isset($instance['color_hover']) && '' !== $instance['color_hover'] ? $instance['color_hover'] : $defaults['color_hover']; $alignment = isset($instance['alignment']) && '' !== $instance['alignment'] ? $instance['alignment'] : $defaults['alignment']; $tooltip = isset($instance['tooltip']) && '' !== $instance['tooltip'] ? $instance['tooltip'] : $defaults['tooltip']; $c = 0; foreach ($options as $option) { $defaults['input' . $c++] = ''; $defaults['select' . $c++] = ''; } $instance = wp_parse_args((array) $instance, $defaults); $id = $this->id; ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> "> </p> <p class="lsi-admin-label-left"> <label> <input class="widefat" style="max-width:65px;" id="<?php echo $this->get_field_id('font_size'); ?> " name="<?php echo $this->get_field_name('font_size'); ?> " type="text" value="<?php echo intval($font_size); ?> "> <span class="pixels">px</span> <?php esc_html_e('Icon Size', 'lsi'); ?> </label> </p> <p class="lsi-admin-label-right"> <label> <input class="widefat" style="max-width:65px;" id="<?php echo $this->get_field_id('border_radius'); ?> " name="<?php echo $this->get_field_name('border_radius'); ?> " type="text" value="<?php echo intval($border_radius); ?> "> <span class="pixels">px</span> <?php esc_html_e('Border Radius', 'lsi'); ?> </label> </p> <div class="lsi-divider"></div> <p class="lsi-admin-label-left"> <label> <input class="widefat color-picker" style="max-width:75px;" id="<?php echo $this->get_field_id('background'); ?> " name="<?php echo $this->get_field_name('background'); ?> " type="text" value="<?php echo $background; ?> "> <br /><?php esc_html_e('Background Color', 'lsi'); ?> </label> </p> <p class="lsi-admin-label-right"> <label> <input class="widefat color-picker" style="max-width:75px;" id="<?php echo $this->get_field_id('color'); ?> " name="<?php echo $this->get_field_name('color'); ?> " type="text" value="<?php echo $color; ?> "> <br /><?php esc_html_e('Text Color', 'lsi'); ?> </label> </p> <div class="lsi-divider"></div> <p class="lsi-admin-label-left"> <label> <input class="widefat color-picker" style="max-width:75px;" id="<?php echo $this->get_field_id('background_hover'); ?> " name="<?php echo $this->get_field_name('background_hover'); ?> " type="text" value="<?php echo $background_hover; ?> "> <br /><?php esc_html_e('Background Hover Color', 'lsi'); ?> </label> </p> <p class="lsi-admin-label-right"> <label> <input class="widefat color-picker" style="max-width:75px;" id="<?php echo $this->get_field_id('color_hover'); ?> " name="<?php echo $this->get_field_name('color_hover'); ?> " type="text" value="<?php echo $color_hover; ?> "> <br /><?php esc_html_e('Text Hover Color', 'lsi'); ?> </label> </p> <div class="lsi-divider"></div> <p> <label> <input id="<?php echo $this->get_field_id('new_window'); ?> " type="checkbox" name="<?php echo $this->get_field_name('new_window'); ?> " value="1" <?php checked(1, $instance['new_window']); ?> /> <?php esc_html_e('Open links in new window?', 'lsi'); ?> </label> </p> <p> <label> <input id="<?php echo $this->get_field_id('tooltip'); ?> " type="checkbox" name="<?php echo $this->get_field_name('tooltip'); ?> " value="1" <?php checked(1, $instance['tooltip']); ?> /> <?php esc_html_e('Enable tooltips?', 'lsi'); ?> </label> </p> <p> <select name="<?php echo $this->get_field_name('alignment'); ?> " id="<?php echo $this->get_field_id('alignment'); ?> "> <option value="left" <?php selected($instance['alignment'], 'left'); ?> ><?php _e('Left', 'lsi'); ?> </option> <option value="center" <?php selected($instance['alignment'], 'center'); ?> ><?php _e('Center', 'lsi'); ?> </option> <option value="right" <?php selected($instance['alignment'], 'right'); ?> ><?php _e('Right', 'lsi'); ?> </option> </select> <?php esc_html_e('Alignment', 'lsi'); ?> </p> <div class="lsi-divider"></div> <ul class="social-icon-fields"> <?php $count = 0; foreach ($options as $option) { $input = 'input' . $count++; $select = 'select' . $count++; ?> <li class="lsi-container"> <select class="left choose-icon" name="<?php echo $this->get_field_name($select); ?> " id="<?php echo $this->get_field_id($select); ?> "> <option value=""></option> <?php foreach ($options as $option) { ?> <option value="<?php echo $option['id']; ?> " <?php selected($instance[$select], $option['id']); ?> ><?php echo $option['name']; ?> </option> <?php } ?> </select> <input class="widefat right social-item" id="<?php echo $this->get_field_id($input); ?> " name="<?php echo $this->get_field_name($input); ?> " type="text" value="<?php echo esc_attr($instance[$input]); ?> "> </li> <?php } ?> <span style="float:right;font-size: 90%;padding-top:3px;"> Developed by: <a href="https://generatepress.com/?utm_source=lsi&utm_medium=plugin&utm_campaign=Lightweight%20Social%20Icons " target="_blank">GeneratePress</a> </span> <button onclick="event.preventDefault();lsiAddIcon(this)" class="button add-lsi-row <?php echo $id; ?> " data-id="<?php echo $id; ?> " style="margin-bottom:10px;"><?php _e('Add Icon', 'lsi'); ?> </button> </ul> <script> jQuery(document).ready(function () { jQuery( '.social-item' ).each( function( index ) { if( ! jQuery(this).val() ) { jQuery( this ).parent().hide(); } }); }); function lsiAddIcon(elem) { jQuery( elem ).siblings('li:hidden:first').show(); } </script> <?php }
/** * Build the actual widget in the Dashboard * @since 0.1 */ public function form($instance) { $options = lsi_icons(); $defaults = lsi_option_defaults(); if (isset($instance['title']) && '' !== $instance['title']) { $title = $instance['title']; } else { $title = ''; } if (isset($instance['border_radius']) && '' !== $instance['border_radius']) { $border_radius = $instance['border_radius']; } else { $border_radius = $defaults['border_radius']; } if (isset($instance['font_size']) && '' !== $instance['font_size']) { $font_size = $instance['font_size']; } else { $font_size = $defaults['font_size']; } if (isset($instance['background']) && '' !== $instance['background']) { $background = $instance['background']; } else { $background = $defaults['background']; } if (isset($instance['color']) && '' !== $instance['color']) { $color = $instance['color']; } else { $color = $defaults['color']; } if (isset($instance['background_hover']) && '' !== $instance['background_hover']) { $background_hover = $instance['background_hover']; } else { $background_hover = $defaults['background_hover']; } if (isset($instance['color_hover']) && '' !== $instance['color_hover']) { $color_hover = $instance['color_hover']; } else { $color_hover = $defaults['color_hover']; } if (isset($instance['alignment']) && '' !== $instance['alignment']) { $alignment = $instance['alignment']; } else { $alignment = $defaults['alignment']; } if (isset($instance['tooltip']) && '' !== $instance['tooltip']) { $tooltip = $instance['tooltip']; } else { $tooltip = $defaults['tooltip']; } $c = 0; foreach ($options as $option) { $defaults['input' . $c++] = ''; $defaults['select' . $c++] = ''; } $instance = wp_parse_args((array) $instance, $defaults); ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo esc_attr($title); ?> "> </p> <p class="lsi-admin-label-left"> <label> <input class="widefat" style="max-width:65px;" id="<?php echo $this->get_field_id('font_size'); ?> " name="<?php echo $this->get_field_name('font_size'); ?> " type="text" value="<?php echo intval($font_size); ?> "> <span class="pixels">px</span> <?php esc_html_e('Icon Size', 'lsi'); ?> </label> </p> <p class="lsi-admin-label-right"> <label> <input class="widefat" style="max-width:65px;" id="<?php echo $this->get_field_id('border_radius'); ?> " name="<?php echo $this->get_field_name('border_radius'); ?> " type="text" value="<?php echo intval($border_radius); ?> "> <span class="pixels">px</span> <?php esc_html_e('Border Radius', 'lsi'); ?> </label> </p> <div class="lsi-divider"></div> <p class="lsi-admin-label-left"> <label> <input class="widefat color-picker" style="max-width:75px;" id="<?php echo $this->get_field_id('background'); ?> " name="<?php echo $this->get_field_name('background'); ?> " type="text" value="<?php echo $background; ?> "> <br /><?php esc_html_e('Background Color', 'lsi'); ?> </label> </p> <p class="lsi-admin-label-right"> <label> <input class="widefat color-picker" style="max-width:75px;" id="<?php echo $this->get_field_id('color'); ?> " name="<?php echo $this->get_field_name('color'); ?> " type="text" value="<?php echo $color; ?> "> <br /><?php esc_html_e('Text Color', 'lsi'); ?> </label> </p> <div class="lsi-divider"></div> <p class="lsi-admin-label-left"> <label> <input class="widefat color-picker" style="max-width:75px;" id="<?php echo $this->get_field_id('background_hover'); ?> " name="<?php echo $this->get_field_name('background_hover'); ?> " type="text" value="<?php echo $background_hover; ?> "> <br /><?php esc_html_e('Background Hover Color', 'lsi'); ?> </label> </p> <p class="lsi-admin-label-right"> <label> <input class="widefat color-picker" style="max-width:75px;" id="<?php echo $this->get_field_id('color_hover'); ?> " name="<?php echo $this->get_field_name('color_hover'); ?> " type="text" value="<?php echo $color_hover; ?> "> <br /><?php esc_html_e('Text Hover Color', 'lsi'); ?> </label> </p> <div class="lsi-divider"></div> <p> <label> <input id="<?php echo $this->get_field_id('new_window'); ?> " type="checkbox" name="<?php echo $this->get_field_name('new_window'); ?> " value="1" <?php checked(1, $instance['new_window']); ?> /> <?php esc_html_e('Open links in new window?', 'lsi'); ?> </label> </p> <p> <label> <input id="<?php echo $this->get_field_id('tooltip'); ?> " type="checkbox" name="<?php echo $this->get_field_name('tooltip'); ?> " value="1" <?php checked(1, $instance['tooltip']); ?> /> <?php esc_html_e('Enable tooltips?', 'lsi'); ?> </label> </p> <p> <select name="<?php echo $this->get_field_name('alignment'); ?> " id="<?php echo $this->get_field_id('alignment'); ?> "> <option value="left" <?php selected($instance['alignment'], 'left'); ?> ><?php _e('Left', 'lsi'); ?> </option> <option value="center" <?php selected($instance['alignment'], 'center'); ?> ><?php _e('Center', 'lsi'); ?> </option> <option value="right" <?php selected($instance['alignment'], 'right'); ?> ><?php _e('Right', 'lsi'); ?> </option> </select> <?php esc_html_e('Alignment', 'lsi'); ?> </p> <div class="lsi-divider"></div> <div class="social-icon-fields"> <?php $count = 0; foreach ($options as $option) { $input = 'input' . $count++; $select = 'select' . $count++; ?> <div class="lsi-container"> <select class="left choose-icon" name="<?php echo $this->get_field_name($select); ?> " id="<?php echo $this->get_field_id($select); ?> "> <option value=""></option> <?php foreach ($options as $option) { ?> <option value="<?php echo $option['id']; ?> " <?php selected($instance[$select], $option['id']); ?> ><?php echo $option['name']; ?> </option> <?php } ?> </select> <input class="widefat right social-item" id="<?php echo $this->get_field_id($input); ?> " name="<?php echo $this->get_field_name($input); ?> " type="text" value="<?php echo esc_attr($instance[$input]); ?> "> </div> <?php } ?> </div> <?php }