forked from Benunc/better-click-to-tweet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bctt_options.php
277 lines (233 loc) · 13.4 KB
/
bctt_options.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<?php
defined( 'ABSPATH' ) or die( "No script kiddies please!" );
// Cache bust tinymce
add_filter( 'tiny_mce_version', 'refresh_mce' );
// Add button to visual editor
include dirname( __FILE__ ) . '/assets/tinymce/bctt-tinymce.php';
// instantiate i18n encouragement module
$bctt_i18n = new bctt_i18n(
array(
'textdomain' => 'better-click-to-tweet',
'project_slug' => '/wp-plugins/better-click-to-tweet/stable',
'plugin_name' => 'Better Click To Tweet',
'hook' => 'bctt_settings_top',
'glotpress_url' => 'https://translate.wordpress.org/',
'glotpress_name' => 'Translating WordPress',
'glotpress_logo' => 'https://plugins.svn.wordpress.org/better-click-to-tweet/assets/icon-256x256.png',
'register_url ' => 'https://translate.wordpress.org/projects/wp-plugins/better-click-to-tweet/',
)
);
// Add Settings Link
add_action( 'admin_menu', 'bctt_admin_menu' );
function bctt_admin_menu() {
add_action( 'admin_init', 'bctt_register_settings', 100, 1 );
add_menu_page( 'Better Click To Tweet Options', 'Better Click To Tweet', 'manage_options', 'better-click-to-tweet', null, 'dashicons-twitter' );
add_submenu_page('better-click-to-tweet', 'Better Click To Tweet Main Settings', 'Settings', 'manage_options', 'better-click-to-tweet', 'bctt_settings_page' );
}
function bctt_register_settings() {
register_setting( 'bctt_clicktotweet-options', 'bctt-twitter-handle', 'bctt_validate_settings' );
register_setting( 'bctt_clicktotweet-options', 'bctt-short-url', 'bctt_validate_checkbox' );
}
function bctt_validate_settings( $input ) {
return preg_replace('/[^0-9a-zA-Z_]/', '', $input);
}
function bctt_validate_checkbox( $input ) {
if ( ! isset( $input ) || $input != '1' ) {
return 0;
} else {
return 1;
}
}
function bctt_add_custom_style_option() {
$bctt_dequeued_with_custom_funtion = bctt_is_default_styles_dequeued();
$bctt_custom_style = bctt_is_custom_stylesheet();
if ( $bctt_dequeued_with_custom_funtion || $bctt_custom_style ) {
return true;
} else {
return false;
}
}
function bctt_admin_styles() {
wp_register_style( 'bctt_admin_style', plugins_url( 'assets/css/bctt-admin.css', __FILE__ ) );
wp_enqueue_style( 'bctt_admin_style' );
}
function bctt_settings_page() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.', 'better-click-to-tweet' ) );
}
bctt_admin_styles();
?>
<div class="wrap">
<h1 class="wp-heading-inline"><?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' ); ?></h1>
<hr/>
<?php do_action( 'bctt_settings_top' ); ?>
<div id="poststuff">
<div id="post-body" class="metabox-holder columns-2 ">
<div id="post-body-content" style="position: relative;">
<div id="bctt_instructions" class="postbox ">
<h2><?php _e( 'Instructions', 'better-click-to-tweet' ); ?></h2>
<div class="inside">
<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>
<p><?php _e( 'Here\'s how you format the shortcode:', 'better-click-to-tweet' ); ?></p>
<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><?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>
<p><?php
_e( 'In the WordPress 5.0 editor (codenamed Gutenberg), there is a Better Click To Tweet block.', 'better-click-to-tweet' ); ?></p>
<p><?php _e( 'If you include a link back to the post using the URL parameter (or leaving it out, the default behavior), the tweet length is automatically shortened to 253 characters minus the length of your twitter handle, to leave room for the handle and link back to the post.', 'better-click-to-tweet' ); ?></p>
<p><?php echo sprintf( __( 'Learn more about the URL parameter as well as the other power user features in the <a href=%s>Power User Guide</a>.', 'better-click-to-tweet' ), esc_url( 'http://benlikes.us/7r') ); ?></p>
</div>
<!--/inside-->
</div>
<!--/bctt_instructions-->
<?php do_action( 'bctt_instructions_bottom' ); ?>
<div class="postbox">
<h2><?php _e( 'Settings', 'better-click-to-tweet' ); ?></h2>
<div class="inside">
<div class="main">
<p><?php _e( 'Enter your Twitter handle to add "via @yourhandle" to your tweets. Do not include the @ symbol.', 'better-click-to-tweet' ); ?></p>
<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>
<form method="post" action="options.php" style="">
<?php settings_fields( 'bctt_clicktotweet-options' ); ?>
<table class="form-table">
<tr valign="top">
<th style="width: 200px;">
<label for="bctt-twitter-handle"><?php _ex( 'Your Twitter Handle', 'label for text input on settings screen', 'better-click-to-tweet' ); ?></label>
</th>
<td><input id="bctt-twitter-handle" type="text" name="bctt-twitter-handle"
value="<?php echo esc_attr( get_option( 'bctt-twitter-handle' ) ); ?>"/>
</td>
<tr valign="top">
<th style="width: 200px;">
<label for="bctt-short-url"><?php _ex( 'Use Short URL?', 'label for checkbox on settings screen', 'better-click-to-tweet' ); ?></label>
</th>
<td><input id="bctt-short-url" type="checkbox" name="bctt-short-url"
value="1" <?php if ( 1 == get_option( 'bctt-short-url' ) ) {
echo 'checked="checked"';
} ?>" />
</td>
</tr>
<?php if ( ! bctt_add_custom_style_option() ) { ?>
<tr valign="top">
<th style="width:200px;">
<label><?php _ex( 'Use Premium Styles?', 'label for checkbox on settings screen', 'better-click-to-tweet' ); ?></label>
</th>
<td><input type="checkbox" name="bctt-custom-style"
value="1" style="float:left;"<?php if ( is_plugin_active( 'better-click-to-tweet-styles/better-click-to-tweet-premium-styles.php' ) ) {
echo 'checked="checked"';
} else {
echo 'disabled="disabled"';
} ?>" /> <div
style="font-size: .85em; margin-left:3em; line-height:1.5em"><em> <?php if ( ! is_plugin_active( 'better-click-to-tweet-styles/better-click-to-tweet-premium-styles.php' ) ) {
echo sprintf( __( 'Want Premium styles? Add the <a href=%s>Premium Styles add-on</a> today!', 'better-click-to-tweet' ), esc_url( 'http://benlikes.us/bcttpsdirect' ) );
} ?></em></div>
</td>
</tr>
<?php } ?>
<?php if ( ! defined( 'BCTTUTM_VERSION' ) ) { ?>
<tr valign="top">
<th style="width:200px;">
<label><?php _ex( 'Use UTM Tags?', 'label for checkbox on settings screen', 'better-click-to-tweet' ); ?></label>
</th>
<td><input type="checkbox" name="bctt-utm-tags"
value="1" disabled="disabled" style="float:left;" /> <div
style="font-size: .85em; margin-left:3em; line-height:1.5em"><em> <?php
echo sprintf( __( 'Want add UTM tags to the return URL to track how well BCTT boxes are performing? Add the <a href=%s>UTM tags add-on</a> today!', 'better-click-to-tweet' ), esc_url( 'http://benlikes.us/bcttutmdirect' ) );
?></em></div>
</td>
</tr>
<?php } ?>
</table>
<?php do_action( 'bctt_before_settings_submit' ); ?>
<br class="clear"/>
<p><input type="submit" class="button-primary"
value="<?php _e( 'Save Changes', 'better-click-to-tweet' ); ?>"/>
</p>
<br class="clear"/>
<em><?php $url = 'https://www.betterclicktotweet.com';
$link = sprintf( __( 'An open source plugin by <a href=%s>Ben Meredith</a>', 'better-click-to-tweet' ), esc_url( $url ) );
echo $link; ?></em>
</form>
</div>
<!--/main-->
</div>
<!--/inside-->
</div>
<!--/postbox-->
</div>
<!--/post-body-content-->
<?php do_action( 'bctt_after_settings' ); ?>
<div id="post-box-container-1" class="post-box-container">
<div id="side-sortables" class="meta-box-sortables ui-sortable">
<div id="bctt-author" class="postbox " style="display:block;">
<h2><?php _e( 'About the Author', 'better-click-to-tweet' ); ?> </h2>
<div id="bctt_signup" class="inside">
<form
action="//benandjacq.us1.list-manage.com/subscribe/post?u=8f88921110b81f81744101f4d&id=bd909b5f89&SUBSET=<?php echo urlencode( site_url() ) ?>"
method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form"
class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<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( 'https://www.wpsteward.com' ), esc_url( 'https://www.wpsteward.com/service-plans' ) ); ?></p>
<h3 class="bctt-signup"><?php _e( 'Sign up here for a free 7-part email series on how to manage your website like a pro.', 'better-click-to-tweet' ); ?></h3>
<p><label for="bctt-email-signup" class="hidden">
Your Email Address
</label>
<input id="bctt-email-signup" 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' ); ?>">
<small><?php _e( 'No Spam. One-click unsubscribe in every message', 'better-click-to-tweet' ); ?></small>
</p>
<div style="position: absolute; left: -5000px;">
<label for="bctt-mailchimp-subscribe-hidden" class="hidden">
Hidden field for MailChimp verification
</label>
<input id="bctt-mailchimp-subscribe-hidden" type="text"
name="b_8f88921110b81f81744101f4d_bd909b5f89"
tabindex="-1" value="">
</div>
<p class="clear"><input type="submit" value="<?php _e( 'Subscribe', 'better-click-to-tweet' ); ?>" name="subscribe"
id="mc-embedded-subscribe" class="button-secondary"></p>
</div>
<!--/mc_embed_signup_scroll-->
</form>
</div>
<!--/bctt_signup-->
<?php do_action( 'bctt_author_box_bottom' ); ?>
</div>
<!--/bctt-author-->
</div>
<!--/side-sortables-->
<div id="side-sortables" class="meta-box-sortables ui-sortable">
<div id="bctt-contrib" class="postbox">
<div class="inside">
<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>
<p><?php $url3 = 'https://www.wpsteward.com/donations/plugin-support/';
$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; ?>
. <?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>
<p><?php _e( 'Did this plugin save you enough time to be worth some money?', 'better-click-to-tweet' ); ?></p>
<p>
<a href="https://www.wpsteward.com/donations/plugin-support/"
target="_blank"><?php _e( 'Click here to buy me a Coke to say thanks.', 'better-click-to-tweet' ); ?></a>
</p>
</div>
<!--/inside-->
</div>
<!--/donate-contrib-->
<?php do_action( 'bctt_contrib_bottom' ); ?>
</div>
<!--side-sortables-->
</div>
<!--/post-box-container-1-->
</div>
<!--/post-body-->
</div>
<!--/wrap-->
<?php
}