Open Graph for Facebook, Google+ and Twitter Card Tags - Version 0.3

Version Description

  • "SubHeading" plugin integration. It's now possible add this field to the "og:title" tag.
  • Changed the way defaults and user settings are loaded and saved, to "try" to eliminate the problem some users experienced where the user settings would disappear.
  • Bugfix: "Also add image to RSS/RSS2 feeds?" option was not being correctly loaded
  • The plugin version is now showed both as a comment before the open graph tags and on the settings page
Download this release

Release Info

Developer wonderm00n
Plugin Icon Open Graph for Facebook, Google+ and Twitter Card Tags
Version 0.3
Comparing to
See all releases

Code changes from version 0.2.3 to 0.3

Files changed (3) hide show
  1. includes/settings-page.php +266 -253
  2. readme.txt +9 -2
  3. wonderm00n-open-graph.php +81 -42
includes/settings-page.php CHANGED
@@ -9,40 +9,24 @@
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_locale_show=get_option('wonderm00n_open_graph_fb_locale_show');
22
- $fb_locale = get_option('wonderm00n_open_graph_fb_locale');
23
- $fb_sitename_show=get_option('wonderm00n_open_graph_fb_sitename_show');
24
- $fb_title_show=get_option('wonderm00n_open_graph_fb_title_show');
25
- $fb_url_show=get_option('wonderm00n_open_graph_fb_url_show');
26
- $fb_url_add_trailing=get_option('wonderm00n_open_graph_fb_url_add_trailing');
27
- $fb_type_show=get_option('wonderm00n_open_graph_fb_type_show');
28
- $fb_type_homepage=get_option('wonderm00n_open_graph_fb_type_homepage');
29
- $fb_desc_show=get_option('wonderm00n_open_graph_fb_desc_show');
30
- $fb_desc_chars=intval(get_option('wonderm00n_open_graph_fb_desc_chars'));
31
- $fb_desc_homepage = get_option('wonderm00n_open_graph_fb_desc_homepage');
32
- $fb_desc_homepage_customtext = get_option('wonderm00n_open_graph_fb_desc_homepage_customtext');
33
- $fb_image_show=get_option('wonderm00n_open_graph_fb_image_show');
34
- $fb_image=get_option('wonderm00n_open_graph_fb_image');
35
- $fb_image_rss=get_option('wonderm00n_open_graph_fb_image_rss');
36
- $fb_image_use_featured=get_option('wonderm00n_open_graph_fb_image_use_featured');
37
- $fb_image_use_content=get_option('wonderm00n_open_graph_fb_image_use_content');
38
- $fb_image_use_media=get_option('wonderm00n_open_graph_fb_image_use_media');
39
- $fb_image_use_default=get_option('wonderm00n_open_graph_fb_image_use_default');
40
 
41
  ?>
42
  <div class="wrap">
43
 
44
  <?php screen_icon(); ?>
45
- <h2>Wonderm00n's Simple Facebook Open Graph Tags</h2>
46
  <br class="clear"/>
47
  <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>
48
 
@@ -52,236 +36,265 @@
52
 
53
  <div class="postbox-container" style="width: 69%;">
54
  <div id="poststuff">
