Better Click To Tweet - Version 4.4.1

Version Description

  • Fixed CSS issue with spacing in the default theme.
Download this release

Release Info

Developer ben.meredith@gmail.com
Plugin Icon 128x128 Better Click To Tweet
Version 4.4.1
Comparing to
See all releases

Code changes from version 4.4 to 4.4.1

assets/css/bcttstyle.css CHANGED
@@ -1,53 +1,58 @@
1
  .bctt-click-to-tweet {
2
- display: block;
3
- background-color: #FFF;
4
- position: relative;
5
- border-top: 2px solid black;
6
- border-bottom: 2px solid black;
7
- padding: 19px 12px 19px 18px;
8
- margin-bottom: 1em;
9
  }
 
10
  .bctt-click-to-tweet:after {
11
- content: ".";
12
- display: block;
13
- clear: both;
14
- visibility: hidden;
15
- line-height: 0;
16
- height: 0;
17
  }
 
18
  .bctt-ctt-text a {
19
- padding: 15px 0px;
20
- margin: 15px 0;
21
- position: relative;
22
- color: #000 !important;
23
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
24
- font-size: 1.5em;
25
- line-height: 140%;
26
- font-weight: 100;
27
- text-decoration: none !important;
28
- text-transform: none !important;
29
- word-wrap:break-word;
30
- border-bottom: none !important;
31
  }
 
32
  .bctt-ctt-text a:hover {
33
- text-decoration: none;
34
- color: #999 !important;
35
  }
 
36
  a.bctt-ctt-btn {
37
- border-bottom: none !important;
38
- margin: 0;
39
- padding: 18px 0 0 0;
40
- position: relative;
41
- display: block;
42
- text-transform: uppercase;
43
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
44
- font-size: .7em;
45
- font-weight: bold;
46
- color: #999999 !important;
47
- float: right;
48
- text-decoration: none !important;
49
  }
 
50
  .bctt-ctt-btn:hover {
51
- text-decoration: none;
52
- color: #666666 !important;
53
  }
1
  .bctt-click-to-tweet {
2
+ display: block;
3
+ background-color: #FFF;
4
+ position: relative;
5
+ border-top: 2px solid black;
6
+ border-bottom: 2px solid black;
7
+ padding: 19px 12px 19px 18px;
8
+ margin-bottom: 1em;
9
  }
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
+
20
  .bctt-ctt-text a {
21
+ padding: 15px 0px;
22
+ margin: 15px 0;
23
+ position: relative;
24
+ color: #000 !important;
25
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
26
+ font-size: 1.5em;
27
+ line-height: 140%;
28
+ font-weight: 100;
29
+ text-decoration: none !important;
30
+ text-transform: none !important;
31
+ word-wrap: break-word;
32
+ border-bottom: none !important;
33
  }
34
+
35
  .bctt-ctt-text a:hover {
36
+ text-decoration: none;
37
+ color: #999 !important;
38
  }
39
+
40
  a.bctt-ctt-btn {
41
+ border-bottom: none !important;
42
+ margin: 0;
43
+ padding: 18px 0 0 0;
44
+ position: relative;
45
+ display: block;
46
+ text-transform: uppercase;
47
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
48
+ font-size: .7em;
49
+ font-weight: bold;
50
+ color: #999999 !important;
51
+ float: right;
52
+ text-decoration: none !important;
53
  }
54
+
55
  .bctt-ctt-btn:hover {
56
+ text-decoration: none;
57
+ color: #666666 !important;
58
  }
assets/css/styles.css CHANGED
@@ -1,57 +1,62 @@
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
- margin-bottom:1em;
11
  }
 
12
  .bctt-click-to-tweet:after {
13
- content: ".";
14
- display: block;
15
- clear: both;
16
- visibility: hidden;
17
- line-height: 0;
18
- height: 0;
19
  }
 
20
  .bctt-ctt-text a {
21
- padding: 15px 6px;
22
- margin: 15px 0;
23
- position: relative;
24
- color: #000 !important;
25
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
26
- font-size: 1.5em;
27
- line-height: 140%;
28
- font-weight: 100;
29
- text-decoration: none !important;
30
- text-transform: none !important;
31
- word-wrap:break-word;
32
- border-bottom: none !important;
33
  }
 
34
  .bctt-ctt-text a:hover {
35
- text-decoration: none;
36
- color: #999 !important;
37
  }
 
38
  a.bctt-ctt-btn {
39
- border-bottom: none !important;
40
- margin: 0;
41
- padding: 11px 24px 0 0;
42
- position: relative;
43
- display: block;
44
- text-transform: uppercase;
45
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
46
- font-size: .7em;
47
- font-weight: bold;
48
- color: #999999 !important;
49
- float: right;
50
- text-decoration: none !important;
51
- background: transparent url(../img/birdy.png) no-repeat right top 10px;
52
  }
 
53
  .bctt-ctt-btn:hover {
54
- text-decoration: none;
55
- color: #666666 !important;
56
- background: transparent url(../img/birdy.png) no-repeat right top 8px;
57
  }
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
+ margin-bottom: 1em;
11
  }
12
+
13
  .bctt-click-to-tweet:after {
14
+ content: ".";
15
+ display: block;
16
+ clear: both;
17
+ visibility: hidden;
18
+ line-height: 0;
19
+ height: 0;
20
  }
21
+
22
  .bctt-ctt-text a {
23
+ padding: 15px 0;
24
+ margin: 15px 0;
25
+ position: relative;
26
+ color: #000 !important;
27
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
28
+ font-size: 1.5em;
29
+ line-height: 140%;
30
+ font-weight: 100;
31
+ text-decoration: none !important;
32
+ text-transform: none !important;
33
+ word-wrap: break-word;
34
+ border-bottom: none !important;
35
  }
36
+
37
  .bctt-ctt-text a:hover {
38
+ text-decoration: none;
39
+ color: #999 !important;
40
  }
41
+
42
  a.bctt-ctt-btn {
43
+ border-bottom: none !important;
44
+ margin: 0;
45
+ padding: 11px 24px 0 0;
46
+ position: relative;
47
+ display: block;
48
+ text-transform: uppercase;
49
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif !important;
50
+ font-size: .7em;
51
+ font-weight: bold;
52
+ color: #999999 !important;
53
+ float: right;
54
+ text-decoration: none !important;
55
+ background: transparent url(../img/birdy.png) no-repeat right top 10px;
56
  }
57
+
58
  .bctt-ctt-btn:hover {
59
+ text-decoration: none;
60
+ color: #666666 !important;
61
+ background: transparent url(../img/birdy.png) no-repeat right top 8px;
62
  }
assets/js/bctt_clicktotweet_plugin.js CHANGED
@@ -1,20 +1,20 @@
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 width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
9
- W = W - 10;
10
- tb_show( 'Better Click To Tweet Shortcode Generator', '#TB_inline?width=' + W + '&height=auto' + '&inlineId=bctt-form' );
11
  }
12
  });
13
  },
14
- createControl: function(n, cm) {
15
  return null;
16
  },
