Sociable - Version 4.1.7

Version Description

  • FIXED: Some Fixes
Download this release

Release Info

Developer sociable
Plugin Icon wp plugin Sociable
Version 4.1.7
Comparing to
See all releases

Code changes from version 4.1.6 to 4.1.7

Files changed (4) hide show
  1. includes/skyscraper_output.php +794 -14
  2. readme.txt +7 -4
  3. screenshot-5.jpg +0 -0
  4. sociable.php +2 -2
includes/skyscraper_output.php CHANGED
@@ -1,781 +1,1561 @@
1
  <?php
2
 
 
 
3
  /*
4
 
 
 
5
  * The Output And Shortcode Functions For sociable
6
 
 
 
7
  */
8
 
9
 
 
 
 
10
  /*
11
 
 
 
12
  * Returns The Skyscraper Output For The Global $post Object Do Not
13
 
 
 
14
  */
15
 
 
 
16
  function diff_date($date1, $date2){
 
17
 
 
18
 
 
19
  $date1 = mktime(substr($date1,8,2), substr($date1,10,2), substr($date1,12,2), substr($date1,4,2), substr($date1,6,2), substr($date1,0,4));
 
20
  $date2 = mktime(substr($date2,8,2), substr($date2,10,2), substr($date2,12,2), substr($date2,4,2), substr($date2,6,2), substr($date2,0,4));
 
21
 
 
22
  $diff_time = ceil((($date2 - $date1)/60));
23
 
 
 
24
  return $diff_time;
 
25
  }
26
 
 
 
27
 
 
28
 
29
 
 
 
30
  function skyscraper_html( $where = "" ){
31
 
 
 
32
  global $skyscraper_options, $wp_query;
33
 
 
 
34
  if (!is_admin() || 1==1){
 
35
 
36
 
 
 
37
 
 
38
  // echo "<script type='text/javascript'>";
 
39
  // echo "var skyscraper_dir = '".SOCIABLE_HTTP_PATH."' ;";
 
40
  // echo "</script>";
 
41
  echo " var skyscraper_dir = document.createElement('input');
 
42
  skyscraper_dir.id = 'skyscraper_dir';
 
43
  skyscraper_dir.type = 'hidden';
 
44
  skyscraper_dir.value = '".SOCIABLE_HTTP_PATH."';
 
45
  document.body.appendChild(skyscraper_dir); ";
46
 
 
 
47
 
 
48
  $widget_width = str_replace("px", "", $skyscraper_options["widget_width"]);
 
49
 
 
50
  $widget_position = "null";
 
51
  if (isset($skyscraper_options["widget_position"])){
 
52
  $widget_position = 1;
 
53
  }
 
54
 
 
55
  $labels_color = $skyscraper_options["labels_color"];
 
56
  $text_size = str_replace("px", "", $skyscraper_options["text_size"]);
 
57
  $background_color = $skyscraper_options["background_color"];
 
58
 
 
59
  $addWhere = "";
 
60
 
 
61
  if ($where == ""){
 
62
  $addWhere = "var div = document.createElement('div');
 
63
  div.id = 'skyscraper';
 
64
  document.body.appendChild(div);";
 
65
  }
 
66
 
 
67
  $url_site= $_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
 
68
 
 
69
  $script = "
 
70
 
 
71
  if (!document.getElementById('fb-root')){
 
72
  var div = document.createElement('div');
 
73
  div.id = 'fb-root';
 
74
  document.body.appendChild(div);
 
75
  }
 
76
 
 
77
  (function(d, s, id) {
 
78
  var js, fjs = d.getElementsByTagName(s)[0];
 
79
  if (d.getElementById(id)) return;
 
80
  js = d.createElement(s); js.id = id;
 
81
  js.src = \"http://connect.facebook.net/en_US/all.js#xfbml=1\";
 
82
  fjs.parentNode.insertBefore(js, fjs);
 
83
  }(document, 'script', 'facebook-jssdk'));
 
84
 
85
 
 
 
86
  (function() {
 
87
  var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
 
88
  po.src = 'https://apis.google.com/js/plusone.js';
 
89
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
 
90
  })();
91
 
 
 
92
 
 
93
 
 
94
  (function() {
 
95
  var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
 
96
  po.src = 'http://platform.twitter.com/widgets.js';
 
97
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
 
98
  })();
 
99
 
 
100
  ".$addWhere."
 
101
 
 
102
  jQuery(document).ready(function(){
 
103
 
 
104
  oPlugin.toolbarStart('skyscraper', ".$widget_position.",230,".$widget_width.",'".$background_color."','".$labels_color."',false,'#6A6A6A',".$text_size.",'#587cc8');
 
105
 
 
106
  ".get_share_node()."
 
107
 
 
108
  ".get_counters_node()."
 
109
 
 
110
  ".get_latest_node()."
 
111
 
 
112
  ".get_mentions_node()."
 
113
 
 
114
  ".get_follow_us_node()."
 
115
 
 
116
  ".get_rss_node()."
 
117
 
 
118
  oPlugin.CreateGoToTop('New_Id_12','Go Top','<img src=\"".SOCIABLE_HTTP_PATH."images/toolbar/gototop.png\" style=\"width:30px;\" />');
 
119
 
 
120
 
 
121
  oPlugin.CreateGoToHome('New_Id_13','Go Home','<img src=\"".SOCIABLE_HTTP_PATH."images/toolbar/gotohome.png\" style=\"width:30px;\" />');
 
122
 
 
123
  });
 
124
 
 
125
 
 
126
 
 
127
  ";
 
128
 
129
 
 
 
130
  echo $script;
 
131
 
 
132
  }
 
133
  }
134
 
 
 
135
  function get_rss_node(){
136
 
 
 
137
  $rss_node = "";
 
138
  $latest_posts = "";
 
139
  global $skyscraper_options;
 
140
 
 
141
  $version = phpversion();
 
142
 
 
143
  if ( substr($version,0,1) == 5 && isset($skyscraper_options["rss_feed"]) && $skyscraper_options["rss_feed"]!="http://"){
 
144
 
 
145
  include("rss_php.php");
 
146
 
 
147
  $rss = new rss_php;
 
148
  $rss->load($skyscraper_options["rss_feed"]);
 
149
  $items = $rss->getItems();
 
150
 
 
151
  if (!empty($skyscraper_options["rss_feed"])){
 
152
 
 
153
  if (count($items) > 0){
 
154
 
 
155
  $cant = 0;
 
156
  foreach($items as $item){
 
157
 
 
158
  if ($cant <= $skyscraper_options["num_rss"]){
 
159
 
 
160
  $title="";
 
161
  if (isset($item["title"])){
 
162
  $title = addslashes($item["title"]);
 
163
  }
 
164
  $description="";
 
165
  if (isset($item["description"])){
 
166
  $description = addslashes($item["description"]);
 
167
  }
 
168
  $guid="";
 
169
  if (isset($item["link"])){
 
170
  $guid = addslashes($item["link"]);
 
171
  }
 
172
  $pubDate="";
 
173
  if (isset($item["pubDate"])){
 
174
  $pubDate = ago(strtotime($item["pubDate"]));
 
175
  }
 
176
 
 
177
  $latest_posts .= "['".$title."','','".$description."','".$guid."','".$pubDate."'],";
 
178
  }
 
179
  else{
 
180
  break;
 
181
  }
 
182
  $cant++;
 
183
  }
 
184
  $latest_posts = trim($latest_posts, ",");
 
185
  }
 
186
  }
 
187
  }
 
188
 
 
189
  if ($latest_posts != ""){
 
190
 
 
191
  $rss_node = "var LatestBlogPostContent = [
 
192
  ".$latest_posts."
 
193
  ];
 
194
  oPlugin.CreateNode('New_Id_5','Posts','',LatestBlogPostContent,'Notice',220,460);";
 
195
  }
 
196
  return $rss_node;
 
197
  }
198
 
 
 
