function form($instance) { $defaults = array('title' => null); if (!empty($instance['services'])) { $services = $instance['services']; } else { $services = ''; } $services_array = Followers()->services; //Set up some default widget settings. $instance = wp_parse_args((array) $instance, $defaults); ?> <div class="widget-content ptfollowers"> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Widget Title:', 'wfsi'); ?> </label> <input type="text" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo $instance['title']; ?> " class="widefat" /> </p> <p id="selector"> <label for="<?php echo $this->get_field_id('id'); ?> "><?php _e('Choose service:', 'wfsi'); ?> </label> <select class="widefat icontype" id="<?php echo $this->get_field_id('icontype'); ?> " name="<?php echo $this->get_field_name('icontype'); ?> "> <option value="">-</option> <?php foreach ($services_array as $icon => $service) { ?> <option value="<?php echo $icon; ?> "><?php echo $icon; ?> </option> <?php } ?> </select> </p> <input type="hidden" id="services" name="<?php echo $this->get_field_name('services'); ?> " value="<?php echo $instance['services']; ?> " /> <div id="socialicons"> <?php if (!empty($instance['services'])) { $icons = explode(',', $instance['services']); foreach ($icons as $icon => $service) { ?> <p><label><?php echo $service; ?> </label><input type="hidden" class="social-name" value="<?php echo $service; ?> "/></p> <?php } } ?> </div> <p> <small><strong>Hint</strong> You can sort icons by drag&drop, and delete them by dragging element outside the widget!</small> </p> <p> <label for="<?php echo $this->get_field_id('target'); ?> "><?php _e('Links target:', 'wfsi'); ?> </label> <select class="widefat" id="<?php echo $this->get_field_id('target'); ?> " name="<?php echo $this->get_field_name('target'); ?> "> <option value="_self" <?php selected($instance['target'], '_self'); ?> >_self</option> <option value="_blank" <?php selected($instance['target'], '_blank'); ?> >_blank</option> <option value="_parent" <?php selected($instance['target'], '_parent'); ?> >_parent</option> <option value="_top" <?php selected($instance['target'], '_top'); ?> >_top</option> </select> </p> </div> <?php }
/** * Render a field of a given type. * @access public * @since 1.0.0 * @param array $args The field parameters. * @return void */ public function render_field($args) { $html = ''; if (!in_array($args['type'], $this->get_supported_fields())) { return ''; } // Supported field type sanity check. // Make sure we have some kind of default, if the key isn't set. if (!isset($args['default'])) { $args['default'] = ''; } $method = 'render_field_' . $args['type']; if (!method_exists($this, $method)) { $method = 'render_field_text'; } // Construct the key. $key = Followers()->token . '-' . $args['section'] . '[' . $args['id'] . ']'; $method_output = $this->{$method}($key, $args); if (is_wp_error($method_output)) { // if ( defined( 'WP_DEBUG' ) || true == constant( 'WP_DEBUG' ) ) print_r( $method_output ); // Add better error display. } else { $html .= $method_output; } // Output the description, if the current field allows it. if (isset($args['type']) && !in_array($args['type'], (array) apply_filters('wf_no_description_fields', array('checkbox')))) { if (isset($args['description'])) { $description = '<p class="description">' . wp_kses_post($args['description']) . '</p>' . "\n"; if (in_array($args['type'], (array) apply_filters('wf_newline_description_fields', array('textarea', 'select')))) { $description = wpautop($description); } $html .= $description; } } echo $html; }
/** * Validate the settings. * @access public * @since 1.0.0 * @param array $input Inputted data. * @return array Validated data. */ public function validate_settings($input) { $sections = Followers()->settings->get_settings_sections(); $tab = $this->_get_current_tab($sections); return Followers()->settings->validate_settings($input, $tab); }
function pt_followers_shortcode($atts) { extract(shortcode_atts(array("icons" => '', "target" => ''), $atts)); $output = ' <ul class="pt-followers-icons share-buttons">'; $services_array = explode(',', $icons); $services_names = Followers()->services; foreach ($services_array as $key) { $key = trim($key); $name = str_replace('-', '_', $key); if (isset($options[$name . '_url'])) { $url = $options[$name . '_url']; } else { $url = '#'; } $method = $name . '_counter'; $output .= '<li class="' . $key . '-share"> <a target="' . $target . '" href="' . esc_url($url) . '"> <span class="counter"> ' . FollowersCounters::$method() . '</span> <span class="counted"> ' . $services_names[$key]['fans'] . '</span> <span class="action-button"> ' . $services_names[$key]['like'] . '</span> </a> </li>'; } $output .= '</ul>'; return $output; }