|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Only user facing pieces of Publicize are found here. |
|
5
|
|
|
*/ |
|
6
|
|
|
class Publicize_UI { |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Contains an instance of class 'publicize' which loads Keyring, sets up services, etc. |
|
10
|
|
|
*/ |
|
11
|
|
|
public $publicize; |
|
12
|
|
|
|
|
13
|
|
|
protected $publicize_settings_url = ''; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Hooks into WordPress to display the various pieces of UI and load our assets |
|
17
|
|
|
*/ |
|
18
|
|
|
function __construct() { |
|
19
|
|
|
global $publicize; |
|
20
|
|
|
|
|
21
|
|
|
$this->publicize = $publicize = new Publicize; |
|
22
|
|
|
|
|
23
|
|
|
add_action( 'init', array( $this, 'init' ) ); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
function init() { |
|
27
|
|
|
$this->publicize_settings_url = apply_filters_deprecated( |
|
28
|
|
|
'jetpack_override_publicize_settings_url', |
|
29
|
|
|
array( admin_url( 'options-general.php?page=sharing' ) ), |
|
30
|
|
|
'6.7', |
|
31
|
|
|
false, |
|
32
|
|
|
__( 'This filter will be removed in a future version of Jetpack', 'jetpack' ) |
|
33
|
|
|
); |
|
34
|
|
|
|
|
35
|
|
|
// Show only to users with the capability required to manage their Publicize connections. |
|
36
|
|
|
if ( ! $this->publicize->current_user_can_access_publicize_data() ) { |
|
37
|
|
|
return; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
// assets (css, js) |
|
41
|
|
|
if ( $this->in_jetpack ) { |
|
|
|
|
|
|
42
|
|
|
add_action( 'load-settings_page_sharing', array( $this, 'load_assets' ) ); |
|
43
|
|
|
} |
|
44
|
|
|
add_action( 'admin_head-post.php', array( $this, 'post_page_metabox_assets' ) ); |
|
45
|
|
|
add_action( 'admin_head-post-new.php', array( $this, 'post_page_metabox_assets' ) ); |
|
46
|
|
|
|
|
47
|
|
|
// management of publicize (sharing screen, ajax/lightbox popup, and metabox on post screen) |
|
48
|
|
|
add_action( 'pre_admin_screen_sharing', array( $this, 'admin_page' ) ); |
|
49
|
|
|
add_action( 'post_submitbox_misc_actions', array( $this, 'post_page_metabox' ) ); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* If the ShareDaddy plugin is not active we need to add the sharing settings page to the menu still |
|
54
|
|
|
*/ |
|
55
|
|
|
function sharing_menu() { |
|
56
|
|
|
add_submenu_page( |
|
57
|
|
|
'options-general.php', |
|
58
|
|
|
__( 'Sharing Settings', 'jetpack' ), |
|
59
|
|
|
__( 'Sharing', 'jetpack' ), |
|
60
|
|
|
'publish_posts', |
|
61
|
|
|
'sharing', |
|
62
|
|
|
array( $this, 'wrapper_admin_page' ) |
|
63
|
|
|
); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
function wrapper_admin_page() { |
|
67
|
|
|
Jetpack_Admin_Page::wrap_ui( array( $this, 'management_page' ), array( 'is-wide' => true ) ); |
|
68
|
|
|
} |
|
69
|
|
|
/** |
|
70
|
|
|
* Management page to load if Sharedaddy is not active so the 'pre_admin_screen_sharing' action exists. |
|
71
|
|
|
*/ |
|
72
|
|
|
function management_page() { ?> |
|
73
|
|
|
<div class="wrap"> |
|
74
|
|
|
<div class="icon32" id="icon-options-general"><br /></div> |
|
75
|
|
|
<h1><?php _e( 'Sharing Settings', 'jetpack' ); ?></h1> |
|
76
|
|
|
|
|
77
|
|
|
<?php |
|
78
|
|
|
/** This action is documented in modules/sharedaddy/sharing.php */ |
|
79
|
|
|
do_action( 'pre_admin_screen_sharing' ); |
|
80
|
|
|
?> |
|
81
|
|
|
|
|
82
|
|
|
</div> <?php |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* styling for the sharing screen and popups |
|
87
|
|
|
* JS for the options and switching |
|
88
|
|
|
*/ |
|
89
|
|
|
function load_assets() { |
|
90
|
|
|
wp_enqueue_script( |
|
91
|
|
|
'publicize', |
|
92
|
|
|
Jetpack::get_file_url_for_environment( |
|
93
|
|
|
'_inc/build/publicize/assets/publicize.min.js', |
|
94
|
|
|
'modules/publicize/assets/publicize.js' |
|
95
|
|
|
), |
|
96
|
|
|
array( 'jquery', 'thickbox' ), |
|
97
|
|
|
'20121019' |
|
98
|
|
|
); |
|
99
|
|
|
if ( is_rtl() ) { |
|
100
|
|
|
wp_enqueue_style( 'publicize', plugins_url( 'assets/rtl/publicize-rtl.css', __FILE__ ), array(), '20180301' ); |
|
101
|
|
|
} else { |
|
102
|
|
|
wp_enqueue_style( 'publicize', plugins_url( 'assets/publicize.css', __FILE__ ), array(), '20180301' ); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
Jetpack_Admin_Page::load_wrapper_styles(); |
|
106
|
|
|
wp_enqueue_style( 'social-logos' ); |
|
107
|
|
|
|
|
108
|
|
|
// for deprecation tooltip |
|
109
|
|
|
wp_enqueue_style( 'wp-pointer' ); |
|
110
|
|
|
wp_enqueue_script( 'wp-pointer' ); |
|
111
|
|
|
|
|
112
|
|
|
add_thickbox(); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
public static function connected_notice( $service_name ) { ?> |
|
116
|
|
|
<div class='updated'> |
|
117
|
|
|
<p><?php |
|
118
|
|
|
|
|
119
|
|
|
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { |
|
120
|
|
|
$platform = 'WordPress.com'; |
|
121
|
|
|
} else { |
|
122
|
|
|
$platform = 'Jetpack'; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
printf( |
|
126
|
|
|
/* translators: %1$s: Service Name (Facebook, Twitter, ...), %2$s: Site type (WordPress.com or Jetpack) */ |
|
127
|
|
|
__( 'You have successfully connected your %1$s account with %2$s.', 'jetpack' ), |
|
128
|
|
|
Publicize::get_service_label( $service_name ), |
|
129
|
|
|
$platform |
|
130
|
|
|
); ?></p> |
|
131
|
|
|
</div><?php |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public static function denied_notice() { ?> |
|
135
|
|
|
<div class='updated'> |
|
136
|
|
|
<p><?php _e ( "You have chosen not to connect your blog. Please click 'accept' when prompted if you wish to connect your accounts.", 'jetpack' ); ?></p> |
|
137
|
|
|
</div><?php |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* Lists the current user's publicized accounts for the blog |
|
142
|
|
|
* looks exactly like Publicize v1 for now, UI and functionality updates will come after the move to keyring |
|
143
|
|
|
*/ |
|
144
|
|
|
function admin_page() { |
|
145
|
|
|
$override_publicize_settings_page = apply_filters_deprecated( |
|
146
|
|
|
'jetpack_override_publicize_settings_page', |
|
147
|
|
|
array( false ), |
|
148
|
|
|
'6.7', |
|
149
|
|
|
false, |
|
150
|
|
|
__( 'This filter will be removed in a future version of Jetpack', 'jetpack' ) |
|
151
|
|
|
); |
|
152
|
|
|
|
|
153
|
|
|
if ( $override_publicize_settings_page ) { |
|
154
|
|
|
echo $override_publicize_settings_page; |
|
155
|
|
|
return; |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
$_blog_id = get_current_blog_id(); |
|
159
|
|
|
?> |
|
160
|
|
|
|
|
161
|
|
|
<form action="" id="publicize-form"> |
|
162
|
|
|
<h2 id="publicize"><?php _e( 'Publicize', 'jetpack' ) ?></h2> |
|
163
|
|
|
|
|
164
|
|
|
<?php |
|
165
|
|
|
if ( ! empty( $_GET['action'] ) && 'deny' == $_GET['action'] ) { |
|
166
|
|
|
$this->denied_notice(); |
|
167
|
|
|
} |
|
168
|
|
|
?> |
|
169
|
|
|
|
|
170
|
|
|
<p> |
|
171
|
|
|
<?php esc_html_e( 'Connect your blog to popular social networking sites and automatically share new posts with your friends.', 'jetpack' ) ?> |
|
172
|
|
|
<?php esc_html_e( 'You can make a connection for just yourself or for all users on your blog. Shared connections are marked with the (Shared) text.', 'jetpack' ); ?> |
|
173
|
|
|
</p> |
|
174
|
|
|
|
|
175
|
|
|
<?php |
|
176
|
|
|
if ( $this->in_jetpack ) { |
|
177
|
|
|
$doc_link = "http://jetpack.com/support/publicize/"; |
|
178
|
|
|
} else { |
|
179
|
|
|
$doc_link = "http://en.support.wordpress.com/publicize/"; |
|
180
|
|
|
} |
|
181
|
|
|
?> |
|
182
|
|
|
|
|
183
|
|
|
<p>→ <a href="<?php echo esc_url( $doc_link ); ?>" rel="noopener noreferrer" target="_blank"><?php esc_html_e( 'More information on using Publicize.', 'jetpack' ); ?></a></p> |
|
184
|
|
|
|
|
185
|
|
|
<div id="publicize-services-block"> |
|
186
|
|
|
<?php |
|
187
|
|
|
$services = $this->publicize->get_services( 'all' ); |
|
188
|
|
|
$total_num_of_services = count ( $services ); |
|
189
|
|
|
$service_num = 0;?> |
|
190
|
|
|
|
|
191
|
|
|
<div class='left'> |
|
192
|
|
|
|
|
193
|
|
|
<?php |
|
194
|
|
|
foreach ( $services as $service_name => $service ) : |
|
195
|
|
|
// do not display any service that cannot be connected anymore (deprecated). |
|
196
|
|
|
$connect_url = $this->publicize->can_connect_service( $service_name ) ? |
|
197
|
|
|
$this->publicize->connect_url( $service_name ) : |
|
198
|
|
|
null; |
|
199
|
|
|
|
|
200
|
|
|
if ( $service_num == ( round ( ( $total_num_of_services / 2 ), 0 ) ) ) |
|
201
|
|
|
echo "</div><div class='right'>"; |
|
202
|
|
|
$service_num++; |
|
203
|
|
|
?> |
|
204
|
|
|
<div class="publicize-service-entry" <?php if ( $service_num > 0 ): ?>class="connected"<?php endif; ?> > |
|
205
|
|
|
<div id="<?php echo esc_attr( $service_name ); ?>" class="publicize-service-left"> |
|
206
|
|
|
<?php if ( $connect_url ): ?> |
|
|
|
|
|
|
207
|
|
|
<a href="<?php echo esc_url( $connect_url ); ?>" id="service-link-<?php echo esc_attr( $service_name ); ?>" target="_top"><?php echo $this->publicize->get_service_label( $service_name ); ?></a> |
|
208
|
|
|
<?php else: ?> |
|
209
|
|
|
<span><?php echo $this->publicize->get_service_label( $service_name ); ?></span> |
|
210
|
|
|
<?php endif; ?> |
|
211
|
|
|
</div> |
|
212
|
|
|
|
|
213
|
|
|
|
|
214
|
|
|
<div class="publicize-service-right"> |
|
215
|
|
|
<?php if ( $this->publicize->is_enabled( $service_name ) && $connections = $this->publicize->get_connections( $service_name ) ) : ?> |
|
216
|
|
|
<ul> |
|
217
|
|
|
<?php |
|
218
|
|
|
foreach( $connections as $c ) : |
|
219
|
|
|
$id = $this->publicize->get_connection_id( $c ); |
|
220
|
|
|
$disconnect_url = $this->publicize->disconnect_url( $service_name, $id ); |
|
221
|
|
|
|
|
222
|
|
|
$cmeta = $this->publicize->get_connection_meta( $c ); |
|
223
|
|
|
$profile_link = $this->publicize->get_profile_link( $service_name, $c ); |
|
224
|
|
|
$connection_display = $this->publicize->get_display_name( $service_name, $c ); |
|
225
|
|
|
|
|
226
|
|
|
$options_nonce = wp_create_nonce( 'options_page_' . $service_name . '_' . $id ); ?> |
|
227
|
|
|
|
|
228
|
|
|
<?php if ( $this->publicize->show_options_popup( $service_name, $c ) ): ?> |
|
229
|
|
|
<script type="text/javascript"> |
|
230
|
|
|
jQuery(document).ready( function($) { |
|
231
|
|
|
showOptionsPage.call( |
|
232
|
|
|
this, |
|
233
|
|
|
'<?php echo esc_js( $service_name ); ?>', |
|
234
|
|
|
'<?php echo esc_js( $options_nonce ); ?>', |
|
235
|
|
|
'<?php echo esc_js( $id ); ?>' |
|
236
|
|
|
); |
|
237
|
|
|
} ); |
|
238
|
|
|
</script> |
|
239
|
|
|
<?php endif; ?> |
|
240
|
|
|
|
|
241
|
|
|
<li class="publicize-connection" data-connection-id="<?php echo esc_attr( $id ); ?>"> |
|
242
|
|
|
<?php esc_html_e( 'Connected as:', 'jetpack' ); ?> |
|
243
|
|
|
<?php |
|
244
|
|
|
if ( !empty( $profile_link ) ) : ?> |
|
245
|
|
|
<a class="publicize-profile-link" href="<?php echo esc_url( $profile_link ); ?>" target="_top"> |
|
246
|
|
|
<?php echo esc_html( $connection_display ); ?> |
|
247
|
|
|
</a><?php |
|
248
|
|
|
else : |
|
249
|
|
|
echo esc_html( $connection_display ); |
|
250
|
|
|
endif; |
|
251
|
|
|
?> |
|
252
|
|
|
|
|
253
|
|
|
<?php if ( 0 == $cmeta['connection_data']['user_id'] ) : ?> |
|
254
|
|
|
<small>(<?php esc_html_e( 'Shared', 'jetpack' ); ?>)</small> |
|
255
|
|
|
|
|
256
|
|
|
<?php if ( current_user_can( $this->publicize->GLOBAL_CAP ) ) : ?> |
|
257
|
|
|
<a class="pub-disconnect-button" title="<?php esc_html_e( 'Disconnect', 'jetpack' ); ?>" href="<?php echo esc_url( $disconnect_url ); ?>" target="_top">×</a> |
|
258
|
|
|
<?php endif; ?> |
|
259
|
|
|
|
|
260
|
|
|
<?php else : ?> |
|
261
|
|
|
<a class="pub-disconnect-button" title="<?php esc_html_e( 'Disconnect', 'jetpack' ); ?>" href="<?php echo esc_url( $disconnect_url ); ?>" target="_top">×</a> |
|
262
|
|
|
<?php endif; ?> |
|
263
|
|
|
|
|
264
|
|
|
<br/> |
|
265
|
|
|
<div class="pub-connection-test test-in-progress" id="pub-connection-test-<?php echo esc_attr( $id ); ?>" > |
|
266
|
|
|
</div> |
|
267
|
|
|
</li> |
|
268
|
|
|
|
|
269
|
|
|
<?php |
|
270
|
|
|
endforeach; |
|
271
|
|
|
?> |
|
272
|
|
|
</ul> |
|
273
|
|
|
<?php endif; ?> |
|
274
|
|
|
|
|
275
|
|
|
<?php |
|
276
|
|
|
if ( $connect_url ) { |
|
|
|
|
|
|
277
|
|
|
$connections = $this->publicize->get_connections( $service_name ); |
|
278
|
|
|
if ( empty( $connections ) ) { |
|
279
|
|
|
printf( |
|
280
|
|
|
'<a id="%1$s" class="publicize-add-connection button" href="%2$s" target="_top">%3$s</a>', |
|
281
|
|
|
esc_attr( $service_name ), |
|
282
|
|
|
esc_url( $connect_url ), |
|
283
|
|
|
esc_html__( 'Connect', 'jetpack' ) |
|
284
|
|
|
); |
|
285
|
|
|
} else { |
|
286
|
|
|
printf( |
|
287
|
|
|
'<a id="%1$s" class="publicize-add-connection button add-new" href="%2$s" target="_top">%3$s</a>', |
|
288
|
|
|
esc_attr( $service_name ), |
|
289
|
|
|
esc_url( $connect_url ), |
|
290
|
|
|
esc_html__( 'Add New', 'jetpack' ) |
|
291
|
|
|
); |
|
292
|
|
|
} |
|
293
|
|
|
} else { |
|
294
|
|
|
echo '<div class="publicize-disabled-service-message">'; |
|
295
|
|
|
esc_html_e( 'Google+ support is being removed.', 'jetpack' ); |
|
296
|
|
|
printf( |
|
297
|
|
|
' <a href="javascript:void(0)" id="jetpack-gplus-deprecated-notice">%1$s<span class="dashicons dashicons-info"></span></a>', |
|
298
|
|
|
esc_html__( 'Why?', 'jetpack' ) |
|
299
|
|
|
); |
|
300
|
|
|
echo '</div>'; |
|
301
|
|
|
} |
|
302
|
|
|
?> |
|
303
|
|
|
</div> |
|
304
|
|
|
</div> |
|
305
|
|
|
<?php endforeach; ?> |
|
306
|
|
|
</div> |
|
307
|
|
|
<script> |
|
308
|
|
|
(function($){ |
|
309
|
|
|
$('.pub-disconnect-button').on('click', function(e){ if ( confirm( '<?php echo esc_js( __( 'Are you sure you want to stop Publicizing posts to this connection?', 'jetpack' ) ); ?>' ) ) { |
|
310
|
|
|
return true; |
|
311
|
|
|
} else { |
|
312
|
|
|
e.preventDefault(); |
|
313
|
|
|
return false; |
|
314
|
|
|
} |
|
315
|
|
|
}); |
|
316
|
|
|
})(jQuery); |
|
317
|
|
|
</script> |
|
318
|
|
|
<?php $this->google_plus_shut_down_tooltip_script(); ?> |
|
319
|
|
|
</div> |
|
320
|
|
|
|
|
321
|
|
|
<?php wp_nonce_field( "wpas_posts_{$_blog_id}", "_wpas_posts_{$_blog_id}_nonce" ); ?> |
|
322
|
|
|
<input type="hidden" id="wpas_ajax_blog_id" name="wpas_ajax_blog_id" value="<?php echo $_blog_id; ?>" /> |
|
323
|
|
|
</form><?php |
|
324
|
|
|
|
|
325
|
|
|
} |
|
326
|
|
|
|
|
327
|
|
|
public static function global_checkbox( $service_name, $id ) { |
|
328
|
|
|
global $publicize; |
|
329
|
|
|
if ( current_user_can( $publicize->GLOBAL_CAP ) ) : ?> |
|
330
|
|
|
<p> |
|
331
|
|
|
<input id="globalize_<?php echo $service_name; ?>" type="checkbox" name="global" value="<?php echo wp_create_nonce( 'publicize-globalize-' . $id ) ?>" /> |
|
332
|
|
|
<label for="globalize_<?php echo $service_name; ?>"><?php _e( 'Make this connection available to all users of this blog?', 'jetpack' ); ?></label> |
|
333
|
|
|
</p> |
|
334
|
|
|
<?php endif; |
|
335
|
|
|
} |
|
336
|
|
|
|
|
337
|
|
|
function broken_connection( $service_name, $id ) { ?> |
|
338
|
|
|
<div id="thickbox-content"> |
|
339
|
|
|
<div class='error'> |
|
340
|
|
|
<p><?php printf( |
|
341
|
|
|
/* translators: %s: Service Name (Facebook, Twitter, ...) */ |
|
342
|
|
|
__( 'There was a problem connecting to %s. Please disconnect and try again.', 'jetpack' ), |
|
343
|
|
|
Publicize::get_service_label( $service_name ) |
|
344
|
|
|
); ?></p> |
|
345
|
|
|
</div> |
|
346
|
|
|
</div><?php |
|
347
|
|
|
} |
|
348
|
|
|
|
|
349
|
|
|
public static function options_page_other( $service_name ) { |
|
350
|
|
|
// Nonce check |
|
351
|
|
|
check_admin_referer( "options_page_{$service_name}_" . $_REQUEST['connection'] ); |
|
352
|
|
|
?> |
|
353
|
|
|
<div id="thickbox-content"> |
|
354
|
|
|
<?php |
|
355
|
|
|
ob_start(); |
|
356
|
|
|
Publicize_UI::connected_notice( $service_name ); |
|
357
|
|
|
$update_notice = ob_get_clean(); |
|
358
|
|
|
if ( ! empty( $update_notice ) ) |
|
359
|
|
|
echo $update_notice; |
|
360
|
|
|
?> |
|
361
|
|
|
|
|
362
|
|
|
<?php Publicize_UI::global_checkbox( $service_name, $_REQUEST['connection'] ); ?> |
|
363
|
|
|
|
|
364
|
|
|
<p style="text-align: center;"> |
|
365
|
|
|
<input type="submit" value="<?php esc_attr_e( 'OK', 'jetpack' ) ?>" class="button <?php echo $service_name; ?>-options save-options" name="save" data-connection="<?php echo esc_attr( $_REQUEST['connection'] ); ?>" rel="<?php echo wp_create_nonce( 'save_'.$service_name.'_token_' . $_REQUEST['connection'] ) ?>" /> |
|
366
|
|
|
</p> <br /> |
|
367
|
|
|
</div> |
|
368
|
|
|
<?php |
|
369
|
|
|
} |
|
370
|
|
|
|
|
371
|
|
|
/** |
|
372
|
|
|
* CSS for styling the publicize message box and counter that displays on the post page. |
|
373
|
|
|
* There is also some JavaScript for length counting and some basic display effects. |
|
374
|
|
|
*/ |
|
375
|
|
|
function post_page_metabox_assets() { |
|
376
|
|
|
global $post; |
|
377
|
|
|
$user_id = empty( $post->post_author ) ? $GLOBALS['user_ID'] : $post->post_author; |
|
|
|
|
|
|
378
|
|
|
|
|
379
|
|
|
$default_prefix = $this->publicize->default_prefix; |
|
380
|
|
|
$default_prefix = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_prefix ) ); |
|
381
|
|
|
|
|
382
|
|
|
$default_message = $this->publicize->default_message; |
|
383
|
|
|
$default_message = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_message ) ); |
|
384
|
|
|
|
|
385
|
|
|
$default_suffix = $this->publicize->default_suffix; |
|
386
|
|
|
$default_suffix = preg_replace( '/%([0-9])\$s/', "' + %\\1\$s + '", esc_js( $default_suffix ) ); |
|
387
|
|
|
|
|
388
|
|
|
$max_length = defined( 'JETPACK_PUBLICIZE_TWITTER_LENGTH' ) ? JETPACK_PUBLICIZE_TWITTER_LENGTH : 280; |
|
389
|
|
|
$max_length = $max_length - 24; // t.co link, space |
|
390
|
|
|
|
|
391
|
|
|
// for deprecation tooltip |
|
392
|
|
|
wp_enqueue_style( 'wp-pointer' ); |
|
393
|
|
|
wp_enqueue_script( 'wp-pointer' ); |
|
394
|
|
|
|
|
395
|
|
|
$this->google_plus_shut_down_tooltip_script(); |
|
396
|
|
|
|
|
397
|
|
|
?> |
|
398
|
|
|
|
|
399
|
|
|
<script type="text/javascript"> |
|
400
|
|
|
jQuery( function($) { |
|
401
|
|
|
var wpasTitleCounter = $( '#wpas-title-counter' ), |
|
402
|
|
|
wpasTwitterCheckbox = $( '.wpas-submit-twitter' ).length, |
|
403
|
|
|
postTitle = $( '#title' ), |
|
404
|
|
|
wpasTitle = $( '#wpas-title' ).keyup( function() { |
|
405
|
|
|
var postTitleVal, |
|
406
|
|
|
length = wpasTitle.val().length; |
|
407
|
|
|
|
|
408
|
|
|
if ( ! length ) { |
|
409
|
|
|
length = wpasTitle.attr( 'placeholder' ).length; |
|
410
|
|
|
} |
|
411
|
|
|
|
|
412
|
|
|
wpasTitleCounter.text( length ).trigger( 'change' ); |
|
413
|
|
|
} ), |
|
414
|
|
|
authClick = false; |
|
415
|
|
|
|
|
416
|
|
|
wpasTitleCounter.on( 'change', function( e ) { |
|
417
|
|
|
if ( wpasTwitterCheckbox && parseInt( $( e.currentTarget ).text(), 10 ) > <?php echo (int) $max_length; ?> ) { |
|
418
|
|
|
wpasTitleCounter.addClass( 'wpas-twitter-length-limit' ); |
|
419
|
|
|
} else { |
|
420
|
|
|
wpasTitleCounter.removeClass( 'wpas-twitter-length-limit' ); |
|
421
|
|
|
} |
|
422
|
|
|
} ); |
|
423
|
|
|
|
|
424
|
|
|
// Keep the postTitle and the placeholder in sync |
|
425
|
|
|
postTitle.on( 'keyup', function( e ) { |
|
426
|
|
|
var url = $( '#sample-permalink' ).text(); |
|
427
|
|
|
var defaultMessage = $.trim( '<?php printf( $default_prefix, 'url' ); printf( $default_message, 'e.currentTarget.value', 'url' ); printf( $default_suffix, 'url' ); ?>' ) |
|
428
|
|
|
.replace( /<[^>]+>/g,''); |
|
429
|
|
|
|
|
430
|
|
|
wpasTitle.attr( 'placeholder', defaultMessage ); |
|
431
|
|
|
wpasTitle.trigger( 'keyup' ); |
|
432
|
|
|
} ); |
|
433
|
|
|
|
|
434
|
|
|
// set the initial placeholder |
|
435
|
|
|
postTitle.trigger( 'keyup' ); |
|
436
|
|
|
|
|
437
|
|
|
// If a custom message has been provided, open the UI so the author remembers |
|
438
|
|
|
if ( wpasTitle.val() && ! wpasTitle.prop( 'disabled' ) && wpasTitle.attr( 'placeholder' ) !== wpasTitle.val() ) { |
|
439
|
|
|
$( '#publicize-form' ).show(); |
|
440
|
|
|
$( '#publicize-defaults' ).hide(); |
|
441
|
|
|
$( '#publicize-form-edit' ).hide(); |
|
442
|
|
|
} |
|
443
|
|
|
|
|
444
|
|
|
$('#publicize-disconnected-form-show').click( function() { |
|
445
|
|
|
$('#publicize-form').slideDown( 'fast' ); |
|
446
|
|
|
$(this).hide(); |
|
447
|
|
|
} ); |
|
448
|
|
|
|
|
449
|
|
|
$('#publicize-disconnected-form-hide').click( function() { |
|
450
|
|
|
$('#publicize-form').slideUp( 'fast' ); |
|
451
|
|
|
$('#publicize-disconnected-form-show').show(); |
|
452
|
|
|
} ); |
|
453
|
|
|
|
|
454
|
|
|
$('#publicize-form-edit').click( function() { |
|
455
|
|
|
$('#publicize-form').slideDown( 'fast', function() { |
|
456
|
|
|
var selBeg = 0, selEnd = 0; |
|
457
|
|
|
wpasTitle.focus(); |
|
458
|
|
|
|
|
459
|
|
|
if ( ! wpasTitle.text() ) { |
|
460
|
|
|
wpasTitle.text( wpasTitle.attr( 'placeholder' ) ); |
|
461
|
|
|
|
|
462
|
|
|
selBeg = wpasTitle.text().indexOf( postTitle.val() ); |
|
463
|
|
|
if ( selBeg < 0 ) { |
|
464
|
|
|
selBeg = 0; |
|
465
|
|
|
} else { |
|
466
|
|
|
selEnd = selBeg + postTitle.val().length; |
|
467
|
|
|
} |
|
468
|
|
|
|
|
469
|
|
|
var domObj = wpasTitle.get(0); |
|
470
|
|
|
if ( domObj.setSelectionRange ) { |
|
471
|
|
|
domObj.setSelectionRange( selBeg, selEnd ); |
|
472
|
|
|
} else if ( domObj.createTextRange ) { |
|
473
|
|
|
var r = domObj.createTextRange(); |
|
474
|
|
|
r.moveStart( 'character', selBeg ); |
|
475
|
|
|
r.moveEnd( 'character', selEnd ); |
|
476
|
|
|
r.select(); |
|
477
|
|
|
} |
|
478
|
|
|
} |
|
479
|
|
|
} ); |
|
480
|
|
|
|
|
481
|
|
|
$('#publicize-defaults').hide(); |
|
482
|
|
|
$(this).hide(); |
|
483
|
|
|
return false; |
|
484
|
|
|
} ); |
|
485
|
|
|
|
|
486
|
|
|
$('#publicize-form-hide').click( function() { |
|
487
|
|
|
var newList = $.map( $('#publicize-form').slideUp( 'fast' ).find( ':checked' ), function( el ) { |
|
488
|
|
|
return $.trim( $(el).parent( 'label' ).text() ); |
|
489
|
|
|
} ); |
|
490
|
|
|
$('#publicize-defaults').html( '<strong>' + newList.join( '</strong>, <strong>' ) + '</strong>' ).show(); |
|
491
|
|
|
$('#publicize-form-edit').show(); |
|
492
|
|
|
return false; |
|
493
|
|
|
} ); |
|
494
|
|
|
|
|
495
|
|
|
$('.authorize-link').click( function() { |
|
496
|
|
|
if ( authClick ) { |
|
497
|
|
|
return false; |
|
498
|
|
|
} |
|
499
|
|
|
authClick = true; |
|
500
|
|
|
$(this).after( '<img src="images/loading.gif" class="alignleft" style="margin: 0 .5em" />' ); |
|
501
|
|
|
$.ajaxSetup( { async: false } ); |
|
502
|
|
|
|
|
503
|
|
|
if ( window.wp && window.wp.autosave ) { |
|
504
|
|
|
window.wp.autosave.server.triggerSave(); |
|
505
|
|
|
} else { |
|
506
|
|
|
autosave(); |
|
507
|
|
|
} |
|
508
|
|
|
|
|
509
|
|
|
return true; |
|
510
|
|
|
} ); |
|
511
|
|
|
|
|
512
|
|
|
$( '.pub-service' ).click( function() { |
|
513
|
|
|
var service = $(this).data( 'service' ), |
|
514
|
|
|
fakebox = '<input id="wpas-submit-' + service + '" type="hidden" value="1" name="wpas[submit][' + service + ']" />'; |
|
515
|
|
|
$( '#add-publicize-check' ).append( fakebox ); |
|
516
|
|
|
} ); |
|
517
|
|
|
|
|
518
|
|
|
publicizeConnTestStart = function() { |
|
519
|
|
|
$( '#pub-connection-tests' ) |
|
520
|
|
|
.removeClass( 'below-h2' ) |
|
521
|
|
|
.removeClass( 'error' ) |
|
522
|
|
|
.removeClass( 'publicize-token-refresh-message' ) |
|
523
|
|
|
.addClass( 'test-in-progress' ) |
|
524
|
|
|
.html( '' ); |
|
525
|
|
|
$.post( ajaxurl, { action: 'test_publicize_conns' }, publicizeConnTestComplete ); |
|
526
|
|
|
} |
|
527
|
|
|
|
|
528
|
|
|
publicizeConnRefreshClick = function( event ) { |
|
529
|
|
|
event.preventDefault(); |
|
530
|
|
|
var popupURL = event.currentTarget.href; |
|
531
|
|
|
var popupTitle = event.currentTarget.title; |
|
532
|
|
|
// open a popup window |
|
533
|
|
|
// when it is closed, kick off the tests again |
|
534
|
|
|
var popupWin = window.open( popupURL, popupTitle, '' ); |
|
535
|
|
|
var popupWinTimer= window.setInterval( function() { |
|
536
|
|
|
if ( popupWin.closed !== false ) { |
|
537
|
|
|
window.clearInterval( popupWinTimer ); |
|
538
|
|
|
publicizeConnTestStart(); |
|
539
|
|
|
} |
|
540
|
|
|
}, 500 ); |
|
541
|
|
|
} |
|
542
|
|
|
|
|
543
|
|
|
publicizeConnTestComplete = function( response ) { |
|
544
|
|
|
var testsSelector = $( '#pub-connection-tests' ); |
|
545
|
|
|
testsSelector |
|
546
|
|
|
.removeClass( 'test-in-progress' ) |
|
547
|
|
|
.removeClass( 'below-h2' ) |
|
548
|
|
|
.removeClass( 'error' ) |
|
549
|
|
|
.removeClass( 'publicize-token-refresh-message' ) |
|
550
|
|
|
.html( '' ); |
|
551
|
|
|
|
|
552
|
|
|
// If any of the tests failed, show some stuff |
|
553
|
|
|
var somethingShownAlready = false; |
|
554
|
|
|
var facebookNotice = false; |
|
555
|
|
|
$.each( response.data, function( index, testResult ) { |
|
556
|
|
|
// find the li for this connection |
|
557
|
|
|
if ( ! testResult.connectionTestPassed && testResult.userCanRefresh ) { |
|
558
|
|
|
if ( ! somethingShownAlready ) { |
|
559
|
|
|
testsSelector |
|
560
|
|
|
.addClass( 'below-h2' ) |
|
561
|
|
|
.addClass( 'error' ) |
|
562
|
|
|
.addClass( 'publicize-token-refresh-message' ) |
|
563
|
|
|
.append( "<p><?php echo esc_html( __( 'Before you hit Publish, please refresh the following connection(s) to make sure we can Publicize your post:', 'jetpack' ) ); ?></p>" ); |
|
564
|
|
|
somethingShownAlready = true; |
|
565
|
|
|
} |
|
566
|
|
|
|
|
567
|
|
|
if ( testResult.userCanRefresh ) { |
|
568
|
|
|
testsSelector.append( '<p/>' ); |
|
569
|
|
|
$( '<a/>', { |
|
570
|
|
|
'class' : 'pub-refresh-button button', |
|
571
|
|
|
'title' : testResult.refreshText, |
|
572
|
|
|
'href' : testResult.refreshURL, |
|
573
|
|
|
'text' : testResult.refreshText, |
|
574
|
|
|
'target' : '_refresh_' + testResult.serviceName |
|
575
|
|
|
} ) |
|
576
|
|
|
.appendTo( testsSelector.children().last() ) |
|
577
|
|
|
.click( publicizeConnRefreshClick ); |
|
578
|
|
|
} |
|
579
|
|
|
} |
|
580
|
|
|
|
|
581
|
|
|
if( ! testResult.connectionTestPassed && ! testResult.userCanRefresh ) { |
|
582
|
|
|
$( '#wpas-submit-' + testResult.unique_id ).prop( "checked", false ).prop( "disabled", true ); |
|
583
|
|
|
if ( ! facebookNotice ) { |
|
584
|
|
|
var message = '<p>' |
|
585
|
|
|
+ testResult.connectionTestMessage |
|
586
|
|
|
+ '</p><p>' |
|
587
|
|
|
+ ' <a class="button" href="<?php echo esc_url( $this->publicize_settings_url ); ?>" rel="noopener noreferrer" target="_blank">' |
|
588
|
|
|
+ '<?php echo esc_html( __( 'Update Your Sharing Settings' ,'jetpack' ) ); ?>' |
|
589
|
|
|
+ '</a>' |
|
590
|
|
|
+ '<p>'; |
|
591
|
|
|
|
|
592
|
|
|
testsSelector |
|
593
|
|
|
.addClass( 'below-h2' ) |
|
594
|
|
|
.addClass( 'error' ) |
|
595
|
|
|
.addClass( 'publicize-token-refresh-message' ) |
|
596
|
|
|
.append( message ); |
|
597
|
|
|
facebookNotice = true; |
|
598
|
|
|
} |
|
599
|
|
|
} |
|
600
|
|
|
} ); |
|
601
|
|
|
} |
|
602
|
|
|
|
|
603
|
|
|
$( document ).ready( function() { |
|
604
|
|
|
// If we have the #pub-connection-tests div present, kick off the connection test |
|
605
|
|
|
if ( $( '#pub-connection-tests' ).length ) { |
|
606
|
|
|
publicizeConnTestStart(); |
|
607
|
|
|
} |
|
608
|
|
|
} ); |
|
609
|
|
|
|
|
610
|
|
|
} ); |
|
611
|
|
|
</script> |
|
612
|
|
|
|
|
613
|
|
|
<style type="text/css"> |
|
614
|
|
|
#publicize { |
|
615
|
|
|
line-height: 1.5; |
|
616
|
|
|
} |
|
617
|
|
|
#publicize ul { |
|
618
|
|
|
margin: 4px 0 4px 6px; |
|
619
|
|
|
} |
|
620
|
|
|
#publicize li { |
|
621
|
|
|
margin: 0; |
|
622
|
|
|
} |
|
623
|
|
|
#publicize textarea { |
|
624
|
|
|
margin: 4px 0 0; |
|
625
|
|
|
width: 100% |
|
626
|
|
|
} |
|
627
|
|
|
#publicize ul.not-connected { |
|
628
|
|
|
list-style: square; |
|
629
|
|
|
padding-left: 1em; |
|
630
|
|
|
} |
|
631
|
|
|
#publicize-title:before { |
|
632
|
|
|
content: "\f237"; |
|
633
|
|
|
font: normal 20px/1 dashicons; |
|
634
|
|
|
speak: none; |
|
635
|
|
|
margin-left: -1px; |
|
636
|
|
|
padding-right: 3px; |
|
637
|
|
|
vertical-align: top; |
|
638
|
|
|
-webkit-font-smoothing: antialiased; |
|
639
|
|
|
color: #82878c; |
|
640
|
|
|
} |
|
641
|
|
|
.post-new-php .authorize-link, .post-php .authorize-link { |
|
642
|
|
|
line-height: 1.5em; |
|
643
|
|
|
} |
|
644
|
|
|
.post-new-php .authorize-message, .post-php .authorize-message { |
|
645
|
|
|
margin-bottom: 0; |
|
646
|
|
|
} |
|
647
|
|
|
#poststuff #publicize .updated p { |
|
648
|
|
|
margin: .5em 0; |
|
649
|
|
|
} |
|
650
|
|
|
.wpas-twitter-length-limit { |
|
651
|
|
|
color: red; |
|
652
|
|
|
} |
|
653
|
|
|
.publicize-disabled-service-message .dashicons { |
|
654
|
|
|
font-size: 16px; |
|
655
|
|
|
text-decoration: none; |
|
656
|
|
|
} |
|
657
|
|
|
</style><?php |
|
658
|
|
|
} |
|
659
|
|
|
|
|
660
|
|
|
/** |
|
661
|
|
|
* @param string $service_label Service's human-readable Label ("Facebook", "Twitter", ...) |
|
662
|
|
|
* @param string $display_name Connection's human-readable Username ("@jetpack", ...) |
|
663
|
|
|
* @return string |
|
664
|
|
|
*/ |
|
665
|
|
|
private function connection_label( $service_label, $display_name ) { |
|
666
|
|
|
return sprintf( |
|
667
|
|
|
/* translators: %1$s: Service Name (Facebook, Twitter, ...), %2$s: Username on Service (@jetpack, ...) */ |
|
668
|
|
|
__( '%1$s: %2$s', 'jetpack' ), |
|
669
|
|
|
$service_label, |
|
670
|
|
|
$display_name |
|
671
|
|
|
); |
|
672
|
|
|
} |
|
673
|
|
|
|
|
674
|
|
|
/** |
|
675
|
|
|
* Controls the metabox that is displayed on the post page |
|
676
|
|
|
* Allows the user to customize the message that will be sent out to the social network, as well as pick which |
|
677
|
|
|
* networks to publish to. Also displays the character counter and some other information. |
|
678
|
|
|
*/ |
|
679
|
|
|
function post_page_metabox() { |
|
680
|
|
|
global $post; |
|
681
|
|
|
|
|
682
|
|
|
if ( ! $this->publicize->post_type_is_publicizeable( $post->post_type ) ) |
|
683
|
|
|
return; |
|
684
|
|
|
|
|
685
|
|
|
$user_id = empty( $post->post_author ) ? $GLOBALS['user_ID'] : $post->post_author; |
|
|
|
|
|
|
686
|
|
|
$connections_data = $this->publicize->get_filtered_connection_data(); |
|
687
|
|
|
|
|
688
|
|
|
$available_services = $this->publicize->get_services( 'all' ); |
|
689
|
|
|
|
|
690
|
|
|
if ( ! is_array( $available_services ) ) |
|
691
|
|
|
$available_services = array(); |
|
692
|
|
|
|
|
693
|
|
|
if ( ! is_array( $connections_data ) ) |
|
694
|
|
|
$connections_data = array(); |
|
695
|
|
|
?> |
|
696
|
|
|
<div id="publicize" class="misc-pub-section misc-pub-section-last"> |
|
697
|
|
|
<span id="publicize-title"> |
|
698
|
|
|
<?php |
|
699
|
|
|
esc_html_e( 'Publicize:', 'jetpack' ); |
|
700
|
|
|
|
|
701
|
|
|
if ( 0 < count( $connections_data ) ) : |
|
702
|
|
|
$publicize_form = $this->get_metabox_form_connected( $connections_data ); |
|
703
|
|
|
|
|
704
|
|
|
$labels = array(); |
|
705
|
|
|
$has_google_plus = false; |
|
706
|
|
|
foreach ( $connections_data as $connection_data ) { |
|
707
|
|
|
if ( ! $connection_data['enabled'] ) { |
|
708
|
|
|
continue; |
|
709
|
|
|
} |
|
710
|
|
|
|
|
711
|
|
|
if ( 'google_plus' === $connection_data['service_name'] ) { |
|
712
|
|
|
$has_google_plus = true; |
|
713
|
|
|
} |
|
714
|
|
|
|
|
715
|
|
|
$labels[] = sprintf( |
|
716
|
|
|
'<strong>%s</strong>', |
|
717
|
|
|
esc_html( $this->connection_label( $connection_data['service_label'], $connection_data['display_name'] ) ) |
|
718
|
|
|
); |
|
719
|
|
|
} |
|
720
|
|
|
|
|
721
|
|
|
?> |
|
722
|
|
|
<span id="publicize-defaults"><?php echo join( ', ', $labels ); ?></span> |
|
723
|
|
|
<?php if ( $has_google_plus ) : ?> |
|
724
|
|
|
<div class="notice inline notice-warning publicize-disabled-service-message"> |
|
725
|
|
|
<p> |
|
726
|
|
|
<strong><?php esc_html_e( 'Google+ support is being removed', 'jetpack' ); ?></strong> |
|
727
|
|
|
<a href="javascript:void(0)" id="jetpack-gplus-deprecated-notice"> |
|
728
|
|
|
<?php esc_html_e( 'Why?', 'jetpack' ); ?> |
|
729
|
|
|
<span class="dashicons dashicons-info"></span> |
|
730
|
|
|
</a> |
|
731
|
|
|
</p> |
|
732
|
|
|
</div> |
|
733
|
|
|
<?php endif; ?> |
|
734
|
|
|
<a href="#" id="publicize-form-edit"><?php esc_html_e( 'Edit', 'jetpack' ); ?></a> <a href="<?php echo esc_url( $this->publicize_settings_url ); ?>" rel="noopener noreferrer" target="_blank"><?php _e( 'Settings', 'jetpack' ); ?></a><br /> |
|
735
|
|
|
<?php |
|
736
|
|
|
|
|
737
|
|
|
else : |
|
738
|
|
|
$publicize_form = $this->get_metabox_form_disconnected( $available_services ); |
|
739
|
|
|
|
|
740
|
|
|
?> |
|
741
|
|
|
<strong><?php echo __( 'Not Connected', 'jetpack' ); ?></strong> |
|
742
|
|
|
<a href="#" id="publicize-disconnected-form-show"><?php esc_html_e( 'Edit', 'jetpack' ); ?></a><br /> |
|
743
|
|
|
<?php |
|
744
|
|
|
|
|
745
|
|
|
endif; |
|
746
|
|
|
?> |
|
747
|
|
|
</span> |
|
748
|
|
|
<?php |
|
749
|
|
|
/** |
|
750
|
|
|
* Filter the Publicize details form. |
|
751
|
|
|
* |
|
752
|
|
|
* @module publicize |
|
753
|
|
|
* |
|
754
|
|
|
* @since 2.0.0 |
|
755
|
|
|
* |
|
756
|
|
|
* @param string $publicize_form Publicize Details form appearing above Publish button in the editor. |
|
757
|
|
|
*/ |
|
758
|
|
|
echo apply_filters( 'publicize_form', $publicize_form ); |
|
759
|
|
|
?> |
|
760
|
|
|
</div> <?php // #publicize |
|
761
|
|
|
} |
|
762
|
|
|
|
|
763
|
|
|
/** |
|
764
|
|
|
* Generates HTML content for connections form. |
|
765
|
|
|
* |
|
766
|
|
|
* @since 6.7 |
|
767
|
|
|
* |
|
768
|
|
|
* @global WP_Post $post The current post instance being published. |
|
769
|
|
|
* |
|
770
|
|
|
* @param array $connections_data |
|
771
|
|
|
* |
|
772
|
|
|
* @return array { |
|
773
|
|
|
* Array of content for generating connection form. |
|
774
|
|
|
* |
|
775
|
|
|
* @type string HTML content of form |
|
776
|
|
|
* @type array { |
|
777
|
|
|
* Array of connection labels for active connections only. |
|
778
|
|
|
* |
|
779
|
|
|
* @type string Connection label string. |
|
780
|
|
|
* } |
|
781
|
|
|
* } |
|
782
|
|
|
*/ |
|
783
|
|
|
private function get_metabox_form_connected( $connections_data ) { |
|
784
|
|
|
global $post; |
|
785
|
|
|
|
|
786
|
|
|
$all_done = $this->publicize->post_is_done_sharing(); |
|
787
|
|
|
$all_connections_done = true; |
|
788
|
|
|
|
|
789
|
|
|
ob_start(); |
|
790
|
|
|
|
|
791
|
|
|
?> |
|
792
|
|
|
<div id="publicize-form" class="hide-if-js"> |
|
793
|
|
|
<ul> |
|
794
|
|
|
<?php |
|
795
|
|
|
|
|
796
|
|
|
foreach ( $connections_data as $connection_data ) { |
|
797
|
|
|
$all_connections_done = $all_connections_done && $connection_data['done']; |
|
798
|
|
|
?> |
|
799
|
|
|
|
|
800
|
|
|
<li> |
|
801
|
|
|
<label for="wpas-submit-<?php echo esc_attr( $connection_data['unique_id'] ); ?>"> |
|
802
|
|
|
<input |
|
803
|
|
|
type="checkbox" |
|
804
|
|
|
name="wpas[submit][<?php echo esc_attr( $connection_data['unique_id'] ); ?>]" |
|
805
|
|
|
id="wpas-submit-<?php echo esc_attr( $connection_data['unique_id'] ); ?>" |
|
806
|
|
|
class="wpas-submit-<?php echo esc_attr( $connection_data['service_name'] ); ?>" |
|
807
|
|
|
value="1" |
|
808
|
|
|
<?php |
|
809
|
|
|
checked( true, $connection_data['enabled'] ); |
|
810
|
|
|
disabled( false, $connection_data['toggleable'] ); |
|
811
|
|
|
?> |
|
812
|
|
|
/> |
|
813
|
|
|
<?php if ( $connection_data['enabled'] && ! $connection_data['toggleable'] ) : // Need to submit a value to force a global connection to POST ?> |
|
814
|
|
|
<input |
|
815
|
|
|
type="hidden" |
|
816
|
|
|
name="wpas[submit][<?php echo esc_attr( $connection_data['unique_id'] ); ?>]" |
|
817
|
|
|
value="1" |
|
818
|
|
|
/> |
|
819
|
|
|
<?php endif; ?> |
|
820
|
|
|
|
|
821
|
|
|
<?php echo esc_html( $this->connection_label( $connection_data['service_label'], $connection_data['display_name'] ) ); ?> |
|
822
|
|
|
|
|
823
|
|
|
</label> |
|
824
|
|
|
</li> |
|
825
|
|
|
<?php |
|
826
|
|
|
} |
|
827
|
|
|
|
|
828
|
|
|
$title = get_post_meta( $post->ID, $this->publicize->POST_MESS, true ); |
|
829
|
|
|
if ( ! $title ) { |
|
830
|
|
|
$title = ''; |
|
831
|
|
|
} |
|
832
|
|
|
|
|
833
|
|
|
$all_done = $all_done || $all_connections_done; |
|
834
|
|
|
|
|
835
|
|
|
?> |
|
836
|
|
|
|
|
837
|
|
|
</ul> |
|
838
|
|
|
|
|
839
|
|
|
<label for="wpas-title"><?php _e( 'Custom Message:', 'jetpack' ); ?></label> |
|
840
|
|
|
<span id="wpas-title-counter" class="alignright hide-if-no-js">0</span> |
|
841
|
|
|
<textarea name="wpas_title" id="wpas-title"<?php disabled( $all_done ); ?>><?php echo esc_textarea( $title ); ?></textarea> |
|
842
|
|
|
<a href="#" class="hide-if-no-js button" id="publicize-form-hide"><?php esc_html_e( 'OK', 'jetpack' ); ?></a> |
|
843
|
|
|
<input type="hidden" name="wpas[0]" value="1" /> |
|
844
|
|
|
</div> |
|
845
|
|
|
|
|
846
|
|
|
<?php if ( ! $all_done ) : ?> |
|
847
|
|
|
<div id="pub-connection-tests"></div> |
|
848
|
|
|
<?php endif; ?> |
|
849
|
|
|
<?php // #publicize-form |
|
850
|
|
|
|
|
851
|
|
|
return ob_get_clean(); |
|
852
|
|
|
} |
|
853
|
|
|
|
|
854
|
|
|
private function get_metabox_form_disconnected( $available_services ) { |
|
855
|
|
|
ob_start(); |
|
856
|
|
|
?><div id="publicize-form" class="hide-if-js"> |
|
857
|
|
|
<div id="add-publicize-check" style="display: none;"></div> |
|
858
|
|
|
|
|
859
|
|
|
<?php _e( 'Connect to', 'jetpack' ); ?>: |
|
860
|
|
|
|
|
861
|
|
|
<ul class="not-connected"> |
|
862
|
|
|
<?php foreach ( $available_services as $service_name => $service ) : ?> |
|
863
|
|
|
<li> |
|
864
|
|
|
<a class="pub-service" data-service="<?php echo esc_attr( $service_name ); ?>" title="<?php echo esc_attr( sprintf( __( 'Connect and share your posts on %s', 'jetpack' ), $this->publicize->get_service_label( $service_name ) ) ); ?>" rel="noopener noreferrer" target="_blank" href="<?php echo esc_url( $this->publicize->connect_url( $service_name ) ); ?>"> |
|
865
|
|
|
<?php echo esc_html( $this->publicize->get_service_label( $service_name ) ); ?> |
|
866
|
|
|
</a> |
|
867
|
|
|
</li> |
|
868
|
|
|
<?php endforeach; ?> |
|
869
|
|
|
</ul> |
|
870
|
|
|
<a href="#" class="hide-if-no-js button" id="publicize-disconnected-form-hide"><?php esc_html_e( 'OK', 'jetpack' ); ?></a> |
|
871
|
|
|
</div><?php // #publicize-form |
|
872
|
|
|
return ob_get_clean(); |
|
873
|
|
|
} |
|
874
|
|
|
|
|
875
|
|
|
private function google_plus_shut_down_notice() { |
|
876
|
|
|
return wp_kses( |
|
877
|
|
|
sprintf( |
|
878
|
|
|
/* Translators: placeholder is a link to an announcement post on Google's blog. */ |
|
879
|
|
|
__( |
|
880
|
|
|
'<h3>Google+ Support is being removed</h3><p>Google recently <a href="%1$s" target="_blank">announced</a> that Google+ is shutting down in April 2019, and access via third-party tools like Jetpack will cease in March 2019.</p><p>For now, you can still post to Google+ using existing connections, but you cannot add new connections. The ability to post will be removed in early 2019.</p>', |
|
881
|
|
|
'jetpack' |
|
882
|
|
|
), |
|
883
|
|
|
esc_url( 'https://www.blog.google/technology/safety-security/expediting-changes-google-plus/' ) |
|
884
|
|
|
), |
|
885
|
|
|
array( |
|
886
|
|
|
'a' => array( |
|
887
|
|
|
'href' => true, |
|
888
|
|
|
'target' => true, |
|
889
|
|
|
), |
|
890
|
|
|
'h3' => true, |
|
891
|
|
|
'p' => true, |
|
892
|
|
|
) |
|
893
|
|
|
); |
|
894
|
|
|
} |
|
895
|
|
|
|
|
896
|
|
|
private function google_plus_shut_down_tooltip_script() { |
|
897
|
|
|
$google_plus_exp_msg = $this->google_plus_shut_down_notice(); |
|
898
|
|
|
?> |
|
899
|
|
|
<script> |
|
900
|
|
|
// deprecation tooltip |
|
901
|
|
|
(function($){ |
|
902
|
|
|
var setup = function() { |
|
903
|
|
|
$('#jetpack-gplus-deprecated-notice').first().pointer( |
|
904
|
|
|
{ |
|
905
|
|
|
content: decodeURIComponent( "<?php echo rawurlencode( $google_plus_exp_msg ); ?>" ), |
|
906
|
|
|
position: { |
|
907
|
|
|
edge: "right", |
|
908
|
|
|
align: "bottom" |
|
909
|
|
|
}, |
|
910
|
|
|
pointerClass: "wp-pointer arrow-bottom", |
|
911
|
|
|
pointerWidth: 420 |
|
912
|
|
|
} |
|
913
|
|
|
).click( function( e ) { |
|
914
|
|
|
e.preventDefault(); |
|
915
|
|
|
$( this ).pointer( 'open' ); |
|
916
|
|
|
} ); |
|
917
|
|
|
}; |
|
918
|
|
|
$(document).ready( setup ); |
|
919
|
|
|
})(jQuery); |
|
920
|
|
|
</script> |
|
921
|
|
|
<?php |
|
922
|
|
|
} |
|
923
|
|
|
} |
|
924
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: