-
Notifications
You must be signed in to change notification settings - Fork 6
/
sticky-social-bar.php
136 lines (118 loc) · 3.72 KB
/
sticky-social-bar.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
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
<?php
/*
Plugin Name: Sticky Social Bar
Plugin URI: http://wordpress.org/plugins/sticky-social-bar/
Description: Sticky social bar is a simple container of social media icons, glued to the right side of the browser window.
Version: 2.0
Author: Eftakhairul Islam
Author URI: http://eftakhairul.com
Wordpress version supported: 3.0 and above
License: GPL2
*/
include("installation-sticky-social-bar.php");
register_activation_hook (__FILE__,'stickysocialbar_install');
register_deactivation_hook (__FILE__,'stickysocialbar_uninstall');
//Admin menu
if ( is_admin() ) {
add_action('admin_menu', 'stickysocialbar_admin_create_menu');
}
/**
* Create admin menu
*/
function stickysocialbar_admin_create_menu()
{
add_menu_page('Sticky Social Bar', 'Sticky Social Bar', 'administrator', 'sticky-social-bar-setting', 'sticky_social_bar_setting_form',plugins_url('/sticky-social-bar/images/icon_pref_settings.gif',1));
}
/**
* Load the setting from
*/
function sticky_social_bar_setting_form()
{
include("sticky-social-bar-setting-form.php");
}
//Main function Sticky Social Bar
add_action('wp_head', 'sticky_social_bar_css');
//CSS
function sticky_social_bar_css() {
?>
<style type="text/css">
.sticky-container {
/*background-color: #333;*/
padding: 0px;
margin: 0px;
position: fixed;
right: -129px;
top:130px;
width: 200px;
z-index: 10000;
}
.sticky li {
list-style-type: none;
background-color: #333;
color: #efefef;
height: 43px;
padding: 0px;
margin: 0px 0px 1px 0px;
-webkit-transition:all 0.25s ease-in-out;
-moz-transition:all 0.25s ease-in-out;
-o-transition:all 0.25s ease-in-out;
transition:all 0.25s ease-in-out;
cursor: pointer;
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");
filter: gray;
-webkit-filter: grayscale(100%);
}
.sticky li:hover {
margin-left: -115px;
/*-webkit-transform: translateX(-115px);
-moz-transform: translateX(-115px);
-o-transform: translateX(-115px);
-ms-transform: translateX(-115px);
transform:translateX(-115px);*/
/*background-color: #8e44ad;*/
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'1 0 0 0 0, 0 1 0 0 0, 0 0 1 0 0, 0 0 0 1 0\'/></filter></svg>#grayscale");
-webkit-filter: grayscale(0%);
}
.sticky li a img {
float: left;
margin: 5px 5px;
margin-right: 10px;
}
.sticky li a p {
padding: 0px;
margin: 0px;
text-transform: uppercase;
line-height: 43px;
text-decoration: none !important;
color: #ECF0F1;
font-family: "Lato";
}
</style>
<?php
}
//HTML
add_action( 'get_footer', 'sticky_social_bar_html' );
function sticky_social_bar_html() {
global $wpdb;
$stickySocialBarTable = $wpdb->prefix . "sticky_social_bar";
$result = $wpdb->get_results("SELECT * FROM {$stickySocialBarTable} WHERE id = 1");
$links = get_object_vars($result[0]);
unset($links['id']);
unset($links['update_date']);
?>
<div class="sticky-container">
<ul class="sticky">
<?php foreach($links as $name => $link) : ?>
<?php if(!empty($link)): ?>
<li>
<a target="_blank" href="<?php echo $link ?>">
<img width="32" height="32" alt="" src="<?php echo plugins_url('/sticky-social-bar/images/'. $name .'.png', 1) ?>" />
<p><?php echo ucfirst($name) ?></p>
</a>
</li>
<?php endif ?>
<?php endforeach ?>
</ul>
</div>
<?php
}