55
- <div id="wonderm00n_open_graph-settings" class="postbox">
56
- <h3 id="settings">Settings</h3>
57
- <div class="inside">
58
-
59
- <form name="form1" method="post">
60
- <table width="100%" class="form-table">
61
- <tr>
62
- <th scope="row" nowrap="nowrap">Include Facebook Platform App ID (fb:app_id) tag?</th>
63
- <td>
64
- <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"' : ''); ?> onclick="showAppidOptions();"/>
65
- </td>
66
- </tr>
67
- <tr class="fb_app_id_options">
68
- <th scope="row" nowrap="nowrap">Facebook Platform App ID:</th>
69
- <td>
70
- <input type="text" name="fb_app_id" id="fb_app_id" size="30" value="<?php echo $fb_app_id; ?>"/>
71
- </td>
72
- </tr>
73
- <tr>
74
- <td>&nbsp;</td>
75
- <td></td>
76
- </tr>
77
- <tr>
78
- <th scope="row" nowrap="nowrap">Include Facebook Admin(s) ID (fb:admins) tag?</th>
79
- <td>
80
- <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"' : ''); ?> onclick="showAdminOptions();"/>
81
- </td>
82
- </tr>
83
- <tr class="fb_admin_id_options">
84
- <th scope="row" nowrap="nowrap">Facebook Admin(s) ID:</th>
85
- <td>
86
- <input type="text" name="fb_admin_id" id="fb_admin_id" size="30" value="<?php echo $fb_admin_id; ?>"/>
87
- <br/>
88
- Comma separated if more than one
89
- </td>
90
- </tr>
91
- <tr>
92
- <td>&nbsp;</td>
93
- <td></td>
94
- </tr>
95
- <tr>
96
- <th scope="row" nowrap="nowrap">Include locale (fb:locale) tag?</th>
97
- <td>
98
- <input type="checkbox" name="fb_locale_show" id="fb_locale_show" value="1" <?php echo (intval($fb_locale_show)==1 ? ' checked="checked"' : ''); ?> onclick="showLocaleOptions();"/>
99
- </td>
100
- </tr>
101
- <tr class="fb_locale_options">
102
- <th scope="row" nowrap="nowrap">Locale:</th>
103
- <td>
104
- <select name="fb_locale" id="fb_locale">
105
- <option value=""<?php if (trim($fb_locale)=='') echo ' selected="selected"'; ?>>Wordpress current locale/language (<?php echo get_locale(); ?>)&nbsp;</option>
106
- <?php
107
- $listLocales=false;
108
- //Online
109
- if ($ch = curl_init('http://www.facebook.com/translations/FacebookLocales.xmla')) {
110
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
111
- $fb_locales=curl_exec($ch);
112
- if (curl_errno($ch)) {
113
- //echo curl_error($ch);
114
- } else {
115
- $info = curl_getinfo($ch);
116
- if (intval($info['http_code'])==200) {
117
- $listLocales=true;
118
  }
 
119
  }
120
- curl_close($ch);
121
- }
122
- //Offline
123
- if (!$listLocales) {
124
- if ($fb_locales=file_get_contents(ABSPATH . 'wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/FacebookLocales.xml')) {
125
- $listLocales=true;
126
  }
127
- }
128
- //OK
129
- if ($listLocales) {
130
- $xml=simplexml_load_string($fb_locales);
131
- $json = json_encode($xml);
132
- $locales = json_decode($json,TRUE);
133
- if (is_array($locales['locale'])) {
134
- foreach ($locales['locale'] as $locale) {
135
- ?><option value="<?php echo $locale['codes']['code']['standard']['representation']; ?>"<?php if (trim($fb_locale)==trim($locale['codes']['code']['standard']['representation'])) echo ' selected="selected"'; ?>><?php echo $locale['englishName']; ?> (<?php echo $locale['codes']['code']['standard']['representation']; ?>)</option><?php
136
  }
137
  }
138
- }
139
- ?>
140
- </select>
141
- </td>
142
- </tr>
143
- <tr>
144
- <td>&nbsp;</td>
145
- <td></td>
146
- </tr>
147
- <tr>
148
- <th scope="row" nowrap="nowrap">Include Site Name (og:site_name) tag?</th>
149
- <td>
150
- <input type="checkbox" name="fb_sitename_show" id="fb_sitename_show" value="1" <?php echo (intval($fb_sitename_show)==1 ? ' checked="checked"' : ''); ?>/>
151
- </td>
152
- </tr>
153
- <tr>
154
- <td>&nbsp;</td>
155
- <td></td>
156
- </tr>
157
- <tr>
158
- <th scope="row" nowrap="nowrap">Include Post/Page title (og:title) tag?</th>
159
- <td>
160
- <input type="checkbox" name="fb_title_show" id="fb_title_show" value="1" <?php echo (intval($fb_title_show)==1 ? ' checked="checked"' : ''); ?>/>
161
- </td>
162
- </tr>
163
- <tr>
164
- <td>&nbsp;</td>
165
- <td></td>
166
- </tr>
167
- <tr>
168
- <th scope="row" nowrap="nowrap">Include URL (og:url) tag?</th>
169
- <td>
170
- <input type="checkbox" name="fb_url_show" id="fb_url_show" value="1" <?php echo (intval($fb_url_show)==1 ? ' checked="checked"' : ''); ?> onclick="showUrlOptions();"/>
171
- </td>
172
- </tr>
173
- <tr class="fb_url_options">
174
- <th scope="row" nowrap="nowrap">Add trailing slash at the end:</th>
175
- <td>
176
- <input type="checkbox" name="fb_url_add_trailing" id="fb_url_add_trailing" value="1" <?php echo (intval($fb_url_add_trailing)==1 ? ' checked="checked"' : ''); ?> onclick="showUrlTrail();"/>
177
- (on the homepage will be: <i><?php echo get_option('siteurl'); ?><span id="fb_url_add_trailing_example">/</span></i>)
178
- </td>
179
- </tr>
180
- <tr>
181
- <td>&nbsp;</td>
182
- <td></td>
183
- </tr>
184
- <tr>
185
- <th scope="row" nowrap="nowrap">Include Type (og:type) tag?</th>
186
- <td>
187
- <input type="checkbox" name="fb_type_show" id="fb_type_show" value="1" <?php echo (intval($fb_type_show)==1 ? ' checked="checked"' : ''); ?> onclick="showTypeOptions();"/>
188
- (will be &quot;article&quot; for posts and pages and &quot;website&quot; or &quot;blog&quot; for the homepage)
189
- </td>
190
- </tr>
191
- <tr class="fb_type_options">
192
- <th scope="row" nowrap="nowrap">Homepage type:</th>
193
- <td>
194
- Use
195
- <select name="fb_type_homepage" id="fb_type_homepage">
196
- <option value="website"<?php if (trim($fb_type_homepage)=='' || trim($fb_type_homepage)=='website') echo ' selected="selected"'; ?>>website&nbsp;</option>
197
- <option value="blog"<?php if (trim($fb_type_homepage)=='blog') echo ' selected="selected"'; ?>>blog&nbsp;</option>
198
- </select>
199
- </td>
200
- </tr>
201
- <tr>
202
- <td>&nbsp;</td>
203
- <td></td>
204
- </tr>
205
- <tr>
206
- <th scope="row" nowrap="nowrap">Include Description (og:description) tag?</th>
207
- <td>
208
- <input type="checkbox" name="fb_desc_show" id="fb_desc_show" value="1" <?php echo (intval($fb_desc_show)==1 ? ' checked="checked"' : ''); ?> onclick="showDescriptionOptions();"/>
209
- </td>
210
- </tr>
211
- <tr class="fb_description_options">
212
- <th scope="row" nowrap="nowrap">Description maximum length:</th>
213
- <td>
214
- <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, 0 or blank for no maximum length
215
- </td>
216
- </tr>
217
- <tr class="fb_description_options">
218
- <th scope="row" nowrap="nowrap">Homepage description:</th>
219
- <td>
220
- Use
221
- <select name="fb_desc_homepage" id="fb_desc_homepage" onchange="showDescriptionCustomText();">
222
- <option value=""<?php if (trim($fb_desc_homepage)=='') echo ' selected="selected"'; ?>>Website tagline&nbsp;</option>
223
- <option value="custom"<?php if (trim($fb_desc_homepage)=='custom') echo ' selected="selected"'; ?>>Custom text&nbsp;</option>
224
- </select>
225
- <div id="fb_desc_homepage_customtext_div">
226
- <textarea name="fb_desc_homepage_customtext" id="fb_desc_homepage_customtext" rows="3" cols="50"><?php echo $fb_desc_homepage_customtext; ?></textarea>
227
- </div>
228
- </td>
229
- </tr>
230
- <tr>
231
- <td>&nbsp;</td>
232
- <td></td>
233
- </tr>
234
- <tr>
235
- <th scope="row" nowrap="nowrap">Include Image (og:image) tag?</th>
236
- <td>
237
- <input type="checkbox" name="fb_image_show" id="fb_image_show" value="1" <?php echo (intval($fb_image_show)==1 ? ' checked="checked"' : ''); ?> onclick="showImageOptions();"/>
238
- </td>
239
- </tr>
240
- <tr class="fb_image_options">
241
- <th scope="row" nowrap="nowrap">Default image:</th>
242
- <td>
243
- <input type="text" name="fb_image" id="fb_image" size="50" value="<?php echo $fb_image; ?>"/>
244
- <input id="fb_image_button" class="button" type="button" value="Upload/Choose image" />
245
- <br/>
246
- Full URL with http://
247
- </td>
248
- </tr>
249
- <tr class="fb_image_options">
250
- <th scope="row" nowrap="nowrap">Also add image to RSS/RSS2 feeds?</th>
251
- <td>
252
- <input type="checkbox" name="fb_image_rss" id="fb_image_rss" value="1" <?php echo (intval($fb_image_rss)==1 ? ' checked="checked"' : ''); ?> onclick="showImageOptions();"/>
253
- (for auto-posting apps like RSS Graffiti, twitterfeed, ...)
254
- </td>
255
- </tr>
256
- <tr class="fb_image_options">
257
- <th scope="row" nowrap="nowrap">On posts/pages:</th>
258
- <td>
259
- <div>
260
- 1) <input type="checkbox" name="fb_image_use_featured" id="fb_image_use_featured" value="1" <?php echo (intval($fb_image_use_featured)==1 ? ' checked="checked"' : ''); ?>/>
261
- Image will be fetched from post/page featured/thumbnail picture.</div>
262
- <div>
263
- 2) <input type="checkbox" name="fb_image_use_content" id="fb_image_use_content" value="1" <?php echo (intval($fb_image_use_content)==1 ? ' checked="checked"' : ''); ?>/>
264
- If it doesn't exist, use the first image from the post/page content.
265
- </div>
266
- <div>
267
- 3) <input type="checkbox" name="fb_image_use_media" id="fb_image_use_media" value="1" <?php echo (intval($fb_image_use_media)==1 ? ' checked="checked"' : ''); ?>/>
268
- If it doesn't exist, use first image from the post/page media gallery.
269
- </div>
270
- <div>
271
- 4) <input type="checkbox" name="fb_image_use_default" id="fb_image_use_default" value="1" <?php echo (intval($fb_image_use_default)==1 ? ' checked="checked"' : ''); ?>/>
272
- If it doesn't exist, use the default image above.
273
- </div>
274
- </td>
275
- </tr>
276
- </table>
277
- <p class="submit">
278
- <input type="hidden" name="action" value="save"/>
279
- <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
280
- </p>
281
- </form>
282
-
283
- </div>
284
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  </div>
286
  </div>
