| Server IP : 103.82.32.14 / Your IP : 216.73.217.121 Web Server : Apache/2.2.32 (Unix) mod_ssl/2.2.32 OpenSSL/1.0.1e-fips mod_fcgid/2.3.9 System : Linux cloud.lonmanhoabinh.com 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : lonmakmf ( 524) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /home/lonmakmf/public_html/wp-content/themes/origamiez/parts/widgets/ |
Upload File : |
<?php
add_action('widgets_init', array('Origamiez_Widget_Social_Links', 'register'));
class Origamiez_Widget_Social_Links extends WP_Widget {
public static function register(){
register_widget('Origamiez_Widget_Social_Links');
}
function __construct() {
$widget_ops = array('classname' => 'origamiez-widget-social-links', 'description' => __('Display your social links. Config on Appearance >> Customize.', 'origamiez'));
$control_ops = array('width' => 'auto', 'height' => 'auto');
parent::__construct('origamiez-widget-social-links', __('Origamiez Social Links', 'origamiez'), $widget_ops, $control_ops);
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
}
function widget($args, $instance) {
extract($args);
$instance = wp_parse_args((array) $instance, $this->get_default());
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
echo htmlspecialchars_decode(esc_html($before_widget));
if (!empty($title))
echo htmlspecialchars_decode(esc_html($before_title . $title . $after_title));
$socials = origamiez_get_socials();
if (!empty($socials)):
?>
<div class="social-link-inner clearfix">
<?php
foreach($socials as $social_slug => $social):
$url = get_theme_mod("{$social_slug}_url", '');
$color = get_theme_mod("{$social_slug}_color", $social['color']);
if($url):
$style = '';
if ($color) {
$style = sprintf('color:#FFF; background-color:%1$s; border-color: %1$s;', $color);
}
if ('fa fa-rss' == $social['icon'] && empty($url)){
$url = get_bloginfo('rss2_url');
}
?>
<a href="<?php echo esc_url($url); ?>"
data-placement="top"
data-toggle="tooltip"
title="<?php echo esc_attr($social['label']);?>"
rel="nofollow"
target="_blank"
class="origamiez-tooltip social-link social-link-first" style="<?php echo esc_attr($style);?>">
<span class="<?php echo esc_attr($social['icon']); ?>"></span>
</a>
<?php
endif;
endforeach;
?>
</div>
<?php
endif;
echo htmlspecialchars_decode(esc_html($after_widget));
}
function form($instance) {
$instance = wp_parse_args((array) $instance, $this->get_default());
?>
<p>
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Title:', 'origamiez'); ?></label>
<input class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" name="<?php echo esc_attr($this->get_field_name('title')); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['title'])); ?>" />
</p>
<?php
}
protected function get_default() {
return array(
'title' => __('Social Links', 'origamiez')
);
}
}