-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-social.php
executable file
·96 lines (83 loc) · 3.18 KB
/
wp-social.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
add_action('wp_head','ubiq_add_socialgraph');
//add_action('wp_footer','ubiq_fb_javascriptapi');
//to avoid activating filters... get the excerpt manually
// make my own excerpt
function ubiq_showBrief($str, $length) {
$str = strip_tags($str);
$str = explode(" ", $str);
return implode(" " , array_slice($str, 0, $length));
}
function ubiq_add_socialgraph() {
if (!get_option('ubiq_fb_opengraph')) { return; }
if (is_single()) {
global $post;
$image_id = get_post_thumbnail_id($post->ID);
$image_url = wp_get_attachment_image_src( $image_id );
// create my excerpt for facebook
$content = $post->post_content;
$brief = ubiq_showBrief ($content, 55);
// get remaining variables
$title = get_the_title();
$link = get_permalink();
$sitename = get_bloginfo('name');
?>
<meta property="og:title" content="<?php echo $title; ?>"/>
<meta property="og:type" content="article"/>
<meta property="og:url" content="<?php echo $link; ?>"/>
<?php if ( has_post_thumbnail() ) { ?>
<meta property="og:image" content="<?php echo $image_url[0]; ?>"/>
<?php } else { ?>
<meta property="og:image" content="<?php echo header_image(); ?>"/>
<?php } ?>
<meta property="og:site_name" content="<?php echo $sitename; ?>"/>
<meta property="og:description" content="<?php echo $brief; ?>"/>
<?php if (get_option('ubiq_fb_appid')) { ?>
<meta property="fb:app_id" content="<?php echo get_option('ubiq_fb_appid') ?>" />
<?php } ?>
<?php
/*
if (function_exists('sharing_display')) {
add_filter( 'excerpt_length', 'calculate_excerpt_length' );
add_filter( 'the_excerpt', 'sharing_display', 19 );
}
*/
} else if(is_home()) {
?>
<meta property="og:title" content="<?php echo get_bloginfo('name') ?>"/>
<meta property="og:type" content="website"/>
<meta property="og:url" content="<?php bloginfo('url') ?>"/>
<meta property="og:image" content="<?php echo header_image(); ?>"/>
<meta property="og:site_name" content="<?php echo get_bloginfo('name') ?>"/>
<meta property="og:description" content="<?php echo bloginfo('description') ?>"/>
<?php if (get_option('ubiq_fb_appid')) { ?>
<meta property="fb:app_id" content="<?php echo get_option('ubiq_fb_appid') ?>" />
<?php } ?>
<?php
}
}
function ubiq_fb_javascriptapi() {
if (!get_option('ubiq_fb_javascriptsdk') && !get_option('ubiq_fb_appid') && !is_admin()) { return; }
$fbAppId = get_option('ubiq_fb_appid');
?>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: '<?php echo $fbAppId ?>', status: true, cookie: true,
xfbml: true});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
<?php
}
function ubiq_sitecard() {
include('widgets/sitecard.php');
}
function ubiq_social_buttons() {
include('widgets/social_buttons.php');
}