199
  function get_latest_node(){
200
 
 
 
201
  $latest_node = "";
 
202
  global $skyscraper_options;
 
203
 
 
204
  if ( isset($skyscraper_options["twitter_username"])){
 
205
 
 
206
  $latest_tweets = get_option_tweets("skyscraper_latest");
 
207
  if ($skyscraper_options["twitter_username"] != ""){
 
208
 
 
209
  if ($latest_tweets != ""){
 
210
 
 
211
  $latest_node = "var LastestTwittsContent = [
 
212
  ".$latest_tweets."
 
213
  ];
 
214
 
 
215
  oPlugin.CreateNode('New_Id_3','Latest','',LastestTwittsContent,'Notice',220,460);";
 
216
  }
 
217
  }
 
218
  }
 
219
  return $latest_node;
 
220
  }
221
 
 
 
222
  function get_mentions_node(){
223
 
 
 
224
  $mentions_node = "";
 
225
 
 
226
  global $skyscraper_options;
 
227
 
 
228
  if ( isset($skyscraper_options["twitter_username"])){
 
229
 
 
230
  $mentions_tweets = get_option_tweets("skyscraper_mentions");
 
231
  if ($skyscraper_options["twitter_username"] != ""){
 
232
 
 
233
  if ($mentions_tweets != "" ){
 
234
 
 
235
  $mentions_node = "var TweetsMentionsContent = [
 
236
  ".$mentions_tweets."
 
237
  ];
 
238
  oPlugin.CreateNode('New_Id_4','Mentions','',TweetsMentionsContent,'Notice',220,460);";
 
239
  }
 
240
  }
 
241
  }
 
242
  return $mentions_node;
 
243
  }
244
 
 
 
245
  function get_counters_node(){
 
246
 
 
247
  global $skyscraper_options;
 
248
  global $title_shared;
 
249
  global $url_shares;
 
250
 
 
251
  $counters_node = "";
252
 
 
 
253
  /*
 
254
 
 
255
  <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script><span><a href="http://twitter.com/share" style="color:#ffffff" class="twitter-share-button" data-url="" data-text="" data-count="vertical" data-via="gBrowser" data-lang="en">Tweet</a></span>
 
256
 
 
257
  */
 
258
  if ((!empty($skyscraper_options["counters"]["check"]))){
 
259
 
260
- $counters_node = " var url = '". addslashes($url_shares)."';
261
- var title = '".addslashes($title_shared)."';
 
 
 
262
 
 
263
  var counter = '<table align=\"center\" cellspacing=\"0\" cellpadding=\"0\" ><tr><td style=\"height:72px;width:50px;\" align=\"center\">';
 
264
  counter += '<div class=\"fb-like\" data-send=\"false\" data-layout=\"box_count\" data-width=\"50\" data-href=\"'+url+'\" data-show-faces=\"false\"></div>';
 
265
  counter += '</td></tr>';
 
266
  counter += '<tr><td align=\"center\">';
 
267
  counter +=' <div class=\"g-plusone\" data-size=\"tall\" data-href=\"'+url+'\"></div>';
 
268
  counter += '</td></tr>';
 
269
  counter += '<tr><td align=\"center\" style=\"height:72px\">';
 
270
  counter += '<a href=\"https://twitter.com/share\" data-with=\"50\" data-text=\"'+ title +' (via @sociablesite)\" data-url=\"'+ url + '\" class=\"twitter-share-button\" data-count=\"vertical\">Tweet</a>';
 
271
  counter += '</td></tr>';
 
272
  counter += '</table>';
 
273
 
 
274
  oPlugin.CreateSimpleNode('New_Id_2','Counters<br/>', counter ,".$skyscraper_options["counters"]["folded"].");
 
275
  ";
 
276
  }
 
277
 
 
278
  return $counters_node;
279
 
 
 
280
  }
281
 
 
 
282
  function get_share_node(){
 
283
 
 
284
  global $skyscraper_options;
 
285
 
 
286
  $share_node = "";
 
287
 
 
288
  if (!empty($skyscraper_options["share"]["check"])){
289
 
 
 
290
  $share_buttons = share_links();
 
291
  $share_node = "oPlugin.CreateSimpleNode('New_Id_1','Share', '".$share_buttons."',".$skyscraper_options["share"]["folded"].");";
 
292
  }
 
293
 
 
294
  return $share_node;
295
 
 
 
296
  }
297
 
 
 
298
  function get_follow_us_node(){
299
 
 
 
300
  $follow_us_node = "";
 
301
  global $skyscraper_options;
 
302
 
 
303
  if (isset($skyscraper_options["follow_us"])){
 
304
 
 
305
  $follow_info = empty_accounts();
 
306
 
 
307
  if ( $follow_info["active"] > 0 && ($follow_info["empty"] < $follow_info["active"])){
 
308
 
 
309
  $follow_us_node = "oPlugin.CreateNode('New_Id_6','Follow', '', '".follow_links()."','Plano',40,140)";
 
310
  }
 
311
  }
 
312
  return $follow_us_node;
 
313
  }
314
 
 
 
315
  function empty_accounts(){
316
 
 
 
317
  $empty = 0;
 
318
  $active = 0;
 
319
  global $skyscraper_options;
 
320
 
 
321
  foreach($skyscraper_options["follow_us"] as $follow_us){
 
322
 
 
323
  if (empty($follow_us["account"])){
 
324
  $empty++;
 
325
  }
 
326
 
 
327
  if (isset($follow_us["active"])){
 
328
  $active++;
 
329
  }
 
330
  }
 
331
 
 
332
  return array("empty" =>$empty, "active"=>$active);
 
333
  }
334
 
 
 
335
  function follow_links(){
336
 
 
 
337
  global $skyscraper_options;
 
338
 
 
339
  $follow_buttons = "";
 
340
 
 
341
  foreach($skyscraper_options["follow_us"] as $follow_us){
 
342
 
 
343
  $follow_us["account"]= trim($follow_us["account"]);
 
344
 
 
345
  if (!empty($follow_us["active"]) && !empty($follow_us["account"]) ){
 
346
 
 
347
  $follow_us["account"] = str_replace("http://", "", $follow_us["account"]);
 
348
  $follow_us["account"] = "http://".$follow_us["account"];
 
349
 
 
350
  $follow_buttons .= "<a target=\'_blank\' rel=\'nofollow\' href=\'".$follow_us["account"]."\'><img src=\'".SOCIABLE_HTTP_PATH."images/toolbar/".$follow_us["logo"]."\' /></a>";
 
351
  }
 
352
  }
 
353
 
 
354
  return $follow_buttons;
 
355
  }
356
 
 
 
357
  function share_links(){
 
358
 
359
- $url = get_bloginfo('wpurl');
360
- $blogname = get_bloginfo('name');
361
-
 
 
 
362
  global $title_shared;
 
363
  global $url_shares;
 
364
 
365
- $page = $url_shares;
366
- $permalink = $url_shares;
 
 
 
 
 
 
 
 
367
 
368
- $title = $title_shared;
369
 
370
 
 
371
  $share_links = array();
 
372
  $share_links = array(
 
373
 
 
374
  "twitter" => array('favicon' => 't.png',
 
375
  'url' => 'http://twitter.com/intent/tweet?text='.$title.'%20-%20'.$permalink.'%20(via%20@sociablesite)',
 
376
  'title' => "Share on Twitter"),
 
377
 
 
378
  "facebook" => array('favicon' => 'f.png',
 
379
  'url' => 'http://www.facebook.com/share.php?u='.$permalink.'&amp;t='.$title.'',
 
380
  'title' => "Share on Facebook"),
 
381
 
 
382
  "google" => array('favicon' => 'g.png',
 
383
  'url' => 'https://mail.google.com/mail/?view=cm&fs=1&to&su='.$title.'&body='.$permalink.'&ui=2&tf=1&shva=1',
 
384
  'title' => "Share on Gmail"),
 
385
 
 
386
  "favorites" => array('favicon' => 'fv.png',
 
387
  'url' => 'javascript:AddToFavorites();',
 
388
  'title' => "Add to favorites - doesn\'t work in Chrome"),
 
389
 
 
390
  "stumble" => array('favicon' => 's.png',
 
391
  'url' => 'http://www.stumbleupon.com/submit?url='.$permalink.'&title='.$title.'',
 
392
  'title' => "Share on StumpleUpon"),
 
393
 
 
394
  "delicious" => array('favicon' => 'o.png',
 
395
  'url' => 'http://delicious.com/post?url='.$permalink.'&amp;title='.$title.'&amp;notes=EXCERPT',
 
396
  "title" => "Share on delicious"),
 
397
 
 
398
  "reader" => array('favicon' => 'n.png',
 
399
  'url' => 'http://www.google.com/reader/link?url='.$permalink.'&amp;title='.$title.'&amp;srcURL='.$permalink.'&amp;srcTitle='.$blogname.'',
 
400
  "title" => "Share on Google Reader"),
 
401
 
 
402
  "linkedin" => array('favicon' => 'i.png',
 
403
  'url' => 'http://www.linkedin.com/shareArticle?mini=true&amp;url='.$permalink.'&amp;title='.$title.'&amp;source='.$blogname.'&amp;summary=EXCERPT',
 
404
  "title" => "Share on LinkedIn")
 
405
 
 
406
  );
 
407
 
 
408
  $share_buttons = "";
 
409
 
 
410
  foreach($share_links as $link){
 
411
 
412
- $share_buttons .= "<a target=\'_blank\' rel=\'nofollow\' href=\'".$link["url"]."\' title=\'".$link["title"]."\'><img src=\'".SOCIABLE_HTTP_PATH."images/toolbar/".$link["favicon"]."\' /></a>";
 
 
413
  }
 
414
 
 
415
  return $share_buttons;
 
416
  }