17
- getInfo: function() {
18
  return {
19
  longname: "Click To Tweet by BenUNC",
20
  author: 'Ben Meredith',
@@ -27,9 +27,9 @@
27
  tinymce.PluginManager.add('bctt_clicktotweet', tinymce.plugins.bctt_clicktotweet);
28
 
29
 
30
- jQuery(function(){
31
- // creates a form to be displayed everytime the button is clicked
32
- var form = jQuery('<div id="bctt-form"><table id="bctt-table" class="form-table">\
33
  <tr>\
34
  <th><label for="bctt-tweet">Tweetable Quote</label></th>\
35
  <td><p><textarea cols="70" id="bctt-tweet" name="tweet" /></p>\
@@ -46,35 +46,35 @@ jQuery(function(){
46
  <input type="button" id="bctt-submit" class="button-primary" value="Insert Tweet" name="submit" />\
47
  </p>\
48
  </div>');
49
-
50
- var table = form.find('table');
51
- form.appendTo('body').hide();
52
-
53
- // handles the click event of the submit button
54
- form.find('#bctt-submit').click(function(){
55
- // defines the options and their default values
56
-
57
- var shortcode = '[bctt';
58
-
59
- var value = table.find('#bctt-tweet').val();
60
-
61
- if ( value != '' ) {
62
- shortcode += ' tweet="' + value + '"';
63
- }
64
-
65
- var viaChoice = table.find('input[name="viamark"]:checked').val();
66
-
67
- if ( viaChoice == "no" ) {
68
- shortcode += ' via="no"';
69
- }
70
-
71
- shortcode += ']';
72
-
73
- // inserts the shortcode into the active editor
74
- tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
75
-
76
- // closes Thickbox
77
- tb_remove();
78
- });
79
- });
80
  })();
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 width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
9
+ W = W - 10;
10
+ tb_show('Better Click To Tweet Shortcode Generator', '#TB_inline?width=' + W + '&height=auto' + '&inlineId=bctt-form');
11
  }
12
  });
13
  },
14
+ createControl: function (n, cm) {
15
  return null;
16
  },
