Easy Social Icons - Version 1.0

Version Description

  • Add sorting icon using drag drop
  • Built in 5 social icons preloaded as sample icon, to save your time (facebook, twitter, linkedin, flickr, youtube).
  • Now you can display the icons split by rows, input the number of rows in the plugins admin option page
  • Css fixes
  • Icons width / height adjustment fix
Download this release

Release Info

Developer cybernetikz
Plugin Icon 128x128 Easy Social Icons
Version 1.0
Comparing to
See all releases

Version 1.0

css/cnss.css ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ table.cnss-social-icon tr td, table.cnss-social-icon, table.cnss-social-icon tr {
2
+ padding:0 !important;
3
+ margin:0 !important;
4
+ border:none !important;
5
+ vertical-align:middle !important;
6
+ background:none !important;
7
+ }
8
+ table.cnss-social-icon tr td img{
9
+ max-width:100% !important;
10
+ /* background: transparent;
11
+ -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF)";
12
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);
13
+ zoom: 1;*/
14
+ }
15
+ /*table.cnss-social-icon tr td img:hover{
16
+ opacity:0.5;
17
+ filter:alpha(opacity=50);
18
+ margin-top:-15px;
19
+ }*/
20
+ table.cnss-social-icon tr td a img, table.cnss-social-icon tr td a:hover img, table.cnss-social-icon tr td a img:hover{
21
+ border:none !important;
22
+ }
23
+ table.cnss-social-icon tr td a img:hover, table.cnss-social-icon tr td a:hover img{
24
+ max-width:100% !important;
25
+ }
26
+ /*table.cnss-social-icon tr td img{
27
+ margin-right:4px;
28
+ }*/
29
+
30
+ #sortable { list-style-type: none; margin: 10px 0 0; padding: 0; width: 100%; }
31
+ #sortable ul { margin-left:20px; list-style: none; }
32
+ #sortable li { padding: 2px 0px; margin: 4px 0px; border: 1px solid #DDDDDD; cursor: move; -moz-border-radius:6px;}
33
+ #sortable li span { display: block; background: #f7f7f7; padding: 5px 10px; color:#808080; font-size:13px; font-weight:bold;}
34
+ #sortable li.placeholder{border: dashed 2px #ccc;background-color:#FFF;height:20px;}
35
+ .clear {clear: both}
easy-social-icons.php ADDED
@@ -0,0 +1,714 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Easy Social Icons
4
+ Plugin URI: http://www.cybernetikz.com
5
+ Description: You can upload your own social icon, set your social URL, choose weather you want to display vertical or horizontal. You can use the shortcode <strong>[cn-social-icon]</strong> in page/post, template tag for php file <strong>&lt;?php if ( function_exists('cn_social_icon') ) echo cn_social_icon(); ?&gt;</strong> also you can use the widget <strong>"Easy Social Icons"</strong> for sidebar.
6
+ Version: 1.0
7
+ Author: cybernetikz
8
+ Author URI: http://www.cybernetikz.com
9
+ License: GPL2
10
+ */
11
+
12
+ $pluginsURI = plugins_url('/easy-social-icons/');
13
+ function cnss_my_script() {
14
+ global $pluginsURI;
15
+ wp_enqueue_script( 'jquery' );
16
+ wp_enqueue_script('jquery-ui-sortable');
17
+ wp_register_script('cnss_js', $pluginsURI . 'js/cnss.js', array(), '1.0' );
18
+ wp_enqueue_script( 'cnss_js' );
19
+
20
+ wp_register_style('cnss_css', $pluginsURI . 'css/cnss.css', array(), '1.0' );
21
+ wp_enqueue_style( 'cnss_css' );
22
+ }
23
+ add_action('init', 'cnss_my_script');
24
+ add_action('wp_ajax_update-social-icon-order', 'cnss_save_ajax_order' );
25
+ add_action('admin_menu', 'cnss_add_menu_pages');
26
+
27
+ function cnss_add_menu_pages() {
28
+ add_menu_page('Easy Social Icon', 'Easy Social Icon', 'manage_options', 'cnss_social_icon_page', 'cnss_social_icon_page_fn',plugins_url('/images/scc-sc.png', __FILE__) );
29
+
30
+ add_submenu_page('cnss_social_icon_page', 'Manage Icons', 'Manage Icons', 'manage_options', 'cnss_social_icon_page', 'cnss_social_icon_page_fn');
31
+
32
+ add_submenu_page('cnss_social_icon_page', 'Add Icons', 'Add Icons', 'manage_options', 'cnss_social_icon_add', 'cnss_social_icon_add_fn');
33
+
34
+ add_submenu_page('cnss_social_icon_page', 'Sort Icons', 'Sort Icons', 'manage_options', 'cnss_social_icon_sort', 'cnss_social_icon_sort_fn');
35
+
36
+ add_submenu_page('cnss_social_icon_page', 'Options', 'Options', 'manage_options', 'cnss_social_icon_option', 'cnss_social_icon_option_fn');
37
+
38
+ add_action( 'admin_init', 'register_cnss_settings' );
39
+
40
+ }
41
+
42
+ function register_cnss_settings() {
43
+ register_setting( 'cnss-settings-group', 'cnss-width' );
44
+ register_setting( 'cnss-settings-group', 'cnss-height' );
45
+ register_setting( 'cnss-settings-group', 'cnss-margin' );
46
+ register_setting( 'cnss-settings-group', 'cnss-row-count' );
47
+ register_setting( 'cnss-settings-group', 'cnss-vertical-horizontal' );
48
+ }
49
+
50
+ function cnss_social_icon_option_fn() {
51
+
52
+ $cnss_width = get_option('cnss-width');
53
+ $cnss_height = get_option('cnss-height');
54
+ $cnss_margin = get_option('cnss-margin');
55
+ $cnss_rows = get_option('cnss-row-count');
56
+ $vorh = get_option('cnss-vertical-horizontal');
57
+ $vertical ='';
58
+ $horizontal ='';
59
+ if($vorh=='vertical') $vertical = 'checked="checked"';
60
+ if($vorh=='horizontal') $horizontal = 'checked="checked"';
61
+ ?>
62
+ <div class="wrap">
63
+ <h2>Social Icon Options</h2>
64
+ <form method="post" action="options.php">
65
+ <?php settings_fields( 'cnss-settings-group' ); ?>
66
+ <table class="form-table">
67
+ <tr valign="top">
68
+ <th scope="row">Icon Width</th>
69
+ <td><input type="text" name="cnss-width" id="cnss-width" class="small-text" value="<?php echo $cnss_width?>" />px</td>
70
+ </tr>
71
+ <tr valign="top">
72
+ <th scope="row">Icon Height</th>
73
+ <td><input type="text" name="cnss-height" id="cnss-height" class="small-text" value="<?php echo $cnss_height?>" />px</td>
74
+ </tr>
75
+ <tr valign="top">
76
+ <th scope="row">Icon Margin <em><small>(Gap between each icon)</small></em></th>
77
+ <td><input type="text" name="cnss-margin" id="cnss-margin" class="small-text" value="<?php echo $cnss_margin?>" />px</td>
78
+ </tr>
79
+
80
+ <tr valign="top">
81
+ <th scope="row">Number of Rows</th>
82
+ <td><input type="text" name="cnss-row-count" id="cnss-row-count" class="small-text" value="<?php echo $cnss_rows?>" /></td>
83
+ </tr>
84
+
85
+ <tr valign="top">
86
+ <th scope="row">Display Icon</th>
87
+ <td>
88
+ <input <?php echo $horizontal ?> type="radio" name="cnss-vertical-horizontal" id="horizontal" value="horizontal" />&nbsp;<label for="horizontal">Horizontally</label><br />
89
+ <input <?php echo $vertical ?> type="radio" name="cnss-vertical-horizontal" id="vertical" value="vertical" />&nbsp;<label for="vertical">Vertically</label></td>
90
+ </tr>
91
+ </table>
92
+
93
+ <p class="submit">
94
+ <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
95
+ </p>
96
+ </form>
97
+ </div>
98
+ <?php
99
+ }
100
+
101
+
102
+ function cnss_db_install () {
103
+ global $wpdb;
104
+ global $cnss_db_version;
105
+
106
+ $srcdir = ABSPATH.'wp-content/plugins/easy-social-icons/images/icon/';
107
+ $upload_dir = wp_upload_dir();
108
+ $targetdir = $upload_dir['basedir'].'/';
109
+
110
+ $files = scandir($srcdir);
111
+ foreach($files as $fname)
112
+ {
113
+ if($fname=='.')continue;
114
+ if($fname=='..')continue;
115
+ copy($srcdir.$fname, $targetdir.$fname);
116
+ }
117
+
118
+ $table_name = $wpdb->prefix . "cn_social_icon";
119
+ if($wpdb->get_var("show tables like '$table_name'") != $table_name) {
120
+
121
+ $sql2 = "CREATE TABLE " . $table_name . " (
122
+ `id` BIGINT(20) NOT NULL AUTO_INCREMENT,
123
+ `title` VARCHAR(255) NULL,
124
+ `url` VARCHAR(255) NOT NULL,
125
+ `image_url` VARCHAR(255) NOT NULL,
126
+ `sortorder` INT NOT NULL DEFAULT '0',
127
+ `date_upload` VARCHAR(100) NULL,
128
+ `target` tinyint(1) NOT NULL DEFAULT '1',
129
+ PRIMARY KEY (`id`)) ENGINE = InnoDB;
130
+ INSERT INTO `wp_cn_social_icon` (`id`, `title`, `url`, `image_url`, `sortorder`, `date_upload`, `target`) VALUES
131
+ (1, 'facebook', 'http://facebook.com/your-fan-page', '1368459524_facebook.png', 1, '1368459524', 1),
132
+ (2, 'twitter', 'http://twitter/username', '1368459556_twitter.png', 2, '1368459556', 1),
133
+ (3, 'flickr', 'http://flickr.com/?username', '1368459641_flicker.png', 3, '1368459641', 1),
134
+ (4, 'linkedin', 'http://linkedin.com', '1368459699_in.png', 4, '1368459699', 1),
135
+ (5, 'youtube', 'http://youtube.com/user', '1368459724_youtube.png', 5, '1368459724', 1);
136
+ ";
137
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
138
+ dbDelta($sql2);
139
+
140
+ add_option( 'cnss-width', '32');
141
+ add_option( 'cnss-height', '32');
142
+ add_option( 'cnss-margin', '4');
143
+ add_option( 'cnss-row-count', '1');
144
+ add_option( 'cnss-vertical-horizontal', 'horizontal');
145
+
146
+ }
147
+ }
148
+
149
+ register_activation_hook(__FILE__,'cnss_db_install');
150
+
151
+ if (isset($_GET['delete'])) {
152
+
153
+ if ($_REQUEST['id'] != '')
154
+ {
155
+
156
+ $table_name = $wpdb->prefix . "cn_social_icon";
157
+ $image_file_path = "../wp-content/uploads/";
158
+ $sql = "SELECT * FROM ".$table_name." WHERE id =".$_REQUEST['id'];
159
+ $video_info = $wpdb->get_results($sql);
160
+
161
+ if (!empty($video_info))
162
+ {
163
+ @unlink($image_file_path.$video_info[0]->image_url);
164
+ }
165
+ $delete = "DELETE FROM ".$table_name." WHERE id = ".$_REQUEST['id']." LIMIT 1";
166
+ $results = $wpdb->query( $delete );
167
+ $msg = "Delete Successfully!!!"."<br />";
168
+ }
169
+
170
+ }
171
+
172
+
173
+ if (isset($_POST['submit_button'])) {
174
+
175
+ if ($_POST['action'] == 'update')
176
+ {
177
+
178
+ $err = "";
179
+ $msg = "";
180
+
181
+ $image_file_path = "../wp-content/uploads/";
182
+
183
+ if ($_FILES["image_file"]["name"] != "" ){
184
+
185
+ if(
186
+ ($_FILES["image_file"]["type"] == "image/gif")
187
+ || ($_FILES["image_file"]["type"] == "image/jpeg")
188
+ || ($_FILES["image_file"]["type"] == "image/pjpeg")
189
+ || ($_FILES["image_file"]["type"] == "image/png")
190
+ && ($_FILES["image_file"]["size"] < 1024*1024*1))
191
+ {
192
+ if ($_FILES["image_file"]["error"] > 0)
193
+ {
194
+ $err .= "Return Code: " . $_FILES["image_file"]["error"] . "<br />";
195
+ }
196
+ else
197
+ {
198
+ if (file_exists($image_file_path . $_FILES["image_file"]["name"]))
199
+ {
200
+ $err .= $_FILES["image_file"]["name"] . " already exists. ";
201
+ }
202
+ else
203
+ {
204
+ $image_file_name = time().'_'.$_FILES["image_file"]["name"];
205
+ $fstatus = move_uploaded_file($_FILES["image_file"]["tmp_name"], $image_file_path . $image_file_name);
206
+ if ($fstatus == true){
207
+ $msg = "File Uploaded Successfully!!!"."<br />";
208
+ }
209
+ }
210
+ }
211
+ }
212
+ else
213
+ {
214
+ $err .= "Invalid file type or max file size exceded" . "<br />";
215
+ }
216
+ }
217
+ else
218
+ {
219
+ $err .= "Please input image file". "<br />";
220
+ }// end if image file
221
+
222
+ if ($err == '')
223
+ {
224
+ $table_name = $wpdb->prefix . "cn_social_icon";
225
+
226
+ $insert = "INSERT INTO " . $table_name .
227
+ " (title, url, image_url, sortorder, date_upload, target) " .
228
+ "VALUES ('" .
229
+ $wpdb->escape( $_REQUEST['title']) . "','" .
230
+ $wpdb->escape( $_REQUEST['url']) . "','" .
231
+ $image_file_name . "'," .
232
+ $_REQUEST['sortorder'] . ",'" .
233
+ time() . "'," .
234
+ $_REQUEST['target'] . "" .
235
+ ")";
236
+ $results = $wpdb->query( $insert );
237
+
238
+ if (!$results)
239
+ $err .= "Fail to update database" . "<br />";
240
+ else
241
+ $msg .= "Update Successfull!!!" . "<br />";
242
+
243
+ }
244
+ }// end if update
245
+
246
+ if ( $_REQUEST['action'] == 'edit' and $_REQUEST['id'] != '' )
247
+ {
248
+ $err = "";
249
+ $msg = "";
250
+
251
+ $url = $_REQUEST['url'];
252
+ $target = $_REQUEST['target'];
253
+
254
+ $image_file_path = "../wp-content/uploads/";
255
+ $table_name = $wpdb->prefix . "cn_social_icon";
256
+ $sql = "SELECT * FROM ".$table_name." WHERE id =".$_REQUEST['id'];
257
+ $video_info = $wpdb->get_results($sql);
258
+ $image_file_name = $video_info[0]->image_url;
259
+ $update = "";
260
+
261
+ $imgExtArray = array('image/gif','image/jpeg','image/pjpeg','image/png');
262
+ $type= 1;
263
+ if ($_FILES["image_file"]["name"] != ""){
264
+ if( in_array($_FILES["image_file"]["type"],$imgExtArray) && $_FILES["image_file"]["size"] <= 1024*1024*1 )
265
+ {
266
+ if ($_FILES["image_file"]["error"] > 0)
267
+ {
268
+ $err .= "Return Code: " . $_FILES["image_file"]["error"] . "<br />";
269
+ }
270
+ else
271
+ {
272
+ if (file_exists($image_file_path . $_FILES["image_file"]["name"]))
273
+ {
274
+ $err .= $_FILES["image_file"]["name"] . " already exists. ";
275
+ }
276
+ else
277
+ {
278
+ $image_file_name = time().'_'.$_FILES["image_file"]["name"];
279
+ $fstatus = move_uploaded_file($_FILES["image_file"]["tmp_name"], $image_file_path . $image_file_name);
280
+
281
+ if ($fstatus == true){
282
+ $msg = "File Uploaded Successfully!!!".'<br />';
283
+ @unlink($image_file_path.$video_info[0]->image_url);
284
+ $update = "UPDATE " . $table_name . " SET " .
285
+ "image_url='" .$image_file_name . "'" .
286
+ " WHERE id=" . $_REQUEST['id'];
287
+ $results1 = $wpdb->query( $update );
288
+ }
289
+ }
290
+ }
291
+ }
292
+ else
293
+ {
294
+ $err .= "Invalid file type or max file size exceded";
295
+ }
296
+ }
297
+
298
+ $update = "UPDATE " . $table_name . " SET " .
299
+ "title='" .$wpdb->escape( $_POST['title']) . "'," .
300
+ "url='" . $url . "'," .
301
+ "sortorder=" .$_POST['sortorder'] . "," .
302
+ "date_upload='" .time(). "'," .
303
+ "target=$target " .
304
+ " WHERE id=" . $_POST['id'];
305
+ if ($err == '')
306
+ {
307
+ $table_name = $wpdb->prefix . "cn_social_icon";
308
+ $results3 = $wpdb->query( $update );
309
+
310
+ if (!$results3){
311
+ $err .= "Update Fail!!!". "<br />";
312
+ }
313
+ else
314
+ {
315
+ $msg = "Update Successfull!!!". "<br />";
316
+ }
317
+ }
318
+
319
+ } // end edit
320
+
321
+ }
322
+
323
+
324
+ function cnss_social_icon_sort_fn() {
325
+ global $wpdb;
326
+
327
+ $cnss_width = get_option('cnss-width');
328
+ $cnss_height = get_option('cnss-height');
329
+
330
+ $image_file_path = "../wp-content/uploads/";
331
+ $table_name = $wpdb->prefix . "cn_social_icon";
332
+ $sql = "SELECT * FROM ".$table_name." WHERE 1 ORDER BY sortorder";
333
+ $video_info = $wpdb->get_results($sql);
334
+
335
+ ?>
336
+ <div class="wrap">
337
+ <h2>Sort Icon</h2>
338
+
339
+ <div id="ajax-response"></div>
340
+
341
+ <noscript>
342
+ <div class="error message">
343
+ <p><?php _e('This plugin can\'t work without javascript, because it\'s use drag and drop and AJAX.', 'cpt') ?></p>
344
+ </div>
345
+ </noscript>
346
+
347
+ <div id="order-post-type">
348
+ <ul id="sortable">
349
+ <?php foreach($video_info as $vdoinfo) { ?>
350
+ <li id="item_<?php echo $vdoinfo->id ?>">
351
+ <table width="100%" border="0" cellspacing="0" cellpadding="0">
352
+ <tr style="background:#f7f7f7">
353
+ <td width="60">&nbsp;<img src="<?php echo $image_file_path.$vdoinfo->image_url;?>" border="0" width="<?php echo $cnss_width ?>" height="<?php echo $cnss_height ?>" alt="<?php echo $vdoinfo->title;?>" /></td>
354
+ <td><span><?php echo $vdoinfo->title;?></span></td>
355
+ </tr>
356
+ </table>
357
+ </li>
358
+ <?php } ?>
359
+ </ul>
360
+
361
+ <div class="clear"></div>
362
+ </div>
363
+
364
+ <p class="submit">
365
+ <a href="#" id="save-order" class="button-primary">Update</a>
366
+ </p>
367
+
368
+ <script type="text/javascript">
369
+ jQuery(document).ready(function() {
370
+ jQuery("#sortable").sortable({
371
+ tolerance:'intersect',
372
+ cursor:'pointer',
373
+ items:'li',
374
+ placeholder:'placeholder'
375
+ });
376
+ jQuery("#sortable").disableSelection();
377
+ jQuery("#save-order").bind( "click", function() {
378
+ //alert(jQuery("#sortable").sortable("serialize"));
379
+ jQuery.post( ajaxurl, { action:'update-social-icon-order', order:jQuery("#sortable").sortable("serialize") }, function(response) {
380
+ //alert(response);
381
+ jQuery("#ajax-response").html('<div class="message updated fade"><p>Items Order Updated</p></div>');
382
+ jQuery("#ajax-response div").delay(3000).hide("slow");
383
+ });
384
+ });
385
+ });
386
+ </script>
387
+
388
+ </div>
389
+ <?php
390
+ }
391
+
392
+ function cnss_save_ajax_order()
393
+ {
394
+ global $wpdb;
395
+ $table_name = $wpdb->prefix . "cn_social_icon";
396
+ parse_str($_POST['order'], $data);
397
+ if (is_array($data))
398
+ foreach($data as $key => $values )
399
+ {
400
+
401
+ if ( $key == 'item' )
402
+ {
403
+ foreach( $values as $position => $id )
404
+ {
405
+ $wpdb->update( $table_name, array('sortorder' => $position), array('id' => $id) );
406
+ }
407
+ }
408
+
409
+ }
410
+ }
411
+
412
+
413
+ function cnss_social_icon_add_fn() {
414
+
415
+ global $err,$msg;
416
+
417
+ if (isset($_GET['mode'])) {
418
+ if ( $_REQUEST['mode'] != '' and $_REQUEST['mode'] == 'edit' and $_REQUEST['id'] != '' )
419
+ {
420
+
421
+ $cnss_width = get_option('cnss-width');
422
+ $cnss_height = get_option('cnss-height');
423
+ //$cnss_margin = get_option('cnss-margin');
424
+
425
+
426
+ $page_title = 'Edit Icon';
427
+ $uptxt = 'Upload Icon';
428
+
429
+ global $wpdb;
430
+ $table_name = $wpdb->prefix . "cn_social_icon";
431
+ $image_file_path = "../wp-content/uploads/";
432
+ $sql = "SELECT * FROM ".$table_name." WHERE id =".$_REQUEST['id'];
433
+ $video_info = $wpdb->get_results($sql);
434
+
435
+ if (!empty($video_info))
436
+ {
437
+ $id = $video_info[0]->id;
438
+ $title = $video_info[0]->title;
439
+ $url = $video_info[0]->url;
440
+ $image_url = $image_file_path.$video_info[0]->image_url;
441
+ $sortorder = $video_info[0]->sortorder;
442
+ $target = $video_info[0]->target;
443
+ }
444
+ }
445
+ }
446
+ else
447
+ {
448
+
449
+ $page_title = 'Add New Icon';
450
+ $title = "";
451
+ $url = "";
452
+ $image_url = "";
453
+ $sortorder = "0";
454
+ $target = "";
455
+ $uptxt = 'Upload Icon';
456
+
457
+ }
458
+ ?>
459
+ <div class="wrap">
460
+ <?php
461
+ if($msg!='' or $err!='')
462
+ echo '<div id="message" class="updated fade">'. $msg.$err.'</div>';
463
+ ?>
464
+
465
+ <h2><?php echo $page_title;?></h2>
466
+
467
+ <form method="post" enctype="multipart/form-data" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
468
+
469
+ <table class="form-table">
470
+ <tr valign="top">
471
+ <th scope="row">Icon Title</th>
472
+ <td>
473
+ <input type="text" name="title" id="title" class="regular-text" value="<?php echo $title?>" />
474
+ </td>
475
+ </tr>
476
+
477
+ <tr valign="top">
478
+ <th scope="row"><?php echo $uptxt;?></th>
479
+ <td>
480
+ <?php if (isset($_GET['mode'])) { ?>
481
+ <br /><img src="<?php echo $image_url?>" border="0" width="<?php echo $cnss_width ?>" height="<?php echo $cnss_height ?>" alt="<?php echo $title?>" /><br />
482
+ <?php } ?>
483
+ <input type="file" name="image_file" id="image_file" value="" />
484
+ </td>
485
+ </tr>
486
+
487
+ <tr valign="top">
488
+ <th scope="row">URL</th>
489
+ <td><input type="text" name="url" id="url" class="regular-text" value="<?php echo $url?>" /><br /><i>Example: <strong>http://facebook.com/your-fan-page</strong> &ndash; don't forget the <strong><code>http://</code></strong></i></td>
490
+ </tr>
491
+
492
+ <tr valign="top">
493
+ <th scope="row">Sort Order</th>
494
+ <td>
495
+ <input type="text" name="sortorder" id="sortorder" class="small-text" value="<?php echo $sortorder?>" />
496
+ </td>
497
+ </tr>
498
+
499
+ <tr valign="top">
500
+ <th scope="row">Target</th>
501
+ <td>
502
+ <input type="radio" name="target" id="new" checked="checked" value="1" />&nbsp;<label for="new">Open new window</label>&nbsp;<br />
503
+ <input type="radio" name="target" id="same" value="0" />&nbsp;<label for="same">Open same window</label>&nbsp;
504
+ </td>
505
+ </tr>
506
+
507
+
508
+ </table>
509
+
510
+
511
+ <?php if (isset($_GET['mode']) ) { ?>
512
+ <input type="hidden" name="action" value="edit" />
513
+ <input type="hidden" name="id" id="id" value="<?php echo $id;?>" />
514
+ <?php } else {?>
515
+ <input type="hidden" name="action" value="update" />
516
+ <?php } ?>
517
+
518
+
519
+ <p class="submit">
520
+ <input type="submit" id="submit_button" name="submit_button" class="button-primary" value="<?php _e('Save Changes') ?>" />
521
+ </p>
522
+
523
+ </form>
524
+
525
+
526
+ </div>
527
+ <?php
528
+ }
529
+
530
+ function cnss_social_icon_page_fn() {
531
+
532
+ global $wpdb;
533
+
534
+ $cnss_width = get_option('cnss-width');
535
+ $cnss_height = get_option('cnss-height');
536
+
537
+ $image_file_path = "../wp-content/uploads/";
538
+ $table_name = $wpdb->prefix . "cn_social_icon";
539
+ $sql = "SELECT * FROM ".$table_name." WHERE 1 ORDER BY sortorder";
540
+ $video_info = $wpdb->get_results($sql);
541
+ ?>
542
+ <div class="wrap">
543
+ <h2>Manage Icons</h2>
544
+ <script type="text/javascript">
545
+ function show_confirm(title, id)
546
+ {
547
+ var rpath1 = "";
548
+ var rpath2 = "";
549
+ var r=confirm('Are you confirm to delete "'+title+'"');
550
+ if (r==true)
551
+ {
552
+ rpath1 = '<?php echo $_SERVER['REQUEST_URI']; ?>';
553
+ rpath2 = '&delete=y&id='+id;
554
+ window.location = rpath1+rpath2;
555
+ }
556
+ }
557
+ </script>
558
+
559
+
560
+ <table class="widefat page fixed" cellspacing="0">
561
+
562
+ <thead>
563
+ <tr valign="top">
564
+ <th class="manage-column column-title" scope="col">Title</th>
565
+ <th class="manage-column column-title" scope="col">URL</th>
566
+ <th class="manage-column column-title" scope="col" width="100">Open In</th>
567
+ <th class="manage-column column-title" scope="col" width="100">Icon</th>
568
+ <th class="manage-column column-title" scope="col" width="50">Order</th>
569
+ <th class="manage-column column-title" scope="col" width="50">Edit</th>
570
+ <th class="manage-column column-title" scope="col" width="50">Delete</th>
571
+ </tr>
572
+ </thead>
573
+
574
+ <tbody>
575
+ <?php foreach($video_info as $vdoinfo){ ?>
576
+ <tr valign="top">
577
+ <td>
578
+ <?php echo $vdoinfo->title;?>
579
+ </td>
580
+ <td>
581
+ <?php echo $vdoinfo->url;?>
582
+ </td>
583
+ <td>
584
+ <?php echo $vdoinfo->target==1?'New Window':'Same Window' ?>
585
+ </td>
586
+
587
+ <td>
588
+ <img src="<?php echo $image_file_path.$vdoinfo->image_url;?>" border="0" width="<?php echo $cnss_width ?>" height="<?php echo $cnss_height ?>" alt="<?php echo $vdoinfo->title;?>" />
589
+ </td>
590
+
591
+ <td>
592
+ <?php echo $vdoinfo->sortorder;?>
593
+ </td>
594
+ <td>
595
+ <a href="?page=cnss_social_icon_add&mode=edit&id=<?php echo $vdoinfo->id;?>"><strong>Edit</strong></a>
596
+ </td>
597
+ <td>
598
+ <a onclick="show_confirm('<?php echo $vdoinfo->title?>','<?php echo $vdoinfo->id;?>');" href="#delete"><strong>Delete</strong></a>
599
+ </td>
600
+
601
+ </tr>
602
+ <?php }?>
603
+ </tbody>
604
+ <tfoot>
605
+ <tr valign="top">
606
+ <th class="manage-column column-title" scope="col">Title</th>
607
+ <th class="manage-column column-title" scope="col">URL</th>
608
+ <th class="manage-column column-title" scope="col" width="100">Open In</th>
609
+ <th class="manage-column column-title" scope="col" width="100">Icon</th>
610
+ <th class="manage-column column-title" scope="col" width="50">Order</th>
611
+ <th class="manage-column column-title" scope="col" width="50">Edit</th>
612
+ <th class="manage-column column-title" scope="col" width="50">Delete</th>
613
+ </tr>
614
+ </tfoot>
615
+ </table>
616
+ </div>
617
+ <?php
618
+ }
619
+
620
+ function cn_social_icon() {
621
+
622
+ $cnss_width = get_option('cnss-width');
623
+ $cnss_height = get_option('cnss-height');
624
+ $cnss_margin = get_option('cnss-margin');
625
+ $cnss_rows = get_option('cnss-row-count');
626
+ $vorh = get_option('cnss-vertical-horizontal');
627
+
628
+ $upload_dir = wp_upload_dir();
629
+ global $wpdb;
630
+ $table_name = $wpdb->prefix . "cn_social_icon";
631
+ $image_file_path = $upload_dir['baseurl'];
632
+ $sql = "SELECT * FROM ".$table_name." WHERE image_url<>'' AND url<>'' ORDER BY sortorder";
633
+ $video_info = $wpdb->get_results($sql);
634
+ $icon_count = count($video_info);
635
+
636
+ $_collectionSize = count($video_info);
637
+ $_rowCount = $cnss_rows ? $cnss_rows : 1;
638
+ $_columnCount = ceil($_collectionSize/$_rowCount);
639
+
640
+ if($vorh=='vertical')
641
+ $table_width = $cnss_width;
642
+ else
643
+ $table_width = $_columnCount*($cnss_width+$cnss_margin);
644
+ //$table_width = $icon_count*($cnss_width+$cnss_margin);
645
+
646
+ $td_width = $cnss_width+$cnss_margin;
647
+
648
+ ob_start();
649
+ echo '<table class="cnss-social-icon" style="width:'.$table_width.'px" border="0" cellspacing="0" cellpadding="0">';
650
+ //echo $vorh=='horizontal'?'<tr>':'';
651
+ $i=0;
652
+ foreach($video_info as $icon)
653
+ {
654
+ $image_url = $image_file_path.'/'.$icon->image_url;
655
+ echo $vorh=='vertical'?'<tr>':'';
656
+ if($i++%$_columnCount==0 && $vorh!='vertical' )echo '<tr>';
657
+ ?><td style="width:<?php echo $td_width ?>px"><a <?php echo ($icon->target==1)?'target="_blank"':'' ?> title="<?php echo $icon->title ?>" href="<?php echo $icon->url ?>"><img src="<?php echo $image_url?>" border="0" width="<?php echo $cnss_width ?>" height="<?php echo $cnss_height ?>" alt="<?php echo $icon->title ?>" /></a></td><?php
658
+ if ( ($i%$_columnCount==0 || $i==$_collectionSize) && $vorh!='vertical' )echo '</tr>';
659
+ echo $vorh=='vertical'?'</tr>':'';
660
+ //$i++;
661
+ }
662
+ //echo $vorh=='horizontal'?'</tr>':'';
663
+ echo '</table>';
664
+ $out = ob_get_contents();
665
+ ob_end_clean();
666
+ return $out;
667
+ }
668
+
669
+ class Cnss_Widget extends WP_Widget {
670
+
671
+ public function __construct() {
672
+ parent::__construct(
673
+ 'cnss_widget', // Base ID
674
+ 'Easy Social Icon', // Name
675
+ array( 'description' => __( 'Easy Social Icon Widget for sidebar' ) ) // Args
676
+ );
677
+ }
678
+
679
+ public function widget( $args, $instance ) {
680
+ extract( $args );
681
+ $title = apply_filters( 'widget_title', $instance['title'] );
682
+
683
+ echo $before_widget;
684
+ if ( ! empty( $title ) )
685
+ echo $before_title . $title . $after_title;
686
+ echo cn_social_icon();
687
+ echo $after_widget;
688
+ }
689
+
690
+ public function update( $new_instance, $old_instance ) {
691
+ $instance = array();
692
+ $instance['title'] = strip_tags( $new_instance['title'] );
693
+ return $instance;
694
+ }
695
+
696
+ public function form( $instance ) {
697
+ if ( isset( $instance[ 'title' ] ) ) {
698
+ $title = $instance[ 'title' ];
699
+ }
700
+ else {
701
+ $title = __( 'New title' );
702
+ }
703
+ ?>
704
+ <p>
705
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
706
+ <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 ); ?>" />
707
+ </p>
708
+ <?php
709
+ }
710
+
711
+ } // class Cnss_Widget
712
+ add_action( 'widgets_init', create_function( '', 'register_widget( "Cnss_Widget" );' ) );
713
+
714
+ add_shortcode('cn-social-icon', 'cn_social_icon');
images/icon/1368459524_facebook.png ADDED
Binary file
images/icon/1368459556_twitter.png ADDED
Binary file
images/icon/1368459641_flicker.png ADDED
Binary file
images/icon/1368459699_in.png ADDED
Binary file
images/icon/1368459724_youtube.png ADDED
Binary file
images/scc-sc.png ADDED
Binary file
js/cnss.js ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function() {
2
+ jQuery('table.cnss-social-icon tr td img').hover(function() {
3
+ jQuery(this).animate({
4
+ opacity: 0.5
5
+ //marginTop:'-5px'
6
+ }, 200 );
7
+ },
8
+ function() {
9
+ jQuery(this).animate({
10
+ opacity: 1
11
+ //marginTop:'0px'
12
+ }, 200 );
13
+ });
14
+ });
readme.txt ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Easy Social Icons ===
2
+ Contributors: cybernetikz
3
+ Donate link:
4
+ Tags: easy social icon,easy social icons,social icon,social icons,social,social share,follow,followus,follow us,share,icon
5
+ Requires at least: 2.8.6
6
+ Tested up to: 3.9.1
7
+ Stable tag: 1.0
8
+
9
+ You can upload your own social icon, set your social URL, choose weather you want to display vertical or horizontal.
10
+
11
+ == Description ==
12
+
13
+ You can upload your own social icon, set your social URL, choose weather you want to display vertical or horizontal. You can use the shortcode <strong>[cn-social-icon]</strong> in page/post, template tag for php file <strong><?php if ( function_exists('cn_social_icon') ) echo cn_social_icon(); ?></strong> also you can use the widget <strong>"Easy Social Icons"</strong> for sidebar.
14
+
15
+ > <strong>PAID SUPPORT ($30/Hr, We ACCEPT PAYPAL )</strong>
16
+ >
17
+ > We assume most of the users would find it easy to install & use this plugin but those who needs support on any of the following:
18
+ >
19
+ > <strong>a. Get the plugin installed </strong>
20
+ >
21
+ > <strong>b. Custom feature, custom theme </strong>
22
+ >
23
+ > <strong>c. Auditing your wordpress theme & hosting environment</strong>
24
+ >
25
+ > <strong>d. Google analytics & webmaster tools support</strong>
26
+ >
27
+ > <strong>e. Custom social icon set $35</strong>
28
+ >
29
+ > please send an email to this address <a href="mailto:support@cybernetikz.com">support@cybernetikz.com</a>
30
+
31
+ = Key Feature =
32
+
33
+ * You can upload your own social icons, set URL for that icon with sort order, target window etc.
34
+ * You will get the add/edit/delete option for icons
35
+ * You can set the icon width and height to fit in your template/design perfectly
36
+ * You can display your social share icon vertically or horizontally to match perfectly with your template/design.
37
+ * You can put your social icon set in the sidebar using the widget
38
+ * You can insert your social icon set in pages/posts using short code
39
+ * Sort social media icons using drag drop
40
+ * You can display the icons split by rows, input the number of rows in the plugins admin option page
41
+ * Also if you are familiar with php code then you can use the template tag to place the social icon set anywhere in the php template file
42
+ * Built in 5 social icons preloaded as sample icon, to save your time (facebook, twitter, linkedin, flickr, youtube).
43
+
44
+ Please visit our site <a target="_blank" href="http://www.cybernetikz.com/blog/wordpress-plugins-easy-social-icons/">www.cybernetikz.com/</a>
45
+
46
+ == Installation ==
47
+
48
+ 1. Download the plugin and extract the files
49
+ 2. Upload "easy-social-icons" to your wp-content/plugins/ directory
50
+ 3. Activate the plugin through the 'Plugins' menu in WordPress
51
+ 4. Check the "Easy Social Icon" Tab created by this plugins for setup.
52
+
53
+ == Frequently Asked Questions ==
54
+
55
+ = Ques : How use this plugins? =
56
+ Ans :
57
+ Use this shortcode for page/post <strong>[cn-social-icon]</strong> , for php code use this template tag <strong>&lt;?php if ( function_exists('cn_social_icon') ) echo cn_social_icon(); ?&gt;</strong>
58
+
59
+ Also you can use the widget for the sidebar.
60
+
61
+ == Screenshots ==
62
+
63
+ 1. add new icon page layout
64
+ 2. manage icons page layout
65
+ 3. options page layout
66
+ 4. display social icons vertically in sidebar using widget
67
+ 5. display social icons vertically in page using shortcode [cn-social-icon]
68
+ 6. display social icons horizontally in sidebar using widget
69
+ 7. display social icons split by number of rows
70
+ 8. sort icons usign drag drop
71
+
72
+ == Changelog ==
73
+
74
+ = 1.0 =
75
+ * Add sorting icon using drag drop
76
+ * Built in 5 social icons preloaded as sample icon, to save your time (facebook, twitter, linkedin, flickr, youtube).
77
+ * Now you can display the icons split by rows, input the number of rows in the plugins admin option page
78
+ * Css fixes
79
+ * Icons width / height adjustment fix
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
screenshot-4.png ADDED
Binary file
screenshot-5.png ADDED
Binary file
screenshot-6.png ADDED
Binary file
screenshot-7.png ADDED
Binary file
screenshot-8.png ADDED
Binary file