-
Notifications
You must be signed in to change notification settings - Fork 8
/
social_icons_widget.php
94 lines (79 loc) · 2.39 KB
/
social_icons_widget.php
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
<?php
/*
Plugin Name: Social Icons Widget
Plugin URI: http://github.com/dannisbet/Social-Icons-Widget
Version: 2013.04
Description: Displays a list of social media website icons and a link to your profile.
Author: Dan Nisbet
Author URI: http://dannisbet.com/
*/
class Social_Icons_Widget extends WP_Widget {
function __construct() {
parent::__construct(
'social-icons-widget', // Base ID
'Social Icons', // Widget Name
array(
'classname' => 'social-icons-widget',
'description' => 'Displays a list of social media website icons and a link to your profile.',
),
array(
'width' => 600,
)
);
// Register Stylesheets
add_action('admin_print_styles', array($this, 'register_admin_styles'));
add_action('wp_enqueue_scripts', array($this, 'register_widget_styles'));
// Declare supported social media websites
global $social_accounts;
$social_accounts = array(
'Behance' => 'behance',
'Bitbucket' => 'bitbucket',
'Dribbble' => 'dribbble',
'Facebook' => 'facebook',
'Flickr' => 'flickr',
'Forrst' => 'forrst',
'Foursquare' => 'foursquare',
'Google+' => 'googleplus',
'GitHub' => 'github',
'Instagram' => 'instagram',
'Klout' => 'klout',
'LinkedIn' => 'linkedin',
'Path' => 'path',
'Pinterest' => 'pinterest',
'RSS Feed' => 'rss',
'StumbleUpon' => 'stumbleupon',
'Technorati' => 'technorati',
'Tumblr' => 'tumblr',
'Twitter' => 'twitter',
'Vimeo' => 'vimeo',
'Yelp' => 'yelp',
'YouTube' => 'youtube',
'Zerply' => 'zerply'
);
}
function form($instance) {
include('lib/form.php');
}
function update($new_instance, $old_instance) {
global $social_accounts;
$instance = array();
foreach ($social_accounts as $site => $id) {
$instance[$id] = $new_instance[$id];
}
$instance['title'] = $new_instance['title'];
$instance['icons'] = $new_instance['icons'];
$instance['labels'] = $new_instance['labels'];
return $instance;
}
function widget($args, $instance) {
include('lib/widget.php');
}
function register_admin_styles() {
wp_enqueue_style('social-icons-widget-admin', plugins_url('social_icons_widget/css/social_icons_admin.css'));
}
function register_widget_styles() {
wp_enqueue_style('social-icons-widget-widget', plugins_url('social_icons_widget/css/social_icons_widget.css'));
}
}
add_action('widgets_init', create_function('', 'register_widget("Social_Icons_Widget");') );
?>