17
+ getInfo: function () {
18
  return {
19
  longname: "Click To Tweet by BenUNC",
20
  author: 'Ben Meredith',
27
  tinymce.PluginManager.add('bctt_clicktotweet', tinymce.plugins.bctt_clicktotweet);
28
 
29
 
30
+ jQuery(function () {
31
+ // creates a form to be displayed everytime the button is clicked
32
+ var form = jQuery('<div id="bctt-form"><table id="bctt-table" class="form-table">\
33
  <tr>\
34
  <th><label for="bctt-tweet">Tweetable Quote</label></th>\
35
  <td><p><textarea cols="70" id="bctt-tweet" name="tweet" /></p>\
46
  <input type="button" id="bctt-submit" class="button-primary" value="Insert Tweet" name="submit" />\
47
  </p>\
48
  </div>');
49
+
50
+ var table = form.find('table');
51
+ form.appendTo('body').hide();
52
+
53
+ // handles the click event of the submit button
54
+ form.find('#bctt-submit').click(function () {
55
+ // defines the options and their default values
56
+
57
+ var shortcode = '[bctt';
58
+
59
+ var value = table.find('#bctt-tweet').val();
60
+
61
+ if (value != '') {
62
+ shortcode += ' tweet="' + value + '"';
63
+ }
64
+
65
+ var viaChoice = table.find('input[name="viamark"]:checked').val();
66
+
67
+ if (viaChoice == "no") {
68
+ shortcode += ' via="no"';
69
+ }
70
+
71
+ shortcode += ']';
72
+
73
+ // inserts the shortcode into the active editor
74
+ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
75
+
76
+ // closes Thickbox
77
+ tb_remove();
78
+ });
79
+ });
80
  })();
assets/tinymce/bctt-tinymce.php CHANGED
@@ -1,102 +1,106 @@
1
  <?php
2
  /**
3
  * This file for use with the Better Click To Tweet Plugin. http://wordpress.org/plugins/better-click-to-tweet
4
- * Huge thanks to Andrew Norcross @norcross for pretty much every bit of code you see here:
5
  *
6
  * @since 4.0
7
  * @author Andrew Norcross
8
  */
9
-
10
  defined( 'ABSPATH' ) or die( "No soup for you. You leave now." );
11
 
12
  if ( ! class_exists( 'BCTT_TinyMCE' ) ) {
13
 
14
  // Start up the engine
15
- class BCTT_TinyMCE {
16
-
17
- /**
18
- * This is our constructor
19
- *
20
- * @return BCTT_TinyMCE
21
- */
22
- public function __construct() {
23
- add_action( 'admin_init', array( $this, 'tinymce_loader' ) );
24
- add_action( 'admin_enqueue_scripts', array( $this, 'tinymce_css' ), 10 );
25
- }
26
-
27
- /**
28
- * load our CSS file
29
- * @return [type] [description]
30
- */
31
- public function tinymce_css() {
32
 
33
- wp_enqueue_style( 'bctt-admin', plugins_url( '/css/bctt-admin.css', __FILE__ ), array(), null, 'all' );
34
- }
 
 
 
35
 
36
- /**
37
- * load the TinyMCE button
38
- *
39
- * @return [type] [description]
40
- */
41
- public function tinymce_loader() {
42
- add_filter( 'mce_external_languages', array( __class__, 'bctt_tinymce_languages' ) );
43
- add_filter( 'mce_external_plugins', array( __class__, 'bctt_tinymce_core' ) );
44
- add_filter( 'mce_buttons', array( __class__, 'bctt_tinymce_buttons' ) );
45
- }
46
- /**
47
- * loader for the language strings
48
- *
49
- */
50
- public static function bctt_tinymce_languages( $bctt_locales) {
51
- $bctt_locales[ 'bctt' ] = plugin_dir_path( __FILE__ ) . '/languages/bctt-mce-locale.php';
52
- return $bctt_locales;
53
- }
54
-
55
- /**
56
- * loader for the required JS
57
- *
58
- * @param [type] $plugin_array [description]
59
- * @return [type] [description]
60
- */
61
- public static function bctt_tinymce_core( $plugin_array ) {
62
-
63
- // add our JS file
64
- $plugin_array['bctt'] = plugins_url( '/js/tinymce-bctt.js', __FILE__ );
65
-
66
- // return the array
67
- return $plugin_array;
68
- }
69
 
70
- /**
71
- * Add the button key for event link via JS
72
- *
73
- * @param [type] $buttons [description]
74
- * @return [type] [description]
75
- */
76
- public static function bctt_tinymce_buttons( $buttons ) {
 
 
 
77
 
78
- // set the 'kitchen sink' button as a variable for later
79
- $sink = array_search( 'wp_adv', $buttons );
 
 
 
 
80
 
81
- // remove the sink
82
- if ( ! empty( $sink ) ) {
83
- unset( $buttons[$sink] );
84
  }
85
 
86
- // push our buttons to the end
87
- array_push( $buttons, 'bctt' );
 
 
 
 
 
 
88
 
89
- // now add back the sink
90
- if ( ! empty( $sink ) ) {
91
- $buttons[] = 'wp_adv';
 
 
92
  }
93
 
94
- // send them back
95
- return $buttons;
96
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
  // end class
99
- }
100
 
101
  // end exists check
102
  }
1
  <?php
2
  /**
3
  * This file for use with the Better Click To Tweet Plugin. http://wordpress.org/plugins/better-click-to-tweet
4
+ * Huge thanks to Andrew Norcross @norcross for pretty much every bit of code you see here:
5
  *
6
  * @since 4.0
7
  * @author Andrew Norcross
8
  */
9
+
10
  defined( 'ABSPATH' ) or die( "No soup for you. You leave now." );
11
 
12
  if ( ! class_exists( 'BCTT_TinyMCE' ) ) {
13
 
14
  // Start up the engine
15
+ class BCTT_TinyMCE {
16
+
17
+ /**
18
+ * This is our constructor
19
+ *
20
+ * @return BCTT_TinyMCE
21
+ */
22
+ public function __construct() {
23
+ add_action( 'admin_init', array( $this, 'tinymce_loader' ) );
24
+ add_action( 'admin_enqueue_scripts', array( $this, 'tinymce_css' ), 10 );
25
+ }
 
 
 
 
 
 
26
 
27
+ /**
28
+ * load our CSS file
29
+ * @return [type] [description]
30
+ */
31
+ public function tinymce_css() {
32
 
33
+ wp_enqueue_style( 'bctt-admin', plugins_url( '/css/bctt-admin.css', __FILE__ ), array(), null, 'all' );
34
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ /**
37
+ * load the TinyMCE button
38
+ *
39
+ * @return [type] [description]
40
+ */
41
+ public function tinymce_loader() {
42
+ add_filter( 'mce_external_languages', array( __class__, 'bctt_tinymce_languages' ) );
43
+ add_filter( 'mce_external_plugins', array( __class__, 'bctt_tinymce_core' ) );
44
+ add_filter( 'mce_buttons', array( __class__, 'bctt_tinymce_buttons' ) );
45
+ }
46
 
47
+ /**
48
+ * loader for the language strings
49
+ *
50
+ */
51
+ public static function bctt_tinymce_languages( $bctt_locales ) {
52
+ $bctt_locales['bctt'] = plugin_dir_path( __FILE__ ) . '/languages/bctt-mce-locale.php';
53
 
54
+ return $bctt_locales;
 
 
55
  }
56
 
57
+ /**
58
+ * loader for the required JS
59
+ *
60
+ * @param [type] $plugin_array [description]
61
+ *
62
+ * @return [type] [description]
63
+ */
64
+ public static function bctt_tinymce_core( $plugin_array ) {
65
 
66
+ // add our JS file
67
+ $plugin_array['bctt'] = plugins_url( '/js/tinymce-bctt.js', __FILE__ );
68
+
69
+ // return the array
70
+ return $plugin_array;
71
  }
72
 
73
+ /**
74
+ * Add the button key for event link via JS
75
+ *
76
+ * @param [type] $buttons [description]
77
+ *
78
+ * @return [type] [description]
79
+ */
80
+ public static function bctt_tinymce_buttons( $buttons ) {
81
+
82
+ // set the 'kitchen sink' button as a variable for later
83
+ $sink = array_search( 'wp_adv', $buttons );
84
+
85
+ // remove the sink
86
+ if ( ! empty( $sink ) ) {
87
+ unset( $buttons[ $sink ] );
88
+ }
89
+
90
+ // push our buttons to the end
91
+ array_push( $buttons, 'bctt' );
92
+
93
+ // now add back the sink
94
+ if ( ! empty( $sink ) ) {
95
+ $buttons[] = 'wp_adv';
96
+ }
97
+
98
+ // send them back
99
+ return $buttons;
100
+ }
101
 
102
  // end class
103
+ }
104
 
105
  // end exists check
106
  }
assets/tinymce/css/bctt-admin.css CHANGED
@@ -1,18 +1,18 @@
1
  .mce-i-bctt-tweet {
2
- font-family: "dashicons";
3
  }
4
 
5
  .mce-i-bctt-tweet:before {
6
- display: inline-block;
7
- -webkit-font-smoothing: antialiased;
8
- text-align: center;
9
- font-weight: 400;
10
- font-size: 20px;
11
- line-height: 1;
12
- font-family: "dashicons";
13
- content: "\f301";
14
- color: #4099ff;
15
- speak: none;
16
- vertical-align: top;
17
- position: relative;
18
  }
1
  .mce-i-bctt-tweet {
2
+ font-family: "dashicons";
3
  }
4
 
5
  .mce-i-bctt-tweet:before {
6
+ display: inline-block;
7
+ -webkit-font-smoothing: antialiased;
8
+ text-align: center;
9
+ font-weight: 400;
10
+ font-size: 20px;
11
+ line-height: 1;
12
+ font-family: "dashicons";
13
+ content: "\f301";
14
+ color: #4099ff;
15
+ speak: none;
16
+ vertical-align: top;
17
+ position: relative;
18
  }
assets/tinymce/languages/bctt-mce-locale.php CHANGED
@@ -1,17 +1,17 @@
1
  <?php
2
  /**
3
- * This file dynamically creates MCE locales, based on .po/.mo files loaded in the plugin's translation folder.
4
- * It interfaces with the TinyMCE API using the tinyMCE.addI18n() function,
5
- * which adds a language pack to TinyMCE
6
- *
7
- * @var string $strings a JavaScript snippet to add another language pack to TinyMCE
8
- * @var string $mce_locale an ISO 639-1 formated string of the current language e.g. en, de...
9
- * @deprecated wp_tiny_mce() at wp-admin/includes/post.php (for versions prior WP 3.3)
10
- * @see _WP_Editors::editor_settings in wp-includes/class-wp-editor.php
11
- */
12
  $strings =
13
  'tinyMCE.addI18n(
14
- "' . $mce_locale .'.bctt",
15
  {
16
  toolTip : "' . esc_js( _x( 'Better Click To Tweet Shortcode Generator', 'Text that shows on mouseover for visual editor button', 'better-click-to-tweet' ) ) . '",
17
  windowTitle : "' . esc_js( _x( 'Better Click To Tweet Shortcode Generator', 'Text for title of the popup box when creating tweetable quote in the visual editor', 'better-click-to-tweet' ) ) . '",
1
  <?php
2
  /**
3
+ * This file dynamically creates MCE locales, based on .po/.mo files loaded in the plugin's translation folder.
4
+ * It interfaces with the TinyMCE API using the tinyMCE.addI18n() function,
5
+ * which adds a language pack to TinyMCE
6
+ *
7
+ * @var string $strings a JavaScript snippet to add another language pack to TinyMCE
8
+ * @var string $mce_locale an ISO 639-1 formated string of the current language e.g. en, de...
9
+ * @deprecated wp_tiny_mce() at wp-admin/includes/post.php (for versions prior WP 3.3)
10
+ * @see _WP_Editors::editor_settings in wp-includes/class-wp-editor.php
11
+ */
12
  $strings =
13
  'tinyMCE.addI18n(
14
+ "' . $mce_locale . '.bctt",
15
  {
16
  toolTip : "' . esc_js( _x( 'Better Click To Tweet Shortcode Generator', 'Text that shows on mouseover for visual editor button', 'better-click-to-tweet' ) ) . '",
17
  windowTitle : "' . esc_js( _x( 'Better Click To Tweet Shortcode Generator', 'Text for title of the popup box when creating tweetable quote in the visual editor', 'better-click-to-tweet' ) ) . '",
bctt-i18n.php CHANGED
@@ -3,5 +3,5 @@
3
  add_action( 'plugins_loaded', 'bctt_load_textdomain' );
4
 
5
  function bctt_load_textdomain() {
6
- load_plugin_textdomain( 'better-click-to-tweet', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
7
  }
3
  add_action( 'plugins_loaded', 'bctt_load_textdomain' );
4
 
5
  function bctt_load_textdomain() {
6
+ load_plugin_textdomain( 'better-click-to-tweet', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
7
  }
bctt_options.php CHANGED
@@ -1,126 +1,173 @@
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 button to visual editor
9
- include dirname(__FILE__).'/assets/tinymce/bctt-tinymce.php';
10
 
11
  // Add Settings Link
12
- add_action('admin_menu', 'bctt_admin_menu');
13
-
14
-
15
 
16
 
17
  function bctt_admin_menu() {
18
- add_action('admin_init', 'bctt_register_settings', 100, 1 );
19
- add_options_page('Better Click To Tweet Options', 'Better Click To Tweet', 'manage_options', 'better-click-to-tweet', 'bctt_settings_page');
20
- }
21
 
22
  function bctt_register_settings() {
23
- register_setting( 'bctt_clicktotweet-options', 'bctt-twitter-handle', 'bctt_validate_settings');
24
- register_setting( 'bctt_clicktotweet-options', 'bctt-short-url', 'bctt_validate_checkbox' );
25
- }
26
-
27
- function bctt_validate_settings($input) {
28
- return str_replace('@', '', strip_tags(stripslashes($input)));
29
- }
30
-
31
- function bctt_validate_checkbox( $input) {
32
- if ( ! isset( $input ) || $input != '1' )
33
- return 0;
34
- else
35
- return 1;
36
- }
 
37
 
38
  function bctt_settings_page() {
39
- if ( !current_user_can( 'manage_options' ) ) {
40
- wp_die( __( 'You do not have sufficient permissions to access this page.', 'better-click-to-tweet' ) );
41
- } ?>
42
-
43
- <div class="wrap">
44
-
45
- <h2><?php /* translators: Treat "Better Click To Tweet" as a brand name, don't translate it */ _e('Better Click To Tweet — a plugin by Ben Meredith', 'better-click-to-tweet');?></h2>
46
-
47
- <hr/>
48
- <div id="bctt_admin" class="metabox-holder has-right-sidebar">
49
- <div class="inner-sidebar">
50
- <div id="normal-sortables" class="meta-box-sortables ui-sortable">
51
- <div class="postbox">
52
- <div class="inside">
53
- <h3 class="hndle ui-sortable-handle"><?php _e('About the Author', 'better-click-to-tweet');?> </h3>
54
- <div id="bctt_signup">
55
- <form action="//benandjacq.us1.list-manage.com/subscribe/post?u=8f88921110b81f81744101f4d&amp;id=bd909b5f89" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
56
- <div id="mc_embed_signup_scroll">
57
- <p> <?php echo sprintf( __('This plugin is developed by <a href="%s">Ben Meredith</a>. I am a freelance developer specializing in <a href="%s">outrunning and outsmarting hackers</a>.', 'better-click-to-tweet'), esc_url('http://benandjacq.com'), esc_url('http://benandjacq.com/wordpress-maintenance-plans') );?></p>
58
- <h4><?php _e('Sign up to receive my FREE web strategy guide', 'better-click-to-tweet'); ?></h4>
59
- <p><input type="email" value="" name="EMAIL" class="widefat" id="mce-EMAIL" placeholder="<?php _ex('Your Email Address', 'placeholder text for input field', 'better-click-to-tweet');?>">
60
- <small><?php _e('No Spam. One-click unsubscribe in every message', 'better-click-to-tweet'); ?></small></p>
61
- <div style="position: absolute; left: -5000px;"><input type="text" name="b_8f88921110b81f81744101f4d_bd909b5f89" tabindex="-1" value="">
62
- </div>
63
- <p class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button-secondary"></p>
64
-
65
- </div>
66
- </form>
 
 
 
 
 
 
 
 
 
67
  </div>
68
- </div>
69
- </div>
70
- </div>
71
- <div class="meta-box-sortables">
72
- <div class="postbox">
73
- <div class="inside">
74
- <p><?php $url2 = 'https://github.com/Benunc/better-click-to-tweet'; $link2 = sprintf( __( 'Are you a developer? I would love your help making this plugin better. Check out the <a href=%s>plugin on Github.</a>' , 'better-click-to-tweet'), esc_url($url2 ) ); echo $link2; ?></p>
75
- <p><?php $url3 = 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HDSGWRJYFQQNJ'; $link3 = sprintf( __( 'The best way you can support this and other plugins is to <a href=%s>donate</a>', 'better-click-to-tweet' ), esc_url($url3) ); echo $link3; ?></a>. <?php $url4 = 'https://wordpress.org/support/view/plugin-reviews/better-click-to-tweet'; $link4 = sprintf( __( 'The second best way is to <a href=%s>leave an honest review.</a>', 'better-click-to-tweet'), esc_url($url4) ); echo $link4; ?></p>
76
- <p><?php _e( 'Did this plugin save you enough time to be worth some money?', 'better-click-to-tweet'); ?></p>
77
- <p><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HDSGWRJYFQQNJ" target="_blank"><?php _e( 'Click here to buy me a Coke to say thanks.', 'better-click-to-tweet' ); ?></a></p>
78
- </div>
79
  </div>
80
  </div>
81
  </div>
82
- <div id="post-body" class="has-sidebar">
83
- <div id="post-body-content" class="has-sidebar-content">
84
- <div id="normal-sortables" class="meta-box-sortables">
85
- <div class="postbox">
86
- <div class="inside">
87
- <h2 class="hndle"><?php _e( 'Instructions', 'better-click-to-tweet'); ?></h2>
88
- <p><?php /* translators: Treat "Better Click To Tweet" as a brand name, don't translate it */ _e('To add styled click-to-tweet quote boxes include the Better Click To Tweet shortcode in your post.', 'better-click-to-tweet' ); ?></p>
89
- <p><?php _e( 'Here\'s how you format the shortcode:', 'better-click-to-tweet' ); ?><pre>[bctt tweet="<?php /* translators: This text shows up as a sample tweet in the instructions for how to use the plugin. */ _e('Meaningful, tweetable quote.', 'better-click-to-tweet' ); ?>"]</pre></p>
90
- <p><?php /* translators: Also, treat "BCTT" as a brand name, don't translate it */ _e( 'If you are using the visual editor, click the BCTT birdie in the toolbar to add a pre-formatted shortcode to your post.', 'better-click-to-tweet' ); ?></p>
91
- <p><?php _e( 'Tweet length is automatically shortened to 117 characters minus the length of your twitter name, to leave room for it and a link back to the post.', 'better-click-to-tweet' ); ?></p>
92
- </div>
93
- </div>
94
- <div class="postbox">
95
- <div class="inside">
96
- <h2 class="hndle"><?php _e( 'Settings', 'better-click-to-tweet' ); ?></h2>
97
- <p><?php _e( 'Enter your Twitter handle to add "via @yourhandle" to your tweets. Do not include the @ symbol.', 'better-click-to-tweet' ); ?></p>
98
- <p><?php _e('Checking the box below will force the plugin to show the WordPress shortlink in place of the full URL. While this does not impact tweet character length, it is useful alongside plugins which customize the WordPress shortlink using services like bit.ly or yourls.org for tracking', 'better-click-to-tweet')?> </p>
99
- <form method="post" action="options.php" style="display: inline-block;">
100
- <?php settings_fields( 'bctt_clicktotweet-options' ); ?>
101
-
102
- <table class="form-table">
103
- <tr valign="top">
104
- <th style="width: 200px;"><label><?php _ex('Your Twitter Handle', 'label for text input on settings screen', 'better-click-to-tweet'); ?></label></th>
105
- <td><input type="text" name="bctt-twitter-handle" value="<?php echo get_option('bctt-twitter-handle'); ?>" /></td></tr>
106
- <tr valign="top">
107
- <th style="width: 200px;"><label><?php _ex('Use Short URL?', 'label for checkbox on settings screen', 'better-click-to-tweet'); ?></label></th>
108
- <td><input type="checkbox" name="bctt-short-url" value="1" <?php if ( 1 == get_option( 'bctt-short-url') ) echo 'checked="checked"'; ?>" /></td>
109
- </tr>
110
- </table>
111
- <br class="clear" />
112
- <p><input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'better-click-to-tweet' ); ?>" /></p>
113
- <br class="clear" />
114
- <em><?php $url = 'http://benandjacq.com'; $link = sprintf( __( 'An open source plugin by <a href=%s>Ben Meredith</a>', 'better-click-to-tweet'), esc_url($url) ); echo $link; ?></em>
115
- </form>
116
- </div>
117
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  </div>
119
  </div>
120
  </div>
121
  </div>
122
  </div>
123
- <?php
124
- }
 
 
125
 
126
 
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 button to visual editor
9
+ include dirname( __FILE__ ) . '/assets/tinymce/bctt-tinymce.php';
10
 
11
  // Add Settings Link
12
+ add_action( 'admin_menu', 'bctt_admin_menu' );
 
 
13
 
14
 
15
  function bctt_admin_menu() {
16
+ add_action( 'admin_init', 'bctt_register_settings', 100, 1 );
17
+ add_options_page( 'Better Click To Tweet Options', 'Better Click To Tweet', 'manage_options', 'better-click-to-tweet', 'bctt_settings_page' );
18
+ }
19
 
20
  function bctt_register_settings() {
21
+ register_setting( 'bctt_clicktotweet-options', 'bctt-twitter-handle', 'bctt_validate_settings' );
22
+ register_setting( 'bctt_clicktotweet-options', 'bctt-short-url', 'bctt_validate_checkbox' );
23
+ }
24
+
25
+ function bctt_validate_settings( $input ) {
26
+ return str_replace( '@', '', strip_tags( stripslashes( $input ) ) );
27
+ }
28
+
29
+ function bctt_validate_checkbox( $input ) {
30
+ if ( ! isset( $input ) || $input != '1' ) {
31
+ return 0;
32
+ } else {
33
+ return 1;
34
+ }
35
+ }
36
 
37
  function bctt_settings_page() {
38
+ if ( ! current_user_can( 'manage_options' ) ) {
39
+ wp_die( __( 'You do not have sufficient permissions to access this page.', 'better-click-to-tweet' ) );
40
+ } ?>
41
+
42
+ <div class="wrap">
43
+
44
+ <h2><?php /* translators: Treat "Better Click To Tweet" as a brand name, don't translate it */
45
+ _e( 'Better Click To Tweet — a plugin by Ben Meredith', 'better-click-to-tweet' ); ?></h2>
46
+
47
+ <hr/>
48
+ <div id="bctt_admin" class="metabox-holder has-right-sidebar">
49
+ <div class="inner-sidebar">
50
+ <div id="normal-sortables" class="meta-box-sortables ui-sortable">
51
+ <div class="postbox">
52
+ <div class="inside">
53
+ <h3 class="hndle ui-sortable-handle"><?php _e( 'About the Author', 'better-click-to-tweet' ); ?> </h3>
54
+
55
+ <div id="bctt_signup">
56
+ <form
57
+ action="//benandjacq.us1.list-manage.com/subscribe/post?u=8f88921110b81f81744101f4d&amp;id=bd909b5f89"
58
+ method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form"
59
+ class="validate" target="_blank" novalidate>
60
+ <div id="mc_embed_signup_scroll">
61
+ <p> <?php echo sprintf( __( 'This plugin is developed by <a href="%s">Ben Meredith</a>. I am a freelance developer specializing in <a href="%s">outrunning and outsmarting hackers</a>.', 'better-click-to-tweet' ), esc_url( 'http://benandjacq.com' ), esc_url( 'http://benandjacq.com/wordpress-maintenance-plans' ) ); ?></p>
62
+ <h4><?php _e( 'Sign up to receive my FREE web strategy guide', 'better-click-to-tweet' ); ?></h4>
63
+
64
+ <p><input type="email" value="" name="EMAIL" class="widefat" id="mce-EMAIL"
65
+ placeholder="<?php _ex( 'Your Email Address', 'placeholder text for input field', 'better-click-to-tweet' ); ?>">
66
+ <small><?php _e( 'No Spam. One-click unsubscribe in every message', 'better-click-to-tweet' ); ?></small>
67
+ </p>
68
+ <div style="position: absolute; left: -5000px;"><input type="text"
69
+ name="b_8f88921110b81f81744101f4d_bd909b5f89"
70
+ tabindex="-1" value="">
71
+ </div>
72
+ <p class="clear"><input type="submit" value="Subscribe" name="subscribe"
73
+ id="mc-embedded-subscribe" class="button-secondary"></p>
74
+
75
  </div>
76
+ </form>
 
 
 
 
 
 
 
 
 
 
77
  </div>
78
  </div>
79
  </div>
80
+ </div>
81
+ <div class="meta-box-sortables">
82
+ <div class="postbox">
83
+ <div class="inside">
84
+ <p><?php $url2 = 'https://github.com/Benunc/better-click-to-tweet';
85
+ $link2 = sprintf( __( 'Are you a developer? I would love your help making this plugin better. Check out the <a href=%s>plugin on Github.</a>', 'better-click-to-tweet' ), esc_url( $url2 ) );
86
+ echo $link2; ?></p>
87
+
88
+ <p><?php $url3 = 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HDSGWRJYFQQNJ';
89
+ $link3 = sprintf( __( 'The best way you can support this and other plugins is to <a href=%s>donate</a>', 'better-click-to-tweet' ), esc_url( $url3 ) );
90
+ echo $link3; ?>
91
+ . <?php $url4 = 'https://wordpress.org/support/view/plugin-reviews/better-click-to-tweet';
92
+ $link4 = sprintf( __( 'The second best way is to <a href=%s>leave an honest review.</a>', 'better-click-to-tweet' ), esc_url( $url4 ) );
93
+ echo $link4; ?></p>
94
+
95
+ <p><?php _e( 'Did this plugin save you enough time to be worth some money?', 'better-click-to-tweet' ); ?></p>
96
+
97
+ <p>
98
+ <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HDSGWRJYFQQNJ"
99
+ target="_blank"><?php _e( 'Click here to buy me a Coke to say thanks.', 'better-click-to-tweet' ); ?></a>
100
+ </p>
101
+ </div>
102
+ </div>
103
+ </div>
104
+ </div>
105
+ <div id="post-body" class="has-sidebar">
106
+ <div id="post-body-content" class="has-sidebar-content">
107
+ <div id="normal-sortables" class="meta-box-sortables">
108
+ <div class="postbox">
109
+ <div class="inside">
110
+ <h2 class="hndle"><?php _e( 'Instructions', 'better-click-to-tweet' ); ?></h2>
111
+
112
+ <p><?php /* translators: Treat "Better Click To Tweet" as a brand name, don't translate it */
113
+ _e( 'To add styled click-to-tweet quote boxes include the Better Click To Tweet shortcode in your post.', 'better-click-to-tweet' ); ?></p>
114
+
115
+ <p><?php _e( 'Here\'s how you format the shortcode:', 'better-click-to-tweet' ); ?></p>
116
+ <pre>[bctt tweet="<?php /* translators: This text shows up as a sample tweet in the instructions for how to use the plugin. */
117
+ _e( 'Meaningful, tweetable quote.', 'better-click-to-tweet' ); ?>"]</pre>
118
+ <p><?php /* translators: Also, treat "BCTT" as a brand name, don't translate it */
119
+ _e( 'If you are using the visual editor, click the BCTT birdie in the toolbar to add a pre-formatted shortcode to your post.', 'better-click-to-tweet' ); ?></p>
120
+
121
+ <p><?php _e( 'Tweet length is automatically shortened to 117 characters minus the length of your twitter name, to leave room for it and a link back to the post.', 'better-click-to-tweet' ); ?></p>
122
+ </div>
123
+ </div>
124
+ <div class="postbox">
125
+ <div class="inside">
126
+ <h2 class="hndle"><?php _e( 'Settings', 'better-click-to-tweet' ); ?></h2>
127
+
128
+ <p><?php _e( 'Enter your Twitter handle to add "via @yourhandle" to your tweets. Do not include the @ symbol.', 'better-click-to-tweet' ); ?></p>
129
+
130
+ <p><?php _e( 'Checking the box below will force the plugin to show the WordPress shortlink in place of the full URL. While this does not impact tweet character length, it is useful alongside plugins which customize the WordPress shortlink using services like bit.ly or yourls.org for tracking', 'better-click-to-tweet' ) ?> </p>
131
+
132
+ <form method="post" action="options.php" style="display: inline-block;">
133
+ <?php settings_fields( 'bctt_clicktotweet-options' ); ?>
134
+
135
+ <table class="form-table">
136
+ <tr valign="top">
137
+ <th style="width: 200px;">
138
+ <label><?php _ex( 'Your Twitter Handle', 'label for text input on settings screen', 'better-click-to-tweet' ); ?></label>
139
+ </th>
140
+ <td><input type="text" name="bctt-twitter-handle"
141
+ value="<?php echo get_option( 'bctt-twitter-handle' ); ?>"/></td>
142
+ </tr>
143
+ <tr valign="top">
144
+ <th style="width: 200px;">
145
+ <label><?php _ex( 'Use Short URL?', 'label for checkbox on settings screen', 'better-click-to-tweet' ); ?></label>
146
+ </th>
147
+ <td><input type="checkbox" name="bctt-short-url"
148
+ value="1" <?php if ( 1 == get_option( 'bctt-short-url' ) ) {
149
+ echo 'checked="checked"';
150
+ } ?>" />
151
+ </td>
152
+ </tr>
153
+ </table>
154
+ <br class="clear"/>
155
+
156
+ <p><input type="submit" class="button-primary"
157
+ value="<?php _e( 'Save Changes', 'better-click-to-tweet' ); ?>"/></p>
158
+ <br class="clear"/>
159
+ <em><?php $url = 'http://benandjacq.com';
160
+ $link = sprintf( __( 'An open source plugin by <a href=%s>Ben Meredith</a>', 'better-click-to-tweet' ), esc_url( $url ) );
161
+ echo $link; ?></em>
162
+ </form>
163
  </div>
164
  </div>
165
  </div>
166
  </div>
167
  </div>
168
+ </div>
169
+ </div>
170
+ <?php
171
+ }
172
 
173
 
better-click-to-tweet.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Better Click To Tweet
4
  Description: The only Click To Tweet plugin to add translation support. The only Click To Tweet plugin to take into account your Twitter username's length in truncating long tweets, or to correctly take into account non-Roman characters. Simply put, as Click To Tweet plugins go, this one is, well, BETTER.
5
- Version: 4.4
6
  Author: Ben Meredith
7
  Author URI: http://benandjacq.com
8
  Plugin URI: https://wordpress.org/plugins/better-click-to-tweet/
@@ -25,49 +25,51 @@ defined( 'ABSPATH' ) or die( "No soup for you. You leave now." );
25
  */
26
 
27
  function bctt_shorten( $input, $length, $ellipsis = true, $strip_html = true ) {
28
-
29
- if ( $strip_html ) {
30
- $input = strip_tags( $input );
31
- }
32
-
33
- /*
34
- * Checks to see if the mbstring php extension is loaded, for optimal truncation.
35
- * If it's not, it bails and counts the characters based on utf-8.
36
- * What this means for users is that non-Roman characters will only be counted
37
- * correctly if that extension is loaded. Contact your server admin to enable the extension.
38
- */
39
-
40
- if ( function_exists( 'mb_internal_encoding' ) ) {
41
- if ( mb_strlen( $input ) <= $length ) {
42
- return $input;
43
- }
44
-
45
- $last_space = mb_strrpos( mb_substr( $input, 0, $length ) , ' ' );
46
- $trimmed_text = mb_substr( $input, 0, $last_space );
47
-
48
- if ( $ellipsis ) {
49
- $trimmed_text .= '…';
50
- }
51
-
52
- return $trimmed_text;
53
-
54
- } else {
55
-
56
- if ( strlen( $input ) <= $length ) {
57
- return $input;
58
- }
59
-
60
- $last_space = strrpos( substr( $input, 0, $length ) , ' ' );
61
- $trimmed_text = substr( $input, 0, $last_space );
62
-
63
- if ( $ellipsis ) {
64
- $trimmed_text .= '…';
65
- }
66
-
67
- return $trimmed_text;
68
- }
69
- };
70
-
 
 
71
  /*
72
  * Creates the bctt shortcode
73
  *
@@ -75,169 +77,173 @@ function bctt_shorten( $input, $length, $ellipsis = true, $strip_html = true ) {
75
  * @param $atts
76
  *
77
  */
78
-
79
  function bctt_shortcode( $atts ) {
80
-
81
- extract( shortcode_atts( array(
82
- 'tweet' => '',
83
- 'via' => 'yes',
84
- 'url' => 'yes',
85
- 'nofollow' => 'no',
86
- ), $atts ) );
87
-
88
- $handle = get_option( 'bctt-twitter-handle' );
89
-
90
- if ( function_exists( 'mb_internal_encoding' ) ) {
91
-
92
- $handle_length = ( 6 + mb_strlen($handle));
93
-
94
- } else {
95
-
96
- $handle_length = ( 6 + strlen($handle));
97
-
98
- }
99
-
100
- if ( !empty( $handle ) && $via != 'no' ) {
101
-
102
- $handle_code = "&amp;via=" . $handle . "&amp;related=" . $handle;
103
-
104
- } else {
105
-
106
- $handle_code = '';
107
-
108
- }
109
-
110
- if( $via != 'yes') {
111
-
112
- $handle = '';
113
- $handle_code = '';
114
- $handle_length = 0;
115
-
116
- }
117
-
118
- $text = $tweet;
119
-
120
- if( filter_var( $url, FILTER_VALIDATE_URL ) ) {
121
-
122
- $bcttURL = '&amp;url=' . $url;
123
-
124
- } elseif( $url != 'no' ){
125
-
126
- if ( get_option('bctt-short-url') != false ) {
127
-
128
- $bcttURL = '&amp;url=' . wp_get_shortlink();
129
-
130
- } else {
131
-
132
- $bcttURL = '&amp;url=' . get_permalink();
133
-
134
- }
135
-
136
- } else {
137
-
138
- $bcttURL = '';
139
-
140
- }
141
-
142
- $bcttBttn = sprintf( _x( 'Click To Tweet', 'Text for the box on the reader-facing box', 'better-click-to-tweet' ) );
143
-
144
- if( $url != 'no'){
145
-
146
- $short = bctt_shorten( $text, ( 117 - ( $handle_length ) ) );
147
-
148
- } else {
149
-
150
- $short = bctt_shorten( $text, ( 140 - ( $handle_length ) ) );
151
-
152
- }
153
-
154
- if( $nofollow != 'no') {
155
-
156
- $rel = "rel='nofollow'";
157
-
158
- } else {
159
-
160
- $rel = '';
161
-
162
- }
163
-
164
- if ( !is_feed() ) {
165
-
166
- return "<div class='bctt-click-to-tweet'><span class='bctt-ctt-text'><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . $bcttURL."' target='_blank'" . $rel . ">".$short." </a></span><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . $bcttURL . "' target='_blank' class='bctt-ctt-btn'" . $rel . ">" . $bcttBttn . "</a></div><script async src='//platform.twitter.com/widgets.js' charset='utf-8'></script>";
167
- } else {
168
-
169
- return "<hr /><p><em>" . $short . "</em><br /><a href='https://twitter.com/intent/tweet?text=" . urlencode($short) . $handle_code . $bcttURL . "' target='_blank' class='bctt-ctt-btn'" . $rel . ">" . $bcttBttn . "</a><br /><hr />";
170
-
171
- };
172
  }
173
 
174
- add_shortcode('bctt', 'bctt_shortcode');
175
-
176
- /*
177
- * Load the stylesheet to style the output.
178
- *
179
- * As of v4.1, defaults to a custom stylesheet
180
- * located in the root of the uploads folder at wp-content/uploads/bcttstyle.css and falls
181
- * back to the stylesheet bundled with the plugin if the custom sheet is not present.
182
- *
183
- * @since 0.1
184
- *
185
- */
186
-
187
- function bctt_scripts () {
188
-
189
  $dir = wp_upload_dir();
190
-
191
- $custom = file_exists( $dir['basedir'] . '/bcttstyle.css');
192
-
193
- if( $custom != 'true' ) {
194
-
195
  wp_register_style( 'bcct_style', plugins_url( 'assets/css/styles.css', __FILE__ ), false, '1.0', 'all' );
196
-
197
- wp_enqueue_style('bcct_style');
198
-
199
  } else {
200
-
201
  wp_register_style( 'bcct_custom_style', $dir['baseurl'] . '/bcttstyle.css', false, '1.0', 'all' );
202
-
203
- wp_enqueue_style('bcct_custom_style');
204
  }
205
-
206
 
207
- };
208
-
209
- add_action('wp_enqueue_scripts', 'bctt_scripts');
210
-
211
- /*
212
- * Delete options and shortcode on uninstall
213
- *
214
- * @since 0.1
215
- */
216
-
217
- function bctt_on_uninstall(){
218
 
219
- delete_option( 'bctt-twitter-handle' );
 
 
 
 
 
 
 
 
 
 
 
 
220
 
221
- delete_option( 'bctt-short-url');
222
 
223
- remove_shortcode( 'bctt' );
 
 
 
 
224
 
225
- };
226
 
227
- register_uninstall_hook( __FILE__, 'bctt_on_uninstall' );
228
 
229
- function bctt_options_link($links) {
230
 
231
- $settingsText = sprintf( _x( 'Settings', 'text for the link on the plugins page', 'better-click-to-tweet'));
232
 
233
- $settings_link = '<a href="options-general.php?page=better-click-to-tweet">'.$settingsText.'</a>';
234
 
235
- array_unshift( $links, $settings_link );
236
 
237
- return $links;
238
 
239
  }
240
 
241
- $bcttlink = plugin_basename(__FILE__);
242
- add_filter("plugin_action_links_$bcttlink", 'bctt_options_link' );
243
 
2
  /*
3
  Plugin Name: Better Click To Tweet
4
  Description: The only Click To Tweet plugin to add translation support. The only Click To Tweet plugin to take into account your Twitter username's length in truncating long tweets, or to correctly take into account non-Roman characters. Simply put, as Click To Tweet plugins go, this one is, well, BETTER.
5
+ Version: 4.4.1
6
  Author: Ben Meredith
7
  Author URI: http://benandjacq.com
8
  Plugin URI: https://wordpress.org/plugins/better-click-to-tweet/
25
  */
26
 
27
  function bctt_shorten( $input, $length, $ellipsis = true, $strip_html = true ) {
28
+
29
+ if ( $strip_html ) {
30
+ $input = strip_tags( $input );
31
+ }
32
+
33
+ /*
34
+ * Checks to see if the mbstring php extension is loaded, for optimal truncation.
35
+ * If it's not, it bails and counts the characters based on utf-8.
36
+ * What this means for users is that non-Roman characters will only be counted
37
+ * correctly if that extension is loaded. Contact your server admin to enable the extension.
38
+ */
39
+
40
+ if ( function_exists( 'mb_internal_encoding' ) ) {
41
+ if ( mb_strlen( $input ) <= $length ) {
42
+ return $input;
43
+ }
44
+
45
+ $last_space = mb_strrpos( mb_substr( $input, 0, $length ), ' ' );
46
+ $trimmed_text = mb_substr( $input, 0, $last_space );
47
+
48
+ if ( $ellipsis ) {
49
+ $trimmed_text .= '…';
50
+ }
51
+
52
+ return $trimmed_text;
53
+
54
+ } else {
55
+
56
+ if ( strlen( $input ) <= $length ) {
57
+ return $input;
58
+ }
59
+
60
+ $last_space = strrpos( substr( $input, 0, $length ), ' ' );
61
+ $trimmed_text = substr( $input, 0, $last_space );
62
+
63
+ if ( $ellipsis ) {
64
+ $trimmed_text .= '…';
65
+ }
66
+
67
+ return $trimmed_text;
68
+ }
69
+ }
70
+
71
+ ;
72
+
73
  /*
74
  * Creates the bctt shortcode
75
  *
77
  * @param $atts
78
  *
79
  */
80
+
81
  function bctt_shortcode( $atts ) {
82
+
83
+ extract( shortcode_atts( array(
84
+ 'tweet' => '',
85
+ 'via' => 'yes',
86
+ 'url' => 'yes',
87
+ 'nofollow' => 'no',
88
+ ), $atts ) );
89
+
90
+ $handle = get_option( 'bctt-twitter-handle' );
91
+
92
+ if ( function_exists( 'mb_internal_encoding' ) ) {
93
+
94
+ $handle_length = ( 6 + mb_strlen( $handle ) );
95
+
96
+ } else {
97
+
98
+ $handle_length = ( 6 + strlen( $handle ) );
99
+
100
+ }
101
+
102
+ if ( ! empty( $handle ) && $via != 'no' ) {
103
+
104
+ $handle_code = "&amp;via=" . $handle . "&amp;related=" . $handle;
105
+
106
+ } else {
107
+
108
+ $handle_code = '';
109
+
110
+ }
111
+
112
+ if ( $via != 'yes' ) {
113
+
114
+ $handle = '';
115
+ $handle_code = '';
116
+ $handle_length = 0;
117
+
118
+ }
119
+
120
+ $text = $tweet;
121
+
122
+ if ( filter_var( $url, FILTER_VALIDATE_URL ) ) {
123
+
124
+ $bcttURL = '&amp;url=' . $url;
125
+
126
+ } elseif ( $url != 'no' ) {
127
+
128
+ if ( get_option( 'bctt-short-url' ) != false ) {
129
+
130
+ $bcttURL = '&amp;url=' . wp_get_shortlink();
131
+
132
+ } else {
133
+
134
+ $bcttURL = '&amp;url=' . get_permalink();
135
+
136
+ }
137
+
138
+ } else {
139
+
140
+ $bcttURL = '';
141
+
142
+ }
143
+
144
+ $bcttBttn = sprintf( _x( 'Click To Tweet', 'Text for the box on the reader-facing box', 'better-click-to-tweet' ) );
145
+
146
+ if ( $url != 'no' ) {
147
+
148
+ $short = bctt_shorten( $text, ( 117 - ( $handle_length ) ) );
149
+
150
+ } else {
151
+
152
+ $short = bctt_shorten( $text, ( 140 - ( $handle_length ) ) );
153
+
154
+ }
155
+
156
+ if ( $nofollow != 'no' ) {
157
+
158
+ $rel = "rel='nofollow'";
159
+
160
+ } else {
161
+
162
+ $rel = '';
163
+
164
+ }
165
+
166
+ if ( ! is_feed() ) {
167
+
168
+ return "<div class='bctt-click-to-tweet'><span class='bctt-ctt-text'><a href='https://twitter.com/intent/tweet?text=" . urlencode( $short ) . $handle_code . $bcttURL . "' target='_blank'" . $rel . ">" . $short . " </a></span><a href='https://twitter.com/intent/tweet?text=" . urlencode( $short ) . $handle_code . $bcttURL . "' target='_blank' class='bctt-ctt-btn'" . $rel . ">" . $bcttBttn . "</a></div><script async src='//platform.twitter.com/widgets.js' charset='utf-8'></script>";
169
+ } else {
170
+
171
+ return "<hr /><p><em>" . $short . "</em><br /><a href='https://twitter.com/intent/tweet?text=" . urlencode( $short ) . $handle_code . $bcttURL . "' target='_blank' class='bctt-ctt-btn'" . $rel . ">" . $bcttBttn . "</a><br /><hr />";
172
+
173
+ };
174
  }
175
 
176
+ add_shortcode( 'bctt', 'bctt_shortcode' );
177
+
178
+ /*
179
+ * Load the stylesheet to style the output.
180
+ *
181
+ * As of v4.1, defaults to a custom stylesheet
182
+ * located in the root of the uploads folder at wp-content/uploads/bcttstyle.css and falls
183
+ * back to the stylesheet bundled with the plugin if the custom sheet is not present.
184
+ *
185
+ * @since 0.1
186
+ *
187
+ */
188
+
189
+ function bctt_scripts() {
190
+
191
  $dir = wp_upload_dir();
192
+
193
+ $custom = file_exists( $dir['basedir'] . '/bcttstyle.css' );
194
+
195
+ if ( $custom != 'true' ) {
196
+
197
  wp_register_style( 'bcct_style', plugins_url( 'assets/css/styles.css', __FILE__ ), false, '1.0', 'all' );
198
+
199
+ wp_enqueue_style( 'bcct_style' );
200
+
201
  } else {
202
+
203
  wp_register_style( 'bcct_custom_style', $dir['baseurl'] . '/bcttstyle.css', false, '1.0', 'all' );
204
+
205
+ wp_enqueue_style( 'bcct_custom_style' );
206
  }
 
207
 
 
 
 
 
 
 
 
 
 
 
 
208
 
209
+ }
210
+
211
+ ;
212
+
213
+ add_action( 'wp_enqueue_scripts', 'bctt_scripts' );
214
+
215
+ /*
216
+ * Delete options and shortcode on uninstall
217
+ *
218
+ * @since 0.1
219
+ */
220
+
221
+ function bctt_on_uninstall() {
222
 
223
+ delete_option( 'bctt-twitter-handle' );
224
 
225
+ delete_option( 'bctt-short-url' );
226
+
227
+ remove_shortcode( 'bctt' );
228
+
229
+ }
230
 
231
+ ;
232
 
233
+ register_uninstall_hook( __FILE__, 'bctt_on_uninstall' );
234
 
235
+ function bctt_options_link( $links ) {
236
 
237
+ $settingsText = sprintf( _x( 'Settings', 'text for the link on the plugins page', 'better-click-to-tweet' ) );
238
 
239
+ $settings_link = '<a href="options-general.php?page=better-click-to-tweet">' . $settingsText . '</a>';
240
 
241
+ array_unshift( $links, $settings_link );
242
 
243
+ return $links;
244
 
245
  }
246
 
247
+ $bcttlink = plugin_basename( __FILE__ );
248
+ add_filter( "plugin_action_links_$bcttlink", 'bctt_options_link' );
249
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: click to tweet, twitter, tweet, twitter plugin, Twitter boxes, share, social media, post, posts, plugin, auto post, bitly, bit.ly, yourls, yourls.org, translate-me, Español, Deutsch, Russian, Finnish, Svenska, Suomi, Italiano,
5
  Requires at least: 3.8
6
  Tested up to: 4.3
7
- Stable tag: 4.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -111,6 +111,9 @@ I want to maximize the usefulness of this plugin by translating it into multiple
111
 
112
  == Changelog ==
113
 
 
 
 
114
  = 4.4 =
115
  * Twitter now opens in a new modal box instead of a new tab, (developers: this is done using a call to platform.twitter.com/widgets.js within the code of the output from the shortcode. This means that the script won't be loaded on pages or posts where it's not needed.)
116
 
4
  Tags: click to tweet, twitter, tweet, twitter plugin, Twitter boxes, share, social media, post, posts, plugin, auto post, bitly, bit.ly, yourls, yourls.org, translate-me, Español, Deutsch, Russian, Finnish, Svenska, Suomi, Italiano,
5
  Requires at least: 3.8
6
  Tested up to: 4.3
7
+ Stable tag: 4.4.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
111
 
112
  == Changelog ==
113
 
114
+ = 4.4.1 =
115
+ * Fixed CSS issue with spacing in the default theme.
116
+
117
  = 4.4 =
118
  * Twitter now opens in a new modal box instead of a new tab, (developers: this is done using a call to platform.twitter.com/widgets.js within the code of the output from the shortcode. This means that the script won't be loaded on pages or posts where it's not needed.)
119