287
 
9
  *
10
  */
11
 
 
 
 
 
12
 
13
+ //Load the defaults
14
+ $defaults=wonderm00n_open_graph_default_values();
15
+ //Load the user settings (if they exist)
16
+ foreach($wonderm00n_open_graph_plugin_settings as $key) {
17
+ $usersettings[$key]=get_option('wonderm00n_open_graph_'.$key);
18
+ }
19
+ //Merge the settings "all together now" (yes, it's a Beatles reference)
20
+ foreach($usersettings as $key => $value) {
21
+ if ($value=='' && $defaults[$key]!='') $usersettings[$key]=$defaults[$key];
22
+ }
23
+ extract($usersettings);
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  ?>
26
  <div class="wrap">
27
 
28
  <?php screen_icon(); ?>
29
+ <h2>Wonderm00n's Simple Facebook Open Graph Tags (<?php echo $wonderm00n_open_graph_plugin_version; ?>)</h2>
30
  <br class="clear"/>
31
  <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>
32
 
36
 
37
  <div class="postbox-container" style="width: 69%;">
38
  <div id="poststuff">
39
+ <form name="form1" method="post">
40
+ <div id="wonderm00n_open_graph-settings" class="postbox">
41
+ <h3 id="settings">Settings</h3>
42
+ <div class="inside">
43
+ <table width="100%" class="form-table">
44
+ <tr>
45
+ <th scope="row" nowrap="nowrap">Include Facebook Platform App ID (fb:app_id) tag?</th>
46
+ <td>
47
+ <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"' : ''); ?> onclick="showAppidOptions();"/>
48
+ </td>
49
+ </tr>
50
+ <tr class="fb_app_id_options">
51
+ <th scope="row" nowrap="nowrap">Facebook Platform App ID:</th>
52
+ <td>
53
+ <input type="text" name="fb_app_id" id="fb_app_id" size="30" value="<?php echo $fb_app_id; ?>"/>
54
+ </td>
55
+ </tr>
56
+ <tr>
57
+ <td>&nbsp;</td>
58
+ <td></td>
59
+ </tr>
60
+ <tr>
61
+ <th scope="row" nowrap="nowrap">Include Facebook Admin(s) ID (fb:admins) tag?</th>
62
+ <td>
63
+ <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"' : ''); ?> onclick="showAdminOptions();"/>
64
+ </td>
65
+ </tr>
66
+ <tr class="fb_admin_id_options">
67
+ <th scope="row" nowrap="nowrap">Facebook Admin(s) ID:</th>
68
+ <td>
69
+ <input type="text" name="fb_admin_id" id="fb_admin_id" size="30" value="<?php echo $fb_admin_id; ?>"/>
70
+ <br/>
71
+ Comma separated if more than one
72
+ </td>
73
+ </tr>
74
+ <tr>
75
+ <td>&nbsp;</td>
76
+ <td></td>
77
+ </tr>
78
+ <tr>
79
+ <th scope="row" nowrap="nowrap">Include locale (fb:locale) tag?</th>
80
+ <td>
81
+ <input type="checkbox" name="fb_locale_show" id="fb_locale_show" value="1" <?php echo (intval($fb_locale_show)==1 ? ' checked="checked"' : ''); ?> onclick="showLocaleOptions();"/>
82
+ </td>
83
+ </tr>
84
+ <tr class="fb_locale_options">
85
+ <th scope="row" nowrap="nowrap">Locale:</th>
86
+ <td>
87
+ <select name="fb_locale" id="fb_locale">
88
+ <option value=""<?php if (trim($fb_locale)=='') echo ' selected="selected"'; ?>>Wordpress current locale/language (<?php echo get_locale(); ?>)&nbsp;</option>
89
+ <?php
90
+ $listLocales=false;
91
+ //Online
92
+ if ($ch = curl_init('http://www.facebook.com/translations/FacebookLocales.xmla')) {
93
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
94
+ $fb_locales=curl_exec($ch);
95
+ if (curl_errno($ch)) {
96
+ //echo curl_error($ch);
97
+ } else {
98
+ $info = curl_getinfo($ch);
99
+ if (intval($info['http_code'])==200) {
100
+ $listLocales=true;
101
+ }
102
  }
103
+ curl_close($ch);
104
  }