417
 
418
 
419
 
 
 
 
 
420
  /*
421
 
 
 
422
  * Template Tag To Echo The Sociable 2 HTML
423
 
 
 
424
  */
425
 
 
 
426
  function do_skyscraper(){
427
 
 
 
428
  echo skyscraper_html();
429
 
 
 
430
  }
431
 
432
 
433
 
 
 
 
 
434
  /*
435
 
 
 
436
  * Sociable 2 Shortcode
437
 
 
 
438
  */
439
 
 
 
440
  function skyscraper_shortcode(){
441
 
 
 
442
  return skyscraper_html();
443
 
 
 
444
  }
445
 
 
 
446
  function auto_skyscraper($content){
 
447
 
 
448
  global $skyscraper_options;
 
449
 
 
450
  if( ! isset( $skyscraper_options['active'] ) ){
 
451
 
 
452
  $content = "";
 
453
  return $content;
 
454
  }
 
455
 
 
456
 
 
457
  if( ! isset( $skyscraper_options['locations'] ) || ! is_array( $skyscraper_options['locations'] ) || empty( $skyscraper_options['locations'] ) ){
 
458
 
 
459
  $content = "";
460
 
 
 
461
  } else {
 
462
 
 
463
  $locations = $skyscraper_options['locations'];
464
 
 
 
465
  }
466
 
 
 
467
  /*
468
 
 
 
469
  * Determine if we are supposed to be displaying the output here.
470
 
 
 
471
  */
472
 
 
 
473
  $display = false;
474
 
 
 
475
 
476
 
 
 
477
  /*
478
 
 
 
479
  * is_single is a unique case it still returning true
480
 
 
 
481
  */
 
482
 
483
 
 
 
484
  //If We Can Verify That We are in the correct loaction, simply add something to the $display array, and test for a true result to continue.
485
 
 
 
486
  foreach( $locations as $location => $val ){
 
487
 
488
 
 
 
489
  //First We Handle is_single() so it returning true on Single Post Type Pages is not an issue, this is not the intended functionality of this plugin
490
 
 
 
491
  if( $location == 'is_single' ){
492
 
 
 
493
  //If we are not in a post, lets ignore this one for now
494
 
 
 
495
  if( is_single() && get_post_type() == 'post' ){
496
 
 
 
497
  $display = true;
498
 
 
 
499
  break;
500
 
 
 
501
  } else {
502
 
 
 
503
  continue; // So not to trigger is_single later in this loop, but still be allowed to handle others
504
 
 
 
505
  }
506
 
 
 
507
 
508
 
 
 
509
  } elseif( strpos( $location , 'is_single_posttype_' ) === 0 ){ //Now We Need To Check For The Variable Names, Taxonomy Archives, Post Type Archives and Single Custom Post Types.
510
 
 
 
511
 
512
 
 
 
513
  //Single Custom Post Type
514
 
 
 
515
  $post_type = str_replace( 'is_single_posttype_' , '' , $location );
516
 
 
 
517
  if( is_single() && get_post_type() == $post_type ){
518
 
519
- $display = true;
520
 
521
- break;
522
 
523
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
524
 
525
 
526
 
527
- } elseif( strpos( $location , 'is_posttype_archive_' ) === 0 ){
528
 
529
-
530
 
531
  //Custom Post Type Archive
532
 
 
 
533
  $post_type = str_replace( 'is_posttype_archive_' , '' , $location );
534
 
 
 
535
  if( is_post_type_archive( $post_type ) ){
536
 
 
 
537
  $display = true;
538
 
 
 
539
  break;
540
 
 
 
541
  }
542
 
 
 
543
 
544
 
 
 
545
  } elseif( strpos( $location , 'is_taxonomy_archive_' ) === 0 ) {
546
 
 
 
547
 
548
 
 
 
549
  //Taxonomy Archive
550
 
 
 
551
  $taxonomy = str_replace( 'is_taxonomy_archive_' , '' , $location );
552
 
 
 
553
  if( is_tax( $taxonomy ) ){
554
 
 
 
555
  $display = true;
556
 
 
 
557
  break;
558
 
 
 
559
  }
560
 
 
 
561
 
562
 
 
 
563
  } elseif( function_exists( $location ) ) {
564
 
 
 
565
 
566
 
 
 
567
  //Standard conditional tag, these will return BOOL
568
 
 
 
569
  if( call_user_func( $location ) === true ){
570
 
 
 
571
  $display = true;
572
 
 
 
573
  break;
574
 
 
 
575
  }
576
 
 
 
577
 
578
 
 
 
579
  } else {
580
 
 
 
581
  continue;
582
 
 
 
583
  }
584
 
 
 
585
 
586
 
 
 
587
 
588
 
 
 
589
  }
590
 
 
 
591
 
592
 
 
 
593
  //If We have passed all the checks and are looking in the right place lets do this thang
594
 
 
 
595
  if( isset( $skyscraper_options['automatic_mode'] ) && $display === true ){
596
 
 
 
597
  if (isset($skyscraper_options["topandbottom"])){
598
 
 
 
599
  $content = skyscraper_html();
600
 
 
 
601
  }else{
602
 
 
 
603
  $content = skyscraper_html();
604
 
 
 
605
  }
606
 
 
 
607
  }
 
608
  else{
 
609
  $content = skyscraper_html();
 
610
  }
 
611
 
 
612
 
613
 
 
 
614
 
615
 
 
 
616
  return $content;
 
617
  }
618
 
619
 
 
 
 
620
  function get_tweets_username($username_complete){
 
621
 
 
622
  if (function_exists('curl_init')) {
 
623
 
 
624
  // last tweets
 
625
  $username = str_replace("@", "", $username_complete);
 
626
  $url = "https://api.twitter.com/1/statuses/user_timeline/".$username.".json";
 
627
  $latest = curl_call($url);
 
628
  $latest_row = parser_twitter_results($latest,0);
 
629
  update_option( "skyscraper_latest", $latest_row );
 
630
 
 
631
  // last mentions
 
632
  $url = "http://search.twitter.com/search.json?q=@".$username."&rpp=5&include_entities=true&result_type=mixed";
 
633
  $mentions = curl_call($url);
 
634
 
 
635
  if (count($mentions["results"]) > 1){
 
636
 
 
637
  $mentions_row = parser_twitter_results($mentions["results"],1);
 
638
  update_option( "skyscraper_mentions", $mentions_row );
 
639
  }
 
640
  }
 
641
  }
642
 
 
 
643
  function ago($time){
644
 
 
 
645
  $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
 
646
  $lengths = array("60","60","24","7","4.35","12","10");
647
 
 
 
648
  $now = time();
649
 
 
 
650
  $difference = $now - $time;
 
651
  $tense = "ago";
652
 
 
 
653
  for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
 
654
  $difference /= $lengths[$j];
 
655
  }
656
 
 
 
657
  $difference = round($difference);
658
 
 
 
659
  if($difference != 1) {
 
660
  $periods[$j].= "s";
 
661
  }
662
 
 
 
663
  return $difference." ".$periods[$j]."ago";
 
664
  }
665
 
