WP to Twitter - Version 1.0.0

Version Description

Download this release

Release Info

Developer joedolson
Plugin Icon 128x128 WP to Twitter
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

images/cligs.png ADDED
Binary file
images/twitter.png ADDED
Binary file
images/wp-to-twitter-custom.png ADDED
Binary file
images/wp-to-twitter-options.png ADDED
Binary file
readme.txt ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: joedolson
3
+ Donate link: http://www.joedolson.com/donate/
4
+ Tags: twitter, microblogging, cligs, redirect, shortener
5
+ Requires at least: 2.3
6
+ Tested up to: 2.6
7
+ Stable tag: 1.0
8
+
9
+ Posts a Twitter status update when you update your blog, using the Cli.gs URL shortening service.
10
+
11
+ == Description ==
12
+
13
+ The WP-to-Twitter plugin posts a Twitter status update from your blog using the Cli.gs URL shortening service to
14
+ provide a link back to your post from Twitter.
15
+
16
+ If you have a Cli.gs API key, the shortened URL will also be filed in your Cli.gs account so that you can track
17
+ statistics for the shortened URL.
18
+
19
+ The plugin can send a default message for updating or editing posts or pages, but also allows you to write a custom
20
+ Tweet for your post which says whatever you want. By default, the shortened URL from Cli.gs is appended to the end
21
+ of your message, so you should keep that in mind when writing your custom Tweet.
22
+
23
+ Any status update you write which is longer than the available space will automatically be truncated by the plugin. This applies to both the default messages and to your custom messages.
24
+
25
+ This plugin was based on the Twitter Updater plugin by Jonathan Dingman (http://www.firesidemedia.net/dev/), which he adapted from a plugin by Victoria Chan.
26
+
27
+ == Installation ==
28
+
29
+ 1. Upload the `wp-to-twitter` folder to your `/wp-content/plugins/` directory
30
+ 2. Activate the plugin using the `Plugins` menu in WordPress
31
+ 3. Go to Settings > WP->Twitter
32
+ 4. Adjust the WP->Twitter Options as you prefer them.
33
+ 5. Supply your Twitter username and login.
34
+ 6. **Optional**: Provide your Cli.gs API key ([available free from Cli.gs](http://cli.gs)), if you want to have statistics available for your URL.
35
+ 7. That's it! You're all set.
36
+
37
+ == Frequently Asked Questions ==
38
+
39
+ = Do I have to have a Twitter.com account to use this plugin? =
40
+
41
+ Yes, you need an account to use this plugin.
42
+
43
+ = Do I have to have a Cli.gs account to use this plugin? =
44
+
45
+ No, the Cli.gs account is entirely optional. Without a Cli.gs API, a "public" Clig will be generated. The redirect will work just fine, but you won't be able to access statistics on your Clig.
46
+
47
+ == Screenshots ==
48
+
49
+ 1. WP to Twitter custom Tweet box
50
+ 2. WP to Twitter options page
wp-to-twitter-manager.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $wp_to_twitter_directory = get_bloginfo( 'wpurl' ) . '/' . PLUGINDIR . '/' . dirname( plugin_basename(__FILE__) );
4
+
5
+ //update_option('twitterInitialised', '0');
6
+ //SETS DEFAULT OPTIONS
7
+ if(get_option('twitterInitialised') != '1'){
8
+ update_option('newpost-published-update', '1');
9
+ update_option('newpost-published-text', 'Published a new post: #title#');
10
+ update_option('newpost-published-showlink', '1');
11
+
12
+ update_option('oldpost-edited-update', '1');
13
+ update_option('oldpost-edited-text', 'Blog post just edited: #title#');
14
+ update_option('oldpost-edited-showlink', '1');
15
+
16
+ update_option('twitterInitialised', '1');
17
+ update_option('cligsapi','0');
18
+ update_option('jd_twit_pages','0');
19
+ $message = "Set your Twitter login information and Cli.gs API to use this plugin!";
20
+ }
21
+
22
+
23
+ if($_POST['submit-type'] == 'options'){
24
+ //UPDATE OPTIONS
25
+ update_option('newpost-published-update', $_POST['newpost-published-update']);
26
+ update_option('newpost-published-text', $_POST['newpost-published-text']);
27
+ update_option('newpost-published-showlink', $_POST['newpost-published-showlink']);
28
+
29
+ update_option('oldpost-edited-update', $_POST['oldpost-edited-update']);
30
+ update_option('oldpost-edited-text', $_POST['oldpost-edited-text']);
31
+ update_option('oldpost-edited-showlink', $_POST['oldpost-edited-showlink']);
32
+ update_option('jd_twit_pages',$_POST['jd_twit_pages']);
33
+ $message = "WP to Twitter Options Updated";
34
+
35
+ }else if ($_POST['submit-type'] == 'login'){
36
+ //UPDATE LOGIN
37
+ if(($_POST['twitterlogin'] != '') AND ($_POST['twitterpw'] != '')){
38
+ update_option('twitterlogin', $_POST['twitterlogin']);
39
+ update_option('twitterlogin_encrypted', base64_encode($_POST['twitterlogin'].':'.$_POST['twitterpw']));
40
+ $message = "Twitter login and password updated.";
41
+ } else {
42
+ $message = "You need to provide your twitter login and password!";
43
+ }
44
+ } else if ($_POST['submit-type'] == 'cligsapi') {
45
+ if($_POST['cligsapi'] != '') {
46
+ update_option('cligsapi',$_POST['cligsapi']);
47
+ $message = "Cligs API Key Updated";
48
+ } else {
49
+ $message = "Cli.gs API Key not added - <a href='http://cli.gs/user/api/'>get one here</a>!";
50
+ }
51
+ }
52
+
53
+ // FUNCTION to see if checkboxes should be checked
54
+ function jd_checkCheckbox($theFieldname){
55
+ if( get_option($theFieldname) == '1'){
56
+ echo('checked="true"');
57
+ }
58
+ }
59
+ ?>
60
+ <style type="text/css">
61
+ <!--
62
+ #wp-to-twitter fieldset {
63
+ margin: 0;
64
+ padding:0;
65
+ border: none;
66
+ }
67
+ #wp-to-twitter form p {
68
+ background: #eaf3fa;
69
+ padding: 10px 5px;
70
+ margin: 4px 0;
71
+ border: 1px solid #eee;
72
+ }
73
+ .floatright {
74
+ float: right;
75
+ }
76
+ .cligs {
77
+ background: #efecdb url(<?php echo $wp_to_twitter_directory; ?>/images/cligs.png) right 50% no-repeat;
78
+ padding: 2px!important;
79
+ }
80
+ .twitter {
81
+ background: url(<?php echo $wp_to_twitter_directory; ?>/images/twitter.png) right 50% no-repeat;
82
+ padding: 2px!important;
83
+ }
84
+ -->
85
+ </style>
86
+ <?php if ($message) : ?>
87
+ <div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
88
+ <?php endif; ?>
89
+ <div id="dropmessage" class="updated" style="display:none;"></div>
90
+
91
+ <div class="wrap" id="wp-to-twitter">
92
+ <h2>WP to Twitter Options</h2>
93
+ <p>
94
+ For any update field, you can use the codes <code>#title#</code> for the title of your blog post or <code>#blog#</code> for the title of your blog! Given the character limit for Twitter, you may not want to include your blog title.
95
+ </p>
96
+ <form method="post">
97
+ <div>
98
+ <fieldset>
99
+ <legend>Wordpress to Twitter Publishing Options</legend>
100
+ <p>
101
+ <input type="checkbox" name="jd_twit_pages" id="jd_twit_pages" value="1" <?php jd_checkCheckbox('jd_twit_pages')?> />
102
+ <label for="jd_twit_pages">Update Twitter when new Wordpress Pages are published</label>
103
+ </p>
104
+ <p>
105
+ <input type="checkbox" name="newpost-published-update" id="newpost-published-update" value="1" <?php jd_checkCheckbox('newpost-published-update')?> />
106
+ <label for="newpost-published-update">Update Twitter when the new post is published</label>
107
+ </p>
108
+ <p>
109
+ <label for="newpost-published-text">Text for this Twitter update</label><br />
110
+ <input type="text" name="newpost-published-text" id="newpost-published-text" size="60" maxlength="146" value="<?php echo(get_option('newpost-published-text')) ?>" />
111
+ &nbsp;&nbsp;
112
+ <input type="checkbox" name="newpost-published-showlink" id="newpost-published-showlink" value="1" <?php jd_checkCheckbox('newpost-published-showlink')?> />
113
+ <label for="newpost-published-showlink">Provide link to blog?</label>
114
+ </p>
115
+
116
+ <p>
117
+ <input type="checkbox" name="oldpost-edited-update" id="oldpost-edited-update" value="1" <?php jd_checkCheckbox('oldpost-edited-update')?> />
118
+ <label for="oldpost-edited-update">Update Twitter when the an old post has been edited</label>
119
+ </p>
120
+ <p>
121
+ <label for="oldpost-edited-text">Text for this Twitter update</label><br />
122
+ <input type="text" name="oldpost-edited-text" id="oldpost-edited-text" size="60" maxlength="146" value="<?php echo(get_option('oldpost-edited-text')) ?>" />
123
+ &nbsp;&nbsp;
124
+ <input type="checkbox" name="oldpost-edited-showlink" id="oldpost-edited-showlink" value="1" <?php jd_checkCheckbox('oldpost-edited-showlink')?> />
125
+ <label for="oldpost-edited-showlink">Provide link to blog?</label>
126
+ </p>
127
+ <div>
128
+ <input type="hidden" name="submit-type" value="options" />
129
+ </div>
130
+ <input type="submit" name="submit" value="Save WP->Twitter Options" />
131
+ </fieldset>
132
+
133
+ </div>
134
+ </form>
135
+
136
+ <h2 class="twitter">Your Twitter account details</h2>
137
+
138
+ <form method="post" >
139
+ <div>
140
+ <p>
141
+ <label for="twitterlogin">Your Twitter username:</label>
142
+ <input type="text" name="twitterlogin" id="twitterlogin" value="<?php echo(get_option('twitterlogin')) ?>" />
143
+ </p>
144
+ <p>
145
+ <label for="twitterpw">Your Twitter password:</label>
146
+ <input type="password" name="twitterpw" id="twitterpw" value="" />
147
+ </p>
148
+ <input type="hidden" name="submit-type" value="login">
149
+ <p><input type="submit" name="submit" value="Save Twitter Login Info" /> &raquo; <small>Don't have a Twitter account? <a href="http://www.twitter.com">Get one for free here</a></small></p>
150
+ </div>
151
+ </form>
152
+
153
+ <h2 class="cligs">Your Cli.gs account details</h2>
154
+
155
+ <form method="post">
156
+ <div>
157
+ <p>
158
+ <label for="cligsapi">Your Cli.gs API Key:</label>
159
+ <input type="text" name="cligsapi" id="cligsapi" size="40" value="<?php echo(get_option('cligsapi')) ?>" />
160
+ </p>
161
+ <div>
162
+ <input type="hidden" name="submit-type" value="cligsapi">
163
+ </div>
164
+ <p><input type="submit" name="submit" value="Save Cli.gs API Key" /> &raquo; <small>Don't have a Cli.gs account or Cligs API key? <a href="http://cli.gs">Get one free here</a>! You'll need an API key in order to associate the Cligs you create with your Cligs account.</small></p>
165
+ </div>
166
+ <div>
167
+
168
+
169
+ </div>
170
+ </form>
171
+
172
+ </div>
173
+
174
+
175
+ <div class="wrap">
176
+ <h3>Need help?</h3>
177
+ <p>Visit the <a href="http://www.joedolson.com/articles/wp-to-twitter/">WP to Twitter plugin page</a>.</p>
178
+ </div>
wp-to-twitter.php ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: WP to Twitter
4
+ Plugin URI: http://www.joedolson.com/wp-to-twitter/
5
+ Description: Updates Twitter when you create a new blog post using Cli.gs. With a Cli.gs API key, creates a clig in your Cli.gs account with the name of your post as the title.
6
+ Version: 1.0beta
7
+ Author: Joseph Dolson, with a nod to Victoria Chan & Jonathan Dingman
8
+ Author URI: http://www.joedolson.com/
9
+ */
10
+
11
+ /* Copyright 2008 Joseph C Dolson (email : wp-to-twitter@joedolson.com)
12
+
13
+ This program is free software; you can redistribute it and/or modify
14
+ it under the terms of the GNU General Public License as published by
15
+ the Free Software Foundation; either version 2 of the License, or
16
+ (at your option) any later version.
17
+
18
+ This program is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
+ GNU General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
+ */
27
+
28
+ $jd_plugin_url = "http://www.joedolson.com/wp-to-twitter/";
29
+ // This function performs the API post to Twitter
30
+ function jd_doTwitterAPIPost( $twit, $twitterURI ) {
31
+ $host = 'twitter.com';
32
+ $port = 80;
33
+ $fp = @fsockopen($host, $port, $err_num, $err_msg, 10);
34
+
35
+ //check if user login details have been entered on admin page
36
+ $thisLoginDetails = get_option( 'twitterlogin_encrypted' );
37
+
38
+ if ( $thisLoginDetails != '' ) {
39
+ if ( !$fp ) {
40
+ #echo "$err_msg ($err_num)<br>\n"; // Fail Silently
41
+ } else {
42
+ fputs( $fp, "POST $twitterURI HTTP/1.1\r\n" );
43
+ fputs( $fp, "Authorization: Basic ".$thisLoginDetails."\r\n" );
44
+ fputs( $fp, "User-Agent: ".$agent."\n" );
45
+ fputs( $fp, "Host: $host\n" );
46
+ fputs( $fp, "Content-type: application/x-www-form-urlencoded\n" );
47
+ fputs( $fp, "Content-length: ".strlen( $twit)."\n" );
48
+ fputs( $fp, "Connection: close\n\n" );
49
+ fputs( $fp, $twit );
50
+ for ( $i = 1; $i < 10; $i++ ) {
51
+ $reply = fgets( $fp, 256 );
52
+ }
53
+ fclose( $fp );
54
+ }
55
+ return $response;
56
+ } else {
57
+ // no username/password: return an empty string
58
+ return '';
59
+ }
60
+ }
61
+
62
+
63
+ function jd_twit( $post_ID ) {
64
+ $twitterURI = "/statuses/update.xml";
65
+ $thisposttitle = urlencode( stripcslashes( $_POST['post_title'] ) );
66
+ $thispostlink = get_permalink( $post_ID );
67
+ $thisblogtitle = urlencode( get_bloginfo( 'name' ) );
68
+ $cligsapi = get_option( 'cligsapi' );
69
+ $sentence = '';
70
+ $customTweet = stripcslashes( $_POST['jd_twitter'] );
71
+
72
+ if ( $_POST['publish'] == 'Publish' ){
73
+ // publish new post
74
+ if ( get_option( 'newpost-published-update' ) == '1' ) {
75
+ $sentence = get_option( 'newpost-published-text' );
76
+ if ( get_option( 'newpost-published-showlink') == '1' ) {
77
+ // Generate and grab the clig using the Cli.gs API
78
+ $shrink = file_get_contents( "http://cli.gs/api/v1/cligs/create?url=".$thispostlink."&title=".$thisposttitle."&key=".$cligsapi."&appid=WP-to-Twitter" );
79
+ $sentence = $sentence . " " . $shrink;
80
+
81
+ if ( $customTweet != "" ) {
82
+ // Get the custom Tweet message if it's been supplied. Truncate it to fit if necessary.
83
+ if ( get_option( 'newpost-published-showlink') == '1' ) {
84
+ if ( ( strlen( $customTweet ) + 21) > 140 ) {
85
+ $customTweet = substr( $customTweet, 0, 119 );
86
+ }
87
+ } else {
88
+ if ( strlen( $customTweet ) > 140 ) {
89
+ $customTweet = substr( $customTweet, 0, 140 );
90
+ }
91
+ }
92
+ if ( get_option( 'newpost-published-showlink') == '1' ) {
93
+ $sentence = $customTweet . " " . $shrink;
94
+ } else {
95
+ $sentence = $customTweet;
96
+ }
97
+ } else {
98
+ // Check the length of the tweet and truncate parts as necessary.
99
+ $twit_length = strlen( $sentence );
100
+ $title_length = strlen( $thisposttitle );
101
+ $blog_length = strlen( $thisblogtitle );
102
+ if ( ( ( $twit_length + $title_length ) - 7 ) < 140 ) {
103
+ $sentence = str_replace( '#title#', $thisposttitle, $sentence );
104
+ $twit_length = strlen( $sentence );
105
+ } else {
106
+ $thisposttitle = substr( $thisposttitle, 0, ( 140- ( $twit_length-3 ) ) ) . "...";
107
+ $sentence = str_replace ( '#title#', $thisposttitle, $sentence );
108
+ $twit_length = strlen( $sentence );
109
+ }
110
+ if ( ( ( $twit_length + $blog_length ) - 6 ) < 140 ) {
111
+ $thisblogtitle = substr( $thisblogtitle, 0, ( 140-( $twit_length-3 ) ) ) . "...";
112
+ $sentence = str_replace ( '#blog#',$thisblogtitle,$sentence );
113
+ }
114
+ }
115
+ /* This is for testing. Creates a post meta field containing the Cli.gs API request string
116
+ //add_post_meta($post_ID, 'post_cligs_text',"http://cli.gs/api/v1/cligs/create?url=".$thispostlink."&title=".$thisposttitle."&key=".$cligsapi."&appid=WP-to-Twitter"); */
117
+ }
118
+ }
119
+ } else if ( ( $_POST['originalaction'] == "editpost" ) && ( $_POST['prev_status'] == 'publish' ) ) {
120
+ // if this is an old post and editing updates are enabled
121
+ if ( get_option( 'oldpost-edited-update') == '1' ) {
122
+ $sentence = get_option( 'oldpost-edited-text' );
123
+ if ( get_option( 'oldpost-edited-showlink') == '1') {
124
+ $thisposttitle = $thisposttitle . ' ( ' . $thispostlink . ' )';
125
+ }
126
+ $sentence = str_replace( '#title#', $thisposttitle, $sentence );
127
+ $sentence = str_replace( '#blog#',$thisblogtitle,$sentence );
128
+
129
+ }
130
+ }
131
+
132
+ if ( $sentence != '' ) {
133
+ $sendToTwitter = jd_doTwitterAPIPost( 'status='.$sentence, $twitterURI );
134
+ }
135
+
136
+ return $post_ID;
137
+ }
138
+ // Add custom Tweet field on Post & Page write/edit forms
139
+ function jd_add_twitter_textinput() {
140
+ global $post;
141
+ $post_id = $post;
142
+ if (is_object($post_id)) {
143
+ $post_id = $post_id->ID;
144
+ }
145
+ $jd_twitter = htmlspecialchars(stripcslashes(get_post_meta($post_id, 'jd_twitter', true)));
146
+ ?>
147
+ <script type="text/javascript">
148
+ <!-- Begin
149
+ function countChars(field,cntfield) {
150
+ cntfield.value = field.value.length;
151
+ }
152
+ // End -->
153
+ </script>
154
+ <?php /* Compatibility with version 2.3 and below (needs to be tested.) */ ?>
155
+ <?php if (substr(get_bloginfo('version'), 0, 3) >= '2.5') { ?>
156
+ <div id="wp-to-twitter" class="postbox closed">
157
+ <h3><?php _e('WP to Twitter', 'wp-to-twitter') ?></h3>
158
+ <div class="inside">
159
+ <div id="jd-twitter">
160
+ <?php } else { ?>
161
+ <div class="dbx-b-ox-wrapper">
162
+ <fieldset id="twitdiv" class="dbx-box">
163
+ <div class="dbx-h-andle-wrapper">
164
+ <h3 class="dbx-handle"><?php _e('WP to Twitter', 'wp-to-twitter') ?></h3>
165
+ </div>
166
+ <div class="dbx-c-ontent-wrapper">
167
+ <div class="dbx-content">
168
+ <?php } ?>
169
+
170
+ <input value="jd_twit_edit" type="hidden" name="jd_twit_edit" />
171
+
172
+ <label for="jd_twitter"><?php _e('Twitter Post', 'wp-to-twitter') ?></label><br /><textarea name="jd_twitter" id="jd_twitter" rows="2" cols="60"
173
+ onKeyDown="countChars(document.post.jd_twitter,document.post.twitlength)"
174
+ onKeyUp="countChars(document.post.jd_twitter,document.post.twitlength)"><?php echo $jd_twitter ?></textarea>
175
+ <p><input readonly type="text" name="twitlength" size="3" maxlength="3" value="<?php echo strlen( $description); ?>" />
176
+ <?php _e(' characters. Twitter posts are a maximum of 140 characters; if your Cli.gs URL is appended to the end of your document, you have 119 characters available.', 'wp-to-twitter') ?> <a target="__blank" href="<?php echo $jd_plugin_url; ?>"><?php _e('Get Support', 'wp-to-twitter') ?></a> &raquo;
177
+ </p>
178
+ <?php if (substr(get_bloginfo('version'), 0, 3) >= '2.5') { ?>
179
+ </div></div></div>
180
+ <?php } else { ?>
181
+ </div>
182
+ </fieldset>
183
+ </div>
184
+ <?php } ?>
185
+
186
+ <?php
187
+ }
188
+ // Post the Custom Tweet into the post meta table
189
+ function post_jd_twitter( $id ) {
190
+ $jd_twit_edit = $_POST["jd_twit_edit"];
191
+ if (isset($jd_twit_edit) && !empty($jd_twit_edit)) {
192
+ $jd_twitter = $_POST["jd_twitter"];
193
+ delete_post_meta( $id, 'jd_twitter' );
194
+ if (isset($jd_twitter) && !empty($jd_twitter)) {
195
+ add_post_meta( $id, 'jd_twitter', $jd_twitter );
196
+ }
197
+ }
198
+ }
199
+
200
+ // Add the administrative settings to the "Settings" menu.
201
+ function jd_addTwitterAdminPages() {
202
+ if ( function_exists( 'add_submenu_page' ) ) {
203
+ add_options_page( 'WP -> Twitter', 'WP -> Twitter', 8, __FILE__, 'jd_wp_Twitter_manage_page' );
204
+ }
205
+ }
206
+ // Include the Manager page
207
+ function jd_wp_Twitter_manage_page() {
208
+ include(dirname(__FILE__).'/wp-to-twitter-manager.php' );
209
+ }
210
+
211
+
212
+ //Add Plugin Actions to WordPress
213
+ if ( substr( get_bloginfo( 'version' ), 0, 3 ) >= '2.5' ) {
214
+ add_action( 'edit_form_advanced','jd_add_twitter_textinput' );
215
+ if ( get_option( 'jd_twit_pages')=='1') {
216
+ add_action( 'edit_page_form','jd_add_twitter_textinput' );
217
+ }
218
+ } else {
219
+ add_action( 'dbx_post_advanced','jd_add_twitter_textinput' );
220
+ if (get_option( 'jd_twit_pages')=='1') {
221
+ add_action( 'dbx_page_advanced','jd_add_twitter_textinput' );
222
+ }
223
+ }
224
+
225
+
226
+ if ( get_option( 'jd_twit_pages')=='1') {
227
+ add_action( 'publish_page', 'jd_twit' );
228
+ add_action( 'edit_page','post_jd_twitter' );
229
+ add_action( 'publish_page','post_jd_twitter' );
230
+ }
231
+ add_action( 'publish_post', 'jd_twit' );
232
+ add_action( 'admin_menu', 'jd_addTwitterAdminPages' );
233
+ add_action( 'edit_post','post_jd_twitter' );
234
+ add_action( 'publish_post','post_jd_twitter' );
235
+ ?>