105
+ //Offline
106
+ if (!$listLocales) {
107
+ if ($fb_locales=file_get_contents(ABSPATH . 'wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/FacebookLocales.xml')) {
108
+ $listLocales=true;
109
+ }
 
110
  }
111
+ //OK
112
+ if ($listLocales) {
113
+ $xml=simplexml_load_string($fb_locales);
114
+ $json = json_encode($xml);
115
+ $locales = json_decode($json,TRUE);
116
+ if (is_array($locales['locale'])) {
117
+ foreach ($locales['locale'] as $locale) {
118
+ ?><option value="<?php echo $locale['codes']['code']['standard']['representation']; ?>"<?php if (trim($fb_locale)==trim($locale['codes']['code']['standard']['representation'])) echo ' selected="selected"'; ?>><?php echo $locale['englishName']; ?> (<?php echo $locale['codes']['code']['standard']['representation']; ?>)</option><?php
119
+ }
120
  }
121
  }
122
+ ?>
123
+ </select>
124
+ </td>
125
+ </tr>
126
+ <tr>
127
+ <td>&nbsp;</td>
128
+ <td></td>
129
+ </tr>
130
+ <tr>
131
+ <th scope="row" nowrap="nowrap">Include Site Name (og:site_name) tag?</th>
132
+ <td>
133
+ <input type="checkbox" name="fb_sitename_show" id="fb_sitename_show" value="1" <?php echo (intval($fb_sitename_show)==1 ? ' checked="checked"' : ''); ?>/>
134
+ </td>
135
+ </tr>
136
+ <tr>
137
+ <td>&nbsp;</td>
138
+ <td></td>
139
+ </tr>
140
+ <tr>
141
+ <th scope="row" nowrap="nowrap">Include Post/Page title (og:title) tag?</th>
142
+ <td>
143
+ <input type="checkbox" name="fb_title_show" id="fb_title_show" value="1" <?php echo (intval($fb_title_show)==1 ? ' checked="checked"' : ''); ?>/>
144
+ </td>
145
+ </tr>
146
+ <tr>
147
+ <td>&nbsp;</td>
148
+ <td></td>
149
+ </tr>
150
+ <tr>
151
+ <th scope="row" nowrap="nowrap">Include URL (og:url) tag?</th>
152
+ <td>
153
+ <input type="checkbox" name="fb_url_show" id="fb_url_show" value="1" <?php echo (intval($fb_url_show)==1 ? ' checked="checked"' : ''); ?> onclick="showUrlOptions();"/>
154
+ </td>
155
+ </tr>
156
+ <tr class="fb_url_options">
157
+ <th scope="row" nowrap="nowrap">Add trailing slash at the end:</th>
158
+ <td>
159
+ <input type="checkbox" name="fb_url_add_trailing" id="fb_url_add_trailing" value="1" <?php echo (intval($fb_url_add_trailing)==1 ? ' checked="checked"' : ''); ?> onclick="showUrlTrail();"/>
160
+ (on the homepage will be: <i><?php echo get_option('siteurl'); ?><span id="fb_url_add_trailing_example">/</span></i>)
161
+ </td>
162
+ </tr>
163
+ <tr>
164
+ <td>&nbsp;</td>
165
+ <td></td>
166
+ </tr>
167
+ <tr>
168
+ <th scope="row" nowrap="nowrap">Include Type (og:type) tag?</th>
169
+ <td>
170
+ <input type="checkbox" name="fb_type_show" id="fb_type_show" value="1" <?php echo (intval($fb_type_show)==1 ? ' checked="checked"' : ''); ?> onclick="showTypeOptions();"/>
171
+ (will be &quot;article&quot; for posts and pages and &quot;website&quot; or &quot;blog&quot; for the homepage)
172
+ </td>
173
+ </tr>
174
+ <tr class="fb_type_options">
175
+ <th scope="row" nowrap="nowrap">Homepage type:</th>
176
+ <td>
177
+ Use
178
+ <select name="fb_type_homepage" id="fb_type_homepage">
179
+ <option value="website"<?php if (trim($fb_type_homepage)=='' || trim($fb_type_homepage)=='website') echo ' selected="selected"'; ?>>website&nbsp;</option>
180
+ <option value="blog"<?php if (trim($fb_type_homepage)=='blog') echo ' selected="selected"'; ?>>blog&nbsp;</option>
181
+ </select>
182
+ </td>
183
+ </tr>
184
+ <tr>
185
+ <td>&nbsp;</td>
186
+ <td></td>
187
+ </tr>
188
+ <tr>
189
+ <th scope="row" nowrap="nowrap">Include Description (og:description) tag?</th>
190
+ <td>
191
+ <input type="checkbox" name="fb_desc_show" id="fb_desc_show" value="1" <?php echo (intval($fb_desc_show)==1 ? ' checked="checked"' : ''); ?> onclick="showDescriptionOptions();"/>
192
+ </td>
193
+ </tr>
194
+ <tr class="fb_description_options">
195
+ <th scope="row" nowrap="nowrap">Description maximum length:</th>
196
+ <td>
197
+ <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, 0 or blank for no maximum length
198
+ </td>
199
+ </tr>
200
+ <tr class="fb_description_options">
201
+ <th scope="row" nowrap="nowrap">Homepage description:</th>
202
+ <td>
203
+ Use
204
+ <select name="fb_desc_homepage" id="fb_desc_homepage" onchange="showDescriptionCustomText();">
205
+ <option value=""<?php if (trim($fb_desc_homepage)=='') echo ' selected="selected"'; ?>>Website tagline&nbsp;</option>
206
+ <option value="custom"<?php if (trim($fb_desc_homepage)=='custom') echo ' selected="selected"'; ?>>Custom text&nbsp;</option>
207
+ </select>
208
+ <div id="fb_desc_homepage_customtext_div">
209
+ <textarea name="fb_desc_homepage_customtext" id="fb_desc_homepage_customtext" rows="3" cols="50"><?php echo $fb_desc_homepage_customtext; ?></textarea>
210
+ </div>
211
+ </td>
212
+ </tr>
213
+ <tr>
214
+ <td>&nbsp;</td>
215
+ <td></td>
216
+ </tr>
217
+ <tr>
218
+ <th scope="row" nowrap="nowrap">Include Image (og:image) tag?</th>
219
+ <td>
220
+ <input type="checkbox" name="fb_image_show" id="fb_image_show" value="1" <?php echo (intval($fb_image_show)==1 ? ' checked="checked"' : ''); ?> onclick="showImageOptions();"/>
221
+ </td>
222
+ </tr>
223
+ <tr class="fb_image_options">
224
+ <th scope="row" nowrap="nowrap">Default image:</th>
225
+ <td>
226
+ <input type="text" name="fb_image" id="fb_image" size="50" value="<?php echo $fb_image; ?>"/>
227
+ <input id="fb_image_button" class="button" type="button" value="Upload/Choose image" />
228
+ <br/>
229
+ Full URL with http://
230
+ </td>
231
+ </tr>
232
+ <tr class="fb_image_options">
233
+ <th scope="row" nowrap="nowrap">Also add image to RSS/RSS2 feeds?</th>
234
+ <td>
235
+ <input type="checkbox" name="fb_image_rss" id="fb_image_rss" value="1" <?php echo (intval($fb_image_rss)==1 ? ' checked="checked"' : ''); ?> onclick="showImageOptions();"/>
236
+ (for auto-posting apps like RSS Graffiti, twitterfeed, ...)
237
+ </td>
238
+ </tr>
239
+ <tr class="fb_image_options">
240
+ <th scope="row" nowrap="nowrap">On posts/pages:</th>
241
+ <td>
242
+ <div>
243
+ 1) <input type="checkbox" name="fb_image_use_featured" id="fb_image_use_featured" value="1" <?php echo (intval($fb_image_use_featured)==1 ? ' checked="checked"' : ''); ?>/>
244
+ Image will be fetched from post/page featured/thumbnail picture.</div>
245
+ <div>
246
+ 2) <input type="checkbox" name="fb_image_use_content" id="fb_image_use_content" value="1" <?php echo (intval($fb_image_use_content)==1 ? ' checked="checked"' : ''); ?>/>
247
+ If it doesn't exist, use the first image from the post/page content.
248
+ </div>
249
+ <div>
250
+ 3) <input type="checkbox" name="fb_image_use_media" id="fb_image_use_media" value="1" <?php echo (intval($fb_image_use_media)==1 ? ' checked="checked"' : ''); ?>/>
251
+ If it doesn't exist, use first image from the post/page media gallery.
252
+ </div>
253
+ <div>
254
+ 4) <input type="checkbox" name="fb_image_use_default" id="fb_image_use_default" value="1" <?php echo (intval($fb_image_use_default)==1 ? ' checked="checked"' : ''); ?>/>
255
+ If it doesn't exist, use the default image above.
256
+ </div>
257
+ </td>
258
+ </tr>
259
+ </table>
260
+ </div>
261
+ </div>
262
+ <div id="wonderm00n_open_graph-thirdparty" class="postbox">
263
+ <h3 id="thirdparty">3rd Party Integration</h3>
264
+ <div class="inside">
265
+ <?php
266
+ $thirdparty=false;
267
+ if(is_plugin_active('subheading/index.php')) {
268
+ $thirdparty=true;
269
+ ?>
270
+ <h4><a href="http://wordpress.org/extend/plugins/subheading/" target="_blank">SubHeading</a></h4>
271
+ <table width="100%" class="form-table">
272
+ <tr>
273
+ <th scope="row" nowrap="nowrap">Add SubHeading to Post/Page title?</th>
274
+ <td>
275
+ <input type="checkbox" name="fb_show_subheading" id="fb_show_subheading" value="1" <?php echo (intval($fb_show_subheading)==1 ? ' checked="checked"' : ''); ?> onclick="showAppidOptions();"/>
276
+ </td>
277
+ </tr>
278
+ </table>
279
+ <?php
280
+ }
281
+ if (!$thirdparty) {
282
+ ?>
283
+ <p>You don't have any compatible 3rd Party plugin installed/active.</p>
284
+ <p>This plugin in currently compatible with:</p>
285
+ <ul>
286
+ <li><a href="http://wordpress.org/extend/plugins/subheading/" target="_blank">SubHeading</a></li>
287
+ </ul>
288
+ <?php
289
+ }
290
+ ?>
291
+ </div>
292
+ </div>
293
+ <p class="submit">
294
+ <input type="hidden" name="action" value="save"/>
295
+ <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
296
+ </p>
297
+ </form>
298
  </div>
