-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstackdesignsocialprofile.php
More file actions
191 lines (148 loc) · 12.4 KB
/
stackdesignsocialprofile.php
File metadata and controls
191 lines (148 loc) · 12.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
/*
*Plugin Name: Stack Design Social Profile Widget
*Plugin URI: https://blog.stackprogramer.xyz/
*Description: Links to Author social media profile
* Version: 1.5
*Author: stackprogramer
*Author URI: https://blog.stackprogramer.xyz/
* Text Domain: StackDesignSocialProfileWidget
* Domain Path: /languages
*/
class StackDesign_Social_Profile extends WP_Widget {
function __construct() {
parent::__construct('StackDesign_Social_Profile', __('Stack Design Social Networks Profiles', 'StackDesignSocialProfileWidget'), // Name
array('description', __('Links to Author social media profile', 'StackDesignSocialProfileWidget'),) );
}
public function form($instance) {
isset($instance['title']) ? $title = $instance['title'] : null;
empty($instance['title']) ? $title = 'My Social Profile' : null;
isset($instance['aparat']) ? $aparat = $instance['aparat'] : null;
isset($instance['cloob']) ? $cloob = $instance['cloob'] : null;
isset($instance['facenama']) ? $facenama = $instance['facenama'] : null;
isset($instance['hammihan']) ? $hammihan = $instance['hammihan'] : null;
isset($instance['youtube']) ? $youtube = $instance['youtube'] : null;
isset($instance['twitter']) ? $twitter = $instance['twitter'] : null;
isset($instance['google']) ? $google = $instance['google'] : null;
isset($instance['linkedin']) ? $linkedin = $instance['linkedin'] : null;
isset($instance['facebook']) ? $facebook = $instance['facebook'] : null;
isset($instance['rss']) ? $rss = $instance['rss'] : null;
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','StackDesignSocialProfileWidget'); ?></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>
<label for="<?php echo $this->get_field_id('aparat'); ?>"><?php _e('Aparat:','StackDesignSocialProfileWidget'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('aparat'); ?>" name="<?php echo $this->get_field_name('aparat'); ?>" type="text" value="<?php if(isset($aparat)){echo esc_attr($aparat);} ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('cloob'); ?>"><?php _e('Cloob:','StackDesignSocialProfileWidget'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('cloob'); ?>" name="<?php echo $this->get_field_name('cloob'); ?>" type="text" value="<?php if(isset($cloob)){echo esc_attr($cloob);} ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('facenama'); ?>"><?php _e('Facenama:','StackDesignSocialProfileWidget'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('facenama'); ?>" name="<?php echo $this->get_field_name('facenama'); ?>" type="text" value="<?php if(isset($facenama)){echo esc_attr($facenama);} ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('hammihan'); ?>"><?php _e('Hammihan:','StackDesignSocialProfileWidget'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('hammihan'); ?>" name="<?php echo $this->get_field_name('hammihan'); ?>" type="text" value="<?php if(isset($hammihan)){echo esc_attr($hammihan);} ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('youtube'); ?>"><?php _e('Youtube:','StackDesignSocialProfileWidget'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('youtube'); ?>" name="<?php echo $this->get_field_name('youtube'); ?>" type="text" value="<?php if(isset($youtube)){echo esc_attr($youtube);} ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('twitter'); ?>"><?php _e('Twitter:','StackDesignSocialProfileWidget'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('twitter'); ?>" name="<?php echo $this->get_field_name('twitter'); ?>" type="text" value="<?php if(isset($twitter)){echo esc_attr($twitter);} ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('google'); ?>"><?php _e('Google+:','StackDesignSocialProfileWidget'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('google'); ?>" name="<?php echo $this->get_field_name('google'); ?>" type="text" value="<?php if(isset($google)){echo esc_attr($google);} ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('linkedin'); ?>"><?php _e('Linkedin:','StackDesignSocialProfileWidget'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('linkedin'); ?>" name="<?php echo $this->get_field_name('linkedin'); ?>" type="text" value="<?php if(isset($linkedin)){echo esc_attr($linkedin);} ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('facebook'); ?>"><?php _e('Facebook:','StackDesignSocialProfileWidget'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('facebook'); ?>" name="<?php echo $this->get_field_name('facebook'); ?>" type="text" value="<?php if(isset($facebook)){echo esc_attr($facebook);} ?>">
</p>
<p>
<label for="<?php echo $this->get_field_id('rss'); ?>"><?php _e('Rss:','StackDesignSocialProfileWidget'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('rss'); ?>" name="<?php echo $this->get_field_name('rss'); ?>" type="text" value="<?php if(isset($rss)){echo esc_attr($rss);} ?>">
</p>
<?php
}
public function update($new_instance, $old_instance) {
$instance = array();
$instance['title'] = (!empty($new_instance['title']) ) ? strip_tags($new_instance['title']) : '';
$instance['aparat'] = (!empty($new_instance['aparat']) ) ? strip_tags($new_instance['aparat']) : '';
$instance['cloob'] = (!empty($new_instance['cloob']) ) ? strip_tags($new_instance['cloob']) : '';
$instance['facenama'] = (!empty($new_instance['facenama']) ) ? strip_tags($new_instance['facenama']) : '';
$instance['hammihan'] = (!empty($new_instance['hammihan']) ) ? strip_tags($new_instance['hammihan']) : '';
$instance['youtube'] = (!empty($new_instance['youtube']) ) ? strip_tags($new_instance['youtube']) : '';
$instance['twitter'] = (!empty($new_instance['twitter']) ) ? strip_tags($new_instance['twitter']) : '';
$instance['google'] = (!empty($new_instance['google']) ) ? strip_tags($new_instance['google']) : '';
$instance['linkedin'] = (!empty($new_instance['linkedin']) ) ? strip_tags($new_instance['linkedin']) : '';
$instance['facebook'] = (!empty($new_instance['facebook']) ) ? strip_tags($new_instance['facebook']) : '';
$instance['rss'] = (!empty($new_instance['rss']) ) ? strip_tags($new_instance['rss']) : '';
return $instance;
}
public function widget($args, $instance) {
$title = apply_filters('widget_title', $instance['title']);
$aparat = $instance['aparat'];
$cloob = $instance['cloob'];
$facenama = $instance['facenama'];
$hammihan = $instance['hammihan'];
$youtube = $instance['youtube'];
$twitter = $instance['twitter'];
$google = $instance['google'];
$linkedin = $instance['linkedin'];
$facebook = $instance['facebook'];
$rss= $instance['rss'];
// social profile link
$aparat_profile = '<a href="' . $aparat . '" rel="nofollow" ><img title="'.__('Aparat','StackDesignSocialProfileWidget').'" class="click-icons" alt="'.__('Twitter:','StackDesignSocialProfileWidget').'" src="'.plugins_url('img/aparat.png', __FILE__).'" ></a>';
$cloob_profile = '<a href="' . $cloob . '" rel="nofollow" ><img title="'.__('Cloob','StackDesignSocialProfileWidget').'" class="click-icons" alt="'.__('Cloob:','StackDesignSocialProfileWidget').'" src="'.plugins_url('img/cloob.png', __FILE__).'" ></a>';
$facenama_profile = '<a href="' . $facenama . '" rel="nofollow" ><img title="'.__('Facenama','StackDesignSocialProfileWidget').'" class="click-icons" alt="'.__('Facenama:','StackDesignSocialProfileWidget').'" src="'.plugins_url('img/facenama.png', __FILE__).'" ></a>';
$hammihan_profile = '<a href="' . $hammihan . '" rel="nofollow" ><img title="'.__('Hammihan','StackDesignSocialProfileWidget').'" class="click-icons" alt="'.__('Hammihan:','StackDesignSocialProfileWidget').'" src="'.plugins_url('img/hammihan.png', __FILE__).'" ></a>';
$youtube_profile = '<a href="' . $youtube . '" rel="nofollow" ><img title="'.__('Youtube','StackDesignSocialProfileWidget').'" class="click-icons" alt="'.__('Youtube:','StackDesignSocialProfileWidget').'" src="'.plugins_url('img/youtube.png', __FILE__).'" ></a>';
$twitter_profile = '<a href="' . $twitter . '" rel="nofollow" ><img title="'.__('Twitter','StackDesignSocialProfileWidget').'" class="click-icons" alt="'.__('Twitter:','StackDesignSocialProfileWidget').'" src="'.plugins_url('img/twitter.png', __FILE__).'" ></a>';
$google_profile = '<a href="' . $google . '" rel="nofollow" ><img title="'.__('Google+','StackDesignSocialProfileWidget').'" class="click-icons" alt="'.__('Google+:','StackDesignSocialProfileWidget').'" src="'.plugins_url('img/google.png', __FILE__).'" ></a>';
$linkedin_profile = '<a href="' . $linkedin . '" rel="nofollow" ><img title="'.__('Linkedin','StackDesignSocialProfileWidget').'" class="click-icons" alt="'.__('Linkedin:','StackDesignSocialProfileWidget').'" src="'.plugins_url('img/linkedin.png', __FILE__).'" ></a>';
$facebook_profile = '<a href="' . $facebook . '" rel="nofollow" > <img title="'.__('Facebook','StackDesignSocialProfileWidget').'" class="click-icons" alt="'.__('Facebook:','StackDesignSocialProfileWidget').'" src="'.plugins_url('img/facebook.png', __FILE__).'" ></a>';
$rss_profile = '<a href="' . $rss. '" rel="nofollow" > <img title="'.__('Rss','StackDesignSocialProfileWidget').'" class="click-icons" alt="'.__('Rss:','StackDesignSocialProfileWidget').'" src="'.plugins_url('img/rss.png', __FILE__).'" ></a>';
echo $args['before_widget'];
if (!empty($title)) {
echo "\r\n"."\t\t\t\t\t\t\t".$args['before_title'] ."\r\n"."\t\t\t\t\t\t\t". $title ."\r\n"."\t\t\t\t\t\t\t". $args['after_title'];
}
echo "\r\n"."\t\t\t\t\t\t\t".'<div class="social-icons">';
echo (!empty($aparat) ) ? "\r\n"."\t\t\t\t\t\t\t\t\t\t".$aparat_profile : null;
echo (!empty($cloob) ) ? "\r\n"."\t\t\t\t\t\t\t\t\t\t".$cloob_profile : null;
echo (!empty($facenama) )? "\r\n"."\t\t\t\t\t\t\t\t\t\t".$facenama_profile : null;
echo (!empty($hammihan) ) ? "\r\n"."\t\t\t\t\t\t\t\t\t\t".$hammihan_profile : null;
echo (!empty($youtube) ) ? "\r\n"."\t\t\t\t\t\t\t\t\t\t".$youtube_profile : null;
echo (!empty($twitter) ) ? "\r\n"."\t\t\t\t\t\t\t\t\t\t".$twitter_profile : null;
echo (!empty($google) ) ? "\r\n"."\t\t\t\t\t\t\t\t\t\t".$google_profile : null;
echo (!empty($linkedin) ) ? "\r\n"."\t\t\t\t\t\t\t\t\t\t".$linkedin_profile : null;
echo (!empty($facebook) ) ? "\r\n"."\t\t\t\t\t\t\t\t\t\t".$facebook_profile : null;
echo (!empty($rss) ) ? "\r\n"."\t\t\t\t\t\t\t\t\t\t".$rss_profile : null;
echo "\r\n"."\t\t\t\t\t\t\t".'</div>';
echo $args['after_widget'];
}
}
// register Designmodo_Social_Profile widget
function register_stackdesign_social_profile() {
register_widget('StackDesign_Social_Profile');
}
add_action('widgets_init', 'register_stackdesign_social_profile');
// enqueue css stylesheet
function stackdesign_social_profile_widget_css() {
wp_enqueue_style('social-profile-widget', plugins_url('stackdesign-social-profile-widget.css', __FILE__));
}
add_action('wp_enqueue_scripts', 'stackdesign_social_profile_widget_css');
// for plugin translation
function StackDesignSocialProfileWidget_load_textdomain() {
load_plugin_textdomain( 'StackDesignSocialProfileWidget', false, basename( dirname( __FILE__ ) ) . '/languages' );
}
add_action( 'init', 'StackDesignSocialProfileWidget_load_textdomain' );