666
 
 
 
 
667
  function parser_twitter_results($results = array(), $mention){
 
668
 
 
669
  $options_latest = array();
 
670
  $options_latest = array("date" => date("YmdHis"));
 
671
  global $skyscraper_options;
 
672
  $i = 0;
 
673
 
 
674
  if (is_array($results)){
 
675
 
 
676
  foreach($results as $tweet){
 
677
 
 
678
  $options_latest[$i] = array();
 
679
  $options_latest[$i]["text"] = $tweet["text"];
 
680
  $options_latest[$i]["created_at"] = ago(strtotime($tweet["created_at"]));
 
681
 
 
682
  if ($mention){
 
683
  $options_latest[$i]["name"] = $tweet["from_user_name"];
 
684
  }
 
685
  else{
 
686
  $options_latest[$i]["name"] = $tweet["user"]["name"];
 
687
  }
 
688
 
 
689
  $i++;
 
690
  if ($i == $skyscraper_options["num_tweets"]){
 
691
  break;
 
692
  }
 
693
  }
 
694
  }
 
695
 
 
696
  return $options_latest;
 
697
  }
698
 
 
 
699
  function curl_call($url){
 
700
 
 
701
  $ch = curl_init();
 
702
  curl_setopt($ch, CURLOPT_URL, $url);
 
703
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
704
  curl_setopt($ch, CURLOPT_TIMEOUT, 3);
 
705
  curl_setopt($ch, CURLINFO_HEADER_OUT, true);
 
706
  $output = curl_exec($ch);
 
707
  $info = curl_getinfo($ch);
 
708
  curl_close($ch);
 
709
 
 
710
  if ($info["http_code"] == "200"){
 
711
 
 
712
  $return = json_decode($output,1);
 
713
  }
 
714
  else{
 
715
  $return = false;
 
716
  }
 
717
 
 
718
  return $return;
 
719
  }
720
 
 
 
721
  function get_option_tweets($option){
 
722
 
 
723
  global $skyscraper_options;
 
724
  $skyscraper_latest = get_option($option);
 
725
 
 
726
  if (empty($skyscraper_latest)){
 
727
 
 
728
  get_tweets_username($skyscraper_options["twitter_username"]);
 
729
  $skyscraper_latest = get_option($option);
 
730
  }
 
731
  else{
 
732
 
 
733
  // 5 minutes
 
734
  if (diff_date($skyscraper_latest["date"], date("YmdHis")) > 5){
 
735
 
 
736
  get_tweets_username($skyscraper_options["twitter_username"]);
 
737
  $skyscraper_latest = get_option($option);
 
738
  }
 
739
  }
 
740
 
 
741
 
 
742
  return generate_tweets_box_content($skyscraper_latest);
 
743
  }
744
 
 
 
745
  function generate_tweets_box_content($tweets){
746
 
 
 
747
  $content = "";
 
748
  if (isset($tweets["date"])){
 
749
  unset($tweets["date"]);
 
750
  }
 
751
 
 
752
 
 
753
  foreach($tweets as $tweet){
 
754
 
 
755
  $tweet["name"] = addslashes($tweet["name"]);
 
756
  $tweet["text"] = addslashes($tweet["text"]);
 
757
 
 
758
  $content .= "['".$tweet["name"]."','".$tweet["name"]."','".$tweet["text"]."','','".$tweet["created_at"]."'],";
 
759
  }
 
760
  $content = trim(trim(trim($content), ","));
 
761
 
 
762
  return $content;
 
763
  }
764
 
 
 
765
  if (!empty($_GET["sky"])){
766
 
 
 
767
  add_action('wp_ajax_my_action', 'my_action_callback');
768
 
 
 
769
  function my_action_callback() {
 
770
  global $wpdb; global $skyscraper_options; // this is how you get access to the database
771
 
 
 
772
  $whatever = intval( $_POST['whatever'] );
773
 
 
 
774
  $whatever += 10;
775
 
 
 
776
  echo $whatever;
777
 
 
 
778
  die(); // this is required to return a proper result
 
779
  }
 
780
  }
 
781
  ?>
1
  <?php
2
 
3
+
4
+
5
  /*
6
 
7
+
8
+
9
  * The Output And Shortcode Functions For sociable
10
 
11
+
12
+
13
  */
14
 
15
 
16
+
17
+
18
+
19
  /*
20
 
21
+
22
+
23
  * Returns The Skyscraper Output For The Global $post Object Do Not
24
 
25
+
26
+
27
  */
28
 
29
+
30
+
31
  function diff_date($date1, $date2){
32
+
33
 
34
+
35
 
36
+
37
  $date1 = mktime(substr($date1,8,2), substr($date1,10,2), substr($date1,12,2), substr($date1,4,2), substr($date1,6,2), substr($date1,0,4));
38
+
39
  $date2 = mktime(substr($date2,8,2), substr($date2,10,2), substr($date2,12,2), substr($date2,4,2), substr($date2,6,2), substr($date2,0,4));
40
+
41
 
42
+
43
  $diff_time = ceil((($date2 - $date1)/60));
44
 
45
+
46
+
47
  return $diff_time;
48
+
49
  }
50
 
51
+
52
+
53
 
54
+
55
 
56
 
57
+
58
+
59
  function skyscraper_html( $where = "" ){
60
 
61
+
62
+
63
  global $skyscraper_options, $wp_query;
64
 
65
+
66
+
67
  if (!is_admin() || 1==1){
68
+
69
 
70
 
71
+
72
+
73
 
74
+
75
  // echo "<script type='text/javascript'>";
76
+
77
  // echo "var skyscraper_dir = '".SOCIABLE_HTTP_PATH."' ;";
78
+
79
  // echo "</script>";
80
+
81
  echo " var skyscraper_dir = document.createElement('input');
82
+
83
  skyscraper_dir.id = 'skyscraper_dir';
84
+
85
  skyscraper_dir.type = 'hidden';
86
+
87
  skyscraper_dir.value = '".SOCIABLE_HTTP_PATH."';
88
+
89
  document.body.appendChild(skyscraper_dir); ";
90
 
91
+
92
+
93
 
94
+
95
  $widget_width = str_replace("px", "", $skyscraper_options["widget_width"]);
96
+
97
 
98
+
99
  $widget_position = "null";
100
+
101
  if (isset($skyscraper_options["widget_position"])){
102
+
103
  $widget_position = 1;
104
+
105
  }
106
+
107
 
108
+
109
  $labels_color = $skyscraper_options["labels_color"];
110
+
111
  $text_size = str_replace("px", "", $skyscraper_options["text_size"]);
112
+
113
  $background_color = $skyscraper_options["background_color"];
114
+
115
 
116
+
117
  $addWhere = "";
118
+
119
 
120
+
121
  if ($where == ""){
122
+
123
  $addWhere = "var div = document.createElement('div');
124
+
125
  div.id = 'skyscraper';
126
+
127
  document.body.appendChild(div);";
128
+
129
  }
130
+
131
 
132
+
133
  $url_site= $_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"];
134
+
135
 
136
+
137
  $script = "
138
+
139
 
140
+
141
  if (!document.getElementById('fb-root')){
142
+
143
  var div = document.createElement('div');
144
+
145
  div.id = 'fb-root';
146
+
147
  document.body.appendChild(div);
148
+
149
  }
150
+
151
 
152
+
153
  (function(d, s, id) {
154
+
155
  var js, fjs = d.getElementsByTagName(s)[0];
156
+
157
  if (d.getElementById(id)) return;
158
+
159
  js = d.createElement(s); js.id = id;
160
+
161
  js.src = \"http://connect.facebook.net/en_US/all.js#xfbml=1\";
162
+
163
  fjs.parentNode.insertBefore(js, fjs);
164
+
165
  }(document, 'script', 'facebook-jssdk'));
166
+
167
 
168
 
169
+
170
+
171
  (function() {
172
+
173
  var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
174
+
175
  po.src = 'https://apis.google.com/js/plusone.js';
176
+
177
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
178
+
179
  })();
180
 
181
+
182
+
183
 
184
+
185
 
186
+
187
  (function() {
188
+
189
  var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
190
+
191
  po.src = 'http://platform.twitter.com/widgets.js';
192
+
193
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
194
+
195
  })();
196
+
197
 
198
+
199
  ".$addWhere."
200
+
201
 
202
+
203
  jQuery(document).ready(function(){
204
+
205
 
206
+
207
  oPlugin.toolbarStart('skyscraper', ".$widget_position.",230,".$widget_width.",'".$background_color."','".$labels_color."',false,'#6A6A6A',".$text_size.",'#587cc8');
208
+
209
 
210
+
211
  ".get_share_node()."
212
+
213
 
214
+
215
  ".get_counters_node()."
216
+
217
 
218
+
219
  ".get_latest_node()."
220
+
221
 
222
+
223
  ".get_mentions_node()."
224
+
225
 
226
+
227
  ".get_follow_us_node()."
228
+
229
 
230
+
231
  ".get_rss_node()."
232
+
233
 
234
+
235
  oPlugin.CreateGoToTop('New_Id_12','Go Top','<img src=\"".SOCIABLE_HTTP_PATH."images/toolbar/gototop.png\" style=\"width:30px;\" />');
236
+
237
 
238
+
239
 
240
+
241
  oPlugin.CreateGoToHome('New_Id_13','Go Home','<img src=\"".SOCIABLE_HTTP_PATH."images/toolbar/gotohome.png\" style=\"width:30px;\" />');
242
+
243
 
244
+
245
  });
246
+
247
 
248
+
249
 
250
+
251
 
252
+
253
  ";
254
+
255
 
256
 
257
+
258
+
259
  echo $script;
260
+
261
 
262
+
263
  }
264
+
265
  }