299
  </div>
300
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: wonderm00n
3
  Donate link: http://blog.wonderm00n.com/2011/10/14/wordpress-plugin-simple-facebook-open-graph-tags/
4
  Tags: facebook, open graph, seo, share, social, meta
5
  Requires at least: 3
6
- Tested up to: 3.2.1
7
- Stable tag: 0.2.3
8
 
9
  This plugin inserts Facebook Open Graph Tags into your WordPress Blog/Website for more effective Facebook sharing results.
10
 
@@ -35,6 +35,13 @@ The tags that this plugin inserts are:
35
 
36
  == Changelog ==
37
 
 
 
 
 
 
 
 
38
  = 0.2.3 =
39
 
40
  * No changes. Had a problem updating to 0.2.2 on the Wordpress website.
3
  Donate link: http://blog.wonderm00n.com/2011/10/14/wordpress-plugin-simple-facebook-open-graph-tags/
4
  Tags: facebook, open graph, seo, share, social, meta
5
  Requires at least: 3
6
+ Tested up to: 3.4.2
7
+ Stable tag: 0.3
8
 
9
  This plugin inserts Facebook Open Graph Tags into your WordPress Blog/Website for more effective Facebook sharing results.
10
 
35
 
36
  == Changelog ==
37
 
38
+ = 0.3 =
39
+
40
+ * "SubHeading" plugin integration. It's now possible add this field to the "og:title" tag.
41
+ * Changed the way defaults and user settings are loaded and saved, to "try" to eliminate the problem some users experienced where the user settings would disappear.
42
+ * Bugfix: "Also add image to RSS/RSS2 feeds?" option was not being correctly loaded
43
+ * The plugin version is now showed both as a comment before the open graph tags and on the settings page
44
+
45
  = 0.2.3 =
