Completed
Push — add/blogname-locale-connect-ur... ( 948a6a...8e4901 )
by
unknown
30:01 queued 20:34
created

Sharing_Admin::output_service()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 15
rs 9.4285
cc 3
eloc 12
nc 2
nop 3
1
<?php
2
3
class Sharing_Admin {
4
	public function __construct() {
5
		if ( !defined( 'WP_SHARING_PLUGIN_URL' ) ) {
6
			define( 'WP_SHARING_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
7
			define( 'WP_SHARING_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
8
		}
9
10
		require_once WP_SHARING_PLUGIN_DIR.'sharing-service.php';
11
12
		add_action( 'admin_init', array( &$this, 'admin_init' ) );
13
		add_action( 'admin_menu', array( &$this, 'subscription_menu' ) );
14
15
		// Insert our CSS and JS
16
		add_action( 'load-settings_page_sharing', array( &$this, 'sharing_head' ) );
17
18
		// Catch AJAX
19
		add_action( 'wp_ajax_sharing_save_services', array( &$this, 'ajax_save_services' ) );
20
		add_action( 'wp_ajax_sharing_save_options', array( &$this, 'ajax_save_options' ) );
21
		add_action( 'wp_ajax_sharing_new_service', array( &$this, 'ajax_new_service' ) );
22
		add_action( 'wp_ajax_sharing_delete_service', array( &$this, 'ajax_delete_service' ) );
23
	}
24
25
	public function sharing_head() {
26
		wp_enqueue_script( 'sharing-js', WP_SHARING_PLUGIN_URL.'admin-sharing.js', array( 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-sortable', 'jquery-form' ), 2 );
27
		wp_enqueue_style( 'sharing-admin', WP_SHARING_PLUGIN_URL.'admin-sharing.css', false, JETPACK__VERSION );
28
		wp_enqueue_style( 'sharing', WP_SHARING_PLUGIN_URL.'sharing.css', false, JETPACK__VERSION );
29
		wp_enqueue_style( 'genericons' );
30
		wp_enqueue_script( 'sharing-js-fe', WP_SHARING_PLUGIN_URL . 'sharing.js', array( ), 4 );
31
32
		add_thickbox();
33
	}
34
35
	public function admin_init() {
36
		if ( isset( $_GET['page'] ) && ( $_GET['page'] == 'sharing.php' || $_GET['page'] == 'sharing' ) )
37
			$this->process_requests();
38
	}
39
40
	public function process_requests() {
41
		if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) ) {
42
			$sharer = new Sharing_Service();
43
			$sharer->set_global_options( $_POST );
44
			/**
45
			 * Fires when updating sharing settings.
46
			 *
47
			 * @module sharedaddy
48
			 *
49
			 * @since 1.1.0
50
			 */
51
			do_action( 'sharing_admin_update' );
52
53
			wp_safe_redirect( admin_url( 'options-general.php?page=sharing&update=saved' ) );
54
			die();
0 ignored issues
show
Coding Style Compatibility introduced by
The method process_requests() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
55
		}
56
	}
57
58
	public function subscription_menu( $user ) {
0 ignored issues
show
Unused Code introduced by
The parameter $user is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
		if ( !defined( 'IS_WPCOM' ) || !IS_WPCOM ) {
60
			$active = Jetpack::get_active_modules();
61
			if ( !in_array( 'publicize', $active ) && !current_user_can( 'manage_options' ) )
62
				return;
63
		}
64
65
		add_submenu_page( 'options-general.php', __( 'Sharing Settings', 'jetpack' ), __( 'Sharing', 'jetpack' ), 'publish_posts', 'sharing', array( &$this, 'management_page' ) );
66
	}
67
68
	public function ajax_save_services() {
69
		if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options' ) && isset( $_POST['hidden'] ) && isset( $_POST['visible'] ) ) {
70
			$sharer = new Sharing_Service();
71
72
			$sharer->set_blog_services( explode( ',', $_POST['visible'] ), explode( ',', $_POST['hidden'] ) );
73
			die();
0 ignored issues
show
Coding Style Compatibility introduced by
The method ajax_save_services() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
74
		}
75
	}
76
77
	public function ajax_new_service() {
78
		if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['sharing_name'] ) && isset( $_POST['sharing_url'] ) && isset( $_POST['sharing_icon'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-new_service' ) ) {
79
			$sharer = new Sharing_Service();
80
			if ( $service = $sharer->new_service( stripslashes( $_POST['sharing_name'] ), stripslashes( $_POST['sharing_url'] ), stripslashes( $_POST['sharing_icon'] ) ) ) {
81
				$this->output_service( $service->get_id(), $service );
82
				echo '<!--->';
83
				$service->button_style = 'icon-text';
84
				$this->output_preview( $service );
85
86
				die();
0 ignored issues
show
Coding Style Compatibility introduced by
The method ajax_new_service() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
87
			}
88
		}
89
90
		// Fail
91
		die( '1' );
0 ignored issues
show
Coding Style Compatibility introduced by
The method ajax_new_service() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
92
	}
93
94
	public function ajax_delete_service() {
95
		if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['service'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options_'.$_POST['service'] ) ) {
96
			$sharer = new Sharing_Service();
97
			$sharer->delete_service( $_POST['service'] );
98
		}
99
	}
100
101
	public function ajax_save_options() {
102
		if ( isset( $_POST['_wpnonce'] ) && isset( $_POST['service'] ) && wp_verify_nonce( $_POST['_wpnonce'], 'sharing-options_'.$_POST['service'] ) ) {
103
			$sharer = new Sharing_Service();
104
			$service = $sharer->get_service( $_POST['service'] );
105
106
			if ( $service && $service instanceof Sharing_Advanced_Source ) {
107
				$service->update_options( $_POST );
108
109
				$sharer->set_service( $_POST['service'], $service );
110
			}
111
112
			$this->output_service( $service->get_id(), $service, true );
113
			echo '<!--->';
114
			$service->button_style = 'icon-text';
115
			$this->output_preview( $service );
116
			die();
0 ignored issues
show
Coding Style Compatibility introduced by
The method ajax_save_options() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
117
		}
118
	}
119
120
	public function output_preview( $service ) {
121
		$klasses = array( 'advanced', 'preview-item' );
122
123
		if ( $service->button_style != 'text' || $service->has_custom_button_style() ) {
124
			$klasses[] = 'preview-'.$service->get_class();
125
			$klasses[] = 'share-'.$service->get_class();
126
127
			if ( $service->get_class() != $service->get_id() )
128
				$klasses[] = 'preview-'.$service->get_id();
129
		}
130
131
		echo '<li class="'.implode( ' ', $klasses ).'">';
132
		$service->display_preview();
133
		echo '</li>';
134
	}
135
136
	public function output_service( $id, $service, $show_dropdown = false ) {
0 ignored issues
show
Unused Code introduced by
The parameter $show_dropdown is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
137
?>
138
	<li class="service advanced share-<?php echo $service->get_class(); ?>" id="<?php echo $service->get_id(); ?>" tabindex="0">
139
		<span class="options-left"><?php echo esc_html( $service->get_name() ); ?></span>
140
		<?php if ( 0 === strpos( $service->get_id(), 'custom-' ) || $service->has_advanced_options() ) : ?>
141
		<span class="close"><a href="#" class="remove">&times;</a></span>
142
		<form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>">
143
			<input type="hidden" name="action" value="sharing_delete_service" />
144
			<input type="hidden" name="service" value="<?php echo esc_attr( $id ); ?>" />
145
			<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options_'.$id );?>" />
146
		</form>
147
		<?php endif; ?>
148
	</li>
149
<?php
150
	}
151
152
	public function management_page() {
153
		$sharer  = new Sharing_Service();
154
		$enabled = $sharer->get_blog_services();
155
		$global  = $sharer->get_global_options();
156
157
		$shows = array_values( get_post_types( array( 'public' => true ) ) );
158
		array_unshift( $shows, 'index' );
159
160
		if ( false == function_exists( 'mb_stripos' ) ) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
161
			echo '<div id="message" class="updated fade"><h3>' . __( 'Warning! Multibyte support missing!', 'jetpack' ) . '</h3>';
162
			echo "<p>" . sprintf( __( 'This plugin will work without it, but multibyte support is used <a href="%s" target="_blank">if available</a>. You may see minor problems with Tweets and other sharing services.', 'jetpack' ), "http://www.php.net/manual/en/mbstring.installation.php" ) . '</p></div>';
163
		}
164
165
		if ( isset( $_GET['update'] ) && $_GET['update'] == 'saved' )
166
			echo '<div class="updated"><p>'.__( 'Settings have been saved', 'jetpack' ).'</p></div>';
167
168
		if( ! isset( $global['sharing_label'] ) ) {
169
			$global['sharing_label'] = __( 'Share this:', 'jetpack' );
170
		}
171
?>
172
173
	<div class="wrap">
174
		<div class="icon32" id="icon-options-general"><br /></div>
175
		<h1><?php _e( 'Sharing Settings', 'jetpack' ); ?></h1>
176
177
		<?php
178
		/**
179
		 * Fires at the top of the admin sharing settings screen.
180
		 *
181
		 * @module sharedaddy
182
		 *
183
		 * @since 1.6.0
184
		 */
185
		do_action( 'pre_admin_screen_sharing' );
186
		?>
187
188
		<?php if ( current_user_can( 'manage_options' ) ) : ?>
189
190
		<div class="share_manage_options">
191
		<h2><?php _e( 'Sharing Buttons', 'jetpack' ) ?></h2>
192
		<p><?php _e( 'Add sharing buttons to your blog and allow your visitors to share posts with their friends.', 'jetpack' ) ?></p>
193
194
		<div id="services-config">
195
			<table id="available-services">
196
					<tr>
197
					<td class="description">
198
						<h3><?php _e( 'Available Services', 'jetpack' ); ?></h3>
199
						<p><?php _e( "Drag and drop the services you'd like to enable into the box below.", 'jetpack' ); ?></p>
200
						<p><a href="#TB_inline?height=395&amp;width=600&amp;inlineId=new-service" class="thickbox" id="add-a-new-service"><?php _e( 'Add a new service', 'jetpack' ); ?></a></p>
201
					</td>
202
					<td class="services">
203
						<ul class="services-available" style="height: 100px;">
204
							<?php foreach ( $sharer->get_all_services_blog() AS $id => $service ) : ?>
205
								<?php
206
									if ( !isset( $enabled['all'][$id] ) )
207
											$this->output_service( $id, $service );
208
									?>
209
							<?php endforeach; ?>
210
						</ul>
211
						<?php
212
							if ( -1 == get_option( 'blog_public' ) )
213
								echo '<p><strong>'.__( 'Please note that your services have been restricted because your site is private.', 'jetpack' ).'</strong></p>';
214
						?>
215
						<br class="clearing" />
216
					</td>
217
					</tr>
218
			</table>
219
220
			<table id="enabled-services">
221
				<tr>
222
					<td class="description">
223
						<h3>
224
							<?php _e( 'Enabled Services', 'jetpack' ); ?>
225
							<img src="<?php echo admin_url( 'images/loading.gif' ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
226
						</h3>
227
						<p><?php _e( 'Services dragged here will appear individually.', 'jetpack' ); ?></p>
228
					</td>
229
					<td class="services" id="share-drop-target">
230
							<h2 id="drag-instructions" <?php if ( count( $enabled['visible'] ) > 0 ) echo ' style="display: none"'; ?>><?php _e( 'Drag and drop available services here.', 'jetpack' ); ?></h2>
231
232
								<ul class="services-enabled">
233
									<?php foreach ( $enabled['visible'] as $id => $service ) : ?>
234
										<?php $this->output_service( $id, $service, true ); ?>
235
									<?php endforeach; ?>
236
237
									<li class="end-fix"></li>
238
								</ul>
239
					</td>
240
					<td id="hidden-drop-target" class="services">
241
							<p><?php _e( 'Services dragged here will be hidden behind a share button.', 'jetpack' ); ?></p>
242
243
							<ul class="services-hidden">
244
									<?php foreach ( $enabled['hidden'] as $id => $service ) : ?>
245
										<?php $this->output_service( $id, $service, true ); ?>
246
									<?php endforeach; ?>
247
									<li class="end-fix"></li>
248
							</ul>
249
					</td>
250
				</tr>
251
			</table>
252
253
			<table id="live-preview">
254
				<tr>
255
					<td class="description">
256
						<h3><?php _e( 'Live Preview', 'jetpack' ); ?></h3>
257
					</td>
258
					<td class="services">
259
						<h2<?php if ( count( $enabled['all'] ) > 0 ) echo ' style="display: none"'; ?>><?php _e( 'Sharing is off. Add services above to enable.', 'jetpack' ); ?></h2>
260
						<div class="sharedaddy sd-sharing-enabled">
261
							<?php if ( count( $enabled['all'] ) > 0 ) : ?>
262
							<h3 class="sd-title"><?php echo esc_html( $global['sharing_label'] ); ?></h3>
263
							<?php endif; ?>
264
							<div class="sd-content">
265
								<ul class="preview">
266
									<?php foreach ( $enabled['visible'] as $id => $service ) : ?>
267
										<?php $this->output_preview( $service ); ?>
268
									<?php endforeach; ?>
269
270
									<?php if ( count( $enabled['hidden'] ) > 0 ) : ?>
271
									<li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php _e( 'More', 'jetpack' ); ?></span></a></li>
272
									<?php endif; ?>
273
								</ul>
274
275
								<?php if ( count( $enabled['hidden'] ) > 0 ) : ?>
276
								<div class="sharing-hidden">
277
									<div class="inner" style="display: none; <?php echo count( $enabled['hidden'] ) == 1 ? 'width:150px;' : ''; ?>">
278
									<?php if ( count( $enabled['hidden'] ) == 1 ) : ?>
279
										<ul style="background-image:none;">
280
									<?php else: ?>
281
										<ul>
282
									<?php endif; ?>
283
284
									<?php foreach ( $enabled['hidden'] as $id => $service ) {
285
											$this->output_preview( $service );
286
										}?>
287
										</ul>
288
									</div>
289
								</div>
290
								<?php endif; ?>
291
292
								<ul class="archive" style="display:none;">
293
								<?php
294
									foreach ( $sharer->get_all_services_blog() as $id => $service ) :
295
										if ( isset( $enabled['visible'][$id] ) )
296
											$service = $enabled['visible'][$id];
297
										elseif ( isset( $enabled['hidden'][$id] ) )
298
											$service = $enabled['hidden'][$id];
299
300
										$service->button_style = 'icon-text';   // The archive needs the full text, which is removed in JS later
301
										$service->smart = false;
302
										$this->output_preview( $service );
303
									endforeach; ?>
304
									<li class="advanced"><a href="#" class="sharing-anchor sd-button share-more"><span><?php _e( 'More', 'jetpack' ); ?></span></a></li>
305
								</ul>
306
							</div>
307
						</div>
308
						<br class="clearing" />
309
					</td>
310
				</tr>
311
			</table>
312
313
				<form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="save-enabled-shares">
314
					<input type="hidden" name="action" value="sharing_save_services" />
315
					<input type="hidden" name="visible" value="<?php echo implode( ',', array_keys( $enabled['visible'] ) ); ?>" />
316
					<input type="hidden" name="hidden" value="<?php echo implode( ',', array_keys( $enabled['hidden'] ) ); ?>" />
317
					<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options' );?>" />
318
				</form>
319
		</div>
320
321
		<form method="post" action="">
322
			<table class="form-table">
323
				<tbody>
324
					<tr valign="top">
325
						<th scope="row"><label><?php _e( 'Button style', 'jetpack' ); ?></label></th>
326
						<td>
327
							<select name="button_style" id="button_style">
328
								<option<?php if ( $global['button_style'] == 'icon-text' ) echo ' selected="selected"';?> value="icon-text"><?php _e( 'Icon + text', 'jetpack' ); ?></option>
329
								<option<?php if ( $global['button_style'] == 'icon' ) echo ' selected="selected"';?> value="icon"><?php _e( 'Icon only', 'jetpack' ); ?></option>
330
								<option<?php if ( $global['button_style'] == 'text' ) echo ' selected="selected"';?> value="text"><?php _e( 'Text only', 'jetpack' ); ?></option>
331
								<option<?php if ( $global['button_style'] == 'official' ) echo ' selected="selected"';?> value="official"><?php _e( 'Official buttons', 'jetpack' ); ?></option>
332
							</select>
333
						</td>
334
					</tr>
335
					<tr valign="top">
336
						<th scope="row"><label><?php _e( 'Sharing label', 'jetpack' ); ?></label></th>
337
						<td>
338
							<input type="text" name="sharing_label" value="<?php echo esc_attr( $global['sharing_label'] ); ?>" />
339
						</td>
340
					</tr>
341
					<?php
342
					/**
343
					* Filters the HTML at the beginning of the "Show button on" row.
344
					*
345
					* @module sharedaddy
346
					*
347
					* @since 2.1.0
348
					*
349
					* @param string $var Opening HTML tag at the beginning of the "Show button on" row.
350
					*/
351
					echo apply_filters( 'sharing_show_buttons_on_row_start', '<tr valign="top">' );
352
					?>
353
						<th scope="row"><label><?php _e( 'Show buttons on', 'jetpack' ); ?></label></th>
354
						<td>
355
						<?php
356
							$br = false;
357 View Code Duplication
							foreach ( $shows as $show ) :
358
								if ( 'index' == $show ) {
359
									$label = __( 'Front Page, Archive Pages, and Search Results', 'jetpack' );
360
								} else {
361
									$post_type_object = get_post_type_object( $show );
362
									$label = $post_type_object->labels->name;
363
								}
364
						?>
365
							<?php if ( $br ) echo '<br />'; ?><label><input type="checkbox"<?php checked( in_array( $show, $global['show'] ) ); ?> name="show[]" value="<?php echo esc_attr( $show ); ?>" /> <?php echo esc_html( $label ); ?></label>
366
						<?php	$br = true; endforeach; ?>
0 ignored issues
show
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
367
						</td>
368
					<?php
369
					/**
370
					 * Filters the HTML at the end of the "Show button on" row.
371
					 *
372
					 * @module sharedaddy
373
					 *
374
					 * @since 2.1.0
375
					 *
376
					 * @param string $var Closing HTML tag at the end of the "Show button on" row.
377
					 */
378
					echo apply_filters( 'sharing_show_buttons_on_row_end', '</tr>' );
379
					?>
380
381
					<?php
382
					/**
383
					 * Fires at the end of the sharing global options settings table.
384
					 *
385
					 * @module sharedaddy
386
					 *
387
					 * @since 1.1.0
388
					 */
389
					do_action( 'sharing_global_options' );
390
					?>
391
				</tbody>
392
			</table>
393
394
			<p class="submit">
395
					<input type="submit" name="submit" class="button-primary" value="<?php _e( 'Save Changes', 'jetpack' ); ?>" />
396
			</p>
397
398
				<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-options' );?>" />
399
		</form>
400
401
	<div id="new-service" style="display: none">
402
		<form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="new-service-form">
403
			<table class="form-table">
404
				<tbody>
405
					<tr valign="top">
406
						<th scope="row" width="100"><label><?php _e( 'Service name', 'jetpack' ); ?></label></th>
407
						<td>
408
							<input type="text" name="sharing_name" id="new_sharing_name" size="40" />
409
						</td>
410
					</tr>
411
					<tr valign="top">
412
						<th scope="row" width="100"><label><?php _e( 'Sharing URL', 'jetpack' ); ?></label></th>
413
						<td>
414
							<input type="text" name="sharing_url" id="new_sharing_url" size="40" />
415
416
							<p><?php _e( 'You can add the following variables to your service sharing URL:', 'jetpack' ); ?><br/>
417
							<code>%post_title%</code>, <code>%post_url%</code>, <code>%post_full_url%</code>, <code>%post_excerpt%</code>, <code>%post_tags%</code></p>
418
						</td>
419
					</tr>
420
					<tr valign="top">
421
						<th scope="row" width="100"><label><?php _e( 'Icon URL', 'jetpack' ); ?></label></th>
422
						<td>
423
							<input type="text" name="sharing_icon" id="new_sharing_icon" size="40" />
424
							<p><?php _e( 'Enter the URL of a 16x16px icon you want to use for this service.', 'jetpack' ); ?></p>
425
						</td>
426
					</tr>
427
					<tr valign="top" width="100">
428
						<th scope="row"></th>
429
						<td>
430
								<input type="submit" class="button-primary" value="<?php _e( 'Create Share Button', 'jetpack' ); ?>" />
431
							<img src="<?php echo admin_url( 'images/loading.gif' ); ?>" width="16" height="16" alt="loading" style="vertical-align: middle; display: none" />
432
						</td>
433
					</tr>
434
435
					<?php
436
					/**
437
					 * Fires after the custom sharing service form
438
					 *
439
					 * @module sharedaddy
440
					 *
441
					 * @since 1.1.0
442
					*/
443
					do_action( 'sharing_new_service_form' );
444
					?>
445
				</tbody>
446
			</table>
447
448
		<?php
449
		/**
450
		 * Fires at the bottom of the admin sharing settings screen.
451
		 *
452
		 * @module sharedaddy
453
		 *
454
		 * @since 1.6.0
455
		 */
456
		do_action( 'post_admin_screen_sharing' );
457
		?>
458
459
				<div class="inerror" style="display: none; margin-top: 15px">
460
					<p><?php _e( 'An error occurred creating your new sharing service - please check you gave valid details.', 'jetpack' ); ?></p>
461
				</div>
462
463
			<input type="hidden" name="action" value="sharing_new_service" />
464
			<input type="hidden" name="_wpnonce" value="<?php echo wp_create_nonce( 'sharing-new_service' );?>" />
465
		</form>
466
	</div>
467
	</div>
468
469
	<?php endif; ?>
470
471
472
	</div>
473
474
	<script type="text/javascript">
475
		var sharing_loading_icon = '<?php echo esc_js( admin_url( "/images/loading.gif" ) ); ?>';
476
		<?php if ( isset( $_GET['create_new_service'] ) && 'true' == $_GET['create_new_service'] ) : ?>
477
		jQuery(document).ready(function() {
478
			// Prefill new service box and then open it
479
			jQuery( '#new_sharing_name' ).val( '<?php echo esc_js( $_GET['name'] ); ?>' );
480
			jQuery( '#new_sharing_url' ).val( '<?php echo esc_js( $_GET['url'] ); ?>' );
481
			jQuery( '#new_sharing_icon' ).val( '<?php echo esc_js( $_GET['icon'] ); ?>' );
482
			jQuery( '#add-a-new-service' ).click();
483
		});
484
		<?php endif; ?>
485
	</script>
486
<?php
487
	}
488
}
489
490
function sharing_admin_init() {
491
	global $sharing_admin;
492
493
	$sharing_admin = new Sharing_Admin();
494
}
495
496
add_action( 'init', 'sharing_admin_init' );
497