266
 
267
+
268
+
269
  function get_rss_node(){
270
 
271
+
272
+
273
  $rss_node = "";
274
+
275
  $latest_posts = "";
276
+
277
  global $skyscraper_options;
278
+
279
 
280
+
281
  $version = phpversion();
282
+
283
 
284
+
285
  if ( substr($version,0,1) == 5 && isset($skyscraper_options["rss_feed"]) && $skyscraper_options["rss_feed"]!="http://"){
286
+
287
 
288
+
289
  include("rss_php.php");
290
+
291
 
292
+
293
  $rss = new rss_php;
294
+
295
  $rss->load($skyscraper_options["rss_feed"]);
296
+
297
  $items = $rss->getItems();
298
+
299
 
300
+
301
  if (!empty($skyscraper_options["rss_feed"])){
302
+
303
 
304
+
305
  if (count($items) > 0){
306
+
307
 
308
+
309
  $cant = 0;
310
+
311
  foreach($items as $item){
312
+
313
 
314
+
315
  if ($cant <= $skyscraper_options["num_rss"]){
316
+
317
 
318
+
319
  $title="";
320
+
321
  if (isset($item["title"])){
322
+
323
  $title = addslashes($item["title"]);
324
+
325
  }
326
+
327
  $description="";
328
+
329
  if (isset($item["description"])){
330
+
331
  $description = addslashes($item["description"]);
332
+
333
  }
334
+
335
  $guid="";
336
+
337
  if (isset($item["link"])){
338
+
339
  $guid = addslashes($item["link"]);
340
+
341
  }
342
+
343
  $pubDate="";
344
+
345
  if (isset($item["pubDate"])){
346
+
347
  $pubDate = ago(strtotime($item["pubDate"]));
348
+
349
  }
350
+
351
 
352
+
353
  $latest_posts .= "['".$title."','','".$description."','".$guid."','".$pubDate."'],";
354
+
355
  }
356
+
357
  else{
358
+
359
  break;
360
+
361
  }
362
+
363
  $cant++;
364
+
365
  }
366
+
367
  $latest_posts = trim($latest_posts, ",");
368
+
369
  }
370
+
371
  }
372
+
373
  }
374
+
375
 
376
+
377
  if ($latest_posts != ""){
378
+
379
 
380
+
381
  $rss_node = "var LatestBlogPostContent = [
382
+
383
  ".$latest_posts."
384
+
385
  ];
386
+
387
  oPlugin.CreateNode('New_Id_5','Posts','',LatestBlogPostContent,'Notice',220,460);";
388
+
389
  }
390
+
391
  return $rss_node;
392
+
393
  }
394
 
395
+
396
+
397
  function get_latest_node(){
398
 
399
+
400
+
401
  $latest_node = "";
402
+
403
  global $skyscraper_options;
404
+
405
 
406
+
407
  if ( isset($skyscraper_options["twitter_username"])){
408
+
409
 
410
+
411
  $latest_tweets = get_option_tweets("skyscraper_latest");
412
+
413
  if ($skyscraper_options["twitter_username"] != ""){
414
+
415
 
416
+
417
  if ($latest_tweets != ""){
418
+
419
 
420
+
421
  $latest_node = "var LastestTwittsContent = [
422
+
423
  ".$latest_tweets."
424
+
425
  ];
426
+
427
 
428
+
429
  oPlugin.CreateNode('New_Id_3','Latest','',LastestTwittsContent,'Notice',220,460);";
430
+
431
  }
432
+
433
  }
434
+
435
  }
436
+
437
  return $latest_node;
438
+
439
  }
440
 
441
+
442
+
443
  function get_mentions_node(){
444
 
445
+
446
+
447
  $mentions_node = "";
448
+
449
 
450
+
451
  global $skyscraper_options;
452
+
453
 
454
+
455
  if ( isset($skyscraper_options["twitter_username"])){
456
+
457
 
458
+
459
  $mentions_tweets = get_option_tweets("skyscraper_mentions");
460
+
461
  if ($skyscraper_options["twitter_username"] != ""){
462
+
463
 
464
+
465
  if ($mentions_tweets != "" ){
466
+
467
 
468
+
469
  $mentions_node = "var TweetsMentionsContent = [
470
+
471
  ".$mentions_tweets."
472
+
473
  ];
474
+
475
  oPlugin.CreateNode('New_Id_4','Mentions','',TweetsMentionsContent,'Notice',220,460);";
476
+
477
  }
478
+
479
  }
480
+
481
  }
482
+
483
  return $mentions_node;
484
+
485
  }
486
 
487
+
488
+
489
  function get_counters_node(){
490
+
491
 
492
+
493
  global $skyscraper_options;
494
+
495
  global $title_shared;
496
+
497
  global $url_shares;
498
+
499
 
500
+
501
  $counters_node = "";
502
 
503
+
504
+
505
  /*
506
+
507
 
508
+
509
  <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script><span><a href="http://twitter.com/share" style="color:#ffffff" class="twitter-share-button" data-url="" data-text="" data-count="vertical" data-via="gBrowser" data-lang="en">Tweet</a></span>
510
+
511
 
512
+
513
  */
514
+
515
  if ((!empty($skyscraper_options["counters"]["check"]))){
516
+
517
 
518
+
519
+ $counters_node = " var url = '". addslashes(trim($url_shares))."';
520
+
521
+ var title = '".addslashes(trim($title_shared)) ."';
522
+
523
 
524
+
525
  var counter = '<table align=\"center\" cellspacing=\"0\" cellpadding=\"0\" ><tr><td style=\"height:72px;width:50px;\" align=\"center\">';
526
+
527
  counter += '<div class=\"fb-like\" data-send=\"false\" data-layout=\"box_count\" data-width=\"50\" data-href=\"'+url+'\" data-show-faces=\"false\"></div>';
528
+
529
  counter += '</td></tr>';
530
+
531
  counter += '<tr><td align=\"center\">';
532
+
533
  counter +=' <div class=\"g-plusone\" data-size=\"tall\" data-href=\"'+url+'\"></div>';
534
+
535
  counter += '</td></tr>';
536
+
537
  counter += '<tr><td align=\"center\" style=\"height:72px\">';
538
+
539
  counter += '<a href=\"https://twitter.com/share\" data-with=\"50\" data-text=\"'+ title +' (via @sociablesite)\" data-url=\"'+ url + '\" class=\"twitter-share-button\" data-count=\"vertical\">Tweet</a>';
540
+
541
  counter += '</td></tr>';
542
+
543
  counter += '</table>';
544
+
545
 
546
+
547
  oPlugin.CreateSimpleNode('New_Id_2','Counters<br/>', counter ,".$skyscraper_options["counters"]["folded"].");
548
+
549
  ";
550
+
551
  }
552
+
553
 
554
+
555
  return $counters_node;
556
 
557
+
558
+
559
  }