46
 
47
  * No changes. Had a problem updating to 0.2.2 on the Wordpress website.
wonderm00n-open-graph.php CHANGED
@@ -1,21 +1,54 @@
1
  <?php
2
  /**
3
  * @package Wonderm00n's Simple Facebook Open Graph Meta Tags
4
- * @version 0.2.3
5
  */
6
  /*
7
  Plugin Name: Wonderm00n's Simple Facebook Open Graph Meta 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.2.3
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');
@@ -36,13 +69,22 @@ function wonderm00n_open_graph() {
36
  $fb_image_use_featured=get_option('wonderm00n_open_graph_fb_image_use_featured');
37
  $fb_image_use_content=get_option('wonderm00n_open_graph_fb_image_use_content');
38
  $fb_image_use_media=get_option('wonderm00n_open_graph_fb_image_use_media');
39
- $fb_image_use_default=get_option('wonderm00n_open_graph_fb_image_use_default');
40
 
41
  $fb_type='article';
42
  if (is_singular()) {
43
  //It's a Post or a Page or an attachment page
44
  global $post;
45
  $fb_title=esc_attr(strip_tags(stripslashes($post->post_title)));
 
 
 
 
 
 
 
 
 
46
  $fb_url=get_permalink();
47
  if (trim($post->post_excerpt)!='') {
48
  //If there's an excerpt that's waht we'll use
@@ -127,7 +169,7 @@ function wonderm00n_open_graph() {
127
  //If no description let's just add the title
128
  if (trim($fb_desc)=='') $fb_desc=$fb_title;
129
 
130
- $html.='<!-- START - Wonderm00n\'s Simple Facebook Open Graph Tags -->
131
  ';
132
  if (intval($fb_app_id_show)==1 && trim($fb_app_id)!='') $html.='<meta property="fb:app_id" content="'.trim($fb_app_id).'" />
133
  ';
@@ -284,7 +326,7 @@ function wonderm00n_open_graph_post_image($fb_image_use_featured=1, $fb_image_us
284
  if ( is_admin() ) {
285
  add_action('admin_menu', 'wonderm00n_open_graph_add_options');
286
 
287
- add_action('activate_wonderm00n-open-graph/wonderm00n-open-graph.php', 'wonderm00n_open_graph_activate');
288
 
289
  function wonderm00n_open_graph_add_options() {
290
  if(function_exists('add_options_page')){
@@ -292,23 +334,26 @@ if ( is_admin() ) {
292
  }
293
  }
294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  function wonderm00n_open_graph_activate() {
296
- update_option("wonderm00n_open_graph_activated", 1);
297
- update_option("wonderm00n_open_graph_fb_admin_id_show", 0);
298
- update_option("wonderm00n_open_graph_fb_app_id_show", 0);
299
- update_option("wonderm00n_open_graph_fb_locale_show", 1);
300
- update_option("wonderm00n_open_graph_fb_sitename_show", 1);
301
- update_option("wonderm00n_open_graph_fb_title_show", 1);
302
- update_option("wonderm00n_open_graph_fb_url_show", 1);
303
- update_option("wonderm00n_open_graph_fb_type_show", 1);
304
- update_option("wonderm00n_open_graph_fb_desc_show", 1);
305
- update_option("wonderm00n_open_graph_fb_desc_chars", 300);
306
- update_option("wonderm00n_open_graph_fb_image_show", 1);
307
- update_option("wonderm00n_open_graph_fb_image_rss", 0);
308
- update_option("wonderm00n_open_graph_fb_image_use_featured", 1);
309
- update_option("wonderm00n_open_graph_fb_image_use_content", 1);
310
- update_option("wonderm00n_open_graph_fb_image_use_media", 1);
311
- update_option("wonderm00n_open_graph_fb_image_use_default", 1);
312
  }
313
 
314
  function wonderm00n_open_graph_settings_link( $links, $file ) {
@@ -322,6 +367,7 @@ if ( is_admin() ) {
322
 
323
 
324
  function wonderm00n_open_graph_admin() {
 
325
  include_once 'includes/settings-page.php';
326
  }
327
 
@@ -338,6 +384,8 @@ if ( is_admin() ) {
338
 
339
  if ( isset($_POST['action']) ) {
340
  if (trim($_POST['action'])=='save') {
 
 
341
  update_option('wonderm00n_open_graph_fb_app_id_show', intval($_POST['fb_app_id_show']));
342
  update_option('wonderm00n_open_graph_fb_app_id', trim($_POST['fb_app_id']));
343
  update_option('wonderm00n_open_graph_fb_admin_id_show', intval($_POST['fb_admin_id_show']));
@@ -361,31 +409,22 @@ if ( is_admin() ) {
361
  update_option('wonderm00n_open_graph_fb_image_use_content', intval($_POST['fb_image_use_content']));
362
  update_option('wonderm00n_open_graph_fb_image_use_media', intval($_POST['fb_image_use_media']));
363
  update_option('wonderm00n_open_graph_fb_image_use_default', intval($_POST['fb_image_use_default']));
 
364
  }
365
  }
366
  }
367
 
368
 
369
-
370
-
371
- //Upgrade 2012-01-02 (locale)
372
- if (trim(get_option('wonderm00n_open_graph_fb_locale_show'))=='') {
373
- update_option("wonderm00n_open_graph_fb_locale_show", 1);
374
- }
375
- //Upgrade 2012-01-02 (images)
376
- if (
377
- trim(get_option('wonderm00n_open_graph_fb_image_use_featured'))==''
378
- ||
379
- trim(get_option('wonderm00n_open_graph_fb_image_use_content'))==''
380
- ||
381
- trim(get_option('wonderm00n_open_graph_fb_image_use_media'))==''
382
- ||
383
- trim(get_option('wonderm00n_open_graph_fb_image_use_default'))==''
384
- ) {
385
- update_option("wonderm00n_open_graph_fb_image_use_featured", 1);
386
- update_option("wonderm00n_open_graph_fb_image_use_content", 1);
387
- update_option("wonderm00n_open_graph_fb_image_use_media", 1);
388
- update_option("wonderm00n_open_graph_fb_image_use_default", 1);
389
  }
390
 
391
  ?>
1
  <?php
2
  /**
3
  * @package Wonderm00n's Simple Facebook Open Graph Meta Tags
4
+ * @version 0.3
5
  */
