Version Description
- Initial release.
Download this release
Release Info
Developer | ben.meredith@gmail.com |
Plugin | Better Click To Tweet |
Version | 0.1 |
Comparing to | |
See all releases |
Version 0.1
- assets/css/styles.css +54 -0
- assets/img/birdy.png +0 -0
- assets/img/birdy_button.png +0 -0
- assets/img/empty.gif +0 -0
- assets/js/bctt_clicktotweet_plugin.js +27 -0
- bctt_options.php +94 -0
- better-click-to-tweet.php +76 -0
- readme.txt +45 -0
assets/css/styles.css
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
.bctt-click-to-tweet {
|
3 |
+
display: block;
|
4 |
+
background-color: #fff;
|
5 |
+
position: relative;
|
6 |
+
border: 1px solid #dddddd;
|
7 |
+
-moz-border-radius: 4px;
|
8 |
+
border-radius: 4px;
|
9 |
+
padding: 15px 15px 15px 30px;
|
10 |
+
}
|
11 |
+
.bctt-click-to-tweet:after {
|
12 |
+
content: ".";
|
13 |
+
display: block;
|
14 |
+
clear: both;
|
15 |
+
visibility: hidden;
|
16 |
+
line-height: 0;
|
17 |
+
height: 0;
|
18 |
+
}
|
19 |
+
.bctt-ctt-text a {
|
20 |
+
padding: 15px 6px;
|
21 |
+
margin: 15px 0;
|
22 |
+
position: relative;
|
23 |
+
color: #000 !important;
|
24 |
+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
|
25 |
+
font-size: 1.5em;
|
26 |
+
line-height: 140%;
|
27 |
+
font-weight: 100;
|
28 |
+
text-decoration: none !important;
|
29 |
+
text-transform: none !important;
|
30 |
+
word-wrap:break-word;
|
31 |
+
}
|
32 |
+
.bctt-ctt-text a:hover {
|
33 |
+
text-decoration: none;
|
34 |
+
color: #999 !important;
|
35 |
+
}
|
36 |
+
a.bctt-ctt-btn {
|
37 |
+
margin: 0;
|
38 |
+
padding: 11px 24px 0 0;
|
39 |
+
position: relative;
|
40 |
+
display: block;
|
41 |
+
text-transform: uppercase;
|
42 |
+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
|
43 |
+
font-size: .7em;
|
44 |
+
font-weight: bold;
|
45 |
+
color: #999999 !important;
|
46 |
+
float: right;
|
47 |
+
text-decoration: none !important;
|
48 |
+
background: transparent url(../img/birdy.png) no-repeat right top 10px;
|
49 |
+
}
|
50 |
+
.bctt-ctt-btn:hover {
|
51 |
+
text-decoration: none;
|
52 |
+
color: #666666 !important;
|
53 |
+
background: transparent url(../img/birdy.png) no-repeat right top 8px;
|
54 |
+
}
|
assets/img/birdy.png
ADDED
Binary file
|
assets/img/birdy_button.png
ADDED
Binary file
|
assets/img/empty.gif
ADDED
Binary file
|
assets/js/bctt_clicktotweet_plugin.js
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function() {
|
2 |
+
tinymce.create('tinymce.plugins.bctt_clicktotweet', {
|
3 |
+
init: function(ed, url) {
|
4 |
+
ed.addButton('bctt_clicktotweet', {
|
5 |
+
title: 'Add Tweetable Text',
|
6 |
+
image: url.replace("/js", "") + '/img/birdy_button.png',
|
7 |
+
onclick: function() {
|
8 |
+
var m = prompt("Add your quote below for readers to tweet.", "Enter the text for readers to tweet");
|
9 |
+
if (m != null && m != 'undefined' && m != 'Enter your tweets' && m != '') ed.execCommand('mceInsertContent', false, '[bctt tweet="' + m + '"]');
|
10 |
+
}
|
11 |
+
});
|
12 |
+
},
|
13 |
+
createControl: function(n, cm) {
|
14 |
+
return null;
|
15 |
+
},
|
16 |
+
getInfo: function() {
|
17 |
+
return {
|
18 |
+
longname: "Click To Tweet by BenUNC",
|
19 |
+
author: 'Ben Meredith',
|
20 |
+
authorurl: 'http://benandjacq.com/',
|
21 |
+
infourl: 'http://benandjacq.com/better-click-to-tweet',
|
22 |
+
version: "1.0"
|
23 |
+
};
|
24 |
+
}
|
25 |
+
});
|
26 |
+
tinymce.PluginManager.add('bctt_clicktotweet', tinymce.plugins.bctt_clicktotweet);
|
27 |
+
})();
|
bctt_options.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
defined('ABSPATH') or die("No script kiddies please!");
|
3 |
+
|
4 |
+
|
5 |
+
// Cache bust tinymce
|
6 |
+
add_filter('tiny_mce_version', 'refresh_mce');
|
7 |
+
|
8 |
+
// Add Settings Link
|
9 |
+
add_action('admin_menu', 'bctt_admin_menu');
|
10 |
+
|
11 |
+
// Add settings link to plugins listing page
|
12 |
+
|
13 |
+
// Add button plugin to TinyMCE
|
14 |
+
add_action('init', 'bctt_tinymce_button');
|
15 |
+
|
16 |
+
function bctt_tinymce_button() {
|
17 |
+
if (!current_user_can('edit_posts') && !current_user_can('edit_pages')) {
|
18 |
+
return;
|
19 |
+
}
|
20 |
+
|
21 |
+
if (get_user_option('rich_editing') == 'true') {
|
22 |
+
add_filter('mce_external_plugins', 'bctt_tinymce_register_plugin');
|
23 |
+
add_filter('mce_buttons', 'bctt_tinymce_register_button');
|
24 |
+
}
|
25 |
+
}
|
26 |
+
function bctt_tinymce_register_button($buttons) {
|
27 |
+
array_push($buttons, "|", "bctt_clicktotweet");
|
28 |
+
return $buttons;
|
29 |
+
}
|
30 |
+
|
31 |
+
function bctt_tinymce_register_plugin($plugin_array) {
|
32 |
+
$plugin_array['bctt_clicktotweet'] = plugins_url( '/assets/js/bctt_clicktotweet_plugin.js', __FILE__);
|
33 |
+
return $plugin_array;
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
function bctt_admin_menu() {
|
38 |
+
add_action('admin_init', 'bctt_register_settings');
|
39 |
+
add_options_page('Better Click To Tweet Options', 'Better Click To Tweet', 'manage_options', 'better-click-to-tweet', 'bctt_settings_page');
|
40 |
+
}
|
41 |
+
|
42 |
+
function bctt_register_settings() {
|
43 |
+
register_setting('bctt_clicktotweet-options', 'bctt-twitter-handle', 'bctt_validate_settings');
|
44 |
+
}
|
45 |
+
|
46 |
+
function bctt_validate_settings($input) {
|
47 |
+
return str_replace('@', '', strip_tags(stripslashes($input)));
|
48 |
+
}
|
49 |
+
|
50 |
+
function bctt_settings_page() {
|
51 |
+
if ( !current_user_can( 'manage_options' ) ) {
|
52 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
53 |
+
} ?>
|
54 |
+
|
55 |
+
<div class="wrap">
|
56 |
+
|
57 |
+
<?php screen_icon(); ?>
|
58 |
+
<h2>Better Click To Tweet</h2>
|
59 |
+
|
60 |
+
<hr/>
|
61 |
+
|
62 |
+
<h2>Instructions</h2>
|
63 |
+
<p>
|
64 |
+
To add styled click-to-tweet quote boxes include the Better Click To Tweet shortcode in your post.</p>
|
65 |
+
<p>Here's how you format the shortcode: <pre>[bctt tweet="Meaningful, tweetable quote."]</pre></p>
|
66 |
+
<p>If you are using the visual editor, click the BCTT birdie in the toolbar to add a pre-formatted shortcode to your post.</p>
|
67 |
+
<p>Tweet length will be automatically shortened to 118 characters minus the length of your twitter name, to leave room for it and a link back to the post.
|
68 |
+
</p>
|
69 |
+
|
70 |
+
<h2>Settings</h2>
|
71 |
+
|
72 |
+
<p>Enter your Twitter handle to add "via @yourhandle" to your tweets. Do not include the @ symbol.</p>
|
73 |
+
<form method="post" action="options.php" style="display: inline-block;">
|
74 |
+
<?php settings_fields( 'bctt_clicktotweet-options' ); ?>
|
75 |
+
|
76 |
+
<table class="form-table">
|
77 |
+
<tr valign="top">
|
78 |
+
<th style="width: 200px;"><label>Your Twitter Handle</label></th>
|
79 |
+
<td><input type="text" name="bctt-twitter-handle" value="<?php echo get_option('bctt-twitter-handle'); ?>" /></td>
|
80 |
+
</tr>
|
81 |
+
<tr>
|
82 |
+
<td></td>
|
83 |
+
<td><?php submit_button(); ?></td>
|
84 |
+
</table>
|
85 |
+
</form>
|
86 |
+
|
87 |
+
<hr/>
|
88 |
+
<em>An open source plugin by <a href="http://benandjacq.com" target="_blank">Ben Meredith</a></em>
|
89 |
+
<p>Are you a developer? Help make it the (even) Better Click To Tweet plugin. Check out the plugin on Github.</p>
|
90 |
+
</div>
|
91 |
+
<?php
|
92 |
+
}
|
93 |
+
|
94 |
+
|
better-click-to-tweet.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Better Click To Tweet
|
4 |
+
Description: Add click to tweet boxes to your WordPress posts, easily. This is a new, fully renovated version of the late "Click to Tweet" plugin by Todaymade. I overhauled the plugin using the shortcode API, and (perhaps most importantly) removed the "powered by" link.
|
5 |
+
Version: 0.1
|
6 |
+
Author: Ben Meredith
|
7 |
+
Author URI: http://benandjacq.com
|
8 |
+
Plugin URI: http://benandjacq.com/better-click-to-tweet
|
9 |
+
*/
|
10 |
+
include 'bctt_options.php';
|
11 |
+
|
12 |
+
defined('ABSPATH') or die("No script kiddies please!");
|
13 |
+
|
14 |
+
function bctt_shorten($input, $length, $ellipsis = true, $strip_html = true) {
|
15 |
+
if ($strip_html) {
|
16 |
+
$input = strip_tags($input);
|
17 |
+
}
|
18 |
+
if (strlen($input) <= $length) {
|
19 |
+
return $input;
|
20 |
+
}
|
21 |
+
$last_space = strrpos(substr($input, 0, $length), ' ');
|
22 |
+
$trimmed_text = substr($input, 0, $last_space);
|
23 |
+
if ($ellipsis) {
|
24 |
+
$trimmed_text .= '…';
|
25 |
+
}
|
26 |
+
return $trimmed_text;
|
27 |
+
};
|
28 |
+
|
29 |
+
function bctt_shortcode($atts, $content) {
|
30 |
+
$handle = get_option('bctt-twitter-handle');
|
31 |
+
if (!empty($handle)) {
|
32 |
+
$handle_code = "&via=".$handle."&related=".$handle;
|
33 |
+
} else {
|
34 |
+
$handle_code = $handle;
|
35 |
+
}
|
36 |
+
extract(shortcode_atts(array(
|
37 |
+
'tweet' => '$content',
|
38 |
+
'handle' => '$handle_code'
|
39 |
+
), $atts));
|
40 |
+
$text = $tweet;
|
41 |
+
$short = bctt_shorten($text, (118 - strlen($handle_code)));
|
42 |
+
return "<div class='bctt-click-to-tweet'><span class='bctt-ctt-text'><a href='https://twitter.com/intent/tweet?text=".urlencode($short).$handle_code."&url=".get_permalink()."' target='_blank'>".$short."</a></span><a href='https://twitter.com/intent/tweet?text=".urlencode($short).$handle_code."&url=".get_permalink()."' target='_blank' class='bctt-ctt-btn'>Click To Tweet</a></div>";
|
43 |
+
}
|
44 |
+
|
45 |
+
add_shortcode('bctt', 'bctt_shortcode');
|
46 |
+
|
47 |
+
/*
|
48 |
+
* Load the stylesheet to style the output
|
49 |
+
*/
|
50 |
+
|
51 |
+
function bctt_scripts () {
|
52 |
+
wp_register_style( 'bcct_style', plugins_url( 'assets/css/styles.css', __FILE__ ), false, '1.0', 'all' );
|
53 |
+
wp_enqueue_style('bcct_style');
|
54 |
+
};
|
55 |
+
|
56 |
+
add_action('wp_enqueue_scripts', 'bctt_scripts');
|
57 |
+
|
58 |
+
/*
|
59 |
+
* Delete options on uninstall
|
60 |
+
*/
|
61 |
+
|
62 |
+
function bctt_on_uninstall(){
|
63 |
+
|
64 |
+
delete_option( 'bctt-twitter-handle' );
|
65 |
+
|
66 |
+
};
|
67 |
+
|
68 |
+
register_uninstall_hook( __FILE__, 'bctt_on_uninstall' );
|
69 |
+
|
70 |
+
function bctt_options_link($links) {
|
71 |
+
$settings_link = '<a href="options-general.php?page=better-click-to-tweet">Settings</a>';
|
72 |
+
array_unshift( $links, $settings_link );
|
73 |
+
return $links;
|
74 |
+
}
|
75 |
+
$bcttlink = plugin_basename(__FILE__);
|
76 |
+
add_filter("plugin_action_links_$bcttlink", 'bctt_options_link' );
|
readme.txt
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Better Click To Tweet ===
|
2 |
+
Contributors: ben.meredith@gmail.com
|
3 |
+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HDSGWRJYFQQNJ
|
4 |
+
Tags: click to tweet, twitter, tweet, twitter plugin, Twitter boxes, share, social media, auto post
|
5 |
+
Requires at least: 3.8
|
6 |
+
Tested up to: 4.1
|
7 |
+
Stable tag: 0.1
|
8 |
+
License: GPLv2 or later
|
9 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
+
|
11 |
+
This plugin allows you to create beautiful Click To Tweet boxes anywhere in your blog post.
|
12 |
+
|
13 |
+
== Description ==
|
14 |
+
|
15 |
+
This plugin allows you to easily create tweetable content for your readers. Using a simple shortcode, your selected text is highlighted and made tweetable.
|
16 |
+
|
17 |
+
|
18 |
+
== Installation ==
|
19 |
+
|
20 |
+
**To install the plugin manually in WordPress:**
|
21 |
+
|
22 |
+
1. Login as Admin on your WordPress blog.
|
23 |
+
2. Click on the "Plugins" tab in the left menu.
|
24 |
+
3. Select "Add New."
|
25 |
+
4. Click on "Upload" at the top of the page.
|
26 |
+
5. Select the 'better-click-to-tweet.zip' on your computer, and upload. Activate the plugin once it is uploaded.
|
27 |
+
|
28 |
+
**To install the plugin manually with FTP:**
|
29 |
+
|
30 |
+
1. Unzip the 'better-click-to-tweet.zip' file. Upload that folder to the '/wp-content/plugins/' directory.
|
31 |
+
2. Login to your WordPress dashboard and activate the plugin through the "Plugins" tab in the left menu.
|
32 |
+
|
33 |
+
== Frequently Asked Questions ==
|
34 |
+
|
35 |
+
|
36 |
+
= How Does Click To Tweet Work? =
|
37 |
+
|
38 |
+
Click To Tweet is a simple plugin that enables you to create beautiful Click To Tweet boxes in your blog posts. By either using simple code or a one-click in your editor, you can generate a custom tweet-able message for your blog readers.
|
39 |
+
|
40 |
+
== Screenshots ==
|
41 |
+
|
42 |
+
== Changelog ==
|
43 |
+
|
44 |
+
= 0.1 =
|
45 |
+
* Initial release.
|