560
 
561
+
562
+
563
  function get_share_node(){
564
+
565
 
566
+
567
  global $skyscraper_options;
568
+
569
 
570
+
571
  $share_node = "";
572
+
573
 
574
+
575
  if (!empty($skyscraper_options["share"]["check"])){
576
 
577
+
578
+
579
  $share_buttons = share_links();
580
+
581
  $share_node = "oPlugin.CreateSimpleNode('New_Id_1','Share', '".$share_buttons."',".$skyscraper_options["share"]["folded"].");";
582
+
583
  }
584
+
585
 
586
+
587
  return $share_node;
588
 
589
+
590
+
591
  }
592
 
593
+
594
+
595
  function get_follow_us_node(){
596
 
597
+
598
+
599
  $follow_us_node = "";
600
+
601
  global $skyscraper_options;
602
+
603
 
604
+
605
  if (isset($skyscraper_options["follow_us"])){
606
+
607
 
608
+
609
  $follow_info = empty_accounts();
610
+
611
 
612
+
613
  if ( $follow_info["active"] > 0 && ($follow_info["empty"] < $follow_info["active"])){
614
+
615
 
616
+
617
  $follow_us_node = "oPlugin.CreateNode('New_Id_6','Follow', '', '".follow_links()."','Plano',40,140)";
618
+
619
  }
620
+
621
  }
622
+
623
  return $follow_us_node;
624
+
625
  }
626
 
627
+
628
+
629
  function empty_accounts(){
630
 
631
+
632
+
633
  $empty = 0;
634
+
635
  $active = 0;
636
+
637
  global $skyscraper_options;
638
+
639
 
640
+
641
  foreach($skyscraper_options["follow_us"] as $follow_us){
642
+
643
 
644
+
645
  if (empty($follow_us["account"])){
646
+
647
  $empty++;
648
+
649
  }
650
+
651
 
652
+
653
  if (isset($follow_us["active"])){
654
+
655
  $active++;
656
+
657
  }
658
+
659
  }
660
+
661
 
662
+
663
  return array("empty" =>$empty, "active"=>$active);
664
+
665
  }
666
 
667
+
668
+
669
  function follow_links(){
670
 
671
+
672
+
673
  global $skyscraper_options;
674
+
675
 
676
+
677
  $follow_buttons = "";
678
+
679
 
680
+
681
  foreach($skyscraper_options["follow_us"] as $follow_us){
682
+
683
 
684
+
685
  $follow_us["account"]= trim($follow_us["account"]);
686
+
687
 
688
+
689
  if (!empty($follow_us["active"]) && !empty($follow_us["account"]) ){
690
+
691
 
692
+
693
  $follow_us["account"] = str_replace("http://", "", $follow_us["account"]);
694
+
695
  $follow_us["account"] = "http://".$follow_us["account"];
696
+
697
 
698
+
699
  $follow_buttons .= "<a target=\'_blank\' rel=\'nofollow\' href=\'".$follow_us["account"]."\'><img src=\'".SOCIABLE_HTTP_PATH."images/toolbar/".$follow_us["logo"]."\' /></a>";
700
+
701
  }
702
+
703
  }
704
+
705
 
706
+
707
  return $follow_buttons;
708
+
709
  }
710
 
711
+
712
+
713
  function share_links(){
714
+
715
 
716
+
717
+ $url = addslashes(get_bloginfo('wpurl'));
718
+
719
+ $blogname = addslashes(get_bloginfo('name'));
720
+
721
+
722
  global $title_shared;
723
+
724
  global $url_shares;
725
+
726
 
727
+
728
+
729
+ $page = trim(addslashes($url_shares));
730
+
731
+ $permalink = trim(addslashes($url_shares));
732
+
733
+
734
+
735
+ $title = trim(addslashes($title_shared));
736
+
737
 
 
738
 
739
 
740
+
741
  $share_links = array();
742
+
743
  $share_links = array(
744
+
745
 
746
+
747
  "twitter" => array('favicon' => 't.png',
748
+
749
  'url' => 'http://twitter.com/intent/tweet?text='.$title.'%20-%20'.$permalink.'%20(via%20@sociablesite)',
750
+
751
  'title' => "Share on Twitter"),
752
+
753
 
754
+
755
  "facebook" => array('favicon' => 'f.png',
756
+
757
  'url' => 'http://www.facebook.com/share.php?u='.$permalink.'&amp;t='.$title.'',
758
+
759
  'title' => "Share on Facebook"),
760
+
761
 
762
+
763
  "google" => array('favicon' => 'g.png',
764
+
765
  'url' => 'https://mail.google.com/mail/?view=cm&fs=1&to&su='.$title.'&body='.$permalink.'&ui=2&tf=1&shva=1',
766
+
767
  'title' => "Share on Gmail"),
768
+
769
 
770
+
771
  "favorites" => array('favicon' => 'fv.png',
772
+
773
  'url' => 'javascript:AddToFavorites();',
774
+
775
  'title' => "Add to favorites - doesn\'t work in Chrome"),
776
+
777
 
778
+
779
  "stumble" => array('favicon' => 's.png',
780
+
781
  'url' => 'http://www.stumbleupon.com/submit?url='.$permalink.'&title='.$title.'',
782
+
783
  'title' => "Share on StumpleUpon"),
784
+
785
 
786
+
787
  "delicious" => array('favicon' => 'o.png',
788
+
789
  'url' => 'http://delicious.com/post?url='.$permalink.'&amp;title='.$title.'&amp;notes=EXCERPT',
790
+
791
  "title" => "Share on delicious"),
792
+
793
 
794
+
795
  "reader" => array('favicon' => 'n.png',
796
+
797
  'url' => 'http://www.google.com/reader/link?url='.$permalink.'&amp;title='.$title.'&amp;srcURL='.$permalink.'&amp;srcTitle='.$blogname.'',
798
+
799
  "title" => "Share on Google Reader"),
800
+
801
 
802
+
803
  "linkedin" => array('favicon' => 'i.png',
804
+
805
  'url' => 'http://www.linkedin.com/shareArticle?mini=true&amp;url='.$permalink.'&amp;title='.$title.'&amp;source='.$blogname.'&amp;summary=EXCERPT',
806
+
807
  "title" => "Share on LinkedIn")
808
+
809
 
810
+
811
  );
812
+
813
 
814
+
815
  $share_buttons = "";
816
+
817
 
818
+
819
  foreach($share_links as $link){
820
+
821
 
822
+
823
+ $share_buttons .= "<a target=\'_blank\' rel=\'nofollow\' href=\'".addslashes($link["url"])."\' title=\'".addslashes($link["title"])."\'><img src=\'".SOCIABLE_HTTP_PATH."images/toolbar/".addslashes($link["favicon"])."\' /></a>";
824
+
825
  }
826
+
827
 
828
+
829
  return $share_buttons;
830
+
831
  }
832
 
833
 
834
 
835
+
836
+
837
+
838
+
839
  /*
840
 
841
+
842
+
843
  * Template Tag To Echo The Sociable 2 HTML
844
 
845
+
846
+
847
  */
848
 
849
+
850
+
851
  function do_skyscraper(){
852
 
853
+
854
+
855
  echo skyscraper_html();
856
 
857
+
858
+
859
  }
860
 
861
 
862
 
863
+
864
+
865
+
866
+
867
  /*
868
 
869
+
870
+
871
  * Sociable 2 Shortcode
872
 
873
+
874
+
875
  */
876
 
877
+
878
+
879
  function skyscraper_shortcode(){
880
 
881
+
882
+
883
  return skyscraper_html();
884
 
885
+
886
+
887
  }
888
 