6
  /*
7
  Plugin Name: Wonderm00n's Simple Facebook Open Graph Meta 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.3
12
  Author URI: http://wonderm00n.com
13
  */
14
 
15
+ $wonderm00n_open_graph_plugin_version='0.3';
16
+ $wonderm00n_open_graph_plugin_settings=array(
17
+ 'fb_app_id_show',
18
+ 'fb_app_id',
19
+ 'fb_admin_id_show',
20
+ 'fb_admin_id',
21
+ 'fb_locale_show',
22
+ 'fb_locale',
23
+ 'fb_sitename_show',
24
+ 'fb_title_show',
25
+ 'fb_url_show',
26
+ 'fb_url_add_trailing',
27
+ 'fb_type_show',
28
+ 'fb_type_homepage',
29
+ 'fb_desc_show',
30
+ 'fb_desc_chars',
31
+ 'fb_desc_homepage',
32
+ 'fb_desc_homepage_customtext',
33
+ 'fb_image_show',
34
+ 'fb_image',
35
+ 'fb_image_rss',
36
+ 'fb_image_use_featured',
37
+ 'fb_image_use_content',
38
+ 'fb_image_use_media',
39
+ 'fb_image_use_default',
40
+ 'fb_show_subheading'
41
+ );
42
+
43
  function wonderm00n_open_graph() {
44
+ global $wonderm00n_open_graph_plugin_settings, $wonderm00n_open_graph_plugin_version;
45
+
46
+ foreach($wonderm00n_open_graph_plugin_settings as $key) {
47
+ $$key=get_option('wonderm00n_open_graph_'.$key);
48
+ }
49
 
50
  //This should be set by options on wp-admin
51
+ /*$fb_app_id_show=get_option('wonderm00n_open_graph_fb_app_id_show');
52
  $fb_app_id=get_option('wonderm00n_open_graph_fb_app_id');
53
  $fb_admin_id_show=get_option('wonderm00n_open_graph_fb_admin_id_show');
54
  $fb_admin_id=get_option('wonderm00n_open_graph_fb_admin_id');
69
  $fb_image_use_featured=get_option('wonderm00n_open_graph_fb_image_use_featured');
70
  $fb_image_use_content=get_option('wonderm00n_open_graph_fb_image_use_content');
71
  $fb_image_use_media=get_option('wonderm00n_open_graph_fb_image_use_media');
72
+ $fb_image_use_default=get_option('wonderm00n_open_graph_fb_image_use_default');*/
73
 
74
  $fb_type='article';
75
  if (is_singular()) {
76
  //It's a Post or a Page or an attachment page
77
  global $post;
78
  $fb_title=esc_attr(strip_tags(stripslashes($post->post_title)));
79
+ //SubHeading
80
+ if ($fb_show_subheading==1) {
81
+ @include_once(ABSPATH . 'wp-admin/includes/plugin.php');
82
+ if (is_plugin_active('subheading/index.php')) {
83
+ if (function_exists('get_the_subheading')) {
84
+ $fb_title.=' - '.get_the_subheading();
85
+ }
86
+ }
87
+ }
88
  $fb_url=get_permalink();
89
  if (trim($post->post_excerpt)!='') {
90
  //If there's an excerpt that's waht we'll use
169
  //If no description let's just add the title
170
  if (trim($fb_desc)=='') $fb_desc=$fb_title;
171
 
172
+ $html.='<!-- START - Wonderm00n\'s Simple Facebook Open Graph Tags '.$wonderm00n_open_graph_plugin_version.' -->
173
  ';
174
  if (intval($fb_app_id_show)==1 && trim($fb_app_id)!='') $html.='<meta property="fb:app_id" content="'.trim($fb_app_id).'" />
175
  ';
326
  if ( is_admin() ) {
327
  add_action('admin_menu', 'wonderm00n_open_graph_add_options');
328
 
329
+ register_activation_hook(__FILE__, 'wonderm00n_open_graph_activate');
330
 
331
  function wonderm00n_open_graph_add_options() {
332
  if(function_exists('add_options_page')){
334
  }
335
  }
336
 
337
+ function wonderm00n_open_graph_default_values() {
338
+ return array(
339
+ 'fb_locale_show' => 1,
340
+ 'fb_sitename_show' => 1,
341
+ 'fb_title_show' => 1,
342
+ 'fb_url_show' => 1,
343
+ 'fb_type_show' => 1,
344
+ 'fb_desc_show' => 1,
345
+ 'fb_desc_chars' => 300,
346
+ 'fb_image_show' => 1,
347
+ 'fb_image_use_featured' => 1,
348
+ 'fb_image_use_content' => 1,
349
+ 'fb_image_use_media' => 1,
350
+ 'fb_image_use_default' => 1,
351
+ 'fb_keep_data_uninstall' => 1
352
+ );
353
+ }
354
+
355
  function wonderm00n_open_graph_activate() {
356
+ // Let's not!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
357
  }
358
 
359
  function wonderm00n_open_graph_settings_link( $links, $file ) {
367
 
368
 
369
  function wonderm00n_open_graph_admin() {
370
+ global $wonderm00n_open_graph_plugin_settings, $wonderm00n_open_graph_plugin_version;
371
  include_once 'includes/settings-page.php';
372
  }
373
 
384
 
385
  if ( isset($_POST['action']) ) {
386
  if (trim($_POST['action'])=='save') {
387
+ print_r($_POST);
388
+ //This should also use the $wonderm00n_open_graph_plugin_settings array, but because of intval and trim we still can't
389
  update_option('wonderm00n_open_graph_fb_app_id_show', intval($_POST['fb_app_id_show']));
390
  update_option('wonderm00n_open_graph_fb_app_id', trim($_POST['fb_app_id']));
391
  update_option('wonderm00n_open_graph_fb_admin_id_show', intval($_POST['fb_admin_id_show']));
409
  update_option('wonderm00n_open_graph_fb_image_use_content', intval($_POST['fb_image_use_content']));
410
  update_option('wonderm00n_open_graph_fb_image_use_media', intval($_POST['fb_image_use_media']));
411
  update_option('wonderm00n_open_graph_fb_image_use_default', intval($_POST['fb_image_use_default']));
412
+ update_option('wonderm00n_open_graph_fb_show_subheading', intval($_POST['fb_show_subheading']));
413
  }
414
  }
415
  }
416
 
417
 
418
+ //Uninstall stuff
419
+ register_uninstall_hook(__FILE__, 'wonderm00n_open_graph_uninstall'); //NOT WORKING! WHY?
420
+ function wonderm00n_open_graph_uninstall() {
421
+ //NOT WORKING! WHY?
422
+ global $wonderm00n_open_graph_plugin_settings;
423
+ //Remove data
424
+ foreach($wonderm00n_open_graph_plugin_settings as $key) {
425
+ delete_option('wonderm00n_open_graph_'.$key);
426
+ }
427
+ delete_option('wonderm00n_open_graph_activated');
 
 
 
 
 
 
 
 
 
 
428
  }
429
 
430
  ?>