Version Description
- Reverted plugin URL fix because of too many people on old WordPress installations complaining. (Upgrade, people, upgrade!)
- Added PHPDoc throughout the plugins code.
Download this release
Release Info
Developer | joostdevalk |
Plugin | Sociable |
Version | 3.3.6 |
Comparing to | |
See all releases |
Code changes from version 3.3.5 to 3.3.6
- readme.txt +5 -2
- sociable.php +153 -39
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://yoast.com/donate/
|
|
4 |
Tags: social, bookmark, bookmarks, bookmarking, social bookmarking, social bookmarks
|
5 |
Requires at least: 2.6
|
6 |
Tested up to: 2.8.1
|
7 |
-
Stable tag: 3.3.
|
8 |
|
9 |
Automatically add links on your posts, pages and RSS feed to your favorite social bookmarking sites.
|
10 |
|
@@ -14,7 +14,6 @@ Automatically add links to your favorite social bookmarking sites on your posts,
|
|
14 |
More info:
|
15 |
|
16 |
* More info on [Sociable](http://yoast.com/wordpress/sociable/), with info on how to add sites to it, and how to integrate it into your WordPress in other ways.
|
17 |
-
* Check out the authors [WordPress Hosting](http://yoast.com/wordpress-hosting/) experience. Good hosting is hard to come by, but it doesn't have to be expensive, Joost tells you why!
|
18 |
* Check out the other [Wordpress plugins](http://yoast.com/wordpress/) by the same author, and read his blog: [Yoast](http://yoast.com).
|
19 |
|
20 |
== Screenshots ==
|
@@ -25,6 +24,10 @@ More info:
|
|
25 |
|
26 |
== Changelog ==
|
27 |
|
|
|
|
|
|
|
|
|
28 |
= 3.3.5 =
|
29 |
* Added a Hyves button.
|
30 |
* Fixed MSN Reporter button.
|
4 |
Tags: social, bookmark, bookmarks, bookmarking, social bookmarking, social bookmarks
|
5 |
Requires at least: 2.6
|
6 |
Tested up to: 2.8.1
|
7 |
+
Stable tag: 3.3.6
|
8 |
|
9 |
Automatically add links on your posts, pages and RSS feed to your favorite social bookmarking sites.
|
10 |
|
14 |
More info:
|
15 |
|
16 |
* More info on [Sociable](http://yoast.com/wordpress/sociable/), with info on how to add sites to it, and how to integrate it into your WordPress in other ways.
|
|
|
17 |
* Check out the other [Wordpress plugins](http://yoast.com/wordpress/) by the same author, and read his blog: [Yoast](http://yoast.com).
|
18 |
|
19 |
== Screenshots ==
|
24 |
|
25 |
== Changelog ==
|
26 |
|
27 |
+
= 3.3.6 =
|
28 |
+
* Reverted plugin URL fix because of too many people on old WordPress installations complaining. (Upgrade, people, upgrade!)
|
29 |
+
* Added PHPDoc throughout the plugins code.
|
30 |
+
|
31 |
= 3.3.5 =
|
32 |
* Added a Hyves button.
|
33 |
* Fixed MSN Reporter button.
|
sociable.php
CHANGED
@@ -28,12 +28,24 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
28 |
// Determine the location
|
29 |
$sociablepluginpath = plugins_url('', __FILE__).'/';
|
30 |
|
|
|
|
|
|
|
|
|
31 |
function sociable_init_locale(){
|
32 |
global $sociablepluginpath;
|
33 |
-
load_plugin_textdomain('sociable',
|
34 |
}
|
35 |
add_filter('init', 'sociable_init_locale');
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
$sociable_known_sites = Array(
|
38 |
|
39 |
'BarraPunto' => Array(
|
@@ -522,8 +534,17 @@ $sociable_known_sites = Array(
|
|
522 |
),
|
523 |
);
|
524 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
525 |
function sociable_html($display=array()) {
|
526 |
-
global $sociable_known_sites, $sociablepluginpath, $wp_query
|
527 |
|
528 |
$sociableooffmeta = get_post_meta($post->ID,'sociableoff',true);
|
529 |
if ($sociableooffmeta == "true") {
|
@@ -532,12 +553,12 @@ function sociable_html($display=array()) {
|
|
532 |
|
533 |
$active_sites = get_option('sociable_active_sites');
|
534 |
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
$imagepath =
|
541 |
|
542 |
// if no sites are specified, display all active
|
543 |
// have to check $active_sites has content because WP
|
@@ -548,23 +569,27 @@ function sociable_html($display=array()) {
|
|
548 |
if (empty($display))
|
549 |
return "";
|
550 |
|
551 |
-
// Load the post's data
|
552 |
$blogname = urlencode(get_bloginfo('name')." ".get_bloginfo('description'));
|
553 |
$blogrss = get_bloginfo('rss2_url');
|
554 |
$post = $wp_query->post;
|
555 |
|
|
|
556 |
$excerpt = urlencode(strip_tags(strip_shortcodes($post->post_excerpt)));
|
557 |
if ($excerpt == "") {
|
558 |
$excerpt = urlencode(substr(strip_tags(strip_shortcodes($post->post_content)),0,250));
|
559 |
}
|
|
|
560 |
$excerpt = str_replace('+','%20',$excerpt);
|
561 |
$permalink = urlencode(get_permalink($post->ID));
|
562 |
$title = str_replace('+','%20',urlencode($post->post_title));
|
563 |
|
564 |
$rss = urlencode(get_bloginfo('ref_url'));
|
565 |
|
566 |
-
|
|
|
567 |
|
|
|
568 |
$tagline = get_option("sociable_tagline");
|
569 |
if ($tagline != "") {
|
570 |
$html .= "<div class=\"sociable_tagline\">\n";
|
@@ -572,12 +597,17 @@ function sociable_html($display=array()) {
|
|
572 |
$html .= "\n</div>";
|
573 |
}
|
574 |
|
|
|
|
|
|
|
575 |
$html .= "\n<ul>\n";
|
576 |
|
577 |
$i = 0;
|
578 |
$totalsites = count($display);
|
579 |
foreach($display as $sitename) {
|
580 |
-
|
|
|
|
|
581 |
if (!in_array($sitename, $active_sites))
|
582 |
continue;
|
583 |
|
@@ -596,8 +626,10 @@ function sociable_html($display=array()) {
|
|
596 |
$description = $sitename;
|
597 |
}
|
598 |
|
599 |
-
if (get_option('sociable_awesmenable') == true &! empty($site['awesm_channel']) ){
|
600 |
-
|
|
|
|
|
601 |
$permalink = str_replace('&', '%26', $permalink);
|
602 |
$destination = str_replace('PERMALINK', 'TARGET', $url);
|
603 |
$destination = str_replace('&', '%26', $destination);
|
@@ -605,7 +637,9 @@ function sociable_html($display=array()) {
|
|
605 |
|
606 |
$parentargument = '';
|
607 |
if ($_GET['awesm']) {
|
608 |
-
|
|
|
|
|
609 |
$parent = $_GET['awesm'];
|
610 |
$parentargument = '&p=' . $parent;
|
611 |
}
|
@@ -616,9 +650,17 @@ function sociable_html($display=array()) {
|
|
616 |
$url = $sociablepluginpath.'awesmate.php?c='.$channel.'&t='.$permalink.'&d='.$destination.$parentargument;
|
617 |
}
|
618 |
} else {
|
|
|
|
|
|
|
619 |
$url = str_replace('PERMALINK', $permalink, $url);
|
620 |
}
|
621 |
|
|
|
|
|
|
|
|
|
|
|
622 |
if ($i == 0) {
|
623 |
$link = '<li class="sociablefirst">';
|
624 |
} else if ($totalsites == ($i+1)) {
|
@@ -626,11 +668,22 @@ function sociable_html($display=array()) {
|
|
626 |
} else {
|
627 |
$link = '<li>';
|
628 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
629 |
$link .= "<a rel=\"nofollow\"";
|
630 |
if (get_option('sociable_usetargetblank')) {
|
631 |
$link .= " target=\"_blank\"";
|
632 |
}
|
633 |
$link .= " href=\"$url\" title=\"$description\">";
|
|
|
|
|
|
|
|
|
|
|
634 |
if (get_option('sociable_usetextlinks')) {
|
635 |
$link .= $description;
|
636 |
} else {
|
@@ -641,6 +694,11 @@ function sociable_html($display=array()) {
|
|
641 |
}
|
642 |
$link .= "</a></li>";
|
643 |
|
|
|
|
|
|
|
|
|
|
|
644 |
$html .= "\t".apply_filters('sociable_link',$link)."\n";
|
645 |
$i++;
|
646 |
}
|
@@ -650,12 +708,17 @@ function sociable_html($display=array()) {
|
|
650 |
return $html;
|
651 |
}
|
652 |
|
653 |
-
|
|
|
|
|
654 |
$sociable_contitionals = get_option('sociable_conditionals');
|
655 |
if (is_array($sociable_contitionals) and in_array(true, $sociable_contitionals)) {
|
656 |
add_filter('the_content', 'sociable_display_hook');
|
657 |
add_filter('the_excerpt', 'sociable_display_hook');
|
658 |
|
|
|
|
|
|
|
659 |
function sociable_display_hook($content='') {
|
660 |
$conditionals = get_option('sociable_conditionals');
|
661 |
if ((is_home() and $conditionals['is_home']) or
|
@@ -676,13 +739,19 @@ if (is_array($sociable_contitionals) and in_array(true, $sociable_contitionals))
|
|
676 |
}
|
677 |
}
|
678 |
|
679 |
-
|
680 |
-
|
|
|
681 |
function sociable_activation_hook() {
|
682 |
-
return sociable_restore_config(
|
683 |
}
|
|
|
684 |
|
685 |
-
|
|
|
|
|
|
|
|
|
686 |
global $sociable_known_sites;
|
687 |
|
688 |
if ($force or !is_array(get_option('sociable_active_sites')))
|
@@ -712,15 +781,22 @@ function sociable_restore_config($force=False) {
|
|
712 |
'is_feed' => False,
|
713 |
));
|
714 |
|
715 |
-
if ($force or !is_bool(get_option('
|
716 |
update_option('sociable_usecss', true);
|
717 |
}
|
718 |
|
719 |
-
|
|
|
|
|
720 |
function sociable_admin_menu() {
|
721 |
-
|
722 |
}
|
|
|
723 |
|
|
|
|
|
|
|
|
|
724 |
function sociable_admin_js() {
|
725 |
if (isset($_GET['page']) && $_GET['page'] == 'Sociable') {
|
726 |
global $sociablepluginpath;
|
@@ -728,11 +804,15 @@ function sociable_admin_js() {
|
|
728 |
wp_enqueue_script('jquery');
|
729 |
wp_enqueue_script('jquery-ui-core',false,array('jquery'));
|
730 |
wp_enqueue_script('jquery-ui-sortable',false,array('jquery','jquery-ui-core'));
|
731 |
-
wp_enqueue_script('sociable-js',$sociablepluginpath.'sociable-admin.js',array('jquery','jquery-ui-core','jquery-ui-sortable'));
|
732 |
}
|
733 |
}
|
734 |
add_action('admin_print_scripts', 'sociable_admin_js');
|
735 |
|
|
|
|
|
|
|
|
|
736 |
function sociable_admin_css() {
|
737 |
global $sociablepluginpath;
|
738 |
if (isset($_GET['page']) && $_GET['page'] == 'Sociable')
|
@@ -740,6 +820,10 @@ function sociable_admin_css() {
|
|
740 |
}
|
741 |
add_action('admin_print_styles', 'sociable_admin_css');
|
742 |
|
|
|
|
|
|
|
|
|
743 |
function sociable_js() {
|
744 |
if (in_array('Wists', get_option('sociable_active_sites'))) {
|
745 |
global $sociablepluginpath;
|
@@ -748,18 +832,28 @@ function sociable_js() {
|
|
748 |
}
|
749 |
add_action('wp_print_scripts', 'sociable_js');
|
750 |
|
|
|
|
|
|
|
751 |
function sociable_css() {
|
752 |
if (get_option('sociable_usecss') == true) {
|
753 |
global $sociablepluginpath;
|
754 |
-
|
755 |
}
|
756 |
}
|
757 |
-
add_action('
|
758 |
|
|
|
|
|
|
|
759 |
function sociable_message($message) {
|
760 |
echo "<div id=\"message\" class=\"updated fade\"><p>$message</p></div>\n";
|
761 |
}
|
762 |
|
|
|
|
|
|
|
|
|
763 |
function sociable_meta() {
|
764 |
global $post;
|
765 |
$sociableoff = false;
|
@@ -772,24 +866,33 @@ function sociable_meta() {
|
|
772 |
<?php
|
773 |
}
|
774 |
|
|
|
|
|
|
|
775 |
function sociable_meta_box() {
|
776 |
add_meta_box('sociable','Sociable','sociable_meta','post');
|
777 |
add_meta_box('sociable','Sociable','sociable_meta','page');
|
778 |
}
|
779 |
add_action('admin_menu', 'sociable_meta_box');
|
780 |
|
|
|
|
|
|
|
781 |
function sociable_insert_post($pID) {
|
782 |
delete_post_meta($pID, 'sociableoff');
|
783 |
update_post_meta($pID, 'sociableoff', ($_POST['sociableoff'] ? 'true' : 'false'));
|
784 |
}
|
785 |
add_action('wp_insert_post', 'sociable_insert_post');
|
786 |
|
|
|
|
|
|
|
787 |
function sociable_submenu() {
|
788 |
global $sociable_known_sites, $sociable_date, $sociablepluginpath;
|
789 |
|
790 |
if (isset($_REQUEST['restore']) && $_REQUEST['restore']) {
|
791 |
check_admin_referer('sociable-config');
|
792 |
-
sociable_restore_config(
|
793 |
sociable_message(__("Restored all settings to defaults.", 'sociable'));
|
794 |
} else if (isset($_REQUEST['save']) && $_REQUEST['save']) {
|
795 |
check_admin_referer('sociable-config');
|
@@ -799,8 +902,10 @@ function sociable_submenu() {
|
|
799 |
foreach($_REQUEST['active_sites'] as $sitename=>$dummy)
|
800 |
$active_sites[] = $sitename;
|
801 |
update_option('sociable_active_sites', $active_sites);
|
802 |
-
|
803 |
-
|
|
|
|
|
804 |
delete_option('sociable_active_sites', $active_sites);
|
805 |
add_option('sociable_active_sites', $active_sites);
|
806 |
|
@@ -818,7 +923,9 @@ function sociable_submenu() {
|
|
818 |
update_option( 'sociable_'.$val, $_POST[$val] );
|
819 |
}
|
820 |
|
821 |
-
|
|
|
|
|
822 |
$conditionals = Array();
|
823 |
if (!$_POST['conditionals'])
|
824 |
$_POST['conditionals'] = Array();
|
@@ -835,20 +942,21 @@ function sociable_submenu() {
|
|
835 |
sociable_message(__("Saved changes.", 'sociable'));
|
836 |
}
|
837 |
|
838 |
-
|
|
|
|
|
839 |
$active_sites = get_option('sociable_active_sites');
|
840 |
-
$active = Array();
|
841 |
-
|
|
|
842 |
$active[$sitename] = $disabled[$sitename];
|
843 |
unset($disabled[$sitename]);
|
844 |
}
|
845 |
uksort($disabled, "strnatcasecmp");
|
846 |
-
|
847 |
-
// load options from db to display
|
848 |
-
$conditionals = get_option('sociable_conditionals');
|
849 |
-
$updated = get_option('sociable_updated');
|
850 |
|
851 |
-
|
|
|
|
|
852 |
?>
|
853 |
<form action="<?php echo attribute_escape( $_SERVER['REQUEST_URI'] ); ?>" method="post">
|
854 |
<?php
|
@@ -902,6 +1010,12 @@ function sociable_submenu() {
|
|
902 |
<td>
|
903 |
<?php _e("The icons appear at the end of each blog post, and posts may show on many different types of pages. Depending on your theme and audience, it may be tacky to display icons on all types of pages.", 'sociable'); ?><br/>
|
904 |
<br/>
|
|
|
|
|
|
|
|
|
|
|
|
|
905 |
<input type="checkbox" name="conditionals[is_home]"<?php echo ($conditionals['is_home']) ? ' checked="checked"' : ''; ?> /> <?php _e("Front page of the blog", 'sociable'); ?><br/>
|
906 |
<input type="checkbox" name="conditionals[is_single]"<?php echo ($conditionals['is_single']) ? ' checked="checked"' : ''; ?> /> <?php _e("Individual blog posts", 'sociable'); ?><br/>
|
907 |
<input type="checkbox" name="conditionals[is_page]"<?php echo ($conditionals['is_page']) ? ' checked="checked"' : ''; ?> /> <?php _e('Individual WordPress "Pages"', 'sociable'); ?><br/>
|
@@ -918,7 +1032,7 @@ function sociable_submenu() {
|
|
918 |
<?php _e("Use CSS:", "sociable"); ?>
|
919 |
</th>
|
920 |
<td>
|
921 |
-
<input type="checkbox" name="usecss" <?php
|
922 |
</td>
|
923 |
</tr>
|
924 |
<tr>
|
@@ -926,7 +1040,7 @@ function sociable_submenu() {
|
|
926 |
<?php _e("Use Text Links:", "sociable"); ?>
|
927 |
</th>
|
928 |
<td>
|
929 |
-
<input type="checkbox" name="usetextlinks" <?php
|
930 |
</td>
|
931 |
</tr>
|
932 |
<tr>
|
28 |
// Determine the location
|
29 |
$sociablepluginpath = plugins_url('', __FILE__).'/';
|
30 |
|
31 |
+
/**
|
32 |
+
* This function makes sure Sociable is able to load the different language files from
|
33 |
+
* the i18n subfolder of the Sociable directory
|
34 |
+
**/
|
35 |
function sociable_init_locale(){
|
36 |
global $sociablepluginpath;
|
37 |
+
load_plugin_textdomain('sociable', false, 'i18n');
|
38 |
}
|
39 |
add_filter('init', 'sociable_init_locale');
|
40 |
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @global array Contains all sites that Sociable supports, array items have 4 keys:
|
44 |
+
* required favicon - the favicon for the site, a 16x16px PNG, to be found in the images subdirectory
|
45 |
+
* required url - submit URL of the site, containing at least PERMALINK
|
46 |
+
* description - description, used in several spots, but most notably as alt and title text for the link
|
47 |
+
* awesm_channel - the channel awe.sm files the traffic under
|
48 |
+
*/
|
49 |
$sociable_known_sites = Array(
|
50 |
|
51 |
'BarraPunto' => Array(
|
534 |
),
|
535 |
);
|
536 |
|
537 |
+
/**
|
538 |
+
* Returns the Sociable links list.
|
539 |
+
*
|
540 |
+
* @param array $display optional list of links to return in HTML
|
541 |
+
* @global $sociable_known_sites array the list of sites that Sociable uses
|
542 |
+
* @global $sociablepluginpath string the path to the plugin
|
543 |
+
* @global $wp_query object the WordPress query object
|
544 |
+
* @return string $html HTML for links list.
|
545 |
+
*/
|
546 |
function sociable_html($display=array()) {
|
547 |
+
global $sociable_known_sites, $sociablepluginpath, $wp_query;
|
548 |
|
549 |
$sociableooffmeta = get_post_meta($post->ID,'sociableoff',true);
|
550 |
if ($sociableooffmeta == "true") {
|
553 |
|
554 |
$active_sites = get_option('sociable_active_sites');
|
555 |
|
556 |
+
// If a path is specified where Sociable should find its images, use that, otherwise,
|
557 |
+
// set the image path to the images subdirectory of the Sociable plugin.
|
558 |
+
// Image files need to be png's.
|
559 |
+
$imagepath = get_option('sociable_imagedir');
|
560 |
+
if ($imagepath == "")
|
561 |
+
$imagepath = $sociablepluginpath.'images/';
|
562 |
|
563 |
// if no sites are specified, display all active
|
564 |
// have to check $active_sites has content because WP
|
569 |
if (empty($display))
|
570 |
return "";
|
571 |
|
572 |
+
// Load the post's and blog's data
|
573 |
$blogname = urlencode(get_bloginfo('name')." ".get_bloginfo('description'));
|
574 |
$blogrss = get_bloginfo('rss2_url');
|
575 |
$post = $wp_query->post;
|
576 |
|
577 |
+
// Grab the excerpt, if there is no excerpt, create one
|
578 |
$excerpt = urlencode(strip_tags(strip_shortcodes($post->post_excerpt)));
|
579 |
if ($excerpt == "") {
|
580 |
$excerpt = urlencode(substr(strip_tags(strip_shortcodes($post->post_content)),0,250));
|
581 |
}
|
582 |
+
// Clean the excerpt for use with links
|
583 |
$excerpt = str_replace('+','%20',$excerpt);
|
584 |
$permalink = urlencode(get_permalink($post->ID));
|
585 |
$title = str_replace('+','%20',urlencode($post->post_title));
|
586 |
|
587 |
$rss = urlencode(get_bloginfo('ref_url'));
|
588 |
|
589 |
+
// Start preparing the output
|
590 |
+
$html = "\n<div class=\"sociable\">\n";
|
591 |
|
592 |
+
// If a tagline is set, display it above the links list
|
593 |
$tagline = get_option("sociable_tagline");
|
594 |
if ($tagline != "") {
|
595 |
$html .= "<div class=\"sociable_tagline\">\n";
|
597 |
$html .= "\n</div>";
|
598 |
}
|
599 |
|
600 |
+
/**
|
601 |
+
* Start the list of links
|
602 |
+
*/
|
603 |
$html .= "\n<ul>\n";
|
604 |
|
605 |
$i = 0;
|
606 |
$totalsites = count($display);
|
607 |
foreach($display as $sitename) {
|
608 |
+
/**
|
609 |
+
* If they specify an unknown or inactive site, ignore it.
|
610 |
+
*/
|
611 |
if (!in_array($sitename, $active_sites))
|
612 |
continue;
|
613 |
|
626 |
$description = $sitename;
|
627 |
}
|
628 |
|
629 |
+
if (get_option('sociable_awesmenable') == true &! empty($site['awesm_channel']) ) {
|
630 |
+
/**
|
631 |
+
* if awe.sm is enabled and it is an awe.sm supported site, use awe.sm
|
632 |
+
*/
|
633 |
$permalink = str_replace('&', '%26', $permalink);
|
634 |
$destination = str_replace('PERMALINK', 'TARGET', $url);
|
635 |
$destination = str_replace('&', '%26', $destination);
|
637 |
|
638 |
$parentargument = '';
|
639 |
if ($_GET['awesm']) {
|
640 |
+
/**
|
641 |
+
* if the page was arrived at through an awe.sm URL, make that the parent
|
642 |
+
*/
|
643 |
$parent = $_GET['awesm'];
|
644 |
$parentargument = '&p=' . $parent;
|
645 |
}
|
650 |
$url = $sociablepluginpath.'awesmate.php?c='.$channel.'&t='.$permalink.'&d='.$destination.$parentargument;
|
651 |
}
|
652 |
} else {
|
653 |
+
/**
|
654 |
+
* if awe.sm is not used, simply replace PERMALINK with $permalink
|
655 |
+
*/
|
656 |
$url = str_replace('PERMALINK', $permalink, $url);
|
657 |
}
|
658 |
|
659 |
+
/**
|
660 |
+
* Start building each list item. They're build up separately to allow filtering by other
|
661 |
+
* plugins.
|
662 |
+
* Give the first and last list item in the list an extra class to allow for cool CSS tricks
|
663 |
+
*/
|
664 |
if ($i == 0) {
|
665 |
$link = '<li class="sociablefirst">';
|
666 |
} else if ($totalsites == ($i+1)) {
|
668 |
} else {
|
669 |
$link = '<li>';
|
670 |
}
|
671 |
+
|
672 |
+
/**
|
673 |
+
* Start building the link, nofollow it to make sure Search engines don't follow it,
|
674 |
+
* and optionally add target=_blank to open in a new window if that option is set in the
|
675 |
+
* backend.
|
676 |
+
*/
|
677 |
$link .= "<a rel=\"nofollow\"";
|
678 |
if (get_option('sociable_usetargetblank')) {
|
679 |
$link .= " target=\"_blank\"";
|
680 |
}
|
681 |
$link .= " href=\"$url\" title=\"$description\">";
|
682 |
+
|
683 |
+
/**
|
684 |
+
* If the option to use text links is enabled in the backend, display a text link, otherwise,
|
685 |
+
* display an image.
|
686 |
+
*/
|
687 |
if (get_option('sociable_usetextlinks')) {
|
688 |
$link .= $description;
|
689 |
} else {
|
694 |
}
|
695 |
$link .= "</a></li>";
|
696 |
|
697 |
+
/**
|
698 |
+
* Add the list item to the output HTML, but allow other plugins to filter the content first.
|
699 |
+
* This is used for instance in the Google Analytics for WordPress plugin to track clicks
|
700 |
+
* on Sociable links.
|
701 |
+
*/
|
702 |
$html .= "\t".apply_filters('sociable_link',$link)."\n";
|
703 |
$i++;
|
704 |
}
|
708 |
return $html;
|
709 |
}
|
710 |
|
711 |
+
/**
|
712 |
+
* Hook the_content to output html if we should display on any page
|
713 |
+
*/
|
714 |
$sociable_contitionals = get_option('sociable_conditionals');
|
715 |
if (is_array($sociable_contitionals) and in_array(true, $sociable_contitionals)) {
|
716 |
add_filter('the_content', 'sociable_display_hook');
|
717 |
add_filter('the_excerpt', 'sociable_display_hook');
|
718 |
|
719 |
+
/**
|
720 |
+
* Loop through the settings and check whether Sociable should be outputted.
|
721 |
+
*/
|
722 |
function sociable_display_hook($content='') {
|
723 |
$conditionals = get_option('sociable_conditionals');
|
724 |
if ((is_home() and $conditionals['is_home']) or
|
739 |
}
|
740 |
}
|
741 |
|
742 |
+
/**
|
743 |
+
* Set the default settings on activation on the plugin.
|
744 |
+
*/
|
745 |
function sociable_activation_hook() {
|
746 |
+
return sociable_restore_config(false);
|
747 |
}
|
748 |
+
register_activation_hook(__FILE__, 'sociable_activation_hook');
|
749 |
|
750 |
+
/**
|
751 |
+
* Add the Sociable menu to the Settings menu
|
752 |
+
* @param boolean $force if set to true, force updates the settings.
|
753 |
+
*/
|
754 |
+
function sociable_restore_config($force=false) {
|
755 |
global $sociable_known_sites;
|
756 |
|
757 |
if ($force or !is_array(get_option('sociable_active_sites')))
|
781 |
'is_feed' => False,
|
782 |
));
|
783 |
|
784 |
+
if ($force or !is_bool(get_option('sociable_usecss')))
|
785 |
update_option('sociable_usecss', true);
|
786 |
}
|
787 |
|
788 |
+
/**
|
789 |
+
* Add the Sociable menu to the Settings menu
|
790 |
+
*/
|
791 |
function sociable_admin_menu() {
|
792 |
+
add_options_page('Sociable', 'Sociable', 8, 'Sociable', 'sociable_submenu');
|
793 |
}
|
794 |
+
add_action('admin_menu', 'sociable_admin_menu');
|
795 |
|
796 |
+
/**
|
797 |
+
* Make sure the required javascript files are loaded in the Sociable backend, and that they are only
|
798 |
+
* loaded in the Sociable settings page, and nowhere else.
|
799 |
+
*/
|
800 |
function sociable_admin_js() {
|
801 |
if (isset($_GET['page']) && $_GET['page'] == 'Sociable') {
|
802 |
global $sociablepluginpath;
|
804 |
wp_enqueue_script('jquery');
|
805 |
wp_enqueue_script('jquery-ui-core',false,array('jquery'));
|
806 |
wp_enqueue_script('jquery-ui-sortable',false,array('jquery','jquery-ui-core'));
|
807 |
+
wp_enqueue_script('sociable-js',$sociablepluginpath.'sociable-admin.js', array('jquery','jquery-ui-core','jquery-ui-sortable'));
|
808 |
}
|
809 |
}
|
810 |
add_action('admin_print_scripts', 'sociable_admin_js');
|
811 |
|
812 |
+
/**
|
813 |
+
* Make sure the required stylesheet is loaded in the Sociable backend, and that it is only
|
814 |
+
* loaded in the Sociable settings page, and nowhere else.
|
815 |
+
*/
|
816 |
function sociable_admin_css() {
|
817 |
global $sociablepluginpath;
|
818 |
if (isset($_GET['page']) && $_GET['page'] == 'Sociable')
|
820 |
}
|
821 |
add_action('admin_print_styles', 'sociable_admin_css');
|
822 |
|
823 |
+
/**
|
824 |
+
* If Wists is active, load it's js file. This is the only site that historically has had a JS file
|
825 |
+
* in Sociable. For all other sites this has so far been refused.
|
826 |
+
*/
|
827 |
function sociable_js() {
|
828 |
if (in_array('Wists', get_option('sociable_active_sites'))) {
|
829 |
global $sociablepluginpath;
|
832 |
}
|
833 |
add_action('wp_print_scripts', 'sociable_js');
|
834 |
|
835 |
+
/**
|
836 |
+
* If the user has the (default) setting of using the Sociable CSS, load it.
|
837 |
+
*/
|
838 |
function sociable_css() {
|
839 |
if (get_option('sociable_usecss') == true) {
|
840 |
global $sociablepluginpath;
|
841 |
+
wp_enqueue_style('sociable-front-css',$sociablepluginpath.'sociable.css');
|
842 |
}
|
843 |
}
|
844 |
+
add_action('wp_print_styles', 'sociable_css');
|
845 |
|
846 |
+
/**
|
847 |
+
* Update message, used in the admin panel to show messages to users.
|
848 |
+
*/
|
849 |
function sociable_message($message) {
|
850 |
echo "<div id=\"message\" class=\"updated fade\"><p>$message</p></div>\n";
|
851 |
}
|
852 |
|
853 |
+
/**
|
854 |
+
* Displays a checkbox that allows users to disable Sociable on a
|
855 |
+
* per post or page basis.
|
856 |
+
*/
|
857 |
function sociable_meta() {
|
858 |
global $post;
|
859 |
$sociableoff = false;
|
866 |
<?php
|
867 |
}
|
868 |
|
869 |
+
/**
|
870 |
+
* Add the checkbox defined above to post and page edit screens.
|
871 |
+
*/
|
872 |
function sociable_meta_box() {
|
873 |
add_meta_box('sociable','Sociable','sociable_meta','post');
|
874 |
add_meta_box('sociable','Sociable','sociable_meta','page');
|
875 |
}
|
876 |
add_action('admin_menu', 'sociable_meta_box');
|
877 |
|
878 |
+
/**
|
879 |
+
* If the post is inserted, delete the sociableoff value and reenable it when its been set.
|
880 |
+
*/
|
881 |
function sociable_insert_post($pID) {
|
882 |
delete_post_meta($pID, 'sociableoff');
|
883 |
update_post_meta($pID, 'sociableoff', ($_POST['sociableoff'] ? 'true' : 'false'));
|
884 |
}
|
885 |
add_action('wp_insert_post', 'sociable_insert_post');
|
886 |
|
887 |
+
/**
|
888 |
+
* Displays the Sociable admin menu, first section (re)stores the settings.
|
889 |
+
*/
|
890 |
function sociable_submenu() {
|
891 |
global $sociable_known_sites, $sociable_date, $sociablepluginpath;
|
892 |
|
893 |
if (isset($_REQUEST['restore']) && $_REQUEST['restore']) {
|
894 |
check_admin_referer('sociable-config');
|
895 |
+
sociable_restore_config(true);
|
896 |
sociable_message(__("Restored all settings to defaults.", 'sociable'));
|
897 |
} else if (isset($_REQUEST['save']) && $_REQUEST['save']) {
|
898 |
check_admin_referer('sociable-config');
|
902 |
foreach($_REQUEST['active_sites'] as $sitename=>$dummy)
|
903 |
$active_sites[] = $sitename;
|
904 |
update_option('sociable_active_sites', $active_sites);
|
905 |
+
/**
|
906 |
+
* Have to delete and re-add because update doesn't hit the db for identical arrays
|
907 |
+
* (sorting does not influence associated array equality in PHP)
|
908 |
+
*/
|
909 |
delete_option('sociable_active_sites', $active_sites);
|
910 |
add_option('sociable_active_sites', $active_sites);
|
911 |
|
923 |
update_option( 'sociable_'.$val, $_POST[$val] );
|
924 |
}
|
925 |
|
926 |
+
/**
|
927 |
+
* Update conditional displays
|
928 |
+
*/
|
929 |
$conditionals = Array();
|
930 |
if (!$_POST['conditionals'])
|
931 |
$_POST['conditionals'] = Array();
|
942 |
sociable_message(__("Saved changes.", 'sociable'));
|
943 |
}
|
944 |
|
945 |
+
/**
|
946 |
+
* Show active sites first and in the right order.
|
947 |
+
*/
|
948 |
$active_sites = get_option('sociable_active_sites');
|
949 |
+
$active = Array();
|
950 |
+
$disabled = $sociable_known_sites;
|
951 |
+
foreach( $active_sites as $sitename ) {
|
952 |
$active[$sitename] = $disabled[$sitename];
|
953 |
unset($disabled[$sitename]);
|
954 |
}
|
955 |
uksort($disabled, "strnatcasecmp");
|
|
|
|
|
|
|
|
|
956 |
|
957 |
+
/**
|
958 |
+
* Display options.
|
959 |
+
*/
|
960 |
?>
|
961 |
<form action="<?php echo attribute_escape( $_SERVER['REQUEST_URI'] ); ?>" method="post">
|
962 |
<?php
|
1010 |
<td>
|
1011 |
<?php _e("The icons appear at the end of each blog post, and posts may show on many different types of pages. Depending on your theme and audience, it may be tacky to display icons on all types of pages.", 'sociable'); ?><br/>
|
1012 |
<br/>
|
1013 |
+
<?php
|
1014 |
+
/**
|
1015 |
+
* Load conditions under which Sociable displays
|
1016 |
+
*/
|
1017 |
+
$conditionals = get_option('sociable_conditionals');
|
1018 |
+
?>
|
1019 |
<input type="checkbox" name="conditionals[is_home]"<?php echo ($conditionals['is_home']) ? ' checked="checked"' : ''; ?> /> <?php _e("Front page of the blog", 'sociable'); ?><br/>
|
1020 |
<input type="checkbox" name="conditionals[is_single]"<?php echo ($conditionals['is_single']) ? ' checked="checked"' : ''; ?> /> <?php _e("Individual blog posts", 'sociable'); ?><br/>
|
1021 |
<input type="checkbox" name="conditionals[is_page]"<?php echo ($conditionals['is_page']) ? ' checked="checked"' : ''; ?> /> <?php _e('Individual WordPress "Pages"', 'sociable'); ?><br/>
|
1032 |
<?php _e("Use CSS:", "sociable"); ?>
|
1033 |
</th>
|
1034 |
<td>
|
1035 |
+
<input type="checkbox" name="usecss" <?php checked( get_option('sociable_usecss'), false ); ?> /> <?php _e("Use the sociable stylesheet?", "sociable"); ?>
|
1036 |
</td>
|
1037 |
</tr>
|
1038 |
<tr>
|
1040 |
<?php _e("Use Text Links:", "sociable"); ?>
|
1041 |
</th>
|
1042 |
<td>
|
1043 |
+
<input type="checkbox" name="usetextlinks" <?php checked( get_option('sociable_usetextlinks'), true ); ?> /> <?php _e("Use text links without images?", "sociable"); ?>
|
1044 |
</td>
|
1045 |
</tr>
|
1046 |
<tr>
|