889
+
890
+
891
  function auto_skyscraper($content){
892
+
893
 
894
+
895
  global $skyscraper_options;
896
+
897
 
898
+
899
  if( ! isset( $skyscraper_options['active'] ) ){
900
+
901
 
902
+
903
  $content = "";
904
+
905
  return $content;
906
+
907
  }
908
+
909
 
910
+
911
 
912
+
913
  if( ! isset( $skyscraper_options['locations'] ) || ! is_array( $skyscraper_options['locations'] ) || empty( $skyscraper_options['locations'] ) ){
914
+
915
 
916
+
917
  $content = "";
918
 
919
+
920
+
921
  } else {
922
+
923
 
924
+
925
  $locations = $skyscraper_options['locations'];
926
 
927
+
928
+
929
  }
930
 
931
+
932
+
933
  /*
934
 
935
+
936
+
937
  * Determine if we are supposed to be displaying the output here.
938
 
939
+
940
+
941
  */
942
 
943
+
944
+
945
  $display = false;
946
 
947
+
948
+
949
 
950
 
951
+
952
+
953
  /*
954
 
955
+
956
+
957
  * is_single is a unique case it still returning true
958
 
959
+
960
+
961
  */
962
+
963
 
964
 
965
+
966
+
967
  //If We Can Verify That We are in the correct loaction, simply add something to the $display array, and test for a true result to continue.
968
 
969
+
970
+
971
  foreach( $locations as $location => $val ){
972
+
973
 
974
 
975
+
976
+
977
  //First We Handle is_single() so it returning true on Single Post Type Pages is not an issue, this is not the intended functionality of this plugin
978
 
979
+
980
+
981
  if( $location == 'is_single' ){
982
 
983
+
984
+
985
  //If we are not in a post, lets ignore this one for now
986
 
987
+
988
+
989
  if( is_single() && get_post_type() == 'post' ){
990
 
991
+
992
+
993
  $display = true;
994
 
995
+
996
+
997
  break;
998
 
999
+
1000
+
1001
  } else {
1002
 
1003
+
1004
+
1005
  continue; // So not to trigger is_single later in this loop, but still be allowed to handle others
1006
 
1007
+
1008
+
1009
  }
1010
 
1011
+
1012
+
1013
 
1014
 
1015
+
1016
+
1017
  } elseif( strpos( $location , 'is_single_posttype_' ) === 0 ){ //Now We Need To Check For The Variable Names, Taxonomy Archives, Post Type Archives and Single Custom Post Types.
1018
 
1019
+
1020
+
1021
 
1022
 
1023
+
1024
+
1025
  //Single Custom Post Type
1026
 
1027
+
1028
+
1029
  $post_type = str_replace( 'is_single_posttype_' , '' , $location );
1030
 
1031
+
1032
+
1033
  if( is_single() && get_post_type() == $post_type ){
1034
 
 
1035
 
 
1036
 
1037
+ $display = true;
1038
+
1039
+
1040
+
1041
+ break;
1042
+
1043
+
1044
+
1045
+ }
1046
+
1047
+
1048
+
1049
+
1050
+
1051
+
1052
+
1053
+ } elseif( strpos( $location , 'is_posttype_archive_' ) === 0 ){
1054
+
1055
+
1056
 
1057
 
1058
 
 
1059
 
 
1060
 
1061
  //Custom Post Type Archive
1062
 
1063
+
1064
+
1065
  $post_type = str_replace( 'is_posttype_archive_' , '' , $location );
1066
 
1067
+
1068
+
1069
  if( is_post_type_archive( $post_type ) ){
1070
 
1071
+
1072
+
1073
  $display = true;
1074
 
1075
+
1076
+
1077
  break;
1078
 
1079
+
1080
+
1081
  }
1082
 
1083
+
1084
+
1085
 
1086
 
1087
+
1088
+
1089
  } elseif( strpos( $location , 'is_taxonomy_archive_' ) === 0 ) {
1090
 
1091
+
1092
+
1093
 
1094
 
1095
+
1096
+
1097
  //Taxonomy Archive
1098
 
1099
+
1100
+
1101
  $taxonomy = str_replace( 'is_taxonomy_archive_' , '' , $location );
1102
 
1103
+
1104
+
1105
  if( is_tax( $taxonomy ) ){
1106
 
1107
+
1108
+
1109
  $display = true;
1110
 
1111
+
1112
+
1113
  break;
1114
 
1115
+
1116
+
1117
  }
1118
 
1119
+
1120
+
1121
 
1122
 
1123
+
1124
+
1125
  } elseif( function_exists( $location ) ) {
1126
 
1127
+
1128
+
1129
 
1130
 
1131
+
1132
+
1133
  //Standard conditional tag, these will return BOOL
1134
 
1135
+
1136
+
1137
  if( call_user_func( $location ) === true ){
1138
 
1139
+
1140
+
1141
  $display = true;
1142
 
1143
+
1144
+
1145
  break;
1146
 
1147
+
1148
+
1149
  }
1150
 
1151
+
1152
+
1153
 
1154
 
1155
+
1156
+
1157
  } else {
1158
 
1159
+
1160
+
1161
  continue;
1162
 
1163
+
1164
+
1165
  }
1166
 
1167
+
1168
+
1169
 
1170
 
1171
+
1172
+
1173
 
1174
 
1175
+
1176
+
1177
  }
1178
 
1179
+
1180
+
1181
 
1182
 
1183
+
1184
+
1185
  //If We have passed all the checks and are looking in the right place lets do this thang
1186
 
1187
+
1188
+
1189
  if( isset( $skyscraper_options['automatic_mode'] ) && $display === true ){
1190
 
1191
+
1192
+
1193
  if (isset($skyscraper_options["topandbottom"])){
1194
 
1195
+
1196
+
1197
  $content = skyscraper_html();
1198
 
1199
+
1200
+
1201
  }else{
1202
 
1203
+
1204
+
1205
  $content = skyscraper_html();
1206
 
1207
+
1208
+
1209
  }
1210
 
1211
+
1212
+
1213
  }
1214
+
1215
  else{
1216
+
1217
  $content = skyscraper_html();
1218
+
1219
  }
1220
+
1221
 
1222
+
1223
 
1224
 
1225
+
1226
+
1227
 
1228
 
1229
+
1230
+
1231
  return $content;
1232
+
1233
  }
1234
 
1235
 
1236
+
1237
+
1238
+
1239
  function get_tweets_username($username_complete){
1240
+
1241
 
1242
+
1243
  if (function_exists('curl_init')) {
1244
+
1245
 
1246
+
1247
  // last tweets
1248
+
1249
  $username = str_replace("@", "", $username_complete);
1250
+
1251
  $url = "https://api.twitter.com/1/statuses/user_timeline/".$username.".json";
1252
+
1253
  $latest = curl_call($url);
1254
+
1255
  $latest_row = parser_twitter_results($latest,0);
1256
+
1257
  update_option( "skyscraper_latest", $latest_row );
1258
+
1259
 
1260
+
1261
  // last mentions
1262
+
1263
  $url = "http://search.twitter.com/search.json?q=@".$username."&rpp=5&include_entities=true&result_type=mixed";
1264
+
1265
  $mentions = curl_call($url);
1266
+
1267
 
1268
+
1269
  if (count($mentions["results"]) > 1){
1270
+
1271
 
1272
+
1273
  $mentions_row = parser_twitter_results($mentions["results"],1);
1274
+
1275
  update_option( "skyscraper_mentions", $mentions_row );
1276
+
1277
  }
1278
+
1279
  }
1280
+
1281
  }
1282
 
1283
+
1284
+
1285
  function ago($time){
1286
 
1287
+
1288
+
1289
  $periods = array("second", "minute", "hour", "day", "week", "month", "year", "decade");
1290
+
1291
  $lengths = array("60","60","24","7","4.35","12","10");
1292
 
1293
+
1294
+
1295
  $now = time();
1296
 
1297
+
1298
+
1299
  $difference = $now - $time;
1300
+
1301
  $tense = "ago";
1302
 
1303
+
1304
+
1305
  for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
1306
+
1307
  $difference /= $lengths[$j];
1308
+
1309
  }
1310
 
1311
+
1312
+
1313
  $difference = round($difference);
1314
 
1315
+
1316
+
1317
  if($difference != 1) {
1318
+
1319
  $periods[$j].= "s";
1320
+
1321
  }
1322
 
1323
+
1324
+
1325
  return $difference." ".$periods[$j]."ago";
1326
+
1327
  }
1328
 
1329
 
