Version Description
- First release
Download this release
Release Info
Developer | wonderm00n |
Plugin | Open Graph for Facebook, Google+ and Twitter Card Tags |
Version | 0.1 |
Comparing to | |
See all releases |
Version 0.1
- includes/settings-page.php +241 -0
- readme.txt +32 -0
- readme.txt.bak +32 -0
- wonderm00n-open-graph.php +217 -0
includes/settings-page.php
ADDED
@@ -0,0 +1,241 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Wonderm00n's Simple Facebook Open Graph Tags
|
4 |
+
* @subpackage Settings Page
|
5 |
+
*
|
6 |
+
* @since 0.1
|
7 |
+
* @author Marco Almeida (Wonderm00n)
|
8 |
+
*
|
9 |
+
*
|
10 |
+
*/
|
11 |
+
|
12 |
+
//Init settings
|
13 |
+
if(intval(get_option("wonderm00n_open_graph_activated", ""))!=1) {
|
14 |
+
wonderm00n_open_graph_activate();
|
15 |
+
}
|
16 |
+
|
17 |
+
$fb_app_id_show = get_option('wonderm00n_open_graph_fb_app_id_show');
|
18 |
+
$fb_app_id = get_option('wonderm00n_open_graph_fb_app_id');
|
19 |
+
$fb_admin_id_show = get_option('wonderm00n_open_graph_fb_admin_id_show');
|
20 |
+
$fb_admin_id = get_option('wonderm00n_open_graph_fb_admin_id');
|
21 |
+
$fb_sitename_show = get_option('wonderm00n_open_graph_fb_sitename_show');
|
22 |
+
$fb_title_show = get_option('wonderm00n_open_graph_fb_title_show');
|
23 |
+
$fb_url_show = get_option('wonderm00n_open_graph_fb_url_show');
|
24 |
+
$fb_type_show = get_option('wonderm00n_open_graph_fb_type_show');
|
25 |
+
$fb_desc_show = get_option('wonderm00n_open_graph_fb_desc_show');
|
26 |
+
$fb_desc_chars = get_option('wonderm00n_open_graph_fb_desc_chars');
|
27 |
+
$fb_image_show = get_option('wonderm00n_open_graph_fb_image_show');
|
28 |
+
$fb_image = get_option('wonderm00n_open_graph_fb_image');
|
29 |
+
|
30 |
+
?>
|
31 |
+
<div class="wrap">
|
32 |
+
|
33 |
+
<?php screen_icon(); ?>
|
34 |
+
<h2>Wonderm00n's Simple Facebook Open Graph Tags</h2>
|
35 |
+
<br class="clear"/>
|
36 |
+
<p>Please set some default values and which tags should, or should not, be included. It may be necessary to exclude some tags if other plugins are already including them.</p>
|
37 |
+
|
38 |
+
<?php
|
39 |
+
settings_fields('wonderm00n_open_graph');
|
40 |
+
?>
|
41 |
+
|
42 |
+
<div class="postbox-container" style="width: 69%;">
|
43 |
+
<div id="poststuff">
|
44 |
+
<div id="wonderm00n_open_graph-settings" class="postbox">
|
45 |
+
<h3 id="settings">Settings</h3>
|
46 |
+
<div class="inside">
|
47 |
+
|
48 |
+
<form name="form1" method="post">
|
49 |
+
<table width="100%" class="form-table">
|
50 |
+
<tr>
|
51 |
+
<th scope="row" nowrap="nowrap">Include Facebook Platform App ID (og:app_id) tag?</th>
|
52 |
+
<td>
|
53 |
+
<input type="checkbox" name="fb_app_id_show" id="fb_app_id_show" value="1" <?php echo (intval($fb_app_id_show)==1 ? ' checked="checked"' : ''); ?>/>
|
54 |
+
</td>
|
55 |
+
</tr>
|
56 |
+
<tr>
|
57 |
+
<th scope="row" nowrap="nowrap">Facebook Platform App ID:</th>
|
58 |
+
<td>
|
59 |
+
<input type="text" name="fb_app_id" id="fb_app_id" size="30" value="<?php echo $fb_app_id; ?>"/>
|
60 |
+
</td>
|
61 |
+
</tr>
|
62 |
+
<tr>
|
63 |
+
<td> </td>
|
64 |
+
<td></td>
|
65 |
+
</tr>
|
66 |
+
<tr>
|
67 |
+
<th scope="row" nowrap="nowrap">Include Facebook Admin(s) ID (og:admins) tag?</th>
|
68 |
+
<td>
|
69 |
+
<input type="checkbox" name="fb_admin_id_show" id="fb_admin_id_show" value="1" <?php echo (intval($fb_admin_id_show)==1 ? ' checked="checked"' : ''); ?>/>
|
70 |
+
</td>
|
71 |
+
</tr>
|
72 |
+
<tr>
|
73 |
+
<th scope="row" nowrap="nowrap">Facebook Admin(s) ID:</th>
|
74 |
+
<td>
|
75 |
+
<input type="text" name="fb_admin_id" id="fb_admin_id" size="30" value="<?php echo $fb_admin_id; ?>"/>
|
76 |
+
<br/>
|
77 |
+
Comma separated if more than one
|
78 |
+
</td>
|
79 |
+
</tr>
|
80 |
+
<tr>
|
81 |
+
<td> </td>
|
82 |
+
<td></td>
|
83 |
+
</tr>
|
84 |
+
<tr>
|
85 |
+
<th scope="row" nowrap="nowrap">Include Site Name (og:site_name) tag?</th>
|
86 |
+
<td>
|
87 |
+
<input type="checkbox" name="fb_sitename_show" id="fb_sitename_show" value="1" <?php echo (intval($fb_sitename_show)==1 ? ' checked="checked"' : ''); ?>/>
|
88 |
+
</td>
|
89 |
+
</tr>
|
90 |
+
<tr>
|
91 |
+
<td> </td>
|
92 |
+
<td></td>
|
93 |
+
</tr>
|
94 |
+
<tr>
|
95 |
+
<th scope="row" nowrap="nowrap">Include Post/Page title (og:title) tag?</th>
|
96 |
+
<td>
|
97 |
+
<input type="checkbox" name="fb_title_show" id="fb_title_show" value="1" <?php echo (intval($fb_title_show)==1 ? ' checked="checked"' : ''); ?>/>
|
98 |
+
</td>
|
99 |
+
</tr>
|
100 |
+
<tr>
|
101 |
+
<td> </td>
|
102 |
+
<td></td>
|
103 |
+
</tr>
|
104 |
+
<tr>
|
105 |
+
<th scope="row" nowrap="nowrap">Include URL (og:url) tag?</th>
|
106 |
+
<td>
|
107 |
+
<input type="checkbox" name="fb_url_show" id="fb_url_show" value="1" <?php echo (intval($fb_url_show)==1 ? ' checked="checked"' : ''); ?>/>
|
108 |
+
</td>
|
109 |
+
</tr>
|
110 |
+
<tr>
|
111 |
+
<td> </td>
|
112 |
+
<td></td>
|
113 |
+
</tr>
|
114 |
+
<tr>
|
115 |
+
<th scope="row" nowrap="nowrap">Include Type (og:type) tag?</th>
|
116 |
+
<td>
|
117 |
+
<input type="checkbox" name="fb_type_show" id="fb_type_show" value="1" <?php echo (intval($fb_type_show)==1 ? ' checked="checked"' : ''); ?>/>
|
118 |
+
(will be "article" for posts and pages and "website" for the homepage)
|
119 |
+
</td>
|
120 |
+
</tr>
|
121 |
+
<tr>
|
122 |
+
<td> </td>
|
123 |
+
<td></td>
|
124 |
+
</tr>
|
125 |
+
<tr>
|
126 |
+
<th scope="row" nowrap="nowrap">Include Description (og:description) tag?</th>
|
127 |
+
<td>
|
128 |
+
<input type="checkbox" name="fb_desc_show" id="fb_desc_show" value="1" <?php echo (intval($fb_desc_show)==1 ? ' checked="checked"' : ''); ?>/>
|
129 |
+
</td>
|
130 |
+
</tr>
|
131 |
+
<tr>
|
132 |
+
<th scope="row" nowrap="nowrap">Description maximum length:</th>
|
133 |
+
<td>
|
134 |
+
<input type="text" name="fb_desc_chars" id="fb_desc_chars" size="3" maxlength="3" value="<?php echo (intval($fb_desc_chars)>0 ? intval($fb_desc_chars) : ''); ?>"/> characters
|
135 |
+
<br/>
|
136 |
+
0 or blank for no maximum length
|
137 |
+
</td>
|
138 |
+
</tr>
|
139 |
+
<tr>
|
140 |
+
<td> </td>
|
141 |
+
<td></td>
|
142 |
+
</tr>
|
143 |
+
<tr>
|
144 |
+
<th scope="row" nowrap="nowrap">Include Image (og:image) tag?</th>
|
145 |
+
<td>
|
146 |
+
<input type="checkbox" name="fb_image_show" id="fb_image_show" value="1" <?php echo (intval($fb_image_show)==1 ? ' checked="checked"' : ''); ?>/>
|
147 |
+
</td>
|
148 |
+
</tr>
|
149 |
+
<tr>
|
150 |
+
<th scope="row" nowrap="nowrap">Default image:</th>
|
151 |
+
<td>
|
152 |
+
<input type="text" name="fb_image" id="fb_image" size="50" value="<?php echo $fb_image; ?>"/>
|
153 |
+
<input id="fb_image_button" class="button" type="button" value="Upload/Choose image" />
|
154 |
+
<br/>
|
155 |
+
Full URL with http://
|
156 |
+
</td>
|
157 |
+
</tr>
|
158 |
+
</table>
|
159 |
+
<p class="submit">
|
160 |
+
<input type="hidden" name="action" value="save"/>
|
161 |
+
<input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
|
162 |
+
</p>
|
163 |
+
</form>
|
164 |
+
|
165 |
+
</div>
|
166 |
+
</div>
|
167 |
+
</div>
|
168 |
+
</div>
|
169 |
+
|
170 |
+
<?php
|
171 |
+
$links[0]['text']='Test your URLs at Facebook URL Linter';
|
172 |
+
$links[0]['url']='https://developers.facebook.com/tools/debug';
|
173 |
+
$links[10]['text']='About the Open Graph Protocol (on Facebook)';
|
174 |
+
$links[10]['url']='https://developers.facebook.com/docs/opengraph/';
|
175 |
+
$links[20]['text']='The Open Graph Protocol (official website)';
|
176 |
+
$links[20]['url']='http://ogp.me/';
|
177 |
+
$links[30]['text']='Plugin official URL (feedback is welcomed)';
|
178 |
+
$links[30]['url']='http://blog.wonderm00n.com/2011/10/14/wordpress-plugin-simple-facebook-open-graph-tags/';
|
179 |
+
$links[40]['text']='Author\'s website: Marco Almeida (Wonderm00n)';
|
180 |
+
$links[40]['url']='http://wonderm00n.com';
|
181 |
+
?>
|
182 |
+
<div class="postbox-container" style="width: 29%;">
|
183 |
+
|
184 |
+
<div id="poststuff">
|
185 |
+
<div id="wonderm00n_open_graph_links" class="postbox">
|
186 |
+
<h3 id="settings">Useful links</h3>
|
187 |
+
<div class="inside">
|
188 |
+
<ul>
|
189 |
+
<?php foreach($links as $link) { ?>
|
190 |
+
<li>- <a href="<?php echo $link['url']; ?>" target="_blank"><?php echo $link['text']; ?></a></li>
|
191 |
+
<?php } ?>
|
192 |
+
</ul>
|
193 |
+
</div>
|
194 |
+
</div>
|
195 |
+
</div>
|
196 |
+
|
197 |
+
<div id="poststuff">
|
198 |
+
<div id="wonderm00n_open_graph_donation" class="postbox">
|
199 |
+
<h3 id="settings">Donate</h3>
|
200 |
+
<div class="inside">
|
201 |
+
<p>If you find this plugin useful and want to make a contribution towards future development please consider making a small, or big ;-), donation.</p>
|
202 |
+
<center><form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
|
203 |
+
<input type="hidden" name="cmd" value="_donations">
|
204 |
+
<input type="hidden" name="business" value="wonderm00n@gmail.com">
|
205 |
+
<input type="hidden" name="lc" value="PT">
|
206 |
+
<input type="hidden" name="item_name" value="Marco Almeida (Wonderm00n)">
|
207 |
+
<input type="hidden" name="item_number" value="wonderm00n_open_graph">
|
208 |
+
<input type="hidden" name="currency_code" value="USD">
|
209 |
+
<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHosted">
|
210 |
+
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
|
211 |
+
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
212 |
+
</form></center>
|
213 |
+
</div>
|
214 |
+
</div>
|
215 |
+
</div>
|
216 |
+
|
217 |
+
</div>
|
218 |
+
|
219 |
+
<div class="clear">
|
220 |
+
<p><br/>© 2011<?php if(date('Y')>2010) echo '-'.date('Y'); ?> <a href="http://wonderm00n.com" target="_blank">Marco Almeida (Wonderm00n)</a></p>
|
221 |
+
</div>
|
222 |
+
|
223 |
+
</div>
|
224 |
+
|
225 |
+
<script type="text/javascript">
|
226 |
+
jQuery(document).ready(function() {
|
227 |
+
jQuery('#fb_image_button').click(function(){
|
228 |
+
tb_show('',"media-upload.php?type=image&TB_iframe=true");
|
229 |
+
});
|
230 |
+
window.send_to_editor = function(html) {
|
231 |
+
imgurl = jQuery('img',html).attr('src');
|
232 |
+
jQuery("input"+"#fb_image").val(imgurl);
|
233 |
+
tb_remove();
|
234 |
+
}
|
235 |
+
});
|
236 |
+
</script>
|
237 |
+
<style type="text/css">
|
238 |
+
TABLE.form-table TR TH {
|
239 |
+
font-weight: bold;
|
240 |
+
}
|
241 |
+
</style>
|
readme.txt
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: wonderm00n
|
3 |
+
Donate link: http://example.com/
|
4 |
+
Tags: facebook, open graph, seo, share
|
5 |
+
Stable tag: 0.1
|
6 |
+
|
7 |
+
This plugin inserts Facebook Open Grpah Tags into your WordPress Blog/Website for more effective Facebook sharing results.
|
8 |
+
|
9 |
+
== Description ==
|
10 |
+
|
11 |
+
It allows the user to choose which tags are, or not, included and also the default image if the post/page doesn't have one.
|
12 |
+
|
13 |
+
The tags that this plugin inserts are:
|
14 |
+
* og:app_id : From settings on the options screen
|
15 |
+
* og:admins : From settings on the options screen
|
16 |
+
* og:site_name : From blog title
|
17 |
+
* og:title : From post/page/archive/tag/... title
|
18 |
+
* og:url : From the post/page permalink
|
19 |
+
* og:type : "article" for posts and pages and "website" for all the others
|
20 |
+
* og:description : From post/page excerpt if it exists, or from post/page content
|
21 |
+
* og:image : From post/page featured/thumbnail image, or if it doesn't exists from the first image in the post content, or if it doesn't exists from the first image on the post media gallery, or if it doesn't exists from the default image defined on the options menu
|
22 |
+
|
23 |
+
== Installation ==
|
24 |
+
|
25 |
+
1. Upload the `wonderm00n-open-graph` to the `/wp-content/plugins/` directory
|
26 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress
|
27 |
+
3. Got to `Options`, `Wonderm00n's Open Graph` to set it up
|
28 |
+
|
29 |
+
== Changelog ==
|
30 |
+
|
31 |
+
= 0.1 =
|
32 |
+
* First release
|
readme.txt.bak
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Plugin Name ===
|
2 |
+
Contributors: wonderm00n
|
3 |
+
Donate link: http://example.com/
|
4 |
+
Tags: facebook, open graph, seo
|
5 |
+
Stable tag: 0.1
|
6 |
+
|
7 |
+
This plugin inserts Facebook Open Grpah Tags into your WordPress Blog/Website for more effective Facebook sharing results.
|
8 |
+
|
9 |
+
== Description ==
|
10 |
+
|
11 |
+
It allows the user to choose which tags are, or not, included and also the default image if the post/page doesn't have one.
|
12 |
+
|
13 |
+
The tags that this plugin inserts are:
|
14 |
+
* og:app_id : From settings on the options screen
|
15 |
+
* og:admins : From settings on the options screen
|
16 |
+
* og:site_name : From blog title
|
17 |
+
* og:title : From post/page/archive/tag/... title
|
18 |
+
* og:url : From the post/page permalink
|
19 |
+
* og:type : "article" for posts and pages and "website" for all the others
|
20 |
+
* og:description : From post/page excerpt if it exists, or from post/page content
|
21 |
+
* og:image : From post/page featured/thumbnail image, or if it doesn't exists from the first image in the post content, or if it doesn't exists from the first image on the post media gallery, or if it doesn't exists from the default image defined on the options menu
|
22 |
+
|
23 |
+
== Installation ==
|
24 |
+
|
25 |
+
1. Upload the `wonderm00n-open-graph` to the `/wp-content/plugins/` directory
|
26 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress
|
27 |
+
3. Got to `Options`, `Wonderm00n's Open Graph` to set it up
|
28 |
+
|
29 |
+
== Changelog ==
|
30 |
+
|
31 |
+
= 0.1 =
|
32 |
+
* First release
|
wonderm00n-open-graph.php
ADDED
@@ -0,0 +1,217 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Wonderm00n's Simple Facebook Open Graph Tags
|
4 |
+
* @version 0.1
|
5 |
+
*/
|
6 |
+
/*
|
7 |
+
Plugin Name: Wonderm00n's Simple Facebook Open Graph Tags
|
8 |
+
Plugin URI: http://blog.wonderm00n.com/2011/10/14/wordpress-plugin-simple-facebook-open-graph-tags/
|
9 |
+
Description: This plugin inserts Facebook Open Graph Tags into your Wordpress Blog/Website for better Facebook sharing
|
10 |
+
Author: Marco Almeida (Wonderm00n)
|
11 |
+
Version: 0.1
|
12 |
+
Author URI: http://wonderm00n.com
|
13 |
+
*/
|
14 |
+
|
15 |
+
function wonderm00n_open_graph() {
|
16 |
+
|
17 |
+
//This should be set by options on wp-admin
|
18 |
+
$fb_app_id_show=get_option('wonderm00n_open_graph_fb_app_id_show');
|
19 |
+
$fb_app_id=get_option('wonderm00n_open_graph_fb_app_id');
|
20 |
+
$fb_admin_id_show=get_option('wonderm00n_open_graph_fb_admin_id_show');
|
21 |
+
$fb_admin_id=get_option('wonderm00n_open_graph_fb_admin_id');
|
22 |
+
$fb_sitename_show=get_option('wonderm00n_open_graph_fb_sitename_show');
|
23 |
+
$fb_title_show=get_option('wonderm00n_open_graph_fb_title_show');
|
24 |
+
$fb_url_show=get_option('wonderm00n_open_graph_fb_url_show');
|
25 |
+
$fb_type_show=get_option('wonderm00n_open_graph_fb_type_show');
|
26 |
+
$fb_desc_show=get_option('wonderm00n_open_graph_fb_desc_show');
|
27 |
+
$fb_desc_chars=intval(get_option('wonderm00n_open_graph_fb_desc_chars'));
|
28 |
+
$fb_image_show=get_option('wonderm00n_open_graph_fb_image_show');
|
29 |
+
$fb_image=get_option('wonderm00n_open_graph_fb_image');
|
30 |
+
|
31 |
+
if (is_singular()) {
|
32 |
+
//It's a Post or a Page or an attachment page
|
33 |
+
global $post;
|
34 |
+
$fb_title=esc_attr(strip_tags(stripslashes($post->post_title)));
|
35 |
+
$fb_url=get_permalink();
|
36 |
+
$fb_type='article';
|
37 |
+
if (trim($post->post_excerpt)!='') {
|
38 |
+
//If there's an excerpt that's waht we'll use
|
39 |
+
$fb_desc=trim($post->post_excerpt);
|
40 |
+
} else {
|
41 |
+
//If not we grab it from the content
|
42 |
+
$fb_desc=trim($post->post_content);
|
43 |
+
}
|
44 |
+
$fb_desc=(intval($fb_desc_chars)>0 ? substr(esc_attr(strip_tags(stripslashes($fb_desc))),0,$fb_desc_chars) : esc_attr(strip_tags(stripslashes($fb_desc))));
|
45 |
+
if ($id_attachment=get_post_thumbnail_id($post->ID)) {
|
46 |
+
//There's a featured/thumbnail image for this post
|
47 |
+
$fb_image=wp_get_attachment_url($id_attachment, false);
|
48 |
+
} else {
|
49 |
+
//If not, we'll try to get the first image on the post content
|
50 |
+
$imgreg = '/<img .*src=["\']([^ ^"^\']*)["\']/';
|
51 |
+
preg_match_all($imgreg, trim($post->post_content), $matches);
|
52 |
+
$image=$matches[1][0];
|
53 |
+
if ($image) {
|
54 |
+
//There's an image on the content
|
55 |
+
$pos = strpos($image, site_url());
|
56 |
+
if ($pos === false) {
|
57 |
+
$fb_image=$_SERVER['HTTP_HOST'].$image;
|
58 |
+
} else {
|
59 |
+
$fb_image=$image;
|
60 |
+
}
|
61 |
+
} else {
|
62 |
+
//If not, we'll try to get the first image associated to the post, even if not used on the content
|
63 |
+
$images = get_posts(array('post_type' => 'attachment','numberposts' => 1,'post_status' => null,'order' => 'ASC','orderby' => 'menu_order','post_mime_type' => 'image','post_parent' => $post->ID));
|
64 |
+
if ($images) {
|
65 |
+
$fb_image=wp_get_attachment_url($images[0]->ID, false);
|
66 |
+
} else {
|
67 |
+
//Well... We sure did try. We'll just keep the default one :-(
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
} else {
|
72 |
+
//Other pages - Defaults
|
73 |
+
$fb_title=esc_attr(strip_tags(stripslashes(get_bloginfo('name'))));
|
74 |
+
$fb_url=get_option('siteurl');
|
75 |
+
$fb_type='website';
|
76 |
+
$fb_desc=esc_attr(strip_tags(stripslashes(get_bloginfo('description'))));
|
77 |
+
|
78 |
+
if (is_category()) {
|
79 |
+
$fb_title=esc_attr(strip_tags(stripslashes(single_cat_title('', false))));
|
80 |
+
$term=get_queried_object();
|
81 |
+
$fb_url=get_term_link($term, $term->taxonomy);
|
82 |
+
} else {
|
83 |
+
if (is_tag()) {
|
84 |
+
$fb_title=esc_attr(strip_tags(stripslashes(single_tag_title('', false))));
|
85 |
+
$term=get_queried_object();
|
86 |
+
$fb_url=get_term_link($term, $term->taxonomy);
|
87 |
+
} else {
|
88 |
+
if (is_tax()) {
|
89 |
+
$fb_title=esc_attr(strip_tags(stripslashes(single_term_title('', false))));
|
90 |
+
$term=get_queried_object();
|
91 |
+
$fb_url=get_term_link($term, $term->taxonomy);
|
92 |
+
} else {
|
93 |
+
if (is_search()) {
|
94 |
+
$fb_title=esc_attr(strip_tags(stripslashes(__('Search for').' "'.get_search_query().'"')));
|
95 |
+
$fb_url=get_search_link();
|
96 |
+
} else {
|
97 |
+
if (is_author()) {
|
98 |
+
$fb_title=esc_attr(strip_tags(stripslashes(get_the_author_meta('display_name', get_query_var('author')))));
|
99 |
+
$fb_url=get_author_posts_url(get_query_var('author'), get_query_var('author_name'));
|
100 |
+
} else {
|
101 |
+
if (is_archive()) {
|
102 |
+
if (is_day()) {
|
103 |
+
$fb_title=esc_attr(strip_tags(stripslashes(get_query_var('day').' '.single_month_title(' ', false).' '.__('Archives'))));
|
104 |
+
$fb_url=get_day_link(get_query_var('year'), get_query_var('monthnum'), get_query_var('day'));
|
105 |
+
} else {
|
106 |
+
if (is_month()) {
|
107 |
+
$fb_title=esc_attr(strip_tags(stripslashes(single_month_title(' ', false).' '.__('Archives'))));
|
108 |
+
$fb_url=get_month_link(get_query_var('year'), get_query_var('monthnum'));
|
109 |
+
} else {
|
110 |
+
if (is_year()) {
|
111 |
+
$fb_title=esc_attr(strip_tags(stripslashes(get_query_var('year').' '.__('Archives'))));
|
112 |
+
$fb_url=get_year_link(get_query_var('year'));
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
} else {
|
117 |
+
//Home or others... Defaults already set up there
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
$html.='<!-- START - Wonderm00n\'s Simple Facebook Open Graph Tags -->
|
127 |
+
';
|
128 |
+
if (intval($fb_app_id_show)==1 && trim($fb_app_id)!='') $html.='<meta property="fb:app_id" content="'.trim($fb_app_id).'" />
|
129 |
+
';
|
130 |
+
if (intval($fb_admin_id_show)==1 && trim($fb_admin_id)!='') $html.='<meta property="fb:admins" content="'.trim($fb_admin_id).'" />
|
131 |
+
';
|
132 |
+
if (intval($fb_sitename_show)==1) $html.='<meta property="og:site_name" content="'.get_bloginfo('name').'" />
|
133 |
+
';
|
134 |
+
if (intval($fb_title_show)==1) $html.='<meta property="og:title" content="'.trim($fb_title).'" />
|
135 |
+
';
|
136 |
+
if (intval($fb_url_show)==1) $html.='<meta property="og:url" content="'.trim(esc_attr($fb_url)).'" />
|
137 |
+
';
|
138 |
+
if (intval($fb_type_show)==1) $html.='<meta property="og:type" content="'.trim(esc_attr($fb_type)).'" />
|
139 |
+
';
|
140 |
+
if (intval($fb_desc_show)==1) $html.='<meta property="og:description" content="'.trim($fb_desc).'" />
|
141 |
+
';
|
142 |
+
if(intval($fb_image_show)==1 && trim($fb_image)!='') $html.='<meta property="og:image" content="'.trim(esc_attr($fb_image)).'" />
|
143 |
+
';
|
144 |
+
$html.='<!-- END - Wonderm00n\'s Simple Facebook Open Graph Tags -->
|
145 |
+
';
|
146 |
+
echo $html;
|
147 |
+
}
|
148 |
+
|
149 |
+
add_action('wp_head', 'wonderm00n_open_graph', 1);
|
150 |
+
|
151 |
+
//Admin
|
152 |
+
if ( is_admin() ){
|
153 |
+
add_action('admin_menu', 'wonderm00n_open_graph_add_options');
|
154 |
+
}
|
155 |
+
add_action('activate_wonderm00n-open-graph/wonderm00n-open-graph.php', 'wonderm00n_open_graph_activate');
|
156 |
+
|
157 |
+
function wonderm00n_open_graph_add_options() {
|
158 |
+
if(function_exists('add_options_page')){
|
159 |
+
add_options_page('Wonderm00n\'s Open Graph', 'Wonderm00n\'s Open Graph', 9, basename(__FILE__), 'wonderm00n_open_graph_admin');
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
function wonderm00n_open_graph_activate() {
|
164 |
+
update_option("wonderm00n_open_graph_activated", 1);
|
165 |
+
update_option("wonderm00n_open_graph_fb_admin_id_show", 1);
|
166 |
+
update_option("wonderm00n_open_graph_fb_app_id_show", 1);
|
167 |
+
update_option("wonderm00n_open_graph_fb_sitename_show", 1);
|
168 |
+
update_option("wonderm00n_open_graph_fb_title_show", 1);
|
169 |
+
update_option("wonderm00n_open_graph_fb_url_show", 1);
|
170 |
+
update_option("wonderm00n_open_graph_fb_type_show", 1);
|
171 |
+
update_option("wonderm00n_open_graph_fb_desc_show", 1);
|
172 |
+
update_option("wonderm00n_open_graph_fb_desc_chars", 300);
|
173 |
+
update_option("wonderm00n_open_graph_fb_image_show", 1);
|
174 |
+
}
|
175 |
+
|
176 |
+
function wonderm00n_open_graph_settings_link( $links, $file ) {
|
177 |
+
if( $file == 'wonderm00n-open-graph/wonderm00n-open-graph.php' && function_exists( "admin_url" ) ) {
|
178 |
+
$settings_link = '<a href="' . admin_url( 'options-general.php?page=wonderm00n-open-graph.php' ) . '">' . __('Settings') . '</a>';
|
179 |
+
array_push( $links, $settings_link ); // after other links
|
180 |
+
}
|
181 |
+
return $links;
|
182 |
+
}
|
183 |
+
add_filter( 'plugin_action_links', 'wonderm00n_open_graph_settings_link', 9, 2 );
|
184 |
+
|
185 |
+
|
186 |
+
function wonderm00n_open_graph_admin() {
|
187 |
+
include_once 'includes/settings-page.php';
|
188 |
+
}
|
189 |
+
|
190 |
+
function wonderm00n_open_graph_scripts() {
|
191 |
+
wp_enqueue_script('media-upload');
|
192 |
+
wp_enqueue_script('thickbox');
|
193 |
+
wp_enqueue_script('jquery');
|
194 |
+
}
|
195 |
+
function wonderm00n_open_graph_styles() {
|
196 |
+
wp_enqueue_style('thickbox');
|
197 |
+
}
|
198 |
+
add_action('admin_print_scripts', 'wonderm00n_open_graph_scripts');
|
199 |
+
add_action('admin_print_styles', 'wonderm00n_open_graph_styles');
|
200 |
+
|
201 |
+
if ( isset($_POST['action']) ) {
|
202 |
+
if (trim($_POST['action'])=='save') {
|
203 |
+
update_option('wonderm00n_open_graph_fb_app_id_show', intval($_POST['fb_app_id_show']));
|
204 |
+
update_option('wonderm00n_open_graph_fb_app_id', trim($_POST['fb_app_id']));
|
205 |
+
update_option('wonderm00n_open_graph_fb_admin_id_show', intval($_POST['fb_admin_id_show']));
|
206 |
+
update_option('wonderm00n_open_graph_fb_admin_id', trim($_POST['fb_admin_id']));
|
207 |
+
update_option('wonderm00n_open_graph_fb_sitename_show', intval($_POST['fb_sitename_show']));
|
208 |
+
update_option('wonderm00n_open_graph_fb_title_show', intval($_POST['fb_title_show']));
|
209 |
+
update_option('wonderm00n_open_graph_fb_url_show', intval($_POST['fb_url_show']));
|
210 |
+
update_option('wonderm00n_open_graph_fb_type_show', intval($_POST['fb_type_show']));
|
211 |
+
update_option('wonderm00n_open_graph_fb_desc_show', intval($_POST['fb_desc_show']));
|
212 |
+
update_option('wonderm00n_open_graph_fb_desc_chars', intval($_POST['fb_desc_chars']));
|
213 |
+
update_option('wonderm00n_open_graph_fb_image', trim($_POST['fb_image']));
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
?>
|