Version Description
- Added option to auto tweet articles, removing the checkbox from the add post screen. This makes sure auto tweet works when you're posting from within an external editor.
Download this release
Release Info
Developer | joostdevalk |
Plugin | Clicky by Yoast |
Version | 1.0.2 |
Comparing to | |
See all releases |
Version 1.0.2
- clicky-32x32.png +0 -0
- clicky.php +410 -0
- readme.txt +43 -0
- screenshot-1.jpg +0 -0
- yst_plugin_tools.css +29 -0
- yst_plugin_tools.php +186 -0
clicky-32x32.png
ADDED
Binary file
|
clicky.php
ADDED
@@ -0,0 +1,410 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Clicky for WordPress
|
4 |
+
Version: 1.0.2
|
5 |
+
Plugin URI: http://getclicky.com/goodies/
|
6 |
+
Description: Integrates Clicky on your blog!
|
7 |
+
Author: Joost de Valk
|
8 |
+
Author URI: http://yoast.com/
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( ! class_exists( 'Clicky_Admin' ) ) {
|
12 |
+
|
13 |
+
require_once('yst_plugin_tools.php');
|
14 |
+
|
15 |
+
class Clicky_Admin extends Clicky_Base_Plugin_Admin {
|
16 |
+
|
17 |
+
var $hook = 'clicky';
|
18 |
+
var $longname = 'Clicky Configuration';
|
19 |
+
var $shortname = 'Clicky';
|
20 |
+
var $shorturl_service = 'Clicky.me';
|
21 |
+
var $filename = 'clicky/clicky.php';
|
22 |
+
var $homepage = 'http://getclicky.com/goodies/';
|
23 |
+
var $feed = 'http://getclicky.com/blog/rss';
|
24 |
+
|
25 |
+
function meta_box() {
|
26 |
+
add_meta_box('clickyme',$this->shortname,array('Clicky_Admin','clicky_meta_box'),'post','side');
|
27 |
+
add_meta_box('clickyme',$this->shortname,array('Clicky_Admin','clicky_meta_box'),'page','side');
|
28 |
+
}
|
29 |
+
|
30 |
+
function clicky_admin_warnings() {
|
31 |
+
$options = get_option('clicky');
|
32 |
+
if ( (!$options['site_id'] || empty($options['site_id']) || !$options['site_key'] || empty($options['site_key']) || !$options['admin_site_key'] || empty($options['admin_site_key'])) && !$_POST ) {
|
33 |
+
function clicky_warning() {
|
34 |
+
echo "<div id='clickywarning' class='updated fade'><p><strong>Clicky is almost ready</strong> You must <a href='options-general.php?page=clicky'>enter your Clicky Site ID, Site Key and Admin Site Key</a> for it to work.</p></div>";
|
35 |
+
echo "<script type=\"text/javascript\">setTimeout(function(){jQuery('#clickywarning').hide('slow');}, 10000);</script>";
|
36 |
+
}
|
37 |
+
add_action('admin_notices', 'clicky_warning');
|
38 |
+
return;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
function clicky_meta_box() {
|
43 |
+
global $post;
|
44 |
+
$options = get_option('clicky');
|
45 |
+
$clicky_goal = get_post_meta($post->ID,'_clicky_goal',true);
|
46 |
+
$clicky_tweetpost = get_post_meta($post->ID,'_clicky_tweetpost',true);
|
47 |
+
|
48 |
+
if ($clicky_tweetpost == '' && $post->post_type == 'post')
|
49 |
+
$clicky_tweetpost = true;
|
50 |
+
|
51 |
+
if ($options['allow_clickyme_integration']) {
|
52 |
+
if ($post->post_status == 'publish') {
|
53 |
+
$shorturl = clickyme_shorturl($post->ID);
|
54 |
+
echo '<p><strong>Twitter</strong></p>';
|
55 |
+
echo '<p>The Clicky.me short URL for this '.$post->post_type.' is <a href="'.$shorturl.'">'.$shorturl.'</a>. <a target="_blank" href="http://twitter.com/home?status='.urlencode($post->post_title.' - '.$shorturl).'">Tweet this post</a>.</p>';
|
56 |
+
echo '<br/>';
|
57 |
+
} else {
|
58 |
+
if (!$options['auto_tweet']) {
|
59 |
+
echo '<p><strong>Twitter</strong></p>';
|
60 |
+
echo '<p>This '.$post->post_type.' is not published yet, a short URL will be created for it once the post is published. Do you want it to be tweeted automatically too?<br/>
|
61 |
+
<br/>
|
62 |
+
<input type="checkbox" name="clicky_tweetpost" '.checked($clicky_tweetpost,true,false).'/> Tweet '.$post->post_type.' on publish</p>';
|
63 |
+
echo '<br/>';
|
64 |
+
}
|
65 |
+
}
|
66 |
+
}
|
67 |
+
echo '<p><strong>Goal Tracking</strong></p>';
|
68 |
+
echo '<p>Clicky can track Goals for you too, <a href="http://getclicky.com/stats/goals-setup">read the documentation here</a>. To be able to track a goal on this '.$post->post_type.', you need to specify the goal ID here. Optionally, you can also provide the goal revenue.</p>';
|
69 |
+
echo '<table>';
|
70 |
+
echo '<tr><th style="text-align:left;"><label for="clicky_goal_id">Goal ID:</label></th><td><input type="text" name="clicky_goal_id" id="clicky_goal_id" value="'.$clicky_goal['id'].'"/></td></tr>';
|
71 |
+
echo '<tr><th style="text-align:left;"><label for="clicky_goal_value">Goal Revenue: </label></th><td><input type="text" name="clicky_goal_value" id="clicky_goal_value" value="'.$clicky_goal['value'].'"/></td></tr>';
|
72 |
+
echo '</table>';
|
73 |
+
}
|
74 |
+
|
75 |
+
function Clicky_Admin() {
|
76 |
+
add_action( 'admin_menu', array(&$this, 'register_settings_page') );
|
77 |
+
add_action( 'admin_menu', array(&$this, 'register_dashboard_page') );
|
78 |
+
|
79 |
+
add_filter( 'plugin_action_links', array(&$this, 'add_action_link'), 10, 2 );
|
80 |
+
add_filter( 'ozh_adminmenu_icon', array(&$this, 'add_ozh_adminmenu_icon' ) );
|
81 |
+
|
82 |
+
add_action('admin_print_scripts', array(&$this,'config_page_scripts'));
|
83 |
+
add_action('admin_print_styles', array(&$this,'config_page_styles'));
|
84 |
+
|
85 |
+
add_action('admin_menu', array(&$this,'meta_box'));
|
86 |
+
add_action('wp_insert_post', array(&$this,'clicky_insert_post'));
|
87 |
+
|
88 |
+
$this->clicky_admin_warnings();
|
89 |
+
}
|
90 |
+
|
91 |
+
function clicky_insert_post($pID) {
|
92 |
+
global $_POST;
|
93 |
+
$options = get_option('clicky');
|
94 |
+
extract($_POST);
|
95 |
+
$clicky_goal = array();
|
96 |
+
$clicky_goal['id'] = $clicky_goal_id;
|
97 |
+
$clicky_goal['value'] = $clicky_goal_value;
|
98 |
+
delete_post_meta($pID,'_clicky_goal');
|
99 |
+
add_post_meta($pID,'_clicky_goal',$clicky_goal, true);
|
100 |
+
|
101 |
+
if ($options['allow_clickyme_integration'] && !$options['auto_tweet']) {
|
102 |
+
delete_post_meta($pID,'_clicky_tweetpost');
|
103 |
+
if (isset($clicky_tweetpost))
|
104 |
+
add_post_meta($pID,'_clicky_tweetpost',true, true);
|
105 |
+
else
|
106 |
+
add_post_meta($pID,'_clicky_tweetpost',false, true);
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
function register_dashboard_page() {
|
111 |
+
add_dashboard_page($this->shortname.' Stats', $this->shortname.' Stats', $this->accesslvl, $this->hook, array(&$this,'dashboard_page'));
|
112 |
+
}
|
113 |
+
|
114 |
+
function dashboard_page() {
|
115 |
+
$options = get_option('clicky');
|
116 |
+
?>
|
117 |
+
<br/>
|
118 |
+
<iframe style="margin-left: 20px; width: 850px; height: 1000px;" src="http://getclicky.com/stats/wp-iframe?site_id=<?php echo $options['site_id']; ?>&sitekey=<?php echo $options['site_key']; ?>"></iframe>
|
119 |
+
<?php
|
120 |
+
}
|
121 |
+
|
122 |
+
function config_page() {
|
123 |
+
$options = get_option('clicky');
|
124 |
+
|
125 |
+
if ( isset($_POST['submit']) ) {
|
126 |
+
if (!current_user_can('manage_options')) die(__('You cannot edit the Clicky settings.'));
|
127 |
+
check_admin_referer('clicky-config');
|
128 |
+
|
129 |
+
foreach (array('site_id', 'site_key', 'admin_site_key', 'twitter_username', 'twitter_password', 'twitter_prefix') as $option_name) {
|
130 |
+
if (isset($_POST[$option_name]))
|
131 |
+
$options[$option_name] = $_POST[$option_name];
|
132 |
+
else
|
133 |
+
$options[$option_name] = '';
|
134 |
+
}
|
135 |
+
|
136 |
+
foreach (array('ignore_admin', 'track_names', 'allow_clickyme_integration','auto_tweet') as $option_name) {
|
137 |
+
if (isset($_POST[$option_name]))
|
138 |
+
$options[$option_name] = true;
|
139 |
+
else
|
140 |
+
$options[$option_name] = false;
|
141 |
+
}
|
142 |
+
|
143 |
+
if (get_option('clicky') != $options) {
|
144 |
+
update_option('clicky', $options);
|
145 |
+
$message = "<p>Clicky settings have been updated.</p>";
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
if (isset($error) && $error != "") {
|
150 |
+
echo "<div id=\"message\" class=\"error\">$error</div>\n";
|
151 |
+
} elseif (isset($message) && $message != "") {
|
152 |
+
echo "<div id=\"updatemessage\" class=\"updated fade\">$message</div>\n";
|
153 |
+
echo "<script type=\"text/javascript\">setTimeout(function(){jQuery('#updatemessage').hide('slow');}, 3000);</script>";
|
154 |
+
}
|
155 |
+
?>
|
156 |
+
<div class="wrap">
|
157 |
+
<a href="http://getclicky.com/"><div id="clicky-icon" style="background: url(<?php echo plugins_url('',__FILE__); ?>/clicky-32x32.png) no-repeat;" class="icon32"><br /></div></a>
|
158 |
+
<h2>Clicky Configuration</h2>
|
159 |
+
<div class="postbox-container" style="width:70%;">
|
160 |
+
<div class="metabox-holder">
|
161 |
+
<div class="meta-box-sortables">
|
162 |
+
<form action="" method="post" id="clicky-conf" enctype="multipart/form-data">
|
163 |
+
<?php
|
164 |
+
wp_nonce_field('clicky-config');
|
165 |
+
|
166 |
+
$content = '<p style="text-align:left; margin: 0 10px; font-size: 13px; line-height: 150%;">Go to your <a href="http://getclicky.com/user/">user homepage on Clicky</a> and click "Preferences" under the name of the domain, you will find the Site ID, Site Key and Admin Site Key under Site information.</p>';
|
167 |
+
|
168 |
+
$rows = array ();
|
169 |
+
$rows[] = array(
|
170 |
+
'id' => 'site_id',
|
171 |
+
'label' => 'Site ID',
|
172 |
+
'desc' => '',
|
173 |
+
'content' => '<input class="text" type="text" value="'.$options['site_id'].'" name="site_id" id="site_id"/>',
|
174 |
+
);
|
175 |
+
|
176 |
+
$rows[] = array(
|
177 |
+
'id' => 'site_key',
|
178 |
+
'label' => 'Site Key',
|
179 |
+
'desc' => '',
|
180 |
+
'content' => '<input class="text" type="text" value="'.$options['site_key'].'" name="site_key" id="site_key"/>',
|
181 |
+
);
|
182 |
+
|
183 |
+
$rows[] = array(
|
184 |
+
'id' => 'admin_site_key',
|
185 |
+
'label' => 'Admin Site Key',
|
186 |
+
'desc' => '',
|
187 |
+
'content' => '<input class="text" type="text" value="'.$options['admin_site_key'].'" name="admin_site_key" id="admin_site_key"/>',
|
188 |
+
);
|
189 |
+
|
190 |
+
$content .= ' '.$this->form_table($rows);
|
191 |
+
$this->postbox('clicky_settings','Clicky Settings', $content);
|
192 |
+
|
193 |
+
$content = '<p style="text-align:left; margin: 0 10px; font-size: 13px; line-height: 150%;">This plugin allows you to automatically create short URL\'s through the <a href="http://clicky.me">Clicky.me service</a>, and tweet your post immediately when you publish it. To do that, this plugin will need your Twitter username and pass.</p>';
|
194 |
+
|
195 |
+
$rows = array();
|
196 |
+
$rows[] = array(
|
197 |
+
'id' => 'ignore_admin',
|
198 |
+
'label' => 'Ignore Admin users',
|
199 |
+
'desc' => 'If you are using a caching plugin, such as WP-Supercache, please ensure that you have it configured to NOT use the cache for logged in users. Otherwise, admin users <em>will still</em> be tracked.',
|
200 |
+
'content' => '<input type="checkbox" '.checked($options['ignore_admin'],true,false).' name="ignore_admin" id="ignore_admin"/>',
|
201 |
+
);
|
202 |
+
|
203 |
+
$rows[] = array(
|
204 |
+
'id' => 'track_names',
|
205 |
+
'label' => 'Track names of commenters',
|
206 |
+
'desc' => '',
|
207 |
+
'content' => '<input type="checkbox" '.checked($options['track_names'],true,false).' name="track_names" id="track_names"/>'
|
208 |
+
);
|
209 |
+
|
210 |
+
$this->postbox('clicky_settings','Advanced Settings', $this->form_table($rows));
|
211 |
+
|
212 |
+
$rows = array();
|
213 |
+
$rows[] = array(
|
214 |
+
'id' => 'allow_clickyme_integration',
|
215 |
+
'label' => 'Allow Clicky.me integration',
|
216 |
+
'desc' => '',
|
217 |
+
'content' => '<input type="checkbox" '.checked($options['allow_clickyme_integration'],true,false).' name="allow_clickyme_integration" id="allow_clickyme_integration"/>',
|
218 |
+
);
|
219 |
+
|
220 |
+
$rows[] = array(
|
221 |
+
'id' => 'auto_tweet',
|
222 |
+
'label' => 'Auto Tweet',
|
223 |
+
'desc' => 'No need to check the box on each post, by checking this box, each post get\'s tweeted automatically.',
|
224 |
+
'content' => '<input type="checkbox" '.checked($options['auto_tweet'],true,false).' name="auto_tweet" id="auto_tweet"/>',
|
225 |
+
);
|
226 |
+
|
227 |
+
$rows[] = array(
|
228 |
+
'id' => 'twitter_username',
|
229 |
+
'label' => 'Twitter username',
|
230 |
+
'desc' => '',
|
231 |
+
'content' => '<input type="text" value="'.$options['twitter_username'].'" name="twitter_username" id="twitter_username"/>'
|
232 |
+
);
|
233 |
+
|
234 |
+
$rows[] = array(
|
235 |
+
'id' => 'twitter_password',
|
236 |
+
'label' => 'Twitter password',
|
237 |
+
'desc' => '',
|
238 |
+
'content' => '<input type="password" value="'.$options['twitter_password'].'" name="twitter_password" id="twitter_password"/>'
|
239 |
+
);
|
240 |
+
|
241 |
+
$rows[] = array(
|
242 |
+
'id' => 'twitter_prefix',
|
243 |
+
'label' => 'Prefix for Tweets',
|
244 |
+
'desc' => 'This text will be put in front of Tweets that are published when a blog post is published',
|
245 |
+
'content' => '<input type="text" class="text" value="'.$options['twitter_prefix'].'" name="twitter_prefix" id="twitter_prefix"/>'
|
246 |
+
);
|
247 |
+
|
248 |
+
$this->postbox('clickyme_integration','Clicky.me & Twitter Integration', $content .' '. $this->form_table($rows));
|
249 |
+
|
250 |
+
|
251 |
+
?>
|
252 |
+
<div class="submit">
|
253 |
+
<input type="submit" class="button-primary" name="submit" value="Update Clicky Settings »" />
|
254 |
+
</div>
|
255 |
+
</form>
|
256 |
+
</div>
|
257 |
+
</div>
|
258 |
+
</div>
|
259 |
+
<div class="postbox-container" style="width:20%;">
|
260 |
+
<div class="metabox-holder">
|
261 |
+
<div class="meta-box-sortables">
|
262 |
+
<?php
|
263 |
+
$this->plugin_like('clicky');
|
264 |
+
$this->plugin_support('clicky');
|
265 |
+
$this->news();
|
266 |
+
?>
|
267 |
+
</div>
|
268 |
+
<br/><br/><br/>
|
269 |
+
</div>
|
270 |
+
</div>
|
271 |
+
</div>
|
272 |
+
<?php
|
273 |
+
}
|
274 |
+
}
|
275 |
+
$clicky_admin = new Clicky_Admin();
|
276 |
+
}
|
277 |
+
|
278 |
+
function clicky_defaults() {
|
279 |
+
$options = array(
|
280 |
+
'site_id' => '',
|
281 |
+
'site_key' => '',
|
282 |
+
'admin_site_key' => '',
|
283 |
+
'twitter_username' => '',
|
284 |
+
'twitter_password' => '',
|
285 |
+
'twitter_prefix' => '',
|
286 |
+
'auto_tweet' => false,
|
287 |
+
'ignore_admin' => false,
|
288 |
+
'track_names' => true,
|
289 |
+
'allow_clickyme_integration' => true,
|
290 |
+
);
|
291 |
+
add_option('clicky',$options);
|
292 |
+
}
|
293 |
+
|
294 |
+
function clickyme_shorturl($pid) {
|
295 |
+
$shorturl = get_post_meta($post->ID, '_clickyme_url', true);
|
296 |
+
if (!$shorturl) {
|
297 |
+
$options = get_option('clicky');
|
298 |
+
if ( empty($options['site_id']) || empty($options['admin_site_key']) )
|
299 |
+
return false;
|
300 |
+
|
301 |
+
$res = wp_remote_get('http://clicky.me/app/api?site_id='.$options['site_id'].'&sitekey_admin='.$options['admin_site_key'].'&url='.get_permalink($pid));
|
302 |
+
if ($res['response']['code'] == 200) {
|
303 |
+
$shorturl = trim($res['body']);
|
304 |
+
if (preg_match( '#^http://#', $shorturl ))
|
305 |
+
add_post_meta($post->ID,'_clickyme_url',$shorturl,true);
|
306 |
+
}
|
307 |
+
}
|
308 |
+
return $shorturl;
|
309 |
+
}
|
310 |
+
|
311 |
+
function publish_tweet($pid) {
|
312 |
+
$options = get_option('clicky');
|
313 |
+
if (!$options['allow_clickyme_integration'] || $options['twitter_username'] == "" || $options['twitter_password'] == "")
|
314 |
+
return false;
|
315 |
+
|
316 |
+
if (!$options['auto_tweet']) {
|
317 |
+
// Check if post has to be tweeted, if not, return false, else make sure it doesn't get tweeted twice.
|
318 |
+
$clicky_tweetpost = get_post_meta($pid,'_clicky_tweetpost',true);
|
319 |
+
|
320 |
+
if (!$clicky_tweetpost) {
|
321 |
+
return false;
|
322 |
+
} else {
|
323 |
+
delete_post_meta($pid,'_clicky_tweetpost');
|
324 |
+
add_post_meta($pid,'_clicky_tweetpost',false, true);
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
+
$shorturl = clickyme_shorturl( $pid );
|
329 |
+
$su_length = strlen( $shorturl );
|
330 |
+
$status = trim( $options['twitter_prefix'] ).' '.get_the_title( $pid ).' -';
|
331 |
+
|
332 |
+
// Make sure the tweet message isn't too long, so make sure the shorturl fits
|
333 |
+
$max = 139 - $su_length;
|
334 |
+
if ( strlen( $status ) > $max ) {
|
335 |
+
$status = substr( 0, $max, $status );
|
336 |
+
}
|
337 |
+
$status .= ' '.$shorturl;
|
338 |
+
|
339 |
+
$headers = array( 'Authorization' => 'Basic '.base64_encode($options['twitter_username'].":".$options['twitter_password']) );
|
340 |
+
$request = new WP_Http;
|
341 |
+
$result = $request->request(
|
342 |
+
'http://twitter.com/statuses/update.xml' ,
|
343 |
+
array(
|
344 |
+
'method' => 'POST',
|
345 |
+
'body' => array('status' => $status),
|
346 |
+
'headers' => $headers )
|
347 |
+
);
|
348 |
+
return $result;
|
349 |
+
}
|
350 |
+
add_action('publish_post','publish_tweet');
|
351 |
+
add_action('publish_page','publish_tweet');
|
352 |
+
|
353 |
+
function clicky_script() {
|
354 |
+
$options = get_option('clicky');
|
355 |
+
if (!is_array($options)) {
|
356 |
+
clicky_defaults();
|
357 |
+
}
|
358 |
+
|
359 |
+
// Bail early if current user is admin and ignore admin is true
|
360 |
+
if( $options['ignore_admin'] && current_user_can("manage_options") ) {
|
361 |
+
echo "\n<!-- Clicky tracking not shown because you're an administrator and you've configured Clicky to ignore administrators. -->\n";
|
362 |
+
return;
|
363 |
+
}
|
364 |
+
|
365 |
+
|
366 |
+
// Branding
|
367 |
+
?>
|
368 |
+
<!-- Clicky Web Analytics - http://getclicky.com, WordPress Plugin by Yoast - http://yoast.com -->
|
369 |
+
<?php
|
370 |
+
// Track commenter name if track_names is true
|
371 |
+
if( $options['track_names'] )
|
372 |
+
{ ?>
|
373 |
+
<script type='text/javascript'>
|
374 |
+
function clicky_gc( name ) {
|
375 |
+
var ca = document.cookie.split(';');
|
376 |
+
for( var i in ca ) {
|
377 |
+
if( ca[i].indexOf( name+'=' ) != -1 )
|
378 |
+
return decodeURIComponent( ca[i].split('=')[1] );
|
379 |
+
}
|
380 |
+
return '';
|
381 |
+
}
|
382 |
+
var clicky_custom_session = { username: clicky_gc( 'comment_author_<?php echo md5( get_option("siteurl") ); ?>' ) };
|
383 |
+
</script>
|
384 |
+
<?php }
|
385 |
+
|
386 |
+
// Goal tracking
|
387 |
+
if (is_singular()) {
|
388 |
+
global $post;
|
389 |
+
$clicky_goal = get_post_meta($post->ID,'_clicky_goal',true);
|
390 |
+
if (isset($clicky_goal)) {
|
391 |
+
echo '<script type="text/javascript">';
|
392 |
+
echo 'var clicky_goal = { id: "'.$clicky_goal['id'].'"';
|
393 |
+
if (isset($clicky_goal['value']) && !empty($clicky_goal['value']))
|
394 |
+
echo ', revenue: "'.$clicky_goal['value'].'"';
|
395 |
+
echo ' };';
|
396 |
+
echo '</script>';
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
// Display the script
|
401 |
+
?>
|
402 |
+
<script src="http://static.getclicky.com/js" type="text/javascript"></script>
|
403 |
+
<script type="text/javascript">clicky.init(<?php echo $options['site_id']; ?>);</script>
|
404 |
+
<noscript><p><img alt="Clicky" width="1" height="1" src="http://static.getclicky.com/<?php echo $options['site_id']; ?>ns.gif" /></p></noscript>
|
405 |
+
<!-- End Clicky Tracking -->
|
406 |
+
<?php
|
407 |
+
}
|
408 |
+
add_action('wp_footer','clicky_script',90);
|
409 |
+
|
410 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Clicky ===
|
2 |
+
Contributors: joostdevalk
|
3 |
+
Donate link: http://yoast.com/
|
4 |
+
Tags: analytics, statistics, clicky
|
5 |
+
Requires at least: 2.8
|
6 |
+
Tested up to: 2.9
|
7 |
+
Stable tag: 1.0.2
|
8 |
+
|
9 |
+
Integrates the Clicky web analytics service and optionally the Clicky.me short URL service into your blog.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Integrates the Clicky web analytics service and optionally the Clicky.me short URL service into your blog.
|
14 |
+
|
15 |
+
* Automatically adding your Clicky tracking code everywhere.
|
16 |
+
* Option to ignore admins.
|
17 |
+
* Option to store names of commenters.
|
18 |
+
* Option to track posts & pages as goals and assign a revenue to that page or post.
|
19 |
+
* An overview of your site's statistics on your dashboard.
|
20 |
+
* Integration with the [Clicky.me Short URL service](http://clicky.me/).
|
21 |
+
* Automatically create a short link for each now post and page.
|
22 |
+
* Option to automatically tweet posts and pages on publish (either for each and every one or on a post by post basis), with the message being a prefix of your choice, the post title and then the short URL.
|
23 |
+
|
24 |
+
== Installation ==
|
25 |
+
|
26 |
+
1. Upload the `clicky` folder to the `/wp-content/plugins/` directory
|
27 |
+
1. Activate the plugin through the 'Plugins' menu in WordPress
|
28 |
+
1. Enter your Site ID, Key and Admin Key, and if needed your Twitter username and password.
|
29 |
+
|
30 |
+
== Screenshots ==
|
31 |
+
|
32 |
+
1. The Clicky WordPress plugin settings panel.
|
33 |
+
|
34 |
+
== Changelog ==
|
35 |
+
|
36 |
+
= 1.0.2 =
|
37 |
+
* Added option to auto tweet articles, removing the checkbox from the add post screen. This makes sure auto tweet works when you're posting from within an external editor.
|
38 |
+
|
39 |
+
= 1.0.1 =
|
40 |
+
* Added prefix option for Tweets that are sent out on publish.
|
41 |
+
|
42 |
+
= 1.0 =
|
43 |
+
* Initial release.
|
screenshot-1.jpg
ADDED
Binary file
|
yst_plugin_tools.css
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
small {
|
2 |
+
font-weight:normal;
|
3 |
+
color:#777;
|
4 |
+
}
|
5 |
+
|
6 |
+
div.inside ul {
|
7 |
+
margin-left: 20px;
|
8 |
+
}
|
9 |
+
|
10 |
+
div.inside ul li {
|
11 |
+
list-style: square;
|
12 |
+
line-height:16px;
|
13 |
+
}
|
14 |
+
|
15 |
+
div.inside ul li.rss {
|
16 |
+
list-style-image: url(/wp-includes/images/rss.png);
|
17 |
+
}
|
18 |
+
|
19 |
+
div.inside ul li.email {
|
20 |
+
list-style-image: url(http://cdn.yoast.com/email_sub.png);
|
21 |
+
}
|
22 |
+
|
23 |
+
div.inside ul li.yoast {
|
24 |
+
list-style-image: url(http://cdn.yoast.com/theme/yoast-16x16.png);
|
25 |
+
}
|
26 |
+
|
27 |
+
.text {
|
28 |
+
width: 250px;
|
29 |
+
}
|
yst_plugin_tools.php
ADDED
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Backend Class for use in all Yoast plugins, modified for Clicky plugin
|
5 |
+
* Version 0.2
|
6 |
+
*/
|
7 |
+
|
8 |
+
if (!class_exists('Clicky_Base_Plugin_Admin')) {
|
9 |
+
class Clicky_Base_Plugin_Admin {
|
10 |
+
|
11 |
+
var $hook = '';
|
12 |
+
var $filename = '';
|
13 |
+
var $longname = '';
|
14 |
+
var $shortname = '';
|
15 |
+
var $ozhicon = '';
|
16 |
+
var $optionname = '';
|
17 |
+
var $homepage = '';
|
18 |
+
var $accesslvl = 'manage_options';
|
19 |
+
var $feed = '';
|
20 |
+
|
21 |
+
function Clicky_Base_Plugin_Admin() {
|
22 |
+
add_action( 'admin_menu', array(&$this, 'register_settings_page') );
|
23 |
+
|
24 |
+
add_filter( 'plugin_action_links', array(&$this, 'add_action_link'), 10, 2 );
|
25 |
+
add_filter( 'ozh_adminmenu_icon', array(&$this, 'add_ozh_adminmenu_icon' ) );
|
26 |
+
|
27 |
+
add_action( 'admin_print_scripts', array(&$this,'config_page_scripts') );
|
28 |
+
add_action( 'admin_print_styles', array(&$this,'config_page_styles') );
|
29 |
+
|
30 |
+
add_action('wp_dashboard_setup', array(&$this,'widget_setup') );
|
31 |
+
}
|
32 |
+
|
33 |
+
function add_ozh_adminmenu_icon( $hook ) {
|
34 |
+
if ($hook == $this->hook)
|
35 |
+
return WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname($filename)). '/'.$this->ozhicon;
|
36 |
+
return $hook;
|
37 |
+
}
|
38 |
+
|
39 |
+
function config_page_styles() {
|
40 |
+
if (isset($_GET['page']) && $_GET['page'] == $this->hook) {
|
41 |
+
wp_enqueue_style('dashboard');
|
42 |
+
wp_enqueue_style('thickbox');
|
43 |
+
wp_enqueue_style('global');
|
44 |
+
wp_enqueue_style('wp-admin');
|
45 |
+
wp_enqueue_style('clicky-admin-css', WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname(__FILE__)). '/yst_plugin_tools.css');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
function register_settings_page() {
|
50 |
+
add_options_page($this->longname, $this->shortname, $this->accesslvl, $this->hook, array(&$this,'config_page'));
|
51 |
+
}
|
52 |
+
|
53 |
+
function plugin_options_url() {
|
54 |
+
return admin_url( 'options-general.php?page='.$this->hook );
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Add a link to the settings page to the plugins list
|
59 |
+
*/
|
60 |
+
function add_action_link( $links, $file ) {
|
61 |
+
static $this_plugin;
|
62 |
+
if( empty($this_plugin) ) $this_plugin = $this->filename;
|
63 |
+
if ( $file == $this_plugin ) {
|
64 |
+
$settings_link = '<a href="' . $this->plugin_options_url() . '">' . __('Settings') . '</a>';
|
65 |
+
array_unshift( $links, $settings_link );
|
66 |
+
}
|
67 |
+
return $links;
|
68 |
+
}
|
69 |
+
|
70 |
+
function config_page() {
|
71 |
+
|
72 |
+
}
|
73 |
+
|
74 |
+
function config_page_scripts() {
|
75 |
+
if (isset($_GET['page']) && $_GET['page'] == $this->hook) {
|
76 |
+
wp_enqueue_script('postbox');
|
77 |
+
wp_enqueue_script('dashboard');
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Create a Checkbox input field
|
83 |
+
*/
|
84 |
+
function checkbox($id, $label) {
|
85 |
+
$options = get_option($this->optionname);
|
86 |
+
return '<input type="checkbox" id="'.$id.'" name="'.$id.'"'. checked($options[$id],true,false).'/> <label for="'.$id.'">'.$label.'</label><br/>';
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Create a Text input field
|
91 |
+
*/
|
92 |
+
function textinput($id, $label) {
|
93 |
+
$options = get_option($this->optionname);
|
94 |
+
return '<label for="'.$id.'">'.$label.':</label><br/><input size="45" type="text" id="'.$id.'" name="'.$id.'" value="'.$options[$id].'"/><br/><br/>';
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Create a potbox widget
|
99 |
+
*/
|
100 |
+
function postbox($id, $title, $content) {
|
101 |
+
?>
|
102 |
+
<div id="<?php echo $id; ?>" class="postbox">
|
103 |
+
<div class="handlediv" title="Click to toggle"><br /></div>
|
104 |
+
<h3 class="hndle"><span><?php echo $title; ?></span></h3>
|
105 |
+
<div class="inside">
|
106 |
+
<?php echo $content; ?>
|
107 |
+
</div>
|
108 |
+
</div>
|
109 |
+
<?php
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Create a form table from an array of rows
|
115 |
+
*/
|
116 |
+
function form_table($rows) {
|
117 |
+
$content = '<table class="form-table">';
|
118 |
+
foreach ($rows as $row) {
|
119 |
+
$content .= '<tr><th valign="top" scrope="row">';
|
120 |
+
if (isset($row['id']) && $row['id'] != '')
|
121 |
+
$content .= '<label for="'.$row['id'].'">'.$row['label'].':</label>';
|
122 |
+
else
|
123 |
+
$content .= $row['label'];
|
124 |
+
if (isset($row['desc']) && $row['desc'] != '')
|
125 |
+
$content .= '<br/><small>'.$row['desc'].'</small>';
|
126 |
+
$content .= '</th><td valign="top">';
|
127 |
+
$content .= $row['content'];
|
128 |
+
$content .= '</td></tr>';
|
129 |
+
}
|
130 |
+
$content .= '</table>';
|
131 |
+
return $content;
|
132 |
+
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Create a "plugin like" box.
|
136 |
+
*/
|
137 |
+
function plugin_like() {
|
138 |
+
$content = '<p>'.__('Why not do any or all of the following:','clickyplugin').'</p>';
|
139 |
+
$content .= '<ul>';
|
140 |
+
$content .= '<li><a href="'.$this->homepage.'">'.__('Link to it so other folks can find out about it.','clickyplugin').'</a></li>';
|
141 |
+
$content .= '<li><a href="http://wordpress.org/extend/plugins/'.$this->hook.'/">'.__('Give it a good rating on WordPress.org.','clickyplugin').'</a></li>';
|
142 |
+
$content .= '<li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2017947">'.__('Donate a token of your appreciation.','clickyplugin').'</a></li>';
|
143 |
+
$content .= '</ul>';
|
144 |
+
$this->postbox($this->hook.'like', 'Like this plugin?', $content);
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Info box with link to the support forums.
|
149 |
+
*/
|
150 |
+
function plugin_support() {
|
151 |
+
$content = '<p>'.__('If you have any problems with this plugin or good ideas for improvements or new features, please talk about them in the','clickyplugin').' <a href="http://wordpress.org/tags/'.$this->hook.'">'.__("Support forums",'clickyplugin').'</a>.</p>';
|
152 |
+
$this->postbox($this->hook.'support', 'Need support?', $content);
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Box with latest news from getclicky.com
|
157 |
+
*/
|
158 |
+
function news() {
|
159 |
+
require_once(ABSPATH.WPINC.'/rss.php');
|
160 |
+
if ( $rss = fetch_rss( $this->feed ) ) {
|
161 |
+
$content = '<ul>';
|
162 |
+
$rss->items = array_slice( $rss->items, 0, 3 );
|
163 |
+
foreach ( (array) $rss->items as $item ) {
|
164 |
+
$content .= '<li>';
|
165 |
+
$content .= '<a class="rsswidget" href="'.clean_url( $item['link'], $protocolls=null, 'display' ).'">'. htmlentities($item['title']) .'</a> ';
|
166 |
+
$content .= '</li>';
|
167 |
+
}
|
168 |
+
$content .= '<li class="rss"><a href="'.$this->feed.'">Subscribe</a></li>';
|
169 |
+
$this->postbox('clickylatest', 'Latest news from Clicky', $content);
|
170 |
+
} else {
|
171 |
+
$this->postbox('clickylatest', 'Latest news from Clicky', 'Nothing to say...');
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
function text_limit( $text, $limit, $finish = ' […]') {
|
176 |
+
if( strlen( $text ) > $limit ) {
|
177 |
+
$text = substr( $text, 0, $limit );
|
178 |
+
$text = substr( $text, 0, - ( strlen( strrchr( $text,' ') ) ) );
|
179 |
+
$text .= $finish;
|
180 |
+
}
|
181 |
+
return $text;
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
185 |
+
|
186 |
+
?>
|