1330
+
1331
+
1332
+
1333
  function parser_twitter_results($results = array(), $mention){
1334
+
1335
 
1336
+
1337
  $options_latest = array();
1338
+
1339
  $options_latest = array("date" => date("YmdHis"));
1340
+
1341
  global $skyscraper_options;
1342
+
1343
  $i = 0;
1344
+
1345
 
1346
+
1347
  if (is_array($results)){
1348
+
1349
 
1350
+
1351
  foreach($results as $tweet){
1352
+
1353
 
1354
+
1355
  $options_latest[$i] = array();
1356
+
1357
  $options_latest[$i]["text"] = $tweet["text"];
1358
+
1359
  $options_latest[$i]["created_at"] = ago(strtotime($tweet["created_at"]));
1360
+
1361
 
1362
+
1363
  if ($mention){
1364
+
1365
  $options_latest[$i]["name"] = $tweet["from_user_name"];
1366
+
1367
  }
1368
+
1369
  else{
1370
+
1371
  $options_latest[$i]["name"] = $tweet["user"]["name"];
1372
+
1373
  }
1374
+
1375
 
1376
+
1377
  $i++;
1378
+
1379
  if ($i == $skyscraper_options["num_tweets"]){
1380
+
1381
  break;
1382
+
1383
  }
1384
+
1385
  }
1386
+
1387
  }
1388
+
1389
 
1390
+
1391
  return $options_latest;
1392
+
1393
  }
1394
 
1395
+
1396
+
1397
  function curl_call($url){
1398
+
1399
 
1400
+
1401
  $ch = curl_init();
1402
+
1403
  curl_setopt($ch, CURLOPT_URL, $url);
1404
+
1405
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1406
+
1407
  curl_setopt($ch, CURLOPT_TIMEOUT, 3);
1408
+
1409
  curl_setopt($ch, CURLINFO_HEADER_OUT, true);
1410
+
1411
  $output = curl_exec($ch);
1412
+
1413
  $info = curl_getinfo($ch);
1414
+
1415
  curl_close($ch);
1416
+
1417
 
1418
+
1419
  if ($info["http_code"] == "200"){
1420
+
1421
 
1422
+
1423
  $return = json_decode($output,1);
1424
+
1425
  }
1426
+
1427
  else{
1428
+
1429
  $return = false;
1430
+
1431
  }
1432
+
1433
 
1434
+
1435
  return $return;
1436
+
1437
  }
1438
 
1439
+
1440
+
1441
  function get_option_tweets($option){
1442
+
1443
 
1444
+
1445
  global $skyscraper_options;
1446
+
1447
  $skyscraper_latest = get_option($option);
1448
+
1449
 
1450
+
1451
  if (empty($skyscraper_latest)){
1452
+
1453
 
1454
+
1455
  get_tweets_username($skyscraper_options["twitter_username"]);
1456
+
1457
  $skyscraper_latest = get_option($option);
1458
+
1459
  }
1460
+
1461
  else{
1462
+
1463
 
1464
+
1465
  // 5 minutes
1466
+
1467
  if (diff_date($skyscraper_latest["date"], date("YmdHis")) > 5){
1468
+
1469
 
1470
+
1471
  get_tweets_username($skyscraper_options["twitter_username"]);
1472
+
1473
  $skyscraper_latest = get_option($option);
1474
+
1475
  }
1476
+
1477
  }
1478
+
1479
 
1480
+
1481
 
1482
+
1483
  return generate_tweets_box_content($skyscraper_latest);
1484
+
1485
  }
1486
 
1487
+
1488
+
1489
  function generate_tweets_box_content($tweets){
1490
 
1491
+
1492
+
1493
  $content = "";
1494
+
1495
  if (isset($tweets["date"])){
1496
+
1497
  unset($tweets["date"]);
1498
+
1499
  }
1500
+
1501
 
1502
+
1503
 
1504
+
1505
  foreach($tweets as $tweet){
1506
+
1507
 
1508
+
1509
  $tweet["name"] = addslashes($tweet["name"]);
1510
+
1511
  $tweet["text"] = addslashes($tweet["text"]);
1512
+
1513
 
1514
+
1515
  $content .= "['".$tweet["name"]."','".$tweet["name"]."','".$tweet["text"]."','','".$tweet["created_at"]."'],";
1516
+
1517
  }
1518
+
1519
  $content = trim(trim(trim($content), ","));
1520
+
1521
 
1522
+
1523
  return $content;
1524
+
1525
  }
1526
 
1527
+
1528
+
1529
  if (!empty($_GET["sky"])){
1530
 
1531
+
1532
+
1533
  add_action('wp_ajax_my_action', 'my_action_callback');
1534
 
1535
+
1536
+
1537
  function my_action_callback() {
1538
+
1539
  global $wpdb; global $skyscraper_options; // this is how you get access to the database
1540
 
1541
+
1542
+
1543
  $whatever = intval( $_POST['whatever'] );
1544
 
1545
+
1546
+
1547
  $whatever += 10;
1548
 
1549
+
1550
+
1551
  echo $whatever;
1552
 
1553
+
1554
+
1555
  die(); // this is required to return a proper result
1556
+
1557
  }
1558
+
1559
  }
1560
+
1561
  ?>
readme.txt CHANGED
@@ -13,10 +13,10 @@ Requires at least: 2.6
13
 
14
  Tested up to: 3.2.1
15
 
16
- Stable tag: 4.1.6
17
 
18
  == Description ==
19
- Sociable continues being the leader in the sharing space of WordPress plugins. Started more than 2 years ago, and with over 1,5mm downloads now, here comes the latest version 4.1.6, with everything you expect to get, and now introducing Sociable Skyscraper: the ultimate advanced packed plugin for setting up rating system on your WordPress blog. Sociable Skyscraper allows you to set up pages and comments with great degree of customization.
20
  About Sociable Skyscraper
21
  Sociable Skyscraper is the ultimate advanced and feature packed plugin for setting up rating system on your WordPress blog. Plugin allows you to set up different rating systems for posts, pages and comments with great degree of customization.
22
  List of features is so smart, very long and non-stop growing:
@@ -52,7 +52,7 @@ Sociable finds its home outside of the WordPress environment on Blogplay.com-
52
 
53
 
54
 
55
- *** Sociable 4.1.6 ***
56
 
57
 
58
 
@@ -111,7 +111,7 @@ Sociable plugin wouldn't be what it is today if it weren't for these people that
111
 
112
  4. Or you can pick your own style
113
 
114
-
115
 
116
 
117
  == Installation ==
@@ -152,6 +152,9 @@ Please send us an email to sociableblogplay [ at ] gmail.com
152
 
153
  == Changelog ==
154
 
 
 
 
155
 
156
  = 4.1.6 =
157
 
13
 
14
  Tested up to: 3.2.1
15
 
16
+ Stable tag: 4.1.7
17
 
18
  == Description ==
19
+ Sociable continues being the leader in the sharing space of WordPress plugins. Started more than 2 years ago, and with over 1,5mm downloads now, here comes the latest version 4.1.7, with everything you expect to get, and now introducing Sociable Skyscraper: the ultimate advanced packed plugin for setting up rating system on your WordPress blog. Sociable Skyscraper allows you to set up pages and comments with great degree of customization.
20
  About Sociable Skyscraper
21
  Sociable Skyscraper is the ultimate advanced and feature packed plugin for setting up rating system on your WordPress blog. Plugin allows you to set up different rating systems for posts, pages and comments with great degree of customization.
22
  List of features is so smart, very long and non-stop growing:
52
 
53
 
54
 
55
+ *** Sociable 4.1.7 ***
56
 
57
 
58
 
111
 
112
  4. Or you can pick your own style
113
 
114
+ 5. Select which plugin want to customize
115
 
116
 
117
  == Installation ==
152
 
153
  == Changelog ==
154
 
155
+ = 4.1.7 =
156
+
157
+ * FIXED: Some Fixes
158
 
159
  = 4.1.6 =
160
 
screenshot-5.jpg ADDED
Binary file
sociable.php CHANGED
@@ -30,7 +30,7 @@ Description: Automatically add links on your posts, pages and RSS feed to your f
30
 
31
 
32
 
33
- Version: 4.1.6
34
 
35
 
36
 
@@ -565,7 +565,7 @@ function sociable_reset(){
565
 
566
  $sociable_options = array(
567
 
568
- 'version' =>'4.1.6',
569
 
570
 
571
 
30
 
31
 
32
 
33
+ Version: 4.1.7
34
 
35
 
36
 
565
 
566
  $sociable_options = array(
567
 
568
+ 'version' =>'4.1.7',
569
 
570
 
571